Snap for 7438839 from 6c971a8a99 to sc-v2-release

Change-Id: If4285abb306b63b5cd586722d3ac61236fdf7053
This commit is contained in:
android-build-team Robot
2021-06-09 01:09:14 +00:00
24 changed files with 193 additions and 225 deletions

View File

@@ -20,15 +20,15 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M21.5,9.39l-1.63,0l0.81,-1.42l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0z" />
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M13.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M6.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M21,17.89H3c-0.28,0 -0.5,-0.22 -0.5,-0.5v-1c0,-0.28 0.22,-0.5 0.5,-0.5h18c0.28,0 0.5,0.22 0.5,0.5v1C21.5,17.66 21.28,17.89 21,17.89z" />
</vector>

View File

@@ -20,18 +20,18 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M4,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M4,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M20,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M20,18c-0.93,0 -1.7,0.64 -1.93,1.5h-4.14c-0.22,-0.86 -1,-1.5 -1.93,-1.5s-1.7,0.64 -1.93,1.5H5.93c-0.05,-0.18 -0.12,-0.35 -0.21,-0.51l5.28,-5.28C11.29,13.89 11.63,14 12,14c1.1,0 2,-0.9 2,-2c0,-0.37 -0.11,-0.71 -0.28,-1.01l5.28,-5.28C19.29,5.89 19.63,6 20,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2s-2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C12.71,10.11 12.37,10 12,10c-1.1,0 -2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C4.71,18.11 4.37,18 4,18c-1.1,0 -2,0.9 -2,2s0.9,2 2,2c0.93,0 1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5s1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5c1.1,0 2,-0.9 2,-2S21.1,18 20,18z" />
</vector>

View File

@@ -20,6 +20,6 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="?attr/sudListItemIconColor"
android:fillColor="?attr/colorAccent"
android:pathData="M20,4L4,4A2,2 0,0 0,2 6L2,18a2,2 0,0 0,2 2L20,20a2,2 0,0 0,2 -2L22,6A2,2 0,0 0,20 4ZM7.1,15L5.9,15L5.9,10.2L4.7,10.2L4.7,9L7.1,9v6ZM13.2,11.4A1.2,1.2 0,0 1,12 12.6L10.8,12.6v1.2h2.4L13.2,15L9.6,15L9.6,12.6a1.2,1.2 0,0 1,1.2 -1.2L12,11.4L12,10.2L9.6,10.2L9.6,9L12,9a1.2,1.2 0,0 1,1.2 1.2v1.2ZM19.3,11.1a0.9,0.9 0,0 1,-0.9 0.9,0.9 0.9,0 0,1 0.9,0.9v0.9A1.2,1.2 0,0 1,18.1 15L15.7,15L15.7,13.8h2.4L18.1,12.6L16.9,12.6L16.9,11.4h1.2L18.1,10.2L15.7,10.2L15.7,9h2.4a1.2,1.2 0,0 1,1.2 1.2v0.9Z" />
</vector>

View File

@@ -20,7 +20,7 @@
android:layout_height="wrap_content"
android:paddingTop="22dp"
android:paddingBottom="32dp"
android:paddingStart="@dimen/preference_no_icon_padding_start"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:orientation="vertical"
android:selectable="false"

View File

@@ -22,10 +22,11 @@
<Button
android:id="@+id/security_settings_face_settings_enroll_button"
android:layout_marginStart="20dp"
style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="20dp"
android:text="@string/security_settings_face_settings_enroll"/>
</LinearLayout>

View File

@@ -22,10 +22,11 @@
<Button
android:id="@+id/security_settings_face_settings_remove_button"
android:layout_marginStart="20dp"
style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="20dp"
android:text="@string/security_settings_face_settings_remove_face_model"/>
</LinearLayout>

View File

