Merge "Fix unprotected StatusBarManagerService calls" into nyc-dev am: 3dd5948

am: 30110b8

* commit '30110b80f73a89e5b52aa203f159147f32211ad7':
  Fix unprotected StatusBarManagerService calls

Change-Id: I3f856ff73c50bea6ff354e5819d796cf4ca97116
This commit is contained in:
Adrian Roos
2016-04-19 22:20:48 +00:00
committed by android-build-merger
7 changed files with 212 additions and 296 deletions

View File

@@ -41,7 +41,6 @@ interface IStatusBarService
void setImeWindowStatus(in IBinder token, int vis, int backDisposition,
boolean showImeSwitcher);
void expandSettingsPanel(String subPanel);
void setCurrentUser(int newUserId);
// ---- Methods below are for use by the status bar policy services ----
// You need the STATUS_BAR_SERVICE permission
@@ -63,48 +62,6 @@ interface IStatusBarService
in NotificationVisibility[] noLongerVisibleKeys);
void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded);
void setSystemUiVisibility(int vis, int mask, String cause);
void setWindowState(int window, int state);
void showRecentApps(boolean triggeredFromAltTab, boolean fromHome);
void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
void toggleRecentApps();
void preloadRecentApps();
void cancelPreloadRecentApps();
void toggleKeyboardShortcutsMenu(int deviceId);
/**
* Notifies the status bar that an app transition is pending to delay applying some flags with
* visual impact until {@link #appTransitionReady} is called.
*/
void appTransitionPending();
/**
* Notifies the status bar that a pending app transition has been cancelled.
*/
void appTransitionCancelled();
/**
* Notifies the status bar that an app transition is now being executed.
*
* @param statusBarAnimationsStartTime the desired start time for all visual animations in the
* status bar caused by this app transition in uptime millis
* @param statusBarAnimationsDuration the duration for all visual animations in the status
* bar caused by this app transition in millis
*/
void appTransitionStarting(long statusBarAnimationsStartTime, long statusBarAnimationsDuration);
void startAssist(in Bundle args);
/**
* Request picture-in-picture.
*
* <p>
* This is called when an user presses picture-in-picture key or equivalent.
* TV device may start picture-in-picture from foreground activity if there's none.
* Picture-in-picture overlay menu will be shown instead otherwise.
*/
void requestTvPictureInPicture();
void addTile(in ComponentName tile);
void remTile(in ComponentName tile);

View File

@@ -60,7 +60,6 @@ import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
@@ -92,7 +91,6 @@ import android.view.accessibility.IAccessibilityManagerClient;
import com.android.internal.R;
import com.android.internal.content.PackageMonitor;
import com.android.internal.os.SomeArgs;
import com.android.internal.statusbar.IStatusBarService;
import com.android.server.LocalServices;
import com.android.server.statusbar.StatusBarManagerInternal;
@@ -3315,13 +3313,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
private void openRecents() {
final long token = Binder.clearCallingIdentity();
IStatusBarService statusBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService("statusbar"));
try {
statusBarService.toggleRecentApps();
} catch (RemoteException e) {
Slog.e(LOG_TAG, "Error toggling recent apps.");
}
StatusBarManagerInternal statusBarService = LocalServices.getService(
StatusBarManagerInternal.class);
statusBarService.toggleRecentApps();
Binder.restoreCallingIdentity(token);
}

View File

