Merge "Revert "Revert "Change battery tip text"""
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 48b1333..96e3dd1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3029,11 +3029,15 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
- <action android:name="android.settings.panel.action.VOLUME" />
+ <action android:name="android.settings.panel.action.NFC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
- <action android:name="android.settings.panel.action.NFC" />
+ <action android:name="android.settings.panel.action.WIFI" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.settings.panel.action.VOLUME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6cbe22b..48bee2d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5587,6 +5587,12 @@
<!-- Battery saver: Title for battery saver schedule screen [CHAR_LIMIT=40] -->
<string name="battery_saver_schedule_settings_title">Set a schedule</string>
+ <!-- Battery Saver: Title for sticky battery saver preference [CHAR_LIMIT=60] -->
+ <string name="battery_saver_sticky_title">Keep battery saver on</string>
+
+ <!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
+ <string name="battery_saver_sticky_description">Battery saver will stay on even after device is fully charged</string>
+
<!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
<string name="battery_saver_seekbar_title"><xliff:g id="percent">%1$s</xliff:g></string>
@@ -7151,6 +7157,9 @@
<string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
<!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
+ <!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
+ <string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
+
<!-- NFC Wi-Fi pairing/setup strings-->
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 89f7eab..ae9d14d 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -26,6 +26,13 @@
android:title="@string/battery_saver_schedule_settings_title"
settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverSchedulePreferenceController"/>
+ <SwitchPreference
+ android:key="battery_saver_sticky"
+ android:title="@string/battery_saver_sticky_title"
+ android:summary="@string/battery_saver_sticky_description"
+ settings:keywords="@string/keywords_battery_saver_sticky"
+ settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController"/>
+
<com.android.settings.widget.TwoStateButtonPreference
android:key="battery_saver"
android:title="@string/battery_saver"
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index b650c6c..39a7a80 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -16,8 +16,6 @@
package com.android.settings.biometrics;
-import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
-
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -25,8 +23,11 @@
import com.android.settings.biometrics.face.FaceEnrollIntroduction;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.biometrics.fingerprint.SetupFingerprintEnrollIntroduction;
import com.android.settings.core.InstrumentedActivity;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
/**
* Trampoline activity launched by the {@code android.settings.BIOMETRIC_ENROLL} action which
* shows the user an appropriate enrollment flow depending on the device's biometric hardware.
@@ -40,20 +41,38 @@
super.onCreate(savedInstanceState);
final PackageManager pm = getApplicationContext().getPackageManager();
- final Intent intent = new Intent();
+ Intent intent;
// This logic may have to be modified on devices with multiple biometrics.
if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
- intent.setClassName(SETTINGS_PACKAGE_NAME,
- FingerprintEnrollIntroduction.class.getName());
+ intent = getFingerprintEnrollIntent();
} else if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
- intent.setClassName(SETTINGS_PACKAGE_NAME, FaceEnrollIntroduction.class.getName());
+ intent = getFaceEnrollIntent();
+ } else {
+ intent = new Intent();
}
+ intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent);
finish();
}
+ private Intent getFingerprintEnrollIntent() {
+ if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
+ Intent intent = new Intent(this, SetupFingerprintEnrollIntroduction.class);
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
+ return intent;
+ } else {
+ return new Intent(this, FingerprintEnrollIntroduction.class);
+ }
+ }
+
+ private Intent getFaceEnrollIntent() {
+ Intent intent = new Intent(this, FaceEnrollIntroduction.class);
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
+ return intent;
+ }
+
@Override
public int getMetricsCategory() {
return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index e8cf809..d7f2c97 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -27,8 +27,10 @@
import com.android.settings.R;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.password.SetupChooseLockGeneric;
import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
/**
@@ -199,7 +201,13 @@
}
protected Intent getChooseLockIntent() {
- return new Intent(this, ChooseLockGeneric.class);
+ if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
+ Intent intent = new Intent(this, SetupChooseLockGeneric.class);
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
+ return intent;
+ } else {
+ return new Intent(this, ChooseLockGeneric.class);
+ }
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index e45817d..8d4c82e 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -36,6 +36,7 @@
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@@ -166,6 +167,7 @@
intent.setClass(this, FaceEnrollEnrolling.class);
}
intent.putExtra(EXTRA_KEY_REQUIRE_DIVERSITY, mSwitchDiversity.isChecked());
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
return intent;
}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
new file mode 100644
index 0000000..b14fec9
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -0,0 +1,41 @@
+package com.android.settings.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerMixin;
+
+public class BatterySaverStickyPreferenceController extends BasePreferenceController implements
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ public static final String LOW_POWER_STICKY_AUTO_DISABLE_ENABLED =
+ "low_power_sticky_auto_disable_enabled";
+
+ public BatterySaverStickyPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ int setting = Settings.System.getInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED, 1);
+
+ ((SwitchPreference) preference).setChecked(setting == 0);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ boolean keepActive = (Boolean) newValue;
+ Settings.System.putInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ keepActive ? 0 : 1);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
index 12590ff..43e90e8 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
@@ -165,6 +165,7 @@
com.android.settings.intelligence.ContextualCardProto.ContextualCard.newBuilder()
.setSliceUri(card.getSliceUri().toString())
.setCardName(card.getName())
+ .setCardScore(card.getRankingScore())
.build()));
return builder.build().toByteArray();
}
diff --git a/src/com/android/settings/panel/NfcPanel.java b/src/com/android/settings/panel/NfcPanel.java
index 8fa41d9..6a9c74d 100644
--- a/src/com/android/settings/panel/NfcPanel.java
+++ b/src/com/android/settings/panel/NfcPanel.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
package com.android.settings.panel;
import android.app.settings.SettingsEnums;
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index 6b096a1..67c300f 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -28,12 +28,14 @@
switch (panelType) {
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
return InternetConnectivityPanel.create(context);
- case Settings.Panel.ACTION_VOLUME:
- return VolumePanel.create(context);
- case Settings.Panel.ACTION_NFC:
- return NfcPanel.create(context);
case ACTION_MEDIA_OUTPUT:
return MediaOutputPanel.create(context, mediaPackageName);
+ case Settings.Panel.ACTION_NFC:
+ return NfcPanel.create(context);
+ case Settings.Panel.ACTION_WIFI:
+ return WifiPanel.create(context);
+ case Settings.Panel.ACTION_VOLUME:
+ return VolumePanel.create(context);
}
throw new IllegalStateException("No matching panel for: " + panelType);
diff --git a/src/com/android/settings/panel/WifiPanel.java b/src/com/android/settings/panel/WifiPanel.java
new file mode 100644
index 0000000..6d83742
--- /dev/null
+++ b/src/com/android/settings/panel/WifiPanel.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+package com.android.settings.panel;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+
+import com.android.settings.R;
+import com.android.settings.SubSettings;
+import com.android.settings.network.NetworkDashboardFragment;
+import com.android.settings.slices.CustomSliceRegistry;
+import com.android.settings.slices.SliceBuilderUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Panel data class for Wifi settings.
+ */
+public class WifiPanel implements PanelContent {
+
+ private final Context mContext;
+
+ public static WifiPanel create(Context context) {
+ return new WifiPanel(context);
+ }
+
+ private WifiPanel(Context context) {
+ mContext = context.getApplicationContext();
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mContext.getText(R.string.wifi_settings);
+ }
+
+ @Override
+ public List<Uri> getSlices() {
+ final List<Uri> uris = new ArrayList<>();
+ uris.add(CustomSliceRegistry.WIFI_SLICE_URI);
+ return uris;
+ }
+
+ @Override
+ public Intent getSeeMoreIntent() {
+ final String screenTitle =
+ mContext.getText(R.string.network_dashboard_title).toString();
+ final Intent intent = SliceBuilderUtils.buildSearchResultPageIntent(mContext,
+ NetworkDashboardFragment.class.getName(),
+ null /* key */,
+ screenTitle,
+ SettingsEnums.SETTINGS_NETWORK_CATEGORY);
+ intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
+ return intent;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_WIFI;
+ }
+}
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 8d20f7f..a2debb8 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -198,7 +198,7 @@
private IconCompat getEndIcon(AccessPoint accessPoint) {
if (accessPoint.isActive()) {
- return IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent);
+ return null;
} else if (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
return IconCompat.createWithResource(mContext, R.drawable.ic_friction_lock_closed);
} else if (accessPoint.isMetered()) {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
new file mode 100644
index 0000000..a441864
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package com.android.settings.fuelgauge.batterysaver;
+
+import static com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController.LOW_POWER_STICKY_AUTO_DISABLE_ENABLED;
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class BatterySaverStickyPreferenceControllerTest {
+
+ private static final String PREF_KEY = "battery_saver_sticky";
+
+ private Context mContext;
+ private BatterySaverStickyPreferenceController mController;
+
+ @Before
+ public void setup() {
+ mContext = RuntimeEnvironment.application;
+ mController = new BatterySaverStickyPreferenceController(mContext, PREF_KEY);
+ }
+
+ private int getAutoDisableSetting() {
+ return Settings.System.getInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ 1);
+ }
+
+ @Test
+ public void testOnPreferenceChange_turnOnKeepActive_autoDisableOff() {
+ mController.onPreferenceChange(null, true);
+ final int isOn = getAutoDisableSetting();
+ assertThat(isOn).isEqualTo(0);
+ }
+
+ @Test
+ public void testOnPreferenceChange_TurnOffKeepActive_autoDisableOff() {
+ mController.onPreferenceChange(null, false);
+ final int isOn = getAutoDisableSetting();
+ assertThat(isOn).isEqualTo(1);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java b/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java
index bf6662d..1de2c5a 100644
--- a/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java
+++ b/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
package com.android.settings.panel;
import static com.google.common.truth.Truth.assertThat;
diff --git a/tests/robotests/src/com/android/settings/panel/WifiPanelTest.java b/tests/robotests/src/com/android/settings/panel/WifiPanelTest.java
new file mode 100644
index 0000000..08db23e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/panel/WifiPanelTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+package com.android.settings.panel;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.net.Uri;
+
+import com.android.settings.slices.CustomSliceRegistry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiPanelTest {
+
+ private WifiPanel mPanel;
+
+ @Before
+ public void setUp() {
+ mPanel = WifiPanel.create(RuntimeEnvironment.application);
+ }
+
+ @Test
+ public void getSlices_containsNecessarySlices() {
+ final List<Uri> uris = mPanel.getSlices();
+
+ assertThat(uris).containsExactly(
+ CustomSliceRegistry.WIFI_SLICE_URI);
+ }
+
+ @Test
+ public void getSeeMoreIntent_notNull() {
+ assertThat(mPanel.getSeeMoreIntent()).isNotNull();
+ }
+}