Add mandatory RECEIVER_EXPORTED flag

For the helper app to communicate with the main verifier app, the
receiver needs to be explicitly marked as exported.

Also cleaning up some deprecated method calls in the test code.

Test: Build, install and test with CtsVerifier manually

Bug: 279863829
Change-Id: I382758a8209795386bb72859b192852df9618eb2
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/forcestop/RecentTaskRemovalTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/forcestop/RecentTaskRemovalTestActivity.java
index 50d5f21..49f3831 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/forcestop/RecentTaskRemovalTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/forcestop/RecentTaskRemovalTestActivity.java
@@ -121,12 +121,13 @@
                     .setPackage(getPackageName())
                     .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
             final PendingIntent onTaskRemoved = PendingIntent.getBroadcast(this, 0,
-                    reportTaskRemovedIntent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
+                    reportTaskRemovedIntent, PendingIntent.FLAG_IMMUTABLE);
 
             final Intent reportAlarmIntent = new Intent(ACTION_REPORT_ALARM)
                     .setPackage(getPackageName())
                     .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
-            final PendingIntent onAlarm = PendingIntent.getBroadcast(this, 0, reportAlarmIntent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
+            final PendingIntent onAlarm = PendingIntent.getBroadcast(this, 0, reportAlarmIntent,
+                    PendingIntent.FLAG_IMMUTABLE);
 
             final Intent testActivity = new Intent()
                     .setClassName(HELPER_APP_NAME, HELPER_ACTIVITY_NAME)
@@ -207,7 +208,7 @@
             final IntentFilter commsFilter = new IntentFilter();
             commsFilter.addAction(ACTION_REPORT_TASK_REMOVED);
             commsFilter.addAction(ACTION_REPORT_ALARM);
-            registerReceiver(this, commsFilter, null, handler);
+            registerReceiver(this, commsFilter, null, handler, RECEIVER_EXPORTED);
         }
 
         void unregister() {
diff --git a/apps/ForceStopHelperApp/src/com/android/cts/forcestophelper/TaskRemovedListenerService.java b/apps/ForceStopHelperApp/src/com/android/cts/forcestophelper/TaskRemovedListenerService.java
index 3955d45..5831a62 100644
--- a/apps/ForceStopHelperApp/src/com/android/cts/forcestophelper/TaskRemovedListenerService.java
+++ b/apps/ForceStopHelperApp/src/com/android/cts/forcestophelper/TaskRemovedListenerService.java
@@ -17,10 +17,10 @@
 
 package com.android.cts.forcestophelper;
 
+import static com.android.cts.forcestophelper.AlarmReceiver.createAlarmPendingIntent;
 import static com.android.cts.forcestophelper.Constants.ALARM_DELAY;
 import static com.android.cts.forcestophelper.Constants.EXTRA_ON_ALARM;
 import static com.android.cts.forcestophelper.Constants.EXTRA_ON_TASK_REMOVED;
-import static com.android.cts.forcestophelper.AlarmReceiver.createAlarmPendingIntent;
 
 import android.app.AlarmManager;
 import android.app.Notification;
@@ -43,8 +43,8 @@
 
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
-        mOnTaskRemoved = intent.getParcelableExtra(EXTRA_ON_TASK_REMOVED);
-        mOnAlarm = intent.getParcelableExtra(EXTRA_ON_ALARM);
+        mOnTaskRemoved = intent.getParcelableExtra(EXTRA_ON_TASK_REMOVED, PendingIntent.class);
+        mOnAlarm = intent.getParcelableExtra(EXTRA_ON_ALARM, PendingIntent.class);
 
         if (mOnTaskRemoved != null && mOnAlarm != null) {
             final NotificationManager nm = getSystemService(NotificationManager.class);