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

Commit e5ba94cf authored by Jakob Schneider's avatar Jakob Schneider Committed by Android (Google) Code Review
Browse files

Merge "Bugfix: set appIcon and appLabel fields on draft sessions created for unarchival." into main

parents 09d30a2b 285806a7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6434,4 +6434,6 @@ ul.</string>
    <string name="satellite_notification_open_message">Open Messages</string>
    <!-- Invoke Satellite setting activity of Settings -->
    <string name="satellite_notification_how_it_works">How it works</string>
    <!-- Initial/System provided label shown for an app which gets unarchived. [CHAR LIMIT=64]. -->
    <string name="unarchival_session_app_label">Pending...</string>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -5373,4 +5373,6 @@
  <java-symbol type="string" name="config_defaultContextualSearchKey" />
  <java-symbol type="string" name="config_defaultContextualSearchEnabled" />
  <java-symbol type="string" name="config_defaultContextualSearchLegacyEnabled" />

  <java-symbol type="string" name="unarchival_session_app_label" />
</resources>
+12 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static android.content.pm.PackageInstaller.UNARCHIVAL_STATUS_UNSET;
import static android.content.pm.PackageManager.DELETE_ALL_USERS;
import static android.content.pm.PackageManager.DELETE_ARCHIVE;
import static android.content.pm.PackageManager.DELETE_KEEP_DATA;
import static android.content.pm.PackageManager.INSTALL_UNARCHIVE;
import static android.content.pm.PackageManager.INSTALL_UNARCHIVE_DRAFT;
import static android.graphics.drawable.AdaptiveIconDrawable.getExtraInsetFraction;
import static android.os.PowerExemptionManager.REASON_PACKAGE_UNARCHIVE;
@@ -754,8 +755,9 @@ public class PackageArchiver {

        int draftSessionId;
        try {
            draftSessionId = Binder.withCleanCallingIdentity(() ->
                    createDraftSession(packageName, installerPackage, statusReceiver, userId));
            draftSessionId = Binder.withCleanCallingIdentity(
                    () -> createDraftSession(packageName, installerPackage, callerPackageName,
                            statusReceiver, userId));
        } catch (RuntimeException e) {
            if (e.getCause() instanceof IOException) {
                throw ExceptionUtils.wrap((IOException) e.getCause());
@@ -795,11 +797,18 @@ public class PackageArchiver {
    }

    private int createDraftSession(String packageName, String installerPackage,
            String callerPackageName,
            IntentSender statusReceiver, int userId) throws IOException {
        PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(
                PackageInstaller.SessionParams.MODE_FULL_INSTALL);
        sessionParams.setAppPackageName(packageName);
        sessionParams.installFlags = INSTALL_UNARCHIVE_DRAFT;
        sessionParams.setAppLabel(
                mContext.getString(com.android.internal.R.string.unarchival_session_app_label));
        sessionParams.setAppIcon(
                getArchivedAppIcon(packageName, UserHandle.of(userId), callerPackageName));
        // To make sure SessionInfo::isUnarchival returns true for draft sessions,
        // INSTALL_UNARCHIVE is also set.
        sessionParams.installFlags = (INSTALL_UNARCHIVE_DRAFT | INSTALL_UNARCHIVE);

        int installerUid = mPm.snapshotComputer().getPackageUid(installerPackage, 0, userId);
        // Handles case of repeated unarchival calls for the same package.