From c90234a315c828169f0ae1e5b770ed25d8dd51bf Mon Sep 17 00:00:00 2001 From: Paul McLean Date: Mon, 25 Nov 2019 14:30:17 -0700 Subject: [PATCH] Hide "Always Allow" checkbox for "record warning" cases. This one for the UsbConfirmActivity. Bug: 145148679 Test: Install UsbAccess App, connect USB audio record device. Note that the "Always Allow: checkbox is removed. Change-Id: Iaac385f4640703e93b881eed7ab51e43e3656dd7 --- .../systemui/usb/UsbConfirmActivity.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java index fd99ef389bec1..286b7c049fc73 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java @@ -71,6 +71,7 @@ public class UsbConfirmActivity extends AlertActivity final AlertController.AlertParams ap = mAlertParams; ap.mTitle = appName; + boolean useRecordWarning = false; if (mDevice == null) { ap.mMessage = getString(R.string.usb_accessory_confirm_prompt, appName, mAccessory.getDescription()); @@ -83,7 +84,7 @@ public class UsbConfirmActivity extends AlertActivity packageName) == android.content.pm.PackageManager.PERMISSION_GRANTED; boolean isAudioCaptureDevice = mDevice.getHasAudioCapture(); - boolean useRecordWarning = isAudioCaptureDevice && !hasRecordPermission; + useRecordWarning = isAudioCaptureDevice && !hasRecordPermission; int strID = useRecordWarning ? R.string.usb_device_confirm_prompt_warn @@ -98,22 +99,23 @@ public class UsbConfirmActivity extends AlertActivity ap.mNegativeButtonListener = this; // add "always use" checkbox - LayoutInflater inflater = (LayoutInflater)getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - ap.mView = inflater.inflate(com.android.internal.R.layout.always_use_checkbox, null); - mAlwaysUse = (CheckBox)ap.mView.findViewById(com.android.internal.R.id.alwaysUse); - if (mDevice == null) { - mAlwaysUse.setText(getString(R.string.always_use_accessory, appName, - mAccessory.getDescription())); - } else { - mAlwaysUse.setText(getString(R.string.always_use_device, appName, - mDevice.getProductName())); + if (!useRecordWarning) { + LayoutInflater inflater = (LayoutInflater) getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + ap.mView = inflater.inflate(com.android.internal.R.layout.always_use_checkbox, null); + mAlwaysUse = (CheckBox) ap.mView.findViewById(com.android.internal.R.id.alwaysUse); + if (mDevice == null) { + mAlwaysUse.setText(getString(R.string.always_use_accessory, appName, + mAccessory.getDescription())); + } else { + mAlwaysUse.setText(getString(R.string.always_use_device, appName, + mDevice.getProductName())); + } + mAlwaysUse.setOnCheckedChangeListener(this); + mClearDefaultHint = (TextView) ap.mView.findViewById( + com.android.internal.R.id.clearDefaultHint); + mClearDefaultHint.setVisibility(View.GONE); } - mAlwaysUse.setOnCheckedChangeListener(this); - mClearDefaultHint = (TextView)ap.mView.findViewById( - com.android.internal.R.id.clearDefaultHint); - mClearDefaultHint.setVisibility(View.GONE); - setupAlert(); } @@ -133,7 +135,7 @@ public class UsbConfirmActivity extends AlertActivity IUsbManager service = IUsbManager.Stub.asInterface(b); final int uid = mResolveInfo.activityInfo.applicationInfo.uid; final int userId = UserHandle.myUserId(); - boolean alwaysUse = mAlwaysUse.isChecked(); + boolean alwaysUse = mAlwaysUse != null ? mAlwaysUse.isChecked() : false; Intent intent = null; if (mDevice != null) {