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

Commit 684cd544 authored by Rohit Goyal's avatar Rohit Goyal
Browse files

In case unarchival confirmation compat option is used, open app details page...

In case unarchival confirmation compat option is used, open app details page during ongoing unarchival.

Test: verified bugfixes locally.
Bug: 322021865

Change-Id: I789438949af04ac8cfd5692d6010617100cb2487
parent 5d261437
Loading
Loading
Loading
Loading
+40 −4
Original line number Diff line number Diff line
@@ -293,9 +293,26 @@ public class PackageArchiver {
            return START_PERMISSION_DENIED;
        }

        try {
            boolean openAppDetailsIfOngoingUnarchival = getAppOpsManager().checkOp(
                    AppOpsManager.OP_UNARCHIVAL_CONFIRMATION, callingUid, callerPackageName)
                    == MODE_ALLOWED;
            if (openAppDetailsIfOngoingUnarchival) {
                PackageInstaller.SessionInfo activeUnarchivalSession = getActiveUnarchivalSession(
                        packageName, userId);
                if (activeUnarchivalSession != null) {
                    mPm.mHandler.post(() -> {
                        Slog.i(TAG, "Opening app details page for ongoing unarchival of: "
                                + packageName);
                        getLauncherApps().startPackageInstallerSessionDetailsActivity(
                                activeUnarchivalSession, null, null);
                    });
                    return START_ABORTED;
                }
            }

            Slog.i(TAG, TextUtils.formatSimple("Unarchival is starting for: %s", packageName));

        try {
            requestUnarchive(packageName, callerPackageName,
                    getOrCreateLauncherListener(userId, packageName),
                    UserHandle.of(userId),
@@ -793,8 +810,27 @@ public class PackageArchiver {
            }
        }

        mPm.mHandler.post(
                () -> unarchiveInternal(packageName, userHandle, installerPackage, draftSessionId));
        mPm.mHandler.post(() -> {
            Slog.i(TAG, "Starting app unarchival for: " + packageName);
            unarchiveInternal(packageName, userHandle, installerPackage,
                    draftSessionId);
        });
    }

    @Nullable
    private PackageInstaller.SessionInfo getActiveUnarchivalSession(String packageName,
            int userId) {
        List<PackageInstaller.SessionInfo> activeSessions =
                mPm.mInstallerService.getAllSessions(userId).getList();
        for (int idx = 0; idx < activeSessions.size(); idx++) {
            PackageInstaller.SessionInfo activeSession = activeSessions.get(idx);
            if (activeSession.appPackageName.equals(packageName)
                    && activeSession.userId == userId && activeSession.active
                    && activeSession.isUnarchival()) {
                return activeSession;
            }
        }
        return null;
    }

    private void requestUnarchiveConfirmation(String packageName, IntentSender statusReceiver,