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

Commit f3269137 authored by Roy Luo's avatar Roy Luo Committed by Android (Google) Code Review
Browse files

Merge "Guard uevent migration with genfs label version" into main

parents 0589188c 5e49cc0c
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.SELinux;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UEventObserver;
@@ -161,6 +162,11 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
    private static final String MIDI_ALSA_PATH =
            "/sys/class/android_usb/android0/f_midi/alsa";

    /**
     * The minimum SELinux genfs labels version that supports udc sysfs genfs context.
     */
    private static final int MIN_SELINUX_GENFS_LABELS_VERSION = 202404;

    private static final int MSG_UPDATE_STATE = 0;
    private static final int MSG_ENABLE_ADB = 1;
    private static final int MSG_SET_CURRENT_FUNCTIONS = 2;
@@ -445,7 +451,8 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser

        mEnableUdcSysfsUsbStateUpdate =
                android.hardware.usb.flags.Flags.enableUdcSysfsUsbStateUpdate()
                && context.getResources().getBoolean(R.bool.config_enableUdcSysfsUsbStateUpdate);
                && context.getResources().getBoolean(R.bool.config_enableUdcSysfsUsbStateUpdate)
                && SELinux.getGenfsLabelsVersion() > MIN_SELINUX_GENFS_LABELS_VERSION;

        if (mEnableUdcSysfsUsbStateUpdate) {
            mUEventObserver.startObserving(UDC_SUBSYS_MATCH);