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

Commit 9f13b2f9 authored by Sumedh Sen's avatar Sumedh Sen
Browse files

Revert "Launching updated package after finishing package installer"

This reverts commit 791697e5.

Reason for revert: The original change along with ag/24499340 caused opening newly installed apps from Pia to fail.

ag/24499340 is required fix b/202942446 and thus, we cannot revert it. Due to this, PackageInstallerActivity.java is not changed in this revert, since it is already changed by ag/24499340.

Reverting the original change (ag/23468185) will not open an app after it updated itself. For this, while opening the newly installed app, FLAG_ACTIVITY_CLEAR_TOP is added in InstallSuccess.java. With this flag, if an app instance already exists in the stack, it will come to foreground, also closing Pia along the way (and also Settings - if appOp wasn't granted to the caller. [Only for self update case]).

Bug: 310263615
Bug: 282618106
Test: Manual. Perform repro steps in b/310263615#comment1
Test: Manual. Perform repro steps in b/282618106#comment1
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6f6037224566c80ad79bd193e3e2215b3df79349)

Change-Id: Ia5c5b462a9302ed7f7675d173a4399ff6b37d036
parent f9762576
Loading
Loading
Loading
Loading
+0 −5
Original line number Original line Diff line number Diff line
@@ -16,8 +16,6 @@


package com.android.packageinstaller;
package com.android.packageinstaller;


import static android.content.Intent.CATEGORY_LAUNCHER;

import static com.android.packageinstaller.PackageInstallerActivity.EXTRA_STAGED_SESSION_ID;
import static com.android.packageinstaller.PackageInstallerActivity.EXTRA_STAGED_SESSION_ID;


import android.app.Activity;
import android.app.Activity;
@@ -47,9 +45,6 @@ public class DeleteStagedFileOnResult extends Activity {
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        setResult(resultCode, data);
        setResult(resultCode, data);
        finish();
        finish();
        if (data != null && data.hasCategory(CATEGORY_LAUNCHER)) {
            startActivity(data);
        }
    }
    }


    @Override
    @Override
+7 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.packageinstaller;


import android.app.Activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
@@ -120,7 +121,12 @@ public class InstallSuccess extends Activity {
        Button launchButton = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
        Button launchButton = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
        if (enabled) {
        if (enabled) {
            launchButton.setOnClickListener(view -> {
            launchButton.setOnClickListener(view -> {
                setResult(Activity.RESULT_OK, mLaunchIntent);
                try {
                    startActivity(mLaunchIntent.addFlags(
                        Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP));
                } catch (ActivityNotFoundException | SecurityException e) {
                    Log.e(LOG_TAG, "Could not start activity", e);
                }
                finish();
                finish();
            });
            });
        } else {
        } else {