|
发表于 2020-5-10 07:16:23
7129 浏览 0 回复
mtk Android8.1平台 取消USB权限提示弹框
- +++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java
- @@ -97,8 +97,11 @@ public class UsbConfirmActivity extends AlertActivity
- com.android.internal.R.id.clearDefaultHint);
- mClearDefaultHint.setVisibility(View.GONE);
-
- - setupAlert();
- -
- + //modify by lzg
- + //setupAlert();
- + AutoConfirmUsb();
- + finish();
- + //end lzg
- }
-
- @Override
- @@ -158,6 +161,53 @@ public class UsbConfirmActivity extends AlertActivity
- }
- finish();
- }
- +
- + private void AutoConfirmUsb(){
- + try {
- + IBinder b = ServiceManager.getService(USB_SERVICE);
- + IUsbManager service = IUsbManager.Stub.asInterface(b);
- + final int uid = mResolveInfo.activityInfo.applicationInfo.uid;
- + final int userId = UserHandle.myUserId();
- + boolean alwaysUse = mAlwaysUse.isChecked();
- + Intent intent = null;
- +
- + if (mDevice != null) {
- + intent = new Intent(UsbManager.ACTION_USB_DEVICE_ATTACHED);
- + intent.putExtra(UsbManager.EXTRA_DEVICE, mDevice);
- +
- + // grant permission for the device
- + service.grantDevicePermission(mDevice, uid);
- + // set or clear default setting
- + if (alwaysUse) {
- + service.setDevicePackage(
- + mDevice, mResolveInfo.activityInfo.packageName, userId);
- + } else {
- + service.setDevicePackage(mDevice, null, userId);
- + }
- + } else if (mAccessory != null) {
- + intent = new Intent(UsbManager.ACTION_USB_ACCESSORY_ATTACHED);
- + intent.putExtra(UsbManager.EXTRA_ACCESSORY, mAccessory);
- +
- + // grant permission for the accessory
- + service.grantAccessoryPermission(mAccessory, uid);
- + // set or clear default setting
- + if (alwaysUse) {
- + service.setAccessoryPackage(
- + mAccessory, mResolveInfo.activityInfo.packageName, userId);
- + } else {
- + service.setAccessoryPackage(mAccessory, null, userId);
- + }
- + }
- +
- + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- + intent.setComponent(
- + new ComponentName(mResolveInfo.activityInfo.packageName,
- + mResolveInfo.activityInfo.name));
- + startActivityAsUser(intent, new UserHandle(userId));
- + } catch (Exception e) {
- + Log.e(TAG, "Unable to start activity", e);
- + }
- + }--
- +++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java
- @@ -109,8 +109,12 @@ public class UsbPermissionActivity extends AlertActivity
- mClearDefaultHint = (TextView)ap.mView.findViewById(
- com.android.internal.R.id.clearDefaultHint);
- mClearDefaultHint.setVisibility(View.GONE);
- -
- - setupAlert();
- + //modify by lzg
- + // setupAlert();
- + //mAlwaysUse.setChecked(true);
- + mPermissionGranted = true;
- + finish();
- + //end lzg
-
- }
- +++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java
- @@ -97,8 +97,11 @@ public class UsbConfirmActivity extends AlertActivity
- com.android.internal.R.id.clearDefaultHint);
- mClearDefaultHint.setVisibility(View.GONE);
-
- - setupAlert();
- -
- + //modify by lzg
- + //setupAlert();
- + AutoConfirmUsb();
- + finish();
- + //end lzg
- }
复制代码
|
|
手机微信同号:13682654092
|
|
|
|
|
登录或注册
|