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

Commit 6b9b18f6 authored by Paul McLean's avatar Paul McLean
Browse files

Hide "Always Allow" UI for USB warning instances.

Bug: 144993164
Test: Run UsbAccess test app with "microphone" permission removed,
connect a USB peripheral with audio capture endpoints, note that
"Always allow..." checkbox is disabled.

Change-Id: I80d6076e57d610583a2bdae4e4c93ced29d7e46d
parent 40160776
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ public class UsbPermissionActivity extends AlertActivity

        final AlertController.AlertParams ap = mAlertParams;
        ap.mTitle = appName;
        boolean useRecordWarning = false;
        if (mDevice == null) {
            // Accessory Case

@@ -97,13 +98,14 @@ public class UsbPermissionActivity extends AlertActivity
                            mPackageName)
                            == android.content.pm.PackageManager.PERMISSION_GRANTED;
            boolean isAudioCaptureDevice = mDevice.getHasAudioCapture();
            boolean useRecordWarning = isAudioCaptureDevice && !hasRecordPermission;
            useRecordWarning = isAudioCaptureDevice && !hasRecordPermission;

            int strID = useRecordWarning
                    ? R.string.usb_device_permission_prompt_warn
                    : R.string.usb_device_permission_prompt;
            ap.mMessage = getString(strID, appName, mDevice.getProductName());
            mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);

        }

        ap.mPositiveButtonText = getString(android.R.string.ok);
@@ -111,7 +113,8 @@ public class UsbPermissionActivity extends AlertActivity
        ap.mPositiveButtonListener = this;
        ap.mNegativeButtonListener = this;

        if (canBeDefault && (mDevice != null || mAccessory != null)) {
        // Don't show the "always use" checkbox if the USB/Record warning is in effect
        if (!useRecordWarning && canBeDefault && (mDevice != null || mAccessory != null)) {
            // add "open when" checkbox
            LayoutInflater inflater = (LayoutInflater) getSystemService(
                    Context.LAYOUT_INFLATER_SERVICE);