@@ -2014,10 +2014,12 @@
<string name="wifi_display_listen_channel" translatable="false">Listen channel</string>
<!-- Wifi Display settings. The dropdown menu title for choosing operating channel during certification process. [CHAR LIMIT=40] -->
<string name="wifi_display_operating_channel" translatable="false">Operating channel</string>
<!-- Wifi 2.4GHz is used as an universal itendifier for 2.4GHz band -->
<!-- Wifi 2.4GHz is used as a universal identifier for 2.4GHz band -->
<string name="wifi_band_24ghz">2.4 GHz</string>
<!-- Wifi Internal 5GHz as an universal itendifier for 5GHz band -->
<!-- Wifi Internal 5GHz as a universal identifier for 5GHz band -->
<string name="wifi_band_5ghz">5 GHz</string>
<!-- Wifi 6GHz is used as a universal identifier for 6GHz band [CHAR LIMIT=40] -->
<string name="wifi_band_6ghz">6 GHz</string>
<!-- Wifi Sign in text for button [CHAR LIMIT = 40]-->
<string name="wifi_sign_in_button_text">Sign in</string>
<!-- Text for button to go to Wifi venue information webpage when Wifi is a captive portal [CHAR LIMIT=40]-->
@@ -5982,6 +5984,8 @@
<string name="manager_battery_usage_unrestricted_title">Unrestricted</string>
<!-- Title for the battery optimized settings [CHAR_LIMIT=40] -->
<string name="manager_battery_usage_optimized_title">Optimized</string>
<!-- Title for the battery restricted settings [CHAR_LIMIT=40] -->
<string name="manager_battery_usage_restricted_title">Restricted</string>
<!-- Summary for the battery unrestricted settings [CHAR_LIMIT=NONE] -->
<string name="manager_battery_usage_unrestricted_summary">Allow battery usage in background without restrictions. May use more battery.</string>
<!-- Summary for the battery optimized settings [CHAR_LIMIT=NONE] -->
@@ -13191,7 +13195,7 @@
<!-- Provider Model: Calls and SMS controllers settings screen, item title to go into the Calls and SMS settings -->
<string name="calls_and_sms">Calls &amp; SMS</string>
<!-- Provider Model: Name for call settings category [CHAR LIMIT=NONE] -->
<string name="calls_and_sms_category">Wi\u2011Fi Calling</string>
<string name="calls_and_sms_category">Wi\u2011Fi calling</string>
<!-- Provider Model: Summary for calling preference -->
<string name="calls_sms_wfc_summary">Make and receive calls over Wi\u2011Fi</string>
<!-- Provider Model: Label for footnote on calling preference -->

View File

@@ -25,14 +25,16 @@
android:key="resetting_your_internet"
android:title="@string/resetting_internet_text"
android:selectable="false"
android:layout="@layout/resetting_internet"/>
android:layout="@layout/resetting_internet"
settings:allowDividerBelow="true"/>
<!-- Airplane mode message -->
<com.android.settingslib.widget.LayoutPreference
android:key="airplane_mode_message"
android:title="@string/condition_airplane_title"
android:selectable="false"
android:layout="@layout/airplane_mode_message_preference"/>
android:layout="@layout/airplane_mode_message_preference"
settings:allowDividerBelow="true"/>
<Preference
android:key="connected_ethernet_network"
@@ -40,16 +42,23 @@
android:summary="@string/to_switch_networks_disconnect_ethernet"
android:icon="@drawable/ic_settings_ethernet"/>
<PreferenceCategory
android:key="connected_access_point"
android:layout="@layout/preference_category_no_label"/>
<PreferenceCategory
android:key="provider_model_mobile_network"
android:title="@string/summary_placeholder"
android:layout="@layout/preference_category_no_label"
settings:controller="com.android.settings.network.NetworkMobileProviderController"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="main_toggle_wifi"
android:title="@string/wifi"
android:summary="@string/wifi_switch_summary"
settings:keywords="@string/keywords_wifi"
settings:allowDividerAbove="true"/>
<PreferenceCategory
android:key="connected_access_point"
android:layout="@layout/preference_category_no_label"/>
<PreferenceCategory
android:key="first_access_points"
android:layout="@layout/preference_category_no_label"/>
@@ -58,16 +67,11 @@
android:key="access_points"
android:layout="@layout/preference_category_no_label"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="main_toggle_wifi"
android:title="@string/wifi"
android:summary="@string/wifi_switch_summary"
settings:keywords="@string/keywords_wifi"/>
<Preference
android:key="configure_wifi_settings"
android:title="@string/network_and_internet_preferences_title"
android:summary="@string/network_and_internet_preferences_summary"
settings:allowDividerAbove="true"
android:fragment="com.android.settings.wifi.ConfigureWifiSettings"/>
<Preference

