Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 380ac73a authored by Diego Vela's avatar Diego Vela Committed by Automerger Merge Worker
Browse files

Merge "Downgrade Window JetPack" into rvc-dev am: ada8355b am: 59da843b am: 21b220c5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11618862

Change-Id: I1e60124a4253c64cebeceede5123b5f65ba3ce81
parents ea514111 21b220c5
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -13,26 +13,26 @@
// limitations under the License.
// limitations under the License.


android_library_import {
android_library_import {
    name: "window-extensions",
    name: "window-sidecar",
    aars: ["window-extensions-release.aar"],
    aars: ["window-sidecar-release.aar"],
    sdk_version: "current",
    sdk_version: "current",
}
}


java_library {
java_library {
    name: "androidx.window.extensions",
    name: "androidx.window.sidecar",
    srcs: ["src/**/*.java"],
    srcs: ["src/**/*.java"],
    static_libs: ["window-extensions"],
    static_libs: ["window-sidecar"],
    installable: true,
    installable: true,
    sdk_version: "core_platform",
    sdk_version: "core_platform",
    vendor: true,
    vendor: true,
    libs: ["framework", "androidx.annotation_annotation",],
    libs: ["framework", "androidx.annotation_annotation",],
    required: ["androidx.window.extensions.xml",],
    required: ["androidx.window.sidecar.xml",],
}
}


