CtsVerifier: Fix cross profile intent filters test.

This CL updates IntentFiltersTestHelper to check intents
based on features and makes CrossProfileTestActivity
to handle some intents.

Bug: 23881585
Change-Id: Ie60c9b10495fa6a48e1ec398d2d50f882607e1df
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 4f5217d..f2a156a 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1454,19 +1454,88 @@
 
         <activity android:name=".managedprovisioning.CrossProfileTestActivity">
             <intent-filter>
-                <!-- We need to have at least one activity listening to this intent in the parent
-                     to test if it is forwarded from the managed profile to the parent -->
-                <action android:name="android.provider.MediaStore.RECORD_SOUND" />
                 <action android:name="com.android.cts.verifier.managedprovisioning.CROSS_PROFILE_TO_PERSONAL" />
                 <action android:name="com.android.cts.verifier.managedprovisioning.CROSS_PROFILE_TO_WORK" />
-                <category android:name="android.intent.category.DEFAULT"></category>
+                <!-- We need to have at least one activity listening to these intents on the device
+                     to test if these are forwarded from the managed profile to the parent or
+                     the other way around. -->
+                <action android:name="android.provider.MediaStore.RECORD_SOUND" />
+                <action android:name="android.speech.action.RECOGNIZE_SPEECH" />
+                <action android:name="android.app.action.SET_NEW_PASSWORD" />
+                <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
+                <action android:name="android.intent.action.WEB_SEARCH" />
+                <action android:name="android.intent.action.VIEW_DOWNLOADS" />
+                <action android:name="android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL" />
+                <action android:name="android.settings.SHOW_INPUT_METHOD_PICKER" />
+                <action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
+                <action android:name="com.android.settings.TTS_SETTINGS" />
+                <action android:name="android.settings.ZEN_MODE_SETTINGS" />
+                <action android:name="android.settings.BATTERY_SAVER_SETTINGS" />
+                <action android:name="android.settings.INPUT_METHOD_SETTINGS" />
+                <action android:name="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.SEND" />
+                <action android:name="android.intent.action.SEND_MULTIPLE" />
+                <data android:mimeType="*/*" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.GET_CONTENT" />
+                <action android:name="android.intent.action.OPEN_DOCUMENT" />
+                <data android:mimeType="*/*" />
+                <category android:name="android.intent.category.OPENABLE" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <action android:name="android.intent.action.SENDTO" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="sms" />
+                <data android:scheme="smsto" />
+                <data android:scheme="mms" />
+                <data android:scheme="mmsto" />
+                <data android:scheme="mailto" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <action android:name="android.intent.action.CALL" />
+                <action android:name="android.intent.action.DIAL" />
+                <action android:name="android.intent.action.CALL_PRIVILEGED" />
+                <action android:name="android.intent.action.CALL_EMERGENCY" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="tel" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.INSERT" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="content" />
+                <data android:mimeType="*/*" />
             </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.BROWSABLE" />
-                <category android:name="android.intent.category.DEFAULT"></category>
+                <category android:name="android.intent.category.DEFAULT" />
                 <data android:scheme="http" android:host="com.android.cts.verifier" />
             </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="http" />
+                <data android:mimeType="video/mp4" />
+                <data android:mimeType="audio/*" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="http" />
+                <data android:scheme="geo" />
+                <data android:scheme="market" />
+            </intent-filter>
         </activity>
 
         <activity android:name=".managedprovisioning.WorkStatusTestActivity">
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
index 7dc99c0..eef6299 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
@@ -30,6 +30,7 @@
 import android.net.Uri;
 import android.nfc.cardemulation.CardEmulation;
 import android.os.Bundle;
+import android.os.Environment;
 import android.os.UserHandle;
 import android.provider.AlarmClock;
 import android.provider.CalendarContract.Events;
@@ -39,6 +40,7 @@
 import android.util.Log;
 import android.widget.Toast;
 
+import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -51,132 +53,83 @@
     private static final String TAG = "IntentFiltersTestHelper";
 
     // These are the intents which can be forwarded to the managed profile.
