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

Commit af68a120 authored by Jeff Davidson's avatar Jeff Davidson
Browse files

Add FLAG_RECEIVER_FOREGROUND to secret code broadcasts.

This flag should ensure that apps can process the broadcast more
quickly; given that dialer codes are dispatched directly in response
to a user entering them in the Dialer app, it makes sense to process
these as foreground activity. These broadcasts are only sent in
response to (rare) user action, so there should be no major system
health impact here.

The primary risk is if a dialer code broadcast receiver takes too
long, it is more likely to time out and be killed before completing
processing. Many receivers just immediately launch an activity which
is fine; for receivers which do asynchronous work, it may be necessary
to defer this work to a Service.

Bug: 64391957
Test: Successfully executed a few dialer codes on device
Change-Id: I8a9d3947b3552de26550b62dcb6e0f25a753013b
parent 74379dc8
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -2585,7 +2585,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            options.setBackgroundActivityStartsAllowed(true);
            options.setBackgroundActivityStartsAllowed(true);
            Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION,
            Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION,
                    Uri.parse("android_secret_code://" + code));
                    Uri.parse("android_secret_code://" + code));
            intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            intent.addFlags(
                    Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_RECEIVER_FOREGROUND);
            mContext.sendBroadcast(intent, null, options.toBundle());
            mContext.sendBroadcast(intent, null, options.toBundle());


            // {@link TelephonyManager.ACTION_SECRET_CODE} will replace {@link
            // {@link TelephonyManager.ACTION_SECRET_CODE} will replace {@link
@@ -2593,7 +2594,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            // that both of these two actions will be broadcast.
            // that both of these two actions will be broadcast.
            Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE,
            Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE,
                    Uri.parse("android_secret_code://" + code));
                    Uri.parse("android_secret_code://" + code));
            secrectCodeIntent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            secrectCodeIntent.addFlags(
                    Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_RECEIVER_FOREGROUND);
            mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle());
            mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle());
        }
        }
    }
    }