Package:
com.android.systemlibMost APIs require system signature or Device Owner / Profile Owner privileges.
- Launcher Management
- Status Bar / Navigation Bar
- Device Information
- Time / Timezone
- Power Management
- DPM (Device Policy Management)
- App Management
- Storage Management
- Network (WiFi / Ethernet / Proxy / NFC)
- Input Injection
- Sensor Privacy
- System Settings
- Accessibility Services
- OTA Update
- Bug Report / Logging
- USB Management
- Dream (Screensaver)
- Device Type Detection
- Image Utilities
- AppOps / Permission Management
- OEMConfig Restriction Parsing
Files:
SystemLib.kt,Syslib.kt
Returns the package name of the current default launcher.
Returns the application label of the current default launcher.
Returns true if the calling application is the current default launcher.
Returns the package name of the launcher that has the FLAG_SYSTEM flag set.
Returns the ComponentName of the system-flagged launcher.
Returns a list of all installed launchers as Pair(appLabel, packageName).
Same as above with a slightly different internal implementation.
Requires: system signature /
IPackageManager.replacePreferredActivity
Silently sets the default launcher by package name.
Requires: system signature
Silently sets the default launcher by ComponentName.
Silently clears the preferred activity setting for the given package.
Clears all preferred activity settings for every registered launcher.
Requires: system signature
Sets the Home Activity via IPackageManager.
Files:
SystemLib.kt,Syslib.kt
| Constant | Value | Description |
|---|---|---|
DISABLE_NONE |
0x00000000 | Re-enable everything |
DISABLE_EXPAND |
0x00010000 | Prevent status bar from expanding |
DISABLE_NOTIFICATION_ICONS |
0x00020000 | Hide notification icons |
DISABLE_NOTIFICATION_ALERTS |
0x00040000 | Suppress notification alerts |
DISABLE_SYSTEM_INFO |
0x00100000 | Hide WiFi/battery system icons |
DISABLE_HOME |
0x00200000 | Disable and hide Home button |
DISABLE_RECENT |
0x01000000 | Disable and hide Recents button |
DISABLE_BACK |
0x00400000 | Disable and hide Back button |
DISABLE_CLOCK |
0x00800000 | Hide status bar clock |
STATUS_DISABLE_NAVIGATION |
BACK|HOME|RECENT | Disable entire navigation bar |
Requires:
android.permission.STATUS_BARor system signature
Calls StatusBarManager.disable(status) via reflection and automatically calls setStatusBar2. Pass DISABLE_NONE to restore everything.
Calls StatusBarManager.disable2(status) to control quick settings panel, system icons, and notification shade.
Requires: system signature /
IOverlayManager
Switches the navigation bar to gesture navigation mode.
Requires: system signature /
IOverlayManager
Switches the navigation bar to 3-button mode.
File:
SystemLib.kt
Returns the device serial number. Reads persist.radio.sn first, falls back to Build.getSerial().
Returns the system version string. Reads ro.product.version first, falls back to ro.build.display.id.
Reads a system property value (equivalent to getprop <key>).
Requires: system signature + SELinux policy
Sets a system property value.
Requires:
READ_PHONE_STATE
Returns IMEI1 and IMEI2 for dual-SIM devices as Pair(imei1, imei2).
Requires:
READ_PHONE_STATE
Returns the IMSI (subscriber ID) of the SIM card.
Returns the Wi-Fi MAC address. If the system returns 02:00:00:00:00:00, attempts to retrieve the real address via IWifiManager.
Returns the Bluetooth MAC address.
Returns external storage (SD card) usage as Triple(used, available, total) in bytes.
Returns RAM usage as Triple(used, available, total) in bytes.
Returns total RAM size in GB.
Returns battery capacity in mAh via reflection on PowerProfile.getBatteryCapacity().
Returns the factory Wi-Fi MAC address via IWifiManager.
Returns true if the active network has NET_CAPABILITY_VALIDATED.
Pings www.baidu.com 3 times. Returns 200 on success, 404 on failure.
Returns true if the device has root access (attempts to run su).
Iterates all network interfaces and returns the first available IPv4 address.
Returns the IPv4 address of the active network via ConnectivityManager.getLinkProperties (Android 6+).
Min API: 26
Returns app storage usage as LongArray(cacheBytes, appBytes, dataBytes).
File:
SystemLib.kt
Asynchronously fetches a timestamp (milliseconds) from an NTP server and delivers it on the main thread.
- Default
url:ntp.aliyun.com - Alternatives:
ntp1.nim.ac.cn,edu.ntp.org.cn
Requires:
SET_TIMEpermission
Sets the system time via AlarmManager.setTime(). time is a Unix timestamp in milliseconds.
Requires:
SET_TIMEpermission
Sets the system timezone. Example zone: Asia/Shanghai.
Returns an array of all timezone IDs supported by the system.
Sets the system language via LocalePicker.updateLocale. Supported language formats: zh, zh-CN, zh-Hant-TW.
Files:
Syslib.kt,Android14.kt
Requires: system signature /
IPowerManager
Powers off the device via IPowerManager.shutdown().
Requires: system signature /
IPowerManager
Reboots the device via IPowerManager.reboot().
Triggers a factory reset by broadcasting android.intent.action.FACTORY_RESET.
Requires: system signature /
IPowerManager
Puts the device to sleep (screen off + lock) via IPowerManager.goToSleep().
Puts the device to sleep via reflection on PowerManager.goToSleep().
Requires: system signature /
IPowerManager
Wakes up the screen via IPowerManager.wakeUp().
Returns true if the screen is on, via IPowerManager.isInteractive.
Returns milliseconds since boot, excluding time spent in deep sleep.
Returns milliseconds since boot, including time spent in deep sleep.
Min API: 34
Note: Turns off the screen without triggering the lock screen.mode=0turns off,mode=2turns on.
Controls display power state via SurfaceComposer.setPowerMode().
File:
DPM.kt
All methods requireDevicePolicyManagerprivileges (Profile Owner or Device Owner).
Compat: API 31–36 (Android 16 adds a 4th
callerPackageNameparameter — handled automatically)
Silently activates the device admin.
Deactivates the device admin.
Compat: API 31–36 (Android 14+ reduces parameters from 3 to 2 — handled automatically)
Sets the component as Profile Owner after activating it as admin.
Convenience method combining setActiveAdmin + setProfileOwner.
Returns the Profile Owner ComponentName for the current user.
Clears the Profile Owner.
Returns true if the given component is an active device admin.
Returns true if the given package is the Profile Owner.
Reads the default supervision Profile Owner component name from system config.xml.
Opens the system's Provision Managed Profile UI to guide the user through authorization.
Shows the system device admin request dialog for manual user authorization.
Compat: API 31–33 uses 2-param
lockNow; API 34+ uses 3-param version with caller package — handled automatically
Immediately locks the device. Returns true on success.
setDisableLockScreen(context: Context, oldPassword: String, isDisable: Boolean, change: (String) -> Unit)
Enables or disables the lock screen. Requires the current password (PIN or password type only).
Min API: 30
Returns the current lock screen credential type: -1=none/swipe, 1=pattern, 3=PIN, 4=password.
Resets the lock screen password.
Returns the current password quality policy value.
Sets the password quality policy. quality refers to DevicePolicyManager.PASSWORD_QUALITY_* constants.
Returns all PASSWORD_QUALITY_* constant names and values for enumeration.
Sets the minimum password length.
Sets the password expiration timeout in milliseconds.
Sets the screen auto-lock timeout in milliseconds. 0 means lock immediately.
setMaximumFailedPasswordsForWipe(admin: ComponentName, context: Context, num: Int, change: (String) -> Unit)
Sets the maximum number of failed password attempts before wiping the device. 0 disables this policy.
Returns the current maximum failed password attempts setting.
Enables or disables the camera.
Returns true if the camera is disabled.
Enables or disables screen capture.
Returns true if screen capture is disabled.
Min API: 23
Enables or disables the status bar via DPM.
disableMDM(context: Context, componentName: ComponentName, key: String, isDisable: Boolean, change: (Boolean) -> Unit)
Disables a feature using a UserManager restriction key (e.g. UserManager.DISALLOW_CAMERA).
Returns true if the given UserManager restriction key is active.
Sets a global proxy via IDevicePolicyManager. host format: 127.0.0.1:8080.
Clears the global proxy.
Sets a recommended global proxy (independent of the system global proxy).
Min API: 26
Grants uninstall-block delegate permission to the given package.
Sets the system update policy (e.g. freeze updates).
Clears external storage data via DPM.
Starts kiosk mode (lock task mode), restricting the device to the specified packages.
installCer(context: Context, admin: ComponentName, file: String, error: (String) -> Unit, success: (String) -> Unit)
Silently installs a CA certificate (.cer format).
Triggers system log collection via DPM.
File:
Syslib.kt
Requires:
INSTALL_PACKAGES
Silently installs an APK or XAPK. Callback change(code, message):
| Code | Meaning |
|---|---|
0 |
Success |
-1 |
Parameter / initialization error |
-2 |
File copy failed |
-3 |
Commit failed |
-4 |
Installation failed (check device logs) |
-5 |
XAPK-related error |
Requires:
DELETE_PACKAGES
Silently uninstalls an application via PackageInstaller.uninstall.
hiddenAPP(packageName: String, isHidden: Boolean)
Requires: system signature
Warning: Can cause system apps to disappear. Do not use on system packages.
Hides an application (invisible in launcher and pm list packages).
isHiddenAPP(packageName: String): Boolean
Returns true if the application is hidden.
Disables or enables a component (hidden from launcher, but visible in pm list packages).
Disables a component at user level (COMPONENT_ENABLED_STATE_DISABLED_USER).
Enables or disables a component (same as disableApp).
Returns true if the component is in DISABLED state.
suspendedAPP(packageName: String, isHidden: Boolean)
Requires: system signature
Compat: API 31–36 (parameter count differs per version — handled automatically)
Suspends an application (icon grayed out, app unusable).
Returns true if the application is suspended.
Returns true if ApplicationInfo.FLAG_SUSPENDED is set for the application.
Requires: system signature
Blocks or unblocks uninstallation of the given package via IPackageManager.setBlockUninstallForUser.
Returns true if uninstallation of the package is blocked.
Returns true if the application has the FLAG_SYSTEM flag.
Returns true if the application is user-installed (FLAG_INSTALLED).
Returns all package names by running pm list packages.
Returns all package names via IPackageManager.allPackages.
Returns the data directory path of the given application.
Returns true if the device has just been flashed or factory-reset.
Returns true if the application allows backup (FLAG_ALLOW_BACKUP).
Requires: system signature
Silently grants a runtime permission via IPackageManager.grantRuntimePermission.
Returns true if the application is on the battery optimization whitelist.
Returns the current battery optimization whitelist.
Removes the specified task via IActivityManager.removeTask().
Removes the specified task via IActivityTaskManager.removeTask().
Launches two activities in split-screen mode. component1 appears on top/left.
Launches the specified activity on the secondary display.
File:
Syslib.kt
Unmounts all removable storage devices.
Returns a list of paths for all connected USB storage devices.
Registers a storage device change listener. Callback parameters: (volumeId, path, type, state).
Unregisters the storage device change listener.
Returns all storage volumes as List<Triple(id, type, state)>.
Mounts the storage volume with the given volume ID.
Unmounts the storage volume with the given volume ID.
| Constant | Value | Description |
|---|---|---|
VOLUME_TYPE_PUBLIC |
0 | Public storage |
VOLUME_STATE_UNMOUNTED |
0 | Not mounted |
VOLUME_STATE_MOUNTED |
2 | Mounted |
Clears all data for the given application. Callback: (packageName, success).
Files:
Syslib.kt,SystemLib.kt
Removes a saved Wi-Fi configuration by SSID.
Removes a saved Wi-Fi configuration by WifiConfiguration object.
Adds a Wi-Fi configuration. Returns networkId (-1 on failure).
Min API: 29
Creates a Wi-Fi connection scoped to the current app (does not persist to system settings).
Requires: system signature
Returns all saved Wi-Fi configurations including passwords via IWifiManager.
Disables the personal hotspot via IWifiManager.stopSoftAp(). Enabling is not currently supported.
Returns true if the personal hotspot is disabled (wifiApEnabledState == 13).
Compat: API 31–32 uses
Trackstop/Trackstart; API 33+ usessetEthernetEnabled
Enables or disables Ethernet. isSupported callback indicates whether the operation is supported on this device.
Registers an Ethernet interface state change listener. Callback: (interfaceName, isAvailable).
Unregisters the Ethernet listener.
Returns true if the specified Ethernet interface is available.
Returns true if the device's IEthernetManager supports the disable control interface.
Returns true if the device's IEthernetManager supports the listener interface.
Sets the HTTP proxy by writing http_proxy to Settings.Global. Format: host:port.
Sets the global proxy by writing multiple fields to Settings.Global. Supports PAC file URLs.
Compat: API 31–34 uses
INfcAdapter; API 35+ usesNfcAdapterreflection
Enables NFC.
Compat: same as above
Disables NFC.
Enables or disables USB data transfer (disables ADB and writes to vendor properties).
Returns true if USB data transfer is disabled.
Min API: 31
Returns the wireless ADB port (default: 5555).
Min API: 31
Allows wireless debugging on the specified SSID network.
Starts the ADB daemon by setting system property ctl.start=adbd. Requires SELinux permission.
Stops the ADB daemon by setting system property ctl.stop=adbd.
File:
InputLib.kt
Requires:INJECT_EVENTS(system signature). Alternatively, use Accessibility Service without system signature.
Initializes input injection. Must be called before any other inject method to obtain the IInputManager instance.
Injects a touch event on a background thread. action: MotionEvent.ACTION_DOWN / ACTION_UP / ACTION_MOVE.
Injects a touch event synchronously (source=TOUCHSCREEN).
Injects a scroll event (source=MOUSE, axis=VSCROLL).
Injects a keyboard event using a JS keycode, converted via the JS_KEYCODE_TO_ANDROID mapping table.
Injects a key press using an Android KeyEvent.KEYCODE_* value via Instrumentation.sendKeyDownUpSync.
Injects any InputEvent object (generic interface).
Files:
Syslib.kt(unified entry),Android12.kt,Android13.kt
Supported only on Android 12–13 (API 31–33). This interface was removed in API 34+.
Toggles sensor privacy for the specified sensor. Automatically selects the correct API version implementation.
sensor = 1: Microphonesensor = 2: Camerasensor = 3: Other sensors
Min API: 33
Registers a sensor privacy change listener.
Unregisters the sensor privacy change listener.
Files:
Syslib.kt,X.kt
Reads a value from Settings.Global.
Requires:
WRITE_SECURE_SETTINGS
Writes a value to Settings.Global.
Enumerates all readable key-value pairs from Settings.Global, Settings.System, and Settings.Secure.
Queries a single setting by URI. Returns Pair(name, value).
Queries multiple settings by URI. Returns List<Pair(name, value)>.
Updates a setting entry (update operation).
Inserts a new setting entry (insert operation).
Batch-updates setting entries (applyBatch operation).
File:
Syslib.kt
Requires:
WRITE_SECURE_SETTINGS
Enables the specified accessibility service (appends to the enabled list).
Requires:
WRITE_SECURE_SETTINGS
Removes the specified accessibility service from the enabled list.
Requires:
WRITE_SECURE_SETTINGS
Enables or disables the calling application's accessibility service master switch.
File:
Syslib.kt
Requires: A/B partition device (Virtual A/B also supported).
Applies a local OTA update package via UpdateEngine.
file: Local OTA zip file pathonStatusUpdate(status, percent): Progress callbackonErrorCode(errorCode): Completion callback.errorCode=0means success.
Converts an UpdateEngine.UpdateStatusConstants value to a human-readable string.
Converts an UpdateEngine.ErrorCodeConstants value to a human-readable string.
File:
Syslib.kt
Triggers system log collection via IActivityManager.requestBugReport(0). A share entry appears in the notification shade when complete. Output path: /data/user_de/0/com.android.shell/files/bugreports.
Requires:
DUMPpermission
Min API: 30
Captures a bug report via BugreportManager, outputs to the app's external files directory, and delivers the file path in the callback.
File:
Syslib.kt
disableUsbPermissionDialogs(device: UsbDevice, packageName: String?, uid: Int, error: (String) -> Unit)
Silently grants USB device permission via IUsbManager and binds the given app as the default handler, suppressing the permission dialog.
packageName = nullclears the binding.
File:
Android12.kt
Prints all installed screensaver apps (services implementing DreamService.SERVICE_INTERFACE).
Starts the screensaver. No-op if the screensaver is already active.
Starts the screensaver after a delay via reflection on PowerManager.dream(time).
Starts a specific screensaver by ComponentName (for debugging).
Returns the currently configured screensaver ComponentName (first item in the list).
Sets the screensaver ComponentName.
Requires: system signature
Silently grants notification listener access to the specified component.
File:
DeviceUtils.kt
Returns true if the device is an Android TV (has android.software.leanback feature).
Returns true if the device is a Wear OS device (has android.hardware.type.watch feature).
Returns true if the device is an Android Auto device (has android.hardware.type.automotive feature).
File:
X.kt
Converts a Drawable to a PNG ByteArray (scaled to 72x72 before compression).
Compresses a Bitmap to a PNG ByteArray.
Deserializes a ByteArray to a BitmapDrawable.
Decodes a ByteArray to a Bitmap.
Converts a Drawable to a 72x72 Bitmap.
Extension function. Scales a Bitmap to 72x72.
Loads and scales a Bitmap from a file path to fit within the specified dimensions. Automatically calculates inSampleSize to avoid OOM.
Writes a string to a file. append=true appends; append=false overwrites.
Known limitation: Currently only traverses and prints the directory tree. Does not actually copy files. Do not use for file copy operations.
Shows a Toast from an Activity.
File:
Oops.kt
| Constant | Value | Description |
|---|---|---|
MODE_ALLOWED |
0 | Access allowed |
MODE_IGNORED |
1 | Access denied, no crash |
MODE_ERRORED |
2 | Access denied, throws exception |
MODE_DEFAULT |
3 | Determined by caller |
MODE_FOREGROUND |
4 | Allowed only in foreground |
| Constant | Value | Description |
|---|---|---|
MODE_UNRESTRICTED |
1 | Unrestricted (whitelist) |
MODE_OPTIMIZED |
2 | Optimized (default) |
MODE_RESTRICTED |
3 | Restricted background |
Requires: system signature /
IAppOpsService
Sets the AppOps mode for the given package and operation code. Calls both setMode and setUidMode.
code: AppOps operation code (see Appendix for the full table)
Verifies the result of setMode by calling AppOpsManager.checkOp via reflection. Returns true if the result is MODE_ALLOWED.
Requires: system signature
Compat: API 30 and below use 2-param interface; API 31+ use 3-param interface — handled automatically
Finds notification listener services in the given package and silently grants access.
Requires: system signature
Silently grants a single runtime (dangerous) permission to the given package.
Requires: system signature
Silently grants all requested runtime (dangerous) permissions to the given package.
Returns the battery optimization state for the given package: MODE_UNRESTRICTED, MODE_OPTIMIZED, or MODE_RESTRICTED.
Min API: 23
Requires: system signature /IDeviceIdleController
Sets the battery optimization state for the given package:
MODE_UNRESTRICTED: Add to whitelist, no background restrictionsMODE_OPTIMIZED: Remove from whitelist, allow backgroundMODE_RESTRICTED: Remove from whitelist, restrict background
Dumps all AppOpsManager operation codes supported on the current device to Logcat (tag: OpCodeDumper).
Exports the full AppOps operation code table for the current device (APP_OP_ constant names, integer codes, OPSTR_ strings) to /sdcard/ops.txt and returns the content as a string.
File:
oemconfig.kt
Parses a single <restriction> element from XML, returning a RestrictionEntry. Supported types:
TYPE_STRING,TYPE_CHOICE,TYPE_INTEGERTYPE_MULTI_SELECT,TYPE_BOOLEANTYPE_BUNDLE,TYPE_BUNDLE_ARRAY(recursively parses child nodes)
Min API: 33
Registers a camera status and torch status listener via ICameraService.addListener().
The full table is available in SystemLib/src/main/java/com/android/systemlib/ops.txt.
Call dumpAppOps() at runtime to generate the complete table for the current device's Android version.
| Feature | Required Permission / Condition |
|---|---|
| DPM operations | Profile Owner or Device Owner |
| Status bar disable | android.permission.STATUS_BAR or system signature |
| Silent install/uninstall | android.permission.INSTALL_PACKAGES |
| Input injection | android.permission.INJECT_EVENTS (system signature) |
| Settings.Global write | android.permission.WRITE_SECURE_SETTINGS |
| Shutdown/reboot | android.permission.REBOOT + system signature |
| System property read/write | System signature + SELinux policy |
| Battery optimization whitelist | System signature |
| App hide/suspend | System signature |
| OTA update | android.permission.OTA_UPDATE + A/B partition |
| AppOps mode set | System signature / IAppOpsService |
| Notification listener grant | System signature / INotificationManager |
| Battery optimization set | System signature / IDeviceIdleController |