修改apk调用蓝牙无明确提示

在源码里第三方apk调用蓝牙时直接打开,无明确权限提示,过CTA认证时会报此问题,修改方法:

diff --git a/frameworks/base/services/core/java/com/android/server/BluetoothManagerService.java b/frameworks/base/services/core/java/com/android/server/BluetoothManagerService.java
index 06d80dc…1ecc217 100644 (file)
— a/frameworks/base/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/BluetoothManagerService.java
@@ -72,6 +72,13 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;

+import android.app.IActivityManager;
+import android.app.ActivityManager.RunningAppProcessInfo;
+import java.util.Iterator;
+import java.util.List;
+import android.app.ActivityManagerNative;
+import android.util.Log;
+
//M: ALPS03484437: Handle NoSuchElementException
import java.util.NoSuchElementException;

@@ -961,9 +968,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
throw new SecurityException("Package " + callingUid
+ " not in uid " + callingUid);
}

  •                   ///修改第三app调用蓝牙无明确提示 
    
  •                   String appName = applicationInfo.loadLabel(mContext.getPackageManager()).toString();///gu
           Intent intent = new Intent(intentAction);
           intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName);
    
  •        intent.putExtra("APP_NAME", appName);///gu
           intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                   | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
           try {
    

diff --git a/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/strings.xml b/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/strings.xml
index 8363017…2b78e9b 100644 (file)
— a/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/strings.xml
+++ b/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/strings.xml
@@ -3752,4 +3752,6 @@

 
 连接类型
  • "%1$s想要开启此设备的蓝牙开关。"
    
diff --git a/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml b/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml index d95356f..56620bf 100644 (file) --- a/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml +++ b/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml @@ -9088,4 +9088,6 @@
 
 Connect Type
  • %1$s wants to turn Bluetooth ON for this device.

    diff --git a/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionActivity.java b/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionActivity.java
    index ef25a9f…f9ad9bb 100644 (file)
    — a/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionActivity.java
    +++ b/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionActivity.java
    @@ -70,7 +70,9 @@ public class RequestPermissionActivity extends Activity implements
    private BroadcastReceiver mReceiver;

    private @NonNull CharSequence mAppLabel;

  •   ///修改第三方调用蓝牙无明确提示 add by hxy029
    
  •   private String mAppName;
    
  • @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    @@ -127,6 +129,11 @@ public class RequestPermissionActivity extends Activity implements
    */
    Intent intent = new Intent(this, RequestPermissionHelperActivity.class);
    intent.setAction(RequestPermissionHelperActivity.ACTION_INTERNAL_REQUEST_BT_ON);
  •                                   ///修改第三方调用蓝牙无明确提示 ///{{&&
    
  •                if (mAppName != null) {
    
  •                                           intent.putExtra("APP_NAME", mAppName);
    
  •                                                                              }
    
  •                                   ///&&}}
                   /// M: add a flag for CR ALPS00379011
                   intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                   intent.putExtra(RequestPermissionHelperActivity.EXTRA_APP_LABEL, mAppLabel);
    

@@ -306,6 +313,7 @@ public class RequestPermissionActivity extends Activity implements
}
if (intent.getAction().equals(BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
mRequest = REQUEST_ENABLE;

  •        mAppName = intent.getStringExtra("APP_NAME");///修改第三方调用蓝牙无明确提示
       } else if (intent.getAction().equals(BluetoothAdapter.ACTION_REQUEST_DISABLE)) {
           mRequest = REQUEST_DISABLE;
       } else if (intent.getAction().equals(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE)) {
    

diff --git a/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java b/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
index 9ea8372…18f714c 100644 (file)
— a/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
+++ b/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
@@ -62,7 +62,9 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
private int mTimeout = -1;

 private int mRequest;
  •   ///修改第三方调用蓝牙无明确提示 
    
  •   private String mAppName;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    @@ -90,9 +92,11 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
    switch (mRequest) {
    case RequestPermissionActivity.REQUEST_ENABLE: {
    if (mTimeout < 0) {
  •                p.mMessage = mAppLabel != null
    
  •                        ? getString(R.string.bluetooth_ask_enablement, mAppLabel)
    
  •                        : getString(R.string.bluetooth_ask_enablement_no_name);
    
  •                 if (mAppName != null) {///修改第三方调用蓝牙无明确提示
    
  •                           p.mMessage = getString(R.string.bluetooth_ask_enablement_with_packagename, mAppName);
    
  •                   } else {
    
  •                           p.mMessage = getString(R.string.bluetooth_ask_enablement);
    
  •                   }  
               } else if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) {
                   p.mMessage = mAppLabel != null
                           ? getString(
    

@@ -162,6 +166,7 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
String action = intent.getAction();
if (ACTION_INTERNAL_REQUEST_BT_ON.equals(action)) {
mRequest = RequestPermissionActivity.REQUEST_ENABLE;

  •        mAppName = intent.getStringExtra("APP_NAME");///修改第三方调用蓝牙无明确提示 
           if (intent.hasExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION)) {
               // Value used for display purposes. Not range checking.
               mTimeout = intent.getIntExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,
    

你可能感兴趣的:(修改apk调用蓝牙无明确提示)