-    private static final Intent[] forwardedIntentsFromPrimary = new Intent[] {
-        new Intent(Intent.ACTION_SEND).setType("*/*"),
-        new Intent(Intent.ACTION_SEND_MULTIPLE).setType("*/*")
-    };
+    private static final ArrayList<Intent> forwardedIntentsFromPrimary =
+            new ArrayList<>(Arrays.asList(
+                new Intent(Intent.ACTION_SEND).setType("*/*"),
+                new Intent(Intent.ACTION_SEND_MULTIPLE).setType("*/*")
+            ));
 
     // These are the intents which can be forwarded to the primary profile.
-    private static final Intent[] forwardedIntentsFromManaged = new Intent[] {
-        new Intent(AlarmClock.ACTION_SET_ALARM),
-        new Intent(AlarmClock.ACTION_SET_TIMER),
-        new Intent(AlarmClock.ACTION_SHOW_ALARMS),
-        new Intent(MediaStore.ACTION_IMAGE_CAPTURE),
-        new Intent(MediaStore.ACTION_VIDEO_CAPTURE),
-        new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA),
-        new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA),
-        new Intent(MediaStore.ACTION_IMAGE_CAPTURE_SECURE),
-        new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE),
-        new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("sms:07700900100")),
-        new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("smsto:07700900100")),
-        new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("mms:07700900100")),
-        new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("mmsto:07700900100")),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("sms:07700900100?body=Hello%20world")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("smsto:07700900100?body=Hello%20world")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("mms:07700900100?body=Hello%20world")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("mmsto:07700900100?body=Hello%20world")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS),
-        new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS),
-        new Intent(Settings.ACTION_APN_SETTINGS),
-        new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS),
-        new Intent(Settings.ACTION_CAPTIONING_SETTINGS),
-        new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS),
-        new Intent(Settings.ACTION_DATE_SETTINGS),
-        new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS),
-        new Intent(Settings.ACTION_DISPLAY_SETTINGS),
-        new Intent(Settings.ACTION_DREAM_SETTINGS),
-        new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS),
-        new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS),
-        new Intent(Settings.ACTION_LOCALE_SETTINGS),
-        new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS),
-        new Intent(Settings.ACTION_NFC_SETTINGS),
-        new Intent(Settings.ACTION_NFCSHARING_SETTINGS),
-        new Intent(Settings.ACTION_PRIVACY_SETTINGS),
-        new Intent(Settings.ACTION_SETTINGS),
-        new Intent(Settings.ACTION_SOUND_SETTINGS),
-        new Intent(Settings.ACTION_WIRELESS_SETTINGS),
-        new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD),
-        new Intent("android.net.vpn.SETTINGS"),
-        new Intent(CardEmulation.ACTION_CHANGE_DEFAULT),
-        new Intent("android.settings.ACCOUNT_SYNC_SETTINGS"),
-        new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS),
-        new Intent(Settings.ACTION_HOME_SETTINGS),
-        new Intent("android.settings.LICENSE"),
-        new Intent("android.settings.NOTIFICATION_SETTINGS"),
-        new Intent(Settings.ACTION_SHOW_REGULATORY_INFO),
-        new Intent("android.settings.USER_SETTINGS"),
-        new Intent("android.settings.ZEN_MODE_SETTINGS"),
-        new Intent("com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS"),
-        new Intent("com.android.settings.STORAGE_USB_SETTINGS"),
-        new Intent("com.android.settings.TTS_SETTINGS"),
-        new Intent("com.android.settings.USER_DICTIONARY_EDIT"),
-        new Intent(Intent.ACTION_CALL).setData(Uri.parse("tel:123")),
-        new Intent("android.intent.action.CALL_EMERGENCY").setData(Uri.parse("tel:123")),
-        new Intent("android.intent.action.CALL_PRIVILEGED").setData(Uri.parse("tel:123")),
-        new Intent(Intent.ACTION_DIAL).setData(Uri.parse("tel:123")),
-        new Intent(Intent.ACTION_VIEW).setData(Uri.parse("tel:123")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Settings.ACTION_MEMORY_CARD_SETTINGS),
-        new Intent(Settings.ACTION_NFC_PAYMENT_SETTINGS),
-        new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),
-        new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS),
-        new Intent(Settings.ACTION_SYNC_SETTINGS),
-        new Intent(Settings.ACTION_ADD_ACCOUNT),
-        new Intent(Intent.ACTION_GET_CONTENT).setType("*/*").addCategory(
-                Intent.CATEGORY_OPENABLE),
-        new Intent(Intent.ACTION_OPEN_DOCUMENT).setType("*/*").addCategory(
-                Intent.CATEGORY_OPENABLE),
-        new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS),
-        new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS),
-        new Intent(Settings.ACTION_APPLICATION_SETTINGS),
-        new Intent("android.settings.ACTION_OTHER_SOUND_SETTINGS"),
-        new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION),
-        new Intent(Settings.ACTION_WIFI_IP_SETTINGS),
-        new Intent(Settings.ACTION_WIFI_SETTINGS),
-        new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
-    };
+    private static final ArrayList<Intent> forwardedIntentsFromManaged =
+            new ArrayList<>(Arrays.asList(
+                new Intent(AlarmClock.ACTION_SET_ALARM),
+                new Intent(AlarmClock.ACTION_SET_TIMER),
+                new Intent(AlarmClock.ACTION_SHOW_ALARMS),
+                new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS),
+                new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS),
+                new Intent(Settings.ACTION_CAPTIONING_SETTINGS),
+                new Intent(Settings.ACTION_DATE_SETTINGS),
+                new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS),
+                new Intent(Settings.ACTION_DISPLAY_SETTINGS),
+                new Intent(Settings.ACTION_LOCALE_SETTINGS),
+                new Intent(Settings.ACTION_PRIVACY_SETTINGS),
+                new Intent(Settings.ACTION_SETTINGS),
+                new Intent(Settings.ACTION_WIRELESS_SETTINGS),
+                new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD),
+                new Intent("android.net.vpn.SETTINGS"),
+                new Intent("android.settings.ACCOUNT_SYNC_SETTINGS"),
+                new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS),
+                new Intent("android.settings.LICENSE"),
+                new Intent("android.settings.NOTIFICATION_SETTINGS"),
+                new Intent("android.settings.USER_SETTINGS"),
+                new Intent("android.settings.ZEN_MODE_SETTINGS"),
+                new Intent("com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS"),
+                new Intent("com.android.settings.STORAGE_USB_SETTINGS"),
+                new Intent("com.android.settings.TTS_SETTINGS"),
+                new Intent("com.android.settings.USER_DICTIONARY_EDIT"),
+                new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS),
+                new Intent(Settings.ACTION_SYNC_SETTINGS),
+                new Intent(Settings.ACTION_ADD_ACCOUNT),
+                new Intent(Intent.ACTION_GET_CONTENT).setType("*/*").addCategory(
+                        Intent.CATEGORY_OPENABLE),
+                new Intent(Intent.ACTION_OPEN_DOCUMENT).setType("*/*").addCategory(
+                        Intent.CATEGORY_OPENABLE),
+                new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS),
+                new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS),
+                new Intent(Settings.ACTION_APPLICATION_SETTINGS)
+            ));
 
     // These are the intents which cannot be forwarded to the primary profile.
