Merge "Move some IWindowManager methods to internal interface" into tm-qpr-dev

This commit is contained in:
Riddle Hsu
2022-05-05 05:49:25 +00:00
committed by Android (Google) Code Review
6 changed files with 22 additions and 49 deletions

View File

@@ -251,18 +251,6 @@ interface IWindowManager
*/ */
void refreshScreenCaptureDisabled(); 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. * Retrieve the current orientation of the primary screen.
* @return Constant as per {@link android.view.Surface.Rotation}. * @return Constant as per {@link android.view.Surface.Rotation}.
@@ -442,11 +430,6 @@ interface IWindowManager
@UnsupportedAppUsage @UnsupportedAppUsage
boolean isSafeModeEnabled(); boolean isSafeModeEnabled();
/**
* Enables the screen if all conditions are met.
*/
void enableScreenIfNeeded();
/** /**
* Clears the frame statistics for a given window. * 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.Display;
import android.view.HapticFeedbackConstants; import android.view.HapticFeedbackConstants;
import android.view.IDisplayFoldListener; import android.view.IDisplayFoldListener;
import android.view.IWindowManager;
import android.view.InputDevice; import android.view.InputDevice;
import android.view.KeyCharacterMap; import android.view.KeyCharacterMap;
import android.view.KeyCharacterMap.FallbackAction; import android.view.KeyCharacterMap.FallbackAction;
@@ -383,7 +382,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private final SparseArray<ScreenOnListener> mScreenOnListeners = new SparseArray<>(); private final SparseArray<ScreenOnListener> mScreenOnListeners = new SparseArray<>();
Context mContext; Context mContext;
IWindowManager mWindowManager;
WindowManagerFuncs mWindowManagerFuncs; WindowManagerFuncs mWindowManagerFuncs;
WindowManagerInternal mWindowManagerInternal; WindowManagerInternal mWindowManagerInternal;
PowerManager mPowerManager; PowerManager mPowerManager;
@@ -1883,10 +1881,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void init(Context context, IWindowManager windowManager, public void init(Context context, WindowManagerFuncs windowManagerFuncs) {
WindowManagerFuncs windowManagerFuncs) {
mContext = context; mContext = context;
mWindowManager = windowManager;
mWindowManagerFuncs = windowManagerFuncs; mWindowManagerFuncs = windowManagerFuncs;
mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
@@ -4814,10 +4810,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
if (enableScreen) { if (enableScreen) {
try { mWindowManagerFuncs.enableScreenIfNeeded();
mWindowManager.enableScreenIfNeeded();
} catch (RemoteException unhandled) {
}
} }
} }
@@ -5274,12 +5267,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
void updateRotation(boolean alwaysSendConfiguration) { void updateRotation(boolean alwaysSendConfiguration) {
try { mWindowManagerFuncs.updateRotation(alwaysSendConfiguration, false /* forceRelayout */);
// Set orientation on WindowManager.
mWindowManager.updateRotation(alwaysSendConfiguration, false /* forceRelayout */);
} catch (RemoteException e) {
// Ignore
}
} }
/** /**

View File

@@ -78,7 +78,6 @@ import android.util.Slog;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
import android.view.Display; import android.view.Display;
import android.view.IDisplayFoldListener; import android.view.IDisplayFoldListener;
import android.view.IWindowManager;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.WindowManagerGlobal; 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. * @return {@code true} if app transition state is idle on the default display.
*/ */
boolean isAppTransitionStateIdle(); 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. * @param context The system context we are running in.
*/ */
public void init(Context context, IWindowManager windowManager, void init(Context context, WindowManagerFuncs windowManagerFuncs);
WindowManagerFuncs windowManagerFuncs);
/** /**
* Check permissions when adding a window. * Check permissions when adding a window.

View File

@@ -1173,7 +1173,7 @@ public class WindowManagerService extends IWindowManager.Stub
@Override @Override
public void run() { public void run() {
WindowManagerPolicyThread.set(Thread.currentThread(), Looper.myLooper()); WindowManagerPolicyThread.set(Thread.currentThread(), Looper.myLooper());
mPolicy.init(mContext, WindowManagerService.this, WindowManagerService.this); mPolicy.init(mContext, WindowManagerService.this);
} }
}, 0); }, 0);
} }

View File

@@ -26,7 +26,6 @@ import android.os.IBinder;
import android.os.PowerManager.GoToSleepReason; import android.os.PowerManager.GoToSleepReason;
import android.os.PowerManager.WakeReason; import android.os.PowerManager.WakeReason;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
import android.view.IWindowManager;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation; import android.view.animation.Animation;
@@ -50,8 +49,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
} }
@Override @Override
public void init(Context context, IWindowManager windowManager, public void init(Context context, WindowManagerFuncs windowManagerFuncs) {
WindowManagerFuncs windowManagerFuncs) {
} }
public void setDefaultDisplay(DisplayContentInfo displayContentInfo) { public void setDefaultDisplay(DisplayContentInfo displayContentInfo) {

View File

@@ -123,16 +123,6 @@ public class WindowManagerPermissionTests extends TestCase {
@SmallTest @SmallTest
public void testSET_ORIENTATION() { 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 { try {
mWm.freezeRotation(-1); mWm.freezeRotation(-1);
fail("IWindowManager.freezeRotation did not throw SecurityException as" fail("IWindowManager.freezeRotation did not throw SecurityException as"