Migrating all model tests to Instrumentation tests

Bug: 196825541
Test: Presubmit
Change-Id: Iebd46eb41eb46c187d569197f4b97b4fddc0f6f7
This commit is contained in:
Sunny Goyal committed 2021-08-23 12:34:44 -07:00
1 parent 494bbb0b6c
commit 455ba62b5d
31 files changed
+784 -684

No files matched your search

@@ -55,7 +55,7 @@ import java.util.Set;
* Utility class to cache properties of default display to avoid a system RPC on every call.
*/
@SuppressLint("NewApi")
public class DisplayController implements DisplayListener, ComponentCallbacks {
public class DisplayController implements DisplayListener, ComponentCallbacks, SafeCloseable {
private static final String TAG = "DisplayController";
@@ -79,6 +79,7 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
private final ArrayList<DisplayInfoChangeListener> mListeners = new ArrayList<>();
private Info mInfo;
private boolean mDestroyed = false;
private DisplayController(Context context) {
mContext = context;
@@ -110,6 +111,17 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
mDM.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler());
}
@Override
public void close() {
mDestroyed = true;
if (mWindowContext != null) {
mWindowContext.unregisterComponentCallbacks(this);
} else {
// TODO: unregister broadcast receiver
}
mDM.unregisterDisplayListener(this);
}
@Override
public final void onDisplayAdded(int displayId) { }
@@ -157,6 +169,9 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
* Only used for pre-S
*/
private void onConfigChanged(Intent intent) {
if (mDestroyed) {
return;
}
Configuration config = mContext.getResources().getConfiguration();
if (mInfo.fontScale != config.fontScale || mInfo.densityDpi != config.densityDpi) {
Log.d(TAG, "Configuration changed, notifying listeners");