Snap for 10354447 from de5c8613ba to udc-qpr1-release

Change-Id: Ic4efe74692d476b3c12438779714891fe840726e
This commit is contained in:
Android Build Coastguard Worker
2023-06-21 03:19:33 +00:00
20 changed files with 162 additions and 78 deletions

View File

@@ -692,6 +692,12 @@
<!-- Description for interrupting the voice call alert. [CHAR_LIMIT=NONE] --> <!-- Description for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
<string name="reset_internet_text" product="tablet">This will end your phone call</string> <string name="reset_internet_text" product="tablet">This will end your phone call</string>
<!-- Help URI, battery saver page [DO NOT TRANSLATE] -->
<string name="help_url_battery_saver_settings" translatable="false" product="default"></string>
<!-- Help URI, app usage page [DO NOT TRANSLATE] -->
<string name="help_url_app_usage_settings" translatable="false" product="default"></string>
<!-- An explanation text that the pattern needs to be solved because the device was factory reset. [CHAR LIMIT=100] --> <!-- An explanation text that the pattern needs to be solved because the device was factory reset. [CHAR LIMIT=100] -->
<string name="lockpassword_confirm_your_pattern_details_frp" product="default">Your phone was reset to factory settings. To use this phone, enter your previous pattern.</string> <string name="lockpassword_confirm_your_pattern_details_frp" product="default">Your phone was reset to factory settings. To use this phone, enter your previous pattern.</string>
<!-- An explanation text that the pattern needs to be solved because the device was factory reset. [CHAR LIMIT=100] --> <!-- An explanation text that the pattern needs to be solved because the device was factory reset. [CHAR LIMIT=100] -->

View File

@@ -15,10 +15,11 @@
limitations under the License. limitations under the License.
--> -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle"> android:shape="rectangle">
<solid
android:color="?attr/notification_importance_button_background_color_selected"/>
<stroke <stroke
android:width="1dp" android:width="1dp"
android:color="?androidprv:attr/materialColorOutlineVariant"/> android:color="?attr/notification_importance_button_border_color_selected"/>
<corners android:radius="@dimen/rect_button_radius" /> <corners android:radius="@dimen/rect_button_radius" />
</shape> </shape>

View File

@@ -15,12 +15,11 @@
limitations under the License. limitations under the License.
--> -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle"> android:shape="rectangle">
<solid <solid
android:color="?androidprv:attr/materialColorSecondaryContainer" /> android:color="?attr/notification_importance_button_background_color_unselected"/>
<stroke <stroke
android:width="1dp" android:width="1dp"
android:color="?androidprv:attr/materialColorOnSecondaryContainer"/> android:color="?attr/notification_importance_button_border_color_unselected"/>
<corners android:radius="@dimen/rect_button_radius" /> <corners android:radius="@dimen/rect_button_radius" />
</shape> </shape>

View File

@@ -34,6 +34,16 @@
<item name="android:colorBackground">@*android:color/surface_dark</item> <item name="android:colorBackground">@*android:color/surface_dark</item>
</style> </style>
<style name="Theme.Panel.Material" parent="Theme.Panel" >
<item name="notification_importance_button_background_color_unselected">@android:color/transparent</item>
<item name="notification_importance_button_border_color_unselected">@android:color/system_outline_variant_dark</item>
<item name="notification_importance_button_foreground_color_unselected">@android:color/system_on_surface_variant_dark</item>
<item name="notification_importance_button_background_color_selected">@android:color/system_secondary_container_dark</item>
<item name="notification_importance_button_border_color_selected">@android:color/system_on_secondary_container_dark</item>
<item name="notification_importance_button_foreground_color_selected">@android:color/system_on_secondary_container_dark</item>
</style>
<!-- Material theme for the pages containing TabLayout and ViewPager --> <!-- Material theme for the pages containing TabLayout and ViewPager -->
<style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight"> <style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight">
<item name="colorPrimary">@*android:color/edge_effect_device_default_dark</item> <item name="colorPrimary">@*android:color/edge_effect_device_default_dark</item>

View File

