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

Commit 40b2df50 authored by paulhu's avatar paulhu
Browse files

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.

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


    private final Context mContext;
    private final Context mContext;
    // The Context is created for UserHandle.ALL.
    private final Context mUserAllContext;
    private final Dependencies mDeps;
    private final Dependencies mDeps;
    // 0 is full bad, 100 is full good
    // 0 is full bad, 100 is full good
    private int mDefaultInetConditionPublished = 0;
    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_REMOVED);
        intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
        intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);


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


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