summaryrefslogtreecommitdiff
path: root/core/java/android/window/WindowProviderService.java
diff options
context:
space:
mode:
authorCharles Chen <charlesccchen@google.com>2021-06-25 14:38:55 +0800
committerCharles Chen <charlesccchen@google.com>2021-08-11 23:43:01 +0800
commit8bae39cab2a9c1ad7827e5d67dae1023f9493a06 (patch)
treee704f743ef6f84f02882377217ff04eedc1fa30f /core/java/android/window/WindowProviderService.java
parentb37ecaa4dce03116a9e994e545ab16b477676115 (diff)
Allow WPS to create windows with multiple type
Before WindowProviderService, Service can add windows with several window types. This is previously not allowed for WindowProviderService because a context can only associate with a window container. However, it may cause regressions because Service is used to add windows with multiple types. This CL allows WindowProviderService to do so, but WindowProviderService can only associate with the window type returned by #getWindowType. This CL also extracts some methods to WindowContext interface so that WindowContext and WindowProviderService can reuse the same interface. Test: atest WindowContextPolicyTests StrictModeTest Test: atest ContextIsUiContextTest ContextGetDisplayTest Test: atest WindowContextTest WindowContextTests fixes: 191959013 Change-Id: Ie16916b370a4cbb8a17ccaec9870d47b4b089390
Diffstat (limited to 'core/java/android/window/WindowProviderService.java')
-rw-r--r--core/java/android/window/WindowProviderService.java36
1 files changed, 26 insertions, 10 deletions
diff --git a/core/java/android/window/WindowProviderService.java b/core/java/android/window/WindowProviderService.java
index 5171adf168ce..033b9eda9da4 100644
--- a/core/java/android/window/WindowProviderService.java
+++ b/core/java/android/window/WindowProviderService.java
@@ -42,21 +42,26 @@ import android.view.WindowManagerImpl;
* {@link WindowContext}, but is represented as {@link Service}.
*
* @see android.inputmethodservice.InputMethodService
- * @see android.accessibilityservice.AccessibilityService
*
* @hide
*/
@TestApi
@UiContext
-public abstract class WindowProviderService extends Service {
+public abstract class WindowProviderService extends Service implements WindowProvider {
+ private final Bundle mOptions;
private final WindowTokenClient mWindowToken = new WindowTokenClient();
private final WindowContextController mController = new WindowContextController(mWindowToken);
private WindowManager mWindowManager;
private boolean mInitialized;
+ public WindowProviderService() {
+ mOptions = new Bundle();
+ mOptions.putBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE, true);
+ }
+
/**
- * Returns the type of this {@link WindowProviderService}.
+ * Returns the window type of this {@link WindowProviderService}.
* Each inheriting class must implement this method to provide the type of the window. It is
* used similar to {@code type} of {@link Context#createWindowContext(int, Bundle)}
*
@@ -68,15 +73,24 @@ public abstract class WindowProviderService extends Service {
@SuppressLint("OnNameExpected")
// Suppress the lint because it is not a callback and users should provide window type
// so we cannot make it final.
- public abstract @WindowType int getWindowType();
+ @WindowType
+ @Override
+ public abstract int getWindowType();
/**
* Returns the option of this {@link WindowProviderService}.
- * Default is {@code null}. The inheriting class can implement this method to provide the
- * customization {@code option} of the window. It is used similar to {@code options} of
- * {@link Context#createWindowContext(int, Bundle)}
- *
- * @see Context#createWindowContext(int, Bundle)
+ * <p>
+ * The inheriting class can implement this method to provide the customization {@code option} of
+ * the window, but must be based on this method's returned value.
+ * It is used similar to {@code options} of {@link Context#createWindowContext(int, Bundle)}
+ * </p>
+ * <pre class="prettyprint">
+ * public Bundle getWindowContextOptions() {
+ * final Bundle options = super.getWindowContextOptions();
+ * options.put(KEY_ROOT_DISPLAY_AREA_ID, displayAreaInfo.rootDisplayAreaId);
+ * return options;
+ * }
+ * </pre>
*
* @hide
*/
@@ -85,8 +99,10 @@ public abstract class WindowProviderService extends Service {
// Suppress the lint because it is not a callback and users may override this API to provide
// launch option. Also, the return value of this API is null by default.
@Nullable
+ @CallSuper
+ @Override
public Bundle getWindowContextOptions() {
- return null;
+ return mOptions;
}
/**