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

Commit d8709253 authored by Antoan Angelov's avatar Antoan Angelov Committed by Android (Google) Code Review
Browse files

Merge "API to get the device manager role holder package name"

parents 274ad40f 5ed5e86c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7362,6 +7362,7 @@ package android.app.admin {
    method public int getCurrentFailedPasswordAttempts();
    method @Nullable public java.util.List<java.lang.String> getDelegatePackages(@NonNull android.content.ComponentName, @NonNull String);
    method @NonNull public java.util.List<java.lang.String> getDelegatedScopes(@Nullable android.content.ComponentName, @NonNull String);
    method @Nullable public String getDeviceManagerRoleHolderPackageName();
    method public CharSequence getDeviceOwnerLockScreenInfo();
    method @Nullable public android.graphics.drawable.Drawable getDrawable(@NonNull String, @NonNull String, @NonNull java.util.concurrent.Callable<android.graphics.drawable.Drawable>);
    method @Nullable public android.graphics.drawable.Drawable getDrawable(@NonNull String, @NonNull String, @NonNull String, @NonNull java.util.concurrent.Callable<android.graphics.drawable.Drawable>);
+36 −0
Original line number Diff line number Diff line
@@ -15635,4 +15635,40 @@ public class DevicePolicyManager {
            }
        }
    }
    /**
     * Returns the package name of the device manager role holder.
     *
     * <p>If the device manager role holder is not configured for this device, returns {@code null}.
     */
    @Nullable
    public String getDeviceManagerRoleHolderPackageName() {
        String deviceManagerConfig =
                mContext.getString(com.android.internal.R.string.config_deviceManager);
        return extractPackageNameFromDeviceManagerConfig(deviceManagerConfig);
    }
    /**
     * Retrieves the package name for a given {@code deviceManagerConfig}.
     *
     * <p>Valid configs look like:
     * <ul>
     *     <li>{@code com.package.name}</li>
     *     <li>{@code com.package.name:<SHA256 checksum>}</li>
     * </ul>
     *
     * <p>If the supplied {@code deviceManagerConfig} is {@code null} or empty, returns
     * {@code null}.
     */
    @Nullable
    private String extractPackageNameFromDeviceManagerConfig(
            @Nullable String deviceManagerConfig) {
        if (TextUtils.isEmpty(deviceManagerConfig)) {
            return null;
        }
        if (deviceManagerConfig.contains(":")) {
            return deviceManagerConfig.split(":")[0];
        }
        return deviceManagerConfig;
    }
}