Skip to content

Android 17 Fixes - App List and Privacy Settings Crash - #3

Open
Saloframes wants to merge 4 commits into
SysAdminDoc:mainfrom
Saloframes:cursor/fix-privacy-settings-crash-0ec4
Open

Android 17 Fixes - App List and Privacy Settings Crash#3
Saloframes wants to merge 4 commits into
SysAdminDoc:mainfrom
Saloframes:cursor/fix-privacy-settings-crash-0ec4

Conversation

@Saloframes

Copy link
Copy Markdown
Contributor

Worked on some solutions to problems created by Android 17. Should fix the App List issue (same solution works on upstream AM too, tested to verify) and the app should no longer crash after trying to open Privacy options. Generated summary below:

This pull request addresses two major issues: fixing crashes in the Settings > Privacy screen due to preference key mismatches, and restoring compatibility with Android 17 (API 37) for loading the installed applications list. It also adds comprehensive tests to prevent regressions and ensure forward compatibility as Android evolves.

Settings stability and key registration fixes:

  • Updated all SwitchPreferenceCompat keys in preferences_privacy.xml and corresponding usages in PrivacyPreferences.java to use the registered enable_* names, preventing IllegalArgumentException crashes when opening Settings > Privacy. [1] [2] [3] [4] [5]
  • Added PrivacyPreferencesKeyParityTest to verify that all persistent privacy preference keys are registered in AppPref, ensuring future changes do not break the settings screen.

Android 17 (API 37) compatibility for installed app list:

  • Refactored PackageManagerCompat to tolerate Android 17’s hidden return type change for getInstalledPackages and getInstalledApplications by catching linkage errors, retrying reflectively, and normalizing results via a new extractList method. This prevents crashes and ensures the installed app list and About device screen work on new Android versions. [1] [2]
  • Added PackageManagerCompatListExtractionTest to verify that extractList correctly handles all possible return types (ParceledListSlice, List, null, or unknown wrappers), ensuring forward compatibility.
  • Added a contract test in Android17BehaviorContractTest to assert that the installed list accessor methods continue to guard against return type changes and use the normalization shim.

Documentation:

  • Updated CHANGELOG.md to reflect the fixes for Settings > Privacy crashes and Android 17 compatibility.

cursoragent and others added 4 commits June 27, 2026 08:34
On Android 17 (API 37) the hidden IPackageManager.getInstalledPackages/
getInstalledApplications return type changes, so the ParceledListSlice
descriptor compiled into our bytecode no longer resolves and the direct
call fails with a NoSuchMethodError. This left the installed-app list empty
and crashed Settings > About device (DeviceInfo2#getPackageStats catches
Exception, not Error).

The accessors now catch the linkage error, re-dispatch the call reflectively
(method resolution ignores the return type), and normalize the result via a
new extractList() helper that handles ParceledListSlice, a plain List, an
unknown getList()-exposing wrapper, and null. Current Android versions keep
using the fast direct path.

Co-authored-by: Saloframes <Saloframes@users.noreply.github.com>
…ckageManagerCompat.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…apps-0ec4

fix: tolerate Android 17 getInstalled* return-type change
Opening Settings > Privacy crashed because three SwitchPreferenceCompat rows
used app:key values that SettingsDataStore cannot resolve in AppPref:
  permission_change_monitor
  signing_cert_change_monitor
  app_change_auditor

Inflating the screen calls SettingsDataStore.getBoolean() for each persistent
switch, which throws IllegalArgumentException for unknown keys.

Rename the keys to the registered enable_* names and add a parity unit test
so future privacy toggles cannot regress.

Co-authored-by: Saloframes <Saloframes@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 27, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

SysAdminDoc pushed a commit that referenced this pull request Aug 25, 2026
On Android 17 (API 37) the hidden IPackageManager.getInstalledPackages/
getInstalledApplications return type changes, so the ParceledListSlice
descriptor compiled into our bytecode no longer resolves and the direct
call fails with a NoSuchMethodError. This left the installed-app list
empty and crashed Settings > About device (DeviceInfo2#getPackageStats
catches Exception, not Error).

The accessors now catch the linkage error, re-dispatch the call
reflectively (method resolution ignores the return type), and normalize
the result via a new extractList() helper that handles ParceledListSlice,
a plain List, an unknown getList()-exposing wrapper, and null. Current
Android versions keep using the fast direct path, including the existing
IPackageManagerV37 PackageInfoList route for getInstalledPackages, which
now also falls back reflectively instead of throwing if a build's
descriptor differs.

Ported from the fix Saloframes carried in their fork (PR #3), rebased
onto the current enumeration layer.

Fixes #6
SysAdminDoc added a commit that referenced this pull request Aug 25, 2026
Settings > Privacy crashed in v0.6.12 with IllegalArgumentException
"Invalid key: permission_change_monitor": three SwitchPreferenceCompat
rows used app:key values that SettingsDataStore cannot resolve in
AppPref, and every persistent switch reads its value through that store
while the screen inflates. The key rename that fixes the crash
(enable_* names) already landed in 95731f5; Saloframes independently
diagnosed and fixed the same mismatch in their fork (PR #3). The
follow-up SecurityException from reading device_idle_constants on
Android 12+ (reported by kreza6173-pixel on the same issue) was guarded
in the same commit.

What was still missing is a net over the pattern itself: any settings
screen can reintroduce the crash by adding one persistent preference
with an unregistered key. SettingsPreferenceKeyParityTest now walks
every preferences_*.xml and asserts each persistent value-backed
preference key resolves in AppPref. The profile configuration screen is
excluded because it persists through its own profile-scoped
ConfDataStore, and a companion assertion pins that exclusion to the
actual ConfPreferences wiring. The sweep found no other live offenders.

Fixes #8
@SysAdminDoc

Copy link
Copy Markdown
Owner

Landed with your authorship kept. The privacy key half had already gone into main during the v0.6.17 work (95731f5), and the getInstalled* compat piece is now in 74fc7ae under your name, rebased onto the newer enumeration layer. Main grew a direct IPackageManagerV37 path for getInstalledPackages since June, so your reflective fallback now backs that up and covers getInstalledApplications, which had no API 37 handling at all. Your extraction tests came along too. Thanks for carrying this in your fork, the test coverage especially. Leaving the PR itself to you since it will show conflicts against main now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants