[Launcher Jank] Improve SimpleBroadcastReceiver.java

Bug: 348649441
Flag: NONE - jank fix
Test: manual - presubmit
Change-Id: I17bd7e4d7f0640522476e94edae691f983835f62
This commit is contained in:
Fengjiang Li committed 2024-07-11 11:12:29 -07:00
1 parent 6e43c6aadf
commit b87ad6f945
13 files changed
+355 -119

No files matched your search

@@ -109,7 +109,10 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
private DisplayInfoChangeListener mPriorityListener;
private final ArrayList<DisplayInfoChangeListener> mListeners = new ArrayList<>();
private final SimpleBroadcastReceiver mReceiver = new SimpleBroadcastReceiver(this::onIntent);
// We will register broadcast receiver on main thread to ensure not missing changes on
// TARGET_OVERLAY_PACKAGE and ACTION_OVERLAY_CHANGED.
private final SimpleBroadcastReceiver mReceiver =
new SimpleBroadcastReceiver(MAIN_EXECUTOR, this::onIntent);
private Info mInfo;
private boolean mDestroyed = false;
@@ -132,11 +135,11 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
mWindowContext.registerComponentCallbacks(this);
} else {
mWindowContext = null;
mReceiver.registerAsync(mContext, ACTION_CONFIGURATION_CHANGED);
mReceiver.register(mContext, ACTION_CONFIGURATION_CHANGED);
}
// Initialize navigation mode change listener
mReceiver.registerPkgActionsAsync(mContext, TARGET_OVERLAY_PACKAGE, ACTION_OVERLAY_CHANGED);
mReceiver.registerPkgActions(mContext, TARGET_OVERLAY_PACKAGE, ACTION_OVERLAY_CHANGED);
WindowManagerProxy wmProxy = WindowManagerProxy.INSTANCE.get(context);
Context displayInfoContext = getDisplayInfoContext(display);
@@ -223,7 +226,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
} else {
// TODO: unregister broadcast receiver
}
mReceiver.unregisterReceiverSafelyAsync(mContext);
mReceiver.unregisterReceiverSafely(mContext);
}
/**