Merge "Marking test receiver as exported."
This commit is contained in:
commit
0762151207
2 changed files with 12 additions and 4 deletions
|
|
@ -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: [
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue