Merge "Fix lockdown icon dark mode coloring." into pi-dev
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index 57f2852..0a667cc 100644
--- a/config/hiddenapi-light-greylist.txt
+++ b/config/hiddenapi-light-greylist.txt
@@ -2357,6 +2357,7 @@
Landroid/hardware/camera2/CaptureRequest$Key;-><init>(Ljava/lang/String;Landroid/hardware/camera2/utils/TypeReference;)V
Landroid/hardware/camera2/CaptureRequest$Key;-><init>(Ljava/lang/String;Ljava/lang/Class;J)V
Landroid/hardware/camera2/CaptureRequest$Key;->getNativeKey()Landroid/hardware/camera2/impl/CameraMetadataNative$Key;
+Landroid/hardware/camera2/CaptureRequest;->getTargets()Ljava/util/Collection;
Landroid/hardware/camera2/CaptureRequest;->JPEG_GPS_COORDINATES:Landroid/hardware/camera2/CaptureRequest$Key;
Landroid/hardware/camera2/CaptureRequest;->JPEG_GPS_PROCESSING_METHOD:Landroid/hardware/camera2/CaptureRequest$Key;
Landroid/hardware/camera2/CaptureRequest;->JPEG_GPS_TIMESTAMP:Landroid/hardware/camera2/CaptureRequest$Key;
@@ -2392,6 +2393,7 @@
Landroid/hardware/camera2/CaptureResult;->TONEMAP_CURVE_RED:Landroid/hardware/camera2/CaptureResult$Key;
Landroid/hardware/camera2/impl/CameraMetadataNative$Key;->getTag()I
Landroid/hardware/camera2/impl/CameraMetadataNative;->mMetadataPtr:J
+Landroid/hardware/camera2/utils/SurfaceUtils;->getSurfaceSize(Landroid/view/Surface;)Landroid/util/Size;
Landroid/hardware/camera2/utils/TypeReference;-><init>()V
Landroid/hardware/camera2/utils/TypeReference;->createSpecializedTypeReference(Ljava/lang/reflect/Type;)Landroid/hardware/camera2/utils/TypeReference;
Landroid/hardware/Camera;->addCallbackBuffer([BI)V
@@ -2853,6 +2855,7 @@
Landroid/media/EncoderCapabilities;->getVideoEncoders()Ljava/util/List;
Landroid/media/ExifInterface;->convertRationalLatLonToFloat(Ljava/lang/String;Ljava/lang/String;)F
Landroid/media/ExifInterface;->getDateTime()J
+Landroid/media/ExifInterface;->getGpsDateTime()J
Landroid/media/ExifInterface;->mAttributes:[Ljava/util/HashMap;
Landroid/media/ExifInterface;->mFilename:Ljava/lang/String;
Landroid/media/ExifInterface;->mHasThumbnail:Z
@@ -4121,6 +4124,7 @@
Landroid/os/storage/StorageManager;->getVolumeState(Ljava/lang/String;)Ljava/lang/String;
Landroid/os/storage/StorageManager;->isFileEncryptedNativeOnly()Z
Landroid/os/storage/StorageManager;->isUsbMassStorageEnabled()Z
+Landroid/os/storage/StorageManager;->partitionPublic(Ljava/lang/String;)V
Landroid/os/storage/StorageManager;->unmount(Ljava/lang/String;)V
Landroid/os/storage/StorageVolume;->allowMassStorage()Z
Landroid/os/storage/StorageVolume;->getFatVolumeId()I
@@ -8125,6 +8129,12 @@
Lcom/android/internal/telephony/IWapPushManager;->deletePackage(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
Lcom/android/internal/telephony/IWapPushManager;->updatePackage(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZZ)Z
Lcom/android/internal/telephony/OperatorInfo;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+Lcom/android/internal/telephony/OperatorInfo;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/android/internal/telephony/OperatorInfo$State;)V
+Lcom/android/internal/telephony/OperatorInfo;->mOperatorAlphaLong:Ljava/lang/String;
+Lcom/android/internal/telephony/OperatorInfo;->mOperatorAlphaShort:Ljava/lang/String;
+Lcom/android/internal/telephony/OperatorInfo;->mOperatorNumeric:Ljava/lang/String;
+Lcom/android/internal/telephony/OperatorInfo;->mState:Lcom/android/internal/telephony/OperatorInfo$State;
+Lcom/android/internal/telephony/OperatorInfo;->rilStateToState(Ljava/lang/String;)Lcom/android/internal/telephony/OperatorInfo$State;
Lcom/android/internal/telephony/SmsAddress;->origBytes:[B
Lcom/android/internal/telephony/SmsConstants$MessageClass;->CLASS_0:Lcom/android/internal/telephony/SmsConstants$MessageClass;
Lcom/android/internal/telephony/SmsConstants$MessageClass;->CLASS_1:Lcom/android/internal/telephony/SmsConstants$MessageClass;
diff --git a/core/java/android/provider/SettingsValidators.java b/core/java/android/provider/SettingsValidators.java
index 5885b6b..c878bba 100644
--- a/core/java/android/provider/SettingsValidators.java
+++ b/core/java/android/provider/SettingsValidators.java
@@ -79,7 +79,7 @@
public static final Validator COMPONENT_NAME_VALIDATOR = new Validator() {
@Override
public boolean validate(String value) {
- return ComponentName.unflattenFromString(value) != null;
+ return value != null && ComponentName.unflattenFromString(value) != null;
}
};
diff --git a/core/java/android/view/textclassifier/TextClassificationManager.java b/core/java/android/view/textclassifier/TextClassificationManager.java
index 1737861..aee0aa7 100644
--- a/core/java/android/view/textclassifier/TextClassificationManager.java
+++ b/core/java/android/view/textclassifier/TextClassificationManager.java
@@ -20,6 +20,7 @@
import android.annotation.Nullable;
import android.annotation.SystemService;
import android.content.Context;
+import android.database.ContentObserver;
import android.os.ServiceManager;
import android.provider.Settings;
import android.service.textclassifier.TextClassifierService;
@@ -28,6 +29,8 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;
+import java.lang.ref.WeakReference;
+
/**
* Interface to the text classification service.
*/
@@ -42,23 +45,27 @@
classificationContext, getTextClassifier());
private final Context mContext;
- private final TextClassificationConstants mSettings;
+ private final SettingsObserver mSettingsObserver;
@GuardedBy("mLock")
- private TextClassifier mTextClassifier;
+ @Nullable
+ private TextClassifier mCustomTextClassifier;
@GuardedBy("mLock")
+ @Nullable
private TextClassifier mLocalTextClassifier;
@GuardedBy("mLock")
+ @Nullable
private TextClassifier mSystemTextClassifier;
@GuardedBy("mLock")
private TextClassificationSessionFactory mSessionFactory;
+ @GuardedBy("mLock")
+ private TextClassificationConstants mSettings;
/** @hide */
public TextClassificationManager(Context context) {
mContext = Preconditions.checkNotNull(context);
- mSettings = TextClassificationConstants.loadFromString(Settings.Global.getString(
- context.getContentResolver(), Settings.Global.TEXT_CLASSIFIER_CONSTANTS));
mSessionFactory = mDefaultSessionFactory;
+ mSettingsObserver = new SettingsObserver(this);
}
/**
@@ -71,14 +78,13 @@
@NonNull
public TextClassifier getTextClassifier() {
synchronized (mLock) {
- if (mTextClassifier == null) {
- if (isSystemTextClassifierEnabled()) {
- mTextClassifier = getSystemTextClassifier();
- } else {
- mTextClassifier = getLocalTextClassifier();
- }
+ if (mCustomTextClassifier != null) {
+ return mCustomTextClassifier;
+ } else if (isSystemTextClassifierEnabled()) {
+ return getSystemTextClassifier();
+ } else {
+ return getLocalTextClassifier();
}
- return mTextClassifier;
}
}
@@ -89,7 +95,7 @@
*/
public void setTextClassifier(@Nullable TextClassifier textClassifier) {
synchronized (mLock) {
- mTextClassifier = textClassifier;
+ mCustomTextClassifier = textClassifier;
}
}
@@ -110,9 +116,15 @@
}
}
- /** @hide */
- public TextClassificationConstants getSettings() {
- return mSettings;
+ private TextClassificationConstants getSettings() {
+ synchronized (mLock) {
+ if (mSettings == null) {
+ mSettings = TextClassificationConstants.loadFromString(Settings.Global.getString(
+ mContext.getApplicationContext().getContentResolver(),
+ Settings.Global.TEXT_CLASSIFIER_CONSTANTS));
+ }
+ return mSettings;
+ }
}
/**
@@ -170,11 +182,24 @@
}
}
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ // Note that fields could be null if the constructor threw.
+ if (mContext != null && mSettingsObserver != null) {
+ mContext.getApplicationContext().getContentResolver()
+ .unregisterContentObserver(mSettingsObserver);
+ }
+ } finally {
+ super.finalize();
+ }
+ }
+
private TextClassifier getSystemTextClassifier() {
synchronized (mLock) {
if (mSystemTextClassifier == null && isSystemTextClassifierEnabled()) {
try {
- mSystemTextClassifier = new SystemTextClassifier(mContext, mSettings);
+ mSystemTextClassifier = new SystemTextClassifier(mContext, getSettings());
Log.d(LOG_TAG, "Initialized SystemTextClassifier");
} catch (ServiceManager.ServiceNotFoundException e) {
Log.e(LOG_TAG, "Could not initialize SystemTextClassifier", e);
@@ -190,9 +215,9 @@
private TextClassifier getLocalTextClassifier() {
synchronized (mLock) {
if (mLocalTextClassifier == null) {
- if (mSettings.isLocalTextClassifierEnabled()) {
+ if (getSettings().isLocalTextClassifierEnabled()) {
mLocalTextClassifier =
- new TextClassifierImpl(mContext, mSettings, TextClassifier.NO_OP);
+ new TextClassifierImpl(mContext, getSettings(), TextClassifier.NO_OP);
} else {
Log.d(LOG_TAG, "Local TextClassifier disabled");
mLocalTextClassifier = TextClassifier.NO_OP;
@@ -203,20 +228,51 @@
}
private boolean isSystemTextClassifierEnabled() {
- return mSettings.isSystemTextClassifierEnabled()
+ return getSettings().isSystemTextClassifierEnabled()
&& TextClassifierService.getServiceComponentName(mContext) != null;
}
+ private void invalidate() {
+ synchronized (mLock) {
+ mSettings = null;
+ mLocalTextClassifier = null;
+ mSystemTextClassifier = null;
+ }
+ }
+
/** @hide */
public static TextClassificationConstants getSettings(Context context) {
Preconditions.checkNotNull(context);
final TextClassificationManager tcm =
context.getSystemService(TextClassificationManager.class);
if (tcm != null) {
- return tcm.mSettings;
+ return tcm.getSettings();
} else {
return TextClassificationConstants.loadFromString(Settings.Global.getString(
- context.getContentResolver(), Settings.Global.TEXT_CLASSIFIER_CONSTANTS));
+ context.getApplicationContext().getContentResolver(),
+ Settings.Global.TEXT_CLASSIFIER_CONSTANTS));
+ }
+ }
+
+ private static final class SettingsObserver extends ContentObserver {
+
+ private final WeakReference<TextClassificationManager> mTcm;
+
+ SettingsObserver(TextClassificationManager tcm) {
+ super(null);
+ mTcm = new WeakReference<>(tcm);
+ tcm.mContext.getApplicationContext().getContentResolver().registerContentObserver(
+ Settings.Global.getUriFor(Settings.Global.TEXT_CLASSIFIER_CONSTANTS),
+ false /* notifyForDescendants */,
+ this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ final TextClassificationManager tcm = mTcm.get();
+ if (tcm != null) {
+ tcm.invalidate();
+ }
}
}
}
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index 1f2b90a..8f1f1ab 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -70,7 +70,6 @@
private final Editor mEditor;
private final TextView mTextView;
private final TextClassificationHelper mTextClassificationHelper;
- private final TextClassificationConstants mTextClassificationSettings;
@Nullable private TextClassification mTextClassification;
private AsyncTask mTextClassificationAsyncTask;
@@ -84,7 +83,6 @@
SelectionActionModeHelper(@NonNull Editor editor) {
mEditor = Preconditions.checkNotNull(editor);
mTextView = mEditor.getTextView();
- mTextClassificationSettings = TextClassificationManager.getSettings(mTextView.getContext());
mTextClassificationHelper = new TextClassificationHelper(
mTextView.getContext(),
mTextView::getTextClassifier,
@@ -92,7 +90,7 @@
0, 1, mTextView.getTextLocales());
mSelectionTracker = new SelectionTracker(mTextView);
- if (mTextClassificationSettings.isSmartSelectionAnimationEnabled()) {
+ if (getTextClassificationSettings().isSmartSelectionAnimationEnabled()) {
mSmartSelectSprite = new SmartSelectSprite(mTextView.getContext(),
editor.getTextView().mHighlightColor, mTextView::invalidate);
} else {
@@ -105,7 +103,7 @@
*/
public void startSelectionActionModeAsync(boolean adjustSelection) {
// Check if the smart selection should run for editable text.
- adjustSelection &= mTextClassificationSettings.isSmartSelectionEnabled();
+ adjustSelection &= getTextClassificationSettings().isSmartSelectionEnabled();
mSelectionTracker.onOriginalSelection(
getText(mTextView),
@@ -212,6 +210,10 @@
return mSmartSelectSprite != null && mSmartSelectSprite.isAnimationActive();
}
+ private TextClassificationConstants getTextClassificationSettings() {
+ return TextClassificationManager.getSettings(mTextView.getContext());
+ }
+
private void cancelAsyncTask() {
if (mTextClassificationAsyncTask != null) {
mTextClassificationAsyncTask.cancel(true);
@@ -245,7 +247,7 @@
if (result != null && text instanceof Spannable
&& (mTextView.isTextSelectable() || mTextView.isTextEditable())) {
// Do not change the selection if TextClassifier should be dark launched.
- if (!mTextClassificationSettings.isModelDarkLaunchEnabled()) {
+ if (!getTextClassificationSettings().isModelDarkLaunchEnabled()) {
Selection.setSelection((Spannable) text, result.mStart, result.mEnd);
mTextView.invalidate();
}
@@ -906,7 +908,6 @@
private static final int TRIM_DELTA = 120; // characters
private final Context mContext;
- private final boolean mDarkLaunchEnabled;
private Supplier<TextClassifier> mTextClassifier;
/** The original TextView text. **/
@@ -942,8 +943,6 @@
CharSequence text, int selectionStart, int selectionEnd, LocaleList locales) {
init(textClassifier, text, selectionStart, selectionEnd, locales);
mContext = Preconditions.checkNotNull(context);
- mDarkLaunchEnabled = TextClassificationManager.getSettings(mContext)
- .isModelDarkLaunchEnabled();
}
@UiThread
@@ -982,7 +981,7 @@
mTrimmedText, mRelativeStart, mRelativeEnd, mDefaultLocales);
}
// Do not classify new selection boundaries if TextClassifier should be dark launched.
- if (!mDarkLaunchEnabled) {
+ if (!isDarkLaunchEnabled()) {
mSelectionStart = Math.max(0, selection.getSelectionStartIndex() + mTrimStart);
mSelectionEnd = Math.min(
mText.length(), selection.getSelectionEndIndex() + mTrimStart);
@@ -1010,6 +1009,10 @@
}
}
+ private boolean isDarkLaunchEnabled() {
+ return TextClassificationManager.getSettings(mContext).isModelDarkLaunchEnabled();
+ }
+
private SelectionResult performClassification(@Nullable TextSelection selection) {
if (!Objects.equals(mText, mLastClassificationText)
|| mSelectionStart != mLastClassificationSelectionStart
diff --git a/core/tests/coretests/src/android/provider/SettingsValidatorsTest.java b/core/tests/coretests/src/android/provider/SettingsValidatorsTest.java
index e750766..c4d5b0c 100644
--- a/core/tests/coretests/src/android/provider/SettingsValidatorsTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsValidatorsTest.java
@@ -16,9 +16,9 @@
package android.provider;
-import static org.junit.Assert.fail;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import android.platform.test.annotations.Presubmit;
import android.provider.SettingsValidators.Validator;
@@ -63,6 +63,11 @@
}
@Test
+ public void testComponentNameValidator_onNullValue_doesNotThrow() {
+ assertFalse(SettingsValidators.COMPONENT_NAME_VALIDATOR.validate(null));
+ }
+
+ @Test
public void testLocaleValidator() {
assertTrue(SettingsValidators.LOCALE_VALIDATOR.validate("en_US"));
assertTrue(SettingsValidators.LOCALE_VALIDATOR.validate("es"));
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 7b76fce..15df0a8 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -3522,14 +3522,7 @@
}
if (currentVersion == 150) {
- // Version 151: Reset rotate locked setting for upgrading users
- final SettingsState systemSettings = getSystemSettingsLocked(userId);
- systemSettings.insertSettingLocked(
- Settings.System.ACCELEROMETER_ROTATION,
- getContext().getResources().getBoolean(
- R.bool.def_accelerometer_rotation) ? "1" : "0",
- null, true, SettingsState.SYSTEM_PACKAGE_NAME);
-
+ // Version 151: Removed.
currentVersion = 151;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
index 0143d01..1303057 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
@@ -137,9 +137,15 @@
return;
}
StatusBarNotification sbn = mRow.getEntry().notification;
- new AsyncInflationTask(sbn, reInflateFlags, mRow, mIsLowPriority,
+ AsyncInflationTask task = new AsyncInflationTask(sbn, reInflateFlags, mRow,
+ mIsLowPriority,
mIsChildInGroup, mUsesIncreasedHeight, mUsesIncreasedHeadsUpHeight, mRedactAmbient,
- mCallback, mRemoteViewClickHandler).execute();
+ mCallback, mRemoteViewClickHandler);
+ if (mCallback != null && mCallback.doInflateSynchronous()) {
+ task.onPostExecute(task.doInBackground());
+ } else {
+ task.execute();
+ }
}
@VisibleForTesting
@@ -331,6 +337,30 @@
final HashMap<Integer, CancellationSignal> runningInflations,
ApplyCallback applyCallback) {
RemoteViews newContentView = applyCallback.getRemoteView();
+ if (callback != null && callback.doInflateSynchronous()) {
+ try {
+ if (isNewView) {
+ View v = newContentView.apply(
+ result.packageContext,
+ parentLayout,
+ remoteViewClickHandler);
+ v.setIsRootNamespace(true);
+ applyCallback.setResultView(v);
+ } else {
+ newContentView.reapply(
+ result.packageContext,
+ existingView,
+ remoteViewClickHandler);
+ existingWrapper.onReinflated();
+ }
+ } catch (Exception e) {
+ handleInflationError(runningInflations, e, entry.notification, callback);
+ // Add a running inflation to make sure we don't trigger callbacks.
+ // Safe to do because only happens in tests.
+ runningInflations.put(inflationId, new CancellationSignal());
+ }
+ return;
+ }
RemoteViews.OnViewAppliedListener listener
= new RemoteViews.OnViewAppliedListener() {
@@ -515,6 +545,13 @@
public interface InflationCallback {
void handleInflationException(StatusBarNotification notification, Exception e);
void onAsyncInflationFinished(NotificationData.Entry entry);
+
+ /**
+ * Used to disable async-ness for tests. Should only be used for tests.
+ */
+ default boolean doInflateSynchronous() {
+ return false;
+ }
}
public void onDensityOrFontScaleChanged() {
@@ -646,6 +683,11 @@
mRow.onNotificationUpdated();
mCallback.onAsyncInflationFinished(mRow.getEntry());
}
+
+ @Override
+ public boolean doInflateSynchronous() {
+ return mCallback != null && mCallback.doInflateSynchronous();
+ }
}
@VisibleForTesting
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 347a4b0..bef6944 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -252,7 +252,8 @@
@Override
public boolean onTouchEvent(MotionEvent event) {
- if (mInstantExpanding || mTouchDisabled
+ if (mInstantExpanding
+ || (mTouchDisabled && event.getActionMasked() != MotionEvent.ACTION_CANCEL)
|| (mMotionAborted && event.getActionMasked() != MotionEvent.ACTION_DOWN)) {
return false;
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaTest.java
index f3be945..f8ca262 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaTest.java
@@ -20,10 +20,9 @@
import static org.mockito.Mockito.mock;
-import android.os.Handler;
-import android.os.Looper;
-import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import com.android.systemui.SysuiTestCase;
@@ -32,33 +31,25 @@
import org.junit.runner.RunWith;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper
public class KeyguardMessageAreaTest extends SysuiTestCase {
- private Handler mHandler = new Handler(Looper.getMainLooper());
private KeyguardMessageArea mMessageArea;
@Before
public void setUp() throws Exception {
KeyguardUpdateMonitor monitor = mock(KeyguardUpdateMonitor.class);
- mHandler.post(()-> mMessageArea = new KeyguardMessageArea(mContext, null, monitor));
+ mMessageArea = new KeyguardMessageArea(mContext, null, monitor);
waitForIdleSync();
}
@Test
public void clearFollowedByMessage_keepsMessage() {
- mHandler.post(()-> {
- mMessageArea.setMessage("");
- mMessageArea.setMessage("test");
- });
-
- waitForIdleSync();
+ mMessageArea.setMessage("");
+ mMessageArea.setMessage("test");
CharSequence[] messageText = new CharSequence[1];
- mHandler.post(()-> {
- messageText[0] = mMessageArea.getText();
- });
-
- waitForIdleSync();
+ messageText[0] = mMessageArea.getText();
assertEquals("test", messageText[0]);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java
index aa840989..08c4235 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java
@@ -22,6 +22,8 @@
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.NotificationTestHelper;
@@ -35,7 +37,8 @@
import static org.mockito.Mockito.when;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class ExpandHelperTest extends SysuiTestCase {
private ExpandableNotificationRow mRow;
@@ -47,9 +50,7 @@
Context context = getContext();
mRow = new NotificationTestHelper(context).createRow();
mCallback = mock(ExpandHelper.Callback.class);
- InstrumentationRegistry.getInstrumentation().runOnMainSync(
- () -> mExpandHelper = new ExpandHelper(context, mCallback, 10, 100));
-
+ mExpandHelper = new ExpandHelper(context, mCallback, 10, 100);
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java
index a8ea1c0..c2da7f5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java
@@ -29,7 +29,8 @@
import android.os.Looper;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.systemui.SysuiTestCase;
@@ -46,7 +47,8 @@
@SmallTest
@Ignore("failing")
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class DozeTriggersTest extends SysuiTestCase {
private DozeTriggers mTriggers;
private DozeMachine mMachine;
@@ -54,7 +56,6 @@
private AmbientDisplayConfiguration mConfig;
private DozeParameters mParameters;
private FakeSensorManager mSensors;
- private Handler mHandler;
private WakeLock mWakeLock;
private Instrumentation mInstrumentation;
private AlarmManager mAlarmManager;
@@ -74,40 +75,29 @@
mConfig = DozeConfigurationUtil.createMockConfig();
mParameters = DozeConfigurationUtil.createMockParameters();
mSensors = new FakeSensorManager(mContext);
- mHandler = new Handler(Looper.getMainLooper());
mWakeLock = new WakeLockFake();
- mInstrumentation.runOnMainSync(() -> {
- mTriggers = new DozeTriggers(mContext, mMachine, mHost, mAlarmManager,
- mConfig, mParameters, mSensors, mHandler, mWakeLock, true);
- });
+ mTriggers = new DozeTriggers(mContext, mMachine, mHost, mAlarmManager, mConfig, mParameters,
+ mSensors, Handler.createAsync(Looper.myLooper()), mWakeLock, true);
}
@Test
public void testOnNotification_stillWorksAfterOneFailedProxCheck() throws Exception {
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
- mInstrumentation.runOnMainSync(()->{
- mTriggers.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED);
- mTriggers.transitionTo(DozeMachine.State.INITIALIZED, DozeMachine.State.DOZE);
+ mTriggers.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED);
+ mTriggers.transitionTo(DozeMachine.State.INITIALIZED, DozeMachine.State.DOZE);
- mHost.callback.onNotificationHeadsUp();
- });
+ mHost.callback.onNotificationHeadsUp();
- mInstrumentation.runOnMainSync(() -> {
- mSensors.getMockProximitySensor().sendProximityResult(false); /* Near */
- });
+ mSensors.getMockProximitySensor().sendProximityResult(false); /* Near */
verify(mMachine, never()).requestState(any());
verify(mMachine, never()).requestPulse(anyInt());
- mInstrumentation.runOnMainSync(()->{
- mHost.callback.onNotificationHeadsUp();
- });
+ mHost.callback.onNotificationHeadsUp();
- mInstrumentation.runOnMainSync(() -> {
- mSensors.getMockProximitySensor().sendProximityResult(true); /* Far */
- });
+ mSensors.getMockProximitySensor().sendProximityResult(true); /* Far */
verify(mMachine).requestPulse(anyInt());
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java b/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java
index b8c946d..b7c1e8e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java
@@ -24,43 +24,36 @@
import static org.junit.Assert.assertTrue;
import android.os.Handler;
-import android.os.HandlerThread;
import android.os.Looper;
import android.os.SystemClock;
import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+import android.testing.TestableLooper.RunWithLooper;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.pip.phone.PipTouchState;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
@SmallTest
+@RunWithLooper
public class PipTouchStateTest extends SysuiTestCase {
- private Handler mHandler;
- private HandlerThread mHandlerThread;
private PipTouchState mTouchState;
private CountDownLatch mDoubleTapCallbackTriggeredLatch;
@Before
public void setUp() throws Exception {
- mHandlerThread = new HandlerThread("PipTouchStateTestThread");
- mHandlerThread.start();
- mHandler = new Handler(mHandlerThread.getLooper());
-
mDoubleTapCallbackTriggeredLatch = new CountDownLatch(1);
mTouchState = new PipTouchState(ViewConfiguration.get(getContext()),
- mHandler, () -> {
+ Handler.createAsync(Looper.myLooper()), () -> {
mDoubleTapCallbackTriggeredLatch.countDown();
});
assertFalse(mTouchState.isDoubleTap());
@@ -91,7 +84,10 @@
assertTrue(mTouchState.getDoubleTapTimeoutCallbackDelay() == 10);
mTouchState.scheduleDoubleTapTimeoutCallback();
- mDoubleTapCallbackTriggeredLatch.await(1, TimeUnit.SECONDS);
+
+ // TODO: Remove this sleep. Its only being added because it speeds up this test a bit.
+ Thread.sleep(15);
+ TestableLooper.get(this).processAllMessages();
assertTrue(mDoubleTapCallbackTriggeredLatch.getCount() == 0);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
index 4f98836..33b347a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
@@ -22,12 +22,15 @@
import android.content.Context;
import android.content.pm.UserInfo;
-import android.os.Handler;
import android.os.Looper;
import android.os.UserManager;
import android.provider.Settings;
-import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
+import android.testing.AndroidTestingRunner;
+import android.testing.LayoutInflaterBuilder;
+import android.testing.TestableImageView;
+import android.testing.TestableLooper;
+import android.testing.TestableLooper.RunWithLooper;
import android.text.SpannableStringBuilder;
import android.view.LayoutInflater;
import android.view.View;
@@ -38,8 +41,6 @@
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.policy.SecurityController;
-import android.testing.LayoutInflaterBuilder;
-import android.testing.TestableImageView;
import org.junit.Before;
import org.junit.Test;
@@ -56,7 +57,8 @@
*/
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class QSSecurityFooterTest extends SysuiTestCase {
private final String MANAGING_ORGANIZATION = "organization";
@@ -81,12 +83,10 @@
.build());
mUserManager = Mockito.mock(UserManager.class);
mContext.addMockSystemService(Context.USER_SERVICE, mUserManager);
- Handler h = new Handler(Looper.getMainLooper());
- h.post(() -> mFooter = new QSSecurityFooter(null, mContext));
- waitForIdleSync(h);
+ mFooter = new QSSecurityFooter(null, mContext);
mRootView = (ViewGroup) mFooter.getView();
- mFooterText = (TextView) mRootView.findViewById(R.id.footer_text);
- mFooterIcon = (TestableImageView) mRootView.findViewById(R.id.footer_icon);
+ mFooterText = mRootView.findViewById(R.id.footer_text);
+ mFooterIcon = mRootView.findViewById(R.id.footer_icon);
mFooter.setHostEnvironment(null);
}
@@ -95,7 +95,7 @@
when(mSecurityController.isDeviceManaged()).thenReturn(false);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(View.GONE, mRootView.getVisibility());
}
@@ -105,7 +105,7 @@
when(mSecurityController.getDeviceOwnerOrganizationName()).thenReturn(null);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(R.string.quick_settings_disclosure_management),
mFooterText.getText());
assertEquals(View.VISIBLE, mRootView.getVisibility());
@@ -121,7 +121,7 @@
.thenReturn(MANAGING_ORGANIZATION);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(R.string.quick_settings_disclosure_named_management,
MANAGING_ORGANIZATION),
mFooterText.getText());
@@ -142,7 +142,7 @@
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(View.GONE, mRootView.getVisibility());
}
@@ -152,7 +152,7 @@
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(R.string.quick_settings_disclosure_management_monitoring),
mFooterText.getText());
assertEquals(View.VISIBLE, mFooterIcon.getVisibility());
@@ -164,7 +164,7 @@
.thenReturn(MANAGING_ORGANIZATION);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(
R.string.quick_settings_disclosure_named_management_monitoring,
MANAGING_ORGANIZATION),
@@ -177,7 +177,7 @@
when(mSecurityController.hasCACertInCurrentUser()).thenReturn(true);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(R.string.quick_settings_disclosure_management_monitoring),
mFooterText.getText());
}
@@ -189,7 +189,7 @@
when(mSecurityController.getPrimaryVpnName()).thenReturn(VPN_PACKAGE);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(R.string.quick_settings_disclosure_management_named_vpn,
VPN_PACKAGE),
mFooterText.getText());
@@ -201,7 +201,7 @@
.thenReturn(MANAGING_ORGANIZATION);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(
R.string.quick_settings_disclosure_named_management_named_vpn,
MANAGING_ORGANIZATION, VPN_PACKAGE),
@@ -216,7 +216,7 @@
when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(R.string.quick_settings_disclosure_management_vpns),
mFooterText.getText());
assertEquals(View.VISIBLE, mFooterIcon.getVisibility());
@@ -227,7 +227,7 @@
.thenReturn(MANAGING_ORGANIZATION);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(R.string.quick_settings_disclosure_named_management_vpns,
MANAGING_ORGANIZATION),
mFooterText.getText());
@@ -241,7 +241,7 @@
when(mSecurityController.getPrimaryVpnName()).thenReturn("VPN Test App");
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(View.VISIBLE, mFooterIcon.getVisibility());
assertEquals(R.drawable.ic_qs_vpn, mFooterIcon.getLastImageResource());
assertEquals(mContext.getString(R.string.quick_settings_disclosure_management_monitoring),
@@ -254,7 +254,7 @@
when(mSecurityController.hasCACertInWorkProfile()).thenReturn(true);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
// -1 == never set.
assertEquals(-1, mFooterIcon.getLastImageResource());
assertEquals(mContext.getString(
@@ -266,7 +266,7 @@
.thenReturn(MANAGING_ORGANIZATION);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(
R.string.quick_settings_disclosure_named_managed_profile_monitoring,
MANAGING_ORGANIZATION),
@@ -279,7 +279,7 @@
when(mSecurityController.hasCACertInCurrentUser()).thenReturn(true);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
// -1 == never set.
assertEquals(-1, mFooterIcon.getLastImageResource());
assertEquals(mContext.getString(R.string.quick_settings_disclosure_monitoring),
@@ -293,7 +293,7 @@
when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(R.drawable.ic_qs_vpn, mFooterIcon.getLastImageResource());
assertEquals(mContext.getString(R.string.quick_settings_disclosure_vpns),
mFooterText.getText());
@@ -305,7 +305,7 @@
when(mSecurityController.getWorkProfileVpnName()).thenReturn(VPN_PACKAGE_2);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(R.drawable.ic_qs_vpn, mFooterIcon.getLastImageResource());
assertEquals(mContext.getString(
R.string.quick_settings_disclosure_managed_profile_named_vpn,
@@ -319,7 +319,7 @@
when(mSecurityController.getPrimaryVpnName()).thenReturn(VPN_PACKAGE);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(R.drawable.ic_qs_vpn, mFooterIcon.getLastImageResource());
assertEquals(mContext.getString(R.string.quick_settings_disclosure_named_vpn,
VPN_PACKAGE),
@@ -328,7 +328,7 @@
when(mSecurityController.hasWorkProfile()).thenReturn(true);
mFooter.refreshState();
- waitForIdleSync(mFooter.mHandler);
+ TestableLooper.get(this).processAllMessages();
assertEquals(mContext.getString(
R.string.quick_settings_disclosure_personal_profile_named_vpn,
VPN_PACKAGE),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java
index 66ec7dd..e5e8ae3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java
@@ -81,7 +81,7 @@
mUser = new UserHandle(UserHandle.myUserId());
mThread = new HandlerThread("TestThread");
mThread.start();
- mHandler = new Handler(mThread.getLooper());
+ mHandler = Handler.createAsync(mThread.getLooper());
mStateManager = new TileLifecycleManager(mHandler, mContext,
Mockito.mock(IQSService.class), new Tile(),
mTileServiceIntent,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTest.java
index c2237c9..cc743245 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceManagerTest.java
@@ -46,7 +46,7 @@
public void setUp() throws Exception {
mThread = new HandlerThread("TestThread");
mThread.start();
- mHandler = new Handler(mThread.getLooper());
+ mHandler = Handler.createAsync(mThread.getLooper());
mTileServices = Mockito.mock(TileServices.class);
Mockito.when(mTileServices.getContext()).thenReturn(mContext);
mTileLifecycle = Mockito.mock(TileLifecycleManager.class);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AppOpsListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AppOpsListenerTest.java
index dc0e2b0..0feaa5a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AppOpsListenerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AppOpsListenerTest.java
@@ -16,8 +16,6 @@
package com.android.systemui.statusbar;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -53,7 +51,6 @@
@Mock private ForegroundServiceController mFsc;
private AppOpsListener mListener;
- private Handler mHandler;
@Before
public void setUp() {
@@ -61,8 +58,7 @@
mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
mDependency.injectTestDependency(ForegroundServiceController.class, mFsc);
getContext().addMockSystemService(AppOpsManager.class, mAppOpsManager);
- mHandler = new Handler(Looper.getMainLooper());
- when(mPresenter.getHandler()).thenReturn(mHandler);
+ when(mPresenter.getHandler()).thenReturn(Handler.createAsync(Looper.myLooper()));
mListener = new AppOpsListener(mContext);
}
@@ -85,7 +81,7 @@
mListener.setUpWithPresenter(mPresenter, mEntryManager);
mListener.onOpActiveChanged(
AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
- waitForIdleSync(mHandler);
+ TestableLooper.get(this).processAllMessages();
verify(mEntryManager, times(1)).updateNotificationsForAppOp(
AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
}
@@ -95,7 +91,7 @@
mListener.setUpWithPresenter(mPresenter, mEntryManager);
mListener.onOpActiveChanged(
AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
- waitForIdleSync(mHandler);
+ TestableLooper.get(this).processAllMessages();
verify(mFsc, times(1)).onAppOpChanged(
AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
index 2a4a5ad..ff12c53 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -33,7 +34,8 @@
import android.app.AppOpsManager;
import android.app.NotificationChannel;
import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.util.ArraySet;
import android.view.NotificationHeaderView;
import android.view.View;
@@ -49,15 +51,14 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Spy;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import java.util.List;
-import java.util.function.Consumer;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class ExpandableNotificationRowTest extends SysuiTestCase {
private ExpandableNotificationRow mGroupRow;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
index 1204dda..2af0c3e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
@@ -55,13 +55,10 @@
@Mock private NotificationGutsManager.OnSettingsClickListener mOnClickListener;
@Mock private NotificationRemoteInputManager.Callback mRemoteInputManagerCallback;
- private Handler mHandler;
-
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mHandler = new Handler(Looper.getMainLooper());
- when(mPresenter.getHandler()).thenReturn(mHandler);
+ when(mPresenter.getHandler()).thenReturn(Handler.createAsync(Looper.myLooper()));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java
index a6d87af..9638541 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java
@@ -52,7 +52,7 @@
@SmallTest
@FlakyTest
@org.junit.runner.RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class NotificationBlockingHelperManagerTest extends SysuiTestCase {
private NotificationBlockingHelperManager mBlockingHelperManager;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationCustomViewWrapperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationCustomViewWrapperTest.java
index 2ff86c3..a34588d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationCustomViewWrapperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationCustomViewWrapperTest.java
@@ -16,9 +16,9 @@
package com.android.systemui.statusbar;
-import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import android.widget.RemoteViews;
@@ -33,7 +33,8 @@
import org.junit.runner.RunWith;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class NotificationCustomViewWrapperTest extends SysuiTestCase {
private ExpandableNotificationRow mRow;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java
index 8bdaff9..609e032 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java
@@ -47,6 +47,8 @@
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.util.ArraySet;
import com.android.systemui.ForegroundServiceController;
@@ -61,7 +63,8 @@
import org.mockito.MockitoAnnotations;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class NotificationDataTest extends SysuiTestCase {
private static final int UID_NORMAL = 123;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryManagerTest.java
index 8172626..f05cf6b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryManagerTest.java
@@ -100,7 +100,6 @@
private NotificationData.Entry mEntry;
private StatusBarNotification mSbn;
- private Handler mHandler;
private TestableNotificationEntryManager mEntryManager;
private CountDownLatch mCountDownLatch;
@@ -160,10 +159,9 @@
mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager);
mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger);
- mHandler = new Handler(Looper.getMainLooper());
mCountDownLatch = new CountDownLatch(1);
- when(mPresenter.getHandler()).thenReturn(mHandler);
+ when(mPresenter.getHandler()).thenReturn(Handler.createAsync(Looper.myLooper()));
when(mPresenter.getNotificationLockscreenUserManager()).thenReturn(mLockscreenUserManager);
when(mPresenter.getGroupManager()).thenReturn(mGroupManager);
when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController);
@@ -188,6 +186,7 @@
@Test
public void testAddNotification() throws Exception {
com.android.systemui.util.Assert.isNotMainThread();
+ TestableLooper.get(this).processAllMessages();
doAnswer(invocation -> {
mCountDownLatch.countDown();
@@ -196,12 +195,10 @@
// Post on main thread, otherwise we will be stuck waiting here for the inflation finished
// callback forever, since it won't execute until the tests ends.
- mHandler.post(() -> {
- mEntryManager.addNotification(mSbn, mRankingMap);
- });
- assertTrue(mCountDownLatch.await(1, TimeUnit.MINUTES));
- assertTrue(mEntryManager.getCountDownLatch().await(1, TimeUnit.MINUTES));
- waitForIdleSync(mHandler);
+ mEntryManager.addNotification(mSbn, mRankingMap);
+ TestableLooper.get(this).processMessages(1);
+ assertTrue(mCountDownLatch.await(10, TimeUnit.SECONDS));
+ assertTrue(mEntryManager.getCountDownLatch().await(10, TimeUnit.SECONDS));
// Check that no inflation error occurred.
verify(mBarService, never()).onNotificationError(any(), any(), anyInt(), anyInt(), anyInt(),
@@ -228,17 +225,16 @@
@Test
public void testUpdateNotification() throws Exception {
com.android.systemui.util.Assert.isNotMainThread();
+ TestableLooper.get(this).processAllMessages();
mEntryManager.getNotificationData().add(mEntry);
setUserSentiment(mEntry.key, NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE);
- mHandler.post(() -> {
- mEntryManager.updateNotification(mSbn, mRankingMap);
- });
+ mEntryManager.updateNotification(mSbn, mRankingMap);
+ TestableLooper.get(this).processMessages(1);
// Wait for content update.
- mEntryManager.getCountDownLatch().await(1, TimeUnit.MINUTES);
- waitForIdleSync(mHandler);
+ assertTrue(mEntryManager.getCountDownLatch().await(10, TimeUnit.SECONDS));
verify(mBarService, never()).onNotificationError(any(), any(), anyInt(), anyInt(), anyInt(),
any(), anyInt());
@@ -259,10 +255,7 @@
mEntry.row = mRow;
mEntryManager.getNotificationData().add(mEntry);
- mHandler.post(() -> {
- mEntryManager.removeNotification(mSbn.getKey(), mRankingMap);
- });
- waitForIdleSync(mHandler);
+ mEntryManager.removeNotification(mSbn.getKey(), mRankingMap);
verify(mBarService, never()).onNotificationError(any(), any(), anyInt(), anyInt(), anyInt(),
any(), anyInt());
@@ -287,12 +280,9 @@
mEntry.row = mRow;
mEntryManager.getNotificationData().add(mEntry);
- mHandler.post(() -> {
- mEntryManager.updateNotificationsForAppOp(
- AppOpsManager.OP_CAMERA, mEntry.notification.getUid(),
- mEntry.notification.getPackageName(), true);
- });
- waitForIdleSync(mHandler);
+ mEntryManager.updateNotificationsForAppOp(
+ AppOpsManager.OP_CAMERA, mEntry.notification.getUid(),
+ mEntry.notification.getPackageName(), true);
verify(mPresenter, times(1)).updateNotificationViews();
assertTrue(mEntryManager.getNotificationData().get(mEntry.key).mActiveAppOps.contains(
@@ -305,10 +295,7 @@
when(mForegroundServiceController.getStandardLayoutKey(anyInt(), anyString()))
.thenReturn(null);
- mHandler.post(() -> {
- mEntryManager.updateNotificationsForAppOp(AppOpsManager.OP_CAMERA, 1000, "pkg", true);
- });
- waitForIdleSync(mHandler);
+ mEntryManager.updateNotificationsForAppOp(AppOpsManager.OP_CAMERA, 1000, "pkg", true);
verify(mPresenter, never()).updateNotificationViews();
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java
index 0ef2d051..cba1b54 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java
@@ -74,7 +74,7 @@
*/
@SmallTest
@RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class NotificationGutsManagerTest extends SysuiTestCase {
private static final String TEST_CHANNEL_ID = "NotificationManagerServiceTestChannelId";
@@ -95,7 +95,7 @@
@Before
public void setUp() {
mTestableLooper = TestableLooper.get(this);
- mHandler = new Handler(mTestableLooper.getLooper());
+ mHandler = Handler.createAsync(mTestableLooper.getLooper());
mHelper = new NotificationTestHelper(mContext);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
index ef5f071..c6397e6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
@@ -59,7 +59,6 @@
@Mock private NotificationRemoteInputManager mRemoteInputManager;
private NotificationListener mListener;
- private Handler mHandler;
private StatusBarNotification mSbn;
private Set<String> mKeysKeptForRemoteInput;
@@ -70,10 +69,9 @@
mDependency.injectTestDependency(NotificationRemoteInputManager.class,
mRemoteInputManager);
- mHandler = new Handler(Looper.getMainLooper());
mKeysKeptForRemoteInput = new HashSet<>();
- when(mPresenter.getHandler()).thenReturn(mHandler);
+ when(mPresenter.getHandler()).thenReturn(Handler.createAsync(Looper.myLooper()));
when(mEntryManager.getNotificationData()).thenReturn(mNotificationData);
when(mRemoteInputManager.getKeysKeptForRemoteInput()).thenReturn(mKeysKeptForRemoteInput);
@@ -87,7 +85,7 @@
@Test
public void testNotificationAddCallsAddNotification() {
mListener.onNotificationPosted(mSbn, mRanking);
- waitForIdleSync(mHandler);
+ TestableLooper.get(this).processAllMessages();
verify(mEntryManager).addNotification(mSbn, mRanking);
}
@@ -95,7 +93,7 @@
public void testPostNotificationRemovesKeyKeptForRemoteInput() {
mKeysKeptForRemoteInput.add(mSbn.getKey());
mListener.onNotificationPosted(mSbn, mRanking);
- waitForIdleSync(mHandler);
+ TestableLooper.get(this).processAllMessages();
assertTrue(mKeysKeptForRemoteInput.isEmpty());
}
@@ -103,21 +101,21 @@
public void testNotificationUpdateCallsUpdateNotification() {
when(mNotificationData.get(mSbn.getKey())).thenReturn(new NotificationData.Entry(mSbn));
mListener.onNotificationPosted(mSbn, mRanking);
- waitForIdleSync(mHandler);
+ TestableLooper.get(this).processAllMessages();
verify(mEntryManager).updateNotification(mSbn, mRanking);
}
@Test
public void testNotificationRemovalCallsRemoveNotification() {
mListener.onNotificationRemoved(mSbn, mRanking);
- waitForIdleSync(mHandler);
+ TestableLooper.get(this).processAllMessages();
verify(mEntryManager).removeNotification(mSbn.getKey(), mRanking);
}
@Test
public void testRankingUpdateCallsNotificationRankingUpdate() {
mListener.onNotificationRankingUpdate(mRanking);
- waitForIdleSync(mHandler);
+ TestableLooper.get(this).processAllMessages();
// RankingMap may be modified by plugins.
verify(mEntryManager).updateNotificationRanking(any());
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
index cb8f7ce..2401519 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
@@ -63,7 +63,6 @@
@Mock private DeviceProvisionedController mDeviceProvisionedController;
private int mCurrentUserId;
- private Handler mHandler;
private TestNotificationLockscreenUserManager mLockscreenUserManager;
@Before
@@ -73,13 +72,12 @@
mDependency.injectTestDependency(DeviceProvisionedController.class,
mDeviceProvisionedController);
- mHandler = new Handler(Looper.getMainLooper());
mContext.addMockSystemService(UserManager.class, mUserManager);
mCurrentUserId = ActivityManager.getCurrentUser();
when(mUserManager.getProfiles(mCurrentUserId)).thenReturn(Lists.newArrayList(
new UserInfo(mCurrentUserId, "", 0), new UserInfo(mCurrentUserId + 1, "", 0)));
- when(mPresenter.getHandler()).thenReturn(mHandler);
+ when(mPresenter.getHandler()).thenReturn(Handler.createAsync(Looper.myLooper()));
mLockscreenUserManager = new TestNotificationLockscreenUserManager(mContext);
mLockscreenUserManager.setUpWithPresenter(mPresenter, mEntryManager);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLoggerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLoggerTest.java
index 14fada5..bbb03d7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLoggerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLoggerTest.java
@@ -26,7 +26,6 @@
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
-import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
@@ -35,7 +34,6 @@
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.UiOffloadThread;
import com.google.android.collect.Lists;
@@ -48,7 +46,7 @@
@SmallTest
@RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class NotificationLoggerTest extends SysuiTestCase {
private static final String TEST_PACKAGE_NAME = "test";
private static final int TEST_UID = 0;
@@ -89,7 +87,7 @@
when(mListContainer.isInVisibleLocation(any())).thenReturn(true);
when(mNotificationData.getActiveNotifications()).thenReturn(Lists.newArrayList(mEntry));
mLogger.getChildLocationsChangedListenerForTest().onChildLocationsChanged();
- waitForIdleSync(mLogger.getHandlerForTest());
+ TestableLooper.get(this).processAllMessages();
waitForUiOffloadThread();
NotificationVisibility[] newlyVisibleKeys = {
@@ -101,7 +99,7 @@
// |mEntry| won't change visibility, so it shouldn't be reported again:
Mockito.reset(mBarService);
mLogger.getChildLocationsChangedListenerForTest().onChildLocationsChanged();
- waitForIdleSync(mLogger.getHandlerForTest());
+ TestableLooper.get(this).processAllMessages();
waitForUiOffloadThread();
verify(mBarService, never()).onNotificationVisibilityChanged(any(), any());
@@ -113,7 +111,7 @@
when(mListContainer.isInVisibleLocation(any())).thenReturn(true);
when(mNotificationData.getActiveNotifications()).thenReturn(Lists.newArrayList(mEntry));
mLogger.getChildLocationsChangedListenerForTest().onChildLocationsChanged();
- waitForIdleSync(mLogger.getHandlerForTest());
+ TestableLooper.get(this).processAllMessages();
waitForUiOffloadThread();
Mockito.reset(mBarService);
@@ -128,8 +126,8 @@
public TestableNotificationLogger(IStatusBarService barService) {
mBarService = barService;
- // Make this on the main thread so we can wait for it during tests.
- mHandler = new Handler(Looper.getMainLooper());
+ // Make this on the current thread so we can wait for it during tests.
+ mHandler = Handler.createAsync(Looper.myLooper());
}
public OnChildLocationsChangedListener
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java
index 4829cb2..8b2f6cd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java
@@ -45,7 +45,6 @@
@Mock private NotificationEntryManager mEntryManager;
@Mock private NotificationLockscreenUserManager mLockscreenUserManager;
- private Handler mHandler;
private TestableNotificationRemoteInputManager mRemoteInputManager;
private StatusBarNotification mSbn;
private NotificationData.Entry mEntry;
@@ -56,9 +55,8 @@
mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
mDependency.injectTestDependency(NotificationLockscreenUserManager.class,
mLockscreenUserManager);
- mHandler = new Handler(Looper.getMainLooper());
- when(mPresenter.getHandler()).thenReturn(mHandler);
+ when(mPresenter.getHandler()).thenReturn(Handler.createAsync(Looper.myLooper()));
when(mEntryManager.getLatestRankingMap()).thenReturn(mRanking);
mRemoteInputManager = new TestableNotificationRemoteInputManager(mContext);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
index de2e6bf..2b0c6bf 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
@@ -143,12 +143,10 @@
throws Exception {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
mContext.LAYOUT_INFLATER_SERVICE);
- mInstrumentation.runOnMainSync(() ->
- mRow = (ExpandableNotificationRow) inflater.inflate(
- R.layout.status_bar_notification_row,
- null /* root */,
- false /* attachToRoot */)
- );
+ mRow = (ExpandableNotificationRow) inflater.inflate(
+ R.layout.status_bar_notification_row,
+ null /* root */,
+ false /* attachToRoot */);
ExpandableNotificationRow row = mRow;
row.setGroupManager(mGroupManager);
row.setHeadsUpManager(mHeadsUpManager);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java
index 76ed452..0d0d1f86 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java
@@ -50,7 +50,7 @@
@SmallTest
@RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class NotificationViewHierarchyManagerTest extends SysuiTestCase {
@Mock private NotificationPresenter mPresenter;
@Mock private NotificationData mNotificationData;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java
index 1ee9b32..00e9995 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java
@@ -21,6 +21,8 @@
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.widget.FrameLayout;
import com.android.systemui.SysuiTestCase;
@@ -33,7 +35,8 @@
import org.junit.runner.RunWith;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class AboveShelfObserverTest extends SysuiTestCase {
private AboveShelfObserver mObserver;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java
index 83a2883..aa8a08c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java
@@ -18,6 +18,7 @@
import static com.android.systemui.statusbar.notification.NotificationInflater.FLAG_REINFLATE_ALL;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -28,10 +29,9 @@
import android.os.Handler;
import android.os.Looper;
import android.service.notification.StatusBarNotification;
-import android.support.test.annotation.UiThreadTest;
-import android.support.test.filters.FlakyTest;
import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RemoteViews;
@@ -52,9 +52,11 @@
import java.util.HashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class NotificationInflaterTest extends SysuiTestCase {
private NotificationInflater mNotificationInflater;
@@ -85,7 +87,6 @@
}
@Test
- @UiThreadTest
public void testIncreasedHeadsUpBeingUsed() {
mNotificationInflater.setUsesIncreasedHeadsUpHeight(true);
Notification.Builder builder = spy(mBuilder);
@@ -94,7 +95,6 @@
}
@Test
- @UiThreadTest
public void testIncreasedHeightBeingUsed() {
mNotificationInflater.setUsesIncreasedHeight(true);
Notification.Builder builder = spy(mBuilder);
@@ -115,8 +115,8 @@
mRow.getEntry().cachedBigContentView = null;
runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(
NotificationInflater.FLAG_REINFLATE_EXPANDED_VIEW), mNotificationInflater);
- Assert.assertTrue(mRow.getPrivateLayout().getChildCount() == 1);
- Assert.assertTrue(mRow.getPrivateLayout().getChildAt(0)
+ assertTrue(mRow.getPrivateLayout().getChildCount() == 1);
+ assertTrue(mRow.getPrivateLayout().getChildAt(0)
== mRow.getPrivateLayout().getExpandedChild());
verify(mRow).onNotificationUpdated();
}
@@ -128,7 +128,7 @@
= new RemoteViews(mContext.getPackageName(), R.layout.status_bar);
runThenWaitForInflation(() -> mNotificationInflater.inflateNotificationViews(),
true /* expectingException */, mNotificationInflater);
- Assert.assertTrue(mRow.getPrivateLayout().getChildCount() == 0);
+ assertTrue(mRow.getPrivateLayout().getChildCount() == 0);
verify(mRow, times(0)).onNotificationUpdated();
}
@@ -181,12 +181,11 @@
R.layout.custom_view_dark);
}
});
- countDownLatch.await();
+ assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS));
}
/* Cancelling requires us to be on the UI thread otherwise we might have a race */
@Test
- @UiThreadTest
public void testSupersedesExistingTask() throws Exception {
mNotificationInflater.inflateNotificationViews();
mNotificationInflater.setIsLowPriority(true);
@@ -219,7 +218,6 @@
private static void runThenWaitForInflation(Runnable block, boolean expectingException,
NotificationInflater inflater) throws Exception {
- com.android.systemui.util.Assert.isNotMainThread();
CountDownLatch countDownLatch = new CountDownLatch(1);
final ExceptionHolder exceptionHolder = new ExceptionHolder();
inflater.setInflationCallback(new NotificationInflater.InflationCallback() {
@@ -240,9 +238,14 @@
}
countDownLatch.countDown();
}
+
+ @Override
+ public boolean doInflateSynchronous() {
+ return true;
+ }
});
block.run();
- countDownLatch.await();
+ assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS));
if (exceptionHolder.mException != null) {
throw exceptionHolder.mException;
}
@@ -257,7 +260,7 @@
}
private class AsyncFailRemoteView extends RemoteViews {
- Handler mHandler = new Handler(Looper.getMainLooper());
+ Handler mHandler = Handler.createAsync(Looper.getMainLooper());
public AsyncFailRemoteView(String packageName, int layoutId) {
super(packageName, layoutId);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java
index 9da28a0..7e2e505 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java
@@ -20,6 +20,8 @@
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import com.android.systemui.SysuiTestCase;
@@ -30,8 +32,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
@SmallTest
+@RunWithLooper(setAsMainLooper = true)
public class NotificationViewWrapperTest extends SysuiTestCase {
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java
index 36fd499..23365a4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java
@@ -51,7 +51,7 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mAutoTileManager = new AutoTileManager(mContext, mAutoAddTracker, mQsTileHost,
- new Handler(TestableLooper.get(this).getLooper()));
+ Handler.createAsync(TestableLooper.get(this).getLooper()));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
index 7a61bfe..537bfd4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
@@ -26,6 +26,8 @@
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import android.widget.TextView;
@@ -47,7 +49,8 @@
import java.util.HashSet;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
private final NotificationStackScrollLayout mStackScroller =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index 37e0005..0a412b9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -48,6 +48,7 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IPowerManager;
+import android.os.Looper;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -173,10 +174,8 @@
mNotificationLogger = new NotificationLogger();
IPowerManager powerManagerService = mock(IPowerManager.class);
- HandlerThread handlerThread = new HandlerThread("TestThread");
- handlerThread.start();
mPowerManager = new PowerManager(mContext, powerManagerService,
- new Handler(handlerThread.getLooper()));
+ Handler.createAsync(Looper.myLooper()));
CommandQueue commandQueue = mock(CommandQueue.class);
when(commandQueue.asBinder()).thenReturn(new Binder());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java
index 7e1aba5..938dfca 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java
@@ -21,6 +21,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ShortcutManager;
+import android.os.Handler;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -28,6 +29,7 @@
import android.widget.EditText;
import android.widget.ImageButton;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.ExpandableNotificationRow;
@@ -42,7 +44,7 @@
import org.mockito.MockitoAnnotations;
@RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class RemoteInputViewTest extends SysuiTestCase {
@@ -60,7 +62,8 @@
MockitoAnnotations.initMocks(this);
mReceiver = new BlockingQueueIntentReceiver();
- mContext.registerReceiver(mReceiver, new IntentFilter(TEST_ACTION));
+ mContext.registerReceiver(mReceiver, new IntentFilter(TEST_ACTION), null,
+ Handler.createAsync(Dependency.get(Dependency.BG_LOOPER)));
// Avoid SecurityException RemoteInputView#sendRemoteInput().
mContext.addMockSystemService(ShortcutManager.class, mShortcutManager);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java
index aca7c9c..2266b47 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java
@@ -51,7 +51,7 @@
resources.addOverride(R.bool.config_smart_replies_in_notifications_enabled, true);
resources.addOverride(
R.integer.config_smart_replies_in_notifications_max_squeeze_remeasure_attempts, 7);
- mConstants = new SmartReplyConstants(new Handler(Looper.getMainLooper()), mContext);
+ mConstants = new SmartReplyConstants(Handler.createAsync(Looper.myLooper()), mContext);
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/ZenModeControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/ZenModeControllerImplTest.java
index ff65587..7437e834 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/ZenModeControllerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/ZenModeControllerImplTest.java
@@ -24,6 +24,7 @@
import android.app.NotificationManager;
import android.os.Handler;
+import android.os.Looper;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
import android.support.test.filters.SmallTest;
@@ -58,7 +59,7 @@
mContext.addMockSystemService(NotificationManager.class, mNm);
when(mNm.getZenModeConfig()).thenReturn(mConfig);
- mController = new ZenModeControllerImpl(mContext, new Handler());
+ mController = new ZenModeControllerImpl(mContext, Handler.createAsync(Looper.myLooper()));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java
index 5ac965c..8a74019 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java
@@ -18,6 +18,8 @@
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.view.NotificationHeaderView;
import android.view.View;
@@ -31,7 +33,8 @@
import org.junit.runner.RunWith;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class NotificationChildrenContainerTest extends SysuiTestCase {
private ExpandableNotificationRow mGroup;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java
index 28d1aff..16e69f4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java
@@ -16,29 +16,18 @@
package com.android.systemui.statusbar.stack;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyFloat;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.statusbar.ActivatableNotificationView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.NotificationTestHelper;
-import com.android.systemui.statusbar.StatusBarState;
-import com.android.systemui.statusbar.phone.ScrimController;
-import com.android.systemui.statusbar.phone.StatusBar;
import org.junit.Assert;
import org.junit.Before;
@@ -46,10 +35,10 @@
import org.junit.runner.RunWith;
import java.util.HashSet;
-import java.util.function.Consumer;
@SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(AndroidTestingRunner.class)
+@RunWithLooper(setAsMainLooper = true)
public class NotificationRoundnessManagerTest extends SysuiTestCase {
private NotificationRoundnessManager mRoundnessManager = new NotificationRoundnessManager();
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index 61b1dcc..3beebcb 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -287,8 +287,10 @@
pw.print(" "); pw.print(KEY_TOP_STATE_SETTLE_TIME); pw.print("=");
TimeUtils.formatDuration(TOP_STATE_SETTLE_TIME, pw);
+ pw.println();
pw.print(" "); pw.print(KEY_FG_SERVICE_STATE_SETTLE_TIME); pw.print("=");
TimeUtils.formatDuration(FG_SERVICE_STATE_SETTLE_TIME, pw);
+ pw.println();
pw.print(" "); pw.print(KEY_BG_STATE_SETTLE_TIME); pw.print("=");
TimeUtils.formatDuration(BG_STATE_SETTLE_TIME, pw);
pw.println();
diff --git a/services/core/java/com/android/server/am/RecentsAnimation.java b/services/core/java/com/android/server/am/RecentsAnimation.java
index 67230c3..bd49bd1 100644
--- a/services/core/java/com/android/server/am/RecentsAnimation.java
+++ b/services/core/java/com/android/server/am/RecentsAnimation.java
@@ -52,8 +52,7 @@
class RecentsAnimation implements RecentsAnimationCallbacks,
ActivityDisplay.OnStackOrderChangedListener {
private static final String TAG = RecentsAnimation.class.getSimpleName();
- // TODO (b/73188263): Reset debugging flags
- private static final boolean DEBUG = true;
+ private static final boolean DEBUG = false;
private final ActivityManagerService mService;
private final ActivityStackSupervisor mStackSupervisor;
diff --git a/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java b/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
index 990eb97..c366e4d 100644
--- a/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
+++ b/services/core/java/com/android/server/wm/WindowManagerDebugConfig.java
@@ -74,9 +74,8 @@
static final boolean SHOW_STACK_CRAWLS = false;
static final boolean DEBUG_WINDOW_CROP = false;
static final boolean DEBUG_UNKNOWN_APP_VISIBILITY = false;
- // TODO (b/73188263): Reset debugging flags
- static final boolean DEBUG_RECENTS_ANIMATIONS = true;
- static final boolean DEBUG_REMOTE_ANIMATIONS = DEBUG_APP_TRANSITIONS || true;
+ static final boolean DEBUG_RECENTS_ANIMATIONS = false;
+ static final boolean DEBUG_REMOTE_ANIMATIONS = DEBUG_APP_TRANSITIONS || false;
static final String TAG_KEEP_SCREEN_ON = "DebugKeepScreenOn";
static final boolean DEBUG_KEEP_SCREEN_ON = false;
diff --git a/wifi/java/android/net/wifi/RttManager.java b/wifi/java/android/net/wifi/RttManager.java
index 50c4b5e..9ab374a 100644
--- a/wifi/java/android/net/wifi/RttManager.java
+++ b/wifi/java/android/net/wifi/RttManager.java
@@ -995,6 +995,10 @@
result.getDistanceStdDevMm() / 10;
legacyResults[i].rssi = result.getRssi() * -2;
legacyResults[i].ts = result.getRangingTimestampMillis() * 1000;
+ legacyResults[i].measurementFrameNumber =
+ result.getNumAttemptedMeasurements();
+ legacyResults[i].successMeasurementFrameNumber =
+ result.getNumSuccessfulMeasurements();
} else {
// just in case legacy API needed some relatively real timestamp
legacyResults[i].ts = SystemClock.elapsedRealtime() * 1000;