Add a flag to enable/disable new device suggestion

Change-Id: Iebf982731a01b3d6c1d3ad60e9d1f858f4e9151e
Fix: 62907886
Test: make RunSettingsRoboTests
diff --git a/res/values/config.xml b/res/values/config.xml
index 0ec92fc..8694887 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -113,4 +113,6 @@
     <!-- Class name for the storage manager's deletion helper class. -->
     <string name="config_deletion_helper_class" translatable="false">com.android.storagemanager.deletionhelper.DeletionHelperActivity</string>
 
+    <!-- Whether or not new device intro suggestion is supported for this device -->
+    <bool name="config_new_device_intro_suggestion_supported">false</bool>
 </resources>
diff --git a/src/com/android/settings/support/NewDeviceIntroSuggestionActivity.java b/src/com/android/settings/support/NewDeviceIntroSuggestionActivity.java
index 2189184..f881e2f 100644
--- a/src/com/android/settings/support/NewDeviceIntroSuggestionActivity.java
+++ b/src/com/android/settings/support/NewDeviceIntroSuggestionActivity.java
@@ -28,6 +28,7 @@
 import android.text.format.DateUtils;
 import android.util.Log;
 
+import com.android.settings.R;
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.overlay.SupportFeatureProvider;
@@ -61,7 +62,15 @@
     }
 
     public static boolean isSuggestionComplete(Context context) {
-        return isExpired(context) || hasLaunchedBefore(context) || !canOpenUrlInBrowser(context);
+        return !isSupported(context)
+                || isExpired(context)
+                || hasLaunchedBefore(context)
+                || !canOpenUrlInBrowser(context);
+    }
+
+    private static boolean isSupported(Context context) {
+        return context.getResources()
+                .getBoolean(R.bool.config_new_device_intro_suggestion_supported);
     }
 
     private static boolean isExpired(Context context) {
diff --git a/tests/robotests/res/values/config.xml b/tests/robotests/res/values/config.xml
new file mode 100644
index 0000000..156e20a
--- /dev/null
+++ b/tests/robotests/res/values/config.xml
@@ -0,0 +1,20 @@
+<!--
+  Copyright (C) 2017 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<resources>
+    <!-- Whether or not new device intro suggestion is supported for this device -->
+    <bool name="config_new_device_intro_suggestion_supported">true</bool>
+</resources>
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java
index dc0f5fd..75551e5 100644
--- a/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java
@@ -22,9 +22,10 @@
 import android.content.SharedPreferences;
 import android.content.pm.ResolveInfo;
 
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.R;
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -70,6 +71,16 @@
     }
 
     @Test
+    public void isSuggestionComplete_notSupported_shouldReturnTrue() {
+        when(mMockContext.getResources()
+                .getBoolean(R.bool.config_new_device_intro_suggestion_supported))
+                .thenReturn(false);
+
+        assertThat(isSuggestionComplete(mContext))
+                .isTrue();
+    }
+
+    @Test
     public void isSuggestionComplete_suggestionExpired_shouldReturnTrue() {
         final long currentTime = System.currentTimeMillis();