@@ -18,15 +18,14 @@ package com.android.server.policy;
import android.app.StatusBarManager;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.util.Slog;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManagerPolicy.WindowState;
import com.android.internal.statusbar.IStatusBarService;
import com.android.server.LocalServices;
import com.android.server.statusbar.StatusBarManagerInternal;
import java.io.PrintWriter;
@@ -52,7 +51,7 @@ public class BarController {
private final int mTranslucentWmFlag;
protected final Handler mHandler;
private final Object mServiceAquireLock = new Object();
protected IStatusBarService mStatusBarService;
protected StatusBarManagerInternal mStatusBarInternal;
private WindowState mWin;
private int mState = StatusBarManager.WINDOW_STATE_SHOWING;
@@ -182,15 +181,9 @@ public class BarController {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.setWindowState(mStatusBarManagerId, state);
}
} catch (RemoteException e) {
if (DEBUG) Slog.w(mTag, "Error posting window state", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarInternal();
if (statusbar != null) {
statusbar.setWindowState(mStatusBarManagerId, state);
}
}
});
@@ -276,13 +269,12 @@ public class BarController {
}
}
protected IStatusBarService getStatusBarService() {
protected StatusBarManagerInternal getStatusBarInternal() {
synchronized (mServiceAquireLock) {
if (mStatusBarService == null) {
mStatusBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService("statusbar"));
if (mStatusBarInternal == null) {
mStatusBarInternal = LocalServices.getService(StatusBarManagerInternal.class);
}
return mStatusBarService;
return mStatusBarInternal;
}
}

View File

@@ -1467,14 +1467,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private void requestTvPictureInPictureInternal() {
try {
IStatusBarService statusbar = getStatusBarService();
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.requestTvPictureInPicture();
}
} catch (RemoteException|IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Cannot handle picture-in-picture key", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
}
}
@@ -3562,21 +3560,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
.launchLegacyAssist(hint, UserHandle.myUserId(), args);
} else {
try {
if (hint != null) {
if (args == null) {
args = new Bundle();
}
args.putBoolean(hint, true);
if (hint != null) {
if (args == null) {
args = new Bundle();
}
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.startAssist(args);
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when starting assist", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
args.putBoolean(hint, true);
}
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.startAssist(args);
}
}
}
@@ -3598,45 +3590,27 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private void preloadRecentApps() {
mPreloadedRecentApps = true;
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.preloadRecentApps();
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when preloading recent apps", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.preloadRecentApps();
}
}
private void cancelPreloadRecentApps() {
if (mPreloadedRecentApps) {
mPreloadedRecentApps = false;
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.cancelPreloadRecentApps();
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when cancelling recent apps preload", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.cancelPreloadRecentApps();
}
}
}
private void toggleRecentApps() {
mPreloadedRecentApps = false; // preloading no longer needs to be canceled
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.toggleRecentApps();
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when toggling recent apps", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.toggleRecentApps();
}
}
@@ -3648,40 +3622,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private void showRecentApps(boolean triggeredFromAltTab, boolean fromHome) {
mPreloadedRecentApps = false; // preloading no longer needs to be canceled
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.showRecentApps(triggeredFromAltTab, fromHome);
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing recent apps", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.showRecentApps(triggeredFromAltTab, fromHome);
}
}
private void toggleKeyboardShortcutsMenu(int deviceId) {
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.toggleKeyboardShortcutsMenu(deviceId);
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing keyboard shortcuts menu", e);
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.toggleKeyboardShortcutsMenu(deviceId);
}
}
private void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHome) {
mPreloadedRecentApps = false; // preloading no longer needs to be canceled
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.hideRecentApps(triggeredFromAltTab, triggeredFromHome);
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when closing recent apps", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.hideRecentApps(triggeredFromAltTab, triggeredFromHome);
}
}
@@ -7483,13 +7441,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mKeyguardDelegate != null) {
mKeyguardDelegate.setCurrentUser(newUserId);
}
IStatusBarService statusBar = getStatusBarService();
StatusBarManagerInternal statusBar = getStatusBarManagerInternal();
if (statusBar != null) {
try {
statusBar.setCurrentUser(newUserId);
} catch (RemoteException e) {
// oh well
}
statusBar.setCurrentUser(newUserId);
}
setLastInputMethodWindowLw(null, null);
}

View File

