{"record":{"id":"a1f59ea8ad6d56e6","repo":"MuntashirAkon/AppManager","slug":"missing-required-permission-android-permission-manage-users","errorCode":null,"errorMessage":"Missing required permission: android.permission.MANAGE_USERS.","messagePattern":"Missing required permission: android\\.permission\\.MANAGE_USERS\\.","errorType":"exception","errorClass":"RemoteException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java","lineNumber":491,"sourceCode":"        }\n        return false;\n    }\n\n    @RequiresPermission(ManifestCompat.permission.MANAGE_USERS)\n    public static void hidePackage(String packageName, @UserIdInt int userId, boolean hide) throws RemoteException {\n        if (SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.MANAGE_USERS)) {\n            boolean hidden = getPackageManager().setApplicationHiddenSettingAsUser(packageName, hide, userId);\n            if (userId != UserHandleHidden.myUserId()) {\n                if (hidden) {\n                    if (hide) {\n                        BroadcastUtils.sendPackageRemoved(ContextUtils.getContext(), new String[]{packageName});\n                    } else {\n                        BroadcastUtils.sendPackageAdded(ContextUtils.getContext(), new String[]{packageName});\n                    }\n                }\n            }\n        } else {\n            throw new RemoteException(\"Missing required permission: android.permission.MANAGE_USERS.\");\n        }\n    }\n\n    public static boolean isPackageHidden(String packageName, @UserIdInt int userId) throws RemoteException {\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {\n            try {\n                // Find using private flags\n                ApplicationInfo info = getApplicationInfo(packageName,\n                        PackageManagerCompat.MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, userId);\n                return ApplicationInfoCompat.isHidden(info);\n            } catch (PackageManager.NameNotFoundException ignore) {\n            }\n        }\n        if (SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.MANAGE_USERS)) {\n            return getPackageManager().getApplicationHiddenSettingAsUser(packageName, userId);\n        }\n        // Otherwise, there is no way to detect if the package is hidden\n        return false;","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/compat/PackageManagerCompat.java#L473-L509","documentation":"hidePackage only proceeds when the caller can act as a package-hiding mechanism (shell/root or the matching hidden-API path); otherwise it throws RemoteException(\"Missing required privilege: android.permission.MANAGE_USERS\") because the OS enforces that privilege for hiding packages. It is a permission gate, not a package lookup failure.","triggerScenarios":"Calling PackageManagerCompat.hidePackage(packageName, hidden, userId) without holding android.permission.MANAGE_USERS (and typically without shell/root or a system-signature), so the fallback branch throws.","commonSituations":"Running in a normal app sandbox without privileged perms; device owner not configured; testing hide/unhide features on a non-rooted device.","solutions":["Grant/hold android.permission.MANAGE_USERS (privileged/system app) or run via shell/root.","Use non-privileged alternatives (setApplicationHiddenEnabled via device owner, or just uninstall/disable).","Catch RemoteException and degrade gracefully (e.g. inform the user the action requires elevated permissions).","Check permission availability before invoking hidePackage."],"exampleFix":"// before\nPackageManagerCompat.hidePackage(pkg, true, userId);\n// after\nif (ContextCompat.checkSelfPermission(ctx, \"android.permission.MANAGE_USERS\")\n        == PackageManager.PERMISSION_GRANTED) {\n    PackageManagerCompat.hidePackage(pkg, true, userId);\n} else {\n    throw new SecurityException(\"MANAGE_USERS required\");\n}","handlingStrategy":"try-catch","validationCode":"boolean canHide = ContextCompat.checkSelfPermission(ctx,\n        \"android.permission.MANAGE_USERS\") == PackageManager.PERMISSION_GRANTED;","typeGuard":null,"tryCatchPattern":"try {\n    PackageManagerCompat.hidePackage(pkg, hidden, userId);\n} catch (RemoteException e) {\n    // inform user that elevated permission is required\n}","preventionTips":["Check MANAGE_USERS (and root/shell context) before calling","Provide graceful degradation for unprivileged callers","Prefer device-owner APIs when available"],"tags":["android","permission","package-hiding"],"backgroundTag":"missing-required-permission","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}