+++ 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)