@@ -18,9 +18,7 @@ package com.android.server.policy;
import android.app.StatusBarManager;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Slog;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
@@ -28,7 +26,6 @@ import android.view.animation.AnimationSet;
import android.view.animation.Interpolator;
import android.view.animation.TranslateAnimation;
import com.android.internal.statusbar.IStatusBarService;
import com.android.server.LocalServices;
import com.android.server.statusbar.StatusBarManagerInternal;
@@ -49,15 +46,9 @@ public class StatusBarController extends BarController {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.appTransitionPending();
}
} catch (RemoteException e) {
Slog.e(mTag, "RemoteException when app transition is pending", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarInternal();
if (statusbar != null) {
statusbar.appTransitionPending();
}
}
});
@@ -69,19 +60,13 @@ public class StatusBarController extends BarController {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
long startTime = calculateStatusBarTransitionStartTime(openAnimation,
closeAnimation);
long duration = closeAnimation != null || openAnimation != null
? TRANSITION_DURATION : 0;
statusbar.appTransitionStarting(startTime, duration);
}
} catch (RemoteException e) {
Slog.e(mTag, "RemoteException when app transition is starting", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarInternal();
if (statusbar != null) {
long startTime = calculateStatusBarTransitionStartTime(openAnimation,
closeAnimation);
long duration = closeAnimation != null || openAnimation != null
? TRANSITION_DURATION : 0;
statusbar.appTransitionStarting(startTime, duration);
}
}
});
@@ -92,15 +77,9 @@ public class StatusBarController extends BarController {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.appTransitionCancelled();
}
} catch (RemoteException e) {
Slog.e(mTag, "RemoteException when app transition is cancelled", e);
// re-acquire status bar service next time it is needed.
mStatusBarService = null;
StatusBarManagerInternal statusbar = getStatusBarInternal();
if (statusbar != null) {
statusbar.appTransitionCancelled();
}
}
});

View File

@@ -28,6 +28,50 @@ public interface StatusBarManagerInternal {
void notificationLightOff();
void showScreenPinningRequest(int taskId);
void showAssistDisclosure();
void preloadRecentApps();
void cancelPreloadRecentApps();
void showRecentApps(boolean triggeredFromAltTab, boolean fromHome);
void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
void toggleKeyboardShortcutsMenu(int deviceId);
/**
* Request picture-in-picture.
*
* <p>
* This is called when an user presses picture-in-picture key or equivalent.
* TV device may start picture-in-picture from foreground activity if there's none.
* Picture-in-picture overlay menu will be shown instead otherwise.
*/
void requestTvPictureInPicture();
void setWindowState(int window, int state);
/**
* Notifies the status bar that an app transition is pending to delay applying some flags with
* visual impact until {@link #appTransitionReady} is called.
*/
void appTransitionPending();
/**
* Notifies the status bar that a pending app transition has been cancelled.
*/
void appTransitionCancelled();
/**
* Notifies the status bar that an app transition is now being executed.
*
* @param statusBarAnimationsStartTime the desired start time for all visual animations in the
* status bar caused by this app transition in uptime millis
* @param statusBarAnimationsDuration the duration for all visual animations in the status
* bar caused by this app transition in millis
*/
void appTransitionStarting(long statusBarAnimationsStartTime, long statusBarAnimationsDuration);
void startAssist(Bundle args);
void onCameraLaunchGestureDetected(int source);
void topAppWindowChanged(boolean menuVisible);
@@ -35,4 +79,8 @@ public interface StatusBarManagerInternal {
Rect fullscreenBounds, Rect dockedBounds, String cause);
void toggleSplitScreen();
void appTransitionFinished();
void toggleRecentApps();
void setCurrentUser(int newUserId);
}

View File

