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

Unverified Commit 57901115 authored by Chirayu Desai's avatar Chirayu Desai Committed by Michael Bestas
Browse files

Drop support for legacy USB restrictor

* Doesn't compile after 14 QPR2 / AP1A
* Has always been an issue for CTS
[CIRCULAR REFERENCE: com.android.tools.r8.internal.h: Library class vendor.lineage.trust.V1_0.IUsbRestrict implements program class android.hidl.base.V1_0.IBase]

Change-Id: Id2a4ccc60d7cae6bca02e302725d982d50311278
parent 16fec389
Loading
Loading
Loading
Loading
+1 −21
Original line number Diff line number Diff line
@@ -97,7 +97,6 @@ import com.android.server.utils.EventLogger;
import com.android.server.wm.ActivityTaskManagerInternal;

import lineageos.providers.LineageSettings;
import vendor.lineage.trust.V1_0.IUsbRestrict;

import java.io.File;
import java.io.FileDescriptor;
@@ -607,8 +606,6 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
        protected int mCurrentGadgetHalVersion;
        protected boolean mPendingBootAccessoryHandshakeBroadcast;

        private IUsbRestrict mUsbRestrictor;

        /**
         * The persistent property which stores whether adb is enabled or not.
         * May also contain vendor-specific default functions for testing purposes.
@@ -647,12 +644,6 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
            boolean massStorageSupported = primary != null && primary.allowMassStorage();
            mUseUsbNotification = !massStorageSupported && mContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_usbChargingMessage);

            try {
                mUsbRestrictor = IUsbRestrict.getService();
            } catch (NoSuchElementException | RemoteException ignored) {
                // This feature is not supported
            }
        }

        public void sendMessage(int what, boolean arg) {
@@ -1690,26 +1681,15 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                    || restrictUsb == 2;

            UsbManager usbManager = mContext.getSystemService(UsbManager.class);
            boolean useUsbManager = false;
            try {
                if (usbManager != null &&
                        usbManager.getUsbHalVersion() >= UsbManager.USB_HAL_V1_3) {
                    useUsbManager = true;
                    usbManager.enableUsbDataSignal(!shouldRestrict);
                }
            } catch (RuntimeException ignore) {
                // Can't get USB Hal version. Assume it's an unsupported version and
                // don't try using UsbManager to toggle USB data.
            }

            if (!useUsbManager || !usbManager.enableUsbDataSignal(!shouldRestrict)) {
                try {
                    if (mUsbRestrictor != null) {
                        mUsbRestrictor.setEnabled(shouldRestrict);
                    }
                } catch (RemoteException ignored) {
                    // This feature is not supported
                }
            }
        }
    }