From 844d12569b569698e03bcf19cb59748bf95b2ad5 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Thu, 7 May 2020 18:08:45 +0800 Subject: [PATCH] Create an API to generate a content description for app name Distinguishes a personal app from a work app for accessibility purpose. If the app is in a work profile, then add a "work" prefix to the app name. Test: Integrate with Settings app and talkback speaks correct content for work profile app. Bug: 127602715 Change-Id: I2c692bc0617566de5006c592f22a16dcf78cb5e7 --- packages/SettingsLib/res/values/strings.xml | 3 +++ .../settingslib/applications/AppUtils.java | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 934f61091bcc2..e42e438019367 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -1373,4 +1373,7 @@ Enabled Your device must be rebooted for this change to apply. Reboot now or cancel. + + + Work %s diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java b/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java index ae3194df28fe5..b1f2a397bde6f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java @@ -26,6 +26,7 @@ import android.hardware.usb.IUsbManager; import android.os.RemoteException; import android.os.SystemProperties; import android.os.UserHandle; +import android.os.UserManager; import android.util.Log; import com.android.settingslib.R; @@ -129,7 +130,7 @@ public class AppUtils { */ public static boolean isHiddenSystemModule(Context context, String packageName) { return ApplicationsState.getInstance((Application) context.getApplicationContext()) - .isHiddenModule(packageName); + .isHiddenModule(packageName); } /** @@ -151,4 +152,17 @@ public class AppUtils { return false; } } + + /** + * Returns a content description of an app name which distinguishes a personal app from a + * work app for accessibility purpose. + * If the app is in a work profile, then add a "work" prefix to the app name. + */ + public static String getAppContentDescription(Context context, String packageName, + int userId) { + final CharSequence appLabel = getApplicationLabel(context.getPackageManager(), packageName); + return UserManager.get(context).isManagedProfile(userId) + ? context.getString(R.string.accessibility_work_profile_app_description, appLabel) + : appLabel.toString(); + } }