@@ -223,6 +223,114 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
} catch (RemoteException ex) {}
}
}
@Override
public void toggleRecentApps() {
if (mBar != null) {
try {
mBar.toggleRecentApps();
} catch (RemoteException ex) {}
}
}
@Override
public void setCurrentUser(int newUserId) {
if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId);
mCurrentUserId = newUserId;
}
@Override
public void preloadRecentApps() {
if (mBar != null) {
try {
mBar.preloadRecentApps();
} catch (RemoteException ex) {}
}
}
@Override
public void cancelPreloadRecentApps() {
if (mBar != null) {
try {
mBar.cancelPreloadRecentApps();
} catch (RemoteException ex) {}
}
}
@Override
public void showRecentApps(boolean triggeredFromAltTab, boolean fromHome) {
if (mBar != null) {
try {
mBar.showRecentApps(triggeredFromAltTab, fromHome);
} catch (RemoteException ex) {}
}
}
@Override
public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
if (mBar != null) {
try {
mBar.hideRecentApps(triggeredFromAltTab, triggeredFromHomeKey);
} catch (RemoteException ex) {}
}
}
@Override
public void toggleKeyboardShortcutsMenu(int deviceId) {
if (mBar != null) {
try {
mBar.toggleKeyboardShortcutsMenu(deviceId);
} catch (RemoteException ex) {}
}
}
@Override
public void requestTvPictureInPicture() {
if (mBar != null) {
try {
mBar.requestTvPictureInPicture();
} catch (RemoteException ex) {}
}
}
@Override
public void setWindowState(int window, int state) {
if (mBar != null) {
try {
mBar.setWindowState(window, state);
} catch (RemoteException ex) {}
}
}
@Override
public void appTransitionPending() {
if (mBar != null) {
try {
mBar.appTransitionPending();
} catch (RemoteException ex) {}
}
}
@Override
public void appTransitionCancelled() {
if (mBar != null) {
try {
mBar.appTransitionCancelled();
} catch (RemoteException ex) {}
}
}
@Override
public void appTransitionStarting(long statusBarAnimationsStartTime,
long statusBarAnimationsDuration) {
if (mBar != null) {
try {
mBar.appTransitionStarting(
statusBarAnimationsStartTime, statusBarAnimationsDuration);
} catch (RemoteException ex) {}
}
}
};
// ================================================================================
@@ -527,122 +635,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
}
}
@Override
public void toggleRecentApps() {
if (mBar != null) {
try {
mBar.toggleRecentApps();
} catch (RemoteException ex) {}
}
}
@Override
public void preloadRecentApps() {
if (mBar != null) {
try {
mBar.preloadRecentApps();
} catch (RemoteException ex) {}
}
}
@Override
public void cancelPreloadRecentApps() {
if (mBar != null) {
try {
mBar.cancelPreloadRecentApps();
} catch (RemoteException ex) {}
}
}
@Override
public void showRecentApps(boolean triggeredFromAltTab, boolean fromHome) {
if (mBar != null) {
try {
mBar.showRecentApps(triggeredFromAltTab, fromHome);
} catch (RemoteException ex) {}
}
}
@Override
public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
if (mBar != null) {
try {
mBar.hideRecentApps(triggeredFromAltTab, triggeredFromHomeKey);
} catch (RemoteException ex) {}
}
}
@Override
public void toggleKeyboardShortcutsMenu(int deviceId) {
if (mBar != null) {
try {
mBar.toggleKeyboardShortcutsMenu(deviceId);
} catch (RemoteException ex) {}
}
}
@Override
public void requestTvPictureInPicture() {
if (mBar != null) {
try {
mBar.requestTvPictureInPicture();
} catch (RemoteException ex) {}
}
}
@Override
public void setCurrentUser(int newUserId) {
if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId);
mCurrentUserId = newUserId;
}
@Override
public void setWindowState(int window, int state) {
if (mBar != null) {
try {
mBar.setWindowState(window, state);
} catch (RemoteException ex) {}
}
}
@Override
public void appTransitionPending() {
if (mBar != null) {
try {
mBar.appTransitionPending();
} catch (RemoteException ex) {}
}
}
@Override
public void appTransitionCancelled() {
if (mBar != null) {
try {
mBar.appTransitionCancelled();
} catch (RemoteException ex) {}
}
}
@Override
public void appTransitionStarting(long statusBarAnimationsStartTime,
long statusBarAnimationsDuration) {
if (mBar != null) {
try {
mBar.appTransitionStarting(
statusBarAnimationsStartTime, statusBarAnimationsDuration);
} catch (RemoteException ex) {}
}
}
@Override
public void startAssist(Bundle args) {
if (mBar != null) {
try {
mBar.startAssist(args);
} catch (RemoteException ex) {}
}
}
private void enforceStatusBarOrShell() {
if (Binder.getCallingUid() == Process.SHELL_UID) {
return;