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

Commit 844d1256 authored by Tsung-Mao Fang's avatar Tsung-Mao Fang
Browse files

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
parent a07377d5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1373,4 +1373,7 @@
    <string name="cached_apps_freezer_enabled">Enabled</string>
    <!-- Developer setting dialog prompting the user to reboot after changing the app freezer setting [CHAR LIMIT=NONE]-->
    <string name="cached_apps_freezer_reboot_dialog_text">Your device must be rebooted for this change to apply. Reboot now or cancel.</string>

    <!-- A content description for work profile app [CHAR LIMIT=35] -->
    <string name="accessibility_work_profile_app_description">Work <xliff:g id="app_name" example="Camera">%s</xliff:g></string>
</resources>
+15 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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();
    }
}