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

Commit 8fb2d472 authored by Benjamin Franz's avatar Benjamin Franz Committed by Android Git Automerger
Browse files

am 94fb2024: Merge "Rename functions that disable status bar and keyguard" into mnc-dev

* commit '94fb2024':
  Rename functions that disable status bar and keyguard
parents fc38d842 94fb2024
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5791,8 +5791,8 @@ package android.app.admin {
    method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
    method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
    method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
    method public boolean setKeyguardEnabledState(android.content.ComponentName, boolean);
    method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
@@ -5818,7 +5818,7 @@ package android.app.admin {
    method public void setRestrictionsProvider(android.content.ComponentName, android.content.ComponentName);
    method public void setScreenCaptureDisabled(android.content.ComponentName, boolean);
    method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public void setStatusBarEnabledState(android.content.ComponentName, boolean);
    method public boolean setStatusBarDisabled(android.content.ComponentName, boolean);
    method public int setStorageEncryption(android.content.ComponentName, boolean);
    method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy);
    method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle);
+2 −2
Original line number Diff line number Diff line
@@ -5897,8 +5897,8 @@ package android.app.admin {
    method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
    method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
    method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
    method public boolean setKeyguardEnabledState(android.content.ComponentName, boolean);
    method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
@@ -5924,7 +5924,7 @@ package android.app.admin {
    method public void setRestrictionsProvider(android.content.ComponentName, android.content.ComponentName);
    method public void setScreenCaptureDisabled(android.content.ComponentName, boolean);
    method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public void setStatusBarEnabledState(android.content.ComponentName, boolean);
    method public boolean setStatusBarDisabled(android.content.ComponentName, boolean);
    method public int setStorageEncryption(android.content.ComponentName, boolean);
    method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy);
    method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle);
