Android 8.1 Support: One Yellow Warning and Two Silent Bugs
Title: Android 8.1 can also be installed: the price is a yellow line and two silent bugs
Author: booboosui
Tags: Android
Conclusion first: lowering the minimum system version from 30 to 27 moves more than a number. You need to supplement a method for old systems to get screen size, add a yellow line at the top of self-check explaining what's missing, and accept the half-finished state of "can talk but can't see the screen". Two errors surfaced during the downgrade, both only valid on old systems, and neither will crash.
Andee is an agent living in an Android phone: uses accessibility service to read the screen, taps by itself, doesn't need any app to open an interface, only a ball on the side of the screen.
On old systems, this leg is simply missing
Screenshot uses takeScreenshot, only available since Android 11. After downgrade to 8.1, there's no branch to write; the first check returns null.
private fun <T> captureFrame(transform: (Bitmap) -> T): T? {
// AccessibilityService.takeScreenshot is API 30. Below that the screen
// tools have no pixels to aim with; returning null is the same answer
// a refused capture gives, and the checklist explains why.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) return null
"Returning null" and "screenshot refused" share one return value, intentionally. The upper layer only faces one failure, no need to write an extra path for old systems. The cost is that the model side only sees one reason: can't capture. It can't tell whether the system is too old or permission was revoked.
Yellow line placed first, and no fix button
SelfCheck.platformVersion() returns null on API 30+, below gives a WARN. The code comment explains three things:
First, because it explains every other degraded screen tool on an old device. Amber, not red: the assistant still installs and talks.
The reason for placing it first is explanation order. On an old phone, if you don't first say the system is too old, the user will go to accessibility, floating window, and after tweaking those still fail. The handling is Fix.Nothing, comment says "no Settings screen can grant an OS upgrade".
The Chinese text the user sees splits in two: the first half lists "screen capture, view image tap, window frosted glass" as features unavailable due to new system APIs, the second half says "chat, voice, notes, and settings still work", and at the end tells them to upgrade to Android 11 to restore.
The rest of the landmines are cleared one by one according to the checklist
Screenshot is the most conspicuous one. After the downgrade, the truly time-consuming parts are scattered old API calls, all fixed by adding checks according to the positions reported by the pre-package check: input method enter key, gesture exclusion area, notch, background blur, the three-parameter overload of startForeground, ACTIVITY_RECOGNITION, ImageDecoder falls back to BitmapFactory on 8.1. Some require just adding a version check, others make the entire feature unavailable on old systems.
In that check, the error "this API doesn't exist on old system" dropped from 37 to 0. There are still 10 similar errors unrelated to this change that have never been handled.
Geometry: one object, twelve call sites
currentWindowMetrics, maximumWindowMetrics, WindowInsets.Type are all API 30. The equivalent on old systems is getRealMetrics plus the resource height of system bars. These queries scattered in UI code would drift independently, so they are collected into a WindowMetricsCompat, and 12 UI files are changed to ask it.
During the collection, an error slipped in, and in the simplest line:
val bottom = (real.heightPixels - app.heightPixels - top).coerceAtLeast(0)
getMetrics() gives the area the app window receives, which already excludes the status bar; getRealMetrics() is the whole screen. So the height difference already includes the status bar, subtracting status_bar_height again describes a phone with only two system bars as having three. The consequences land in two places: bottomEdge() is one status bar lower, so the folded ball stops above the navigation bar, not touching the ground; usableSize() is shorter by the same amount, making every centered card shorter than the screen.
This code only runs on devices below API 30. Nothing throws when written, only geometry numbers are wrong.
There is also a stated assumption: the width difference is treated as the right navigation bar. On landscape devices where the navigation bar is at the bottom, the width difference is 0 and the height difference carries it, so "whichever axis has nonzero difference, the bar is on that axis" holds; as for whether the horizontal difference is specifically on the left or right, it's based on the behavior of a few measured ROMs, and the comment marks it as an assumption, not a conclusion.
A default answer makes Android 11 reminders all inaccurate
Before the change, the code for deciding whether exact alarms can be scheduled was: call canScheduleExactAlarms(), wrapped in runCatching, return false if not obtainable.
The problem is that this method is added in API 31. On Android 11, calling it directly throws an exception; runCatching swallows it, and getOrDefault(false) gives a very confident wrong answer: not allowed. armTodo() gets false and goes with setAndAllowWhileIdle, so all Android 11 reminders are allowed to be late.
The current writing restores the semantics:
fun exactAllowed(context: Context): Boolean =
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) true
else runCatching { am(context).canScheduleExactAlarms() }.getOrDefault(false)
SDK_INT < S returns true not as a relaxation, but because those two versions never had this switch; the permission model doesn't include this item. The real lesson is on the default value side: a fallback of "if not obtainable, treat as not allowed", facing an API that is guaranteed to fail on old systems, makes a feature silently break, and it produces no logs.
Cost
Installable does not mean usable. It can chat, voice, take notes, and keep reminders on time; it cannot see the screen, cannot tap buttons, cannot do things in specified apps. Because without a picture there is no aim.
This yellow line will never provide a pressable fix button. System version is not in settings; you can only change the device, or keep looking at this yellow line.
Both errors don't crash, so they don't appear in crash statistics, only in UI position deviations and reminder time deviations. The only environment to reproduce them is API 27–29 real devices, and these devices are exactly the fewest.
My current judgment is: this downgrade line is worth it. A person's 2018 phone that can speak and take notes is better than a blank screen that cannot even install.