Android 默认USB 弹框权限屏蔽

--- a/android/frameworks/base/core/res/res/values/config.xml
+++ b/android/frameworks/base/core/res/res/values/config.xml
@@ -2502,7 +2502,7 @@

     <!-- If true, then we do not ask user for permission for apps to connect to USB devices.
          Do not set this to true for production devices. Doing so will cause you to fail CTS. -->
-    <bool name="config_disableUsbPermissionDialogs">false</bool>
+    <bool name="config_disableUsbPermissionDialogs">true</bool>

     <!-- Activity to handle Usb Device connection in USB Host side. Keeping it to null value will
          lead into handling it inside system using Intent resolution. Non-null contents will have

全志Android 10  默认USB 音频打开

/*
    private void chooseUsbAudioDeviceDialog(final ArrayList<String> usb_device)
    {  //sam jiang loged
        String str = mCtx.getResources().getString(com.android.internal.R.string.usb_output_message);
        alertDialog = new AlertDialog.Builder(mCtx).
                setTitle(com.android.internal.R.string.usb_output_title).
                setMessage(String.format(str, Integer.toString(USB_TOAST_TIME))).
                setPositiveButton(com.android.internal.R.string.usb_yes, new DialogInterface.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
                           // TODO Auto-generated method stub
                           String message = mCtx.getResources().getString(R.string.usb_audio_plug_in_message);
                           toastPlugInNotification(message, AUDIO_OUT_NOTIFY);
                           mAudioManagerEx.setAudioDeviceActive(usb_device, AudioManagerEx.AUDIO_OUTPUT_ACTIVE);
                     }
                }).
                setNegativeButton(com.android.internal.R.string.usb_no, new DialogInterface.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
                           // TODO Auto-generated method stub
                           //Log.v(TAG, "setNegativeButton ");
                           String message = mCtx.getResources().getString(R.string.usb_audio_plug_out_message);
                           toastPlugInNotification(message, AUDIO_OUT_NOTIFY);
                     }
                }).
                create();
        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
        alertDialog.show();
        new AsyncTask() {
            @Override
            protected Object doInBackground(Object... arg0) {
                int time = USB_TOAST_TIME;
                while(time >= 0 && alertDialog != null && alertDialog.isShowing()){
                    publishProgress(time);
                    try {
                        Thread.sleep(1000);
                    } catch(Exception e) {
                        // do nothing
                    }
                    time--;
                }
                return null;
            }
            @Override
            protected void onPostExecute(Object result) {
                super.onPostExecute(result);
                if (alertDialog != null && alertDialog.isShowing()) {
                    alertDialog.dismiss();
                    mAudioManagerEx.setAudioDeviceActive(usb_device, AudioManagerEx.AUDIO_OUTPUT_ACTIVE);
                    alertDialog = null;
                }
            }
            @Override
            protected void onProgressUpdate(Object... values) {
                super.onProgressUpdate(values);
                int time = (Integer)values[0];
                String str = mCtx.getResources().getString(com.android.internal.R.string.usb_output_message);
                if(alertDialog != null)
                    alertDialog.setMessage(String.format(str, Integer.toString(time)));
            }
       }.execute();
    }
*/
    private void chooseUsbAudioDeviceDialog(final ArrayList<String> usb_device)
    {  //loged
           String message = mCtx.getResources().getString(R.string.usb_audio_plug_in_message);
           toastPlugInNotification(message, AUDIO_OUT_NOTIFY);
           mAudioManagerEx.setAudioDeviceActive(usb_device, AudioManagerEx.AUDIO_OUTPUT_ACTIVE);  //起作用的是这一句
    }

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Keep Coding...

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值