|
发表于 2021-6-25 18:25:20
10263 浏览 0 回复
mt6762-android9.0 屏蔽usb权限提示框
vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\usb\UsbPermissionActivity.javapublic void onCreate(Bundle icicle) {
super.onCreate(icicle);
Intent intent = getIntent();
mDevice = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
mAccessory = (UsbAccessory)intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
mPendingIntent = (PendingIntent)intent.getParcelableExtra(Intent.EXTRA_INTENT);
mUid = intent.getIntExtra(Intent.EXTRA_UID, -1);
mPackageName = intent.getStringExtra("package");
PackageManager packageManager = getPackageManager();
ApplicationInfo aInfo;
try {
aInfo = packageManager.getApplicationInfo(mPackageName, 0);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "unable to look up package name", e);
finish();
return;
}
String appName = aInfo.loadLabel(packageManager).toString();
final AlertController.AlertParams ap = mAlertParams;
ap.mTitle = appName;
if (mDevice == null) {
ap.mMessage = getString(R.string.usb_accessory_permission_prompt, appName,
mAccessory.getDescription());
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mAccessory);
} else {
ap.mMessage = getString(R.string.usb_device_permission_prompt, appName,
mDevice.getProductName());
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);
}
ap.mPositiveButtonText = getString(android.R.string.ok);
ap.mNegativeButtonText = getString(android.R.string.cancel);
ap.mPositiveButtonListener = this;
ap.mNegativeButtonListener = this;
try {
PackageInfo packageInfo = packageManager.getPackageInfo(mPackageName,
PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);
if ((mDevice != null && canBeDefault(mDevice, packageInfo))
|| (mAccessory != null && canBeDefault(mAccessory, packageInfo))) {
// add "open when" 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()));
}
mAlwaysUse.setOnCheckedChangeListener(this);
mClearDefaultHint = (TextView)ap.mView.findViewById(
com.android.internal.R.id.clearDefaultHint);
mClearDefaultHint.setVisibility(View.GONE);
}
} catch (PackageManager.NameNotFoundException e) {
// ignore
}
//modify by lzg
//setupAlert();
//mAlwaysUse.setChecked(true);
mPermissionGranted = true;
finish();
//end lzg
}
|
|
|
|
|
|
|
登录或注册
|