1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.tv.usb; 18 19 import com.android.systemui.R; 20 21 /** 22 * Dialog shown to confirm the package to start when a USB device or accessory is attached and there 23 * is only one package that claims to handle this USB device or accessory. 24 */ 25 public class TvUsbConfirmActivity extends TvUsbDialogActivity { 26 private static final String TAG = TvUsbConfirmActivity.class.getSimpleName(); 27 28 @Override onResume()29 protected void onResume() { 30 super.onResume(); 31 final int strId; 32 if (mDialogHelper.isUsbDevice()) { 33 boolean useRecordWarning = mDialogHelper.deviceHasAudioCapture() 34 && !mDialogHelper.packageHasAudioRecordingPermission(); 35 strId = useRecordWarning 36 ? R.string.usb_device_confirm_prompt_warn 37 : R.string.usb_device_confirm_prompt; 38 } else { 39 // UsbAccessory case 40 strId = R.string.usb_accessory_confirm_prompt; 41 } 42 CharSequence text = getString(strId, mDialogHelper.getAppName(), 43 mDialogHelper.getDeviceDescription()); 44 initUI(mDialogHelper.getAppName(), text); 45 } 46 47 @Override onConfirm()48 void onConfirm() { 49 mDialogHelper.grantUidAccessPermission(); 50 mDialogHelper.confirmDialogStartActivity(); 51 finish(); 52 } 53 } 54