Snap for 9414670 from 3aca71cfc2 to tm-qpr2-release

Change-Id: Ic62396633e0305160213fa45cd55b1610151fc68
This commit is contained in:
Android Build Coastguard Worker
2022-12-17 02:25:44 +00:00
7 changed files with 25 additions and 58 deletions

View File

@@ -6410,21 +6410,21 @@
<!-- Summary for the battery high usage tip, which presents apps with highest usage [CHAR LIMIT=NONE] -->
<string name="battery_tip_high_usage_summary">See apps with highest usage</string>
<!-- Title for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_limited_temporarily_title">Charging is paused</string>
<string name="battery_tip_limited_temporarily_title">Charging optimized to protect your battery</string>
<!-- Summary for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_limited_temporarily_summary">Protecting battery to extend battery lifespan</string>
<string name="battery_tip_limited_temporarily_summary">To help extend your batter\'s lifespan, charging is optimized</string>
<!-- Title for the battery dock defender future bypass tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_dock_defender_future_bypass_title">Charging to <xliff:g id="percent" example="10%">%1$s</xliff:g> to protect the battery</string>
<string name="battery_tip_dock_defender_future_bypass_title">Charging optimized to protect your battery</string>
<!-- Summary for the battery dock defender future bypass tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_dock_defender_future_bypass_summary">When your tablet is docked, charging will be paused at <xliff:g id="percent" example="10%">%1$s</xliff:g> to extend battery lifespan</string>
<string name="battery_tip_dock_defender_future_bypass_summary">To help extend your battery\'s lifespan, charging is optimized while docked</string>
<!-- Title for the battery dock defender active tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_dock_defender_active_title">Charging paused to protect battery</string>
<string name="battery_tip_dock_defender_active_title">Charging optimized to protect your battery</string>
<!-- Summary for the battery dock defender active tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_dock_defender_active_summary">When your tablet is docked, charging is paused at <xliff:g id="percent" example="10%">%1$s</xliff:g> to extend battery lifespan</string>
<string name="battery_tip_dock_defender_active_summary">To help extend your battery\'s lifespan, charging is optimized while docked</string>
<!-- Title for the battery dock defender temporarily bypassed tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_dock_defender_temporarily_bypassed_title">Charging to full</string>
<!-- Summary for the battery dock defender temporarily bypassed tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_dock_defender_temporarily_bypassed_summary">To protect your battery, charging will be paused at <xliff:g id="percent" example="10%">%1$s</xliff:g> the next time your tablet is docked</string>
<string name="battery_tip_dock_defender_temporarily_bypassed_summary">To protect your battery, charging will be optimized the next time your tablet is docked</string>
<!-- Content description for the battery limited temporarily tip secondary button [CHAR LIMIT=NONE] -->
<string name="battery_tip_limited_temporarily_sec_button_content_description">Learn more about charging is paused</string>
<!-- Text of battery limited temporarily tip resume charge button. [CHAR LIMIT=NONE] -->
@@ -8141,6 +8141,8 @@
<string name="help_url_battery" translatable="false"></string>
<!-- Help URL, Battery Defender [DO NOT TRANSLATE] -->
<string name="help_url_battery_defender" translatable="false"></string>
<!-- Help URL, Dock Defender [DO NOT TRANSLATE] -->
<string name="help_url_dock_defender" translatable="false"></string>
<!-- Help URL, Accounts [DO NOT TRANSLATE] -->
<string name="help_url_accounts" translatable="false"></string>
<!-- Help URL, Choose lockscreen [DO NOT TRANSLATE] -->

View File

