feat: Android 11 support

This commit is contained in:
Pun Butrach committed 2026-01-10 20:51:29 +07:00
1 parent 0ddb32979e
commit a2edbcbe75
21 files changed
+155 -62

No files matched your search

+3 -1
View File
@@ -116,10 +116,11 @@ Compatibility list:
| 🏗️ Crash | 🥞 Fully supported |
|-------------|--------------------|
| Android 8.0 | Android 11 |
| Android 8.1 | Android 12.0 |
| Android 9 | Android 12.1 |
| Android 10 | Android 13 |
| Android 11 | Android 14 |
| | Android 14 |
| | Android 15 |
| | Android 16 |
@@ -158,6 +159,7 @@ Compatibility list:
* [Lawnchair] Correctly display warning in experimental features (race conditions)
* [Project] Support for Android Studio 2025.2.3 Canary 5 (Bump to AGP 9.0.0-beta05)
* [Lawnchair] Offer a toggle to disable/enable suggestions instead of linking it to ASI if the device is not Google Pixel
* [Launcher] Android 11 support
### 🥞 Development 3 Release 2
@@ -3,6 +3,7 @@ package app.lawnchair.util
import android.content.Context
import android.content.res.Resources
import android.graphics.Insets
import android.graphics.Point
import android.graphics.Rect
import android.hardware.display.DisplayManager
import android.util.ArrayMap
@@ -33,6 +33,7 @@ import com.android.app.displaylib.PerDisplayInstanceRepositoryImpl
import com.android.app.displaylib.PerDisplayRepository
import com.android.app.displaylib.SingleInstanceRepositoryImpl
import com.android.app.displaylib.createDisplayLibComponent
import com.android.launcher3.Utilities
import com.android.launcher3.util.coroutines.DispatcherProvider
import com.android.quickstep.FallbackWindowInterface
import com.android.quickstep.RecentsAnimationDeviceState
@@ -189,22 +190,30 @@ object PerDisplayRepositoriesModule {
"DisplayContextRepo",
{ displayId ->
displayRepository.getDisplay(displayId)?.let {
context.createWindowContext(
it,
TYPE_APPLICATION_OVERLAY,
/* options=*/ null,
)
if (Utilities.ATLEAST_S) {
context.createWindowContext(
it,
TYPE_APPLICATION_OVERLAY,
/* options=*/ null,
)
} else {
context.createDisplayContext(it)
}
}
},
)
} else {
SingleInstanceRepositoryImpl(
"DisplayContextRepo",
context.createWindowContext(
displayRepository.getDisplay(DEFAULT_DISPLAY)!!,
TYPE_APPLICATION_OVERLAY,
/* options=*/ null,
),
if (Utilities.ATLEAST_S) {
context.createWindowContext(
displayRepository.getDisplay(DEFAULT_DISPLAY)!!,
TYPE_APPLICATION_OVERLAY,
/* options=*/ null,
)
} else {
context.createDisplayContext(displayRepository.getDisplay(DEFAULT_DISPLAY)!!)
}
)
}
}
@@ -107,12 +107,14 @@ public class DepthController extends BaseDepthController implements StateHandler
mOnAttachListener = new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
try {
UI_HELPER_EXECUTOR.execute(() ->
CrossWindowBlurListeners.getInstance().addListener(
mLauncher.getMainExecutor(), mCrossWindowBlurListener));
} catch (Throwable t) {
// LC-Ignored
if (Utilities.ATLEAST_S) {
try {
UI_HELPER_EXECUTOR.execute(() ->
CrossWindowBlurListeners.getInstance().addListener(
mLauncher.getMainExecutor(), mCrossWindowBlurListener));
} catch (Throwable t) {
// LC-Ignored
}
}
mLauncher.getScrimView().addOpaquenessListener(mOpaquenessListener);
@@ -144,12 +146,14 @@ public class DepthController extends BaseDepthController implements StateHandler
}
private void removeSecondaryListeners() {
try {
UI_HELPER_EXECUTOR.execute(() ->
CrossWindowBlurListeners.getInstance()
.removeListener(mCrossWindowBlurListener));
} catch (Throwable t) {
// LC-Ignored
if (Utilities.ATLEAST_S) {
try {
UI_HELPER_EXECUTOR.execute(() ->
CrossWindowBlurListeners.getInstance()
.removeListener(mCrossWindowBlurListener));
} catch (Throwable t) {
// LC-Ignored
}
}
if (mOpaquenessListener != null) {
mLauncher.getScrimView().removeOpaquenessListener(mOpaquenessListener);
@@ -764,7 +764,8 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
}
addMultiWindowModeChangedListener(mDepthController);
initUnfoldTransitionProgressProvider();
mViewCapture = ViewCaptureFactory.getInstance(this).startCapture(getWindow());
// LC-Note: Make it NoOp for Android 8.0/8.1/9/10/11 support
mViewCapture = null;
// getWindow().addPrivateFlags(PRIVATE_FLAG_OPTIMIZE_MEASURE);
QuickstepOnboardingPrefs.setup(this);
// View.setTraceLayoutSteps(TRACE_LAYOUTS);
@@ -328,6 +328,8 @@ class StatsLogCompatManager private constructor(context: Context) : StatsLogMana
val features = mFeatures ?: getFeatures(atomInfo)
if (!Utilities.ATLEAST_R) return
SysUiStatsLog.write(
SysUiStatsLog.LAUNCHER_EVENT,
SysUiStatsLog.LAUNCHER_UICHANGED__ACTION__DEFAULT_ACTION, /* deprecated */
@@ -430,6 +432,8 @@ class StatsLogCompatManager private constructor(context: Context) : StatsLogMana
Log.d(LATENCY_TAG, "InstanceId=$mInstanceId $name=${mLatencyInMillis}ms")
}
if (!Utilities.ATLEAST_R) return
SysUiStatsLog.write(
SysUiStatsLog.LAUNCHER_LATENCY,
event.id, // event_id
@@ -492,6 +496,8 @@ class StatsLogCompatManager private constructor(context: Context) : StatsLogMana
)
}
if (!Utilities.ATLEAST_R) return
SysUiStatsLog.write(
SysUiStatsLog.LAUNCHER_IMPRESSION_EVENT_V2,
event.id, // event_id
@@ -548,6 +554,9 @@ class StatsLogCompatManager private constructor(context: Context) : StatsLogMana
if (Utilities.isRunningInTestHarness()) {
return
}
if (!Utilities.ATLEAST_R) return
SysUiStatsLog.write(
SysUiStatsLog.LAUNCHER_SNAPSHOT,
LAUNCHER_WORKSPACE_SNAPSHOT.id, /* event_id */
@@ -202,6 +202,7 @@ public class BaseDepthController {
float depth = mDepth;
IBinder windowToken = mLauncher.getRootView().getWindowToken();
if (windowToken != null) {
if (!Utilities.ATLEAST_R) return;
if (enableScalingRevealHomeAnimation()) {
mWallpaperManager.setWallpaperZoomOut(windowToken, depth);
} else {
@@ -44,6 +44,7 @@ import androidx.annotation.CallSuper;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dagger.ApplicationContext;
import com.android.launcher3.dagger.LauncherAppComponent;
import com.android.launcher3.dagger.LauncherAppSingleton;
@@ -107,7 +108,9 @@ public class ContextualSearchStateManager {
|| !context.getPackageManager().hasSystemFeature(FEATURE_CONTEXTUAL_SEARCH)) {
// If we had previously registered a SystemAction which is no longer valid, we need to
// unregister it here.
unregisterSearchScreenSystemAction();
if (Utilities.ATLEAST_R) {
unregisterSearchScreenSystemAction();
}
// Don't listen for stuff we aren't gonna use.
return;
}
@@ -19,6 +19,7 @@ package com.android.quickstep.util
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.Typeface
import android.os.Build
import com.android.wm.shell.shared.TypefaceUtils
object FontUtils {
@@ -31,7 +32,12 @@ object FontUtils {
Typeface.create(baseTypeface, getFontWeight(resources), /* italic= */ false)
fun getFontWeight(resources: Resources): Int {
val fontWeightAdjustment: Int = resources.configuration.fontWeightAdjustment
val fontWeightAdjustment: Int = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
resources.configuration.fontWeightAdjustment
} else {
// LC-Note: Android 11 don't have font weight adjustment, assume 400 Normal
400
}
return if (fontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED) {
Typeface.Builder.NORMAL_WEIGHT + fontWeightAdjustment
} else {
@@ -23,6 +23,7 @@ import androidx.annotation.NonNull;
import com.android.internal.protolog.ProtoLog;
import com.android.internal.protolog.common.IProtoLogGroup;
import com.android.launcher3.Utilities;
import java.util.UUID;
/** Enums used to interface with the ProtoLog API. */
@@ -40,6 +41,7 @@ public enum QuickstepProtoLogGroup implements IProtoLogGroup {
private final @NonNull String mTag;
public static boolean isProtoLogInitialized() {
if (!Utilities.ATLEAST_R) return false;
if (!Variables.sIsInitialized) {
Log.w(Constants.TAG,
"Attempting to log to ProtoLog before initializing it.",
+6 -4
View File
@@ -1474,10 +1474,12 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
// Detect if user tries to swipe to -1 page but gets disallowed by checking if there was
// left-over values in mEdgeGlowLeft (or mEdgeGlowRight in RLT).
final int layoutDir = getLayoutDirection();
if ((mEdgeGlowLeft.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_LTR)
|| (mEdgeGlowRight.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_RTL)) {
onDisallowSwipeToMinusOnePage();
if (Utilities.ATLEAST_S) {
final int layoutDir = getLayoutDirection();
if ((mEdgeGlowLeft.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_LTR)
|| (mEdgeGlowRight.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_RTL)) {
onDisallowSwipeToMinusOnePage();
}
}
mEdgeGlowLeft.onRelease(ev);
+5 -1
View File
@@ -776,7 +776,11 @@ public final class Utilities {
if (activityInfo == null) {
return null;
}
mainIcon = appState.getIconCache().getFullResIcon(activityInfo.getActivityInfo());
if (Utilities.ATLEAST_S) {
mainIcon = appState.getIconCache().getFullResIcon(activityInfo.getActivityInfo());
} else {
mainIcon = appState.getIconCache().getFullResIcon(activityInfo.getComponentName().getPackageName());
}
} else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
List<ShortcutInfo> siList = ShortcutKey.fromItemInfo(info)
.buildRequest(context)
@@ -234,7 +234,7 @@ public class LauncherAppWidgetInfo extends ItemInfo {
if (providerInfo.isConfigurationOptional()) {
widgetFeatures |= FEATURE_OPTIONAL_CONFIGURATION;
}
if (providerInfo.previewLayout != Resources.ID_NULL) {
if (ATLEAST_S && (providerInfo.previewLayout != Resources.ID_NULL)) {
widgetFeatures |= FEATURE_PREVIEW_LAYOUT;
}
if (ATLEAST_S && (providerInfo.targetCellWidth > 0 || providerInfo.targetCellHeight > 0)) {
@@ -40,6 +40,7 @@ import androidx.annotation.Nullable;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.icons.cache.BaseIconCache;
import com.android.launcher3.icons.cache.CachedObject;
import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -149,7 +150,11 @@ public abstract class ShortcutConfigActivityInfo implements CachedObject {
@Override
public Drawable getFullResIcon(BaseIconCache cache) {
return cache.getFullResIcon(mInfo.getActivityInfo());
if (Utilities.ATLEAST_S) {
return cache.getFullResIcon(mInfo.getActivityInfo());
} else {
return cache.getFullResIcon(mInfo.getComponentName().getPackageName());
}
}
@Override
@@ -16,6 +16,8 @@
package com.android.launcher3.util;
import static android.content.pm.PackageManager.FEATURE_SENSOR_HINGE_ANGLE;
import static android.content.res.Configuration.UI_MODE_NIGHT_MASK;
import static android.content.res.Configuration.UI_MODE_NIGHT_YES;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
@@ -577,8 +579,12 @@ public class DisplayController implements DesktopVisibilityListener {
mStableDensityScaleFactor = (float) defaultDensityDpi / DisplayMetrics.DENSITY_DEFAULT;
mScreenSizeDp = new PortraitSize(config.screenHeightDp, config.screenWidthDp);
navigationMode = wmProxy.getNavigationMode(displayInfoContext);
mIsNightModeActive = config.isNightModeActive();
if (Utilities.ATLEAST_R) {
mIsNightModeActive = config.isNightModeActive();
} else {
mIsNightModeActive = (config.uiMode & UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES;
}
// LC: Hacky stuff but it work!
mIsFoldable = Utilities.ATLEAST_R && displayInfoContext.getPackageManager()
.hasSystemFeature(FEATURE_SENSOR_HINGE_ANGLE);
@@ -45,6 +45,7 @@ import androidx.annotation.Nullable;
import com.android.launcher3.PendingAddItemInfo;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dagger.ApplicationContext;
import com.android.launcher3.dagger.LauncherAppSingleton;
import com.android.launcher3.dagger.LauncherBaseAppComponent;
@@ -221,7 +222,11 @@ public class PackageManagerHelper {
/** Returns the incremental download progress for the given shortcut's app. */
public static int getLoadingProgress(LauncherActivityInfo info) {
return (int) (100 * info.getLoadingProgress());
if (Utilities.ATLEAST_S) {
return (int) (100 * info.getLoadingProgress());
} else {
return 100;
}
}
/**
@@ -31,6 +31,7 @@ import static com.android.launcher3.util.RotationUtils.deltaRotation;
import static com.android.launcher3.util.RotationUtils.rotateRect;
import static com.android.launcher3.util.RotationUtils.rotateSize;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -38,6 +39,7 @@ import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.util.ArrayMap;
import android.util.Log;
import android.view.Display;
@@ -431,9 +433,16 @@ public class WindowManagerProxy {
*/
public CachedDisplayInfo getDisplayInfo(Context displayInfoContext) {
int rotation = getRotation(displayInfoContext);
WindowMetrics windowMetrics = displayInfoContext.getSystemService(WindowManager.class)
.getMaximumWindowMetrics();
return getDisplayInfo(windowMetrics, rotation);
if (Utilities.ATLEAST_S) {
WindowMetrics windowMetrics = displayInfoContext.getSystemService(WindowManager.class)
.getMaximumWindowMetrics();
return getDisplayInfo(windowMetrics, rotation);
} else {
Point size = new Point();
Display display = getDisplay(displayInfoContext);
display.getRealSize(size);
return new CachedDisplayInfo(size, rotation);
}
}
/**
@@ -24,6 +24,7 @@ import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.EdgeEffectFactory;
import com.android.launcher3.Utilities;
/**
* View group to allow rendering overscroll effect in a child at the parent level
@@ -44,8 +45,13 @@ public class SpringRelativeLayout extends RelativeLayout {
public SpringRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mEdgeGlowTop = new EdgeEffect(context, attrs);
mEdgeGlowBottom = new EdgeEffect(context, attrs);
if (Utilities.ATLEAST_S) {
mEdgeGlowTop = new EdgeEffect(context, attrs);
mEdgeGlowBottom = new EdgeEffect(context, attrs);
} else {
mEdgeGlowTop = new EdgeEffect(context);
mEdgeGlowBottom = new EdgeEffect(context);
}
setWillNotDraw(false);
}
@@ -162,4 +168,4 @@ public class SpringRelativeLayout extends RelativeLayout {
return mParent.isFinished();
}
}
}
}
@@ -130,13 +130,15 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo impleme
getSpanY(widgetPadding, minResizeHeight, dp.cellLayoutBorderSpacePx.y,
cellSize.y));
if (maxResizeWidth > 0) {
maxSpanX = Math.min(maxSpanX, getSpanX(widgetPadding, maxResizeWidth,
if (Utilities.ATLEAST_S) {
if (maxResizeWidth > 0) {
maxSpanX = Math.min(maxSpanX, getSpanX(widgetPadding, maxResizeWidth,
dp.cellLayoutBorderSpacePx.x, cellSize.x));
}
if (maxResizeHeight > 0) {
maxSpanY = Math.min(maxSpanY, getSpanY(widgetPadding, maxResizeHeight,
}
if (maxResizeHeight > 0) {
maxSpanY = Math.min(maxSpanY, getSpanY(widgetPadding, maxResizeHeight,
dp.cellLayoutBorderSpacePx.y, cellSize.y));
}
}
spanX = Math.max(spanX,
@@ -147,16 +149,18 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo impleme
cellSize.y));
}
// Ensures maxSpan >= minSpan
maxSpanX = Math.max(maxSpanX, minSpanX);
maxSpanY = Math.max(maxSpanY, minSpanY);
if (Utilities.ATLEAST_S) {
// Ensures maxSpan >= minSpan
maxSpanX = Math.max(maxSpanX, minSpanX);
maxSpanY = Math.max(maxSpanY, minSpanY);
// Use targetCellWidth/Height if it is within the min/max ranges.
// Otherwise, use the span of minWidth/Height.
if (targetCellWidth >= minSpanX && targetCellWidth <= maxSpanX
&& targetCellHeight >= minSpanY && targetCellHeight <= maxSpanY) {
spanX = targetCellWidth;
spanY = targetCellHeight;
// Use targetCellWidth/Height if it is within the min/max ranges.
// Otherwise, use the span of minWidth/Height.
if (targetCellWidth >= minSpanX && targetCellWidth <= maxSpanX
&& targetCellHeight >= minSpanY && targetCellHeight <= maxSpanY) {
spanX = targetCellWidth;
spanY = targetCellHeight;
}
}
// If minSpanX/Y > spanX/Y, ignore the minSpanX/Y to match the behavior described in
@@ -221,11 +225,11 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo impleme
}
public boolean isReconfigurable() {
return configure != null && (getWidgetFeatures() & WIDGET_FEATURE_RECONFIGURABLE) != 0;
return Utilities.ATLEAST_P && configure != null && (getWidgetFeatures() & WIDGET_FEATURE_RECONFIGURABLE) != 0;
}
public boolean isConfigurationOptional() {
return isReconfigurable()
return Utilities.ATLEAST_S && isReconfigurable()
&& (getWidgetFeatures() & WIDGET_FEATURE_CONFIGURATION_OPTIONAL) != 0;
}
@@ -241,12 +245,23 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo impleme
@Override
public Drawable getFullResIcon(BaseIconCache cache) {
return cache.getFullResIcon(getActivityInfo());
if (Utilities.ATLEAST_S) {
return cache.getFullResIcon(getActivityInfo());
} else {
return cache.getFullResIcon(provider.getPackageName());
}
}
@Nullable
@Override
public ApplicationInfo getApplicationInfo() {
return getActivityInfo().applicationInfo;
if (Utilities.ATLEAST_S) {
return getActivityInfo().applicationInfo;
}
try {
return mPM.getApplicationInfo(provider.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
return null;
}
}
}
@@ -44,6 +44,7 @@ import android.util.Log;
import android.view.Display;
import android.window.TaskSnapshot;
import app.lawnchair.compat.LawnchairQuickstepCompat;
import com.android.internal.app.IVoiceInteractionManagerService;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -63,7 +64,8 @@ public class ActivityManagerWrapper {
// Should match the value in AssistManager
private static final String INVOCATION_TIME_MS_KEY = "invocation_time_ms";
private final ActivityTaskManager mAtm = ActivityTaskManager.getInstance();
// pE-TODO(CompatTier2): Try not to do this? Just use ActivityTaskManager.getInstance()
private final ActivityTaskManager mAtm = LawnchairQuickstepCompat.ATLEAST_S ? ActivityTaskManager.getInstance() : null;
private ActivityManagerWrapper() { }
public static ActivityManagerWrapper getInstance() {
@@ -20,6 +20,7 @@ import static android.view.CrossWindowBlurListeners.CROSS_WINDOW_BLUR_SUPPORTED;
import android.app.ActivityManager;
import android.os.SystemProperties;
import app.lawnchair.compat.LawnchairQuickstepCompat;
public abstract class BlurUtils {
@@ -29,7 +30,7 @@ public abstract class BlurUtils {
* @return {@code true} when supported.
*/
public static boolean supportsBlursOnWindows() {
return CROSS_WINDOW_BLUR_SUPPORTED && ActivityManager.isHighEndGfx()
return LawnchairQuickstepCompat.ATLEAST_S && CROSS_WINDOW_BLUR_SUPPORTED && ActivityManager.isHighEndGfx()
&& !SystemProperties.getBoolean("persist.sysui.disableBlur", false);
}
}