Add a flag to enable/disable new device suggestion
Change-Id: Iebf982731a01b3d6c1d3ad60e9d1f858f4e9151e Fix: 62907886 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -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>
|
||||
|
@@ -28,6 +28,7 @@ import android.text.TextUtils;
|
||||
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 class NewDeviceIntroSuggestionActivity extends Activity {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
20
tests/robotests/res/values/config.xml
Normal file
20
tests/robotests/res/values/config.xml
Normal file
@@ -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>
|
@@ -22,9 +22,10 @@ import android.content.Intent;
|
||||
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;
|
||||
@@ -69,6 +70,16 @@ public class NewDeviceIntroSuggestionActivityTest {
|
||||
.thenReturn(getSharedPreferences());
|
||||
}
|
||||
|
||||
@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();
|
||||
|
Reference in New Issue
Block a user