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

Commit 4bf606c5 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Move some IWindowManager methods to internal interface

The methods are only used in system server. It is unnecessary to
declare in aidl.

This also eliminates the confusion of missing permission check
for updateRotation().

Bug: 230863943
Test: atest WindowManagerPermissionTests
Change-Id: I703830650bab3a792982cada99aa1512430658a4
parent 923e43dc
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -251,18 +251,6 @@ interface IWindowManager
     */
    void refreshScreenCaptureDisabled();

    // These can only be called with the SET_ORIENTATION permission.
    /**
     * Update the current screen rotation based on the current state of
     * the world.
     * @param alwaysSendConfiguration Flag to force a new configuration to
     * be evaluated.  This can be used when there are other parameters in
     * configuration that are changing.
     * @param forceRelayout If true, the window manager will always do a relayout
     * of its windows even if the rotation hasn't changed.
     */
    void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout);

    /**
     * Retrieve the current orientation of the primary screen.
     * @return Constant as per {@link android.view.Surface.Rotation}.
@@ -442,11 +430,6 @@ interface IWindowManager
    @UnsupportedAppUsage
    boolean isSafeModeEnabled();

    /**
     * Enables the screen if all conditions are met.
     */
    void enableScreenIfNeeded();

    /**
     * Clears the frame statistics for a given window.
     *
+3 −15
Original line number Diff line number Diff line
@@ -171,7 +171,6 @@ import android.util.proto.ProtoOutputStream;
import android.view.Display;
import android.view.HapticFeedbackConstants;
import android.view.IDisplayFoldListener;
import android.view.IWindowManager;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyCharacterMap.FallbackAction;
@@ -383,7 +382,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private final SparseArray<ScreenOnListener> mScreenOnListeners = new SparseArray<>();

    Context mContext;
    IWindowManager mWindowManager;
    WindowManagerFuncs mWindowManagerFuncs;
    WindowManagerInternal mWindowManagerInternal;
    PowerManager mPowerManager;
@@ -1883,10 +1881,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    /** {@inheritDoc} */
    @Override
    public void init(Context context, IWindowManager windowManager,
            WindowManagerFuncs windowManagerFuncs) {
    public void init(Context context, WindowManagerFuncs windowManagerFuncs) {
        mContext = context;
        mWindowManager = windowManager;
        mWindowManagerFuncs = windowManagerFuncs;
        mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
        mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
@@ -4814,10 +4810,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }

        if (enableScreen) {
            try {
                mWindowManager.enableScreenIfNeeded();
            } catch (RemoteException unhandled) {
            }
            mWindowManagerFuncs.enableScreenIfNeeded();
        }
    }

@@ -5274,12 +5267,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    void updateRotation(boolean alwaysSendConfiguration) {
        try {
            // Set orientation on WindowManager.
            mWindowManager.updateRotation(alwaysSendConfiguration, false /* forceRelayout */);
        } catch (RemoteException e) {
            // Ignore
        }
        mWindowManagerFuncs.updateRotation(alwaysSendConfiguration, false /* forceRelayout */);
    }

    /**
+17 −3
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.Display;
import android.view.IDisplayFoldListener;
import android.view.IWindowManager;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -343,6 +342,22 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         * @return {@code true} if app transition state is idle on the default display.
         */
        boolean isAppTransitionStateIdle();

        /**
         * Enables the screen if all conditions are met.
         */
        void enableScreenIfNeeded();

        /**
         * Updates the current screen rotation based on the current state of the world.
         *
         * @param alwaysSendConfiguration Flag to force a new configuration to be evaluated.
         *                                This can be used when there are other parameters in
         *                                configuration that are changing.
         * @param forceRelayout If true, the window manager will always do a relayout of its
         *                      windows even if the rotation hasn't changed.
         */
        void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout);
    }

    /**
@@ -391,8 +406,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     *
     * @param context The system context we are running in.
     */
    public void init(Context context, IWindowManager windowManager,
            WindowManagerFuncs windowManagerFuncs);
    void init(Context context, WindowManagerFuncs windowManagerFuncs);

    /**
     * Check permissions when adding a window.
+1 −1
Original line number Diff line number Diff line
@@ -1173,7 +1173,7 @@ public class WindowManagerService extends IWindowManager.Stub
            @Override
            public void run() {
                WindowManagerPolicyThread.set(Thread.currentThread(), Looper.myLooper());
                mPolicy.init(mContext, WindowManagerService.this, WindowManagerService.this);
                mPolicy.init(mContext, WindowManagerService.this);
            }
        }, 0);
    }
+1 −3
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.os.IBinder;
import android.os.PowerManager.GoToSleepReason;
import android.os.PowerManager.WakeReason;
import android.util.proto.ProtoOutputStream;
import android.view.IWindowManager;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.view.animation.Animation;
@@ -50,8 +49,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
    }

    @Override
    public void init(Context context, IWindowManager windowManager,
            WindowManagerFuncs windowManagerFuncs) {
    public void init(Context context, WindowManagerFuncs windowManagerFuncs) {
    }

    public void setDefaultDisplay(DisplayContentInfo displayContentInfo) {
Loading