Launch activities in another task if the metadata is set.

Add FLAG_ACTIVITY_NEW_TASK to the intent if META_DATA_LAUNCH_NEW_TASK is
set to true to make it launch a separate task.

Bug: 197702494
Bug: 197700978
Bug: 197702789
Test: Set this metadata to true and make sure this page is launched in another task.
Change-Id: I3b4e5745e940a3db5db6be51e17a9c505915e3c0
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 4581f6c..27b20cf 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -421,6 +421,11 @@
         ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
         mMetricsFeatureProvider.logStartedIntent(intent, sourceMetricCategory);
 
+        //TODO(b/201970810): Add test cases.
+        if (tile.isNewTask(mContext)) {
+            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        }
+
         if (tile.userHandle == null || tile.isPrimaryProfileOnly()) {
             activity.startActivity(intent);
         } else if (tile.userHandle.size() == 1) {