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

Commit 24ce9bae authored by Xiaozhen Lin's avatar Xiaozhen Lin
Browse files

UsbService:update mUsbDisableRequesters for enableUsbDataWhileDocked()

1. mUsbDisableRequesters list needs to be updated for enableUsbDataWhileDocked(). If list size > 0, We shouldn't enable USB Data Signaling.
2. Update the callback in enableUsbData() before it returns

Bug: 287498482
Test: manual testing
Change-Id: I8c311c25dccc513dac9aa8cfcd6e419c1aa3f87f
parent ab57e5b3
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -894,7 +894,14 @@ public class UsbService extends IUsbManager.Stub {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null);

        if (android.hardware.usb.flags.Flags.enableUsbDataSignalStaking()) {
            if (!shouldUpdateUsbSignaling(portId, enable, Binder.getCallingUid())) return false;
            if (!shouldUpdateUsbSignaling(portId, enable, Binder.getCallingUid())) {
                try {
                    callback.onOperationComplete(USB_OPERATION_ERROR_INTERNAL);
                } catch (RemoteException e) {
                    Slog.e(TAG, "enableUsbData: Failed to call onOperationComplete", e);
                }
                return false;
            }
        }

        final long ident = Binder.clearCallingIdentity();
@@ -950,8 +957,19 @@ public class UsbService extends IUsbManager.Stub {
                "enableUsbDataWhileDocked: callback must not be null. opId:"
                + operationId);
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null);

        if (android.hardware.usb.flags.Flags.enableUsbDataSignalStaking()) {
            if (!shouldUpdateUsbSignaling(portId, true, Binder.getCallingUid())) {
                try {
                    callback.onOperationComplete(USB_OPERATION_ERROR_INTERNAL);
                } catch (RemoteException e) {
                    Slog.e(TAG, "enableUsbDataWhileDocked: Failed to call onOperationComplete", e);
                }
                return;
            }
        }

        final long ident = Binder.clearCallingIdentity();
        boolean wait;
        try {
            if (mPortManager != null) {
                mPortManager.enableUsbDataWhileDocked(portId, operationId, callback, null);