mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Merge "Revert "Revert "Migrating all model tests to Instrumentation tests""" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
667bda8448
@@ -58,7 +58,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";
|
||||
|
||||
@@ -82,6 +82,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;
|
||||
@@ -118,6 +119,17 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
|
||||
return internalDisplays;
|
||||
}
|
||||
|
||||
@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) { }
|
||||
|
||||
@@ -165,6 +177,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");
|
||||
|
||||
Reference in New Issue
Block a user