+13 −9
Original line number Diff line number Diff line
@@ -4294,14 +4294,14 @@ public class DevicePolicyManager {
     * being disabled.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param enabled New state of the keyguard.
     * @param disabled {@code true} disables the keyguard, {@code false} reenables it.
     *
     * @return {@code false} if attempting to disable the keyguard while a lock password was in
     * place. {@code true} otherwise."
     * place. {@code true} otherwise.
     */
    public boolean setKeyguardEnabledState(ComponentName admin, boolean enabled) {
    public boolean setKeyguardDisabled(ComponentName admin, boolean disabled) {
        try {
            return mService.setKeyguardEnabledState(admin, enabled);
            return mService.setKeyguardDisabled(admin, disabled);
        } catch (RemoteException re) {
            Log.w(TAG, "Failed talking with device policy service", re);
            return false;
@@ -4309,18 +4309,22 @@ public class DevicePolicyManager {
    }

    /**
     * Called by device owner to set the enabled state of the status bar. Disabling the status
     * bar blocks notifications, quick settings and other screen overlays that allow escaping from
     * Called by device owner to disable the status bar. Disabling the status bar blocks
     * notifications, quick settings and other screen overlays that allow escaping from
     * a single use device.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param enabled New state of the status bar.
     * @param disabled {@code true} disables the status bar, {@code false} reenables it.
     *
     * @return {@code false} if attempting to disable the status bar failed.
     * {@code true} otherwise.
     */
    public void setStatusBarEnabledState(ComponentName admin, boolean enabled) {
    public boolean setStatusBarDisabled(ComponentName admin, boolean disabled) {
        try {
            mService.setStatusBarEnabledState(admin, enabled);
            return mService.setStatusBarDisabled(admin, disabled);
        } catch (RemoteException re) {
            Log.w(TAG, "Failed talking with device policy service", re);
            return false;
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -224,8 +224,8 @@ interface IDevicePolicyManager {
    void setSystemUpdatePolicy(in ComponentName who, in PersistableBundle policy);
    PersistableBundle getSystemUpdatePolicy();

    boolean setKeyguardEnabledState(in ComponentName admin, boolean enabled);
    void setStatusBarEnabledState(in ComponentName who, boolean enabled);
    boolean setKeyguardDisabled(in ComponentName admin, boolean disabled);
    boolean setStatusBarDisabled(in ComponentName who, boolean disabled);
    boolean getDoNotAskCredentialsOnBoot();

    void notifyPendingSystemUpdate(in long updateReceivedTime);
+24 −19
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {

    private static final String TAG_STATUS_BAR = "statusbar";

    private static final String ATTR_ENABLED = "enabled";
    private static final String ATTR_DISABLED = "disabled";

    private static final String DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML =
            "do-not-ask-credentials-on-boot";
@@ -313,7 +313,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        // This is the list of component allowed to start lock task mode.
        List<String> mLockTaskPackages = new ArrayList<>();

        boolean mStatusBarEnabledState = true;
        boolean mStatusBarDisabled = false;

        ComponentName mRestrictionsProvider;

@@ -1476,9 +1476,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                out.endTag(null, TAG_LOCK_TASK_COMPONENTS);
            }

            if (!policy.mStatusBarEnabledState) {
            if (policy.mStatusBarDisabled) {
                out.startTag(null, TAG_STATUS_BAR);
                out.attribute(null, ATTR_ENABLED, Boolean.toString(policy.mStatusBarEnabledState));
                out.attribute(null, ATTR_DISABLED, Boolean.toString(policy.mStatusBarDisabled));
                out.endTag(null, TAG_STATUS_BAR);
            }

@@ -1615,8 +1615,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                } else if (TAG_LOCK_TASK_COMPONENTS.equals(tag)) {
                    policy.mLockTaskPackages.add(parser.getAttributeValue(null, "name"));
                } else if (TAG_STATUS_BAR.equals(tag)) {
                    policy.mStatusBarEnabledState = Boolean.parseBoolean(
                            parser.getAttributeValue(null, ATTR_ENABLED));
                    policy.mStatusBarDisabled = Boolean.parseBoolean(
                            parser.getAttributeValue(null, ATTR_DISABLED));
                } else if (DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML.equals(tag)) {
                    policy.doNotAskCredentialsOnBoot = true;
                } else {
@@ -1678,8 +1678,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        updateMaximumTimeToLockLocked(policy);
        addDeviceInitializerToLockTaskPackagesLocked(userHandle);
        updateLockTaskPackagesLocked(policy.mLockTaskPackages, userHandle);
        if (!policy.mStatusBarEnabledState) {
            setStatusBarEnabledStateInternal(policy.mStatusBarEnabledState, userHandle);
        if (policy.mStatusBarDisabled) {
            setStatusBarDisabledInternal(policy.mStatusBarDisabled, userHandle);
        }
        updatePreferredSetupActivityLocked(userHandle);
    }
@@ -4275,7 +4275,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            DevicePolicyData policy = getUserData(userId);
            policy.mPermissionPolicy = DevicePolicyManager.PERMISSION_POLICY_PROMPT;
            policy.mDelegatedCertInstallerPackage = null;
            policy.mStatusBarEnabledState = true;
            policy.mStatusBarDisabled = false;
            saveSettingsLocked(userId);

            long ident = Binder.clearCallingIdentity();
@@ -6026,7 +6026,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    }

    @Override
    public boolean setKeyguardEnabledState(ComponentName who, boolean enabled) {
    public boolean setKeyguardDisabled(ComponentName who, boolean disabled) {
        Preconditions.checkNotNull(who, "ComponentName is null");
        synchronized (this) {
            getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
@@ -6037,10 +6037,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        long ident = Binder.clearCallingIdentity();
        try {
            // disallow disabling the keyguard if a password is currently set
            if (!enabled && utils.isSecure(userId)) {
            if (disabled && utils.isSecure(userId)) {
                return false;
            }
            utils.setLockScreenDisabled(!enabled, userId);
            utils.setLockScreenDisabled(disabled, userId);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
@@ -6048,35 +6048,40 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    }

    @Override
    public void setStatusBarEnabledState(ComponentName who, boolean enabled) {
    public boolean setStatusBarDisabled(ComponentName who, boolean disabled) {
        int userId = UserHandle.getCallingUserId();
        synchronized (this) {
            getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
            DevicePolicyData policy = getUserData(userId);
            if (policy.mStatusBarEnabledState != enabled) {
                policy.mStatusBarEnabledState = enabled;
                setStatusBarEnabledStateInternal(enabled, userId);
            if (policy.mStatusBarDisabled != disabled) {
                if (!setStatusBarDisabledInternal(disabled, userId)) {
                    return false;
                }
                policy.mStatusBarDisabled = disabled;
                saveSettingsLocked(userId);
            }
        }
        return true;
    }

    private void setStatusBarEnabledStateInternal(boolean enabled, int userId) {
    private boolean setStatusBarDisabledInternal(boolean disabled, int userId) {
        long ident = Binder.clearCallingIdentity();
        try {
            IStatusBarService statusBarService = IStatusBarService.Stub.asInterface(
                    ServiceManager.checkService(Context.STATUS_BAR_SERVICE));
            if (statusBarService != null) {
                int flags1 = enabled ? StatusBarManager.DISABLE_NONE : STATUS_BAR_DISABLE_MASK;
                int flags2 = enabled ? StatusBarManager.DISABLE2_NONE : STATUS_BAR_DISABLE2_MASK;
                int flags1 = disabled ? STATUS_BAR_DISABLE_MASK : StatusBarManager.DISABLE_NONE;
                int flags2 = disabled ? STATUS_BAR_DISABLE2_MASK : StatusBarManager.DISABLE2_NONE;
                statusBarService.disableForUser(flags1, mToken, mContext.getPackageName(), userId);
                statusBarService.disable2ForUser(flags2, mToken, mContext.getPackageName(), userId);
                return true;
            }
        } catch (RemoteException e) {
            Slog.e(LOG_TAG, "Failed to disable the status bar", e);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
        return false;
    }

    /**