Merge "Add specific uninstall dialog string for work profile"

This commit is contained in:
TreeHugger Robot
2021-12-09 20:21:47 +00:00
committed by Android (Google) Code Review
3 changed files with 28 additions and 6 deletions

View File

@@ -112,6 +112,8 @@
<!-- [CHAR LIMIT=none] -->
<string name="uninstall_application_text_user">Do you want to uninstall this app for the user <xliff:g id="username">%1$s</xliff:g>?</string>
<!-- [CHAR LIMIT=none] -->
<string name="uninstall_application_text_current_user_work_profile">Do you want to uninstall this app from your work profile?</string>
<!-- [CHAR LIMIT=none] -->
<string name="uninstall_update_text">Replace this app with the factory version? All data will be removed.</string>
<!-- [CHAR LIMIT=none] -->
<string name="uninstall_update_text_multiuser">Replace this app with the factory version? All data will be removed. This affects all users of this device, including those with work profiles.</string>

View File

@@ -31,6 +31,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -125,6 +126,7 @@ public class UninstallAlertDialogFragment extends DialogFragment implements
final boolean isUpdate =
((dialogInfo.appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0);
final UserHandle myUserHandle = Process.myUserHandle();
UserManager userManager = UserManager.get(getActivity());
if (isUpdate) {
if (isSingleUser(userManager)) {
@@ -135,10 +137,17 @@ public class UninstallAlertDialogFragment extends DialogFragment implements
} else {
if (dialogInfo.allUsers && !isSingleUser(userManager)) {
messageBuilder.append(getString(R.string.uninstall_application_text_all_users));
} else if (!dialogInfo.user.equals(android.os.Process.myUserHandle())) {
} else if (!dialogInfo.user.equals(myUserHandle)) {
UserInfo userInfo = userManager.getUserInfo(dialogInfo.user.getIdentifier());
messageBuilder.append(
getString(R.string.uninstall_application_text_user, userInfo.name));
if (userInfo.isManagedProfile()
&& userInfo.profileGroupId == myUserHandle.getIdentifier()) {
messageBuilder.append(
getString(R.string.uninstall_application_text_current_user_work_profile,
userInfo.name));
} else {
messageBuilder.append(
getString(R.string.uninstall_application_text_user, userInfo.name));
}
} else {
messageBuilder.append(getString(R.string.uninstall_application_text));
}

View File

@@ -21,7 +21,10 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import androidx.leanback.app.GuidedStepFragment;
import androidx.leanback.widget.GuidanceStylist;
import androidx.leanback.widget.GuidedAction;
@@ -59,6 +62,7 @@ public class UninstallAlertFragment extends GuidedStepFragment {
final boolean isUpdate =
((dialogInfo.appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0);
final UserHandle myUserHandle = Process.myUserHandle();
UserManager userManager = UserManager.get(getActivity());
if (isUpdate) {
if (isSingleUser(userManager)) {
@@ -69,10 +73,17 @@ public class UninstallAlertFragment extends GuidedStepFragment {
} else {
if (dialogInfo.allUsers && !isSingleUser(userManager)) {
messageBuilder.append(getString(R.string.uninstall_application_text_all_users));
} else if (!dialogInfo.user.equals(android.os.Process.myUserHandle())) {
} else if (!dialogInfo.user.equals(myUserHandle)) {
UserInfo userInfo = userManager.getUserInfo(dialogInfo.user.getIdentifier());
messageBuilder.append(
getString(R.string.uninstall_application_text_user, userInfo.name));
if (userInfo.isManagedProfile()
&& userInfo.profileGroupId == myUserHandle.getIdentifier()) {
messageBuilder.append(
getString(R.string.uninstall_application_text_current_user_work_profile,
userInfo.name));
} else {
messageBuilder.append(
getString(R.string.uninstall_application_text_user, userInfo.name));
}
} else {
messageBuilder.append(getString(R.string.uninstall_application_text));
}