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
This commit is contained in:
Chirayu Desai
2022-09-08 19:43:48 +05:30
committed by Bruno Martins
parent 607d627706
commit 500f74f78f
2 changed files with 6 additions and 10 deletions

View File

@@ -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",

View File

@@ -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() {