@@ -301,7 +301,6 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
notifyBackupManager();
logMetricCategory(selectedPreference);
mBatteryOptimizeUtils.setAppUsageState(selectedPreference);
Log.d(TAG, "Leave with mode: " + selectedPreference);
}
}
@@ -468,6 +467,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
updatePreferenceState(mUnrestrictedPreference, selectedKey);
updatePreferenceState(mOptimizePreference, selectedKey);
updatePreferenceState(mRestrictedPreference, selectedKey);
mBatteryOptimizeUtils.setAppUsageState(getSelectedPreference());
}
private void updatePreferenceState(SelectorWithWidgetPreference preference,

View File

@@ -42,8 +42,6 @@ import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.utils.PowerUtil;
import com.android.settingslib.utils.StringUtil;
import java.text.NumberFormat;
public class BatteryInfo {
private static final String TAG = "BatteryInfo";
@@ -305,13 +303,9 @@ public class BatteryInfo {
timeString);
info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
} else if (dockDefenderMode == BatteryUtils.DockDefenderMode.FUTURE_BYPASS) {
// Dock defender will be triggered in the future, charging will be paused at 90%.
final int extraValue = context.getResources().getInteger(
R.integer.config_battery_extra_tip_value);
final String extraPercentage = NumberFormat.getPercentInstance().format(
extraValue * 0.01f);
// Dock defender will be triggered in the future, charging will be optimized.
info.chargeLabel = context.getString(R.string.power_charging_future_paused,
info.batteryPercentString, extraPercentage);
info.batteryPercentString);
} else {
final String chargeStatusLabel = Utils.getBatteryStatus(context, batteryBroadcast,
compactStatus);

View File

@@ -24,7 +24,6 @@ import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.pm.UserInfo;
import android.os.AsyncTask;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArraySet;
@@ -222,10 +221,8 @@ public class BatteryOptimizeUtils {
mode == MODE_RESTRICTED ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED;
final boolean allowListed = mode == MODE_UNRESTRICTED;
AsyncTask.execute(() -> {
setAppOptimizationModeInternal(appOpsManagerMode, allowListed, uid, packageName,
setAppOptimizationModeInternal(appOpsManagerMode, allowListed, uid, packageName,
batteryUtils, powerAllowlistBackend);
});
}
private static void setAppOptimizationModeInternal(

View File

@@ -32,8 +32,6 @@ import com.android.settings.widget.CardPreference;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import java.text.NumberFormat;
/**
* Tip to show dock defender status
*/
@@ -58,8 +56,7 @@ public class DockDefenderTip extends BatteryTip {
public CharSequence getTitle(Context context) {
switch (mMode) {
case DockDefenderMode.FUTURE_BYPASS:
return context.getString(R.string.battery_tip_dock_defender_future_bypass_title,
getExtraPercentage(context));
return context.getString(R.string.battery_tip_dock_defender_future_bypass_title);
case DockDefenderMode.ACTIVE:
return context.getString(R.string.battery_tip_dock_defender_active_title);
case DockDefenderMode.TEMPORARILY_BYPASSED:
@@ -74,15 +71,12 @@ public class DockDefenderTip extends BatteryTip {
public CharSequence getSummary(Context context) {
switch (mMode) {
case DockDefenderMode.FUTURE_BYPASS:
return context.getString(R.string.battery_tip_dock_defender_future_bypass_summary,
getExtraPercentage(context));
return context.getString(R.string.battery_tip_dock_defender_future_bypass_summary);
case DockDefenderMode.ACTIVE:
return context.getString(R.string.battery_tip_dock_defender_active_summary,
getExtraPercentage(context));
return context.getString(R.string.battery_tip_dock_defender_active_summary);
case DockDefenderMode.TEMPORARILY_BYPASSED:
return context.getString(
R.string.battery_tip_dock_defender_temporarily_bypassed_summary,
getExtraPercentage(context));
R.string.battery_tip_dock_defender_temporarily_bypassed_summary);
default:
return null;
}
@@ -145,12 +139,11 @@ public class DockDefenderTip extends BatteryTip {
}
cardPreference.setSecondaryButtonText(context.getString(R.string.learn_more));
//TODO: update helper string
cardPreference.setSecondaryButtonClickListener(
button -> button.startActivityForResult(
HelpUtils.getHelpIntent(
context,
context.getString(R.string.help_url_battery_defender),
context.getString(R.string.help_url_dock_defender),
/* backupContext */ ""), /* requestCode */ 0));
cardPreference.setSecondaryButtonVisible(true);
cardPreference.setSecondaryButtonContentDescription(context.getString(
@@ -174,13 +167,6 @@ public class DockDefenderTip extends BatteryTip {
Log.i(TAG, "send resume charging broadcast intent=" + intent);
}
private String getExtraPercentage(Context context) {
final int extraValue = context.getResources()
.getInteger(R.integer.config_battery_extra_tip_value);
return NumberFormat.getPercentInstance()
.format(extraValue * 0.01f);
}
public static final Creator CREATOR = new Creator() {
public BatteryTip createFromParcel(Parcel in) {
return new DockDefenderTip(in);

View File

@@ -67,8 +67,8 @@ public class BatteryInfoTest {
private static final String STATUS_CHARGING_NO_TIME = "50% - charging";
private static final String STATUS_CHARGING_TIME = "50% - 0 min left until full";
private static final String STATUS_NOT_CHARGING = "Not charging";
private static final String STATUS_CHARGING_FUTURE_BYPASS = "50% - Charging to 12%";
private static final String STATUS_CHARGING_PAUSED = "50% - Charging paused";
private static final String STATUS_CHARGING_FUTURE_BYPASS = "50% - Charging optimized";
private static final String STATUS_CHARGING_PAUSED = "50% - Charging optimized";
private static final long REMAINING_TIME_NULL = -1;
private static final long REMAINING_TIME = 2;
// Strings are defined in frameworks/base/packages/SettingsLib/res/values/strings.xml

View File

@@ -44,8 +44,6 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowLog;
import java.text.NumberFormat;
@RunWith(RobolectricTestRunner.class)
public class DockDefenderTipTest {
private Context mContext;
@@ -85,8 +83,7 @@ public class DockDefenderTipTest {
@Test
public void testGetTitle() {
assertThat(mDockDefenderTipFutureBypass.getTitle(mContext).toString()).isEqualTo(
mContext.getString(R.string.battery_tip_dock_defender_future_bypass_title,
getExtraPercentage(mContext)));
mContext.getString(R.string.battery_tip_dock_defender_future_bypass_title));
assertThat(mDockDefenderTipActive.getTitle(mContext).toString()).isEqualTo(
mContext.getString(R.string.battery_tip_dock_defender_active_title));
assertThat(mDockDefenderTipTemporarilyBypassed.getTitle(mContext).toString()).isEqualTo(
@@ -97,14 +94,12 @@ public class DockDefenderTipTest {
@Test
public void testGetSummary() {
assertThat(mDockDefenderTipFutureBypass.getSummary(mContext).toString()).isEqualTo(
mContext.getString(R.string.battery_tip_dock_defender_future_bypass_summary,
getExtraPercentage(mContext)));
mContext.getString(R.string.battery_tip_dock_defender_future_bypass_summary));
assertThat(mDockDefenderTipActive.getSummary(mContext).toString()).isEqualTo(
mContext.getString(R.string.battery_tip_dock_defender_active_summary,
getExtraPercentage(mContext)));
mContext.getString(R.string.battery_tip_dock_defender_active_summary));
assertThat(mDockDefenderTipTemporarilyBypassed.getSummary(mContext).toString()).isEqualTo(
mContext.getString(R.string.battery_tip_dock_defender_temporarily_bypassed_summary,
getExtraPercentage(mContext)));
mContext.getString(
R.string.battery_tip_dock_defender_temporarily_bypassed_summary));
assertThat(mDockDefenderTipDisabled.getSummary(mContext)).isNull();
}
@@ -195,11 +190,4 @@ public class DockDefenderTipTest {
private ShadowLog.LogItem createErrorLog(String msg) {
return new ShadowLog.LogItem(Log.ERROR, "tag", msg, null);
}
private String getExtraPercentage(Context context) {
final int extraValue = context.getResources().getInteger(
R.integer.config_battery_extra_tip_value);
return NumberFormat.getPercentInstance().format(extraValue * 0.01f);
}
}