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

Commit 1c2e9a19 authored by Adrian Roos's avatar Adrian Roos
Browse files

DeviceConfig: Split android:window_manager into android and window_manager

The keys are split according to whether they affect the system as a whole,
or simply the inner workings of the window manager.

Also encapsulates WindowManagerConstants properly and adds testing.

Bug: 139735771
Test: atest WindowManagerConstantsTest
Change-Id: I67c96a2bdd3140fe2ff9c6832d2d69f2e57115e2
parent 56af6730
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -2359,6 +2359,11 @@ package android.print {

package android.provider {

  public interface AndroidDeviceConfig {
    field public static final String KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE = "system_gestures_excluded_by_pre_q_sticky_immersive";
    field public static final String KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP = "system_gesture_exclusion_limit_dp";
  }

  public static final class CalendarContract.Calendars implements android.provider.BaseColumns android.provider.CalendarContract.CalendarColumns android.provider.CalendarContract.SyncColumns {
    field public static final String[] SYNC_WRITABLE_COLUMNS;
  }
@@ -2394,13 +2399,13 @@ package android.provider {
    method public static void removeOnPropertiesChangedListener(@NonNull android.provider.DeviceConfig.OnPropertiesChangedListener);
    method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static void resetToDefaults(int, @Nullable String);
    method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperty(@NonNull String, @NonNull String, @Nullable String, boolean);
    field public static final String NAMESPACE_ANDROID = "android";
    field public static final String NAMESPACE_AUTOFILL = "autofill";
    field public static final String NAMESPACE_CONTENT_CAPTURE = "content_capture";
    field public static final String NAMESPACE_PERMISSIONS = "permissions";
    field public static final String NAMESPACE_PRIVACY = "privacy";
    field public static final String NAMESPACE_ROLLBACK = "rollback";
    field public static final String NAMESPACE_ROLLBACK_BOOT = "rollback_boot";
    field public static final String NAMESPACE_WINDOW_MANAGER = "android:window_manager";
  }

  public static interface DeviceConfig.OnPropertiesChangedListener {
@@ -2417,11 +2422,6 @@ package android.provider {
    method @Nullable public String getString(@NonNull String, @Nullable String);
  }

  public static interface DeviceConfig.WindowManager {
    field public static final String KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE = "system_gestures_excluded_by_pre_q_sticky_immersive";
    field public static final String KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP = "system_gesture_exclusion_limit_dp";
  }

  public final class MediaStore {
    method @RequiresPermission(android.Manifest.permission.CLEAR_APP_USER_DATA) public static void deleteContributedMedia(android.content.Context, String, android.os.UserHandle) throws java.io.IOException;
    method @RequiresPermission(android.Manifest.permission.CLEAR_APP_USER_DATA) public static long getContributedMediaSize(android.content.Context, String, android.os.UserHandle) throws java.io.IOException;
+48 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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 android.provider;

import android.annotation.TestApi;

/**
 * Interface for accessing keys belonging to {@link DeviceConfig#NAMESPACE_ANDROID}.
 * @hide
 */
@TestApi
public interface AndroidDeviceConfig {

    /**
     * Key for accessing the system gesture exclusion limit (an integer in dp).
     *
     * <p>Note: On Devices running Q, this key is in the "android:window_manager" namespace.
     *
     * @see android.provider.DeviceConfig#NAMESPACE_ANDROID
     */
    String KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP = "system_gesture_exclusion_limit_dp";

    /**
     * Key for controlling whether system gestures are implicitly excluded by windows requesting
     * sticky immersive mode from apps that are targeting an SDK prior to Q.
     *
     * <p>Note: On Devices running Q, this key is in the "android:window_manager" namespace.
     *
     * @see android.provider.DeviceConfig#NAMESPACE_ANDROID
     */
    String KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE =
            "system_gestures_excluded_by_pre_q_sticky_immersive";

}
+12 −45
Original line number Diff line number Diff line
@@ -314,13 +314,22 @@ public final class DeviceConfig {
    public static final String NAMESPACE_SETTINGS_UI = "settings_ui";

    /**
     * Namespace for window manager related features. The names to access the properties in this
     * namespace should be defined in {@link WindowManager}.
     * Namespace for android related features, i.e. for flags that affect not just a single
     * component, but the entire system.
     *
     * The keys for this namespace are defined in {@link AndroidDeviceConfig}.
     *
     * @hide
     */
    @TestApi
    public static final String NAMESPACE_WINDOW_MANAGER = "android:window_manager";
    public static final String NAMESPACE_ANDROID = "android";

    /**
     * Namespace for window manager related features.
     *
     * @hide
     */
    public static final String NAMESPACE_WINDOW_MANAGER = "window_manager";

    /**
     * List of namespaces which can be read without READ_DEVICE_CONFIG permission
@@ -348,48 +357,6 @@ public final class DeviceConfig {
    @TestApi
    public static final String NAMESPACE_PERMISSIONS = "permissions";

    /**
     * Interface for accessing keys belonging to {@link #NAMESPACE_WINDOW_MANAGER}.
     * @hide
     */
    @TestApi
    public interface WindowManager {

        /**
         * Key for accessing the system gesture exclusion limit (an integer in dp).
         *
         * @see android.provider.DeviceConfig#NAMESPACE_WINDOW_MANAGER
         * @hide
         */
        @TestApi
        String KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP = "system_gesture_exclusion_limit_dp";

        /**
         * Key for controlling whether system gestures are implicitly excluded by windows requesting
         * sticky immersive mode from apps that are targeting an SDK prior to Q.
         *
         * @see android.provider.DeviceConfig#NAMESPACE_WINDOW_MANAGER
         * @hide
         */
        @TestApi
        String KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE =
                "system_gestures_excluded_by_pre_q_sticky_immersive";

        /**
         * The minimum duration between gesture exclusion logging for a given window in
         * milliseconds.
         *
         * Events that happen in-between will be silently dropped.
         *
         * A non-positive value disables logging.
         *
         * @see android.provider.DeviceConfig#NAMESPACE_WINDOW_MANAGER
         * @hide
         */
        String KEY_SYSTEM_GESTURE_EXCLUSION_LOG_DEBOUNCE_MILLIS =
                "system_gesture_exclusion_log_debounce_millis";
    }

    private static final Object sLock = new Object();
    @GuardedBy("sLock")
    private static ArrayMap<OnPropertiesChangedListener, Pair<String, Executor>> sListeners =
+3 −3
Original line number Diff line number Diff line
@@ -858,7 +858,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        mWallpaperController = new WallpaperController(mWmService, this);
        display.getDisplayInfo(mDisplayInfo);
        display.getMetrics(mDisplayMetrics);
        mSystemGestureExclusionLimit = mWmService.mSystemGestureExclusionLimitDp
        mSystemGestureExclusionLimit = mWmService.mConstants.mSystemGestureExclusionLimitDp
                * mDisplayMetrics.densityDpi / DENSITY_DEFAULT;
        isDefaultDisplay = mDisplayId == DEFAULT_DISPLAY;
        mDisplayFrames = new DisplayFrames(mDisplayId, mDisplayInfo,
@@ -2038,7 +2038,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    }

    void updateSystemGestureExclusionLimit() {
        mSystemGestureExclusionLimit = mWmService.mSystemGestureExclusionLimitDp
        mSystemGestureExclusionLimit = mWmService.mConstants.mSystemGestureExclusionLimitDp
                * mDisplayMetrics.densityDpi / DENSITY_DEFAULT;
        updateSystemGestureExclusion();
    }
@@ -5096,7 +5096,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     * @return Whether gesture exclusion area should be logged for the given window
     */
    static boolean logsGestureExclusionRestrictions(WindowState win) {
        if (win.mWmService.mSystemGestureExclusionLogDebounceTimeoutMillis <= 0) {
        if (win.mWmService.mConstants.mSystemGestureExclusionLogDebounceTimeoutMillis <= 0) {
            return false;
        }
        final WindowManager.LayoutParams attrs = win.getAttrs();
+3 −29
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ import android.util.ArraySet;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BackgroundThread;
import com.android.server.wm.utils.DeviceConfigInterface;

import java.io.PrintWriter;
import java.util.concurrent.Executor;

/**
 * A Blacklist for packages that should force the display out of high refresh rate.
@@ -45,25 +45,7 @@ class HighRefreshRateBlacklist {
    private OnPropertiesChangedListener mListener = new OnPropertiesChangedListener();

    static HighRefreshRateBlacklist create(@NonNull Resources r) {
        return new HighRefreshRateBlacklist(r, new DeviceConfigInterface() {
            @Override
            public @Nullable String getProperty(@NonNull String namespace, @NonNull String name) {
                return DeviceConfig.getProperty(namespace, name);
            }

            @Override
            public void addOnPropertiesChangedListener(@NonNull String namespace,
                    @NonNull Executor executor,
                    @NonNull DeviceConfig.OnPropertiesChangedListener listener) {
                DeviceConfig.addOnPropertiesChangedListener(namespace, executor, listener);
            }

            @Override
            public void removePropertiesChangedListener(
                    DeviceConfig.OnPropertiesChangedListener listener) {
                DeviceConfig.removeOnPropertiesChangedListener(listener);
            }
        });
        return new HighRefreshRateBlacklist(r, DeviceConfigInterface.REAL);
    }

    @VisibleForTesting
@@ -116,19 +98,11 @@ class HighRefreshRateBlacklist {
    /** Used to prevent WmTests leaking issues. */
    @VisibleForTesting
    void dispose() {
        mDeviceConfig.removePropertiesChangedListener(mListener);
        mDeviceConfig.removeOnPropertiesChangedListener(mListener);
        mDeviceConfig = null;
        mBlacklistedPackages.clear();
    }

    interface DeviceConfigInterface {
        @Nullable String getProperty(@NonNull String namespace, @NonNull String name);
        void addOnPropertiesChangedListener(@NonNull String namespace, @NonNull Executor executor,
                @NonNull DeviceConfig.OnPropertiesChangedListener listener);
        void removePropertiesChangedListener(
                @NonNull DeviceConfig.OnPropertiesChangedListener listener);
    }

    private class OnPropertiesChangedListener implements DeviceConfig.OnPropertiesChangedListener {
        public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
            updateBlacklist(
Loading