@@ -194,4 +194,12 @@
<attr name="biometricsEnrollProgressHelp" format="reference|color" /> <attr name="biometricsEnrollProgressHelp" format="reference|color" />
<attr name="biometricsEnrollProgressHelpWithTalkback" format="reference|color" /> <attr name="biometricsEnrollProgressHelpWithTalkback" format="reference|color" />
</declare-styleable> </declare-styleable>
<attr name="notification_importance_button_background_color_unselected" format="color" />
<attr name="notification_importance_button_border_color_unselected" format="color" />
<attr name="notification_importance_button_foreground_color_unselected" format="color" />
<attr name="notification_importance_button_background_color_selected" format="color" />
<attr name="notification_importance_button_border_color_selected" format="color" />
<attr name="notification_importance_button_foreground_color_selected" format="color" />
</resources> </resources>

View File

@@ -10447,15 +10447,9 @@
<!-- Help URI, restricted apps page [DO NOT TRANSLATE] --> <!-- Help URI, restricted apps page [DO NOT TRANSLATE] -->
<string name="help_uri_restricted_apps" translatable="false"></string> <string name="help_uri_restricted_apps" translatable="false"></string>
<!-- Help URI, battery saver page [DO NOT TRANSLATE] -->
<string name="help_url_battery_saver_settings" translatable="false"></string>
<!-- Help URI, auto rotate page [DO NOT TRANSLATE] --> <!-- Help URI, auto rotate page [DO NOT TRANSLATE] -->
<string name="help_url_auto_rotate_settings" translatable="false"></string> <string name="help_url_auto_rotate_settings" translatable="false"></string>
<!-- Help URI, app usage page [DO NOT TRANSLATE] -->
<string name="help_url_app_usage_settings" translatable="false"></string>
<!-- Help URI, smart battery page [DO NOT TRANSLATE] --> <!-- Help URI, smart battery page [DO NOT TRANSLATE] -->
<string name="help_uri_smart_battery_settings" translatable="false"></string> <string name="help_uri_smart_battery_settings" translatable="false"></string>

View File

@@ -14,7 +14,8 @@
limitations under the License. limitations under the License.
--> -->
<resources> <resources
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<style name="Transparent"> <style name="Transparent">
<item name="alertDialogTheme">@style/Theme.AlertDialog</item> <item name="alertDialogTheme">@style/Theme.AlertDialog</item>
@@ -66,6 +67,14 @@
<!-- For slice view in settings --> <!-- For slice view in settings -->
<item name="sliceViewStyle">@style/Widget.SliceView.Settings</item> <item name="sliceViewStyle">@style/Widget.SliceView.Settings</item>
<item name="notification_importance_button_background_color_unselected">@android:color/transparent</item>
<item name="notification_importance_button_border_color_unselected">?androidprv:attr/materialColorOutlineVariant</item>
<item name="notification_importance_button_foreground_color_unselected">?androidprv:attr/materialColorOnSurfaceVariant</item>
<item name="notification_importance_button_background_color_selected">?androidprv:attr/materialColorSecondaryContainer</item>
<item name="notification_importance_button_border_color_selected">?androidprv:attr/materialColorOnSecondaryContainer</item>
<item name="notification_importance_button_foreground_color_selected">?androidprv:attr/materialColorOnSecondaryContainer</item>
</style> </style>
<!-- Variant of the settings theme with no action bar. --> <!-- Variant of the settings theme with no action bar. -->
@@ -229,9 +238,18 @@
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item> <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
</style> </style>
<style name="Theme.Panel.Material" parent="Theme.Panel" > <style name="Theme.Panel.Material" parent="Theme.Panel">
<item name="android:switchStyle">@style/Switch.SettingsLib</item> <item name="android:switchStyle">@style/Switch.SettingsLib</item>
<item name="notification_importance_button_background_color_unselected">@android:color/transparent</item>
<item name="notification_importance_button_border_color_unselected">@android:color/system_outline_variant_light</item>
<item name="notification_importance_button_foreground_color_unselected">@android:color/system_on_surface_variant_light</item>
<item name="notification_importance_button_background_color_selected">@android:color/system_secondary_container_light</item>
<item name="notification_importance_button_border_color_selected">@android:color/system_on_secondary_container_light</item>
<item name="notification_importance_button_foreground_color_selected">@android:color/system_on_secondary_container_light</item>
</style> </style>
<!-- Material theme for the pages containing TabLayout and ViewPager --> <!-- Material theme for the pages containing TabLayout and ViewPager -->
<style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight"> <style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight">
<item name="colorPrimary">@*android:color/edge_effect_device_default_light</item> <item name="colorPrimary">@*android:color/edge_effect_device_default_light</item>

