diff options
| author | 2019-12-05 10:15:19 +0000 | |
|---|---|---|
| committer | 2019-12-06 10:32:17 +0000 | |
| commit | d69738602a34c995c313f071c2ad30be5924c735 (patch) | |
| tree | 28015d9f7d6129518fe668cee6e5830e82ae456e | |
| parent | 40067bbcd2e64e6fa7eccf31d71b7f4b43de2a63 (diff) | |
Move WindowControllerCallback methods into a delagate.
Adding @hide public methods to commonly subclassed classes like Activity
is never safe, as they can clash with existing methods in apps. Moving
@hide interface implementations into an inner class avoids the need to
add new @hide public methods in many cases.
Bug: 144361565
Test: Build, flash, boot device.
Change-Id: Ie8459c5a542e6ff4058d4ce783e27ebcf9c41dbb
| -rw-r--r-- | core/java/android/app/Activity.java | 110 |
1 files changed, 59 insertions, 51 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 6bea68b446a4..577272e38707 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -726,7 +726,7 @@ public class Activity extends ContextThemeWrapper implements LayoutInflater.Factory2, Window.Callback, KeyEvent.Callback, OnCreateContextMenuListener, ComponentCallbacks2, - Window.OnWindowDismissedCallback, WindowControllerCallback, + Window.OnWindowDismissedCallback, AutofillManager.AutofillClient, ContentCaptureManager.ContentCaptureClient { private static final String TAG = "Activity"; private static final boolean DEBUG_LIFECYCLE = false; @@ -938,6 +938,62 @@ public class Activity extends ContextThemeWrapper private Boolean mLastDispatchedIsInMultiWindowMode; private Boolean mLastDispatchedIsInPictureInPictureMode; + private final WindowControllerCallback mWindowControllerCallback = + new WindowControllerCallback() { + /** + * Moves the activity between {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing + * mode and {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}. + * + * @hide + */ + @Override + public void toggleFreeformWindowingMode() throws RemoteException { + ActivityTaskManager.getService().toggleFreeformWindowingMode(mToken); + } + + /** + * Puts the activity in picture-in-picture mode if the activity supports. + * @see android.R.attr#supportsPictureInPicture + * @hide + */ + @Override + public void enterPictureInPictureModeIfPossible() { + if (mActivityInfo.supportsPictureInPicture()) { + enterPictureInPictureMode(); + } + } + + @Override + public boolean isTaskRoot() { + try { + return ActivityTaskManager.getService().getTaskForActivity(mToken, true) >= 0; + } catch (RemoteException e) { + return false; + } + } + + /** + * Update the forced status bar color. + * @hide + */ + @Override + public void updateStatusBarColor(int color) { + mTaskDescription.setStatusBarColor(color); + setTaskDescription(mTaskDescription); + } + + /** + * Update the forced navigation bar color. + * @hide + */ + @Override + public void updateNavigationBarColor(int color) { + mTaskDescription.setNavigationBarColor(color); + setTaskDescription(mTaskDescription); + } + + }; + private static native String getDlWarning(); /** Return the intent that started this activity. */ @@ -3915,49 +3971,6 @@ public class Activity extends ContextThemeWrapper /** - * Moves the activity between {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing mode - * and {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}. - * - * @hide - */ - @Override - public void toggleFreeformWindowingMode() throws RemoteException { - ActivityTaskManager.getService().toggleFreeformWindowingMode(mToken); - } - - /** - * Update the forced status bar color. - * @hide - */ - @Override - public void updateStatusBarColor(int color) { - mTaskDescription.setStatusBarColor(color); - setTaskDescription(mTaskDescription); - } - - /** - * Update the forced navigation bar color. - * @hide - */ - @Override - public void updateNavigationBarColor(int color) { - mTaskDescription.setNavigationBarColor(color); - setTaskDescription(mTaskDescription); - } - - /** - * Puts the activity in picture-in-picture mode if the activity supports. - * @see android.R.attr#supportsPictureInPicture - * @hide - */ - @Override - public void enterPictureInPictureModeIfPossible() { - if (mActivityInfo.supportsPictureInPicture()) { - enterPictureInPictureMode(); - } - } - - /** * Called to process key events. You can override this to intercept all * key events before they are dispatched to the window. Be sure to call * this implementation for key events that should be handled normally. @@ -6603,13 +6616,8 @@ public class Activity extends ContextThemeWrapper * * @return True if this is the root activity, else false. */ - @Override public boolean isTaskRoot() { - try { - return ActivityTaskManager.getService().getTaskForActivity(mToken, true) >= 0; - } catch (RemoteException e) { - return false; - } + return mWindowControllerCallback.isTaskRoot(); } /** @@ -7801,7 +7809,7 @@ public class Activity extends ContextThemeWrapper mFragments.attachHost(null /*parent*/); mWindow = new PhoneWindow(this, window, activityConfigCallback); - mWindow.setWindowControllerCallback(this); + mWindow.setWindowControllerCallback(mWindowControllerCallback); mWindow.setCallback(this); mWindow.setOnWindowDismissedCallback(this); mWindow.getLayoutInflater().setPrivateFactory(this); |