Snap for 8207804 from 24abb535ed to tm-release

Change-Id: I3b34786b72d270313dc3ae11787fe24686dc9202
This commit is contained in:
Android Build Coastguard Worker
2022-02-22 02:08:43 +00:00
9 changed files with 96 additions and 47 deletions

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="178dp"
android:height="150dp"
android:viewportWidth="178"
android:viewportHeight="150">
<path
android:pathData="M161.612,147.208L16.619,147.208A13,13 0,0 1,3.619 134.208L3.619,-442.725A13,13 0,0 1,16.619 -455.725L161.612,-455.725A13,13 0,0 1,174.612 -442.725L174.612,134.208A13,13 0,0 1,161.612 147.208z"
android:strokeWidth="6"
android:fillColor="#ffffff"
android:strokeColor="#EDEDED"/>
<path
android:pathData="M28.47,103.945L48.47,103.945A12,12 0,0 1,60.47 115.945L60.47,115.945A12,12 0,0 1,48.47 127.945L28.47,127.945A12,12 0,0 1,16.47 115.945L16.47,115.945A12,12 0,0 1,28.47 103.945z"
android:fillColor="#797272"/>
<path
android:pathData="M38.5,115.5m-15.5,0a15.5,15.5 0,1 1,31 0a15.5,15.5 0,1 1,-31 0"
android:fillColor="#BCEDDF"
android:fillAlpha="0.5"/>
<path
android:pathData="M45.279,108.52L46.48,109.72C47.182,110.414 47.182,111.543 46.48,112.237L34.717,124H31V120.283L42.763,108.52C43.457,107.827 44.586,107.827 45.279,108.52ZM32.778,122.222L34.032,122.275L42.763,113.535L41.51,112.281L32.778,121.013V122.222Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M79,104L99,104A12,12 0,0 1,111 116L111,116A12,12 0,0 1,99 128L79,128A12,12 0,0 1,67 116L67,116A12,12 0,0 1,79 104z"
android:fillColor="#E0DCDC"/>
<path
android:pathData="M79,104L99,104A12,12 0,0 1,111 116L111,116A12,12 0,0 1,99 128L79,128A12,12 0,0 1,67 116L67,116A12,12 0,0 1,79 104z"
android:fillColor="#E7E7E7"/>
<path
android:pathData="M129,104L149,104A12,12 0,0 1,161 116L161,116A12,12 0,0 1,149 128L129,128A12,12 0,0 1,117 116L117,116A12,12 0,0 1,129 104z"
android:fillColor="#E0DCDC"/>
<path
android:pathData="M129,104L149,104A12,12 0,0 1,161 116L161,116A12,12 0,0 1,149 128L129,128A12,12 0,0 1,117 116L117,116A12,12 0,0 1,129 104z"
android:fillColor="#E7E7E7"/>
<path
android:pathData="M22,14L76.49,14A6,6 0,0 1,82.49 20L82.49,38.782A6,6 0,0 1,76.49 44.782L22,44.782A6,6 0,0 1,16 38.782L16,20A6,6 0,0 1,22 14z"
android:fillColor="#EDEDED"/>
<path
android:pathData="M22,56L76.49,56A6,6 0,0 1,82.49 62L82.49,80.782A6,6 0,0 1,76.49 86.782L22,86.782A6,6 0,0 1,16 80.782L16,62A6,6 0,0 1,22 56z"
android:fillColor="#EDEDED"/>
<path
android:pathData="M101,14L155.49,14A6,6 0,0 1,161.49 20L161.49,38.782A6,6 0,0 1,155.49 44.782L101,44.782A6,6 0,0 1,95 38.782L95,20A6,6 0,0 1,101 14z"
android:fillColor="#EDEDED"/>
<path
android:pathData="M101,56L155.49,56A6,6 0,0 1,161.49 62L161.49,80.782A6,6 0,0 1,155.49 86.782L101,86.782A6,6 0,0 1,95 80.782L95,62A6,6 0,0 1,101 56z"
android:fillColor="#EDEDED"/>
</vector>

View File

