Merge "Update battery settings strings" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
17a463130e
@@ -4899,10 +4899,6 @@
|
|||||||
<string name="background_activity_title">Background restriction</string>
|
<string name="background_activity_title">Background restriction</string>
|
||||||
<!-- Summary for the background activity [CHAR_LIMIT=120] -->
|
<!-- Summary for the background activity [CHAR_LIMIT=120] -->
|
||||||
<string name="background_activity_summary">Allow the app to run in the background</string>
|
<string name="background_activity_summary">Allow the app to run in the background</string>
|
||||||
<!-- Summary for the background activity when it is on [CHAR_LIMIT=120] -->
|
|
||||||
<string name="background_activity_summary_on">App can run in the background when not in use</string>
|
|
||||||
<!-- Summary for the background activity when it is off [CHAR_LIMIT=120] -->
|
|
||||||
<string name="background_activity_summary_off">App\'s background activity is limited when not in use</string>
|
|
||||||
<!-- Summary for the background activity when it is disabled [CHAR_LIMIT=120] -->
|
<!-- Summary for the background activity when it is disabled [CHAR_LIMIT=120] -->
|
||||||
<string name="background_activity_summary_disabled">App not allowed to run in background</string>
|
<string name="background_activity_summary_disabled">App not allowed to run in background</string>
|
||||||
<!-- TODO: Pending UX review. Summary for the background activity when it is whitlisted [CHAR_LIMIT=120] -->
|
<!-- TODO: Pending UX review. Summary for the background activity when it is whitlisted [CHAR_LIMIT=120] -->
|
||||||
@@ -5023,11 +5019,11 @@
|
|||||||
<!-- Summary for the battery high usage tip, which presents battery may run out soon [CHAR LIMIT=NONE] -->
|
<!-- Summary for the battery high usage tip, which presents battery may run out soon [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_high_usage_summary">Battery may run out soon</string>
|
<string name="battery_tip_high_usage_summary">Battery may run out soon</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last full charge(<xliff:g id="time_period_ago" example="1 hr ago">%2$s</xliff:g>):</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_dialog_message" product="tablet">Your tablet has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
<string name="battery_tip_dialog_message" product="tablet">Your tablet has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last full charge(<xliff:g id="time_period_ago" example="1 hr ago">%2$s</xliff:g>):</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_dialog_message" product="device">Your device has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
<string name="battery_tip_dialog_message" product="device">Your device has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last full charge(<xliff:g id="time_period_ago" example="1 hr ago">%2$s</xliff:g>):</string>
|
||||||
<!-- Title for restricted app preference, showing how many app need to be restricted [CHAR LIMIT=NONE] -->
|
<!-- Title for restricted app preference, showing how many app need to be restricted [CHAR LIMIT=NONE] -->
|
||||||
<plurals name="battery_tip_restrict_title">
|
<plurals name="battery_tip_restrict_title">
|
||||||
<item quantity="one">Restrict %1$d app</item>
|
<item quantity="one">Restrict %1$d app</item>
|
||||||
@@ -5097,7 +5093,7 @@
|
|||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
<!-- Footer message for restrict app details page -->
|
<!-- Footer message for restrict app details page -->
|
||||||
<string name="restricted_app_detail_footer">Apps shown here aren\'t behaving properly and have been using battery in the background.\n\nThese apps are now blocked from using battery in the background. As a result, some app notifications may be delayed.</string>
|
<string name="restricted_app_detail_footer">These apps have been using battery in the background. Restricted apps may not work properly and notifications may be delayed.</string>
|
||||||
|
|
||||||
<!-- Title for auto restriction toggle -->
|
<!-- Title for auto restriction toggle -->
|
||||||
<string name="battery_auto_restriction_title">Use Battery Manager</string>
|
<string name="battery_auto_restriction_title">Use Battery Manager</string>
|
||||||
@@ -8022,7 +8018,7 @@
|
|||||||
<string name="encryption_interstitial_no">No</string>
|
<string name="encryption_interstitial_no">No</string>
|
||||||
|
|
||||||
<!-- Label to say yes to the question of whether app is restricted. [CHAR LIMIT=20] -->
|
<!-- Label to say yes to the question of whether app is restricted. [CHAR LIMIT=20] -->
|
||||||
<string name="restricted_true_label">App can\u2019t use battery in background</string>
|
<string name="restricted_true_label">Restricted</string>
|
||||||
<!-- Label to say no to the question of whether app is restricted. [CHAR LIMIT=20] -->
|
<!-- Label to say no to the question of whether app is restricted. [CHAR LIMIT=20] -->
|
||||||
<string name="restricted_false_label">App can use battery in background</string>
|
<string name="restricted_false_label">App can use battery in background</string>
|
||||||
|
|
||||||
|
@@ -102,7 +102,10 @@ public class BatteryTipDialogFragment extends InstrumentedDialogFragment impleme
|
|||||||
|
|
||||||
return new AlertDialog.Builder(context)
|
return new AlertDialog.Builder(context)
|
||||||
.setMessage(getString(R.string.battery_tip_dialog_message,
|
.setMessage(getString(R.string.battery_tip_dialog_message,
|
||||||
highUsageTip.getHighUsageAppList().size()))
|
highUsageTip.getHighUsageAppList().size(),
|
||||||
|
StringUtil.formatRelativeTime(context,
|
||||||
|
highUsageTip.getLastFullChargeTimeMs(),
|
||||||
|
false /* withSeconds */)))
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.create();
|
.create();
|
||||||
|
@@ -63,7 +63,8 @@ public class HighUsageDetector implements BatteryTipDetector {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatteryTip detect() {
|
public BatteryTip detect() {
|
||||||
final long screenUsageTimeMs = mBatteryUtils.calculateScreenUsageTime(mBatteryStatsHelper);
|
final long lastFullChargeTimeMs = mBatteryUtils.calculateLastFullChargeTime(
|
||||||
|
mBatteryStatsHelper, System.currentTimeMillis());
|
||||||
if (mPolicy.highUsageEnabled) {
|
if (mPolicy.highUsageEnabled) {
|
||||||
parseBatteryData();
|
parseBatteryData();
|
||||||
if (mDataParser.isDeviceHeavilyUsed() || mPolicy.testHighUsageTip) {
|
if (mDataParser.isDeviceHeavilyUsed() || mPolicy.testHighUsageTip) {
|
||||||
@@ -99,7 +100,7 @@ public class HighUsageDetector implements BatteryTipDetector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HighUsageTip(screenUsageTimeMs, mHighUsageAppList);
|
return new HighUsageTip(lastFullChargeTimeMs, mHighUsageAppList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@@ -26,7 +26,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.fuelgauge.batterytip.AppInfo;
|
import com.android.settings.fuelgauge.batterytip.AppInfo;
|
||||||
|
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
import com.android.settingslib.utils.StringUtil;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,28 +34,28 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class HighUsageTip extends BatteryTip {
|
public class HighUsageTip extends BatteryTip {
|
||||||
|
|
||||||
private final long mScreenTimeMs;
|
private final long mLastFullChargeTimeMs;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final List<AppInfo> mHighUsageAppList;
|
final List<AppInfo> mHighUsageAppList;
|
||||||
|
|
||||||
public HighUsageTip(long screenTimeMs, List<AppInfo> appList) {
|
public HighUsageTip(long lastFullChargeTimeMs, List<AppInfo> appList) {
|
||||||
super(TipType.HIGH_DEVICE_USAGE, appList.isEmpty() ? StateType.INVISIBLE : StateType.NEW,
|
super(TipType.HIGH_DEVICE_USAGE, appList.isEmpty() ? StateType.INVISIBLE : StateType.NEW,
|
||||||
true /* showDialog */);
|
true /* showDialog */);
|
||||||
mScreenTimeMs = screenTimeMs;
|
mLastFullChargeTimeMs = lastFullChargeTimeMs;
|
||||||
mHighUsageAppList = appList;
|
mHighUsageAppList = appList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
HighUsageTip(Parcel in) {
|
HighUsageTip(Parcel in) {
|
||||||
super(in);
|
super(in);
|
||||||
mScreenTimeMs = in.readLong();
|
mLastFullChargeTimeMs = in.readLong();
|
||||||
mHighUsageAppList = in.createTypedArrayList(AppInfo.CREATOR);
|
mHighUsageAppList = in.createTypedArrayList(AppInfo.CREATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
super.writeToParcel(dest, flags);
|
super.writeToParcel(dest, flags);
|
||||||
dest.writeLong(mScreenTimeMs);
|
dest.writeLong(mLastFullChargeTimeMs);
|
||||||
dest.writeTypedList(mHighUsageAppList);
|
dest.writeTypedList(mHighUsageAppList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +91,8 @@ public class HighUsageTip extends BatteryTip {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getScreenTimeMs() {
|
public long getLastFullChargeTimeMs() {
|
||||||
return mScreenTimeMs;
|
return mLastFullChargeTimeMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AppInfo> getHighUsageAppList() {
|
public List<AppInfo> getHighUsageAppList() {
|
||||||
|
@@ -183,7 +183,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateSummary(mPreference);
|
mController.updateSummary(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.getSummary()).isEqualTo("App can\u2019t use battery in background");
|
assertThat(mPreference.getSummary()).isEqualTo("Restricted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -112,8 +112,8 @@ public class BatteryTipDialogFragmentTest {
|
|||||||
final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
|
final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
|
||||||
ShadowAlertDialog shadowDialog = shadowOf(dialog);
|
ShadowAlertDialog shadowDialog = shadowOf(dialog);
|
||||||
|
|
||||||
assertThat(shadowDialog.getMessage())
|
assertThat(shadowDialog.getMessage()).isEqualTo(
|
||||||
.isEqualTo(mContext.getString(R.string.battery_tip_dialog_message, 1));
|
mContext.getString(R.string.battery_tip_dialog_message, 1, "60 minutes ago"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -43,6 +43,7 @@ public class HighUsageTipTest {
|
|||||||
|
|
||||||
private static final String PACKAGE_NAME = "com.android.app";
|
private static final String PACKAGE_NAME = "com.android.app";
|
||||||
private static final long SCREEN_TIME = 30 * DateUtils.MINUTE_IN_MILLIS;
|
private static final long SCREEN_TIME = 30 * DateUtils.MINUTE_IN_MILLIS;
|
||||||
|
private static final long LAST_FULL_CHARGE_TIME = 20 * DateUtils.MINUTE_IN_MILLIS;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
@@ -60,7 +61,7 @@ public class HighUsageTipTest {
|
|||||||
.setPackageName(PACKAGE_NAME)
|
.setPackageName(PACKAGE_NAME)
|
||||||
.setScreenOnTimeMs(SCREEN_TIME)
|
.setScreenOnTimeMs(SCREEN_TIME)
|
||||||
.build());
|
.build());
|
||||||
mBatteryTip = new HighUsageTip(SCREEN_TIME, mUsageAppList);
|
mBatteryTip = new HighUsageTip(LAST_FULL_CHARGE_TIME, mUsageAppList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -75,7 +76,7 @@ public class HighUsageTipTest {
|
|||||||
assertThat(parcelTip.getTitle(mContext)).isEqualTo("Phone used more than usual");
|
assertThat(parcelTip.getTitle(mContext)).isEqualTo("Phone used more than usual");
|
||||||
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.HIGH_DEVICE_USAGE);
|
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.HIGH_DEVICE_USAGE);
|
||||||
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
||||||
assertThat(parcelTip.getScreenTimeMs()).isEqualTo(SCREEN_TIME);
|
assertThat(parcelTip.getLastFullChargeTimeMs()).isEqualTo(LAST_FULL_CHARGE_TIME);
|
||||||
assertThat(parcelTip.mHighUsageAppList).isNotNull();
|
assertThat(parcelTip.mHighUsageAppList).isNotNull();
|
||||||
assertThat(parcelTip.mHighUsageAppList.size()).isEqualTo(1);
|
assertThat(parcelTip.mHighUsageAppList.size()).isEqualTo(1);
|
||||||
final AppInfo app = parcelTip.mHighUsageAppList.get(0);
|
final AppInfo app = parcelTip.mHighUsageAppList.get(0);
|
||||||
|
Reference in New Issue
Block a user