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

Commit 9ded659a authored by Hall Liu's avatar Hall Liu
Browse files

Add setDisabledForSimNetworkLock to StatusBarManager

Add a new @SystemApi disable utility method to allow telephony's
mainline module to disable the status bar when the device is SIM-locked

Bug: 146834818
Bug: 138956541
Test: atest StatusBarManagerTest
Change-Id: Id3757fc560c5b70bed553f19b050524a024b4c78
parent 967232ee
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -596,6 +596,7 @@ package android.app {
  public class StatusBarManager {
  public class StatusBarManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSetup(boolean);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSetup(boolean);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSimNetworkLock(boolean);
  }
  }
  public static final class StatusBarManager.DisableInfo {
  public static final class StatusBarManager.DisableInfo {
+1 −0
Original line number Original line Diff line number Diff line
@@ -352,6 +352,7 @@ package android.app {
  public class StatusBarManager {
  public class StatusBarManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSetup(boolean);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSetup(boolean);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSimNetworkLock(boolean);
  }
  }


  public static final class StatusBarManager.DisableInfo {
  public static final class StatusBarManager.DisableInfo {
+29 −0
Original line number Original line Diff line number Diff line
@@ -153,6 +153,11 @@ public class StatusBarManager {
     */
     */
    public static final int DEFAULT_SETUP_DISABLE2_FLAGS = DISABLE2_ROTATE_SUGGESTIONS;
    public static final int DEFAULT_SETUP_DISABLE2_FLAGS = DISABLE2_ROTATE_SUGGESTIONS;


    /**
     * disable flags to be applied when the device is sim-locked.
     */
    private static final int DEFAULT_SIM_LOCKED_DISABLED_FLAGS = DISABLE_EXPAND;

    /** @hide */
    /** @hide */
    public static final int NAVIGATION_HINT_BACK_ALT      = 1 << 0;
    public static final int NAVIGATION_HINT_BACK_ALT      = 1 << 0;
    /** @hide */
    /** @hide */
@@ -384,6 +389,30 @@ public class StatusBarManager {
        }
        }
    }
    }


    /**
     * Enable or disable expansion of the status bar. When the device is SIM-locked, the status
     * bar should not be expandable.
     *
     * @param disabled If {@code true}, the status bar will be set to non-expandable. If
     *                 {@code false}, re-enables expansion of the status bar.
     * @hide
     */
    @SystemApi
    @TestApi
    @RequiresPermission(android.Manifest.permission.STATUS_BAR)
    public void setDisabledForSimNetworkLock(boolean disabled) {
        try {
            final int userId = Binder.getCallingUserHandle().getIdentifier();
            final IStatusBarService svc = getService();
            if (svc != null) {
                svc.disableForUser(disabled ? DEFAULT_SIM_LOCKED_DISABLED_FLAGS : DISABLE_NONE,
                        mToken, mContext.getPackageName(), userId);
            }
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * Get this app's currently requested disabled components
     * Get this app's currently requested disabled components
     *
     *