View File

@@ -130,10 +130,17 @@ public abstract class AccessibilityQuickSettingsPrimarySwitchPreferenceControlle
return; return;
} }
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext); // TODO (287728819): Move tooltip showing to SystemUI
mTooltipWindow.setup(getTileTooltipContent(), // Since the lifecycle of controller is independent of that of the preference, doing
R.drawable.accessibility_auto_added_qs_tooltip_illustration); // null check on switch is a temporary solution for the case that switch view
mTooltipWindow.showAtTopCenter(mPreference.getSwitch()); // is not ready when we would like to show the tooltip. If the switch is not ready,
// we give up showing the tooltip and also do not reshow it in the future.
if (mPreference.getSwitch() != null) {
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext);
mTooltipWindow.setup(getTileTooltipContent(),
R.drawable.accessibility_auto_added_qs_tooltip_illustration);
mTooltipWindow.showAtTopCenter(mPreference.getSwitch());
}
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, tileComponentName); AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, tileComponentName);
mNeedsQSTooltipReshow = false; mNeedsQSTooltipReshow = false;
} }

View File

@@ -213,11 +213,19 @@ abstract class PreviewSizeSeekBarController extends BasePreferenceController imp
return; return;
} }
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext); // TODO (287728819): Move tooltip showing to SystemUI
mTooltipWindow.setup(getTileTooltipContent(), // Since the lifecycle of controller is independent of that of the preference, doing
R.drawable.accessibility_auto_added_qs_tooltip_illustration); // null check on seekbar is a temporary solution for the case that seekbar view
mTooltipWindow.showAtTopCenter(mSeekBarPreference.getSeekbar()); // is not ready when we would like to show the tooltip. If the seekbar is not ready,
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, tileComponentName); // we give up showing the tooltip and also do not reshow it in the future.
if (mSeekBarPreference.getSeekbar() != null) {
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext);
mTooltipWindow.setup(getTileTooltipContent(),
R.drawable.accessibility_auto_added_qs_tooltip_illustration);
mTooltipWindow.showAtTopCenter(mSeekBarPreference.getSeekbar());
}
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext,
tileComponentName);
mNeedsQSTooltipReshow = false; mNeedsQSTooltipReshow = false;
} }

View File

@@ -29,6 +29,7 @@ import androidx.preference.SwitchPreference;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.utils.ThreadUtils;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@@ -66,23 +67,34 @@ public class EnableVerboseVendorLoggingPreferenceController
return isIDumpstateDeviceAidlServiceAvailable() || isIDumpstateDeviceV1_1ServiceAvailable(); return isIDumpstateDeviceAidlServiceAvailable() || isIDumpstateDeviceV1_1ServiceAvailable();
} }
@SuppressWarnings("FutureReturnValueIgnored")
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
setVerboseLoggingEnabled(isEnabled); // IDumpstateDevice IPC may be blocking when system is extremely heavily-loaded.
// Post to background thread to avoid ANR. Ignore the returned Future.
ThreadUtils.postOnBackgroundThread(() ->
setVerboseLoggingEnabled(isEnabled));
return true; return true;
} }
@SuppressWarnings("FutureReturnValueIgnored")
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean enabled = getVerboseLoggingEnabled(); ThreadUtils.postOnBackgroundThread(() -> {
((SwitchPreference) mPreference).setChecked(enabled); final boolean enabled = getVerboseLoggingEnabled();
ThreadUtils.getUiThreadHandler().post(() ->
((SwitchPreference) mPreference).setChecked(enabled));
}
);
} }
@SuppressWarnings("FutureReturnValueIgnored")
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled(); super.onDeveloperOptionsSwitchDisabled();
setVerboseLoggingEnabled(false); ThreadUtils.postOnBackgroundThread(() ->
setVerboseLoggingEnabled(false));
((SwitchPreference) mPreference).setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
} }

View File

@@ -45,7 +45,7 @@ public class BatteryFirstUseDatePreferenceController extends BasePreferenceContr
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return mBatterySettingsFeatureProvider.isFirstUseDateAvailable(getFirstUseDate()) return mBatterySettingsFeatureProvider.isFirstUseDateAvailable(mContext, getFirstUseDate())
? AVAILABLE : CONDITIONALLY_UNAVAILABLE; ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
} }

View File

