From 500f74f78fa330bc8b9ba05262007e502cc6a623 Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Thu, 8 Sep 2022 19:43:48 +0530 Subject: [PATCH] Trust: restrict-usb: Check DPM for support * Pixels have switched to the new AIDL HAL, so V1_3 doesn't exist there * Switch to directly checking DPM since that's where we found this code in the first place, and it'll keep getting updated. Change-Id: Icfc30b73984e82809c3838c421e05da7addaa6cb --- Android.bp | 1 - .../platform/internal/TrustInterfaceService.java | 15 ++++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Android.bp b/Android.bp index 35ed21c9..4145e4f6 100644 --- a/Android.bp +++ b/Android.bp @@ -66,7 +66,6 @@ lineage_sdk_internal_src = "sdk/src/java/org/lineageos/internal" library_src = "lineage/lib/main/java" lineage_sdk_LOCAL_STATIC_JAVA_LIBRARIES = [ - "android.hardware.usb-V1.3-java", "vendor.lineage.livedisplay-V2.0-java", "vendor.lineage.livedisplay-V2.1-java", "vendor.lineage.touch-V1.0-java", diff --git a/lineage/lib/main/java/org/lineageos/platform/internal/TrustInterfaceService.java b/lineage/lib/main/java/org/lineageos/platform/internal/TrustInterfaceService.java index bff2ee84..5ffde1a7 100644 --- a/lineage/lib/main/java/org/lineageos/platform/internal/TrustInterfaceService.java +++ b/lineage/lib/main/java/org/lineageos/platform/internal/TrustInterfaceService.java @@ -39,7 +39,6 @@ import lineageos.providers.LineageSettings; import lineageos.trust.ITrustInterface; import lineageos.trust.TrustInterface; -import android.hardware.usb.V1_3.IUsb; import vendor.lineage.trust.V1_0.IUsbRestrict; import java.text.ParseException; @@ -69,7 +68,6 @@ public class TrustInterfaceService extends LineageSystemService { private NotificationManager mNotificationManager = null; private IUsbRestrict mUsbRestrictor = null; - private IUsb mUsb = null; public TrustInterfaceService(Context context) { super(context); @@ -96,12 +94,6 @@ public class TrustInterfaceService extends LineageSystemService { if (phase == PHASE_BOOT_COMPLETED) { mNotificationManager = mContext.getSystemService(NotificationManager.class); - try { - mUsb = IUsb.getService(); - } catch (NoSuchElementException | RemoteException e) { - // ignore, the hal is not available - } - try { mUsbRestrictor = IUsbRestrict.getService(); } catch (NoSuchElementException | RemoteException e) { @@ -172,7 +164,12 @@ public class TrustInterfaceService extends LineageSystemService { } private boolean hasUsbRestrictorInternal() { - return mUsb != null || mUsbRestrictor != null; + DevicePolicyManager policyManager = mContext.getSystemService(DevicePolicyManager.class); + if (policyManager != null) { + return policyManager.canUsbDataSignalingBeDisabled(); + } else { + return mUsbRestrictor != null; + } } private boolean postOnBoardingNotification() {