diff --git a/tests/cts/hostside/app2/Android.bp b/tests/cts/hostside/app2/Android.bp index 4c9bccf63f..01c8cd25d7 100644 --- a/tests/cts/hostside/app2/Android.bp +++ b/tests/cts/hostside/app2/Android.bp @@ -22,7 +22,10 @@ android_test_helper_app { name: "CtsHostsideNetworkTestsApp2", defaults: ["cts_support_defaults"], sdk_version: "test_current", - static_libs: ["CtsHostsideNetworkTestsAidl"], + static_libs: [ + "CtsHostsideNetworkTestsAidl", + "NetworkStackApiStableShims", + ], srcs: ["src/**/*.java"], // Tag this module as a cts test artifact test_suites: [ diff --git a/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyService.java b/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyService.java index 3b5e46fe9a..f2a7b3f656 100644 --- a/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyService.java +++ b/tests/cts/hostside/app2/src/com/android/cts/net/hostside/app2/MyService.java @@ -21,6 +21,7 @@ import static com.android.cts.net.hostside.app2.Common.ACTION_RECEIVER_READY; import static com.android.cts.net.hostside.app2.Common.ACTION_SNOOZE_WARNING; import static com.android.cts.net.hostside.app2.Common.DYNAMIC_RECEIVER; import static com.android.cts.net.hostside.app2.Common.TAG; +import static com.android.networkstack.apishim.ConstantsShim.RECEIVER_EXPORTED; import android.app.NotificationChannel; import android.app.NotificationManager; @@ -40,6 +41,7 @@ import android.util.Log; import com.android.cts.net.hostside.IMyService; import com.android.cts.net.hostside.INetworkCallback; +import com.android.modules.utils.build.SdkLevel; /** * Service used to dynamically register a broadcast receiver. @@ -64,11 +66,14 @@ public class MyService extends Service { return; } final Context context = getApplicationContext(); + final int flags = SdkLevel.isAtLeastT() ? RECEIVER_EXPORTED : 0; mReceiver = new MyBroadcastReceiver(DYNAMIC_RECEIVER); - context.registerReceiver(mReceiver, new IntentFilter(ACTION_RECEIVER_READY)); context.registerReceiver(mReceiver, - new IntentFilter(ACTION_RESTRICT_BACKGROUND_CHANGED)); - context.registerReceiver(mReceiver, new IntentFilter(ACTION_SNOOZE_WARNING)); + new IntentFilter(ACTION_RECEIVER_READY), flags); + context.registerReceiver(mReceiver, + new IntentFilter(ACTION_RESTRICT_BACKGROUND_CHANGED), flags); + context.registerReceiver(mReceiver, + new IntentFilter(ACTION_SNOOZE_WARNING), flags); Log.d(TAG, "receiver registered"); }