Merge "Pass WindowContext to DisplayInfoChangeListener" into sc-dev
This commit is contained in:
@@ -21,6 +21,7 @@ import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION;
|
||||
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.res.Configuration;
|
||||
@@ -296,7 +297,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayInfoChanged(Info info, int flags) {
|
||||
public void onDisplayInfoChanged(Context context, Info info, int flags) {
|
||||
if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.updateIsSeascape(this)) {
|
||||
reapplyUi();
|
||||
}
|
||||
|
||||
@@ -203,9 +203,9 @@ public class InvariantDeviceProfile {
|
||||
.apply();
|
||||
|
||||
DisplayController.INSTANCE.get(context).addChangeListener(
|
||||
(info, flags) -> {
|
||||
(displayContext, info, flags) -> {
|
||||
if ((flags & (CHANGE_SIZE | CHANGE_DENSITY)) != 0) {
|
||||
onConfigChanged(context);
|
||||
onConfigChanged(displayContext);
|
||||
}
|
||||
});
|
||||
mOverlayMonitor = new OverlayMonitor(context);
|
||||
@@ -226,7 +226,7 @@ public class InvariantDeviceProfile {
|
||||
*/
|
||||
public InvariantDeviceProfile(Context context, Display display) {
|
||||
// Ensure that the main device profile is initialized
|
||||
InvariantDeviceProfile originalProfile = INSTANCE.get(context);
|
||||
INSTANCE.get(context);
|
||||
String gridName = getCurrentGridName(context);
|
||||
|
||||
// Get the display info based on default display and interpolate it to existing display
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
|
||||
new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
|
||||
}
|
||||
|
||||
mInfo = createInfo(display);
|
||||
mInfo = new Info(getContext(display), display);
|
||||
mDM.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler());
|
||||
}
|
||||
|
||||
@@ -125,7 +125,13 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
|
||||
*/
|
||||
public interface DisplayInfoChangeListener {
|
||||
|
||||
void onDisplayInfoChanged(Info info, int flags);
|
||||
/**
|
||||
* Invoked when display info has changed.
|
||||
* @param context updated context associated with the display.
|
||||
* @param info updated display information.
|
||||
* @param flags bitmask indicating type of change.
|
||||
*/
|
||||
void onDisplayInfoChanged(Context context, Info info, int flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,14 +178,15 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
|
||||
return mInfo;
|
||||
}
|
||||
|
||||
private Info createInfo(Display display) {
|
||||
return new Info(mContext.createDisplayContext(display), display);
|
||||
private Context getContext(Display display) {
|
||||
return Utilities.ATLEAST_S ? mWindowContext : mContext.createDisplayContext(display);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
private void handleInfoChange(Display display) {
|
||||
Info oldInfo = mInfo;
|
||||
Info newInfo = createInfo(display);
|
||||
Context context = getContext(display);
|
||||
Info newInfo = new Info(context, display);
|
||||
int change = 0;
|
||||
if (newInfo.hasDifferentSize(oldInfo)) {
|
||||
change |= CHANGE_SIZE;
|
||||
@@ -197,13 +204,13 @@ public class DisplayController implements DisplayListener, ComponentCallbacks {
|
||||
if (change != 0) {
|
||||
mInfo = newInfo;
|
||||
final int flags = change;
|
||||
MAIN_EXECUTOR.execute(() -> notifyChange(flags));
|
||||
MAIN_EXECUTOR.execute(() -> notifyChange(context, flags));
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyChange(int flags) {
|
||||
private void notifyChange(Context context, int flags) {
|
||||
for (int i = mListeners.size() - 1; i >= 0; i--) {
|
||||
mListeners.get(i).onDisplayInfoChanged(mInfo, flags);
|
||||
mListeners.get(i).onDisplayInfoChanged(context, mInfo, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user