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

Commit b9636318 authored by Paul Hu's avatar Paul Hu
Browse files

Revert^2 "Replace Context#sendStickyBroadcastAsUser()"

ConnectivityService is using Context#sendStickyBroadcastAsUser
to send sticky broadcast but this API is not able to call after
it becomes part of Connectivity mainline module. Thus, replace it
with Context#sendStickyBroadcast.

The original commit was reverted because of a test failure. This
reverted commit is bound to the fix and will submit together.

Bug: 177223402
Change-Id: I75b8494e8ee30f484f33e9a9a660c7f9ad75f368
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Test: atest CtsNetApi23TestCases
Test: atest FrameworksNetIntegrationTests
parent f068636d
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -314,6 +314,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
    private boolean mRestrictBackground;

    private final Context mContext;
    // The Context is created for UserHandle.ALL.
    private final Context mUserAllContext;
    private final Dependencies mDeps;
    // 0 is full bad, 100 is full good
    private int mDefaultInetConditionPublished = 0;
@@ -1088,8 +1090,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
        intentFilter.addAction(Intent.ACTION_USER_REMOVED);
        intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);

        final Context userAllContext = mContext.createContextAsUser(UserHandle.ALL, 0 /* flags */);
        userAllContext.registerReceiver(
        mUserAllContext = mContext.createContextAsUser(UserHandle.ALL, 0 /* flags */);
        mUserAllContext.registerReceiver(
                mIntentReceiver,
                intentFilter,
                null /* broadcastPermission */,
@@ -1105,7 +1107,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
        intentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
        intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        intentFilter.addDataScheme("package");
        userAllContext.registerReceiver(
        mUserAllContext.registerReceiver(
                mIntentReceiver,
                intentFilter,
                null /* broadcastPermission */,
@@ -1114,7 +1116,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
        // Listen to lockdown VPN reset.
        intentFilter = new IntentFilter();
        intentFilter.addAction(LockdownVpnTracker.ACTION_LOCKDOWN_RESET);
        userAllContext.registerReceiver(
        mUserAllContext.registerReceiver(
                mIntentReceiver, intentFilter, NETWORK_STACK, mHandler);

        try {
@@ -2320,7 +2322,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
                intent.addFlags(Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
            }
            try {
                mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL, options);
                mUserAllContext.sendStickyBroadcast(intent, options);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }