Merge "Update About phone icon background color"
diff --git a/res/drawable/face_enroll_introduction.xml b/res/drawable/face_enroll_introduction.xml
index 4493d66..6065f23 100644
--- a/res/drawable/face_enroll_introduction.xml
+++ b/res/drawable/face_enroll_introduction.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2018 The Android Open Source Project
~
@@ -15,9 +16,29 @@
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:height="24dp"
- android:width="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24">
- <path android:fillColor="#000" android:pathData="M9,11.75A1.25,1.25 0 0,0 7.75,13A1.25,1.25 0 0,0 9,14.25A1.25,1.25 0 0,0 10.25,13A1.25,1.25 0 0,0 9,11.75M15,11.75A1.25,1.25 0 0,0 13.75,13A1.25,1.25 0 0,0 15,14.25A1.25,1.25 0 0,0 16.25,13A1.25,1.25 0 0,0 15,11.75M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,11.71 4,11.42 4.05,11.14C6.41,10.09 8.28,8.16 9.26,5.77C11.07,8.33 14.05,10 17.42,10C18.2,10 18.95,9.91 19.67,9.74C19.88,10.45 20,11.21 20,12C20,16.41 16.41,20 12,20Z" />
+ android:width="240dp"
+ android:height="240dp"
+ android:viewportWidth="300"
+ android:viewportHeight="300">
+
+ <path
+ android:fillColor="#DADCE0"
+ android:fillType="evenOdd"
+ android:pathData="M150,0C67.16,0,0,67.16,0,150s67.16,150,150,150 s150-67.16,150-150S232.84,0,150,0 M150,4c39,0,75.66,15.19,103.24,42.76C280.81,74.34,296,111,296,150s-15.19,75.66-42.76,103.24 C225.66,280.81,189,296,150,296s-75.66-15.19-103.24-42.76C19.19,225.66,4,189,4,150S19.19,74.34,46.76,46.76 C74.34,19.19,111,4,150,4" />
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:fillType="evenOdd"
+ android:pathData="M220,120c0,5.52-4.48,10-10,10s-10-4.48-10-10 s4.48-10,10-10S220,114.48,220,120" />
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:fillType="evenOdd"
+ android:pathData="M90,130c-5.52,0-10-4.48-10-10s4.48-10,10-10 s10,4.48,10,10S95.52,130,90,130" />
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:fillType="evenOdd"
+ android:pathData="M164.2,215.88c-3.83,3.25-8.79,5.22-14.2,5.22 c-12.13,0-22-9.87-22-22c0-0.03,0-0.06,0-0.09l-8-0.03c0,0.04,0,0.08,0,0.13c0,6.24,1.9,12.03,5.16,16.83 c5.4,7.95,14.51,13.17,24.84,13.17c1.04,0,2.06-0.05,3.08-0.15c6.18-0.63,11.81-3.14,16.3-6.95L164.2,215.88z" />
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:fillType="evenOdd"
+ android:pathData="M 153 140 L 153 166 L 137 166 L 137 174 L 161 174 L 161 140 Z" />
</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_face_enroll_introduction_detail.xml b/res/drawable/ic_face_enroll_introduction_detail.xml
new file mode 100644
index 0000000..7159148
--- /dev/null
+++ b/res/drawable/ic_face_enroll_introduction_detail.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 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="24dp"
+ android:height="24dp"
+ android:tint="?android:attr/colorControlNormal"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:pathData="M0 0h24v24H0V0z" />
+ <path
+ android:fillColor="#000000"
+ android:pathData="M11 15h2v2h-2zm0-8h2v6h-2zm0.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" />
+</vector>
\ No newline at end of file
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index b5f13db..b55041a 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -27,7 +27,7 @@
<LinearLayout
style="@style/SudContentFrame"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
@@ -45,50 +45,87 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
- <com.google.android.setupdesign.view.FillContentLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1">
-
- <com.google.android.setupdesign.view.IllustrationVideoView
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/face_enroll_introduction_animation"
- style="@style/SudContentIllustration"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:sudVideo="@raw/face_enroll_introduction_animation" />
-
- </com.google.android.setupdesign.view.FillContentLayout>
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
<FrameLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center">
- <Button
- android:id="@+id/accessibility_button"
- style="@style/SudGlifButton.Secondary"
- android:layout_gravity="center"
+ android:layout_height="wrap_content">
+
+ <com.google.android.setupdesign.view.IllustrationVideoView
+ android:id="@+id/illustration_normal"
+ style="@style/SudContentIllustration"
+ android:layout_width="240dp"
+ android:layout_height="240dp"
+ app:sudVideo="@raw/face_enroll_introduction_animation" />
+
+ <ImageView
+ android:id="@+id/illustration_accessibility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_introduction_accessibility" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
android:layout_gravity="center"
- android:id="@+id/accessibility_layout"
- android:orientation="vertical"
- android:visibility="invisible">
+ android:visibility="invisible"
+ android:background="@drawable/face_enroll_introduction" />
+
+ </FrameLayout>
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="2"/>
+
+ <!-- Contains the buttons and extra information text at the bottom -->
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_gravity="center_horizontal|bottom">
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button
+ android:id="@+id/accessibility_button"
+ style="@style/SudGlifButton.Secondary"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_accessibility" />
<com.android.settings.biometrics.face.FaceEnrollAccessibilityToggle
android:id="@+id/toggle_diversity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:visibility="invisible"
FaceEnrollAccessibilitySwitch:messageText="@string/security_settings_face_enroll_introduction_accessibility_diversity"/>
+ </FrameLayout>
+
+ <LinearLayout
+ android:id="@+id/footer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_face_enroll_introduction_detail">
+ </ImageView>
+ <Space
+ android:layout_width="8dp"
+ android:layout_height="wrap_content" />
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_footer_message"/>
</LinearLayout>
- </FrameLayout>
+
+ </LinearLayout>
</LinearLayout>
diff --git a/res/layout/network_request_dialog_title.xml b/res/layout/network_request_dialog_title.xml
index f643e0f..b61a7db 100644
--- a/res/layout/network_request_dialog_title.xml
+++ b/res/layout/network_request_dialog_title.xml
@@ -25,14 +25,12 @@
<TextView
android:id="@+id/network_request_title_text"
android:layout_width="0dp"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:paddingTop="18dp"
android:layout_weight="1"
android:textSize="18sp"
android:gravity="center_vertical"
- android:maxLines="1"
- android:ellipsize="end"
style="@style/info_label"/>
<ProgressBar
diff --git a/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
index ed288f0..3606ccd 100644
--- a/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
+++ b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
@@ -22,28 +22,24 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <ScrollView
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="0dp"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/footer">
- <LinearLayout
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <LinearLayout android:id="@+id/wifi_network_list_container"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center_horizontal"
- android:orientation="vertical">
+ android:layout_height="wrap_content"/>
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <LinearLayout android:id="@+id/wifi_network_list_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toBottomOf="@+id/header"/>
-
- </LinearLayout>
-
- </ScrollView>
+ </LinearLayout>
<include
+ android:id="@+id/footer"
layout="@layout/wifi_dpp_fragment_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 631d912..c6ae67c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -898,8 +898,10 @@
<string name="security_settings_face_enroll_introduction_message">Use your face to unlock your phone, authorize purchases, or sign in to apps.</string>
<!-- Introduction detail message shown in face enrollment dialog, when face unlock is disabled by device admin [CHAR LIMIT=NONE] -->
<string name="security_settings_face_enroll_introduction_message_unlock_disabled">Use your face to unlock your phone or approve purchases.\n\nNote: You can\u2019t use your face to unlock this device. For more information, contact your organization\u2019s admin.</string>
- <!-- Introduction detail message shwon in face enrollment screen in setup wizard. [CHAR LIMIT=NONE] -->
+ <!-- Introduction detail message shown in face enrollment screen in setup wizard. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_enroll_introduction_message_setup">Use your face to unlock your phone, authorize purchases, or sign in to apps</string>
+ <!-- Introduction detail message shown in face enrollment that provides extra detais. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_footer_message"></string>
<!-- Title shown in face enrollment dialog [CHAR LIMIT=40] -->
<string name="security_settings_face_enroll_repeat_title">Center your face in the circle</string>
<!-- Button text to skip enrollment of face [CHAR LIMIT=40] -->
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java
index 2db654b..dffc67d 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java
@@ -20,6 +20,7 @@
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
+import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
@@ -68,4 +69,12 @@
public void setChecked(boolean checked) {
mSwitch.setChecked(checked);
}
+
+ public void setListener(CompoundButton.OnCheckedChangeListener listener) {
+ mSwitch.setOnCheckedChangeListener(listener);
+ }
+
+ public Switch getSwitch() {
+ return mSwitch;
+ }
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index c7966f2..d923e55 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -25,7 +25,7 @@
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
-import android.widget.LinearLayout;
+import android.widget.CompoundButton;
import android.widget.TextView;
import com.android.settings.R;
@@ -38,6 +38,7 @@
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
+import com.google.android.setupdesign.view.IllustrationVideoView;
public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@@ -46,19 +47,44 @@
private FaceManager mFaceManager;
private FaceEnrollAccessibilityToggle mSwitchDiversity;
+ private IllustrationVideoView mIllustrationNormal;
+ private View mIllustrationAccessibility;
+
+ private CompoundButton.OnCheckedChangeListener mSwitchDiversityListener =
+ new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ mIllustrationNormal.stop();
+ mIllustrationNormal.setVisibility(View.INVISIBLE);
+ mIllustrationAccessibility.setVisibility(View.VISIBLE);
+ } else {
+ mIllustrationNormal.setVisibility(View.VISIBLE);
+ mIllustrationNormal.start();
+ mIllustrationAccessibility.setVisibility(View.INVISIBLE);
+ }
+ }
+ };
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
mFaceManager = Utils.getFaceManagerOrNull(this);
- final LinearLayout accessibilityLayout = findViewById(R.id.accessibility_layout);
final Button accessibilityButton = findViewById(R.id.accessibility_button);
+ final View footerView = findViewById(R.id.footer_layout);
accessibilityButton.setOnClickListener(view -> {
mSwitchDiversity.setChecked(true);
- accessibilityButton.setVisibility(View.INVISIBLE);
- accessibilityLayout.setVisibility(View.VISIBLE);
+ accessibilityButton.setVisibility(View.GONE);
+ mSwitchDiversity.setVisibility(View.VISIBLE);
+ footerView.setVisibility(View.GONE);
});
mSwitchDiversity = findViewById(R.id.toggle_diversity);
+ mSwitchDiversity.setListener(mSwitchDiversityListener);
+
+ mIllustrationNormal = findViewById(R.id.illustration_normal);
+ mIllustrationAccessibility = findViewById(R.id.illustration_accessibility);
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
@@ -92,6 +118,13 @@
}
@Override
+ protected void onResume() {
+ super.onResume();
+ mSwitchDiversityListener.onCheckedChanged(mSwitchDiversity.getSwitch(),
+ mSwitchDiversity.isChecked());
+ }
+
+ @Override
protected boolean isDisabledByAdmin() {
return RestrictedLockUtilsInternal.checkIfKeyguardFeaturesDisabled(
this, DevicePolicyManager.KEYGUARD_DISABLE_FACE, mUserId) != null;
@@ -114,7 +147,7 @@
@Override
protected int getDescriptionResDisabledByAdmin() {
- return R.string.security_settings_fingerprint_enroll_introduction_message_unlock_disabled;
+ return R.string.security_settings_face_enroll_introduction_message_unlock_disabled;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
index b14fec9..7a1f7f5 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -19,7 +19,7 @@
@Override
public void updateState(Preference preference) {
- int setting = Settings.System.getInt(mContext.getContentResolver(),
+ int setting = Settings.Global.getInt(mContext.getContentResolver(),
LOW_POWER_STICKY_AUTO_DISABLE_ENABLED, 1);
((SwitchPreference) preference).setChecked(setting == 0);
@@ -28,7 +28,7 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean keepActive = (Boolean) newValue;
- Settings.System.putInt(mContext.getContentResolver(),
+ Settings.Global.putInt(mContext.getContentResolver(),
LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
keepActive ? 0 : 1);
return true;
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index 23136a4..d9af345 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -20,6 +20,8 @@
import android.text.TextUtils;
import android.util.Log;
+import androidx.annotation.Nullable;
+
import com.android.settings.R;
import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider;
@@ -50,6 +52,7 @@
private static final boolean DEBUG = false;
protected static FeatureFactory sFactory;
+ protected static Context sAppContext;
/**
* Returns a factory for creating feature controllers. Creates the factory if it does not
@@ -60,6 +63,9 @@
if (sFactory != null) {
return sFactory;
}
+ if (sAppContext == null) {
+ sAppContext = context.getApplicationContext();
+ }
if (DEBUG) Log.d(LOG_TAG, "getFactory");
final String clsName = context.getString(R.string.config_featureFactory);
@@ -76,6 +82,16 @@
return sFactory;
}
+ /**
+ * Returns an application {@link Context} used to create this {@link FeatureFactory}. If the
+ * factory has not been properly created yet (aka {@link #getFactory} has not been called), this
+ * will return null.
+ */
+ @Nullable
+ public static Context getAppContext() {
+ return sAppContext;
+ }
+
public abstract AssistGestureFeatureProvider getAssistGestureFeatureProvider();
public abstract SuggestionFeatureProvider getSuggestionFeatureProvider(Context context);
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index ba29e3a..09360e4 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -82,11 +82,15 @@
@VisibleForTesting
final static String EXTRA_APP_NAME = "com.android.settings.wifi.extra.APP_NAME";
+ final static String EXTRA_IS_SPECIFIED_SSID =
+ "com.android.settings.wifi.extra.REQUEST_IS_FOR_SINGLE_NETWORK";
private List<AccessPoint> mAccessPointList;
private FilterWifiTracker mFilterWifiTracker;
private AccessPointAdapter mDialogAdapter;
private NetworkRequestUserSelectionCallback mUserSelectionCallback;
+ private boolean mIsSpecifiedSsid;
+ private boolean mWaitingConnectCallback;
public static NetworkRequestDialogFragment newInstance() {
NetworkRequestDialogFragment dialogFragment = new NetworkRequestDialogFragment();
@@ -104,6 +108,11 @@
final TextView title = customTitle.findViewById(R.id.network_request_title_text);
title.setText(getTitle());
+ final Intent intent = getActivity().getIntent();
+ if (intent != null) {
+ mIsSpecifiedSsid = intent.getBooleanExtra(EXTRA_IS_SPECIFIED_SSID, false);
+ }
+
final ProgressBar progressBar = customTitle.findViewById(
R.id.network_request_title_progress);
progressBar.setVisibility(View.VISIBLE);
@@ -115,10 +124,13 @@
final AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCustomTitle(customTitle)
.setAdapter(mDialogAdapter, this)
- .setPositiveButton(R.string.cancel, (dialog, which) -> getActivity().finish())
+ .setNegativeButton(R.string.cancel, (dialog, which) -> getActivity().finish())
// Do nothings, will replace the onClickListener to avoid auto closing dialog.
.setNeutralButton(R.string.network_connection_request_dialog_showall,
null /* OnClickListener */);
+ if (mIsSpecifiedSsid) {
+ builder.setPositiveButton(R.string.wifi_connect, null /* OnClickListener */);
+ }
// Clicking list item is to connect wifi ap.
final AlertDialog dialog = builder.create();
@@ -136,8 +148,19 @@
notifyAdapterRefresh();
neutralBtn.setVisibility(View.GONE);
});
- });
+ // Replace Positive onClickListener to avoid closing dialog
+ if (mIsSpecifiedSsid) {
+ final Button positiveBtn = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
+ positiveBtn.setOnClickListener(v -> {
+ // When clicking connect button, should connect to the first and the only one
+ // list item.
+ this.onClick(dialog, 0 /* position */);
+ });
+ // Disable button in first, and enable it after there are some accesspoints in list.
+ positiveBtn.setEnabled(false);
+ }
+ });
return dialog;
}
@@ -184,6 +207,9 @@
if (wifiConfig != null) {
mUserSelectionCallback.select(wifiConfig);
+
+ mWaitingConnectCallback = true;
+ updateConnectButton(false);
}
}
}
@@ -223,7 +249,7 @@
}
}
- private void showNeutralButton() {
+ private void showAllButton() {
final AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog == null) {
return;
@@ -235,6 +261,35 @@
}
}
+ private void updateConnectButton(boolean enabled) {
+ // The button is only showed in single SSID mode.
+ if (!mIsSpecifiedSsid) {
+ return;
+ }
+
+ final AlertDialog alertDialog = (AlertDialog) getDialog();
+ if (alertDialog == null) {
+ return;
+ }
+
+ final Button positiveBtn = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
+ if (positiveBtn != null) {
+ positiveBtn.setEnabled(enabled);
+ }
+ }
+
+ private void hideProgressIcon() {
+ final AlertDialog alertDialog = (AlertDialog) getDialog();
+ if (alertDialog == null) {
+ return;
+ }
+
+ final View progress = alertDialog.findViewById(R.id.network_request_title_progress);
+ if (progress != null) {
+ progress.setVisibility(View.GONE);
+ }
+ }
+
@Override
public void onResume() {
super.onResume();
@@ -403,7 +458,9 @@
@Override
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
- stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
+ // Do nothing when selection is failed, let user could try again easily.
+ mWaitingConnectCallback = false;
+ updateConnectButton(true);
}
private final class FilterWifiTracker {
@@ -427,10 +484,6 @@
mAccessPointKeys.add(key);
}
}
-
- if (mShowLimitedItem && (mAccessPointKeys.size() > MAX_NUMBER_LIST_ITEM)) {
- showNeutralButton();
- }
}
/**
@@ -457,6 +510,21 @@
}
}
+ // Update related UI buttons
+ if (mShowLimitedItem && (count >= MAX_NUMBER_LIST_ITEM)) {
+ showAllButton();
+ }
+ if (count > 0) {
+ hideProgressIcon();
+ }
+ // Enable connect button if there is Accesspoint item, except for the situation that
+ // user click but connected status doesn't come back yet.
+ if (count < 0) {
+ updateConnectButton(false);
+ } else if (!mWaitingConnectCallback) {
+ updateConnectButton(true);
+ }
+
return result;
}
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
index 4688d76..84f1c36 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkListFragment.java
@@ -34,11 +34,14 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.wifi.AddNetworkFragment;
+import com.android.settings.wifi.savedaccesspoints.SavedNetworkComparator;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
+import com.android.settingslib.wifi.WifiSavedConfigUtils;
import com.android.settingslib.wifi.WifiTracker;
import com.android.settingslib.wifi.WifiTrackerFactory;
+import java.util.Collections;
import java.util.List;
public class WifiNetworkListFragment extends SettingsPreferenceFragment implements
@@ -256,17 +259,6 @@
return false;
}
- // Can only use saved network for DPP configuration. For ephemeral connections networkId
- // is invalid.
- if (!accessPoint.isSaved()) {
- return false;
- }
-
- // Ignore access points that are out of range.
- if (!accessPoint.isReachable()) {
- return false;
- }
-
return true;
}
@@ -290,44 +282,47 @@
return;
}
- // AccessPoints are sorted by the WifiTracker
- final List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
-
- mAccessPointsPreferenceCategory.setVisible(true);
-
- cacheRemoveAllPrefs(mAccessPointsPreferenceCategory);
+ // TODO(b/128942314): Lists reachable AccessPoints on top of the list
+ final List<AccessPoint> savedAccessPoints =
+ WifiSavedConfigUtils.getAllConfigs(getContext(), mWifiManager);
+ Collections.sort(savedAccessPoints, SavedNetworkComparator.INSTANCE);
int index = 0;
- for (; index < accessPoints.size(); index++) {
- AccessPoint accessPoint = accessPoints.get(index);
- // Check if this access point is valid for DPP.
- if (isValidForDppConfiguration(accessPoint)) {
- final String key = accessPoint.getKey();
+ mAccessPointsPreferenceCategory.removeAll();
+ for (AccessPoint savedAccessPoint : savedAccessPoints) {
+ if (isValidForDppConfiguration(savedAccessPoint)) {
+ // Replaces with an AccessPoint from scanned result for signal information
+ savedAccessPoint = getScannedAccessPointIfAvailable(savedAccessPoint);
+ final AccessPointPreference preference =
+ createAccessPointPreference(savedAccessPoint);
- final AccessPointPreference pref = (AccessPointPreference) getCachedPreference(key);
- if (pref != null) {
- pref.setOrder(index);
- continue;
- }
- final AccessPointPreference preference = createAccessPointPreference(accessPoint);
- preference.setKey(key);
- preference.setOrder(index);
+ preference.setOrder(index++);
+ preference.setEnabled(savedAccessPoint.isReachable());
+ savedAccessPoint.setListener(this);
- mAccessPointsPreferenceCategory.addPreference(preference);
- accessPoint.setListener(this);
preference.refresh();
+ mAccessPointsPreferenceCategory.addPreference(preference);
}
}
- removeCachedPrefs(mAccessPointsPreferenceCategory);
mAddPreference.setOrder(index);
mAccessPointsPreferenceCategory.addPreference(mAddPreference);
if (mIsTest) {
- mFakeNetworkPreference.setOrder(index + 1);
mAccessPointsPreferenceCategory.addPreference(mFakeNetworkPreference);
}
}
+ private AccessPoint getScannedAccessPointIfAvailable(AccessPoint savedAccessPoint) {
+ final List<AccessPoint> scannedAccessPoints = mWifiTracker.getAccessPoints();
+ final WifiConfiguration savedWifiConfiguration = savedAccessPoint.getConfig();
+ for (AccessPoint scannedAccessPoint : scannedAccessPoints) {
+ if (scannedAccessPoint.matches(savedWifiConfiguration)) {
+ return scannedAccessPoint;
+ }
+ }
+ return savedAccessPoint;
+ }
+
private AccessPointPreference createAccessPointPreference(AccessPoint accessPoint) {
return new AccessPointPreference(accessPoint, getPrefContext(), mUserBadgeCache,
R.drawable.ic_wifi_signal_0, /* forSavedNetworks */ false);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
index a441864..0ee9cfc 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
@@ -42,7 +42,7 @@
}
private int getAutoDisableSetting() {
- return Settings.System.getInt(mContext.getContentResolver(),
+ return Settings.Global.getInt(mContext.getContentResolver(),
LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
1);
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index 21b68f2..d2403b9 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -106,12 +106,12 @@
}
@Test
- public void clickPositiveButton_shouldCloseTheDialog() {
+ public void clickNegativeButton_shouldCloseTheDialog() {
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(alertDialog.isShowing()).isTrue();
- Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
+ Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
assertThat(positiveButton).isNotNull();
positiveButton.performClick();
@@ -186,26 +186,6 @@
}
@Test
- public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallAbortDialog() {
- FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
- FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
- List<AccessPoint> accessPointList = createAccessPointList();
- when(spyFakeFragment.getAccessPointList()).thenReturn(accessPointList);
- spyFakeFragment.show(mActivity.getSupportFragmentManager(), null);
-
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog.isShowing()).isTrue();
-
- // Test if config would update list.
- WifiConfiguration config = new WifiConfiguration();
- config.SSID = "Test AP 3";
- fakeFragment.onUserSelectionConnectFailure(config);
-
- assertThat(fakeFragment.bCalledStopAndPop).isTrue();
- assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.ABORT);
- }
-
- @Test
public void onUserSelectionCallbackRegistration_onClick_shouldCallSelect() {
// Assert.
final int indexClickItem = 3;
@@ -267,19 +247,27 @@
Bundle bundle = new Bundle();
bundle.putString(KEY_SSID, "Test AP 1");
- bundle.putInt(KEY_SECURITY, 1);
+ bundle.putInt(KEY_SECURITY, 1 /* WEP */);
accessPointList.add(new AccessPoint(mContext, bundle));
bundle.putString(KEY_SSID, "Test AP 2");
- bundle.putInt(KEY_SECURITY, 1);
+ bundle.putInt(KEY_SECURITY, 1 /* WEP */);
accessPointList.add(new AccessPoint(mContext, bundle));
bundle.putString(KEY_SSID, "Test AP 3");
- bundle.putInt(KEY_SECURITY, 2);
+ bundle.putInt(KEY_SECURITY, 1 /* WEP */);
accessPointList.add(new AccessPoint(mContext, bundle));
bundle.putString(KEY_SSID, "Test AP 4");
- bundle.putInt(KEY_SECURITY, 0);
+ bundle.putInt(KEY_SECURITY, 0 /* NONE */);
+ accessPointList.add(new AccessPoint(mContext, bundle));
+
+ bundle.putString(KEY_SSID, "Test AP 5");
+ bundle.putInt(KEY_SECURITY, 1 /* WEP */);
+ accessPointList.add(new AccessPoint(mContext, bundle));
+
+ bundle.putString(KEY_SSID, "Test AP 6");
+ bundle.putInt(KEY_SECURITY, 1 /* WEP */);
accessPointList.add(new AccessPoint(mContext, bundle));
return accessPointList;
@@ -300,9 +288,13 @@
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ List<AccessPoint> accessPointList = createAccessPointList();
+ when(mWifiTracker.getAccessPoints()).thenReturn(accessPointList);
+
final String SSID_AP = "Test AP ";
final List<ScanResult> scanResults = new ArrayList<>();
- for (int i = 0; i < 6 ; i ++) {
+ for (int i = 0; i < 7 ; i ++) {
ScanResult scanResult = new ScanResult();
scanResult.SSID = SSID_AP + i;
scanResult.capabilities = "WEP";