Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88ce0942 authored by Fan Zhang's avatar Fan Zhang Committed by android-build-merger
Browse files

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

am: e2859904

Change-Id: I4ee4f15c73d8ef633704553b8147c3c3c3a02a6c
parents a043cf04 e2859904
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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>
+10 −1
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
<!--
  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
+12 −1
Original line number Diff line number Diff line
@@ -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();