@@ -509,7 +509,9 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
? R.string.accessibility_service_qs_tooltips_content ? R.string.accessibility_service_qs_tooltips_content
: R.string.accessibility_service_auto_added_qs_tooltips_content; : R.string.accessibility_service_auto_added_qs_tooltips_content;
final String title = getString(titleResId, tileName); final String title = getString(titleResId, tileName);
final int imageResId = R.drawable.accessibility_qs_tooltips_illustration; final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
? R.drawable.accessibility_qs_tooltips_illustration
: R.drawable.accessibility_auto_added_qs_tooltips_illustration;
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext()); mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
mTooltipWindow.setup(title, imageResId); mTooltipWindow.setup(title, imageResId);
mTooltipWindow.showAtTopCenter(getView()); mTooltipWindow.showAtTopCenter(getView());

View File

@@ -79,6 +79,7 @@ import java.util.Locale;
public abstract class ToggleFeaturePreferenceFragment extends SettingsPreferenceFragment public abstract class ToggleFeaturePreferenceFragment extends SettingsPreferenceFragment
implements ShortcutPreference.OnClickCallback, OnMainSwitchChangeListener { implements ShortcutPreference.OnClickCallback, OnMainSwitchChangeListener {
protected TopIntroPreference mTopIntroPreference;
protected SettingsMainSwitchPreference mToggleServiceSwitchPreference; protected SettingsMainSwitchPreference mToggleServiceSwitchPreference;
protected ShortcutPreference mShortcutPreference; protected ShortcutPreference mShortcutPreference;
protected Preference mSettingsPreference; protected Preference mSettingsPreference;
@@ -483,10 +484,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
if (TextUtils.isEmpty(mTopIntroTitle)) { if (TextUtils.isEmpty(mTopIntroTitle)) {
return; return;
} }
final TopIntroPreference topIntroPreference = new TopIntroPreference(getPrefContext()); mTopIntroPreference = new TopIntroPreference(getPrefContext());
topIntroPreference.setKey(KEY_TOP_INTRO_PREFERENCE); mTopIntroPreference.setKey(KEY_TOP_INTRO_PREFERENCE);
topIntroPreference.setTitle(mTopIntroTitle); mTopIntroPreference.setTitle(mTopIntroTitle);
getPreferenceScreen().addPreference(topIntroPreference); getPreferenceScreen().addPreference(mTopIntroPreference);
} }
private void initToggleServiceSwitchPreference() { private void initToggleServiceSwitchPreference() {
@@ -879,7 +880,9 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
? R.string.accessibility_service_qs_tooltips_content ? R.string.accessibility_service_qs_tooltips_content
: R.string.accessibility_service_auto_added_qs_tooltips_content; : R.string.accessibility_service_auto_added_qs_tooltips_content;
final String title = getString(titleResId, tileName); final String title = getString(titleResId, tileName);
final int imageResId = R.drawable.accessibility_qs_tooltips_illustration; final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
? R.drawable.accessibility_qs_tooltips_illustration
: R.drawable.accessibility_auto_added_qs_tooltips_illustration;
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext()); mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
mTooltipWindow.setup(title, imageResId); mTooltipWindow.setup(title, imageResId);
mTooltipWindow.showAtTopCenter(getView()); mTooltipWindow.showAtTopCenter(getView());

View File

@@ -40,7 +40,7 @@ public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
final String title = getContext().getString( final String title = getContext().getString(
R.string.accessibility_screen_magnification_title); R.string.accessibility_screen_magnification_title);
final String description = getContext().getString( final String description = getContext().getString(
R.string.accessibility_preference_magnification_summary); R.string.accessibility_screen_magnification_intro_text);
final Drawable icon = getContext().getDrawable(R.drawable.ic_accessibility_visibility); final Drawable icon = getContext().getDrawable(R.drawable.ic_accessibility_visibility);
AccessibilitySetupWizardUtils.updateGlifPreferenceLayout(getContext(), layout, title, AccessibilitySetupWizardUtils.updateGlifPreferenceLayout(getContext(), layout, title,
description, icon); description, icon);
@@ -51,6 +51,8 @@ public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
* Hide the magnification preference settings in the SuW's vision settings. * Hide the magnification preference settings in the SuW's vision settings.
*/ */
private void hidePreferenceSettingComponents() { private void hidePreferenceSettingComponents() {
// Intro
mTopIntroPreference.setVisible(false);
// Setting of magnification type // Setting of magnification type
mSettingsPreference.setVisible(false); mSettingsPreference.setVisible(false);
// Setting of following typing // Setting of following typing

View File

@@ -46,6 +46,9 @@ public class ToggleScreenReaderPreferenceFragmentForSetupWizard
description, icon); description, icon);
mToggleSwitchWasInitiallyChecked = mToggleServiceSwitchPreference.isChecked(); mToggleSwitchWasInitiallyChecked = mToggleServiceSwitchPreference.isChecked();
if (mTopIntroPreference != null) {
mTopIntroPreference.setVisible(false);
}
} }
@Override @Override