@@ -45,7 +45,8 @@ public class BatteryManufactureDatePreferenceController extends BasePreferenceCo
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return mBatterySettingsFeatureProvider.isManufactureDateAvailable(getManufactureDate()) return mBatterySettingsFeatureProvider.isManufactureDateAvailable(mContext,
getManufactureDate())
? AVAILABLE : CONDITIONALLY_UNAVAILABLE; ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
} }

View File

@@ -16,12 +16,14 @@
package com.android.settings.fuelgauge; package com.android.settings.fuelgauge;
import android.content.Context;
/** Feature provider for battery settings usage. */ /** Feature provider for battery settings usage. */
public interface BatterySettingsFeatureProvider { public interface BatterySettingsFeatureProvider {
/** Returns true if manufacture date should be shown */ /** Returns true if manufacture date should be shown */
boolean isManufactureDateAvailable(long manufactureDateMs); boolean isManufactureDateAvailable(Context context, long manufactureDateMs);
/** Returns true if first use date should be shown */ /** Returns true if first use date should be shown */
boolean isFirstUseDateAvailable(long firstUseDateMs); boolean isFirstUseDateAvailable(Context context, long firstUseDateMs);
} }

View File

@@ -16,16 +16,18 @@
package com.android.settings.fuelgauge; package com.android.settings.fuelgauge;
import android.content.Context;
/** Feature provider implementation for battery settings usage. */ /** Feature provider implementation for battery settings usage. */
public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatureProvider { public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatureProvider {
@Override @Override
public boolean isManufactureDateAvailable(long manufactureDateMs) { public boolean isManufactureDateAvailable(Context context, long manufactureDateMs) {
return false; return false;
} }
@Override @Override
public boolean isFirstUseDateAvailable(long firstUseDateMs) { public boolean isFirstUseDateAvailable(Context context, long firstUseDateMs) {
return false; return false;
} }
} }

View File

