Merge "Allow Device Management Role Holder to update Settings strings."

This commit is contained in:
Jonathan Scott
2022-01-31 19:10:30 +00:00
committed by Android (Google) Code Review
55 changed files with 788 additions and 231 deletions

View File

@@ -219,7 +219,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
}
}
public static void startAppInfoFragment(Class<?> fragment, int titleRes,
public static void startAppInfoFragment(Class<?> fragment, String title,
String pkg, int uid, Fragment source, int request, int sourceMetricsCategory) {
final Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkg);
@@ -228,7 +228,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
new SubSettingLauncher(source.getContext())
.setDestination(fragment.getName())
.setSourceMetricsCategory(sourceMetricsCategory)
.setTitleRes(titleRes)
.setTitleText(title)
.setArguments(args)
.setUserHandle(new UserHandle(UserHandle.getUserId(uid)))
.setResultListener(source, request)

View File

@@ -211,7 +211,8 @@ public class AppsPreferenceController extends BasePreferenceController implement
pref.setOrder(showAppsCount++);
pref.setOnPreferenceClickListener(preference -> {
AppInfoBase.startAppInfoFragment(AppInfoDashboardFragment.class,
R.string.application_info_label, pkgName, appEntry.info.uid,
mContext.getString(R.string.application_info_label),
pkgName, appEntry.info.uid,
mHost, 1001 /*RequestCode*/, getMetricsCategory());
return true;
});

View File

@@ -17,6 +17,7 @@ package com.android.settings.applications;
import static android.app.AppOpsManager.OP_GET_USAGE_STATS;
import static android.app.AppOpsManager.OP_LOADER_USAGE_STATS;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_DISABLE_USAGE_ACCESS_WARNING;
import android.Manifest;
import android.app.AppOpsManager;
@@ -96,7 +97,8 @@ public class UsageAccessDetails extends AppInfoWithHeader implements OnPreferenc
new AlertDialog.Builder(getContext())
.setIcon(com.android.internal.R.drawable.ic_dialog_alert_material)
.setTitle(android.R.string.dialog_alert_title)
.setMessage(R.string.work_profile_usage_access_warning)
.setMessage(mDpm.getString(WORK_PROFILE_DISABLE_USAGE_ACCESS_WARNING,
() -> getString(R.string.work_profile_usage_access_warning)))
.setPositiveButton(R.string.okay, null)
.show();
}

View File

@@ -649,8 +649,8 @@ public class ManageApplications extends InstrumentedFragment
}
private void startAppInfoFragment(Class<?> fragment, int titleRes) {
AppInfoBase.startAppInfoFragment(fragment, titleRes, mCurrentPkgName, mCurrentUid, this,
INSTALLED_APP_DETAILS, getMetricsCategory());
AppInfoBase.startAppInfoFragment(fragment, getString(titleRes), mCurrentPkgName,
mCurrentUid, this, INSTALLED_APP_DETAILS, getMetricsCategory());
}
@Override

View File

