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

Commit 03a3b6a4 authored by Joanne Chung's avatar Joanne Chung
Browse files

Finish PIA if UnknownSourcesListener would like to start a PIA again

when starting PIA in UnknownSourcesListener, the start flags we used
doesn't work for multiple user case, it will cause the two APIs in
the task. Because the caller may use startActivityForResult, it makes
the PackageInstaller cannot in the seperate task to resolve the
above limitation. To avoid multiple PIAs in the task, PIA will finish
itself if UnknownSourcesListener would like to start a PIA again.

Bug: 202942446
Test: atest CtsPackageInstallTestCases
Test: manual. The issue flow is resolved.
Test: manual. Normal install flow that will trigger unknown source
flow.

Change-Id: Icfce5b79b1cf356015b908f5c3ac44a488707dd7
parent d2522efd
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@
*/
package com.android.packageinstaller;

import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_NO_HISTORY;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.Manifest;
@@ -808,8 +806,12 @@ public class PackageInstallerActivity extends AlertActivity {
            }
            new Handler(Looper.getMainLooper()).postDelayed(() -> {
                if (!isDestroyed()) {
                    startActivity(getIntent().addFlags(
                            FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP));
                    // The start flag (FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP) doesn't
                    // work for the multiple user case, i.e. the caller task user and started
                    // Activity user are not the same. To avoid having multiple PIAs in the task,
                    // finish the current PackageInstallerActivity
                    finish();
                    startActivity(getIntent());
                }
            }, 500);