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

Commit 4e49a5d0 authored by Evan Severson's avatar Evan Severson Committed by Android (Google) Code Review
Browse files

Merge "Add new api to get the button label for background permission"

parents 201ab6dc cfae44ae
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11788,6 +11788,7 @@ package android.content.pm {
    method @NonNull public abstract CharSequence getApplicationLabel(@NonNull android.content.pm.ApplicationInfo);
    method @Nullable public abstract android.graphics.drawable.Drawable getApplicationLogo(@NonNull android.content.pm.ApplicationInfo);
    method @Nullable public abstract android.graphics.drawable.Drawable getApplicationLogo(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull public CharSequence getBackgroundPermissionButtonLabel();
    method @Nullable public abstract android.content.pm.ChangedPackages getChangedPackages(@IntRange(from=0) int);
    method public abstract int getComponentEnabledSetting(@NonNull android.content.ComponentName);
    method @NonNull public abstract android.graphics.drawable.Drawable getDefaultActivityIcon();
+24 −0
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@ public class ApplicationPackageManager extends PackageManager {
    // Default flags to use with PackageManager when no flags are given.
    private final static int sDefaultFlags = PackageManager.GET_SHARED_LIBRARY_FILES;

    // Name of the resource which provides background permission button string
    public static final String APP_PERMISSION_BUTTON_ALLOW_ALWAYS =
            "app_permission_button_allow_always";

    private final Object mLock = new Object();

    @GuardedBy("mLock")
@@ -806,6 +810,26 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override
    public CharSequence getBackgroundPermissionButtonLabel() {
        try {

            String permissionController = getPermissionControllerPackageName();
            Context context =
                    mContext.createPackageContext(permissionController, 0);

            int textId = context.getResources().getIdentifier(APP_PERMISSION_BUTTON_ALLOW_ALWAYS,
                    "string", "com.android.permissioncontroller");
//                    permissionController); STOPSHIP b/147434671
            if (textId != 0) {
                return context.getText(textId);
            }
        } catch (NameNotFoundException e) {
            Log.e(TAG, "Permission controller not found.", e);
        }
        return "";
    }

    @Override
    public int checkSignatures(String pkg1, String pkg2) {
        try {
+12 −0
Original line number Diff line number Diff line
@@ -4388,6 +4388,18 @@ public abstract class PackageManager {
    @UnsupportedAppUsage
    public abstract boolean shouldShowRequestPermissionRationale(@NonNull String permName);

    /**
     * Gets the string that is displayed on the button which corresponds to granting background
     * location in settings. The intended use for this is to help apps instruct users how to
     * grant a background permission by providing the string that users will see.
     *
     * @return the string shown on the button for granting background location
     */
    @NonNull
    public CharSequence getBackgroundPermissionButtonLabel() {
        return "";
    }

    /**
     * Returns an {@link android.content.Intent} suitable for passing to
     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}