Privileged app: does a /system/priv-app app get Android 6's privileged permissions, and keep them after it updates?
On this page
Status (2026-11-16): verified on the unit. AOSP 6.0.1's package manager grants
signature|privileged permissions to any app scanned from /system/priv-app, whatever its signing
key, and an update of that app keeps them while it is signed with the same key. The probe app
(tools/mirror/probe-app) showed it on the Mirror on
2026-11-16 (the root's run, on #395): privileged, INSTALL_PACKAGES, REBOOT and
WRITE_SECURE_SETTINGS granted, a silent update with all three kept, a secure setting written, and a
reboot back into the app. Such an app can approve the computer that is asking, for that one
connection: below (verified on the unit 2026-11-16).
Device: lululemon Mirror (MSM8916), community image Glass Panes mirror-android-1 (Android 6.0.1,
MMB29M, userdebug, test-keys). Source: AOSP tag android-6.0.1_r81
(platform/frameworks/base and platform/external/sepolicy on android.googlesource.com, read
2026-11-15). The image is built from CAF's tree for the DragonBoard; that its package manager matches
AOSP here is an assumption the probe tests.
Question
Kiln's Mirror image put S1 Kiosk in /system/priv-app/S1Kiosk (image-patch.md). Since
2026-11-16 it puts the legacy build of Glassworks in /system/priv-app/Glassworks, and the probe still
goes to S1Kiosk (the harness's --probe).
If that makes it privileged, Glassworks gets three things on the Mirror without root:
INSTALL_PACKAGES: its own updates install with no confirmation;REBOOT: it can restart the Mirror;WRITE_SECURE_SETTINGS: it can change secure and global settings itself.
Does it, and do the permissions survive an update, which installs to /data/app?
What we read
All read from source (2026-11-15). Line numbers are in the files at android-6.0.1_r81.
-
The three permissions' protection levels (
core/res/AndroidManifest.xml):Permission Lines protectionLevelWRITE_SECURE_SETTINGS1762–1763 signature|privileged|developmentINSTALL_PACKAGES2098–2099 signature|privilegedREBOOT2236–2237 signature|privileged -
/system/priv-appmakes an app privileged (services/core/java/com/android/server/pm/PackageManagerService.java). At boot it scans the folder with the privileged flag, lines 2077–2081:// Collected privileged system packages. final File privilegedAppDir = new File(Environment.getRootDirectory(), "priv-app"); scanDirLI(privilegedAppDir, PackageParser.PARSE_IS_SYSTEM | PackageParser.PARSE_IS_SYSTEM_DIR | PackageParser.PARSE_IS_PRIVILEGED, scanFlags, 0);and
scanPackageDirtyLIturns that into the app's flag, lines 6499–6501:if ((parseFlags&PackageParser.PARSE_IS_PRIVILEGED) != 0) { pkg.applicationInfo.privateFlags |= ApplicationInfo.PRIVATE_FLAG_PRIVILEGED; }No signature check is involved. There is no privileged-permission whitelist on Android 6 (that came with Android 8's
privapp-permissions). -
Signature permissions go through
grantSignaturePermission.grantPermissionsLPw(line 8339) sends everysignaturepermission there, lines 8446–8452 ("For all apps signature permissions are install time ones").grantSignaturePermission, lines 8623–8668:allowed = (compareSignatures( bp.packageSetting.signatures.mSignatures, pkg.mSignatures) == PackageManager.SIGNATURE_MATCH) || (compareSignatures(mPlatformPackage.mSignatures, pkg.mSignatures) == PackageManager.SIGNATURE_MATCH); if (!allowed && (bp.protectionLevel & PermissionInfo.PROTECTION_FLAG_PRIVILEGED) != 0) { if (isSystemApp(pkg)) { // For updated system applications, a system permission // is granted only if it had been defined by the original application. if (pkg.isUpdatedSystemApp()) { final PackageSetting sysPs = mSettings .getDisabledSystemPkgLPr(pkg.packageName); if (sysPs.getPermissionsState().hasInstallPermission(perm)) { … if (sysPs.isPrivileged()) { allowed = true; } } else { … if (sysPs.pkg != null && sysPs.isPrivileged()) { for (int j=0; j<sysPs.pkg.requestedPermissions.size(); j++) { if (perm.equals( sysPs.pkg.requestedPermissions.get(j))) { allowed = true; … } else { allowed = isPrivilegedApp(pkg); }with
isPrivilegedApp, lines 12878–12880:private static boolean isPrivilegedApp(PackageParser.Package pkg) { return (pkg.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0; }So a system app from
/system/priv-app, signed with any key, getsINSTALL_PACKAGES,REBOOTandWRITE_SECURE_SETTINGS. The first branch (platform key) is the other way in: the image istest-keys, so an app signed with AOSP's public platform test key gets them too, as uidsystemor not (mirror-root.md). -
An update keeps the app a privileged system app. An update installs over a system app through
replacePackageLI, which first needs the same signature, lines 12103–12108 ("New package has a different signature",INSTALL_FAILED_UPDATE_INCOMPATIBLE), then sends a system app down the system path, lines 12119–12121:boolean sysPkg = (isSystemApp(oldPackage)); if (sysPkg) { replaceSystemPackageLI(oldPackage, pkg, parseFlags, scanFlags,replaceSystemPackageLIscans the new APK as system, and as privileged if the old one was, lines 12230–12234:parseFlags |= PackageParser.PARSE_IS_SYSTEM; if ((deletedPackage.applicationInfo.privateFlags&ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) { parseFlags |= PackageParser.PARSE_IS_PRIVILEGED; }and keeps the
/systemcopy as the disabled system package, line 12263 (mSettings.disableSystemPackageLPw(packageName)). That copy is thesysPsthatgrantSignaturePermissionchecks for an updated system app (read 3). ItsisPrivileged()is the same flag (PackageSetting.java, lines 66–68). -
After a reboot the update stays privileged. The boot scan finds the disabled
/systemcopy and sets its flag from where it lies, lines 5779–5786 ("If new package is not located in "/system/priv-app" (e.g. due to an OTA), it needs to drop FLAG_PRIVILEGED"). Then the/data/appcopy is scanned with the privileged flag again, lines 5849–5853:// An updated privileged app will not have the PARSE_IS_PRIVILEGED // flag set initially if ((updatedPkg.pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) { parseFlags |= PackageParser.PARSE_IS_PRIVILEGED; }If the
/systemcopy'sversionCodeis higher than the update's (a re-flashed image with a newer app), the system copy wins and the update is dropped (around line 5793). -
Without
INSTALL_PACKAGES, a commit waits for a tap (services/core/java/com/android/server/pm/PackageInstallerSession.java). Any app may open a session (PackageInstallerService.createSessionInternal, line 573, checks only that the caller owns its installer package name). The session decides at creation, lines 226–233:if ((mPm.checkUidPermission(android.Manifest.permission.INSTALL_PACKAGES, installerUid) == PackageManager.PERMISSION_GRANTED) || (installerUid == Process.ROOT_UID) || mIsInstallerDeviceOwner) { mPermissionsAccepted = true;and at commit, lines 488–495, a session without it sends
ACTION_CONFIRM_PERMISSIONSback throughonUserActionRequired, which the app sees asSTATUS_PENDING_USER_ACTION(-1,PackageInstaller.javaline 177). With it, the commit goes straight to the install. -
The probe can read the update APK from
/data/local/tmp. A priv-app not signed with the platform key runs asuntrusted_app(seapp_contextslines 49–50;mac_permissions.xmlgivesplatformonly to@PLATFORM), anduntrusted_app.telines 47–48 allowshell_data_filereads ("Used by Finsky / Android "Verify Apps" functionality"). A vendor policy could differ; the probe's README gives/sdcard/Android/data/<package>/filesas the fallback. -
An
activity-aliasdoesn't take its target's permission (core/java/android/content/pm/PackageParser.java,parseActivityAlias, lines 3357–3398): it copies the target's flags, theme and launch mode, butpermissiononly from its ownandroid:permission. So the generic app's pattern (#364), a permission-guardedMainActivityand an unguarded HOME alias, works on Android 6 as intended. The probe uses two plain activities instead:MainActivityfor HOME,ProbeActionfor adb.
Result
| Claim | Evidence | How sure |
|---|---|---|
An app in /system/priv-app gets INSTALL_PACKAGES, REBOOT, WRITE_SECURE_SETTINGS, whatever its key |
Reads 1–3; the probe on the unit (2026-11-16): privileged yes, INSTALL_PACKAGES and REBOOT granted from /system/priv-app |
Verified (2026-11-16) |
| An update signed with the same key keeps them, and stays privileged across reboots | Reads 4–5; the probe on the unit (2026-11-16): after the silent update, an updated system app in /data/app, still PRIVILEGED, all three kept, and again after a reboot |
Verified (2026-11-16) |
An update gets a privileged permission only if the /system copy asked for it, unless the update is signed with the platform key (or the permission's own key) |
Read 3: the signature check comes first, then the updated-system-app branch | Read |
With INSTALL_PACKAGES, a PackageInstaller commit needs no tap; without it, STATUS_PENDING_USER_ACTION |
Read 6; the probe on the unit (2026-11-16): v1 to v2 through PackageInstaller with no prompt |
Verified (2026-11-16) for the case with INSTALL_PACKAGES; the case without it is read |
WRITE_SECURE_SETTINGS granted on the unit proves little by itself |
Kiln's first boot runs pm grant … WRITE_SECURE_SETTINGS (grantPermissions in @glassworks/app-adb), which a development permission allows |
Read |
What it means for Glassworks, now that the probe confirmed it: Glassworks updates itself on the Mirror from
Home Assistant with no tap and no root, can restart the Mirror, and writes its own settings. The APK
Kiln flashes into system must already ask for every privileged permission a later version will
need, because an update signed with our key can't add one (row 3). Kiln refuses an APK that doesn't
ask for all three.
Can a privileged app approve an adb key?
Status (2026-11-16): verified on the unit. The approval works for the computer that is asking, and doesn't last on this image (the run). The Mirror has no touchscreen, so its "Allow USB debugging?" dialog can't be answered on the glass. If Glassworks could answer it, a Manage page "Allow a new computer over USB" would be possible.
Read at android-6.0.1_r81 (platform/frameworks/base):
| # | File and line | What it says |
|---|---|---|
| 1 | core/res/AndroidManifest.xml:1164 |
MANAGE_USB is signature|privileged: a privileged system app gets it, as with INSTALL_PACKAGES above |
| 2 | core/java/android/hardware/usb/IUsbManager.aidl:103 |
void allowUsbDebugging(boolean alwaysAllow, String publicKey). Hidden; the app reaches it through ServiceManager.getService("usb") and IUsbManager.Stub.asInterface, by reflection |
| 3 | services/usb/java/com/android/server/usb/UsbService.java:329–330 |
enforceCallingOrSelfPermission(MANAGE_USB) (line 330), then UsbDeviceManager.allowUsbDebugging (UsbDeviceManager.java:940), which posts MESSAGE_ADB_ALLOW to UsbDebuggingManager |
| 4 | UsbDebuggingManager.java:236–248 |
On MESSAGE_ADB_ALLOW, the key's fingerprint (MD5 of the decoded key) must equal mFingerprints, else it logs "Fingerprints do not match" and does nothing. On a match with alwaysAllow, writeKey appends the key to /data/misc/adb/adb_keys (line 403). Any match, with or without alwaysAllow, also sends "OK" to the computer connected at that moment (line 251, only if one is) |
| 5 | UsbDebuggingManager.java:271–281 |
mFingerprints is set only on MESSAGE_ADB_CONFIRM: adbd asking about a computer that just connected with an unknown key. It keeps that value until the next computer asks: a deny, an unplug or the dialog going away doesn't clear it, so a later call with that same key still writes it |
| 6 | IUsbManager.aidl:109, UsbDebuggingManager.java MESSAGE_ADB_CLEAR |
clearUsbDebuggingKeys deletes the whole adb_keys file. The probe never calls it: it would remove every key, the root's included, with no touchscreen to allow one again |
On the unit (2026-11-16, verified, read-only: the root, over adb's shell on the Mirror):
| Command | What came back | What it settles |
|---|---|---|
dumpsys package android |
Permission [android.permission.MANAGE_USB] … prot=signature|privileged |
Read 1 holds on this image: the probe's /system copy can hold MANAGE_USB |
service list |
usb: [android.hardware.usb.IUsbManager] |
The usb service the probe reaches through ServiceManager.getService("usb") exists, with that interface |
(MANAGE_DEBUGGING) |
Not on this image | Later Android added MANAGE_DEBUGGING for this; on Android 6, MANAGE_USB is the permission allowUsbDebugging checks (read 3) |
What we expect. allowUsbDebugging is not a way to add any key. It answers the last computer the
Mirror asked about.
- A key no computer asked for is ignored.
- A key that matches the last computer asked about is written, even after a deny or an unplug, and that computer connects when it next tries.
The call is asynchronous and returns nothing, so the app can't tell which happened: adb_keys and
logcat do.
For Glassworks. A Manage page could approve "the computer that last asked", if it has that computer's full public key. A fingerprint can only confirm a key, not supply it. Kiln can send the key, since it holds the browser's key, and the page can show its fingerprint to confirm. It can't pre-approve keys. The probe's step 6 tests both cases: no computer asking, and with a second computer asking.
The run on the unit (2026-11-16)
The root ran the probe's step 6 on the Mirror (Glass Panes image 2, the probe in /system/priv-app), with
the method now in the probe's README: a throwaway key pair, the approval queued on the Mirror with
nohup sh -c "sleep 20; am start … allow-adb-key …", then adb's server restarted with only the test
key (HOME=<dir> adb start-server --one-device <serial>), then the normal server again. In that
order adb ignores --one-device (it parses global options only before the command), and the server
did see the S1 too. The right form is HOME=<dir> adb --one-device <serial> start-server.
| What | Result |
|---|---|
| The approval while the test key's computer was asking | unauthorized to device within about 1 s of the queued call. One-time approval works |
| The key afterwards | Written to /data/misc/adb/adb_keys (dumpsys usb lists it) |
| The next connection with the same key | unauthorized again: it doesn't last. This image's adbd ignores adb_keys (image-patch.md) |
| Reconnecting the root's own computer between queueing and switching | Resets "the last computer asked about" to that computer: every connection sets mFingerprints (the image's MESSAGE_ADB_CONFIRM, case 5), its own included. Hence the queued call |
adb shell cat /data/misc/adb/adb_keys |
Not readable by the shell here. dumpsys usb lists the keys instead |
What it means for Glassworks: an "Allow a new computer" page could let a computer in for one
connection. A lasting one needs the key where this image looks, which is services.jar's constant
(what Kiln's flash now writes), or a fix in adbd.
How to reproduce
Off-device: fetch the files above at android-6.0.1_r81 from android.googlesource.com
(…/+/refs/tags/android-6.0.1_r81/<path>?format=TEXT, base64) and read the lines given.
On the unit: the test sequence in tools/mirror/probe-app.
It flashes system and userdata with the probe as the APK, then works over adb only. To put the
APK back, flash again with the APK the unit had, or the way back. Neither brings back the unit's old
userdata: every flash writes a fresh one, and the bootloader can't read the old one back first.
Open questions
All of the above, on the unit: the probe's steps 1 to 5.Done, 2026-11-16: all passed.The adb key approval above, on the unit: the probe's step 6.Done, 2026-11-16: works for one connection, doesn't last.- Whether CAF's package manager in this image differs from AOSP's in these paths.
- Whether the Mirror's vendor SELinux policy lets
untrusted_appread/data/local/tmp(read 7).