@@ -70,7 +70,8 @@ public class DomainAppPreferenceController extends BasePreferenceController impl
public boolean handlePreferenceTreeClick(Preference preference) {
if (preference instanceof DomainAppPreference) {
ApplicationsState.AppEntry entry = ((DomainAppPreference) preference).getEntry();
AppInfoBase.startAppInfoFragment(AppLaunchSettings.class, R.string.auto_launch_label,
AppInfoBase.startAppInfoFragment(AppLaunchSettings.class,
mContext.getString(R.string.auto_launch_label),
entry.info.packageName, entry.info.uid, mFragment,
INSTALLED_APP_DETAILS, mMetricsCategory);
return true;

View File

@@ -17,6 +17,18 @@
package com.android.settings.applications.specialaccess.deviceadmin;
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACTIVATE_DEVICE_ADMIN_APP;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACTIVATE_THIS_DEVICE_ADMIN_APP;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACTIVE_DEVICE_ADMIN_WARNING;
import static android.app.admin.DevicePolicyResources.Strings.Settings.DEVICE_ADMIN_POLICIES_WARNING;
import static android.app.admin.DevicePolicyResources.Strings.Settings.NEW_DEVICE_ADMIN_WARNING;
import static android.app.admin.DevicePolicyResources.Strings.Settings.NEW_DEVICE_ADMIN_WARNING_SIMPLIFIED;
import static android.app.admin.DevicePolicyResources.Strings.Settings.REMOVE_AND_UNINSTALL_DEVICE_ADMIN;
import static android.app.admin.DevicePolicyResources.Strings.Settings.REMOVE_DEVICE_ADMIN;
import static android.app.admin.DevicePolicyResources.Strings.Settings.REMOVE_WORK_PROFILE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.SET_PROFILE_OWNER_DIALOG_TITLE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.USER_ADMIN_POLICIES_WARNING;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_ADMIN_POLICIES_WARNING;
import android.app.Activity;
import android.app.ActivityManager;
@@ -318,7 +330,8 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
// Build and show the simplified dialog
final Dialog dialog = new AlertDialog.Builder(this)
.setTitle(getText(R.string.profile_owner_add_title_simplified))
.setTitle(mDPM.getString(SET_PROFILE_OWNER_DIALOG_TITLE,
() -> getString(R.string.profile_owner_add_title_simplified)))
.setView(R.layout.profile_owner_add)
.setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -339,8 +352,10 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
mAddMsg = dialog.findViewById(R.id.add_msg_simplified);
mAddMsg.setText(mAddMsgText);
mAdminWarning = dialog.findViewById(R.id.admin_warning_simplified);
mAdminWarning.setText(getString(R.string.device_admin_warning_simplified,
mProfileOwnerName));
mAdminWarning.setText(
mDPM.getString(NEW_DEVICE_ADMIN_WARNING_SIMPLIFIED, () ->
getString(R.string.device_admin_warning_simplified,
mProfileOwnerName), mProfileOwnerName));
return;
}
setContentView(R.layout.device_admin_add);
@@ -655,8 +670,10 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
final boolean isManagedProfile = isManagedProfile(mDeviceAdmin);
if (isProfileOwner && isManagedProfile) {
// Profile owner in a managed profile, user can remove profile to disable admin.
mAdminWarning.setText(R.string.admin_profile_owner_message);
mActionButton.setText(R.string.remove_managed_profile_label);
mAdminWarning.setText(mDPM.getString(WORK_PROFILE_ADMIN_POLICIES_WARNING,
() -> getString(R.string.admin_profile_owner_message)));
mActionButton.setText(mDPM.getString(REMOVE_WORK_PROFILE,
() -> getString(R.string.remove_managed_profile_label)));
final EnforcedAdmin admin = getAdminEnforcingCantRemoveProfile();
final boolean hasBaseRestriction = hasBaseCantRemoveProfileRestriction();
@@ -670,27 +687,33 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
// Profile owner in a user or device owner, user can't disable admin.
if (isProfileOwner) {
// Show profile owner in a user description.
mAdminWarning.setText(R.string.admin_profile_owner_user_message);
mAdminWarning.setText(mDPM.getString(USER_ADMIN_POLICIES_WARNING,
() -> getString(R.string.admin_profile_owner_user_message)));
} else {
// Show device owner description.
if (isFinancedDevice()) {
mAdminWarning.setText(R.string.admin_financed_message);
} else {
mAdminWarning.setText(R.string.admin_device_owner_message);
mAdminWarning.setText(mDPM.getString(DEVICE_ADMIN_POLICIES_WARNING,
() -> getString(R.string.admin_device_owner_message)));
}
}
mActionButton.setText(R.string.remove_device_admin);
mActionButton.setText(mDPM.getString(REMOVE_DEVICE_ADMIN,
() -> getString(R.string.remove_device_admin)));
mActionButton.setEnabled(false);
} else {
addDeviceAdminPolicies(false /* showDescription */);
mAdminWarning.setText(getString(R.string.device_admin_status,
mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(
getPackageManager())));
CharSequence label = mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(
getPackageManager());
mAdminWarning.setText(mDPM.getString(ACTIVE_DEVICE_ADMIN_WARNING,
() -> getString(R.string.device_admin_status, label), label));
setTitle(R.string.active_device_admin_msg);
if (mUninstalling) {
mActionButton.setText(R.string.remove_and_uninstall_device_admin);
mActionButton.setText(mDPM.getString(REMOVE_AND_UNINSTALL_DEVICE_ADMIN,
() -> getString(R.string.remove_and_uninstall_device_admin)));
} else {
mActionButton.setText(R.string.remove_device_admin);
mActionButton.setText(mDPM.getString(REMOVE_DEVICE_ADMIN,
() -> getString(R.string.remove_device_admin)));
}
}
CharSequence supportMessage = mDPM.getLongSupportMessageForUser(
@@ -703,10 +726,16 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
}
} else {
addDeviceAdminPolicies(true /* showDescription */);
mAdminWarning.setText(getString(R.string.device_admin_warning,
mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(getPackageManager())));
setTitle(getText(R.string.add_device_admin_msg));
mActionButton.setText(getText(R.string.add_device_admin));
CharSequence label = mDeviceAdmin.getActivityInfo()
.applicationInfo.loadLabel(getPackageManager());
mAdminWarning.setText(
mDPM.getString(NEW_DEVICE_ADMIN_WARNING, () ->
getString(R.string.device_admin_warning, label
), label));
setTitle(mDPM.getString(ACTIVATE_DEVICE_ADMIN_APP,
() -> getString(R.string.add_device_admin_msg)));
mActionButton.setText(mDPM.getString(ACTIVATE_THIS_DEVICE_ADMIN_APP,
() -> getString(R.string.add_device_admin)));
if (isAdminUninstallable()) {
mUninstallButton.setVisibility(View.VISIBLE);
}

View File

@@ -15,6 +15,11 @@
*/
package com.android.settings.applications.specialaccess.interactacrossprofiles;
import static android.app.admin.DevicePolicyResources.Strings.Settings.APP_CAN_ACCESS_PERSONAL_DATA;
import static android.app.admin.DevicePolicyResources.Strings.Settings.APP_CAN_ACCESS_PERSONAL_PERMISSIONS;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECT_APPS_DIALOG_TITLE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.INSTALL_IN_PERSONAL_PROFILE_TO_CONNECT_PROMPT;
import static android.app.admin.DevicePolicyResources.Strings.Settings.INSTALL_IN_WORK_PROFILE_TO_CONNECT_PROMPT;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static android.provider.Settings.ACTION_MANAGE_CROSS_PROFILE_ACCESS;
@@ -258,16 +263,22 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
final TextView dialogTitle = dialogView.findViewById(
R.id.interact_across_profiles_consent_dialog_title);
dialogTitle.setText(
getString(R.string.interact_across_profiles_consent_dialog_title, mAppLabel));
dialogTitle.setText(mDpm.getString(CONNECT_APPS_DIALOG_TITLE, () ->
getString(R.string.interact_across_profiles_consent_dialog_title, mAppLabel)));
final TextView appDataSummary = dialogView.findViewById(R.id.app_data_summary);
appDataSummary.setText(getString(
R.string.interact_across_profiles_consent_dialog_app_data_summary, mAppLabel));
appDataSummary.setText(
mDpm.getString(APP_CAN_ACCESS_PERSONAL_DATA,
() -> getString(
R.string.interact_across_profiles_consent_dialog_app_data_summary,
mAppLabel), mAppLabel));
final TextView permissionsSummary = dialogView.findViewById(R.id.permissions_summary);
permissionsSummary.setText(getString(
R.string.interact_across_profiles_consent_dialog_permissions_summary, mAppLabel));
permissionsSummary.setText(mDpm.getString(APP_CAN_ACCESS_PERSONAL_PERMISSIONS,
() -> getString(
R.string.interact_across_profiles_consent_dialog_permissions_summary,
mAppLabel),
mAppLabel));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(dialogView)
@@ -393,9 +404,12 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
return false;
}
if (!mInstalledInPersonal) {
mInstallBanner.setTitle(getString(
R.string.interact_across_profiles_install_personal_app_title,
mAppLabel));
mInstallBanner.setTitle(
mDpm.getString(INSTALL_IN_PERSONAL_PROFILE_TO_CONNECT_PROMPT,
() -> getString(
R.string.interact_across_profiles_install_personal_app_title,
mAppLabel),
mAppLabel));
if (mInstallAppIntent != null) {
mInstallBanner.setSummary(
R.string.interact_across_profiles_install_app_summary);
@@ -404,9 +418,12 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
return true;
}
if (!mInstalledInWork) {
mInstallBanner.setTitle(getString(
R.string.interact_across_profiles_install_work_app_title,
mAppLabel));
mInstallBanner.setTitle(
mDpm.getString(INSTALL_IN_WORK_PROFILE_TO_CONNECT_PROMPT,
() -> getString(
R.string.interact_across_profiles_install_work_app_title,
mAppLabel),
mAppLabel));
if (mInstallAppIntent != null) {
mInstallBanner.setSummary(
R.string.interact_across_profiles_install_app_summary);

View File

@@ -15,9 +15,11 @@
*/
package com.android.settings.applications.specialaccess.interactacrossprofiles;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_WORK_AND_PERSONAL_APPS_TITLE;
import static android.content.pm.PackageManager.GET_ACTIVITIES;
import android.annotation.Nullable;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -51,6 +53,7 @@ public class InteractAcrossProfilesSettings extends EmptyTextSettings {
private Context mContext;
private PackageManager mPackageManager;
private UserManager mUserManager;
private DevicePolicyManager mDevicePolicyManager;
private CrossProfileApps mCrossProfileApps;
private IconDrawableFactory mIconDrawableFactory;
@@ -63,6 +66,7 @@ public class InteractAcrossProfilesSettings extends EmptyTextSettings {
mUserManager = mContext.getSystemService(UserManager.class);
mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
}
@Override
@@ -91,7 +95,8 @@ public class InteractAcrossProfilesSettings extends EmptyTextSettings {
@Override
public boolean onPreferenceClick(Preference preference) {
AppInfoBase.startAppInfoFragment(InteractAcrossProfilesDetails.class,
R.string.interact_across_profiles_title,
mDevicePolicyManager.getString(CONNECTED_WORK_AND_PERSONAL_APPS_TITLE,
() -> getString(R.string.interact_across_profiles_title)),
packageName,
appInfo.uid,
InteractAcrossProfilesSettings.this/* source */,

View File

@@ -168,7 +168,8 @@ public class PictureInPictureSettings extends EmptyTextSettings {
@Override
public boolean onPreferenceClick(Preference preference) {
AppInfoBase.startAppInfoFragment(PictureInPictureDetails.class,
R.string.picture_in_picture_app_detail_title, packageName, appInfo.uid,
getString(R.string.picture_in_picture_app_detail_title),
packageName, appInfo.uid,
PictureInPictureSettings.this, -1, getMetricsCategory());
return true;
}