Merge "Create some strings for RTT setting"
diff --git a/res/layout/preference_gesture_navigation_slider.xml b/res/layout/preference_labeled_slider.xml
similarity index 96%
rename from res/layout/preference_gesture_navigation_slider.xml
rename to res/layout/preference_labeled_slider.xml
index ac7f334..42ad988 100644
--- a/res/layout/preference_gesture_navigation_slider.xml
+++ b/res/layout/preference_labeled_slider.xml
@@ -62,7 +62,6 @@
android:layout_height="wrap_content"
android:layout_gravity="start|top"
android:gravity="start"
- android:text="@string/low_label"
android:layout_weight="1"/>
<TextView
@@ -72,7 +71,6 @@
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:gravity="end"
- android:text="@string/high_label"
android:layout_weight="1"/>
</LinearLayout>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 6514304..ee47124 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -159,6 +159,12 @@
<attr name="textOff" format="reference" />
</declare-styleable>
+ <!-- For LabeledSeekBarPreference -->
+ <declare-styleable name="LabeledSeekBarPreference">
+ <attr name="textStart" format="reference" />
+ <attr name="textEnd" format="reference" />
+ </declare-styleable>
+
<declare-styleable name="TintDrawable">
<attr name="android:tint" />
<attr name="android:drawable" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e7b013a..7fe1ff7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2056,6 +2056,12 @@
<string name="wifi_dpp_failure_generic">Make sure the device has been plugged in, charged, and turned on. If the issue continues, contact the device manufacturer</string>
<!-- Hint for Wi-Fi DPP handshake failure [CHAR LIMIT=NONE] -->
<string name="wifi_dpp_failure_not_supported">Adding \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d isn\u2019t supported by this device</string>
+ <!-- Hint for Wi-Fi DPP handshake failure [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_failure_cannot_find_network">Try moving the device closer to your Wi\u2011Fi access point/router</string>
+ <!-- Hint for Wi-Fi DPP handshake failure [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_failure_enrollee_authentication">Check the password and try again</string>
+ <!-- Hint for Wi-Fi DPP handshake failure [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_failure_enrollee_rejected_configuration">Contact the device manufacturer</string>
<!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] -->
<string name="wifi_dpp_check_connection_try_again">Check connection and try again</string>
<!-- Title for the fragment choose network [CHAR LIMIT=50] -->
diff --git a/res/xml/gesture_navigation_settings.xml b/res/xml/gesture_navigation_settings.xml
index 2751f88..6230054 100644
--- a/res/xml/gesture_navigation_settings.xml
+++ b/res/xml/gesture_navigation_settings.xml
@@ -28,17 +28,21 @@
android:persistent="false"
android:title="@string/back_sensitivity_dialog_title">
- <com.android.settings.gestures.GestureNavigationSeekBarPreference
+ <com.android.settings.widget.LabeledSeekBarPreference
android:key="gesture_left_back_sensitivity"
android:title="@string/left_edge"
android:max="3"
- android:selectable="true"/>
+ android:selectable="true"
+ settings:textStart="@string/low_label"
+ settings:textEnd="@string/high_label"/>
- <com.android.settings.gestures.GestureNavigationSeekBarPreference
+ <com.android.settings.widget.LabeledSeekBarPreference
android:key="gesture_right_back_sensitivity"
android:title="@string/right_edge"
android:max="3"
- android:selectable="true"/>
+ android:selectable="true"
+ settings:textStart="@string/low_label"
+ settings:textEnd="@string/high_label"/>
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
diff --git a/src/com/android/settings/gestures/GestureNavigationSeekBarPreference.java b/src/com/android/settings/gestures/GestureNavigationSeekBarPreference.java
deleted file mode 100644
index 085411b..0000000
--- a/src/com/android/settings/gestures/GestureNavigationSeekBarPreference.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.gestures;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.SeekBar;
-
-import androidx.core.content.res.TypedArrayUtils;
-
-import com.android.settings.R;
-import com.android.settings.widget.SeekBarPreference;
-
-/** A slider preference that is used to set the back gesture's sensitivity **/
-public class GestureNavigationSeekBarPreference extends SeekBarPreference {
-
- private OnPreferenceChangeListener mStopListener;
-
- public GestureNavigationSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
- int defStyleRes) {
-
- super(context, attrs, defStyleAttr, defStyleRes);
- setLayoutResource(R.layout.preference_gesture_navigation_slider);
- }
-
- public GestureNavigationSeekBarPreference(Context context, AttributeSet attrs) {
- this(context, attrs, TypedArrayUtils.getAttr(context,
- androidx.preference.R.attr.seekBarPreferenceStyle,
- com.android.internal.R.attr.seekBarPreferenceStyle), 0);
- }
-
- public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) {
- mStopListener = listener;
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- super.onStopTrackingTouch(seekBar);
-
- if (mStopListener != null) {
- mStopListener.onPreferenceChange(this, seekBar.getProgress());
- }
- }
-}
-
diff --git a/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java b/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
index c209c81..73d7b85 100644
--- a/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
+++ b/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
@@ -25,6 +25,7 @@
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.widget.LabeledSeekBarPreference;
import com.android.settingslib.search.SearchIndexable;
/**
@@ -108,7 +109,7 @@
}
private void initSeekBarPreference(final String key) {
- final GestureNavigationSeekBarPreference pref = getPreferenceScreen().findPreference(key);
+ final LabeledSeekBarPreference pref = getPreferenceScreen().findPreference(key);
pref.setContinuousUpdates(true);
final String settingsKey = key == LEFT_EDGE_SEEKBAR_KEY
diff --git a/src/com/android/settings/widget/LabeledSeekBarPreference.java b/src/com/android/settings/widget/LabeledSeekBarPreference.java
new file mode 100644
index 0000000..e2b2d68
--- /dev/null
+++ b/src/com/android/settings/widget/LabeledSeekBarPreference.java
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import androidx.core.content.res.TypedArrayUtils;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+
+/** A slider preference with left and right labels **/
+public class LabeledSeekBarPreference extends SeekBarPreference {
+
+ private final int mTextStartId;
+ private final int mTextEndId;
+ private OnPreferenceChangeListener mStopListener;
+
+ public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+
+ super(context, attrs, defStyleAttr, defStyleRes);
+ setLayoutResource(R.layout.preference_labeled_slider);
+
+ final TypedArray styledAttrs = context.obtainStyledAttributes(attrs,
+ R.styleable.LabeledSeekBarPreference);
+ mTextStartId = styledAttrs.getResourceId(
+ R.styleable.LabeledSeekBarPreference_textStart,
+ R.string.summary_placeholder);
+ mTextEndId = styledAttrs.getResourceId(
+ R.styleable.LabeledSeekBarPreference_textEnd,
+ R.string.summary_placeholder);
+ styledAttrs.recycle();
+ }
+
+ public LabeledSeekBarPreference(Context context, AttributeSet attrs) {
+ this(context, attrs, TypedArrayUtils.getAttr(context,
+ androidx.preference.R.attr.seekBarPreferenceStyle,
+ com.android.internal.R.attr.seekBarPreferenceStyle), 0);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+
+ final TextView startText = (TextView) holder.findViewById(android.R.id.text1);
+ final TextView endText = (TextView) holder.findViewById(android.R.id.text2);
+ startText.setText(mTextStartId);
+ endText.setText(mTextEndId);
+ }
+
+ public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) {
+ mStopListener = listener;
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ super.onStopTrackingTouch(seekBar);
+
+ if (mStopListener != null) {
+ mStopListener.onPreferenceChange(this, seekBar.getProgress());
+ }
+ }
+}
+
diff --git a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
index f7e8936..caba227 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
@@ -24,6 +24,7 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
+import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -61,8 +62,22 @@
}
@Override
- public void onFailure(int code) {
- Log.d(TAG, "EasyConnectConfiguratorStatusCallback.onFailure " + code);
+ public void onFailure(int code, String ssid, SparseArray<int[]> channelListArray,
+ int[] operatingClassArray) {
+ Log.d(TAG, "EasyConnectConfiguratorStatusCallback.onFailure: " + code);
+ if (!TextUtils.isEmpty(ssid)) {
+ Log.d(TAG, "Tried SSID: " + ssid);
+ }
+ if (channelListArray.size() != 0) {
+ Log.d(TAG, "Tried channels: " + channelListArray);
+ }
+ if (operatingClassArray != null && operatingClassArray.length > 0) {
+ StringBuilder sb = new StringBuilder("Supported bands: ");
+ for (int i = 0; i < operatingClassArray.length; i++) {
+ sb.append(operatingClassArray[i] + " ");
+ }
+ Log.d(TAG, sb.toString());
+ }
showErrorUi(code, /* isConfigurationChange */ false);
}
@@ -150,6 +165,20 @@
throw(new IllegalStateException("Wi-Fi DPP configurator used a non-PSK/non-SAE"
+ "network to handshake"));
+ case EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_CANNOT_FIND_NETWORK:
+ summaryCharSequence = getText(R.string.wifi_dpp_failure_cannot_find_network);
+ break;
+
+ case EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_ENROLLEE_AUTHENTICATION:
+ summaryCharSequence = getText(R.string.wifi_dpp_failure_enrollee_authentication);
+ break;
+
+ case EasyConnectStatusCallback
+ .EASY_CONNECT_EVENT_FAILURE_ENROLLEE_REJECTED_CONFIGURATION:
+ summaryCharSequence =
+ getText(R.string.wifi_dpp_failure_enrollee_rejected_configuration);
+ break;
+
default:
throw(new IllegalStateException("Unexpected Wi-Fi DPP error"));
}
@@ -218,7 +247,8 @@
if (code == WifiDppUtils.EASY_CONNECT_EVENT_SUCCESS) {
new EasyConnectConfiguratorStatusCallback().onConfiguratorSuccess(code);
} else {
- new EasyConnectConfiguratorStatusCallback().onFailure(code);
+ new EasyConnectConfiguratorStatusCallback().onFailure(code, model.getTriedSsid(),
+ model.getTriedChannels(), model.getBandArray());
}
});
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppInitiatorViewModel.java b/src/com/android/settings/wifi/dpp/WifiDppInitiatorViewModel.java
index f48ec7c..05febc5 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppInitiatorViewModel.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppInitiatorViewModel.java
@@ -19,14 +19,18 @@
import android.app.Application;
import android.net.wifi.EasyConnectStatusCallback;
import android.net.wifi.WifiManager;
+import android.util.SparseArray;
-import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.AndroidViewModel;
+import androidx.lifecycle.MutableLiveData;
public class WifiDppInitiatorViewModel extends AndroidViewModel {
private MutableLiveData<Integer> mEnrolleeSuccessNetworkId;
private MutableLiveData<Integer> mStatusCode;
private boolean mIsWifiDppHandshaking;
+ private String mTriedSsid;
+ private SparseArray<int[]> mTriedChannels;
+ private int[] mBandArray;
public WifiDppInitiatorViewModel(Application application) {
super(application);
@@ -48,6 +52,18 @@
return mStatusCode;
}
+ String getTriedSsid() {
+ return mTriedSsid;
+ }
+
+ SparseArray<int[]> getTriedChannels() {
+ return mTriedChannels;
+ }
+
+ int[] getBandArray() {
+ return mBandArray;
+ }
+
boolean isWifiDppHandshaking() {
return mIsWifiDppHandshaking;
}
@@ -83,8 +99,12 @@
}
@Override
- public void onFailure(int code) {
+ public void onFailure(int code, String ssid, SparseArray<int[]> channelListArray,
+ int[] operatingClassArray) {
mIsWifiDppHandshaking = false;
+ mTriedSsid = ssid;
+ mTriedChannels = channelListArray;
+ mBandArray = operatingClassArray;
mStatusCode.setValue(code);
}
diff --git a/tests/robotests/src/com/android/settings/gestures/GestureNavigationSeekBarPreferenceTest.java b/tests/robotests/src/com/android/settings/gestures/LabeledSeekBarPreferenceTest.java
similarity index 89%
rename from tests/robotests/src/com/android/settings/gestures/GestureNavigationSeekBarPreferenceTest.java
rename to tests/robotests/src/com/android/settings/gestures/LabeledSeekBarPreferenceTest.java
index 82c3262..4fb94f8 100644
--- a/tests/robotests/src/com/android/settings/gestures/GestureNavigationSeekBarPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/LabeledSeekBarPreferenceTest.java
@@ -27,6 +27,8 @@
import androidx.preference.Preference;
+import com.android.settings.widget.LabeledSeekBarPreference;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,11 +38,11 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
-public class GestureNavigationSeekBarPreferenceTest {
+public class LabeledSeekBarPreferenceTest {
private Context mContext;
private SeekBar mSeekBar;
- private GestureNavigationSeekBarPreference mSeekBarPreference;
+ private LabeledSeekBarPreference mSeekBarPreference;
@Mock
private Preference.OnPreferenceChangeListener mListener;
@@ -50,7 +52,7 @@
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mSeekBarPreference = new GestureNavigationSeekBarPreference(mContext, null);
+ mSeekBarPreference = new LabeledSeekBarPreference(mContext, null);
LayoutInflater inflater = LayoutInflater.from(mContext);
final View view =
inflater.inflate(mSeekBarPreference.getLayoutResource(),