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

Commit f42090cb authored by Michal Karpinski's avatar Michal Karpinski
Browse files

Whitelist the secret code broadcasts for background

activity starts

Bug: 124574600
Test: atest FrameworksTelephonyTests
Test: manual with *#*#4636#*#* and *#*#CHECKIN#*#*
Change-Id: I20f1770b77fbaa13604d840160e4c983925cf694
parent 520d340d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.telephony;

import android.annotation.Nullable;
import android.app.BroadcastOptions;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -2438,10 +2439,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     */
    public void sendDialerSpecialCode(String code) {
        if (!TextUtils.isEmpty(code)) {
            final BroadcastOptions options = BroadcastOptions.makeBasic();
            options.setAllowBackgroundActivityStarts(true);
            Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION,
                    Uri.parse("android_secret_code://" + code));
            intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            mContext.sendBroadcast(intent);
            mContext.sendBroadcast(intent, null, options.toBundle());

            // {@link TelephonyManager.ACTION_SECRET_CODE} will replace {@link
            // TelephonyIntents#SECRET_CODE_ACTION} in the next Android version. Before
@@ -2449,7 +2452,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE,
                    Uri.parse("android_secret_code://" + code));
            intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            mContext.sendBroadcast(secrectCodeIntent);
            mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle());
        }
    }