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

Commit c140750f authored by Chris Li's avatar Chris Li
Browse files

Add a WM server side utility to cache and read trunk stable flags

Because server side flag can be used at anytime, updating flags should
only take effect after device reboot.

Bug: 291681490
Test: adb shell device_config put [namespace] [package].[name]
Change-Id: I433fdbadbb5f73c2154f9c336b7350516c94f359
parent 3d252012
Loading
Loading
Loading
Loading
+49 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2023 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.server.wm;

import com.android.window.flags.Flags;

/**
 * Utility class to read the flags used in the WindowManager server.
 *
 * It is not very cheap to read trunk stable flag, so having a centralized place to cache the flag
 * values in the system server side.
 *
 * Flags should be defined in `core.java.android.window.flags` to allow access from client side.
 *
 * To override flag:
 *   adb shell device_config put [namespace] [package].[name] [true/false]
 *   adb reboot
 *
 * To access in wm:
 *   {@link WindowManagerService#mFlags}
 *
 * Notes:
 *   The system may use flags at anytime, so changing flags will only take effect after device
 *   reboot. Otherwise, it may result unexpected behavior, such as broken transition.
 *   When a flag needs to be read from both the server side and the client side, changing the flag
 *   value will result difference in server and client until device reboot.
 */
class WindowManagerFlags {

    /* Start Available Flags */

    final boolean mSyncWindowConfigUpdateFlag = Flags.syncWindowConfigUpdateFlag();

    /* End Available Flags */
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -546,6 +546,8 @@ public class WindowManagerService extends IWindowManager.Stub
    @VisibleForTesting
    @VisibleForTesting
    WindowManagerPolicy mPolicy;
    WindowManagerPolicy mPolicy;


    final WindowManagerFlags mFlags;

    final IActivityManager mActivityManager;
    final IActivityManager mActivityManager;
    final ActivityManagerInternal mAmInternal;
    final ActivityManagerInternal mAmInternal;
    final UserManagerInternal mUmInternal;
    final UserManagerInternal mUmInternal;
@@ -1152,6 +1154,7 @@ public class WindowManagerService extends IWindowManager.Stub
        mGlobalLock = atm.getGlobalLock();
        mGlobalLock = atm.getGlobalLock();
        mAtmService = atm;
        mAtmService = atm;
        mContext = context;
        mContext = context;
        mFlags = new WindowManagerFlags();
        mIsPc = mContext.getPackageManager().hasSystemFeature(FEATURE_PC);
        mIsPc = mContext.getPackageManager().hasSystemFeature(FEATURE_PC);
        mAllowBootMessages = showBootMsgs;
        mAllowBootMessages = showBootMsgs;
        mLimitedAlphaCompositing = context.getResources().getBoolean(
        mLimitedAlphaCompositing = context.getResources().getBoolean(