diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java index 0c77deef08..0c36c93e80 100644 --- a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java +++ b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java @@ -523,12 +523,10 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - onUserRestrictionsChanged(isThreadUserRestricted()); + mHandler.post(() -> onUserRestrictionsChanged(isThreadUserRestricted())); } }, - new IntentFilter(UserManager.ACTION_USER_RESTRICTIONS_CHANGED), - null /* broadcastPermission */, - mHandler); + new IntentFilter(UserManager.ACTION_USER_RESTRICTIONS_CHANGED)); } private void onUserRestrictionsChanged(boolean newUserRestrictedState) { @@ -580,12 +578,10 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - onAirplaneModeChanged(isAirplaneModeOn()); + mHandler.post(() -> onAirplaneModeChanged(isAirplaneModeOn())); } }, - new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED), - null /* broadcastPermission */, - mHandler); + new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED)); } private void onAirplaneModeChanged(boolean newAirplaneModeOn) { diff --git a/thread/tests/cts/src/android/net/thread/cts/ThreadNetworkControllerTest.java b/thread/tests/cts/src/android/net/thread/cts/ThreadNetworkControllerTest.java index 0e95703943..41f34ff4e1 100644 --- a/thread/tests/cts/src/android/net/thread/cts/ThreadNetworkControllerTest.java +++ b/thread/tests/cts/src/android/net/thread/cts/ThreadNetworkControllerTest.java @@ -45,6 +45,7 @@ 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; diff --git a/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java b/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java index 2f58943907..959e155a83 100644 --- a/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java +++ b/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java @@ -539,9 +539,7 @@ public final class ThreadNetworkControllerServiceTest { .when(mContext) .registerReceiver( any(BroadcastReceiver.class), - argThat(actualIntentFilter -> actualIntentFilter.hasAction(action)), - any(), - any()); + argThat(actualIntentFilter -> actualIntentFilter.hasAction(action))); return receiverRef; }