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

Commit 83c8bf29 authored by Santos Cordon's avatar Santos Cordon Committed by Automerger Merge Worker
Browse files

Add static display layout XML files. am: 6c1dca2e

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Icd31c81a1e5b00d6804f02db2719fc6c8e358036
parents d28f7330 6c1dca2e
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -673,15 +673,6 @@
        -->
    </integer-array>

    <!-- The device states (supplied by DeviceStateManager) that should be treated as unfolded by
         the display fold controller. Default is empty. -->
    <integer-array name="config_unfoldedDeviceStates">
        <!-- Example:
        <item>3</item>
        <item>4</item>
        -->
    </integer-array>

    <!-- Indicate the display area rect for foldable devices in folded state. -->
    <string name="config_foldedArea"></string>

@@ -4675,15 +4666,6 @@
    <!-- WindowsManager JetPack display features -->
    <string name="config_display_features" translatable="false" />

    <!-- Physical Display IDs of the display-devices that are swapped when a folding device folds.
         This list is expected to contain two elements: the first is the display to use
         when the device is folded, the second is the display to use when unfolded. If the array
         is empty or the display IDs are not recognized, this feature is turned off and the value
         ignored.
         TODO: b/170470621 - remove once we can have multiple Internal displays in DMS as
               well as a notification from DisplayStateManager. -->
    <string-array name="config_internalFoldedPhysicalDisplayIds" translatable="false" />

    <!-- Aspect ratio of task level letterboxing. Values <= 1.0 will be ignored.
         Note: Activity min/max aspect ratio restrictions will still be respected by the
         activity-level letterboxing (size-compat mode). Therefore this override can control the
+0 −2
Original line number Diff line number Diff line
@@ -3769,7 +3769,6 @@

  <!-- For Foldables -->
  <java-symbol type="array" name="config_foldedDeviceStates" />
  <java-symbol type="array" name="config_unfoldedDeviceStates" />
  <java-symbol type="string" name="config_foldedArea" />

  <java-symbol type="array" name="config_disableApksUnlessMatchedSku_apk_list" />
