fix: Crash in multi-window on API 26-29 (#7453)

getMultiWindowDisplaySize() calls WindowManager.getCurrentWindowMetrics(),
added in API 30, without a version check. Lawnchair runs down to
minSdk 26, so building the multi-window device profile
(Launcher#initDeviceProfile and the fallback RecentsActivity) throws
NoSuchMethodError on Android 8-10 devices in split-screen.

Derive the bounds from the default display size below R.

Co-authored-by: caizhixing <17589399+caizhixing03@user.noreply.gitee.com>
This commit is contained in:
caizhixingandcaizhixing authored and GitHub committed 2026-10-30 21:37:05 +07:00
1 parent be56ee534f
commit d714016ffc
1 file changed
+10 -1
+10 -1
View File
@@ -28,11 +28,13 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Point;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.ActionMode;
import android.view.Display;
import android.view.View;
import android.window.OnBackInvokedDispatcher;
@@ -530,7 +532,14 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
}
protected WindowBounds getMultiWindowDisplaySize() {
return WindowBounds.fromWindowMetrics(getWindowManager().getCurrentWindowMetrics());
if (Utilities.ATLEAST_R) {
return WindowBounds.fromWindowMetrics(getWindowManager().getCurrentWindowMetrics());
} else {
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return new WindowBounds(size.x, size.y, size.x, size.y, -1);
}
}
@Override