-    private static final Intent[] notForwardedIntentsFromManaged = new Intent[] {
-        new Intent(Intent.ACTION_INSERT).setData(
-                Uri.parse("content://browser/bookmarks")),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("http://www.example.com")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Intent.ACTION_SENDTO).setData(
-                Uri.parse("mailto:user@example.com")),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("mailto:user@example.com")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("geo:0,0?q=BuckinghamPalace")),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("http://example.com/oceans.mp4")).setType("video/mp4"),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("http://www.example.com/horse.mp3")).setType("audio/*"),
-        new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH),
-        new Intent(Intent.ACTION_VIEW).setData(
-                Uri.parse("market://details?id=com.android.chrome")).addCategory(
-                Intent.CATEGORY_BROWSABLE),
-        new Intent(Intent.ACTION_WEB_SEARCH),
-        new Intent(Settings.ACTION_SEARCH_SETTINGS),
-        new Intent(Settings.ACTION_PRINT_SETTINGS),
-        new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE),
-        new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(
-                Uri.parse("package:com.android.chrome")),
-        new Intent("android.settings.SHOW_INPUT_METHOD_PICKER"),
-        new Intent(Intent.ACTION_INSERT).setData(Events.CONTENT_URI),
-        new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL),
-        new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)
-    };
+    private static final ArrayList<Intent> notForwardedIntentsFromManaged =
+            new ArrayList<>(Arrays.asList(
+                new Intent(Intent.ACTION_INSERT).setData(
+                        Uri.parse("content://browser/bookmarks")),
+                new Intent(Intent.ACTION_VIEW).setData(
+                        Uri.parse("http://www.example.com")).addCategory(
+                        Intent.CATEGORY_BROWSABLE),
+                new Intent(Intent.ACTION_SENDTO).setData(
+                        Uri.parse("mailto:user@example.com")),
+                new Intent(Intent.ACTION_VIEW).setData(
+                        Uri.parse("mailto:user@example.com")).addCategory(
+                        Intent.CATEGORY_BROWSABLE),
+                new Intent(Intent.ACTION_VIEW).setData(
+                        Uri.parse("geo:0,0?q=BuckinghamPalace")),
+                new Intent(Intent.ACTION_VIEW).setData(
+                        Uri.parse("http://example.com/oceans.mp4")).setType("video/mp4"),
+                new Intent(Intent.ACTION_VIEW).setData(
+                        Uri.parse("http://www.example.com/horse.mp3")).setType("audio/*"),
+                new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH),
+                new Intent(Intent.ACTION_VIEW).setData(
+                        Uri.parse("market://details?id=com.android.chrome")).addCategory(
+                        Intent.CATEGORY_BROWSABLE),
+                new Intent(Intent.ACTION_WEB_SEARCH),
+                new Intent(Settings.ACTION_SEARCH_SETTINGS),
+                new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE),
+                new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(
+                        Uri.parse("package:com.android.chrome")),
+                new Intent(Intent.ACTION_INSERT).setData(Events.CONTENT_URI),
+                new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)
+            ));
 
     // This flag specifies we are dealing with intents fired from the primary profile.
     public static final int FLAG_INTENTS_FROM_PRIMARY = 1;
