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

Commit e94a6ff5 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Add SUPL-specific network bcast

Move SUPL CONNECTIVITY_ACTION bcasts to a different, hidden intent
to reduce the churn of apps when SUPL comes/goes.

Short term hack until SUPL moves to use the new APIs and there's
no bcast.

bug:23350688
Change-Id: I3dc14b42afa72465260aa41ccedfe1df27baabd9
parent 7878eee8
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -99,6 +99,16 @@ public class ConnectivityManager {
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
    public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";


    /**
     * A temporary hack until SUPL system can get off the legacy APIS.
     * They do too many network requests and the long list of apps listening
     * and waking due to the CONNECTIVITY_ACTION bcast makes it expensive.
     * Use this bcast intent instead for SUPL requests.
     * @hide
     */
    public static final String CONNECTIVITY_ACTION_SUPL =
            "android.net.conn.CONNECTIVITY_CHANGE_SUPL";

    /**
    /**
     * The device has connected to a network that has presented a captive
     * The device has connected to a network that has presented a captive
     * portal, which is blocking Internet connectivity. The user was presented
     * portal, which is blocking Internet connectivity. The user was presented
+6 −2
Original line number Original line Diff line number Diff line
@@ -1524,10 +1524,14 @@ public class ConnectivityService extends IConnectivityManager.Stub


            final long ident = Binder.clearCallingIdentity();
            final long ident = Binder.clearCallingIdentity();
            if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
            if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
                final NetworkInfo ni = intent.getParcelableExtra(
                        ConnectivityManager.EXTRA_NETWORK_INFO);
                if (ni.getType() == ConnectivityManager.TYPE_MOBILE_SUPL) {
                    intent.setAction(ConnectivityManager.CONNECTIVITY_ACTION_SUPL);
                    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
                }
                final IBatteryStats bs = BatteryStatsService.getService();
                final IBatteryStats bs = BatteryStatsService.getService();
                try {
                try {
                    NetworkInfo ni = intent.getParcelableExtra(
                            ConnectivityManager.EXTRA_NETWORK_INFO);
                    bs.noteConnectivityChanged(intent.getIntExtra(
                    bs.noteConnectivityChanged(intent.getIntExtra(
                            ConnectivityManager.EXTRA_NETWORK_TYPE, ConnectivityManager.TYPE_NONE),
                            ConnectivityManager.EXTRA_NETWORK_TYPE, ConnectivityManager.TYPE_NONE),
                            ni != null ? ni.getState().toString() : "?");
                            ni != null ? ni.getState().toString() : "?");