prebuilt_etc {
prebuilt_etc {
    name: "androidx.window.extensions.xml",
    name: "androidx.window.sidecar.xml",
    vendor: true,
    vendor: true,
    sub_dir: "permissions",
    sub_dir: "permissions",
    src: "androidx.window.extensions.xml",
    src: "androidx.window.sidecar.xml",
    filename_from_src: true,
    filename_from_src: true,
}
}
+0 −21
Original line number Original line Diff line number Diff line
<?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>
+21 −0
Original line number Original line Diff line number Diff line
<?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>
+27 −22
Original line number Original line Diff line number Diff line
/*
/*
 * 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");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -14,14 +14,14 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


package androidx.window.extensions;
package androidx.window.sidecar;


import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;


import static androidx.window.extensions.ExtensionHelper.getWindowDisplay;
import static androidx.window.sidecar.SidecarHelper.getWindowDisplay;
import static androidx.window.extensions.ExtensionHelper.isInMultiWindow;
import static androidx.window.sidecar.SidecarHelper.isInMultiWindow;
import static androidx.window.extensions.ExtensionHelper.rotateRectToDisplayRotation;
import static androidx.window.sidecar.SidecarHelper.rotateRectToDisplayRotation;
import static androidx.window.extensions.ExtensionHelper.transformToWindowSpaceRect;
import static androidx.window.sidecar.SidecarHelper.transformToWindowSpaceRect;


import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
@@ -42,8 +42,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.Pattern;


class SettingsExtensionImpl extends StubExtension {
class SettingsSidecarImpl extends StubSidecar {
    private static final String TAG = "SettingsExtension";
    private static final String TAG = "SettingsSidecar";


    private static final String DEVICE_POSTURE = "device_posture";
    private static final String DEVICE_POSTURE = "device_posture";
    private static final String DISPLAY_FEATURES = "display_features";
    private static final String DISPLAY_FEATURES = "display_features";
@@ -106,7 +106,7 @@ class SettingsExtensionImpl extends StubExtension {
        }
        }
    }
    }


    SettingsExtensionImpl(Context context) {
    SettingsSidecarImpl(Context context) {
        mContext = context;
        mContext = context;
        mSettingsObserver = new SettingsObserver();
        mSettingsObserver = new SettingsObserver();
    }
    }
@@ -118,29 +118,33 @@ class SettingsExtensionImpl extends StubExtension {
    /** Update display features with values read from settings. */
    /** Update display features with values read from settings. */
    private void updateDisplayFeatures() {
    private void updateDisplayFeatures() {
        for (IBinder windowToken : getWindowsListeningForLayoutChanges()) {
        for (IBinder windowToken : getWindowsListeningForLayoutChanges()) {
            ExtensionWindowLayoutInfo newLayout = getWindowLayoutInfo(windowToken);
            SidecarWindowLayoutInfo newLayout = getWindowLayoutInfo(windowToken);
            updateWindowLayout(windowToken, newLayout);
            updateWindowLayout(windowToken, newLayout);
        }
        }
    }
    }


    @NonNull
    @NonNull
    @Override
    @Override
    public ExtensionDeviceState getDeviceState() {
    public SidecarDeviceState getDeviceState() {
        ContentResolver resolver = mContext.getContentResolver();
        ContentResolver resolver = mContext.getContentResolver();
        int posture = Settings.Global.getInt(resolver, DEVICE_POSTURE,
        int posture = Settings.Global.getInt(resolver, DEVICE_POSTURE,
                ExtensionDeviceState.POSTURE_UNKNOWN);
                SidecarDeviceState.POSTURE_UNKNOWN);
        return new ExtensionDeviceState(posture);
        SidecarDeviceState deviceState = new SidecarDeviceState();
        deviceState.posture = posture;
        return deviceState;
    }
    }


    @NonNull
    @NonNull
    @Override
    @Override
    public ExtensionWindowLayoutInfo getWindowLayoutInfo(@NonNull IBinder windowToken) {
    public SidecarWindowLayoutInfo getWindowLayoutInfo(@NonNull IBinder windowToken) {
        List<ExtensionDisplayFeature> displayFeatures = readDisplayFeatures(windowToken);
        List<SidecarDisplayFeature> displayFeatures = readDisplayFeatures(windowToken);
        return new ExtensionWindowLayoutInfo(displayFeatures);
        SidecarWindowLayoutInfo windowLayoutInfo = new SidecarWindowLayoutInfo();
        windowLayoutInfo.displayFeatures = displayFeatures;
        return windowLayoutInfo;
    }
    }


    private List<ExtensionDisplayFeature> readDisplayFeatures(IBinder windowToken) {
    private List<SidecarDisplayFeature> readDisplayFeatures(IBinder windowToken) {
        List<ExtensionDisplayFeature> features = new ArrayList<ExtensionDisplayFeature>();
        List<SidecarDisplayFeature> features = new ArrayList<SidecarDisplayFeature>();
        int displayId = getWindowDisplay(windowToken);
        int displayId = getWindowDisplay(windowToken);
        if (displayId != DEFAULT_DISPLAY) {
        if (displayId != DEFAULT_DISPLAY) {
            Log.w(TAG, "This sample doesn't support display features on secondary displays");
            Log.w(TAG, "This sample doesn't support display features on secondary displays");
@@ -170,10 +174,10 @@ class SettingsExtensionImpl extends StubExtension {
                int type;
                int type;
                switch (featureType) {
                switch (featureType) {
                    case FEATURE_TYPE_FOLD:
                    case FEATURE_TYPE_FOLD:
                        type = ExtensionDisplayFeature.TYPE_FOLD;
                        type = SidecarDisplayFeature.TYPE_FOLD;
                        break;
                        break;
                    case FEATURE_TYPE_HINGE:
                    case FEATURE_TYPE_HINGE:
                        type = ExtensionDisplayFeature.TYPE_HINGE;
                        type = SidecarDisplayFeature.TYPE_HINGE;
                        break;
                        break;
                    default: {
                    default: {
                        Log.e(TAG, "Malformed feature type: " + featureType);
                        Log.e(TAG, "Malformed feature type: " + featureType);
@@ -189,8 +193,9 @@ class SettingsExtensionImpl extends StubExtension {
                rotateRectToDisplayRotation(featureRect, displayId);
                rotateRectToDisplayRotation(featureRect, displayId);
                transformToWindowSpaceRect(featureRect, windowToken);
                transformToWindowSpaceRect(featureRect, windowToken);
                if (!featureRect.isEmpty()) {
                if (!featureRect.isEmpty()) {
                    ExtensionDisplayFeature feature =
                    SidecarDisplayFeature feature = new SidecarDisplayFeature();
                            new ExtensionDisplayFeature(featureRect, type);
                    feature.setRect(featureRect);
                    feature.setType(type);
                    features.add(feature);
                    features.add(feature);
                } else {
                } else {
                    Log.w(TAG, "Failed to adjust feature to window");
                    Log.w(TAG, "Failed to adjust feature to window");
+3 −8
Original line number Original line Diff line number Diff line
/*
/*
 * 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");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


package androidx.window.extensions;
package androidx.window.sidecar;


import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_0;
@@ -32,12 +32,7 @@ import android.view.Surface;


import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


/**
class SidecarHelper {
 * 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 {
    /**
    /**
     * Rotate the input rectangle specified in default display orientation to the current display
     * Rotate the input rectangle specified in default display orientation to the current display
     * rotation.
     * rotation.
Loading