@@ -187,6 +140,124 @@
 
     IntentFiltersTestHelper(Context context) {
         mContext = context;
+
+        addIntentsThatDependOnDeviceFeatures();
+    }
+
+    private void addIntentsThatDependOnDeviceFeatures() {
+        PackageManager pm = mContext.getPackageManager();
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            forwardedIntentsFromManaged.addAll(Arrays.asList(
+                    new Intent(Intent.ACTION_DIAL).setData(Uri.parse("tel:123")),
+                    new Intent(Intent.ACTION_CALL).setData(Uri.parse("tel:123")),
+                    new Intent("android.intent.action.CALL_EMERGENCY").setData(
+                            Uri.parse("tel:123")),
+                    new Intent("android.intent.action.CALL_PRIVILEGED").setData(
+                            Uri.parse("tel:123")),
+                    new Intent(Intent.ACTION_VIEW).setData(Uri.parse("tel:123")).addCategory(
+                            Intent.CATEGORY_BROWSABLE),
+                    new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS),
+                    new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS),
+                    new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("sms:07700900100")),
+                    new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("smsto:07700900100")),
+                    new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("mms:07700900100")),
+                    new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("mmsto:07700900100")),
+                    new Intent(Intent.ACTION_VIEW).setData(
+                            Uri.parse("sms:07700900100?body=Hello%20world")).addCategory(
+                            Intent.CATEGORY_BROWSABLE),
+                    new Intent(Intent.ACTION_VIEW).setData(
+                            Uri.parse("smsto:07700900100?body=Hello%20world")).addCategory(
+                            Intent.CATEGORY_BROWSABLE),
+                    new Intent(Intent.ACTION_VIEW).setData(
+                            Uri.parse("mms:07700900100?body=Hello%20world")).addCategory(
+                            Intent.CATEGORY_BROWSABLE),
+                    new Intent(Intent.ACTION_VIEW).setData(
+                            Uri.parse("mmsto:07700900100?body=Hello%20world")).addCategory(
+                            Intent.CATEGORY_BROWSABLE),
+                    new Intent(Settings.ACTION_APN_SETTINGS)));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
+            forwardedIntentsFromManaged.addAll(Arrays.asList(
+                    new Intent(Settings.ACTION_NFC_SETTINGS),
+                    new Intent(Settings.ACTION_NFCSHARING_SETTINGS),
+                    new Intent(Settings.ACTION_NFC_PAYMENT_SETTINGS)));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
+            forwardedIntentsFromManaged.add(
+                    new Intent(CardEmulation.ACTION_CHANGE_DEFAULT));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
+            forwardedIntentsFromManaged.addAll(Arrays.asList(
+                    new Intent(MediaStore.ACTION_IMAGE_CAPTURE),
+                    new Intent(MediaStore.ACTION_VIDEO_CAPTURE),
+                    new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA),
+                    new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA),
+                    new Intent(MediaStore.ACTION_IMAGE_CAPTURE_SECURE),
+                    new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE)));
+        }
+
+        final String state = Environment.getExternalStorageState();
+        if (Environment.MEDIA_MOUNTED.equals(state)) {
+            forwardedIntentsFromManaged.add(
+                    new Intent(Settings.ACTION_MEMORY_CARD_SETTINGS));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+            forwardedIntentsFromManaged.addAll(Arrays.asList(
+                    new Intent(Settings.ACTION_WIFI_IP_SETTINGS),
+                    new Intent(Settings.ACTION_WIFI_SETTINGS)));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
+            forwardedIntentsFromManaged.addAll(Arrays.asList(
+                    new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION),
+                    new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_LOCATION)) {
+            forwardedIntentsFromManaged.add(
+                    new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)) {
+            forwardedIntentsFromManaged.addAll(Arrays.asList(
+                    new Intent(Settings.ACTION_SOUND_SETTINGS),
+                    new Intent("android.settings.ACTION_OTHER_SOUND_SETTINGS")));
+            notForwardedIntentsFromManaged.add(
+                    new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_HOME_SCREEN)) {
+            forwardedIntentsFromManaged.add(
+                    new Intent(Settings.ACTION_HOME_SETTINGS));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_INPUT_METHODS)) {
+            forwardedIntentsFromManaged.addAll(Arrays.asList(
+                    new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS),
+                    new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS)));
+            notForwardedIntentsFromManaged.add(
+                    new Intent("android.settings.SHOW_INPUT_METHOD_PICKER"));
+        }
+
+        if (!pm.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+            forwardedIntentsFromManaged.add(
+                    new Intent(Settings.ACTION_DREAM_SETTINGS));
+        }
+
+        if (!pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
+            forwardedIntentsFromManaged.add(
+                    new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS));
+        }
+
+        if (pm.hasSystemFeature(PackageManager.FEATURE_PRINTING)) {
+            notForwardedIntentsFromManaged.add(
+                    new Intent(Settings.ACTION_PRINT_SETTINGS));
+        }
     }
 
     public boolean checkCrossProfileIntentFilters(int flag) {
@@ -298,7 +369,7 @@
      * @return {@code null} if all the intents are correctly handled
      *         otherwise, the first intent in the list which is not handled correctly.
      */
-    private Intent checkForIntentsNotHandled(Intent[] intentList,
+    private Intent checkForIntentsNotHandled(ArrayList<Intent> intentList,
             ActivityInfo expectedForwarderActivityInfo, boolean canResolve) {
         for (Intent intent : intentList) {
             if (canForwarderActivityHandleIntent(intent,