diff options
author | Diego Vela <diegovela@google.com> | 2020-06-02 10:28:16 -0700 |
---|---|---|
committer | Diego Vela <diegovela@google.com> | 2020-06-03 15:44:46 -0700 |
commit | b9437ef4f12c5b9307c50bf4a294cbc1b62f2c1a (patch) | |
tree | 6f772667450aa204f271a4c8ddf6f8b874bb561c /libs/WindowManager | |
parent | cf3274b3ba66ab6403b92c4ac4244ec8999ac016 (diff) |
Downgrade Window JetPack
Add window sidecar aar.
Add settings implementation of SidecarInterface.
Bug: 157477145
Test: use a device with sidecar and not window extensions.
atest CtsWindowManagerJetpackTestCases:ExtensionTest
Change-Id: Iade7a4ba5a75ba7301cd151b54a95820a3d4bdde
Diffstat (limited to 'libs/WindowManager')
-rw-r--r-- | libs/WindowManager/Jetpack/Android.bp | 14 | ||||
-rw-r--r-- | libs/WindowManager/Jetpack/androidx.window.extensions.xml | 21 | ||||
-rw-r--r-- | libs/WindowManager/Jetpack/androidx.window.sidecar.xml | 21 | ||||
-rw-r--r-- | libs/WindowManager/Jetpack/src/androidx/window/sidecar/SettingsSidecarImpl.java (renamed from libs/WindowManager/Jetpack/src/androidx/window/extensions/SettingsExtensionImpl.java) | 49 | ||||
-rw-r--r-- | libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarHelper.java (renamed from libs/WindowManager/Jetpack/src/androidx/window/extensions/ExtensionHelper.java) | 11 | ||||
-rw-r--r-- | libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarProvider.java (renamed from libs/WindowManager/Jetpack/src/androidx/window/extensions/ExtensionProvider.java) | 17 | ||||
-rw-r--r-- | libs/WindowManager/Jetpack/src/androidx/window/sidecar/StubSidecar.java | 85 | ||||
-rw-r--r-- | libs/WindowManager/Jetpack/window-extensions-release.aar | bin | 6427 -> 0 bytes | |||
-rw-r--r-- | libs/WindowManager/Jetpack/window-sidecar-release.aar | bin | 0 -> 4366 bytes |
9 files changed, 151 insertions, 67 deletions
diff --git a/libs/WindowManager/Jetpack/Android.bp b/libs/WindowManager/Jetpack/Android.bp index 308c1a59a7aa..4f4364f72fef 100644 --- a/libs/WindowManager/Jetpack/Android.bp +++ b/libs/WindowManager/Jetpack/Android.bp @@ -13,26 +13,26 @@ // limitations under the License. android_library_import { - name: "window-extensions", - aars: ["window-extensions-release.aar"], + name: "window-sidecar", + aars: ["window-sidecar-release.aar"], sdk_version: "current", } java_library { - name: "androidx.window.extensions", + name: "androidx.window.sidecar", srcs: ["src/**/*.java"], - static_libs: ["window-extensions"], + static_libs: ["window-sidecar"], installable: true, sdk_version: "core_platform", vendor: true, libs: ["framework", "androidx.annotation_annotation",], - required: ["androidx.window.extensions.xml",], + required: ["androidx.window.sidecar.xml",], } prebuilt_etc { - name: "androidx.window.extensions.xml", + name: "androidx.window.sidecar.xml", vendor: true, sub_dir: "permissions", - src: "androidx.window.extensions.xml", + src: "androidx.window.sidecar.xml", filename_from_src: true, } diff --git a/libs/WindowManager/Jetpack/androidx.window.extensions.xml b/libs/WindowManager/Jetpack/androidx.window.extensions.xml deleted file mode 100644 index 1f0ff6656de0..000000000000 --- a/libs/WindowManager/Jetpack/androidx.window.extensions.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright 2020 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<permissions> - <library - name="androidx.window.extensions" - file="/vendor/framework/androidx.window.extensions.jar"/> -</permissions> diff --git a/libs/WindowManager/Jetpack/androidx.window.sidecar.xml b/libs/WindowManager/Jetpack/androidx.window.sidecar.xml new file mode 100644 index 000000000000..f88a5f4ae039 --- /dev/null +++ b/libs/WindowManager/Jetpack/androidx.window.sidecar.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2020 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> +<permissions> + <library + name="androidx.window.sidecar" + file="/vendor/framework/androidx.window.sidecar.jar"/> +</permissions> diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/SettingsExtensionImpl.java b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SettingsSidecarImpl.java index 7a3fbf3ad9b8..92e575804bbe 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/SettingsExtensionImpl.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SettingsSidecarImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,14 @@ * limitations under the License. */ -package androidx.window.extensions; +package androidx.window.sidecar; import static android.view.Display.DEFAULT_DISPLAY; -import static androidx.window.extensions.ExtensionHelper.getWindowDisplay; -import static androidx.window.extensions.ExtensionHelper.isInMultiWindow; -import static androidx.window.extensions.ExtensionHelper.rotateRectToDisplayRotation; -import static androidx.window.extensions.ExtensionHelper.transformToWindowSpaceRect; +import static androidx.window.sidecar.SidecarHelper.getWindowDisplay; +import static androidx.window.sidecar.SidecarHelper.isInMultiWindow; +import static androidx.window.sidecar.SidecarHelper.rotateRectToDisplayRotation; +import static androidx.window.sidecar.SidecarHelper.transformToWindowSpaceRect; import android.content.ContentResolver; import android.content.Context; @@ -42,8 +42,8 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -class SettingsExtensionImpl extends StubExtension { - private static final String TAG = "SettingsExtension"; +class SettingsSidecarImpl extends StubSidecar { + private static final String TAG = "SettingsSidecar"; private static final String DEVICE_POSTURE = "device_posture"; private static final String DISPLAY_FEATURES = "display_features"; @@ -106,7 +106,7 @@ class SettingsExtensionImpl extends StubExtension { } } - SettingsExtensionImpl(Context context) { + SettingsSidecarImpl(Context context) { mContext = context; mSettingsObserver = new SettingsObserver(); } @@ -118,29 +118,33 @@ class SettingsExtensionImpl extends StubExtension { /** Update display features with values read from settings. */ private void updateDisplayFeatures() { for (IBinder windowToken : getWindowsListeningForLayoutChanges()) { - ExtensionWindowLayoutInfo newLayout = getWindowLayoutInfo(windowToken); + SidecarWindowLayoutInfo newLayout = getWindowLayoutInfo(windowToken); updateWindowLayout(windowToken, newLayout); } } @NonNull @Override - public ExtensionDeviceState getDeviceState() { + public SidecarDeviceState getDeviceState() { ContentResolver resolver = mContext.getContentResolver(); int posture = Settings.Global.getInt(resolver, DEVICE_POSTURE, - ExtensionDeviceState.POSTURE_UNKNOWN); - return new ExtensionDeviceState(posture); + SidecarDeviceState.POSTURE_UNKNOWN); + SidecarDeviceState deviceState = new SidecarDeviceState(); + deviceState.posture = posture; + return deviceState; } @NonNull @Override - public ExtensionWindowLayoutInfo getWindowLayoutInfo(@NonNull IBinder windowToken) { - List<ExtensionDisplayFeature> displayFeatures = readDisplayFeatures(windowToken); - return new ExtensionWindowLayoutInfo(displayFeatures); + public SidecarWindowLayoutInfo getWindowLayoutInfo(@NonNull IBinder windowToken) { + List<SidecarDisplayFeature> displayFeatures = readDisplayFeatures(windowToken); + SidecarWindowLayoutInfo windowLayoutInfo = new SidecarWindowLayoutInfo(); + windowLayoutInfo.displayFeatures = displayFeatures; + return windowLayoutInfo; } - private List<ExtensionDisplayFeature> readDisplayFeatures(IBinder windowToken) { - List<ExtensionDisplayFeature> features = new ArrayList<ExtensionDisplayFeature>(); + private List<SidecarDisplayFeature> readDisplayFeatures(IBinder windowToken) { + List<SidecarDisplayFeature> features = new ArrayList<SidecarDisplayFeature>(); int displayId = getWindowDisplay(windowToken); if (displayId != DEFAULT_DISPLAY) { Log.w(TAG, "This sample doesn't support display features on secondary displays"); @@ -170,10 +174,10 @@ class SettingsExtensionImpl extends StubExtension { int type; switch (featureType) { case FEATURE_TYPE_FOLD: - type = ExtensionDisplayFeature.TYPE_FOLD; + type = SidecarDisplayFeature.TYPE_FOLD; break; case FEATURE_TYPE_HINGE: - type = ExtensionDisplayFeature.TYPE_HINGE; + type = SidecarDisplayFeature.TYPE_HINGE; break; default: { Log.e(TAG, "Malformed feature type: " + featureType); @@ -189,8 +193,9 @@ class SettingsExtensionImpl extends StubExtension { rotateRectToDisplayRotation(featureRect, displayId); transformToWindowSpaceRect(featureRect, windowToken); if (!featureRect.isEmpty()) { - ExtensionDisplayFeature feature = - new ExtensionDisplayFeature(featureRect, type); + SidecarDisplayFeature feature = new SidecarDisplayFeature(); + feature.setRect(featureRect); + feature.setType(type); features.add(feature); } else { Log.w(TAG, "Failed to adjust feature to window"); diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/ExtensionHelper.java b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarHelper.java index c61f1ed2d179..e5b6cff17b26 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/ExtensionHelper.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package androidx.window.extensions; +package androidx.window.sidecar; import static android.view.Display.INVALID_DISPLAY; import static android.view.Surface.ROTATION_0; @@ -32,12 +32,7 @@ import android.view.Surface; import androidx.annotation.Nullable; -/** - * Toolkit class for calculation of the display feature bounds within the window. - * NOTE: This sample implementation only works for Activity windows, because there is no public APIs - * to obtain layout params or bounds for arbitrary windows. - */ -class ExtensionHelper { +class SidecarHelper { /** * Rotate the input rectangle specified in default display orientation to the current display * rotation. diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/ExtensionProvider.java b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarProvider.java index 47349f11fb93..0b4915ed5dac 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/ExtensionProvider.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package androidx.window.extensions; +package androidx.window.sidecar; import android.content.Context; @@ -22,14 +22,13 @@ import android.content.Context; * Provider class that will instantiate the library implementation. It must be included in the * vendor library, and the vendor implementation must match the signature of this class. */ -public class ExtensionProvider { - +public class SidecarProvider { /** - * The support library will instantiate the vendor implementation using this interface. - * @return An implementation of {@link ExtensionInterface}. + * Provide a simple implementation of {@link SidecarInterface} that can be replaced by + * an OEM by overriding this method. */ - public static ExtensionInterface getExtensionImpl(Context context) { - return new SettingsExtensionImpl(context); + public static SidecarInterface getSidecarImpl(Context context) { + return new SettingsSidecarImpl(context); } /** @@ -37,6 +36,6 @@ public class ExtensionProvider { * @return API version string in MAJOR.MINOR.PATCH-description format. */ public static String getApiVersion() { - return "1.0.0-settings_sample"; + return "0.1.0-settings_sample"; } } diff --git a/libs/WindowManager/Jetpack/src/androidx/window/sidecar/StubSidecar.java b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/StubSidecar.java new file mode 100644 index 000000000000..199c37315c07 --- /dev/null +++ b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/StubSidecar.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package androidx.window.sidecar; + +import android.os.IBinder; + +import androidx.annotation.NonNull; + +import java.util.HashSet; +import java.util.Set; + +/** + * Basic implementation of the {@link SidecarInterface}. An OEM can choose to use it as the base + * class for their implementation. + */ +abstract class StubSidecar implements SidecarInterface { + + private SidecarCallback mSidecarCallback; + private final Set<IBinder> mWindowLayoutChangeListenerTokens = new HashSet<>(); + private boolean mDeviceStateChangeListenerRegistered; + + StubSidecar() { + } + + @Override + public void setSidecarCallback(@NonNull SidecarCallback sidecarCallback) { + this.mSidecarCallback = sidecarCallback; + } + + @Override + public void onWindowLayoutChangeListenerAdded(@NonNull IBinder iBinder) { + this.mWindowLayoutChangeListenerTokens.add(iBinder); + this.onListenersChanged(); + } + + @Override + public void onWindowLayoutChangeListenerRemoved(@NonNull IBinder iBinder) { + this.mWindowLayoutChangeListenerTokens.remove(iBinder); + this.onListenersChanged(); + } + + @Override + public void onDeviceStateListenersChanged(boolean isEmpty) { + this.mDeviceStateChangeListenerRegistered = !isEmpty; + this.onListenersChanged(); + } + + void updateDeviceState(SidecarDeviceState newState) { + if (this.mSidecarCallback != null) { + mSidecarCallback.onDeviceStateChanged(newState); + } + } + + void updateWindowLayout(@NonNull IBinder windowToken, + @NonNull SidecarWindowLayoutInfo newLayout) { + if (this.mSidecarCallback != null) { + mSidecarCallback.onWindowLayoutChanged(windowToken, newLayout); + } + } + + @NonNull + Set<IBinder> getWindowsListeningForLayoutChanges() { + return mWindowLayoutChangeListenerTokens; + } + + protected boolean hasListeners() { + return !mWindowLayoutChangeListenerTokens.isEmpty() || mDeviceStateChangeListenerRegistered; + } + + protected abstract void onListenersChanged(); +} diff --git a/libs/WindowManager/Jetpack/window-extensions-release.aar b/libs/WindowManager/Jetpack/window-extensions-release.aar Binary files differdeleted file mode 100644 index 0ebbb86daf82..000000000000 --- a/libs/WindowManager/Jetpack/window-extensions-release.aar +++ /dev/null diff --git a/libs/WindowManager/Jetpack/window-sidecar-release.aar b/libs/WindowManager/Jetpack/window-sidecar-release.aar Binary files differnew file mode 100644 index 000000000000..50f101d7d181 --- /dev/null +++ b/libs/WindowManager/Jetpack/window-sidecar-release.aar |