Merge "[Telephony Setting] Add Preferred Network observer for Auto Select Network Mode" into rvc-dev
diff --git a/res/layout/contextual_slice_full_tile.xml b/res/layout/contextual_slice_full_tile.xml
index 4b1155e..b6ab410 100644
--- a/res/layout/contextual_slice_full_tile.xml
+++ b/res/layout/contextual_slice_full_tile.xml
@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/ContextualCardStyle">
+ style="@style/ContextualCardStyle"
+ android:importantForAccessibility="no">
<include layout="@layout/dismissal_swipe_background"/>
@@ -28,10 +29,9 @@
android:theme="@style/Theme.Settings.ContextualCard"
style="@style/ContextualCardSliceViewStyle"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:importantForAccessibility="no"/>
+ android:layout_height="wrap_content"/>
- <!--dismissal view-->
+ <!--dismissal view -->
<include layout="@layout/contextual_card_dismissal_view"/>
</com.google.android.material.card.MaterialCardView>
\ No newline at end of file
diff --git a/res/layout/contextual_slice_sticky_tile.xml b/res/layout/contextual_slice_sticky_tile.xml
index 5991068..2e7a2be 100644
--- a/res/layout/contextual_slice_sticky_tile.xml
+++ b/res/layout/contextual_slice_sticky_tile.xml
@@ -19,14 +19,14 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/ContextualCardStyle">
+ style="@style/ContextualCardStyle"
+ android:importantForAccessibility="no">
<androidx.slice.widget.SliceView
android:id="@+id/slice_view"
android:theme="@style/Theme.Settings.ContextualCard"
style="@style/ContextualCardSliceViewStyle"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:importantForAccessibility="no"/>
+ android:layout_height="wrap_content"/>
</com.google.android.material.card.MaterialCardView>
diff --git a/res/layout/notification_history.xml b/res/layout/notification_history.xml
index 0e7f6b0..f5fae3f 100644
--- a/res/layout/notification_history.xml
+++ b/res/layout/notification_history.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<ScrollView
+<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="match_parent"
@@ -124,22 +124,15 @@
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingBottom="16dp" />
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/list_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:clipChildren="true"
- android:elevation="3dp"
- android:background="@drawable/rounded_bg">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notification_list"
+ android:elevation="3dp"
+ android:background="@drawable/rounded_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="true"
android:scrollbars="none"/>
-
- </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<LinearLayout
@@ -156,21 +149,14 @@
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingBottom="16dp" />
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/list_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:elevation="3dp"
- android:clipChildren="true"
- android:background="@drawable/rounded_bg">
- <androidx.recyclerview.widget.RecyclerView
+ <androidx.recyclerview.widget.RecyclerView
android:id="@+id/notification_list"
+ android:elevation="3dp"
+ android:background="@drawable/rounded_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="true"
android:scrollbars="none"/>
-
- </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<LinearLayout
@@ -198,4 +184,4 @@
</LinearLayout>
</LinearLayout>
-</ScrollView>
\ No newline at end of file
+</androidx.core.widget.NestedScrollView>
\ No newline at end of file
diff --git a/res/layout/notification_history_app_layout.xml b/res/layout/notification_history_app_layout.xml
index a8757fe..e8d3316 100644
--- a/res/layout/notification_history_app_layout.xml
+++ b/res/layout/notification_history_app_layout.xml
@@ -73,18 +73,12 @@
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/list_container"
- android:layout_width="match_parent"
- android:clipChildren="true"
- android:layout_height="wrap_content">
<com.android.settings.notification.history.NotificationHistoryRecyclerView
android:id="@+id/notification_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="true"
+ android:importantForAccessibility="yes"
android:scrollbars="none"/>
- </androidx.constraintlayout.widget.ConstraintLayout>
-
</LinearLayout>
\ No newline at end of file
diff --git a/src/com/android/settings/AirplaneModeEnabler.java b/src/com/android/settings/AirplaneModeEnabler.java
index a843a04..6028c18 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -19,6 +19,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
+import android.os.Looper;
import android.os.UserHandle;
import android.provider.Settings;
import android.telephony.PhoneStateListener;
@@ -62,8 +63,6 @@
@VisibleForTesting
PhoneStateListener mPhoneStateListener;
- private GlobalSettingsChangeListener mAirplaneModeObserver;
-
public AirplaneModeEnabler(Context context, OnAirplaneModeChangedListener listener) {
super(context, Settings.Global.AIRPLANE_MODE_ON);
@@ -73,7 +72,7 @@
mTelephonyManager = context.getSystemService(TelephonyManager.class);
- mPhoneStateListener = new PhoneStateListener() {
+ mPhoneStateListener = new PhoneStateListener(Looper.getMainLooper()) {
@Override
public void onRadioPowerStateChanged(int state) {
if (DEBUG) {
@@ -87,6 +86,7 @@
/**
* Implementation of GlobalSettingsChangeListener.onChanged
*/
+ @Override
public void onChanged(String field) {
if (DEBUG) {
Log.d(LOG_TAG, "Airplane mode configuration update");
@@ -94,12 +94,18 @@
onAirplaneModeChanged();
}
- public void resume() {
+ /**
+ * Start listening to the phone state change
+ */
+ public void start() {
mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED);
}
- public void pause() {
+ /**
+ * Stop listening to the phone state change
+ */
+ public void stop() {
mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_NONE);
}
diff --git a/src/com/android/settings/backup/UserBackupSettingsActivity.java b/src/com/android/settings/backup/UserBackupSettingsActivity.java
index 08461ad..e6d313c 100644
--- a/src/com/android/settings/backup/UserBackupSettingsActivity.java
+++ b/src/com/android/settings/backup/UserBackupSettingsActivity.java
@@ -29,8 +29,8 @@
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList;
import java.util.List;
@@ -109,7 +109,7 @@
// Add the activity title
SearchIndexableRaw data = new SearchIndexableRaw(context);
data.title = context.getString(R.string.privacy_settings_title);
- data.screenTitle = context.getString(R.string.settings_label);
+ data.screenTitle = context.getString(R.string.privacy_settings_title);
data.keywords = context.getString(R.string.keywords_backup);
data.intentTargetPackage = context.getPackageName();
data.intentTargetClass = UserBackupSettingsActivity.class.getName();
diff --git a/src/com/android/settings/development/DSULoader.java b/src/com/android/settings/development/DSULoader.java
index 4727369..1c897c4 100644
--- a/src/com/android/settings/development/DSULoader.java
+++ b/src/com/android/settings/development/DSULoader.java
@@ -65,7 +65,8 @@
private static final String PROPERTY_KEY_CPU = "ro.product.cpu.abi";
private static final String PROPERTY_KEY_OS = "ro.system.build.version.release";
private static final String PROPERTY_KEY_VNDK = "ro.vndk.version";
- private static final String PROPERTY_KEY_LIST = "ro.vendor.dsu.list";
+ private static final String PROPERTY_KEY_LIST =
+ "persist.sys.fflag.override.settings_dynamic_system.list";
private static final String PROPERTY_KEY_SPL = "ro.build.version.security_patch";
private static final String DSU_LIST =
"https://dl.google.com/developers/android/gsi/gsi-src.json";
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index 5f1e955..740c328 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -21,6 +21,7 @@
import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
+import android.os.Bundle;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
@@ -29,6 +30,9 @@
import androidx.annotation.LayoutRes;
import androidx.annotation.VisibleForTesting;
+import androidx.core.view.AccessibilityDelegateCompat;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
@@ -167,6 +171,27 @@
resetCardView(holder);
mSliceLiveDataMap.get(card.getSliceUri()).removeObservers(mLifecycleOwner);
});
+
+ ViewCompat.setAccessibilityDelegate(getInitialView(holder),
+ new AccessibilityDelegateCompat() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host,
+ AccessibilityNodeInfoCompat info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ info.addAction(AccessibilityNodeInfoCompat.ACTION_DISMISS);
+ info.setDismissable(true);
+ }
+
+ @Override
+ public boolean performAccessibilityAction(View host, int action, Bundle args) {
+ if (action == AccessibilityNodeInfoCompat.ACTION_DISMISS) {
+ mControllerRendererPool.getController(mContext,
+ card.getCardType()).onDismissed(card);
+ }
+ return super.performAccessibilityAction(host, action, args);
+ }
+ });
+
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
diff --git a/src/com/android/settings/media/MediaOutputIndicatorSlice.java b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
index f336f27..63dd2de 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorSlice.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
@@ -25,8 +25,8 @@
import android.graphics.Bitmap;
import android.media.session.MediaController;
import android.net.Uri;
-import android.util.Log;
+import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
import androidx.slice.builders.ListBuilder;
@@ -36,7 +36,6 @@
import com.android.settings.Utils;
import com.android.settings.slices.CustomSliceable;
import com.android.settings.slices.SliceBackgroundWorker;
-import com.android.settings.slices.SliceBroadcastReceiver;
import com.android.settingslib.media.MediaOutputSliceConstants;
public class MediaOutputIndicatorSlice implements CustomSliceable {
@@ -60,8 +59,10 @@
final IconCompat icon = IconCompat.createWithResource(mContext,
com.android.internal.R.drawable.ic_settings_bluetooth);
final CharSequence title = mContext.getText(R.string.media_output_title);
+ final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext,
+ 0 /* requestCode */, getMediaOutputSliceIntent(), 0 /* flags */);
final SliceAction primarySliceAction = SliceAction.createDeeplink(
- getBroadcastIntent(), icon, ListBuilder.ICON_IMAGE, title);
+ primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
// To set an empty icon to indent the row
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
@@ -74,18 +75,27 @@
return listBuilder.build();
}
+ @VisibleForTesting
+ Intent getMediaOutputSliceIntent() {
+ final MediaController mediaController = getWorker().getActiveLocalMediaController();
+ final Intent intent = new Intent()
+ .setPackage(Utils.SETTINGS_PACKAGE_NAME)
+ .setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ if (mediaController != null) {
+ intent.putExtra(MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN,
+ mediaController.getSessionToken());
+ intent.putExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME,
+ mediaController.getPackageName());
+ }
+ return intent;
+ }
+
private IconCompat createEmptyIcon() {
final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
return IconCompat.createWithBitmap(bitmap);
}
- private PendingIntent getBroadcastIntent() {
- final Intent intent = new Intent(getUri().toString());
- intent.setClass(mContext, SliceBroadcastReceiver.class);
- return PendingIntent.getBroadcast(mContext, 0, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- }
-
@Override
public Uri getUri() {
return MEDIA_OUTPUT_INDICATOR_SLICE_URI;
@@ -103,26 +113,6 @@
return MediaOutputIndicatorWorker.class;
}
- @Override
- public void onNotifyChange(Intent i) {
- if (getWorker() == null) {
- Log.d(TAG, "onNotifyChange: Worker is null");
- return;
- }
- final MediaController mediaController = getWorker().getActiveLocalMediaController();
- final Intent intent = new Intent()
- .setPackage(Utils.SETTINGS_PACKAGE_NAME)
- .setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- if (mediaController != null) {
- intent.putExtra(MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN,
- mediaController.getSessionToken());
- intent.putExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME,
- mediaController.getPackageName());
- }
- mContext.startActivity(intent);
- }
-
private MediaOutputIndicatorWorker getWorker() {
if (mWorker == null) {
mWorker = SliceBackgroundWorker.getInstance(getUri());
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index e852b80..122b975 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -35,11 +35,11 @@
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
public class AirplaneModePreferenceController extends TogglePreferenceController
- implements LifecycleObserver, OnResume, OnPause,
+ implements LifecycleObserver, OnStart, OnStop,
AirplaneModeEnabler.OnAirplaneModeChangedListener {
public static final int REQUEST_CODE_EXIT_ECM = 1;
@@ -120,16 +120,16 @@
}
@Override
- public void onResume() {
+ public void onStart() {
if (isAvailable()) {
- mAirplaneModeEnabler.resume();
+ mAirplaneModeEnabler.start();
}
}
@Override
- public void onPause() {
+ public void onStop() {
if (isAvailable()) {
- mAirplaneModeEnabler.pause();
+ mAirplaneModeEnabler.stop();
}
}
diff --git a/src/com/android/settings/network/SubscriptionsChangeListener.java b/src/com/android/settings/network/SubscriptionsChangeListener.java
index 1b50a54..192ee53 100644
--- a/src/com/android/settings/network/SubscriptionsChangeListener.java
+++ b/src/com/android/settings/network/SubscriptionsChangeListener.java
@@ -23,6 +23,7 @@
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
+import android.os.Looper;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
@@ -45,11 +46,11 @@
private BroadcastReceiver mBroadcastReceiver;
public SubscriptionsChangeListener(Context context, SubscriptionsChangeListenerClient client) {
- super(new Handler());
+ super(new Handler(Looper.getMainLooper()));
mContext = context;
mClient = client;
mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
- mSubscriptionsChangedListener = new OnSubscriptionsChangedListener() {
+ mSubscriptionsChangedListener = new OnSubscriptionsChangedListener(Looper.getMainLooper()) {
@Override
public void onSubscriptionsChanged() {
subscriptionsChangedCallback();
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index d3fb437..cbe0912 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;
import android.content.Context;
+import android.os.Looper;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
@@ -187,7 +188,7 @@
private class PhoneCallStateListener extends PhoneStateListener {
PhoneCallStateListener() {
- super();
+ super(Looper.getMainLooper());
}
private TelephonyManager mTelephonyManager;
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index eed4046..d235a9a 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;
import android.content.Context;
+import android.os.Looper;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
@@ -164,7 +165,7 @@
private class PhoneCallStateListener extends PhoneStateListener {
PhoneCallStateListener() {
- super();
+ super(Looper.getMainLooper());
}
private TelephonyManager mTelephonyManager;
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index e928dba..bec8a51 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -20,6 +20,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.Looper;
import android.os.PersistableBundle;
import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
@@ -194,7 +195,7 @@
private class PhoneCallStateListener extends PhoneStateListener {
PhoneCallStateListener() {
- super();
+ super(Looper.getMainLooper());
}
private TelephonyManager mTelephonyManager;
diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
index d41268d..73befeb 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
@@ -77,7 +77,7 @@
View viewForPackage = LayoutInflater.from(this)
.inflate(R.layout.notification_history_app_layout, null);
- final View container = viewForPackage.findViewById(R.id.list_container);
+ final View container = viewForPackage.findViewById(R.id.notification_list);
container.setVisibility(View.GONE);
ImageButton expand = viewForPackage.findViewById(R.id.expand);
expand.setContentDescription(container.getVisibility() == View.VISIBLE
diff --git a/src/com/android/settings/notification/history/NotificationHistoryAdapter.java b/src/com/android/settings/notification/history/NotificationHistoryAdapter.java
index a06939a..9d652d9 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryAdapter.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryAdapter.java
@@ -16,13 +16,22 @@
package com.android.settings.notification.history;
+import static android.provider.Settings.EXTRA_APP_PACKAGE;
+import static android.provider.Settings.EXTRA_CHANNEL_ID;
+import static android.provider.Settings.EXTRA_CONVERSATION_ID;
+
import android.app.INotificationManager;
import android.app.NotificationHistory.HistoricalNotification;
+import android.content.Intent;
+import android.os.Bundle;
import android.os.RemoteException;
+import android.os.UserHandle;
+import android.provider.Settings;
import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityNodeInfo;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@@ -63,8 +72,37 @@
holder.setTitle(hn.getTitle());
holder.setSummary(hn.getText());
holder.setPostedTime(hn.getPostedTimeMs());
- holder.addOnClick(hn.getPackage(), hn.getUserId(), hn.getChannelId(),
- hn.getConversationId());
+ holder.itemView.setOnClickListener(v -> {
+ Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
+ .putExtra(EXTRA_APP_PACKAGE, hn.getPackage())
+ .putExtra(EXTRA_CHANNEL_ID, hn.getChannelId())
+ .putExtra(EXTRA_CONVERSATION_ID, hn.getConversationId());
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ holder.itemView.getContext().startActivityAsUser(intent, UserHandle.of(hn.getUserId()));
+ });
+ holder.itemView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host,
+ AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ CharSequence description =
+ host.getResources().getText(R.string.notification_history_view_settings);
+ AccessibilityNodeInfo.AccessibilityAction customClick =
+ new AccessibilityNodeInfo.AccessibilityAction(
+ AccessibilityNodeInfo.ACTION_CLICK, description);
+ info.addAction(customClick);
+ //info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS);
+ }
+
+ @Override
+ public boolean performAccessibilityAction(View host, int action, Bundle args) {
+ if (action == AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS.getId()) {
+ onItemSwipeDeleted(position);
+ return true;
+ }
+ return false;
+ }
+ });
}
@Override
diff --git a/src/com/android/settings/notification/history/NotificationHistoryRecyclerView.java b/src/com/android/settings/notification/history/NotificationHistoryRecyclerView.java
index eaaa7c9..6f6deb0 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryRecyclerView.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryRecyclerView.java
@@ -34,6 +34,7 @@
ItemTouchHelper touchHelper = new ItemTouchHelper(
new DismissTouchHelper(0, ItemTouchHelper.START | ItemTouchHelper.END));
touchHelper.attachToRecyclerView(this);
+ setNestedScrollingEnabled(false);
}
public void setOnItemSwipeDeleteListener(OnItemSwipeDeleteListener listener) {
diff --git a/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java b/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
index d1f47af..ef4f0da 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
@@ -16,20 +16,10 @@
package com.android.settings.notification.history;
-import static android.provider.Settings.EXTRA_APP_PACKAGE;
-import static android.provider.Settings.EXTRA_CHANNEL_ID;
-import static android.provider.Settings.EXTRA_CONVERSATION_ID;
-
-import android.content.Intent;
-import android.os.UserHandle;
-import android.provider.Settings;
import android.view.View;
import android.widget.DateTimeView;
import android.widget.TextView;
-import androidx.core.view.AccessibilityDelegateCompat;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
@@ -61,28 +51,4 @@
void setPostedTime(long postedTime) {
mTime.setTime(postedTime);
}
-
- void addOnClick(String pkg, int userId, String channelId, String conversationId) {
- itemView.setOnClickListener(v -> {
- Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
- .putExtra(EXTRA_APP_PACKAGE, pkg)
- .putExtra(EXTRA_CHANNEL_ID, channelId)
- .putExtra(EXTRA_CONVERSATION_ID, conversationId);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- itemView.getContext().startActivityAsUser(intent, UserHandle.of(userId));
- });
- ViewCompat.setAccessibilityDelegate(itemView, new AccessibilityDelegateCompat() {
- @Override
- public void onInitializeAccessibilityNodeInfo(View host,
- AccessibilityNodeInfoCompat info) {
- super.onInitializeAccessibilityNodeInfo(host, info);
- CharSequence description =
- host.getResources().getText(R.string.notification_history_view_settings);
- AccessibilityNodeInfoCompat.AccessibilityActionCompat customClick =
- new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
- AccessibilityNodeInfoCompat.ACTION_CLICK, description);
- info.addAction(customClick);
- }
- });
- }
}
diff --git a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
index dabf3f3..42a2100 100644
--- a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
+++ b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
@@ -20,6 +20,7 @@
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.drawable.Drawable;
+import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Slog;
@@ -81,39 +82,44 @@
void setProfileBadge(Drawable badge) {
mProfileBadge.setImageDrawable(badge);
+ mProfileBadge.setVisibility(badge != null ? View.VISIBLE : View.GONE);
}
void addOnClick(String pkg, int userId, PendingIntent pi) {
- itemView.setOnClickListener(v -> {
- if (pi != null) {
- try {
- pi.send();
- } catch (PendingIntent.CanceledException e) {
- Slog.e(TAG, "Could not launch", e);
+ Intent appIntent = itemView.getContext().getPackageManager()
+ .getLaunchIntentForPackage(pkg);
+ boolean isPendingIntentValid = pi != null && PendingIntent.getActivity(
+ itemView.getContext(), 0, pi.getIntent(), PendingIntent.FLAG_NO_CREATE) != null;
+ if (isPendingIntentValid || appIntent != null) {
+ itemView.setOnClickListener(v -> {
+ if (pi != null) {
+ try {
+ pi.send();
+ } catch (PendingIntent.CanceledException e) {
+ Slog.e(TAG, "Could not launch", e);
+ }
+ } else if (appIntent != null) {
+ appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ try {
+ itemView.getContext().startActivityAsUser(appIntent, UserHandle.of(userId));
+ } catch (ActivityNotFoundException e) {
+ Slog.e(TAG, "no launch activity", e);
+ }
}
- } else {
- Intent appIntent = itemView.getContext().getPackageManager()
- .getLaunchIntentForPackage(pkg);
- appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- try {
- itemView.getContext().startActivityAsUser(appIntent, UserHandle.of(userId));
- } catch (ActivityNotFoundException e) {
- Slog.e(TAG, "no launch activity", e);
+ });
+ ViewCompat.setAccessibilityDelegate(itemView, new AccessibilityDelegateCompat() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host,
+ AccessibilityNodeInfoCompat info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ CharSequence description = host.getResources().getText(
+ R.string.notification_history_open_notification);
+ AccessibilityNodeInfoCompat.AccessibilityActionCompat customClick =
+ new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
+ AccessibilityNodeInfoCompat.ACTION_CLICK, description);
+ info.addAction(customClick);
}
- }
- });
- ViewCompat.setAccessibilityDelegate(itemView, new AccessibilityDelegateCompat() {
- @Override
- public void onInitializeAccessibilityNodeInfo(View host,
- AccessibilityNodeInfoCompat info) {
- super.onInitializeAccessibilityNodeInfo(host, info);
- CharSequence description = host.getResources().getText(
- R.string.notification_history_open_notification);
- AccessibilityNodeInfoCompat.AccessibilityActionCompat customClick =
- new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
- AccessibilityNodeInfoCompat.ACTION_CLICK, description);
- info.addAction(customClick);
- }
- });
+ });
+ }
}
}
diff --git a/src/com/android/settings/panel/MediaOutputPanel.java b/src/com/android/settings/panel/MediaOutputPanel.java
index 56ed6fb..1bf6f26 100644
--- a/src/com/android/settings/panel/MediaOutputPanel.java
+++ b/src/com/android/settings/panel/MediaOutputPanel.java
@@ -103,7 +103,7 @@
return metadata.getDescription().getSubtitle();
}
}
- return null;
+ return mContext.getText(R.string.media_output_panel_title);
}
@Override
diff --git a/src/com/android/settings/search/CustomSiteMapRegistry.java b/src/com/android/settings/search/CustomSiteMapRegistry.java
index 300cf17..756479b 100644
--- a/src/com/android/settings/search/CustomSiteMapRegistry.java
+++ b/src/com/android/settings/search/CustomSiteMapRegistry.java
@@ -19,9 +19,17 @@
import android.util.ArrayMap;
import com.android.settings.DisplaySettings;
+import com.android.settings.backup.UserBackupSettingsActivity;
+import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
+import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
+import com.android.settings.fuelgauge.PowerUsageAdvanced;
+import com.android.settings.fuelgauge.PowerUsageSummary;
+import com.android.settings.location.LocationSettings;
+import com.android.settings.location.RecentLocationRequestSeeAllFragment;
import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.security.SecuritySettings;
import com.android.settings.security.screenlock.ScreenLockSettings;
+import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
import com.android.settings.wifi.WifiSettings2;
@@ -44,5 +52,12 @@
WallpaperSuggestionActivity.class.getName(), DisplaySettings.class.getName());
CUSTOM_SITE_MAP.put(
WifiSettings2.class.getName(), NetworkDashboardFragment.class.getName());
+ CUSTOM_SITE_MAP.put(PowerUsageAdvanced.class.getName(), PowerUsageSummary.class.getName());
+ CUSTOM_SITE_MAP.put(RecentLocationRequestSeeAllFragment.class.getName(),
+ LocationSettings.class.getName());
+ CUSTOM_SITE_MAP.put(UsbDetailsFragment.class.getName(),
+ ConnectedDeviceDashboardFragment.class.getName());
+ CUSTOM_SITE_MAP.put(UserBackupSettingsActivity.class.getName(),
+ SystemDashboardFragment.class.getName());
}
}
diff --git a/src/com/android/settings/slices/SlicesIndexer.java b/src/com/android/settings/slices/SlicesIndexer.java
index 3a68a32..e527fd6 100644
--- a/src/com/android/settings/slices/SlicesIndexer.java
+++ b/src/com/android/settings/slices/SlicesIndexer.java
@@ -104,7 +104,10 @@
values.put(IndexColumns.SLICE_URI, dataRow.getUri().toSafeString());
values.put(IndexColumns.TITLE, dataRow.getTitle());
values.put(IndexColumns.SUMMARY, dataRow.getSummary());
- values.put(IndexColumns.SCREENTITLE, dataRow.getScreenTitle().toString());
+ final CharSequence screenTitle = dataRow.getScreenTitle();
+ if (screenTitle != null) {
+ values.put(IndexColumns.SCREENTITLE, screenTitle.toString());
+ }
values.put(IndexColumns.KEYWORDS, dataRow.getKeywords());
values.put(IndexColumns.ICON_RESOURCE, dataRow.getIconResource());
values.put(IndexColumns.FRAGMENT, dataRow.getFragmentClassName());
diff --git a/src/com/android/settings/users/MultiUserSwitchBarController.java b/src/com/android/settings/users/MultiUserSwitchBarController.java
index a5fdf9b..58de149 100644
--- a/src/com/android/settings/users/MultiUserSwitchBarController.java
+++ b/src/com/android/settings/users/MultiUserSwitchBarController.java
@@ -52,8 +52,6 @@
mListener = listener;
mUserCapabilities = UserCapabilities.create(context);
mSwitchBar.setChecked(mUserCapabilities.mUserSwitcherEnabled);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.USER_SWITCHER_ENABLED, mSwitchBar.isChecked() ? 1 : 0);
if (mUserCapabilities.mDisallowSwitchUser) {
mSwitchBar.setDisabledByAdmin(RestrictedLockUtilsInternal
diff --git a/src/com/android/settings/wifi/NetworkRequestErrorDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestErrorDialogFragment.java
index 57e1bca..aebd072 100644
--- a/src/com/android/settings/wifi/NetworkRequestErrorDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestErrorDialogFragment.java
@@ -25,6 +25,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
+
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
@@ -44,10 +45,6 @@
return new NetworkRequestErrorDialogFragment();
}
- private NetworkRequestErrorDialogFragment() {
- super();
- }
-
@Override
public void onCancel(@NonNull DialogInterface dialog) {
super.onCancel(dialog);
diff --git a/tests/perftests/Android.bp b/tests/perftests/Android.bp
index 1ba5d9c..7708bbe 100644
--- a/tests/perftests/Android.bp
+++ b/tests/perftests/Android.bp
@@ -19,4 +19,4 @@
test_suites: ["device-tests"],
instrumentation_for: "Settings",
-}
+}
\ No newline at end of file
diff --git a/tests/perftests/AndroidManifest.xml b/tests/perftests/AndroidManifest.xml
index 4ce6a54..972467f 100644
--- a/tests/perftests/AndroidManifest.xml
+++ b/tests/perftests/AndroidManifest.xml
@@ -15,15 +15,15 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.settings.tests.perf">
+ package="com.android.settings.tests.perf">
<application>
- <uses-library android:name="android.test.runner" />
+ <uses-library android:name="android.test.runner"/>
</application>
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.settings"
- android:label="Settings Performance Test Cases">
+ android:targetPackage="com.android.settings.tests.perf"
+ android:label="Settings Performance Test Cases">
</instrumentation>
</manifest>
diff --git a/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java b/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java
index 5140be2..f55598c 100644
--- a/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java
+++ b/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java
@@ -15,8 +15,15 @@
*/
package com.android.settings.tests.perf;
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
+import static junit.framework.TestCase.fail;
+
import android.app.Instrumentation;
import android.os.Bundle;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.Until;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -26,23 +33,119 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
@RunWith(AndroidJUnit4.class)
public class LaunchSettingsTest {
+ private static class Page {
+ String action;
+ String displayName;
+ String title;
+
+ Page(String action, String displayName, String title) {
+ this.action = action;
+ this.displayName = displayName;
+ this.title = title;
+ }
+ }
+
+ private static final int TIME_OUT = 5000;
+ private static final int TEST_TIME = 10;
+ private static final Pattern PATTERN = Pattern.compile("TotalTime:\\s[0-9]*");
+ private static final Page[] PAGES;
+
+ static {
+ PAGES = new Page[]{
+ new Page("android.settings.SETTINGS", "Search settings", "Settings"),
+ new Page("android.settings.WIFI_SETTINGS", "Use Wi‑Fi", "Wi-Fi"),
+ new Page("android.settings.BLUETOOTH_SETTINGS", "Connected devices", "BlueTooth"),
+ new Page("android.settings.APPLICATION_SETTINGS", "App info", "Application"),
+ new Page("android.intent.action.POWER_USAGE_SUMMARY", "Battery", "Battery")
+ };
+ }
+
+ private Bundle mBundle;
+ private UiDevice mDevice;
+ private Instrumentation mInstrumentation;
+ private Map<String, ArrayList<Integer>> mResult;
@Before
public void setUp() throws Exception {
+ mBundle = new Bundle();
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mResult = new LinkedHashMap<>();
+ mDevice.pressHome();
+ mDevice.waitForIdle(TIME_OUT);
+
+ for (Page page : PAGES) {
+ mResult.put(page.title, new ArrayList<Integer>());
+ }
}
@After
public void tearDown() throws Exception {
+ putResultToBundle();
+ mInstrumentation.sendStatus(0, mBundle);
}
@Test
- public void testReportMetrics() throws Exception {
- Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
- final Bundle result = new Bundle();
- result.putString("LaunchSettingsTest_metric_key1", "1000");
- result.putString("LaunchSettingsTest_metric_key2", "5000");
- instrumentation.sendStatus(0, result);
+ public void settingsPerformanceTest() throws Exception {
+ for (int i = 0; i < TEST_TIME; i++) {
+ for (Page page : PAGES) {
+ executePreformanceTest(page.action, page.displayName, page.title);
+ }
+ }
}
-}
+
+ private void executePreformanceTest(String action, String displayName, String title)
+ throws Exception {
+ final String mString = mDevice.executeShellCommand("am start -W -a" + action);
+ mDevice.wait(Until.findObject(By.text(displayName)), TIME_OUT);
+ handleLaunchResult(title, mString);
+ closeApp();
+ mDevice.waitForIdle(TIME_OUT);
+ }
+
+ private void handleLaunchResult(String title, String s) {
+ Matcher mMatcher = PATTERN.matcher(s);
+ if (mMatcher.find()) {
+ mResult.get(title).add(Integer.valueOf(mMatcher.group().split("\\s")[1]));
+ } else {
+ fail("Some pages can't be found");
+ }
+ }
+
+ private void closeApp() throws Exception {
+ mDevice.executeShellCommand("am force-stop com.android.settings");
+ Thread.sleep(1000);
+ }
+
+ private void putResultToBundle() {
+ for (String string : mResult.keySet()) {
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "max"),
+ getMax(mResult.get(string)));
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "min"),
+ getMin(mResult.get(string)));
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "avg"),
+ getAvg(mResult.get(string)));
+ }
+ }
+
+ private String getMax(ArrayList<Integer> launchResult) {
+ return String.format("%s", launchResult.isEmpty() ? "null" : Collections.max(launchResult));
+ }
+
+ private String getMin(ArrayList<Integer> launchResult) {
+ return String.format("%s", launchResult.isEmpty() ? "null" : Collections.min(launchResult));
+ }
+
+ private String getAvg(ArrayList<Integer> launchResult) {
+ return String.valueOf((int) launchResult.stream().mapToInt(i -> i).average().orElse(0));
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java b/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
index 24abac9..6c5b9f2 100644
--- a/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
@@ -53,7 +53,7 @@
@Test
public void onRadioPowerStateChanged_beenInvoke_invokeOnAirplaneModeChanged() {
- mAirplaneModeEnabler.resume();
+ mAirplaneModeEnabler.start();
ShadowSettings.setAirplaneMode(true);
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
index 55cc4cd..1fc3910 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
@@ -21,11 +21,8 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -48,14 +45,12 @@
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.media.LocalMediaManager;
import com.android.settingslib.media.MediaDevice;
import com.android.settingslib.media.MediaOutputSliceConstants;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
@@ -85,8 +80,6 @@
@Mock
private MediaController mMediaController;
@Mock
- private LocalMediaManager mLocalMediaManager;
- @Mock
private MediaDevice mDevice1;
@Mock
private MediaDevice mDevice2;
@@ -193,46 +186,32 @@
}
@Test
- public void onNotifyChange_noWorker_doNothing() {
- sMediaOutputIndicatorWorker = null;
- mMediaOutputIndicatorSlice.onNotifyChange(new Intent());
-
- verify(mContext, never()).startActivity(any());
- }
-
- @Test
- public void onNotifyChange_withActiveLocalMedia_verifyIntentExtra() {
+ public void getMediaOutputSliceIntent_withActiveLocalMedia_verifyIntentExtra() {
when(mMediaController.getSessionToken()).thenReturn(mToken);
when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
.getActiveLocalMediaController();
+ final Intent intent = mMediaOutputIndicatorSlice.getMediaOutputSliceIntent();
- final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- mMediaOutputIndicatorSlice.onNotifyChange(new Intent());
- verify(mContext).startActivity(intentCaptor.capture());
-
- assertThat(TextUtils.equals(TEST_PACKAGE_NAME, intentCaptor.getValue().getStringExtra(
+ assertThat(TextUtils.equals(TEST_PACKAGE_NAME, intent.getStringExtra(
MediaOutputSliceConstants.EXTRA_PACKAGE_NAME))).isTrue();
- assertThat(TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, intentCaptor.getValue()
- .getPackage())).isTrue();
- assertThat(mToken == intentCaptor.getValue().getExtras().getParcelable(
+ assertThat(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT).isEqualTo(intent.getAction());
+ assertThat(TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, intent.getPackage())).isTrue();
+ assertThat(mToken == intent.getExtras().getParcelable(
MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN)).isTrue();
}
@Test
- public void onNotifyChange_withoutActiveLocalMedia_verifyIntentExtra() {
+ public void getMediaOutputSliceIntent_withoutActiveLocalMedia_verifyIntentExtra() {
doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
.getActiveLocalMediaController();
+ final Intent intent = mMediaOutputIndicatorSlice.getMediaOutputSliceIntent();
- final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- mMediaOutputIndicatorSlice.onNotifyChange(new Intent());
- verify(mContext).startActivity(intentCaptor.capture());
-
- assertThat(TextUtils.isEmpty(intentCaptor.getValue().getStringExtra(
+ assertThat(TextUtils.isEmpty(intent.getStringExtra(
MediaOutputSliceConstants.EXTRA_PACKAGE_NAME))).isTrue();
- assertThat(TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, intentCaptor.getValue()
- .getPackage())).isTrue();
- assertThat(intentCaptor.getValue().getExtras().getParcelable(
+ assertThat(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT).isEqualTo(intent.getAction());
+ assertThat(TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, intent.getPackage())).isTrue();
+ assertThat(intent.getExtras().getParcelable(
MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN) == null).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
index 54c3683..cb68e2a 100644
--- a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
@@ -102,8 +102,8 @@
mController.displayPreference(mScreen);
// This should not crash
- mController.onResume();
- mController.onPause();
+ mController.onStart();
+ mController.onStop();
}
@Test
@@ -115,8 +115,8 @@
mController.displayPreference(mScreen);
// This should not crash
- mController.onResume();
- mController.onPause();
+ mController.onStart();
+ mController.onStop();
}
@Test
@@ -147,7 +147,7 @@
Settings.Global.putInt(mResolver, Settings.Global.AIRPLANE_MODE_ON, ON);
mController.displayPreference(mScreen);
- mController.onResume();
+ mController.onStart();
assertThat(mController.isChecked()).isTrue();
@@ -161,7 +161,7 @@
Settings.Global.putInt(mResolver, Settings.Global.AIRPLANE_MODE_ON, OFF);
mController.displayPreference(mScreen);
- mController.onResume();
+ mController.onStop();
assertThat(mPreference.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java b/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java
index e0b926b..cdfa87f 100644
--- a/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java
+++ b/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java
@@ -35,7 +35,6 @@
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.net.Uri;
-import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.slices.CustomSliceRegistry;
@@ -238,28 +237,31 @@
}
@Test
- public void getSubTitle_noMetadata_returnEmpty() {
+ public void getSubTitle_noMetadata_returnDefault() {
when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGENAME);
when(mMediaController.getMetadata()).thenReturn(null);
- assertThat(TextUtils.isEmpty(mPanel.getSubTitle())).isTrue();
+ assertThat(mPanel.getSubTitle()).isEqualTo(mContext.getText(
+ R.string.media_output_panel_title));
}
@Test
- public void getSubTitle_noPackageName_returnEmpty() {
+ public void getSubTitle_noPackageName_returnDefault() {
mPanel = MediaOutputPanel.create(mContext, null);
when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
- assertThat(TextUtils.isEmpty(mPanel.getSubTitle())).isTrue();
+ assertThat(mPanel.getSubTitle()).isEqualTo(mContext.getText(
+ R.string.media_output_panel_title));
}
@Test
- public void getSubTitle_noController_returnEmpty() {
+ public void getSubTitle_noController_returnDefault() {
mMediaControllers.clear();
mPanel = MediaOutputPanel.create(mContext, TEST_PACKAGENAME);
when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
- assertThat(TextUtils.isEmpty(mPanel.getSubTitle())).isTrue();
+ assertThat(mPanel.getSubTitle()).isEqualTo(mContext.getText(
+ R.string.media_output_panel_title));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/search/CustomSiteMapRegistryTest.java b/tests/robotests/src/com/android/settings/search/CustomSiteMapRegistryTest.java
index 5bd4538..5c78a6b 100644
--- a/tests/robotests/src/com/android/settings/search/CustomSiteMapRegistryTest.java
+++ b/tests/robotests/src/com/android/settings/search/CustomSiteMapRegistryTest.java
@@ -19,9 +19,17 @@
import static com.google.common.truth.Truth.assertThat;
import com.android.settings.DisplaySettings;
+import com.android.settings.backup.UserBackupSettingsActivity;
+import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
+import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
+import com.android.settings.fuelgauge.PowerUsageAdvanced;
+import com.android.settings.fuelgauge.PowerUsageSummary;
+import com.android.settings.location.LocationSettings;
+import com.android.settings.location.RecentLocationRequestSeeAllFragment;
import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.security.SecuritySettings;
import com.android.settings.security.screenlock.ScreenLockSettings;
+import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
import com.android.settings.wifi.WifiSettings2;
@@ -50,4 +58,31 @@
assertThat(CustomSiteMapRegistry.CUSTOM_SITE_MAP.get(WifiSettings2.class.getName()))
.isEqualTo(NetworkDashboardFragment.class.getName());
}
+
+ @Test
+ public void shouldContainPowerUsageAdvancedPairs() {
+ assertThat(CustomSiteMapRegistry.CUSTOM_SITE_MAP.get(PowerUsageAdvanced.class.getName()))
+ .isEqualTo(PowerUsageSummary.class.getName());
+ }
+
+ @Test
+ public void shouldContainRecentLocationRequestSeeAllFragmentPairs() {
+ assertThat(CustomSiteMapRegistry.CUSTOM_SITE_MAP.get(
+ RecentLocationRequestSeeAllFragment.class.getName())).isEqualTo(
+ LocationSettings.class.getName());
+ }
+
+ @Test
+ public void shouldContainUsbDetailsFragmentPairs() {
+ assertThat(CustomSiteMapRegistry.CUSTOM_SITE_MAP.get(
+ UsbDetailsFragment.class.getName())).isEqualTo(
+ ConnectedDeviceDashboardFragment.class.getName());
+ }
+
+ @Test
+ public void shouldContainUserBackupSettingsActivityPairs() {
+ assertThat(CustomSiteMapRegistry.CUSTOM_SITE_MAP.get(
+ UserBackupSettingsActivity.class.getName())).isEqualTo(
+ SystemDashboardFragment.class.getName());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java
index c4bdda8..333c4eb 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java
@@ -17,6 +17,8 @@
package com.android.settings.wifi;
import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -26,12 +28,15 @@
import android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback;
import android.os.Bundle;
import android.widget.Button;
+
import androidx.appcompat.app.AlertDialog;
+
import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.wifi.NetworkRequestErrorDialogFragment.ERROR_DIALOG_TYPE;
import com.android.settingslib.wifi.WifiTracker;
import com.android.settingslib.wifi.WifiTrackerFactory;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,6 +63,15 @@
}
@Test
+ public void getConstructor_shouldNotThrowNoSuchMethodException() {
+ try {
+ NetworkRequestErrorDialogFragment.class.getConstructor();
+ } catch (NoSuchMethodException e) {
+ fail("No default constructor for configuration change!");
+ }
+ }
+
+ @Test
public void display_shouldShowTimeoutDialog() {
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();