@@ -4163,7 +4162,6 @@
  <java-symbol type="dimen" name="default_background_blur_radius" />
  <java-symbol type="array" name="config_keep_warming_services" />
  <java-symbol type="string" name="config_display_features" />
  <java-symbol type="array" name="config_internalFoldedPhysicalDisplayIds" />

  <java-symbol type="dimen" name="controls_thumbnail_image_max_height" />
  <java-symbol type="dimen" name="controls_thumbnail_image_max_width" />
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ java_library_static {
        ":platform-compat-config",
        ":platform-compat-overrides",
        ":display-device-config",
        ":display-layout-config",
        ":cec-config",
        ":device-state-config",
        "java/com/android/server/EventLogTags.logtags",
+43 −43
Original line number Diff line number Diff line
@@ -16,17 +16,26 @@

package com.android.server.display;

import android.content.Context;
import android.hardware.devicestate.DeviceStateManager;
import android.text.TextUtils;
import android.os.Environment;
import android.util.IndentingPrintWriter;
import android.util.Slog;
import android.util.SparseArray;
import android.view.DisplayAddress;

import com.android.server.display.config.layout.Layouts;
import com.android.server.display.config.layout.XmlParser;
import com.android.server.display.layout.Layout;

import java.util.Arrays;
import org.xmlpull.v1.XmlPullParserException;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.xml.datatype.DatatypeConfigurationException;

/**
 * Mapping from device states into {@link Layout}s. This allows us to map device
@@ -39,11 +48,14 @@ class DeviceStateToLayoutMap {

    public static final int STATE_DEFAULT = DeviceStateManager.INVALID_DEVICE_STATE;

    private static final String CONFIG_FILE_PATH =
            "etc/displayconfig/display_layout_configuration.xml";

    private final SparseArray<Layout> mLayoutMap = new SparseArray<>();

    DeviceStateToLayoutMap(Context context) {
        mLayoutMap.append(STATE_DEFAULT, new Layout());
        loadFoldedDisplayConfig(context);
    DeviceStateToLayoutMap() {
        loadLayoutsFromConfig();
        createLayout(STATE_DEFAULT);
    }

    public void dumpLocked(IndentingPrintWriter ipw) {
@@ -76,48 +88,36 @@ class DeviceStateToLayoutMap {
    }

    /**
     * Loads config.xml-specified folded configurations for foldable devices.
     * Reads display-layout-configuration files to get the layouts to use for this device.
     */
    private void loadFoldedDisplayConfig(Context context) {
        final String[] strDisplayIds = context.getResources().getStringArray(
                com.android.internal.R.array.config_internalFoldedPhysicalDisplayIds);
        if (strDisplayIds.length != 2 || TextUtils.isEmpty(strDisplayIds[0])
                || TextUtils.isEmpty(strDisplayIds[1])) {
            Slog.w(TAG, "Folded display configuration invalid: [" + Arrays.toString(strDisplayIds)
                    + "]");
            return;
        }
    private void loadLayoutsFromConfig() {
        final File configFile = Environment.buildPath(
                Environment.getVendorDirectory(), CONFIG_FILE_PATH);

        final long[] displayIds;
        try {
            displayIds = new long[] {
                Long.parseLong(strDisplayIds[0]),
                Long.parseLong(strDisplayIds[1])
            };
        } catch (NumberFormatException nfe) {
            Slog.w(TAG, "Folded display config non numerical: " + Arrays.toString(strDisplayIds));
        if (!configFile.exists()) {
            return;
        }

        final int[] foldedDeviceStates = context.getResources().getIntArray(
                com.android.internal.R.array.config_foldedDeviceStates);
        final int[] unfoldedDeviceStates = context.getResources().getIntArray(
                com.android.internal.R.array.config_unfoldedDeviceStates);
        // Only add folded states if folded state config is not empty
        if (foldedDeviceStates.length == 0 || unfoldedDeviceStates.length == 0) {
        Slog.i(TAG, "Loading display layouts from " + configFile);
        try (InputStream in = new BufferedInputStream(new FileInputStream(configFile))) {
            final Layouts layouts = XmlParser.read(in);
            if (layouts == null) {
                Slog.i(TAG, "Display layout config not found: " + configFile);
                return;
            }

        for (int state : foldedDeviceStates) {
            // Create the folded state layout
            createLayout(state).createDisplayLocked(
                    DisplayAddress.fromPhysicalDisplayId(displayIds[0]), true /*isDefault*/);
            for (com.android.server.display.config.layout.Layout l : layouts.getLayout()) {
                final int state = l.getState().intValue();
                final Layout layout = createLayout(state);
                for (com.android.server.display.config.layout.Display d: l.getDisplay()) {
                    layout.createDisplayLocked(
                            DisplayAddress.fromPhysicalDisplayId(d.getAddress().longValue()),
                            d.getIsDefault(),
                            d.getEnabled());
                }

        for (int state : unfoldedDeviceStates) {
            // Create the unfolded state layout
            createLayout(state).createDisplayLocked(
                    DisplayAddress.fromPhysicalDisplayId(displayIds[1]), true /*isDefault*/);
            }
        } catch (IOException | DatatypeConfigurationException | XmlPullParserException e) {
            Slog.e(TAG, "Encountered an error while reading/parsing display layout config file: "
                    + configFile, e);
        }
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -423,7 +423,7 @@ public final class DisplayManagerService extends SystemService {
        mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper());
        mUiHandler = UiThread.getHandler();
        mDisplayDeviceRepo = new DisplayDeviceRepository(mSyncRoot, mPersistentDataStore);
        mLogicalDisplayMapper = new LogicalDisplayMapper(context, mDisplayDeviceRepo,
        mLogicalDisplayMapper = new LogicalDisplayMapper(mDisplayDeviceRepo,
                new LogicalDisplayListener());
        mDisplayModeDirector = new DisplayModeDirector(context, mHandler);
        mBrightnessSynchronizer = new BrightnessSynchronizer(mContext);
@@ -1178,7 +1178,10 @@ public final class DisplayManagerService extends SystemService {

    private void handleLogicalDisplayRemovedLocked(@NonNull LogicalDisplay display) {
        final int displayId = display.getDisplayIdLocked();
        mDisplayPowerControllers.removeReturnOld(displayId).stop();
        final DisplayPowerController dpc = mDisplayPowerControllers.removeReturnOld(displayId);
        if (dpc != null) {
            dpc.stop();
        }
        mDisplayStates.delete(displayId);
        mDisplayBrightnesses.delete(displayId);
        DisplayManagerGlobal.invalidateLocalDisplayInfoCaches();
@@ -1200,9 +1203,6 @@ public final class DisplayManagerService extends SystemService {
        // by the display power controller (if known).
        DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
        if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
            // TODO - b/170498827 The rules regarding what display state to apply to each
            // display will depend on the configuration/mapping of logical displays.
            // Clean up LogicalDisplay.isEnabled() mechanism once this is fixed.
            final LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(device);
            final int state;
            final int displayId = display.getDisplayIdLocked();
Loading