Update Battery settings main page string (1/2)
- Update Battery usage preference summary string - Update Battery saver preference summary string - Update Adaptive preference column string Screenshot: https://screenshot.googleplex.com/6FVaoeHjTSFs2o6.png Bug: 183689347 Test: make RunSettingsRoboTests -j40 Change-Id: I72c5ebb5d3fd189db7c40c645b8dab4367d154ba
This commit is contained in:
@@ -5830,6 +5830,8 @@
|
||||
<string name="history_details_title">History details</string>
|
||||
<!-- Preference title for advanced battery usage [CHAR LIMIT=40] -->
|
||||
<string name="advanced_battery_preference_title">View battery usage</string>
|
||||
<!-- Preference summary for advanced battery usage [CHAR LIMIT=40] -->
|
||||
<string name="advanced_battery_preference_summary">View usage for past 24 hours</string>
|
||||
|
||||
<!-- Activity title for battery usage details for an app. or power consumer -->
|
||||
<string name="battery_details_title">Battery usage</string>
|
||||
@@ -5966,7 +5968,7 @@
|
||||
<string name="battery_auto_restriction_summary">Detect when apps drain battery</string>
|
||||
|
||||
<!-- Summary for battery manager when it is on -->
|
||||
<string name="battery_manager_on" product="default">On / Detecting when apps drain battery</string>
|
||||
<string name="battery_manager_summary">Detecting when apps drain battery</string>
|
||||
|
||||
<!-- Summary for battery manager when it is off -->
|
||||
<string name="battery_manager_off">Off</string>
|
||||
@@ -6232,6 +6234,9 @@
|
||||
<!-- Battery saver: Label for preference to indicate there is a routine based schedule [CHAR_LIMIT=40] -->
|
||||
<string name="battery_saver_auto_routine">Based on your routine</string>
|
||||
|
||||
<!-- Battery saver: Summary for preference to indicate there is a routine based schedule [CHAR_LIMIT=40] -->
|
||||
<string name="battery_saver_pref_auto_routine_summary">Will turn on based on your routine</string>
|
||||
|
||||
<!-- Battery saver: Label for preference to indicate there is a percentage based schedule [CHAR_LIMIT=40] -->
|
||||
<string name="battery_saver_auto_percentage">Based on percentage</string>
|
||||
|
||||
|
@@ -111,7 +111,7 @@ public class BatterySaverController extends BasePreferenceController
|
||||
Utils.formatPercentage(percent)) :
|
||||
mContext.getString(R.string.battery_saver_off_summary);
|
||||
} else {
|
||||
return mContext.getString(R.string.battery_saver_auto_routine);
|
||||
return mContext.getString(R.string.battery_saver_pref_auto_routine_summary);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.fuelgauge.batterytip;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
@@ -34,7 +33,6 @@ import com.android.settings.overlay.FeatureFactory;
|
||||
*/
|
||||
public class BatteryManagerPreferenceController extends BasePreferenceController {
|
||||
private static final String KEY_BATTERY_MANAGER = "smart_battery_manager";
|
||||
private static final int ON = 1;
|
||||
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
|
||||
private AppOpsManager mAppOpsManager;
|
||||
private UserManager mUserManager;
|
||||
@@ -56,24 +54,17 @@ public class BatteryManagerPreferenceController extends BasePreferenceController
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
final int num = BatteryTipUtils.getRestrictedAppsList(mAppOpsManager, mUserManager).size();
|
||||
final String setting = mPowerUsageFeatureProvider.isSmartBatterySupported()
|
||||
? Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED
|
||||
: Settings.Global.APP_AUTO_RESTRICTION_ENABLED;
|
||||
final boolean featureOn =
|
||||
Settings.Global.getInt(mContext.getContentResolver(), setting, ON) == ON;
|
||||
|
||||
updateSummary(preference, featureOn, num);
|
||||
updateSummary(preference, num);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateSummary(Preference preference, boolean featureOn, int num) {
|
||||
void updateSummary(Preference preference, int num) {
|
||||
if (num > 0) {
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.battery_manager_app_restricted, num, num));
|
||||
} else if (featureOn) {
|
||||
preference.setSummary(R.string.battery_manager_on);
|
||||
} else {
|
||||
preference.setSummary(R.string.battery_manager_off);
|
||||
preference.setSummary(R.string.battery_manager_summary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -105,7 +105,8 @@ public class BatterySaverControllerTest {
|
||||
Settings.Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
|
||||
|
||||
assertThat(mBatterySaverController.getSummary()).isEqualTo("Based on your routine");
|
||||
assertThat(mBatterySaverController.getSummary()).
|
||||
isEqualTo("Will turn on based on your routine");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -63,31 +63,20 @@ public class BatteryManagerPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_smartBatteryOnWithRestrictApps_showSummary() {
|
||||
mController.updateSummary(mPreference, true /* smartBatteryOn */, 2);
|
||||
public void updateState_smartBatteryWithRestrictApps_showSummary() {
|
||||
mController.updateSummary(mPreference, 2);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo("2 apps restricted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_smartBatteryOnWithoutRestriction_showSummary() {
|
||||
public void updateState_smartBatteryWithoutRestriction_showSummary() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isSmartBatterySupported()).thenReturn(true);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, ON);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo("On / Detecting when apps drain battery");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_smartBatteryOff_showSummary() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isSmartBatterySupported()).thenReturn(true);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, OFF);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo("Off");
|
||||
assertThat(mPreference.getSummary()).isEqualTo("Detecting when apps drain battery");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user