Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fcab4dc authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I71a625e9,Id8eb952c,If37d6502 into main

* changes:
  Migrate Unarchive Error to Pia V2
  Migrate Unarchival to Pia V2
  Foundation for Unarchival in Pia V2
parents 7a5a527e d7a7d53a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -175,6 +175,11 @@
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".v2.ui.UnarchiveLaunch"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:theme="@style/Theme.AlertDialogActivity"
            android:exported="false"/>
    </application>

</manifest>
+6 −17
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
package com.android.packageinstaller;

import static android.content.pm.Flags.usePiaV2;

import static com.android.packageinstaller.PackageUtil.getMaxTargetSdkVersionForUid;
import static com.android.packageinstaller.PackageUtil.getReasonForDebug;

import android.Manifest;
import android.app.Activity;
@@ -41,8 +43,11 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;

import androidx.annotation.Nullable;

import com.android.packageinstaller.v2.ui.InstallLaunch;

import java.util.Arrays;

/**
@@ -69,7 +74,7 @@ public class InstallStart extends Activity {
        boolean usePiaV2aConfig = usePiaV2();

        if (usePiaV2aConfig || testOverrideForPiaV2) {
            logReasonForDebug(usePiaV2aConfig, testOverrideForPiaV2);
            Log.d(TAG, getReasonForDebug(usePiaV2aConfig, testOverrideForPiaV2));

            Intent piaV2 = new Intent(getIntent());
            piaV2.putExtra(InstallLaunch.EXTRA_CALLING_PKG_NAME, getLaunchedFromPackage());
@@ -398,20 +403,4 @@ public class InstallStart extends Activity {
        }
        return null;
    }

    private void logReasonForDebug(boolean usePiaV2aConfig, boolean testOverrideForPiaV2) {
        StringBuilder sb = new StringBuilder("Using Pia V2 due to: ");
        boolean aconfigUsed = false;
        if (usePiaV2aConfig) {
            sb.append("aconfig flag USE_PIA_V2");
            aconfigUsed = true;
        }
        if (testOverrideForPiaV2) {
            if (aconfigUsed) {
                sb.append(" and ");
            }
            sb.append("testOverrideForPiaV2.");
        }
        Log.i(TAG, sb.toString());
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -401,4 +401,23 @@ public class PackageUtil {
        }
        return null;
    }

    /**
     * Returns a string containing the reason for using Pia V2. Used for debugging purposes
     */
    public static String getReasonForDebug(boolean usePiaV2aConfig, boolean testOverrideForPiaV2) {
        StringBuilder sb = new StringBuilder("Using Pia V2 due to: ");
        boolean aconfigUsed = false;
        if (usePiaV2aConfig) {
            sb.append("aconfig flag USE_PIA_V2");
            aconfigUsed = true;
        }
        if (testOverrideForPiaV2) {
            if (aconfigUsed) {
                sb.append(" and ");
            }
            sb.append("testOverrideForPiaV2.");
        }
        return sb.toString();
    }
}
+24 −0
Original line number Diff line number Diff line
@@ -17,25 +17,32 @@
package com.android.packageinstaller;

import static android.Manifest.permission;
import static android.content.pm.Flags.usePiaV2;
import static android.content.pm.PackageManager.GET_PERMISSIONS;
import static android.content.pm.PackageManager.MATCH_ARCHIVED_PACKAGES;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import static com.android.packageinstaller.PackageUtil.getReasonForDebug;

import android.app.Activity;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.InstallSourceInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Process;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.NonNull;

import com.android.packageinstaller.v2.ui.UnarchiveLaunch;

import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
@@ -58,6 +65,23 @@ public class UnarchiveActivity extends Activity {

        super.onCreate(null);

        boolean testOverrideForPiaV2 = Settings.System.getInt(getContentResolver(),
                "use_pia_v2", 0) == 1;
        boolean usePiaV2aConfig = usePiaV2();

        if (usePiaV2aConfig || testOverrideForPiaV2) {
            Log.d(TAG, getReasonForDebug(usePiaV2aConfig, testOverrideForPiaV2));

            Intent piaV2 = new Intent(getIntent());
            piaV2.putExtra(UnarchiveLaunch.EXTRA_CALLING_PKG_NAME, getLaunchedFromPackage());
            piaV2.putExtra(UnarchiveLaunch.EXTRA_CALLING_PKG_UID, getLaunchedFromUid());
            piaV2.setClass(this, UnarchiveLaunch.class);
            piaV2.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
            startActivity(piaV2);
            finish();
            return;
        }

        int callingUid = getLaunchedFromUid();
        if (callingUid == Process.INVALID_UID) {
            // Cannot reach Package/ActivityManager. Aborting uninstall.
+26 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

package com.android.packageinstaller;

import static android.content.pm.Flags.usePiaV2;

import static com.android.packageinstaller.PackageUtil.getReasonForDebug;

import android.app.Activity;
import android.app.DialogFragment;
import android.app.Fragment;
@@ -24,11 +28,16 @@ import android.app.PendingIntent;
import android.content.Intent;
import android.content.pm.PackageInstaller;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;

import com.android.packageinstaller.v2.ui.UnarchiveLaunch;

import java.util.Objects;

public class UnarchiveErrorActivity extends Activity {

    static final String LOG_TAG = UnarchiveErrorActivity.class.getSimpleName();
    static final String EXTRA_REQUIRED_BYTES =
            "com.android.content.pm.extra.UNARCHIVE_EXTRA_REQUIRED_BYTES";
    static final String EXTRA_INSTALLER_PACKAGE_NAME =
@@ -40,6 +49,23 @@ public class UnarchiveErrorActivity extends Activity {
    public void onCreate(Bundle icicle) {
        super.onCreate(null);

        boolean testOverrideForPiaV2 = Settings.System.getInt(getContentResolver(),
                "use_pia_v2", 0) == 1;
        boolean usePiaV2aConfig = usePiaV2();

        if (usePiaV2aConfig || testOverrideForPiaV2) {
            Log.d(LOG_TAG, getReasonForDebug(usePiaV2aConfig, testOverrideForPiaV2));

            Intent piaV2 = new Intent(getIntent());
            piaV2.putExtra(UnarchiveLaunch.EXTRA_CALLING_PKG_NAME, getLaunchedFromPackage());
            piaV2.putExtra(UnarchiveLaunch.EXTRA_CALLING_PKG_UID, getLaunchedFromUid());
            piaV2.setClass(this, UnarchiveLaunch.class);
            piaV2.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
            startActivity(piaV2);
            finish();
            return;
        }

        Bundle extras = getIntent().getExtras();
        int unarchivalStatus = extras.getInt(PackageInstaller.EXTRA_UNARCHIVE_STATUS);
        long requiredBytes = extras.getLong(EXTRA_REQUIRED_BYTES);
Loading