Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1f09cb4 authored by rongbo.x.chi's avatar rongbo.x.chi Committed by Andre Eisenbach
Browse files

Only allow access to MAP if SMS is not supported

Bluetooth MAP shows SMS/MMS instance and when SMS is not supported.
Don't create SMS/MMS instance if device does not support SMS.

Fixes: 28803983
Change-Id: I807fe7e10bf51316729fe56ff6181a9161a410ef
parent 3823b227
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -152,6 +152,8 @@ public class BluetoothMapService extends ProfileService {
    private MapServiceMessageHandler mSessionStatusHandler;
    private boolean mStartError = true;

    private boolean mSmsCapable = true;

    // package and class name to which we send intent to check phone book access permission
    private static final String ACCESS_AUTHORITY_PACKAGE = "com.android.settings";
    private static final String ACCESS_AUTHORITY_CLASS =
@@ -632,6 +634,9 @@ public class BluetoothMapService extends ProfileService {
        mAppObserver = new BluetoothMapAppObserver(this, this);

        mEnabledAccounts = mAppObserver.getEnabledAccountItems();

        mSmsCapable = getResources().getBoolean(
                com.android.internal.R.bool.config_sms_capable);
        // Uses mEnabledAccounts, hence getEnabledAccountItems() must be called before this.
        createMasInstances();

@@ -770,8 +775,9 @@ public class BluetoothMapService extends ProfileService {
    }

    private void createMasInstances() {
        int masId = MAS_ID_SMS_MMS;
        int masId = mSmsCapable ? MAS_ID_SMS_MMS : -1;

        if (mSmsCapable) {
            // Add the SMS/MMS instance
            BluetoothMapMasInstance smsMmsInst =
                    new BluetoothMapMasInstance(this,
@@ -781,6 +787,7 @@ public class BluetoothMapService extends ProfileService {
                            true);
            mMasInstances.append(masId, smsMmsInst);
            mMasInstanceMap.put(null, smsMmsInst);
        }

        // get list of accounts already set to be visible through MAP
        for(BluetoothMapAccountItem account : mEnabledAccounts) {
@@ -1103,7 +1110,8 @@ public class BluetoothMapService extends ProfileService {
                BluetoothMapMasInstance masInst = null;
                int result = getResultCode();
                boolean handled = false;
                if(mMasInstances != null && (masInst = mMasInstances.get(MAS_ID_SMS_MMS)) != null) {
                if(mSmsCapable && mMasInstances != null &&
                        (masInst = mMasInstances.get(MAS_ID_SMS_MMS)) != null) {
                    intent.putExtra(BluetoothMapContentObserver.EXTRA_MESSAGE_SENT_RESULT, result);
                    if(masInst.handleSmsSendIntent(context, intent)) {
                        // The intent was handled by the mas instance it self