View File

@@ -45,7 +45,7 @@
<com.android.settingslib.widget.RadioButtonPreference
android:key="restricted_pref"
android:summary="@string/manager_battery_usage_restricted_summary"
android:title="@string/restricted_true_label"
android:title="@string/manager_battery_usage_restricted_title"
settings:controller="com.android.settings.fuelgauge.RestrictedPreferenceController"/>
</PreferenceCategory>

View File

@@ -29,7 +29,7 @@
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.wifi.tether.WifiTetherSettings"
settings:allowDividerAbove="true"
settings:summaryLineCount="2"/>
settings:maxLines="2"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="usb_tether_settings"

View File

@@ -19,16 +19,22 @@ package com.android.settings.biometrics;
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
import com.android.settings.core.InstrumentedActivity;
import com.android.settings.password.ChooseLockSettingsHelper;
@@ -138,6 +144,20 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
initViews();
@SuppressLint("VisibleForTests")
final LinearLayout buttonContainer = mFooterBarMixin != null
? mFooterBarMixin.getButtonContainer()
: null;
if (buttonContainer != null) {
buttonContainer.setBackgroundColor(getBackgroundColor());
}
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
getWindow().setStatusBarColor(getBackgroundColor());
}
@Override
@@ -242,4 +262,10 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
mLaunchedConfirmLock = true;
}
}
@ColorInt
private int getBackgroundColor() {
final ColorStateList stateList = Utils.getColorAttr(this, android.R.attr.windowBackground);
return stateList != null ? stateList.getDefaultColor() : Color.TRANSPARENT;
}
}

View File

@@ -18,8 +18,6 @@ package com.android.settings.biometrics;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.os.Bundle;
@@ -27,17 +25,14 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockSettingsHelper;
@@ -187,15 +182,6 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
}
}
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
final LinearLayout buttonContainer = mFooterBarMixin.getButtonContainer();
if (buttonContainer != null) {
buttonContainer.setBackgroundColor(getBackgroundColor());
}
}
@Override
protected void onResume() {
super.onResume();
@@ -213,12 +199,6 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
}
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
getWindow().setStatusBarColor(getBackgroundColor());
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -355,10 +335,4 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
}
return mIconColorFilter;
}
@ColorInt
private int getBackgroundColor() {
final ColorStateList stateList = Utils.getColorAttr(this, android.R.attr.windowBackground);
return stateList != null ? stateList.getDefaultColor() : Color.TRANSPARENT;
}
}

View File

