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
This commit is contained in:
Riddle Hsu
2022-05-04 18:36:26 +08:00
parent 923e43dc70
commit 4bf606c578
6 changed files with 22 additions and 49 deletions

View File

@@ -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.
*

View File

@@ -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 */);
}
/**

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -123,16 +123,6 @@ public class WindowManagerPermissionTests extends TestCase {
@SmallTest
public void testSET_ORIENTATION() {
try {
mWm.updateRotation(true, false);
fail("IWindowManager.updateRotation did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
// expected
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
try {
mWm.freezeRotation(-1);
fail("IWindowManager.freezeRotation did not throw SecurityException as"