View File

@@ -46,6 +46,9 @@ public class ToggleSelectToSpeakPreferenceFragmentForSetupWizard
description, icon); description, icon);
mToggleSwitchWasInitiallyChecked = mToggleServiceSwitchPreference.isChecked(); mToggleSwitchWasInitiallyChecked = mToggleServiceSwitchPreference.isChecked();
if (mTopIntroPreference != null) {
mTopIntroPreference.setVisible(false);
}
} }
@Override @Override

View File

@@ -112,7 +112,8 @@ public class BatteryBroadcastReceiver extends BroadcastReceiver {
if (intent != null && mBatteryListener != null) { if (intent != null && mBatteryListener != null) {
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
final String batteryLevel = Utils.getBatteryPercentage(intent); final String batteryLevel = Utils.getBatteryPercentage(intent);
final String batteryStatus = Utils.getBatteryStatus(mContext, intent); final String batteryStatus =
Utils.getBatteryStatus(mContext, intent, /* compactStatus= */ false);
final int batteryHealth = intent.getIntExtra( final int batteryHealth = intent.getIntExtra(
BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_UNKNOWN); BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_UNKNOWN);
if (!Utils.isBatteryPresent(intent)) { if (!Utils.isBatteryPresent(intent)) {

View File

@@ -37,7 +37,6 @@ import com.android.settings.Utils;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.UsageView; import com.android.settings.widget.UsageView;
import com.android.settingslib.R; import com.android.settingslib.R;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.settingslib.fuelgauge.Estimate; import com.android.settingslib.fuelgauge.Estimate;
import com.android.settingslib.fuelgauge.EstimateKt; import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.utils.PowerUtil; import com.android.settingslib.utils.PowerUtil;
@@ -244,6 +243,8 @@ public class BatteryInfo {
@NonNull BatteryUsageStats batteryUsageStats, Estimate estimate, @NonNull BatteryUsageStats batteryUsageStats, Estimate estimate,
long elapsedRealtimeUs, boolean shortString) { long elapsedRealtimeUs, boolean shortString) {
final long startTime = System.currentTimeMillis(); final long startTime = System.currentTimeMillis();
final boolean isCompactStatus = context.getResources().getBoolean(
com.android.settings.R.bool.config_use_compact_battery_status);
BatteryInfo info = new BatteryInfo(); BatteryInfo info = new BatteryInfo();
info.mBatteryUsageStats = batteryUsageStats; info.mBatteryUsageStats = batteryUsageStats;
info.batteryLevel = Utils.getBatteryLevel(batteryBroadcast); info.batteryLevel = Utils.getBatteryLevel(batteryBroadcast);
@@ -254,21 +255,21 @@ public class BatteryInfo {
BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_UNKNOWN) BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_UNKNOWN)
== BatteryManager.BATTERY_HEALTH_OVERHEAT; == BatteryManager.BATTERY_HEALTH_OVERHEAT;
info.statusLabel = getBatteryStatus(context, batteryBroadcast); info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast, isCompactStatus);
info.batteryStatus = batteryBroadcast.getIntExtra( info.batteryStatus = batteryBroadcast.getIntExtra(
BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN); BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN);
if (!info.mCharging) { if (!info.mCharging) {
updateBatteryInfoDischarging(context, shortString, estimate, info); updateBatteryInfoDischarging(context, shortString, estimate, info);
} else { } else {
updateBatteryInfoCharging(context, batteryBroadcast, batteryUsageStats, updateBatteryInfoCharging(context, batteryBroadcast, batteryUsageStats,
info); info, isCompactStatus);
} }
BatteryUtils.logRuntime(LOG_TAG, "time for getBatteryInfo", startTime); BatteryUtils.logRuntime(LOG_TAG, "time for getBatteryInfo", startTime);
return info; return info;
} }
private static void updateBatteryInfoCharging(Context context, Intent batteryBroadcast, private static void updateBatteryInfoCharging(Context context, Intent batteryBroadcast,
BatteryUsageStats stats, BatteryInfo info) { BatteryUsageStats stats, BatteryInfo info, boolean compactStatus) {
final Resources resources = context.getResources(); final Resources resources = context.getResources();
final long chargeTimeMs = stats.getChargeTimeRemainingMs(); final long chargeTimeMs = stats.getChargeTimeRemainingMs();
final int status = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS, final int status = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS,
@@ -292,7 +293,8 @@ public class BatteryInfo {
R.string.power_remaining_charging_duration_only, timeString); R.string.power_remaining_charging_duration_only, timeString);
info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString); info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
} else { } else {
final String chargeStatusLabel = getBatteryStatus(context, batteryBroadcast); final String chargeStatusLabel =
Utils.getBatteryStatus(context, batteryBroadcast, compactStatus);
info.remainingLabel = null; info.remainingLabel = null;
info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString : info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
resources.getString(R.string.power_charging, info.batteryPercentString, resources.getString(R.string.power_charging, info.batteryPercentString,
@@ -326,35 +328,6 @@ public class BatteryInfo {
} }
} }
private static String getBatteryStatus(Context context, Intent batteryChangedIntent) {
final Resources res = context.getResources();
final boolean isShortStatus =
res.getBoolean(com.android.settings.R.bool.config_use_compact_battery_status);
if (!isShortStatus) {
return Utils.getBatteryStatus(context, batteryChangedIntent);
}
final int status = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_STATUS,
BatteryManager.BATTERY_STATUS_UNKNOWN);
final BatteryStatus batteryStatus = new BatteryStatus(batteryChangedIntent);
String statusString = res.getString(R.string.battery_info_status_unknown);
if (batteryStatus.isCharged()) {
statusString = res.getString(R.string.battery_info_status_full);
} else {
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
statusString = res.getString(R.string.battery_info_status_charging);
} else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) {
statusString = res.getString(R.string.battery_info_status_discharging);
} else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
statusString = res.getString(R.string.battery_info_status_not_charging);
}
}
return statusString;
}
public interface BatteryDataParser { public interface BatteryDataParser {
void onParsingStarted(long startTime, long endTime); void onParsingStarted(long startTime, long endTime);

View File

@@ -85,8 +85,8 @@ public class BatteryBroadcastReceiverTest {
assertThat(mBatteryBroadcastReceiver.mBatteryLevel) assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
.isEqualTo(Utils.getBatteryPercentage(mChargingIntent)); .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
assertThat(mBatteryBroadcastReceiver.mBatteryStatus) assertThat(mBatteryBroadcastReceiver.mBatteryStatus).isEqualTo(
.isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent)); Utils.getBatteryStatus(mContext, mChargingIntent, /* compactStatus= */ false));
verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL); verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL);
} }
@@ -134,7 +134,7 @@ public class BatteryBroadcastReceiverTest {
public void testOnReceive_batteryDataNotChanged_listenerNotInvoked() { public void testOnReceive_batteryDataNotChanged_listenerNotInvoked() {
final String batteryLevel = Utils.getBatteryPercentage(mChargingIntent); final String batteryLevel = Utils.getBatteryPercentage(mChargingIntent);
final String batteryStatus = final String batteryStatus =
Utils.getBatteryStatus(mContext, mChargingIntent); Utils.getBatteryStatus(mContext, mChargingIntent, /* compactStatus= */ false);
mBatteryBroadcastReceiver.mBatteryLevel = batteryLevel; mBatteryBroadcastReceiver.mBatteryLevel = batteryLevel;
mBatteryBroadcastReceiver.mBatteryStatus = batteryStatus; mBatteryBroadcastReceiver.mBatteryStatus = batteryStatus;
@@ -159,8 +159,8 @@ public class BatteryBroadcastReceiverTest {
assertThat(mBatteryBroadcastReceiver.mBatteryLevel) assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
.isEqualTo(Utils.getBatteryPercentage(mChargingIntent)); .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
assertThat(mBatteryBroadcastReceiver.mBatteryStatus) assertThat(mBatteryBroadcastReceiver.mBatteryStatus).isEqualTo(
.isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent)); Utils.getBatteryStatus(mContext, mChargingIntent, /* compactStatus= */ false));
assertThat(mBatteryBroadcastReceiver.mBatteryHealth) assertThat(mBatteryBroadcastReceiver.mBatteryHealth)
.isEqualTo(BatteryManager.BATTERY_HEALTH_UNKNOWN); .isEqualTo(BatteryManager.BATTERY_HEALTH_UNKNOWN);
// 2 times because register will force update the battery // 2 times because register will force update the battery