Merge "Add a flag to enable/disable new device suggestion" into oc-dr1-dev am: e28599049e

am: 88ce094235

Change-Id: Iefc8c7173e6d375d1045a3b148ba5c0f11c426e2
This commit is contained in:
Fan Zhang
2017-06-23 17:47:36 +00:00
committed by android-build-merger
4 changed files with 44 additions and 2 deletions

View File

@@ -116,4 +116,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>

View File

@@ -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) {

View 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>

View File

@@ -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();