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

Commit df8ae818 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Move USI version configuration from config.xml to DisplayDeviceConfig

A static configuration of the USI version supported by a display was
added in change Ia19dbb9251d0f710ad0d1187ba9a3607540fbee4.

Move this static display-specific configuration from config.xml to
DisplayDeviceConfig.

Bug: 265843204
Test: Presubmit
Change-Id: I9ea5a635fbbb0dc57abb869f2f8fcb509a76a58d
parent e81026fa
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.companion.virtual.IVirtualDevice;
import android.graphics.Point;
import android.hardware.SensorManager;
import android.hardware.input.HostUsiVersion;
import android.os.Handler;
import android.os.PowerManager;
import android.util.IntArray;
@@ -402,6 +403,14 @@ public abstract class DisplayManagerInternal {
     */
    public abstract SurfaceControl.DisplayPrimaries getDisplayNativePrimaries(int displayId);

    /**
     * Get the version of the Universal Stylus Initiative (USI) Protocol supported by the display.
     * @param displayId The id of the display.
     * @return The USI version, or null if not supported
     */
    @Nullable
    public abstract HostUsiVersion getHostUsiVersion(int displayId);

    /**
     * Describes the requested power state of the display.
     *
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware.input;

import android.graphics.Rect;
import android.hardware.input.HostUsiVersion;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.KeyboardLayout;
import android.hardware.input.IInputDevicesChangedListener;
@@ -233,4 +234,6 @@ interface IInputManager {
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
            + "android.Manifest.permission.MONITOR_KEYBOARD_BACKLIGHT)")
    void unregisterKeyboardBacklightListener(IKeyboardBacklightListener listener);

    HostUsiVersion getHostUsiVersionFromDisplayConfig(int displayId);
}
+4 −30
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ import android.os.VibrationEffect;
import android.os.Vibrator;
import android.os.VibratorManager;
import android.provider.Settings;
import android.util.DisplayUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.Display;
@@ -70,7 +69,6 @@ import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.SomeArgs;
@@ -1663,35 +1661,11 @@ public final class InputManager {
        // If there are no input devices that report a valid USI version, see if there is a config
        // that specifies the USI version for the display. This is to handle cases where the USI
        // input device is not registered by the kernel/driver all the time.
        return findConfigUsiVersionForDisplay(display);
    }

    private HostUsiVersion findConfigUsiVersionForDisplay(@NonNull Display display) {
        final Context context = getContext();
        final String[] displayUniqueIds = context.getResources().getStringArray(
                R.array.config_displayUniqueIdArray);
        final int index;
        if (displayUniqueIds.length == 0 && display.getDisplayId() == context.getDisplayId()) {
            index = 0;
        } else {
            index = DisplayUtils.getDisplayUniqueIdConfigIndex(context.getResources(),
                    display.getUniqueId());
        }

        final String[] versions = context.getResources().getStringArray(
                R.array.config_displayUsiVersionArray);
        if (index < 0 || index >= versions.length) {
            return null;
        }
        final String version = versions[index];
        if (version == null || version.isEmpty()) {
            return null;
        }
        final String[] majorMinor = version.split("\\.");
        if (majorMinor.length != 2) {
            throw new IllegalStateException("Failed to parse USI version: " + version);
        try {
            return mIm.getHostUsiVersionFromDisplayConfig(display.getDisplayId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return new HostUsiVersion(Integer.parseInt(majorMinor[0]), Integer.parseInt(majorMinor[1]));
    }

    private void populateInputDevicesLocked() {
+0 −18
Original line number Diff line number Diff line
@@ -5820,7 +5820,6 @@
           - config_roundedCornerDrawableArray (config in SystemUI resource)
           - config_roundedCornerTopDrawableArray (config in SystemUI resource)
           - config_roundedCornerBottomDrawableArray (config in SystemUI resource)
           - config_displayUsiVersionArray

         Leave this array empty for single display device and the system will load the default main
         built-in related configs.
@@ -6189,21 +6188,4 @@
        trusted certificate using the SHA-256 digest algorithm. -->
    <string-array name="config_healthConnectMigrationKnownSigners">
    </string-array>

    <!-- The Universal Stylus Initiative (USI) protocol version supported by each display.
         (@see https://universalstylus.org/).

         The i-th value in this array corresponds to the supported USI version of the i-th display
         listed in config_displayUniqueIdArray. On a single-display device, the
         config_displayUniqueIdArray may be empty, in which case the only value in this array should
         be the USI version for the main built-in display.

         If the display does not support USI, the version value should be an empty string. If the
         display supports USI, the version must be in the following format:
           "<major-version>.<minor-version>"

         For example, "", "1.0", and "2.0" are valid values. -->
    <string-array name="config_displayUsiVersionArray" translatable="false">
        <item>""</item>
    </string-array>
</resources>
+0 −1
Original line number Diff line number Diff line
@@ -4782,7 +4782,6 @@
  <java-symbol type="array" name="config_mainBuiltInDisplayWaterfallCutout" />
  <java-symbol type="array" name="config_secondaryBuiltInDisplayWaterfallCutout" />
  <java-symbol type="array" name="config_waterfallCutoutArray" />
  <java-symbol type="array" name="config_displayUsiVersionArray" />

  <java-symbol type="fraction" name="global_actions_vertical_padding_percentage" />
  <java-symbol type="fraction" name="global_actions_horizontal_padding_percentage" />
Loading