@@ -163,13 +163,13 @@ public class BubblePreference extends Preference implements View.OnClickListener
void setSelected(Context context, boolean selected) { void setSelected(Context context, boolean selected) {
mView.setBackground(mContext.getDrawable(selected mView.setBackground(mContext.getDrawable(selected
? R.drawable.button_border_selected ? R.drawable.notification_importance_button_background_selected
: R.drawable.button_border_unselected)); : R.drawable.notification_importance_button_background_unselected));
mView.setSelected(selected); mView.setSelected(selected);
int colorResId = selected int colorResId = selected
? com.android.internal.R.attr.materialColorOnSecondaryContainer ? R.attr.notification_importance_button_foreground_color_selected
: com.android.internal.R.attr.materialColorOnSurfaceVariant; : R.attr.notification_importance_button_foreground_color_unselected;
ColorStateList stateList = Utils.getColorAttr(context, colorResId); ColorStateList stateList = Utils.getColorAttr(context, colorResId);
mImageView.setImageTintList(stateList); mImageView.setImageTintList(stateList);
mTextView.setTextColor(stateList); mTextView.setTextColor(stateList);

View File

@@ -127,12 +127,14 @@ public class ConversationPriorityPreference extends Preference {
}); });
} }
private ColorStateList getAccentTint() { private ColorStateList getSelectedColor() {
return Utils.getColorAccent(getContext()); return Utils.getColorAttr(getContext(),
R.attr.notification_importance_button_foreground_color_selected);
} }
private ColorStateList getRegularTint() { private ColorStateList getUnselectedColor() {
return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary); return Utils.getColorAttr(getContext(),
R.attr.notification_importance_button_foreground_color_unselected);
} }
void updateToggles(ViewGroup parent, int importance, boolean isPriority, void updateToggles(ViewGroup parent, int importance, boolean isPriority,
@@ -161,20 +163,21 @@ public class ConversationPriorityPreference extends Preference {
} }
void setSelected(View view, boolean selected) { void setSelected(View view, boolean selected) {
ColorStateList colorAccent = getAccentTint(); ColorStateList colorSelected = getSelectedColor();
ColorStateList colorNormal = getRegularTint(); ColorStateList colorUnselected = getUnselectedColor();
ImageView icon = view.findViewById(R.id.icon); ImageView icon = view.findViewById(R.id.icon);
TextView label = view.findViewById(R.id.label); TextView label = view.findViewById(R.id.label);
TextView summary = view.findViewById(R.id.summary); TextView summary = view.findViewById(R.id.summary);
icon.setImageTintList(selected ? colorAccent : colorNormal); icon.setImageTintList(selected ? colorSelected : colorUnselected);
label.setTextColor(selected ? colorAccent : colorNormal); label.setTextColor(selected ? colorSelected : colorUnselected);
summary.setTextColor(selected ? colorSelected : colorUnselected);
summary.setVisibility(selected ? VISIBLE : GONE); summary.setVisibility(selected ? VISIBLE : GONE);
view.setBackground(mContext.getDrawable(selected view.setBackground(mContext.getDrawable(selected
? R.drawable.button_border_selected ? R.drawable.notification_importance_button_background_selected
: R.drawable.button_border_unselected)); : R.drawable.notification_importance_button_background_unselected));
// a11y service won't always read the newly appearing text in the right order if the // a11y service won't always read the newly appearing text in the right order if the
// selection happens too soon (readback happens on a different thread as layout). post // selection happens too soon (readback happens on a different thread as layout). post
// the selection to make that conflict less likely // the selection to make that conflict less likely

View File

@@ -77,8 +77,10 @@ public class ImportancePreference extends Preference {
private void init(Context context) { private void init(Context context) {
mContext = context; mContext = context;
selectedBackground = mContext.getDrawable(R.drawable.button_border_selected); selectedBackground = mContext.getDrawable(
unselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected); R.drawable.notification_importance_button_background_selected);
unselectedBackground = mContext.getDrawable(
R.drawable.notification_importance_button_background_unselected);
setLayoutResource(R.layout.notif_importance_preference); setLayoutResource(R.layout.notif_importance_preference);
} }
@@ -152,12 +154,14 @@ public class ImportancePreference extends Preference {
}); });
} }
private ColorStateList getAccentTint() { private ColorStateList getSelectedColor() {
return Utils.getColorAccent(getContext()); return Utils.getColorAttr(getContext(),
R.attr.notification_importance_button_foreground_color_selected);
} }
private ColorStateList getRegularTint() { private ColorStateList getUnselectedColor() {
return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary); return Utils.getColorAttr(getContext(),
R.attr.notification_importance_button_foreground_color_unselected);
} }
void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) { void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) {
@@ -167,25 +171,25 @@ public class ImportancePreference extends Preference {
TransitionManager.beginDelayedTransition(parent, transition); TransitionManager.beginDelayedTransition(parent, transition);
} }
ColorStateList colorAccent = getAccentTint(); ColorStateList colorSelected = getSelectedColor();
ColorStateList colorNormal = getRegularTint(); ColorStateList colorUnselected = getUnselectedColor();
if (importance >= IMPORTANCE_DEFAULT) { if (importance >= IMPORTANCE_DEFAULT) {
parent.findViewById(R.id.silence_summary).setVisibility(GONE); parent.findViewById(R.id.silence_summary).setVisibility(GONE);
((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorNormal); ((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorUnselected);
((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorNormal); ((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorUnselected);
((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorAccent); ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorSelected);
((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorAccent); ((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorSelected);
parent.findViewById(R.id.alert_summary).setVisibility(VISIBLE); parent.findViewById(R.id.alert_summary).setVisibility(VISIBLE);
} else { } else {
parent.findViewById(R.id.alert_summary).setVisibility(GONE); parent.findViewById(R.id.alert_summary).setVisibility(GONE);
((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorNormal); ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorUnselected);
((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorNormal); ((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorUnselected);
((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorAccent); ((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorSelected);
((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorAccent); ((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorSelected);
parent.findViewById(R.id.silence_summary).setVisibility(VISIBLE); parent.findViewById(R.id.silence_summary).setVisibility(VISIBLE);
} }
} }

View File

@@ -22,6 +22,7 @@ import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_U
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf; import static org.robolectric.Shadows.shadowOf;
@@ -60,24 +61,24 @@ public class BatteryFirstUseDatePreferenceControllerTest {
@Test @Test
public void getAvailabilityStatus_dateAvailable_returnAvailable() { public void getAvailabilityStatus_dateAvailable_returnAvailable() {
when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(anyLong())) when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(eq(mContext),
.thenReturn(true); anyLong())).thenReturn(true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
} }
@Test @Test
public void getAvailabilityStatus_dateUnavailable_returnNotAvailable() { public void getAvailabilityStatus_dateUnavailable_returnNotAvailable() {
when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(anyLong())) when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(eq(mContext),
.thenReturn(false); anyLong())).thenReturn(false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }
@Test @Test
public void getSummary_available_returnExpectedDate() { public void getSummary_available_returnExpectedDate() {
when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(anyLong())) when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(eq(mContext),
.thenReturn(true); anyLong())).thenReturn(true);
mShadowBatteryManager.setLongProperty(BatteryManager.BATTERY_PROPERTY_FIRST_USAGE_DATE, mShadowBatteryManager.setLongProperty(BatteryManager.BATTERY_PROPERTY_FIRST_USAGE_DATE,
1669680000L); 1669680000L);
@@ -88,8 +89,8 @@ public class BatteryFirstUseDatePreferenceControllerTest {
@Test @Test
public void getSummary_unavailable_returnNull() { public void getSummary_unavailable_returnNull() {
when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(anyLong())) when(mFactory.batterySettingsFeatureProvider.isFirstUseDateAvailable(eq(mContext),
.thenReturn(false); anyLong())).thenReturn(false);
assertThat(mController.getSummary()).isNull(); assertThat(mController.getSummary()).isNull();
} }

View File

@@ -22,6 +22,7 @@ import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_U
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf; import static org.robolectric.Shadows.shadowOf;
@@ -61,7 +62,7 @@ public class BatteryManufactureDatePreferenceControllerTest {
@Test @Test
public void getAvailabilityStatus_dateAvailable_returnAvailable() { public void getAvailabilityStatus_dateAvailable_returnAvailable() {
when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable( when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable(eq(mContext),
anyLong())).thenReturn(true); anyLong())).thenReturn(true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
@@ -69,15 +70,15 @@ public class BatteryManufactureDatePreferenceControllerTest {
@Test @Test
public void getAvailabilityStatus_dateUnavailable_returnNotAvailable() { public void getAvailabilityStatus_dateUnavailable_returnNotAvailable() {
when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable(anyLong())) when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable(eq(mContext),
.thenReturn(false); anyLong())).thenReturn(false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }
@Test @Test
public void getSummary_available_returnExpectedDate() { public void getSummary_available_returnExpectedDate() {
when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable( when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable(eq(mContext),
anyLong())).thenReturn(true); anyLong())).thenReturn(true);
mShadowBatteryManager.setLongProperty(BatteryManager.BATTERY_PROPERTY_MANUFACTURING_DATE, mShadowBatteryManager.setLongProperty(BatteryManager.BATTERY_PROPERTY_MANUFACTURING_DATE,
1669680000L); 1669680000L);
@@ -89,8 +90,8 @@ public class BatteryManufactureDatePreferenceControllerTest {
@Test @Test
public void getSummary_unavailable_returnNull() { public void getSummary_unavailable_returnNull() {
when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable(anyLong())) when(mFactory.batterySettingsFeatureProvider.isManufactureDateAvailable(eq(mContext),
.thenReturn(false); anyLong())).thenReturn(false);
assertThat(mController.getSummary()).isNull(); assertThat(mController.getSummary()).isNull();
} }

View File

@@ -19,6 +19,11 @@ package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.eq;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -28,19 +33,21 @@ import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class BatterySettingsFeatureProviderImplTest { public class BatterySettingsFeatureProviderImplTest {
private BatterySettingsFeatureProviderImpl mImpl; private BatterySettingsFeatureProviderImpl mImpl;
private Context mContext;
@Before @Before
public void setUp() { public void setUp() {
mImpl = new BatterySettingsFeatureProviderImpl(); mImpl = new BatterySettingsFeatureProviderImpl();
mContext = ApplicationProvider.getApplicationContext();
} }
@Test @Test
public void isManufactureDateAvailable_returnFalse() { public void isManufactureDateAvailable_returnFalse() {
assertThat(mImpl.isManufactureDateAvailable(anyLong())).isFalse(); assertThat(mImpl.isManufactureDateAvailable(eq(mContext), anyLong())).isFalse();
} }
@Test @Test
public void isFirstUseDateAvailable_returnFalse() { public void isFirstUseDateAvailable_returnFalse() {
assertThat(mImpl.isFirstUseDateAvailable(anyLong())).isFalse(); assertThat(mImpl.isFirstUseDateAvailable(eq(mContext), anyLong())).isFalse();
} }
} }