Merge "Require proper permission for togglePanel()/handleSystemKey()" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6b1896db4f
@@ -333,8 +333,10 @@ package android.app {
|
|||||||
method public void clickNotification(@Nullable String, int, int, boolean);
|
method public void clickNotification(@Nullable String, int, int, boolean);
|
||||||
method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void collapsePanels();
|
method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void collapsePanels();
|
||||||
method public void expandNotificationsPanel();
|
method public void expandNotificationsPanel();
|
||||||
|
method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void handleSystemKey(int);
|
||||||
method public void sendNotificationFeedback(@Nullable String, @Nullable android.os.Bundle);
|
method public void sendNotificationFeedback(@Nullable String, @Nullable android.os.Bundle);
|
||||||
method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setExpansionDisabledForSimNetworkLock(boolean);
|
method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setExpansionDisabledForSimNetworkLock(boolean);
|
||||||
|
method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void togglePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class SyncNotedAppOp implements android.os.Parcelable {
|
public final class SyncNotedAppOp implements android.os.Parcelable {
|
||||||
|
|||||||
@@ -351,6 +351,42 @@ public class StatusBarManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the notification panel.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@RequiresPermission(android.Manifest.permission.STATUS_BAR)
|
||||||
|
@TestApi
|
||||||
|
public void togglePanel() {
|
||||||
|
try {
|
||||||
|
final IStatusBarService svc = getService();
|
||||||
|
if (svc != null) {
|
||||||
|
svc.togglePanel();
|
||||||
|
}
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
throw ex.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends system keys to the status bar.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@RequiresPermission(android.Manifest.permission.STATUS_BAR)
|
||||||
|
@TestApi
|
||||||
|
public void handleSystemKey(int key) {
|
||||||
|
try {
|
||||||
|
final IStatusBarService svc = getService();
|
||||||
|
if (svc != null) {
|
||||||
|
svc.handleSystemKey(key);
|
||||||
|
}
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
throw ex.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand the settings panel.
|
* Expand the settings panel.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -671,20 +671,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collapsePanels() {
|
public void collapsePanels() {
|
||||||
int uid = Binder.getCallingUid();
|
if (!checkCanCollapseStatusBar("collapsePanels")) {
|
||||||
int pid = Binder.getCallingPid();
|
return;
|
||||||
if (CompatChanges.isChangeEnabled(LOCK_DOWN_COLLAPSE_STATUS_BAR, uid)) {
|
|
||||||
enforceStatusBar();
|
|
||||||
} else {
|
|
||||||
if (mContext.checkPermission(Manifest.permission.STATUS_BAR, pid, uid)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
|
||||||
enforceExpandStatusBar();
|
|
||||||
if (!mActivityTaskManager.canCloseSystemDialogs(pid, uid)) {
|
|
||||||
Slog.e(TAG, "Permission Denial: Method collapsePanels() requires permission "
|
|
||||||
+ Manifest.permission.STATUS_BAR + ", ignoring call.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBar != null) {
|
if (mBar != null) {
|
||||||
@@ -697,7 +685,9 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void togglePanel() {
|
public void togglePanel() {
|
||||||
enforceExpandStatusBar();
|
if (!checkCanCollapseStatusBar("togglePanel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isDisable2FlagSet(DISABLE2_NOTIFICATION_SHADE)) {
|
if (isDisable2FlagSet(DISABLE2_NOTIFICATION_SHADE)) {
|
||||||
return;
|
return;
|
||||||
@@ -758,7 +748,9 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSystemKey(int key) throws RemoteException {
|
public void handleSystemKey(int key) throws RemoteException {
|
||||||
enforceExpandStatusBar();
|
if (!checkCanCollapseStatusBar("handleSystemKey")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mBar != null) {
|
if (mBar != null) {
|
||||||
try {
|
try {
|
||||||
@@ -1201,6 +1193,29 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
|||||||
"StatusBarManagerService");
|
"StatusBarManagerService");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For targetSdk S+ we require STATUS_BAR. For targetSdk < S, we only require EXPAND_STATUS_BAR
|
||||||
|
* but also require that it falls into one of the allowed use-cases to lock down abuse vector.
|
||||||
|
*/
|
||||||
|
private boolean checkCanCollapseStatusBar(String method) {
|
||||||
|
int uid = Binder.getCallingUid();
|
||||||
|
int pid = Binder.getCallingUid();
|
||||||
|
if (CompatChanges.isChangeEnabled(LOCK_DOWN_COLLAPSE_STATUS_BAR, uid)) {
|
||||||
|
enforceStatusBar();
|
||||||
|
} else {
|
||||||
|
if (mContext.checkPermission(Manifest.permission.STATUS_BAR, pid, uid)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
enforceExpandStatusBar();
|
||||||
|
if (!mActivityTaskManager.canCloseSystemDialogs(pid, uid)) {
|
||||||
|
Slog.e(TAG, "Permission Denial: Method " + method + "() requires permission "
|
||||||
|
+ Manifest.permission.STATUS_BAR + ", ignoring call.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
// Callbacks from the status bar service.
|
// Callbacks from the status bar service.
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user