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

Commit 7d0992ce authored by Bernardo Rufino's avatar Bernardo Rufino
Browse files

Require signature|privileged STATUS_BAR for collapsePanels()

For apps targeting S+. This API was being exploited by malware to
prevent the user from accessing critical notifications
(go/collapse-status-bar, b/137274359).

This API was hidden and never intended to be used by 3p apps, so putting
it behind proper permission after targetSdk S. Since it's
@UnsupportedAppUsage trying to steer apps to the
Intent.ACTION_CLOSE_SYSTEM_DIALOGS (Intent.ACSD), which produces the
same effect and has been part of the API surface (as opposed to this
one). However, to fix the vulnerability (b/137274359) that intent will
be subjected to further restrictions based on privilege (who) and
circumstance (what), for more details see go/close-system-dialogs.

To lock down the abuse vector, similar restrictions to the ones applied
to Intent.ACSD will be applied to collapsePanels() NOT gated on
targetSdk, but these will be in future CLs.

Test: CTS coming
Bug: 173031413
Bug: 159105552
Bug: 137274359
Change-Id: I05f05ff6a2052820a132c2284101480448d18b77
parent a0e5a733
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ package android.app {
  }

  public class StatusBarManager {
    method public void collapsePanels();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void collapsePanels();
    method public void expandNotificationsPanel();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setExpansionDisabledForSimNetworkLock(boolean);
  }
+7 −1
Original line number Diff line number Diff line
@@ -283,9 +283,15 @@ public class StatusBarManager {
    /**
     * Collapse the notifications and settings panels.
     *
     * Starting in Android {@link Build.VERSION_CODES.S}, apps targeting SDK level {@link
     * Build.VERSION_CODES.S} or higher will need {@link android.Manifest.permission.STATUS_BAR}
     * permission to call this API.
     *
     * @hide
     */
    @UnsupportedAppUsage
    @RequiresPermission(android.Manifest.permission.STATUS_BAR)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, publicAlternatives = "Send {@link "
            + "android.content.Intent#ACTION_CLOSE_SYSTEM_DIALOGS} instead.")
    @TestApi
    public void collapsePanels() {
        try {
+21 −2
Original line number Diff line number Diff line
@@ -24,15 +24,18 @@ import android.app.ActivityThread;
import android.app.ITransientNotificationCallback;
import android.app.Notification;
import android.app.StatusBarManager;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.content.ComponentName;
import android.content.Context;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -84,6 +87,18 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
    private static final String TAG = "StatusBarManagerService";
    private static final boolean SPEW = false;

    /**
     * Apps targeting {@code Build.VERSION_CODES.S} or higher need {@link
     * android.Manifest.permission#STATUS_BAR} permission to collapse the status bar panels due to
     * security reasons.
     *
     * This was being exploited by malware to prevent the user from accessing critical
     * notifications.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
    private static final long LOCK_DOWN_COLLAPSE_STATUS_BAR = 173031413L;

    private final Context mContext;

    private Handler mHandler = new Handler();
@@ -605,7 +620,11 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D

    @Override
    public void collapsePanels() {
        if (CompatChanges.isChangeEnabled(LOCK_DOWN_COLLAPSE_STATUS_BAR, Binder.getCallingUid())) {
            enforceStatusBar();
        } else {
            enforceExpandStatusBar();
        }

        if (mBar != null) {
            try {