Merge "Update enrollment with API update" into rvc-dev
diff --git a/res/drawable/accessibility_shortcut_type_hardware.png b/res/drawable/accessibility_shortcut_type_hardware.png
index 141af83..664ceb3 100644
--- a/res/drawable/accessibility_shortcut_type_hardware.png
+++ b/res/drawable/accessibility_shortcut_type_hardware.png
Binary files differ
diff --git a/res/drawable/accessibility_shortcut_type_software.png b/res/drawable/accessibility_shortcut_type_software.png
index 5b0611d..0212548 100644
--- a/res/drawable/accessibility_shortcut_type_software.png
+++ b/res/drawable/accessibility_shortcut_type_software.png
Binary files differ
diff --git a/res/drawable/accessibility_shortcut_type_software_gesture.png b/res/drawable/accessibility_shortcut_type_software_gesture.png
index a5df752..0a2921a 100644
--- a/res/drawable/accessibility_shortcut_type_software_gesture.png
+++ b/res/drawable/accessibility_shortcut_type_software_gesture.png
Binary files differ
diff --git a/res/drawable/accessibility_shortcut_type_software_gesture_talkback.png b/res/drawable/accessibility_shortcut_type_software_gesture_talkback.png
index a8d86aa..85fec85 100644
--- a/res/drawable/accessibility_shortcut_type_software_gesture_talkback.png
+++ b/res/drawable/accessibility_shortcut_type_software_gesture_talkback.png
Binary files differ
diff --git a/res/drawable/accessibility_shortcut_type_triple_tap.png b/res/drawable/accessibility_shortcut_type_triple_tap.png
index 5c6ce95..6a08d29 100644
--- a/res/drawable/accessibility_shortcut_type_triple_tap.png
+++ b/res/drawable/accessibility_shortcut_type_triple_tap.png
Binary files differ
diff --git a/res/drawable/ic_accessibility_new.xml b/res/drawable/ic_accessibility_new.xml
index 6bfc6c6..1347239 100644
--- a/res/drawable/ic_accessibility_new.xml
+++ b/res/drawable/ic_accessibility_new.xml
@@ -18,7 +18,8 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
- android:viewportHeight="24">
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#757575"
android:pathData="M20.5,6c-2.61,0.7 -5.67,1 -8.5,1s-5.89,-0.3 -8.5,-1L3,8c1.86,0.5 4,0.83 6,1v13h2v-6h2v6h2V9c2,-0.17 4.14,-0.5 6,-1l-0.5,-2zM12,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z"/>
diff --git a/res/layout/accessibility_edit_shortcut.xml b/res/layout/accessibility_edit_shortcut.xml
index 753adb1b..412ce94 100644
--- a/res/layout/accessibility_edit_shortcut.xml
+++ b/res/layout/accessibility_edit_shortcut.xml
@@ -22,19 +22,19 @@
android:scrollbarStyle="outsideOverlay">
<LinearLayout
- android:theme="@style/Theme.AlertDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="24dp"
- android:paddingStart="24dp"
- android:paddingEnd="24dp">
+ android:padding="24dp">
<include android:id="@+id/software_shortcut"
- layout="@layout/accessibility_edit_shortcut_component"/>
+ layout="@layout/accessibility_edit_shortcut_component"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="32dp" />
<include android:id="@+id/hardware_shortcut"
- layout="@layout/accessibility_edit_shortcut_component"/>
+ layout="@layout/accessibility_edit_shortcut_component" />
</LinearLayout>
diff --git a/res/layout/accessibility_edit_shortcut_component.xml b/res/layout/accessibility_edit_shortcut_component.xml
index dd92a1d..02938c3 100644
--- a/res/layout/accessibility_edit_shortcut_component.xml
+++ b/res/layout/accessibility_edit_shortcut_component.xml
@@ -19,32 +19,32 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingBottom="16dp">
+ android:orientation="vertical">
<CheckBox
android:id="@+id/checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:paddingStart="12dp"
android:saveEnabled="false"
- android:textAppearance="?android:attr/textAppearanceListItem"
- android:textColor="?android:attr/textColorAlertDialogListItem" />
+ android:textColor="?android:attr/textColorAlertDialogListItem"
+ android:textSize="16sp" />
<TextView
android:id="@+id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
- android:paddingStart="32dp"
+ android:paddingStart="44dp"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary" />
<ImageView
android:id="@+id/image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingStart="32dp"
- android:scaleType="fitCenter" />
+ android:layout_width="176dp"
+ android:layout_height="176dp"
+ android:layout_marginStart="44dp"
+ android:scaleType="centerCrop" />
</LinearLayout>
diff --git a/res/layout/accessibility_edit_shortcut_magnification.xml b/res/layout/accessibility_edit_shortcut_magnification.xml
index 8a724cc..afb1ec8 100644
--- a/res/layout/accessibility_edit_shortcut_magnification.xml
+++ b/res/layout/accessibility_edit_shortcut_magnification.xml
@@ -15,26 +15,30 @@
limitations under the License
-->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay">
<LinearLayout
- android:theme="@style/Theme.AlertDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="24dp"
- android:paddingStart="24dp"
- android:paddingEnd="24dp">
+ android:padding="24dp">
- <include android:id="@+id/software_shortcut"
- layout="@layout/accessibility_edit_shortcut_component"/>
+ <include
+ android:id="@+id/software_shortcut"
+ layout="@layout/accessibility_edit_shortcut_component"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="32dp" />
- <include android:id="@+id/hardware_shortcut"
- layout="@layout/accessibility_edit_shortcut_component"/>
+ <include
+ android:id="@+id/hardware_shortcut"
+ layout="@layout/accessibility_edit_shortcut_component"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="32dp" />
<LinearLayout
android:id="@+id/advanced_shortcut"
@@ -45,24 +49,27 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:src="@drawable/ic_keyboard_arrow_down"
- android:scaleType="fitCenter"/>
+ android:scaleType="fitCenter"
+ android:src="@drawable/ic_keyboard_arrow_down" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:paddingStart="12dp"
android:text="@string/accessibility_shortcut_edit_dialog_title_advance"
android:textAppearance="?android:attr/textAppearanceListItem"
- android:textColor="?android:attr/colorAccent" />
+ android:textColor="?android:attr/colorAccent"
+ android:textSize="16sp" />
- </LinearLayout>>
+ </LinearLayout>
- <include android:id="@+id/triple_tap_shortcut"
- layout="@layout/accessibility_edit_shortcut_component"
- android:visibility="gone"/>
+ <include
+ android:id="@+id/triple_tap_shortcut"
+ layout="@layout/accessibility_edit_shortcut_component"
+ android:visibility="gone" />
</LinearLayout>
-</ScrollView>
\ No newline at end of file
+</ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 618b77b..608eac8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11117,6 +11117,9 @@
<!-- Summary for media output group with the active device count [CHAR LIMIT=NONE] -->
<string name="media_output_group_panel_multiple_devices_summary"><xliff:g id="count" example="2">%1$d</xliff:g> devices selected</string>
+ <!-- Summary for media output switching output [CHAR LIMIT=50] -->
+ <string name="media_output_switching">Switching\u2026</string>
+
<!-- Title for HFP(hands free profile) output switch button in settings. -->
<string name="take_call_on_title">Take call on</string>
diff --git a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
index c96013f..fbe1e77 100644
--- a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
+++ b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
@@ -285,7 +285,6 @@
final Drawable icon = context.getDrawable(R.drawable.ic_accessibility_new);
final ImageSpan imageSpan = new ImageSpan(icon);
imageSpan.setContentDescription("");
- icon.setTint(getThemeAttrColor(context, android.R.attr.textColorPrimary));
icon.setBounds(0, 0, lineHeight, lineHeight);
spannableMessage.setSpan(
imageSpan, indexIconStart, indexIconEnd,
diff --git a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
index 0c8644f..ddf7bd4 100644
--- a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
+++ b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
@@ -178,7 +178,6 @@
final Drawable icon = context.getDrawable(R.drawable.ic_accessibility_new);
final ImageSpan imageSpan = new ImageSpan(icon);
imageSpan.setContentDescription("");
- icon.setTint(getThemeAttrColor(context, android.R.attr.textColorPrimary));
icon.setBounds(0, 0, lineHeight, lineHeight);
spannableMessage.setSpan(
imageSpan, indexIconStart, indexIconEnd,
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index ec5784e..c0ad2ac 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -43,7 +43,6 @@
public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
- private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
private final Handler mHandler = new Handler();
private SettingsContentObserver mSettingsContentObserver;
@@ -117,7 +116,7 @@
@Override
public void onSettingsClicked(ShortcutPreference preference) {
super.onSettingsClicked(preference);
- showDialog(DIALOG_ID_EDIT_SHORTCUT);
+ showDialog(DialogEnums.EDIT_SHORTCUT);
}
private void updateSwitchBarToggleSwitch() {
diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
index c226cb0..7557fd9 100644
--- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java
+++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
@@ -174,6 +174,10 @@
return mLocalMediaManager.getSessionVolume();
}
+ CharSequence getSessionName() {
+ return mLocalMediaManager.getSessionName();
+ }
+
/**
* Find the active MediaDevice.
*
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index f5fff1c..e852b80 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -25,6 +25,7 @@
import android.provider.SettingsSlicesContract;
import android.telephony.TelephonyManager;
+import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -70,6 +71,11 @@
mFragment = hostFragment;
}
+ @VisibleForTesting
+ void setAirplaneModeEnabler(AirplaneModeEnabler airplaneModeEnabler) {
+ mAirplaneModeEnabler = airplaneModeEnabler;
+ }
+
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY_AIRPLANE_MODE.equals(preference.getKey())
diff --git a/src/com/android/settings/notification/history/HistoryLoader.java b/src/com/android/settings/notification/history/HistoryLoader.java
index 046b5ef..461bbc1 100644
--- a/src/com/android/settings/notification/history/HistoryLoader.java
+++ b/src/com/android/settings/notification/history/HistoryLoader.java
@@ -22,6 +22,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.UserHandle;
+import android.util.Slog;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.utils.ThreadUtils;
@@ -33,6 +34,7 @@
import java.util.Map;
public class HistoryLoader {
+ private static final String TAG = "HistoryLoader";
private final Context mContext;
private final NotificationBackend mBackend;
private final PackageManager mPm;
@@ -45,45 +47,48 @@
public void load(OnHistoryLoaderListener listener) {
ThreadUtils.postOnBackgroundThread(() -> {
- Map<String, NotificationHistoryPackage> historicalNotifications = new HashMap<>();
- NotificationHistory history =
- mBackend.getNotificationHistory(mContext.getPackageName());
+ try {
+ Map<String, NotificationHistoryPackage> historicalNotifications = new HashMap<>();
+ NotificationHistory history =
+ mBackend.getNotificationHistory(mContext.getPackageName());
+ while (history.hasNextNotification()) {
+ HistoricalNotification hn = history.getNextNotification();
- while (history.hasNextNotification()) {
- HistoricalNotification hn = history.getNextNotification();
-
- String key = hn.getPackage() + "|" + hn.getUid();
- NotificationHistoryPackage hnsForPackage = historicalNotifications.getOrDefault(
- key,
- new NotificationHistoryPackage(hn.getPackage(), hn.getUid()));
- hnsForPackage.notifications.add(hn);
- historicalNotifications.put(key, hnsForPackage);
- }
- List<NotificationHistoryPackage> packages =
- new ArrayList<>(historicalNotifications.values());
- Collections.sort(packages,
- (o1, o2) -> -1 * Long.compare(o1.getMostRecent(), o2.getMostRecent()));
- for (NotificationHistoryPackage nhp : packages) {
- ApplicationInfo info;
- try {
- info = mPm.getApplicationInfoAsUser(
- nhp.pkgName,
- PackageManager.MATCH_UNINSTALLED_PACKAGES
- | PackageManager.MATCH_DISABLED_COMPONENTS
- | PackageManager.MATCH_DIRECT_BOOT_UNAWARE
- | PackageManager.MATCH_DIRECT_BOOT_AWARE,
- UserHandle.getUserId(nhp.uid));
- if (info != null) {
- nhp.label = String.valueOf(mPm.getApplicationLabel(info));
- nhp.icon = mPm.getUserBadgedIcon(mPm.getApplicationIcon(info),
- UserHandle.of(UserHandle.getUserId(nhp.uid)));
- }
- } catch (PackageManager.NameNotFoundException e) {
- // app is gone, just show package name and generic icon
- nhp.icon = mPm.getDefaultActivityIcon();
+ String key = hn.getPackage() + "|" + hn.getUid();
+ NotificationHistoryPackage hnsForPackage = historicalNotifications.getOrDefault(
+ key,
+ new NotificationHistoryPackage(hn.getPackage(), hn.getUid()));
+ hnsForPackage.notifications.add(hn);
+ historicalNotifications.put(key, hnsForPackage);
}
+ List<NotificationHistoryPackage> packages =
+ new ArrayList<>(historicalNotifications.values());
+ Collections.sort(packages,
+ (o1, o2) -> -1 * Long.compare(o1.getMostRecent(), o2.getMostRecent()));
+ for (NotificationHistoryPackage nhp : packages) {
+ ApplicationInfo info;
+ try {
+ info = mPm.getApplicationInfoAsUser(
+ nhp.pkgName,
+ PackageManager.MATCH_UNINSTALLED_PACKAGES
+ | PackageManager.MATCH_DISABLED_COMPONENTS
+ | PackageManager.MATCH_DIRECT_BOOT_UNAWARE
+ | PackageManager.MATCH_DIRECT_BOOT_AWARE,
+ UserHandle.getUserId(nhp.uid));
+ if (info != null) {
+ nhp.label = String.valueOf(mPm.getApplicationLabel(info));
+ nhp.icon = mPm.getUserBadgedIcon(mPm.getApplicationIcon(info),
+ UserHandle.of(UserHandle.getUserId(nhp.uid)));
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ // app is gone, just show package name and generic icon
+ nhp.icon = mPm.getDefaultActivityIcon();
+ }
+ }
+ ThreadUtils.postOnMainThread(() -> listener.onHistoryLoaded(packages));
+ } catch (Exception e) {
+ Slog.e(TAG, "Error loading history", e);
}
- ThreadUtils.postOnMainThread(() -> listener.onHistoryLoaded(packages));
});
}
diff --git a/src/com/android/settings/security/ConfirmSimDeletionPreferenceController.java b/src/com/android/settings/security/ConfirmSimDeletionPreferenceController.java
index f24d8db..8d093c0 100644
--- a/src/com/android/settings/security/ConfirmSimDeletionPreferenceController.java
+++ b/src/com/android/settings/security/ConfirmSimDeletionPreferenceController.java
@@ -24,11 +24,13 @@
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
-import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.telephony.MobileNetworkUtils;
+import com.android.settings.wifi.dpp.WifiDppUtils;
/** Enable/disable user confirmation before deleting an eSim */
-public class ConfirmSimDeletionPreferenceController extends TogglePreferenceController {
+public class ConfirmSimDeletionPreferenceController extends BasePreferenceController implements
+ Preference.OnPreferenceChangeListener{
public static final String KEY_CONFIRM_SIM_DELETION = "confirm_sim_deletion";
private boolean mConfirmationDefaultOn;
@@ -53,21 +55,39 @@
== 1;
}
- @Override
public boolean isChecked() {
return getGlobalState();
}
- @Override
public boolean setChecked(boolean isChecked) {
Settings.Global.putInt(
mContext.getContentResolver(), KEY_CONFIRM_SIM_DELETION, isChecked ? 1 : 0);
return true;
}
+ // handle UI change
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (!preference.getKey().equals(getPreferenceKey())) {
+ return false;
+ }
+ if (!isChecked()) {
+ setChecked(true);
+ return true;
+ } else {
+ // prevent disabling the feature until authorized
+ WifiDppUtils.showLockScreen(mContext, () -> {
+ // set data
+ setChecked(false);
+ // set UI
+ ((TwoStatePreference) preference).setChecked(false);
+ });
+ return false;
+ }
+ }
+
@Override
public void updateState(Preference preference) {
-
final KeyguardManager keyguardManager = mContext.getSystemService(KeyguardManager.class);
if (!keyguardManager.isKeyguardSecure()) {
preference.setEnabled(false);
diff --git a/src/com/android/settings/wifi/ConnectedWifiEntryPreference.java b/src/com/android/settings/wifi/ConnectedWifiEntryPreference.java
new file mode 100644
index 0000000..f79499a
--- /dev/null
+++ b/src/com/android/settings/wifi/ConnectedWifiEntryPreference.java
@@ -0,0 +1,92 @@
+/*
+ * 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.wifi;
+
+import android.content.Context;
+import android.view.View;
+
+import androidx.fragment.app.Fragment;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settingslib.R;
+import com.android.settingslib.wifi.LongPressWifiEntryPreference;
+import com.android.wifitrackerlib.WifiEntry;
+
+/**
+ * An AP preference for the currently connected AP.
+ */
+public class ConnectedWifiEntryPreference extends LongPressWifiEntryPreference implements
+ View.OnClickListener {
+
+ private OnGearClickListener mOnGearClickListener;
+
+ public ConnectedWifiEntryPreference(Context context, WifiEntry wifiEntry, Fragment fragment) {
+ super(context, wifiEntry, fragment);
+ setWidgetLayoutResource(R.layout.preference_widget_gear_optional_background);
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh();
+
+ if (getWifiEntry().canSignIn()) {
+ setSummary(R.string.wifi_tap_to_sign_in);
+ }
+ }
+
+ /**
+ * Set gear icon click callback listener.
+ */
+ public void setOnGearClickListener(OnGearClickListener l) {
+ mOnGearClickListener = l;
+ notifyChanged();
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+
+ final View gear = holder.findViewById(R.id.settings_button);
+ gear.setOnClickListener(this);
+
+ final boolean canSignIn = getWifiEntry().canSignIn();
+ holder.findViewById(R.id.settings_button_no_background).setVisibility(
+ canSignIn ? View.INVISIBLE : View.VISIBLE);
+ gear.setVisibility(canSignIn ? View.VISIBLE : View.INVISIBLE);
+ holder.findViewById(R.id.two_target_divider).setVisibility(
+ canSignIn ? View.VISIBLE : View.INVISIBLE);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.settings_button) {
+ if (mOnGearClickListener != null) {
+ mOnGearClickListener.onGearClick(this);
+ }
+ }
+ }
+
+ /**
+ * Gear Icon click callback interface.
+ */
+ public interface OnGearClickListener {
+ /**
+ * The callback triggered when gear icon is clicked.
+ */
+ void onGearClick(ConnectedWifiEntryPreference p);
+ }
+
+}
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index f88a4df..5152569 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -711,8 +711,8 @@
mConnectedWifiEntryPreferenceCategory.findPreference(connectedEntry.getKey());
if (connectedPref == null || connectedPref.getWifiEntry() != connectedEntry) {
mConnectedWifiEntryPreferenceCategory.removeAll();
- final LongPressWifiEntryPreference pref =
- createLongPressWifiEntryPreference(connectedEntry);
+ final ConnectedWifiEntryPreference pref =
+ new ConnectedWifiEntryPreference(getPrefContext(), connectedEntry, this);
pref.setKey(connectedEntry.getKey());
pref.refresh();
mConnectedWifiEntryPreferenceCategory.addPreference(pref);
@@ -724,6 +724,9 @@
}
return true;
});
+ pref.setOnGearClickListener(preference -> {
+ launchNetworkDetailsFragment(pref);
+ });
}
} else {
mConnectedWifiEntryPreferenceCategory.removeAll();
diff --git a/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java
index 597e94e..714ef9a 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java
@@ -21,7 +21,6 @@
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.LinearLayout;
import androidx.preference.PreferenceViewHolder;
@@ -37,7 +36,7 @@
@RunWith(RobolectricTestRunner.class)
public class ShortcutPreferenceTest {
- private static final String CHECKBOX_CLICKED = "checkbox_clicked";
+ private static final String TOGGLE_CLICKED = "toggle_clicked";
private static final String SETTINGS_CLICKED = "settings_clicked";
private ShortcutPreference mShortcutPreference;
@@ -48,7 +47,7 @@
new ShortcutPreference.OnClickCallback() {
@Override
public void onToggleClicked(ShortcutPreference preference) {
- mResult = CHECKBOX_CLICKED;
+ mResult = TOGGLE_CLICKED;
}
@Override
@@ -69,14 +68,13 @@
}
@Test
- public void clickLinearLayout_checkboxClicked() {
+ public void clickToggle_toggleClicked() {
mShortcutPreference.onBindViewHolder(mPreferenceViewHolder);
mShortcutPreference.setOnClickCallback(mListener);
- LinearLayout mainFrame = mPreferenceViewHolder.itemView.findViewById(R.id.main_frame);
- mainFrame.performClick();
+ mPreferenceViewHolder.itemView.performClick();
- assertThat(mResult).isEqualTo(CHECKBOX_CLICKED);
+ assertThat(mResult).isEqualTo(TOGGLE_CLICKED);
assertThat(mShortcutPreference.isChecked()).isTrue();
}
@@ -85,14 +83,14 @@
mShortcutPreference.onBindViewHolder(mPreferenceViewHolder);
mShortcutPreference.setOnClickCallback(mListener);
- View settings = mPreferenceViewHolder.itemView.findViewById(android.R.id.widget_frame);
+ final View settings = mPreferenceViewHolder.itemView.findViewById(R.id.main_frame);
settings.performClick();
assertThat(mResult).isEqualTo(SETTINGS_CLICKED);
}
@Test
- public void setCheckedTrue_getCheckedIsTrue() {
+ public void setCheckedTrue_getToggleIsTrue() {
mShortcutPreference.setChecked(true);
assertThat(mShortcutPreference.isChecked()).isEqualTo(true);
diff --git a/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
index bc495f6..4276407 100644
--- a/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
@@ -38,6 +38,7 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -80,6 +81,7 @@
}
@Test
+ @Ignore
public void onPreferenceChange_bluetoothConnected_shouldUpdateCodec() {
mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -98,6 +100,7 @@
}
@Test
+ @Ignore
public void updateState_option2Set_shouldUpdateToOption2() {
when(mBluetoothCodecConfig.getSampleRate()).thenReturn(
BluetoothCodecConfig.SAMPLE_RATE_48000);
diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
index e558d62..1e59167 100644
--- a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
+++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
@@ -88,11 +88,11 @@
public void setUp() throws RemoteException, NameNotFoundException {
MockitoAnnotations.initMocks(this);
mChanges = new CompatibilityChangeInfo[5];
- mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, false, "");
- mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, true, "");
- mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_After_SDK_1_1", 1, false, "");
- mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_After_SDK_1_2", 1, false, "");
- mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_After_SDK_2", 2, false, "");
+ mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, false, false, "");
+ mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, true, false, "");
+ mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_After_SDK_1_1", 1, false, false, "");
+ mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_After_SDK_1_2", 1, false, false, "");
+ mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_After_SDK_2", 2, false, false, "");
when(mPlatformCompat.listAllChanges()).thenReturn(mChanges);
when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator);
// By default, allow any change
@@ -205,7 +205,7 @@
for (int i = 0; i < mChanges.length; ++i) {
changesToAdd.add(new CompatibilityChangeInfo(mChanges[i].getId(), mChanges[i].getName(),
mChanges[i].getEnableAfterTargetSdk(), mChanges[i].getDisabled(),
- mChanges[i].getDescription()));
+ mChanges[i].getLoggingOnly(), mChanges[i].getDescription()));
}
PreferenceCategory category = mDashboard.createChangeCategoryPreference(changesToAdd,
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
index 964fce3..87f59f2 100644
--- a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
@@ -92,7 +92,7 @@
public void onPreferenceChange_turnOn_returnOn() {
mController.onPreferenceChange(null, true);
- final int mode = Settings.System.getInt(mContentResolver, ADAPTIVE_SLEEP, 0);
+ final int mode = Settings.Secure.getInt(mContentResolver, ADAPTIVE_SLEEP, 0);
assertThat(mode).isEqualTo(1);
}
@@ -100,7 +100,7 @@
public void onPreferenceChange_turnOff_returnOff() {
mController.onPreferenceChange(null, false);
- final int mode = Settings.System.getInt(mContentResolver, ADAPTIVE_SLEEP, 1);
+ final int mode = Settings.Secure.getInt(mContentResolver, ADAPTIVE_SLEEP, 1);
assertThat(mode).isEqualTo(0);
}
@@ -124,7 +124,7 @@
@Test
public void isChecked_yes() {
- Settings.System.putInt(mContentResolver, ADAPTIVE_SLEEP, 1);
+ Settings.Secure.putInt(mContentResolver, ADAPTIVE_SLEEP, 1);
assertThat(mController.isChecked()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
index 9924cb4..0738fe0 100644
--- a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
@@ -16,10 +16,19 @@
package com.android.settings.display;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
import android.content.Context;
+
import androidx.fragment.app.Fragment;
+
import com.android.settings.display.darkmode.DarkModePreference;
+
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -27,11 +36,8 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class DarkUIPreferenceControllerTest {
private DarkUIPreferenceController mController;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
index 63e8a80..cda5f96 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
@@ -50,6 +50,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -62,6 +63,7 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowEntityHeaderController.class)
+@Ignore
public class BatteryHeaderPreferenceControllerTest {
private static final String PREF_KEY = "battery_header";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
index 55020e2..b9f4e06 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
@@ -28,6 +28,7 @@
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -41,6 +42,7 @@
import java.util.concurrent.TimeUnit;
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class LowBatteryDetectorTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java
index e4ca6c0..20bc1bb 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java
@@ -29,6 +29,7 @@
import com.android.settings.fuelgauge.BatterySaverReceiver;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -39,6 +40,7 @@
import org.robolectric.shadows.ShadowPowerManager;
@RunWith(RobolectricTestRunner.class)
+@Ignore
public class BatterySaverConditionControllerTest {
@Mock
private ConditionManager mConditionManager;
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
index f71c090..0f54cfb 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
@@ -50,6 +50,7 @@
import com.android.settingslib.media.MediaDevice;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -157,6 +158,7 @@
}
@Test
+ @Ignore
public void getSlice_disconnectedBluetooth_verifyTitle() {
mDevices.clear();
final MediaDevice device = mock(MediaDevice.class);
diff --git a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
index f47c0c5..54c3683 100644
--- a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
@@ -32,13 +32,13 @@
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
+import com.android.settings.AirplaneModeEnabler;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -55,7 +55,8 @@
@Mock
private PackageManager mPackageManager;
-
+ @Mock
+ private AirplaneModeEnabler mAirplaneModeEnabler;
private Context mContext;
private ContentResolver mResolver;
private PreferenceManager mPreferenceManager;
@@ -126,38 +127,18 @@
}
@Test
- @Ignore
public void airplaneModePreference_testSetValue_updatesCorrectly() {
- // Airplane mode default off
- Settings.Global.putInt(mResolver, Settings.Global.AIRPLANE_MODE_ON, OFF);
-
- mController.displayPreference(mScreen);
- mController.onResume();
-
- assertThat(mPreference.isChecked()).isFalse();
-
- assertThat(mController.isChecked()).isFalse();
// Set airplane mode ON by setChecked
- boolean updated = mController.setChecked(true);
- assertThat(updated).isTrue();
+ mController.setAirplaneModeEnabler(mAirplaneModeEnabler);
+ assertThat(mController.setChecked(true)).isTrue();
// Check return value if set same status.
- updated = mController.setChecked(true);
- assertThat(updated).isFalse();
-
- // UI is updated
- assertThat(mPreference.isChecked()).isTrue();
-
- // Settings status changed.
- int updatedValue = Settings.Global.getInt(mResolver, Settings.Global.AIRPLANE_MODE_ON, OFF);
- assertThat(updatedValue).isEqualTo(ON);
+ when(mAirplaneModeEnabler.isAirplaneModeOn()).thenReturn(true);
+ assertThat(mController.setChecked(true)).isFalse();
// Set to OFF
assertThat(mController.setChecked(false)).isTrue();
- assertThat(mPreference.isChecked()).isFalse();
- updatedValue = Settings.Global.getInt(mResolver, Settings.Global.AIRPLANE_MODE_ON, OFF);
- assertThat(updatedValue).isEqualTo(OFF);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
index e2410c1..6d46f9c 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
@@ -33,6 +33,7 @@
import android.provider.Settings;
import android.provider.Settings.Global;
import android.telephony.PhoneStateListener;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.lifecycle.LifecycleOwner;
@@ -46,7 +47,6 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -63,6 +63,8 @@
@Mock
private TelephonyManager mTelephonyManager;
@Mock
+ private SubscriptionManager mSubscriptionManager;
+ @Mock
private PreferenceScreen mScreen;
private Lifecycle mLifecycle;
@@ -77,6 +79,7 @@
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
+ when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
mPreference = new Preference(mContext);
mPreference.setKey(MobileNetworkPreferenceController.KEY_MOBILE_NETWORK_SETTINGS);
}
@@ -121,7 +124,6 @@
}
@Test
- @Ignore
public void serviceStateChange_shouldUpdatePrefSummary() {
final String testCarrierName = "test";
final Preference mPreference = mock(Preference.class);
@@ -138,8 +140,8 @@
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE);
- // Trigger listener update
- when(mTelephonyManager.getNetworkOperatorName()).thenReturn(testCarrierName);
+ doReturn(testCarrierName).when(mController).getSummary();
+
mController.mPhoneStateListener.onServiceStateChanged(null);
// Carrier name should be set.
@@ -147,7 +149,6 @@
}
@Test
- @Ignore
public void airplaneModeTurnedOn_shouldDisablePreference() {
Settings.Global.putInt(mContext.getContentResolver(),
Global.AIRPLANE_MODE_ON, 1);
@@ -158,7 +159,6 @@
}
@Test
- @Ignore
public void airplaneModeTurnedOffAndNoUserRestriction_shouldEnablePreference() {
Settings.Global.putInt(mContext.getContentResolver(),
Global.AIRPLANE_MODE_ON, 0);
@@ -170,7 +170,6 @@
}
@Test
- @Ignore
public void airplaneModeTurnedOffAndHasUserRestriction_shouldDisablePreference() {
Settings.Global.putInt(mContext.getContentResolver(),
Global.AIRPLANE_MODE_ON, 0);
diff --git a/tests/robotests/src/com/android/settings/wifi/ConnectedWifiEntryPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/ConnectedWifiEntryPreferenceTest.java
new file mode 100644
index 0000000..401fdcf
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/ConnectedWifiEntryPreferenceTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.wifi;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.wifitrackerlib.WifiEntry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConnectedWifiEntryPreferenceTest {
+
+ @Mock
+ private WifiEntry mWifiEntry;
+ @Mock
+ private View mView;
+ @Mock
+ private ConnectedWifiEntryPreference.OnGearClickListener mOnGearClickListener;
+ private Context mContext;
+ private ConnectedWifiEntryPreference mConnectedWifiEntryPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ mConnectedWifiEntryPreference = new ConnectedWifiEntryPreference(mContext, mWifiEntry,
+ null /* fragment */);
+ mConnectedWifiEntryPreference.setOnGearClickListener(mOnGearClickListener);
+ }
+
+ @Test
+ public void testOnClick_gearClicked_listenerInvoked() {
+ when(mView.getId()).thenReturn(R.id.settings_button);
+
+ mConnectedWifiEntryPreference.onClick(mView);
+
+ verify(mOnGearClickListener).onGearClick(mConnectedWifiEntryPreference);
+ }
+
+ @Test
+ public void testOnClick_gearNotClicked_listenerNotInvoked() {
+ mConnectedWifiEntryPreference.onClick(mView);
+
+ verify(mOnGearClickListener, never()).onGearClick(mConnectedWifiEntryPreference);
+ }
+
+ @Test
+ public void testWidgetLayoutPreference() {
+ assertThat(mConnectedWifiEntryPreference.getWidgetLayoutResource())
+ .isEqualTo(R.layout.preference_widget_gear_optional_background);
+ }
+}