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

Commit 8fc60dd7 authored by Marzia Favaro's avatar Marzia Favaro
Browse files

Enable app handle on foldables (reland)

The resource config_enableAppHandle that was supposed to be used before
was not very practical. Since there wasn't an overlay config common to
all large screens (or at least foldble devices), it was impractial to
override the resource on all the required devices, especially non-pixels.

This change enables the app handle for devices that have at least one
built-in large screen.

Bug: 377689543
Test: WMShellUnitTests
Test: Manual, app handle shows on foldable
Flag: com.android.window.flags.universal_resizable_by_default
Change-Id: Idf4438d288d5644c607af98f121a03c24302c9be
parent 253eda20
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE;
import static android.Manifest.permission.CONTROL_DISPLAY_BRIGHTNESS;
import static android.hardware.flags.Flags.FLAG_OVERLAYPROPERTIES_CLASS_API;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;

import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_GET_SUPPORTED_REFRESH_RATES;
import static com.android.server.display.feature.flags.Flags.FLAG_HIGHEST_HDR_SDR_RATIO_API;
@@ -58,6 +59,7 @@ import android.os.SystemClock;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -1047,6 +1049,19 @@ public final class Display {
        }
    }

    /**
     * Returns the smallest size of the display in dp
     * @hide
     */
    public float getMinSizeDimensionDp() {
        synchronized (mLock) {
            updateDisplayInfoLocked();
            mDisplayInfo.getAppMetrics(mTempMetrics);
            return TypedValue.deriveDimension(COMPLEX_UNIT_DIP,
                    Math.min(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight), mTempMetrics);
        }
    }

    /**
     * @deprecated Use {@link WindowMetrics#getBounds#width()} instead.
     */
+0 −4
Original line number Diff line number Diff line
@@ -7213,10 +7213,6 @@
         screen. -->
    <bool name="config_dragToMaximizeInDesktopMode">false</bool>

    <!-- Whether showing the app handle is supported on this device.
         If config_isDesktopModeSupported, then this has no effect -->
    <bool name="config_enableAppHandle">false</bool>

    <!-- Frame rate compatibility value for Wallpaper
         FRAME_RATE_COMPATIBILITY_MIN (102) is used by default for lower power consumption -->
    <integer name="config_wallpaperFrameRateCompatibility">102</integer>
+0 −3
Original line number Diff line number Diff line
@@ -5764,9 +5764,6 @@
       screen. -->
  <java-symbol type="bool" name="config_dragToMaximizeInDesktopMode" />

  <!-- Whether showing the app handle is supported on this device -->
  <java-symbol type="bool" name="config_enableAppHandle" />

  <!-- Frame rate compatibility value for Wallpaper -->
  <java-symbol type="integer" name="config_wallpaperFrameRateCompatibility" />

+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ filegroup {
    name: "wm_shell-shared-utils",
    srcs: [
        "src/com/android/wm/shell/shared/TransitionUtil.java",
        "src/com/android/wm/shell/shared/Utils.java",
    ],
}

@@ -71,6 +72,7 @@ java_library {
    srcs: [
        "**/desktopmode/*.java",
        "**/desktopmode/*.kt",
        ":wm_shell-shared-utils",
    ],
    static_libs: [
        "com.android.window.flags.window-aconfig-java",
+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 com.android.wm.shell.shared;

import android.annotation.NonNull;

import java.util.function.Supplier;

/**
 * This class provides generic utility methods and classes for shell
 */
public class Utils {

    /**
     * Lazily returns object from a supplier with caching
     * @param <T> type of object to get
     */
    public static class Lazy<T> {
        private T mInstance;

        /**
         * @param supplier the supplier to use, when the instance has not yet been initialized
         * @return the cached value or the value from the supplier
         */
        public final T get(@NonNull Supplier<T> supplier) {
            if (mInstance == null) {
                mInstance = supplier.get();
            }
            return mInstance;
        }
    }
}
Loading