@@ -16,6 +16,8 @@
package com.android.settings.biometrics.face;
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import android.content.Context;
import android.content.Intent;
import android.view.View;
@@ -29,6 +31,9 @@ import com.android.settings.core.BasePreferenceController;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.widget.LayoutPreference;
import com.google.android.setupdesign.util.ButtonStyler;
import com.google.android.setupdesign.util.PartnerStyleHelper;
/**
* Preference controller that allows a user to enroll their face.
*/
@@ -38,6 +43,8 @@ public class FaceSettingsEnrollButtonPreferenceController extends BasePreference
private static final String TAG = "FaceSettings/Remove";
static final String KEY = "security_settings_face_enroll_faces_container";
private final Context mContext;
private int mUserId;
private byte[] mToken;
private SettingsActivity mActivity;
@@ -49,17 +56,22 @@ public class FaceSettingsEnrollButtonPreferenceController extends BasePreference
this(context, KEY);
}
public FaceSettingsEnrollButtonPreferenceController(Context context,
String preferenceKey) {
public FaceSettingsEnrollButtonPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mContext = context;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
mButton = ((LayoutPreference) preference)
.findViewById(R.id.security_settings_face_settings_enroll_button);
mButton = ((LayoutPreference) preference).findViewById(
R.id.security_settings_face_settings_enroll_button);
if (PartnerStyleHelper.shouldApplyPartnerResource(mButton)) {
ButtonStyler.applyPartnerCustomizationPrimaryButtonStyle(mContext, mButton);
}
mButton.setOnClickListener(this);
}
@@ -67,7 +79,7 @@ public class FaceSettingsEnrollButtonPreferenceController extends BasePreference
public void onClick(View v) {
mIsClicked = true;
final Intent intent = new Intent();
intent.setClassName("com.android.settings", FaceEnrollIntroduction.class.getName());
intent.setClassName(SETTINGS_PACKAGE_NAME, FaceEnrollIntroduction.class.getName());
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
if (mListener != null) {

View File

@@ -39,6 +39,9 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.widget.LayoutPreference;
import com.google.android.setupdesign.util.ButtonStyler;
import com.google.android.setupdesign.util.PartnerStyleHelper;
import java.util.List;
/**
@@ -163,6 +166,11 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
mPreference = preference;
mButton = ((LayoutPreference) preference)
.findViewById(R.id.security_settings_face_settings_remove_button);
if (PartnerStyleHelper.shouldApplyPartnerResource(mButton)) {
ButtonStyler.applyPartnerCustomizationPrimaryButtonStyle(mContext, mButton);
}
mButton.setOnClickListener(this);
if (!FaceSettings.isFaceHardwareDetected(mContext)) {

View File

@@ -17,6 +17,7 @@
package com.android.settings.core;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_SETTINGS_PAGE_SCROLL;
import static com.android.internal.jank.InteractionJankMonitor.Configuration;
import android.content.Context;
import android.os.Bundle;
@@ -156,8 +157,11 @@ public abstract class InstrumentedPreferenceFragment extends ObservablePreferenc
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
switch (newState) {
case RecyclerView.SCROLL_STATE_DRAGGING:
// TODO: Update API with tag parameter (class name).
mMonitor.begin(recyclerView, CUJ_SETTINGS_PAGE_SCROLL);
final Configuration.Builder builder =
new Configuration.Builder(CUJ_SETTINGS_PAGE_SCROLL)
.setView(recyclerView)
.setTag(mClassName);
mMonitor.begin(builder);
break;
case RecyclerView.SCROLL_STATE_IDLE:
mMonitor.end(CUJ_SETTINGS_PAGE_SCROLL);

View File

@@ -23,15 +23,23 @@ import android.os.UserHandle;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.internal.view.RotationPolicy;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
/**
* SmartAutoRotatePreferenceController provides auto rotate summary in display settings
*/
public class SmartAutoRotatePreferenceController extends BasePreferenceController {
public class SmartAutoRotatePreferenceController extends BasePreferenceController
implements LifecycleObserver, OnStart, OnStop {
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
private Preference mPreference;
public SmartAutoRotatePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -43,8 +51,34 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
protected void update(Preference preference) {
refreshSummary(preference);
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override
public void onStart() {
if (mRotationPolicyListener == null) {
mRotationPolicyListener = new RotationPolicy.RotationPolicyListener() {
@Override
public void onChange() {
if (mPreference != null) {
refreshSummary(mPreference);
}
}
};
}
RotationPolicy.registerRotationPolicyListener(mContext,
mRotationPolicyListener);
}
@Override
public void onStop() {
if (mRotationPolicyListener != null) {
RotationPolicy.unregisterRotationPolicyListener(mContext,
mRotationPolicyListener);
}
}
@Override

View File

@@ -17,7 +17,6 @@
package com.android.settings.fuelgauge.batterysaver;
import android.app.settings.SettingsEnums;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
@@ -36,7 +35,6 @@ import com.android.settingslib.widget.FooterPreference;
public class BatterySaverSettings extends DashboardFragment {
private static final String TAG = "BatterySaverSettings";
private static final String KEY_FOOTER_PREFERENCE = "battery_saver_footer_preference";
private SpannableStringBuilder mFooterText;
private String mHelpUri;
@Override
@@ -76,8 +74,6 @@ public class BatterySaverSettings extends DashboardFragment {
void setupFooter() {
mHelpUri = getString(R.string.help_url_battery_saver_settings);
if (!TextUtils.isEmpty(mHelpUri)) {
mFooterText = new SpannableStringBuilder(getText(
com.android.internal.R.string.battery_saver_description_with_learn_more));
addHelpLink();
}
}
@@ -87,7 +83,6 @@ public class BatterySaverSettings extends DashboardFragment {
void addHelpLink() {
FooterPreference pref = getPreferenceScreen().findPreference(KEY_FOOTER_PREFERENCE);
if (pref != null) {
pref.setTitle(mFooterText);
pref.setSelectable(false);
pref.setLearnMoreAction(v -> {
mMetricsFeatureProvider.action(getContext(),

View File

@@ -169,6 +169,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
return WifiPickerTracker.isVerboseLoggingEnabled();
}
private boolean mIsWifiEntryListStale = true;
private final Runnable mUpdateWifiEntryPreferencesRunnable = () -> {
updateWifiEntryPreferences();
};
@@ -437,6 +438,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onStop() {
mIsWifiEntryListStale = true;
getView().removeCallbacks(mUpdateWifiEntryPreferencesRunnable);
getView().removeCallbacks(mHideProgressBarRunnable);
mAirplaneModeEnabler.stop();
@@ -698,7 +700,12 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onWifiEntriesChanged() {
updateWifiEntryPreferencesDelayed();
if (mIsWifiEntryListStale) {
mIsWifiEntryListStale = false;
updateWifiEntryPreferences();
} else {
updateWifiEntryPreferencesDelayed();
}
changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
// Edit the Wi-Fi network of specified SSID.

View File

@@ -31,7 +31,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.LifecycleObserver;
@@ -50,7 +50,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Copied the logic of WiFi calling from {@link WifiCallingPreferenceController}.
@@ -72,8 +71,7 @@ public class NetworkProviderWifiCallingGroup extends
private Map<Integer, TelephonyManager> mTelephonyManagerList = new HashMap<>();
private Map<Integer, PhoneAccountHandle> mSimCallManagerList = new HashMap<>();
private Map<Integer, Preference> mWifiCallingForSubPreferences;
private Set<Integer> mSubIdList = new ArraySet<>();
private List<SubscriptionInfo> mSubInfoListForWfc;
public NetworkProviderWifiCallingGroup(Context context, Lifecycle lifecycle,
String preferenceGroupKey) {
@@ -83,18 +81,26 @@ public class NetworkProviderWifiCallingGroup extends
mPreferenceGroupKey = preferenceGroupKey;
mWifiCallingForSubPreferences = new ArrayMap<>();
lifecycle.addObserver(this);
setSubscriptionInfoList(context);
lifecycle.addObserver(this);
}
private void setSubscriptionInfoList(Context context){
final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions(
mSubscriptionManager);
for (SubscriptionInfo info : subscriptions) {
final int subId = info.getSubscriptionId();
mSubIdList.add(subId);
setTelephonyManagerForSubscriptionId(context, subId);
setPhoneAccountHandleForSubscriptionId(context, subId);
private void setSubscriptionInfoList(Context context) {
mSubInfoListForWfc = SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager);
if (mSubInfoListForWfc != null) {
mSubInfoListForWfc.removeIf(info -> {
final int subId = info.getSubscriptionId();
setTelephonyManagerForSubscriptionId(context, subId);
setPhoneAccountHandleForSubscriptionId(context, subId);
boolean isExisted = mSubInfoListForWfc.contains(info);
boolean shouldShowWfcForSub = shouldShowWifiCallingForSub(subId);
if (!shouldShowWfcForSub && isExisted) {
return true;
}
return false;
});
} else {
Log.d(TAG, "No active subscriptions");
}
}
@@ -110,12 +116,12 @@ public class NetworkProviderWifiCallingGroup extends
mSimCallManagerList.put(subId, phoneAccountHandle);
}
private TelephonyManager getTelephonyManagerForSubscriptionId(int subId){
return mTelephonyManagerList.get(subId);
private TelephonyManager getTelephonyManagerForSubscriptionId(int subId) {
return mTelephonyManagerList.get(subId);
}
@VisibleForTesting
protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId){
protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId) {
return mSimCallManagerList.get(subId);
}
@@ -131,7 +137,12 @@ public class NetworkProviderWifiCallingGroup extends
@Override
public boolean isAvailable() {
return mSubIdList.size() >= 1;
if (mSubInfoListForWfc == null) {
Log.d(TAG, "No active subscriptions, hide the controller");
return false;
} else {
return mSubInfoListForWfc.size() >= 1;
}
}
@Override
@@ -167,19 +178,15 @@ public class NetworkProviderWifiCallingGroup extends
final Map<Integer, Preference> toRemovePreferences = mWifiCallingForSubPreferences;
mWifiCallingForSubPreferences = new ArrayMap<>();
final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions(
mSubscriptionManager);
setSubscriptionInfoForPreference(subscriptions, toRemovePreferences);
setSubscriptionInfoForPreference(toRemovePreferences);
for (Preference pref : toRemovePreferences.values()) {
mPreferenceGroup.removePreference(pref);
}
}
private void setSubscriptionInfoForPreference(List<SubscriptionInfo> subscriptions,
Map<Integer, Preference> toRemovePreferences) {
private void setSubscriptionInfoForPreference(Map<Integer, Preference> toRemovePreferences) {
int order = PREF_START_ORDER;
for (SubscriptionInfo info : subscriptions) {
for (SubscriptionInfo info : mSubInfoListForWfc) {
final int subId = info.getSubscriptionId();
if (!shouldShowWifiCallingForSub(subId)) {
@@ -192,9 +199,11 @@ public class NetworkProviderWifiCallingGroup extends
mPreferenceGroup.addPreference(pref);
}
CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info, mContext);
CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info,
mContext);
if (getPhoneAccountHandleForSubscriptionId(subId) != null) {
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(
mContext,
getPhoneAccountHandleForSubscriptionId(subId));
if (intent != null) {
final PackageManager pm = mContext.getPackageManager();
@@ -245,7 +254,7 @@ public class NetworkProviderWifiCallingGroup extends
* 1. Check the subscription is valid or not.
* 2. Check whether Wi-Fi Calling can be perform or not on this subscription.
* 3. Check the carrier's config (carrier_wfc_ims_available_bool). If true, the carrier
* supports the Wi-Fi calling, otherwise false.
* supports the Wi-Fi calling, otherwise false.
*/
@VisibleForTesting
protected boolean shouldShowWifiCallingForSub(int subId) {

View File

@@ -16,7 +16,6 @@
package com.android.settings.wifi;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -35,7 +34,6 @@ import android.net.wifi.WifiEnterpriseConfig.Eap;
import android.net.wifi.WifiEnterpriseConfig.Phase2;
import android.net.wifi.WifiManager;
import android.os.IBinder;
import android.os.UserHandle;
import android.security.keystore.KeyProperties;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -402,6 +400,9 @@ public class WifiConfigController2 implements TextWatcher,
} else if (frequency >= WifiEntry.MIN_FREQ_5GHZ
&& frequency < WifiEntry.MAX_FREQ_5GHZ) {
band = res.getString(R.string.wifi_band_5ghz);
} else if (frequency >= WifiEntry.MIN_FREQ_6GHZ
&& frequency < WifiEntry.MAX_FREQ_6GHZ) {
band = res.getString(R.string.wifi_band_6ghz);
} else {
Log.e(TAG, "Unexpected frequency " + frequency);
}

View File

@@ -160,6 +160,7 @@ public class WifiSettings extends RestrictedSettingsFragment
return WifiPickerTracker.isVerboseLoggingEnabled();
}
private boolean mIsWifiEntryListStale = true;
private final Runnable mUpdateWifiEntryPreferencesRunnable = () -> {
updateWifiEntryPreferences();
};
@@ -421,6 +422,7 @@ public class WifiSettings extends RestrictedSettingsFragment
public void onStop() {
getView().removeCallbacks(mUpdateWifiEntryPreferencesRunnable);
getView().removeCallbacks(mHideProgressBarRunnable);
mIsWifiEntryListStale = true;
super.onStop();
}
@@ -678,7 +680,12 @@ public class WifiSettings extends RestrictedSettingsFragment
@Override
public void onWifiEntriesChanged() {
updateWifiEntryPreferencesDelayed();
if (mIsWifiEntryListStale) {
mIsWifiEntryListStale = false;
updateWifiEntryPreferences();
} else {
updateWifiEntryPreferencesDelayed();
}
changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
// Edit the Wi-Fi network of specified SSID.

View File

@@ -623,12 +623,16 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
return;
}
// TODO(b/190390803): We should get the band string directly from WifiEntry.ConnectedInfo
// instead of doing the frequency -> band conversion here.
final int frequency = connectedInfo.frequencyMhz;
String band = null;
if (frequency >= WifiEntry.MIN_FREQ_24GHZ && frequency < WifiEntry.MAX_FREQ_24GHZ) {
band = mContext.getResources().getString(R.string.wifi_band_24ghz);
} else if (frequency >= WifiEntry.MIN_FREQ_5GHZ && frequency < WifiEntry.MAX_FREQ_5GHZ) {
band = mContext.getResources().getString(R.string.wifi_band_5ghz);
} else if (frequency >= WifiEntry.MIN_FREQ_6GHZ && frequency < WifiEntry.MAX_FREQ_6GHZ) {
band = mContext.getResources().getString(R.string.wifi_band_6ghz);
} else {
// Connecting state is unstable, make it disappeared if unexpected
if (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTING) {

View File

@@ -29,7 +29,6 @@ import android.os.UserHandle;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -316,8 +315,6 @@ public final class ConvertUtilsTest {
.isEqualTo(entry.mConsumePower * ratio);
}
@Ignore
@Test
public void testUtcToLocalTime_returnExpectedResult() {
ConvertUtils.sZoneId = null;
ConvertUtils.sLocale = null;
@@ -335,8 +332,6 @@ public final class ConvertUtilsTest {
assertThat(ConvertUtils.sLocale).isEqualTo(Locale.getDefault());
}
@Ignore
@Test
public void testUtcToLocalTimeHour_12HourFormat_returnExpectedResult() {
ConvertUtils.sZoneIdForHour = null;
ConvertUtils.sLocaleForHour = null;
@@ -354,8 +349,6 @@ public final class ConvertUtilsTest {
assertThat(ConvertUtils.sLocaleForHour).isEqualTo(Locale.getDefault());
}
@Ignore
@Test
public void testUtcToLocalTimeHour_24HourFormat_returnExpectedResult() {
ConvertUtils.sZoneIdForHour = null;
ConvertUtils.sLocaleForHour = null;

View File

@@ -1,116 +0,0 @@
/*
* Copyright (C) 2020 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.
*/
package com.android.settings.fuelgauge.batterytip;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.provider.Settings;
import android.text.format.DateUtils;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class BatteryTipPolicyTest {
private static final String BATTERY_TIP_CONSTANTS_VALUE = "battery_tip_enabled=true"
+ ",summary_enabled=false"
+ ",battery_saver_tip_enabled=false"
+ ",high_usage_enabled=true"
+ ",high_usage_app_count=5"
+ ",high_usage_period_ms=2000"
+ ",high_usage_battery_draining=30"
+ ",app_restriction_enabled=true"
+ ",reduced_battery_enabled=true"
+ ",reduced_battery_percent=30"
+ ",low_battery_enabled=false"
+ ",low_battery_hour=10"
+ ",data_history_retain_day=24"
+ ",excessive_bg_drain_percentage=25"
+ ",test_battery_saver_tip=true"
+ ",test_high_usage_tip=false"
+ ",test_smart_battery_tip=true"
+ ",test_low_battery_tip=true"
+ ",app_restriction_active_hour=6";
private Context mContext;
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
}
@Test
public void testInit_usesConfigValues() {
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.BATTERY_TIP_CONSTANTS, BATTERY_TIP_CONSTANTS_VALUE);
final BatteryTipPolicy batteryTipPolicy = new BatteryTipPolicy(mContext);
assertThat(batteryTipPolicy.batteryTipEnabled).isTrue();
assertThat(batteryTipPolicy.summaryEnabled).isFalse();
assertThat(batteryTipPolicy.batterySaverTipEnabled).isFalse();
assertThat(batteryTipPolicy.highUsageEnabled).isTrue();
assertThat(batteryTipPolicy.highUsageAppCount).isEqualTo(5);
assertThat(batteryTipPolicy.highUsagePeriodMs).isEqualTo(2000);
assertThat(batteryTipPolicy.highUsageBatteryDraining).isEqualTo(30);
assertThat(batteryTipPolicy.appRestrictionEnabled).isTrue();
assertThat(batteryTipPolicy.appRestrictionActiveHour).isEqualTo(6);
assertThat(batteryTipPolicy.reducedBatteryEnabled).isTrue();
assertThat(batteryTipPolicy.reducedBatteryPercent).isEqualTo(30);
assertThat(batteryTipPolicy.lowBatteryEnabled).isFalse();
assertThat(batteryTipPolicy.lowBatteryHour).isEqualTo(10);
assertThat(batteryTipPolicy.dataHistoryRetainDay).isEqualTo(24);
assertThat(batteryTipPolicy.excessiveBgDrainPercentage).isEqualTo(25);
assertThat(batteryTipPolicy.testBatterySaverTip).isTrue();
assertThat(batteryTipPolicy.testHighUsageTip).isFalse();
assertThat(batteryTipPolicy.testSmartBatteryTip).isTrue();
assertThat(batteryTipPolicy.testLowBatteryTip).isTrue();
}
@Test
public void testInit_defaultValues() {
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.BATTERY_TIP_CONSTANTS, "");
final BatteryTipPolicy batteryTipPolicy = new BatteryTipPolicy(mContext);
assertThat(batteryTipPolicy.batteryTipEnabled).isTrue();
assertThat(batteryTipPolicy.summaryEnabled).isFalse();
assertThat(batteryTipPolicy.batterySaverTipEnabled).isTrue();
assertThat(batteryTipPolicy.highUsageEnabled).isTrue();
assertThat(batteryTipPolicy.highUsageAppCount).isEqualTo(3);
assertThat(batteryTipPolicy.highUsagePeriodMs).isEqualTo(2 * DateUtils.HOUR_IN_MILLIS);
assertThat(batteryTipPolicy.highUsageBatteryDraining).isEqualTo(25);
assertThat(batteryTipPolicy.appRestrictionEnabled).isTrue();
assertThat(batteryTipPolicy.appRestrictionActiveHour).isEqualTo(24);
assertThat(batteryTipPolicy.reducedBatteryEnabled).isFalse();
assertThat(batteryTipPolicy.reducedBatteryPercent).isEqualTo(50);
assertThat(batteryTipPolicy.lowBatteryEnabled).isTrue();
assertThat(batteryTipPolicy.lowBatteryHour).isEqualTo(3);
assertThat(batteryTipPolicy.dataHistoryRetainDay).isEqualTo(30);
assertThat(batteryTipPolicy.excessiveBgDrainPercentage).isEqualTo(10);
assertThat(batteryTipPolicy.testBatterySaverTip).isFalse();
assertThat(batteryTipPolicy.testHighUsageTip).isFalse();
assertThat(batteryTipPolicy.testSmartBatteryTip).isFalse();
assertThat(batteryTipPolicy.testLowBatteryTip).isFalse();
}
}