diff options
| author | 2023-12-11 10:30:28 +0000 | |
|---|---|---|
| committer | 2023-12-11 10:30:28 +0000 | |
| commit | 79f7fe1c5ad98398b2bc6442844cec73f7e8c855 (patch) | |
| tree | 810f2d08511ee9925e38a9d8c3e5466d7fbcad04 | |
| parent | c7faccbdbdae750779b2cf5bc70de3c8a95e2a94 (diff) | |
| parent | ae1a50d3266dcc2a4aff8140be4ab7264026c67a (diff) | |
Merge "Update title, message, positive button strings in uninstall confirmation dialog when archiving an app" into main
| -rw-r--r-- | packages/PackageInstaller/res/values/strings.xml | 14 | ||||
| -rw-r--r-- | packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java | 45 |
2 files changed, 44 insertions, 15 deletions
diff --git a/packages/PackageInstaller/res/values/strings.xml b/packages/PackageInstaller/res/values/strings.xml index 1c8a8d5771d9..e3b93ba34045 100644 --- a/packages/PackageInstaller/res/values/strings.xml +++ b/packages/PackageInstaller/res/values/strings.xml @@ -85,6 +85,8 @@ <!-- [CHAR LIMIT=15] --> <string name="ok">OK</string> + <!-- Confirmation text label for button to archive an application. Archiving means uninstalling the app without deleting user's personal data and replacing the app with a stub app with minimum size. So, the user can unarchive the app later and not lose any personal data. --> + <string name="archive">Archive</string> <!-- [CHAR LIMIT=30] --> <string name="update_anyway">Update anyway</string> <!-- [CHAR LIMIT=15] --> @@ -115,6 +117,16 @@ <!-- [CHAR LIMIT=none] --> <string name="uninstall_application_text">Do you want to uninstall this app?</string> <!-- [CHAR LIMIT=none] --> + <string name="archive_application_text">Your personal data will be saved</string> + <!-- [CHAR LIMIT=none] --> + <string name="archive_application_text_all_users">Archive this app for all users? Your personal data will be saved</string> + <!-- [CHAR LIMIT=none] --> + <string name="archive_application_text_current_user_work_profile">Archive this app on your work profile? Your personal data will be saved</string> + <!-- [CHAR LIMIT=none] --> + <string name="archive_application_text_user">Archive this app for <xliff:g id="username">%1$s</xliff:g>? Your personal data will be saved</string> + <!-- [CHAR LIMIT=none] --> + <string name="archive_application_text_current_user_private_profile">Do you want to archive this app from your private space? Your personal data will be saved</string> + <!-- [CHAR LIMIT=none] --> <string name="uninstall_application_text_all_users">Do you want to uninstall this app for <b>all</b> users? The application and its data will be removed from <b>all</b> users on the device.</string> <!-- [CHAR LIMIT=none] --> @@ -239,6 +251,8 @@ <!-- Label for cloned app in uninstall dialogue [CHAR LIMIT=40] --> <string name="cloned_app_label"><xliff:g id="package_label">%1$s</xliff:g> Clone</string> + <!-- Label for archiving an app in uninstall dialogue --> + <string name="archiving_app_label">Archive <xliff:g id="package_label">%1$s</xliff:g>?</string> <!-- Label for button to continue install of an app whose source cannot be identified [CHAR LIMIT=40] --> <string name="anonymous_source_continue">Continue</string> diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java b/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java index e8890504f622..e07e9425808e 100644 --- a/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java +++ b/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java @@ -130,6 +130,9 @@ public class UninstallAlertDialogFragment extends DialogFragment implements final boolean isUpdate = ((dialogInfo.appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0); + final boolean isArchive = + android.content.pm.Flags.archiving() && ( + (dialogInfo.deleteFlags & PackageManager.DELETE_ARCHIVE) != 0); final UserHandle myUserHandle = Process.myUserHandle(); UserManager userManager = getContext().getSystemService(UserManager.class); if (isUpdate) { @@ -140,7 +143,9 @@ public class UninstallAlertDialogFragment extends DialogFragment implements } } else { if (dialogInfo.allUsers && !isSingleUser(userManager)) { - messageBuilder.append(getString(R.string.uninstall_application_text_all_users)); + messageBuilder.append( + isArchive ? getString(R.string.archive_application_text_all_users) + : getString(R.string.uninstall_application_text_all_users)); } else if (!dialogInfo.user.equals(myUserHandle)) { int userId = dialogInfo.user.getIdentifier(); UserManager customUserManager = getContext() @@ -150,9 +155,11 @@ public class UninstallAlertDialogFragment extends DialogFragment implements if (customUserManager.isUserOfType(USER_TYPE_PROFILE_MANAGED) && customUserManager.isSameProfileGroup(dialogInfo.user, myUserHandle)) { - messageBuilder.append( - getString(R.string.uninstall_application_text_current_user_work_profile, - userName)); + messageBuilder.append(isArchive + ? getString(R.string.archive_application_text_current_user_work_profile, + userName) : getString( + R.string.uninstall_application_text_current_user_work_profile, + userName)); } else if (customUserManager.isUserOfType(USER_TYPE_PROFILE_CLONE) && customUserManager.isSameProfileGroup(dialogInfo.user, myUserHandle)) { mIsClonedApp = true; @@ -161,9 +168,14 @@ public class UninstallAlertDialogFragment extends DialogFragment implements } else if (Flags.allowPrivateProfile() && customUserManager.isPrivateProfile() && customUserManager.isSameProfileGroup(dialogInfo.user, myUserHandle)) { - messageBuilder.append(getString( + messageBuilder.append(isArchive ? getString( + R.string.archive_application_text_current_user_private_profile, + userName) : getString( R.string.uninstall_application_text_current_user_private_profile, userName)); + } else if (isArchive) { + messageBuilder.append( + getString(R.string.archive_application_text_user, userName)); } else { messageBuilder.append( getString(R.string.uninstall_application_text_user, userName)); @@ -172,24 +184,27 @@ public class UninstallAlertDialogFragment extends DialogFragment implements mIsClonedApp = true; messageBuilder.append(getString( R.string.uninstall_application_text_current_user_clone_profile)); + } else if (Process.myUserHandle().equals(UserHandle.SYSTEM) + && hasClonedInstance(dialogInfo.appInfo.packageName)) { + messageBuilder.append(getString( + R.string.uninstall_application_text_with_clone_instance, + appLabel)); + } else if (isArchive) { + messageBuilder.append(getString(R.string.archive_application_text)); } else { - if (Process.myUserHandle().equals(UserHandle.SYSTEM) - && hasClonedInstance(dialogInfo.appInfo.packageName)) { - messageBuilder.append(getString( - R.string.uninstall_application_text_with_clone_instance, - appLabel)); - } else { - messageBuilder.append(getString(R.string.uninstall_application_text)); - } + messageBuilder.append(getString(R.string.uninstall_application_text)); } } if (mIsClonedApp) { dialogBuilder.setTitle(getString(R.string.cloned_app_label, appLabel)); + } else if (isArchive) { + dialogBuilder.setTitle(getString(R.string.archiving_app_label, appLabel)); } else { dialogBuilder.setTitle(appLabel); } - dialogBuilder.setPositiveButton(android.R.string.ok, this); + dialogBuilder.setPositiveButton(isArchive ? R.string.archive : android.R.string.ok, + this); dialogBuilder.setNegativeButton(android.R.string.cancel, this); String pkg = dialogInfo.appInfo.packageName; @@ -199,7 +214,7 @@ public class UninstallAlertDialogFragment extends DialogFragment implements PackageInfo pkgInfo = pm.getPackageInfo(pkg, PackageManager.PackageInfoFlags.of(PackageManager.MATCH_ARCHIVED_PACKAGES)); - suggestToKeepAppData = pkgInfo.applicationInfo.hasFragileUserData(); + suggestToKeepAppData = pkgInfo.applicationInfo.hasFragileUserData() && !isArchive; } catch (PackageManager.NameNotFoundException e) { Log.e(LOG_TAG, "Cannot check hasFragileUserData for " + pkg, e); suggestToKeepAppData = false; |