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

Commit ad4922ef authored by rongbo.x.chi's avatar rongbo.x.chi Committed by android-build-merger
Browse files

Only allow access to MAP if SMS is not supported

am: e1f09cb4

* commit 'e1f09cb4':
  Only allow access to MAP if SMS is not supported

Change-Id: I33a25eb06427b65297cb72fac7c7325dec0e2067
parents 349c74b3 e1f09cb4
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