android7.0 蓝牙权限,Android 7.0 CTA认证蓝牙权限未明示的问题

+++ b/frameworks/base/services/core/java/com/android/server/BluetoothManagerService.java

@@-69,6 +69,7 @@ importjava.util.NoSuchElementException;importandroid.os.SystemProperties;/// M: CTA requirement - permission control @{

+importandroid.content.ActivityNotFoundException;importcom.mediatek.cta.CtaUtils;///@}

@@-817,8 +818,19 @@ class BluetoothManagerService extendsIBluetoothManager.Stub {

mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,"Need BLUETOOTH ADMIN permission");/// M: Permission check for CTA requirement @{

-CtaUtils.enforceCheckPermission(com.mediatek.Manifest.permission.CTA_ENABLE_BT,- "Enable bluetooth");+ /*CtaUtils.enforceCheckPermission(com.mediatek.Manifest.permission.CTA_ENABLE_BT,

+ "Enable bluetooth");*/

+ int callingUid =Binder.getCallingUid();+ int callingPid =Binder.getCallingPid();+ final boolean callerSystem = UserHandle.getAppId(callingUid) ==Process.SYSTEM_UID;+ if (!callerSystem) {+ String packageName =CtaUtils.getCallingPkgName(callingPid, callingUid);+ if (!isEnabled() && CtaUtils.isCtaSupported() && !CtaUtils.isSystemApp(mContext,+ packageName) &&startConsentUiIfNeeded(packageName, callingUid,+BluetoothAdapter.ACTION_REQUEST_ENABLE)) {+ return false;+}+}///@}

if(DBG) {

Slog.d(TAG,"enable(): mBluetooth =" + mBluetooth +@@-834,6 +846,24 @@ class BluetoothManagerService extendsIBluetoothManager.Stub {if (DBG) Slog.d(TAG, "enable returning");return true;

}+

+ /// M: Permission check for CTA requirement

+ private booleanstartConsentUiIfNeeded(String packageName,+ intcallingUid, String intentAction) {+ Intent intent = newIntent(intentAction);+intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName);+ Slog.e(TAG, "menghua packageName:" +packageName);+intent.setFlags(+ Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);+ try{+mContext.startActivity(intent);+ } catch(ActivityNotFoundException e) {+ //Shouldn‘t happen

+ Slog.e(TAG, "Intent to handle action " + intentAction + " missing");+ return false;+}+ return true;+}public boolean disable(booleanpersist) {

mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,

(END)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值