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

Commit f2efdd8c authored by Adrian Roos's avatar Adrian Roos
Browse files

Fix unprotected StatusBarManagerService calls

Some Binder calls in StatusBarManagerService were
left unprotected. They had no business being binder
calls in the first place, so they got moved to
StatusBarManagerInternal.

Bug: 28222649
Change-Id: Ib26dcca413eb642ba8cd6a4482bf13071f8bd3ab
parent 2a12c6c2
Loading
Loading
Loading
Loading
+0 −43
Original line number Diff line number Diff line
@@ -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);
+3 −9
Original line number Diff line number Diff line
@@ -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 {
            StatusBarManagerInternal statusBarService = LocalServices.getService(
                    StatusBarManagerInternal.class);
            statusBarService.toggleRecentApps();
            } catch (RemoteException e) {
                Slog.e(LOG_TAG, "Error toggling recent apps.");
            }

            Binder.restoreCallingIdentity(token);
        }
+10 −18
Original line number Diff line number Diff line
@@ -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,16 +181,10 @@ public class BarController {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        IStatusBarService statusbar = getStatusBarService();
                    StatusBarManagerInternal statusbar = getStatusBarInternal();
                    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;
                    }
                }
            });
            return true;
@@ -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;
        }
    }

+30 −76
Original line number Diff line number Diff line
@@ -1465,14 +1465,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;
        }
    }

@@ -3544,22 +3542,16 @@ 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);
            }
                IStatusBarService statusbar = getStatusBarService();
            StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
            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;
            }
        }
    }

@@ -3580,46 +3572,28 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    private void preloadRecentApps() {
        mPreloadedRecentApps = true;
        try {
            IStatusBarService statusbar = getStatusBarService();
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
        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;
        }
    }

    private void cancelPreloadRecentApps() {
        if (mPreloadedRecentApps) {
            mPreloadedRecentApps = false;
            try {
                IStatusBarService statusbar = getStatusBarService();
            StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
            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;
            }
        }
    }

    private void toggleRecentApps() {
        mPreloadedRecentApps = false; // preloading no longer needs to be canceled
        try {
            IStatusBarService statusbar = getStatusBarService();
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
        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;
        }
    }

    @Override
@@ -3630,41 +3604,25 @@ 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();
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
        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;
        }
    }

    private void toggleKeyboardShortcutsMenu(int deviceId) {
        try {
            IStatusBarService statusbar = getStatusBarService();
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
        if (statusbar != null) {
            statusbar.toggleKeyboardShortcutsMenu(deviceId);
        }
        } catch (RemoteException e) {
            Slog.e(TAG, "RemoteException when showing keyboard shortcuts menu", e);
        }
    }

    private void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHome) {
        mPreloadedRecentApps = false; // preloading no longer needs to be canceled
        try {
            IStatusBarService statusbar = getStatusBarService();
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
        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;
        }
    }

    void launchHomeFromHotKey() {
@@ -7465,13 +7423,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
            }
        }
        setLastInputMethodWindowLw(null, null);
    }
+13 −34
Original line number Diff line number Diff line
@@ -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,16 +46,10 @@ public class StatusBarController extends BarController {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        IStatusBarService statusbar = getStatusBarService();
                    StatusBarManagerInternal statusbar = getStatusBarInternal();
                    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;
                    }
                }
            });
        }
@@ -69,8 +60,7 @@ public class StatusBarController extends BarController {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        IStatusBarService statusbar = getStatusBarService();
                    StatusBarManagerInternal statusbar = getStatusBarInternal();
                    if (statusbar != null) {
                        long startTime = calculateStatusBarTransitionStartTime(openAnimation,
                                closeAnimation);
@@ -78,11 +68,6 @@ public class StatusBarController extends BarController {
                                ? 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;
                    }
                }
            });
        }
@@ -92,16 +77,10 @@ public class StatusBarController extends BarController {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        IStatusBarService statusbar = getStatusBarService();
                    StatusBarManagerInternal statusbar = getStatusBarInternal();
                    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;
                    }
                }
            });
        }
Loading