Merge "Revert "[Thread] post broacast receivers on the handler thread"" into main

This commit is contained in:
Treehugger Robot 2024-07-10 09:43:16 +00:00 • committed by Gerrit Code Review
commit 4866872a4d
3 changed files with 11 additions and 6 deletions

View file

@ -598,10 +598,12 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
mHandler.post(() -> onUserRestrictionsChanged(isThreadUserRestricted()));
onUserRestrictionsChanged(isThreadUserRestricted());
}
},
new IntentFilter(UserManager.ACTION_USER_RESTRICTIONS_CHANGED));
new IntentFilter(UserManager.ACTION_USER_RESTRICTIONS_CHANGED),
null /* broadcastPermission */,
mHandler);
}
private void onUserRestrictionsChanged(boolean newUserRestrictedState) {
@ -653,10 +655,12 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
mHandler.post(() -> onAirplaneModeChanged(isAirplaneModeOn()));
onAirplaneModeChanged(isAirplaneModeOn());
}
},
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED),
null /* broadcastPermission */,
mHandler);
}
private void onAirplaneModeChanged(boolean newAirplaneModeOn) {

View file

@ -45,7 +45,6 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import android.content.Context;

View file

@ -542,7 +542,9 @@ public final class ThreadNetworkControllerServiceTest {
.when(mContext)
.registerReceiver(
any(BroadcastReceiver.class),
argThat(actualIntentFilter -> actualIntentFilter.hasAction(action)));
argThat(actualIntentFilter -> actualIntentFilter.hasAction(action)),
any(),
any());
return receiverRef;
}