MuntashirAkon/AppManager · error · RemoteException

Could not freeze myself.

Error message

Could not freeze myself.

What it means

FreezeUtils.freeze refuses to freeze App Manager itself: if the target packageName equals BuildConfig.APPLICATION_ID and the target userId is the current user, it throws RemoteException("Could not freeze myself.") as a self-protection guard, since freezing the running app would break the caller. It is thrown before any actual freezing (hide/disable/suspend) happens.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/utils/FreezeUtils.java:84

        // An app is frozen if one of the following operations return true: suspend, disable or hide
        if (!applicationInfo.enabled) {
            return true;
        }
        if (ApplicationInfoCompat.isSuspended(applicationInfo)) {
            return true;
        }
        return ApplicationInfoCompat.isHidden(applicationInfo);
    }

    @Deprecated
    public static void freeze(@NonNull String packageName, @UserIdInt int userId) throws RemoteException {
        freeze(packageName, userId, Prefs.Blocking.getDefaultFreezingMethod());
    }

    public static void freeze(@NonNull String packageName, @UserIdInt int userId, @FreezeMethod int freezeType)
            throws RemoteException {
        if (BuildConfig.APPLICATION_ID.equals(packageName) && userId == UserHandleHidden.myUserId()) {
            throw new RemoteException("Could not freeze myself.");
        }
        if (freezeType == FREEZE_HIDE) {
            if (SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.MANAGE_USERS)) {
                PackageManagerCompat.hidePackage(packageName, userId, true);
                return;
            }
            // No permission, fall-through
        } else if ((freezeType == FREEZE_SUSPEND || freezeType == FREEZE_ADV_SUSPEND) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            if (freezeType == FREEZE_ADV_SUSPEND) {
                // Force-stop app
                if (SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.FORCE_STOP_PACKAGES)) {
                    PackageManagerCompat.forceStopPackage(packageName, userId);
                }
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                if (SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.SUSPEND_APPS)) {
                    PackageManagerCompat.suspendPackages(new String[]{packageName}, userId, true);
                    return;

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Exclude the app's own package (BuildConfig.APPLICATION_ID) from the list before calling freeze
  2. Check `BuildConfig.APPLICATION_ID.equals(packageName) && userId == UserHandleHidden.myUserId()` and skip/notify instead of freezing
  3. Only pass a different userId when intentionally freezing a clone of the app in another profile
  4. Catch RemoteException and surface a user-friendly message

Example fix

// before
FreezeUtils.freeze(pkg, userId, method);
// after
if (!BuildConfig.APPLICATION_ID.equals(pkg) || userId != UserHandleHidden.myUserId()) {
    FreezeUtils.freeze(pkg, userId, method);
}
Defensive patterns

Strategy: validation

Validate before calling

if (BuildConfig.APPLICATION_ID.equals(packageName) && userId == UserHandleHidden.myUserId()) {
    return; // skip self
}
FreezeUtils.freeze(packageName, userId, freezeType);

Type guard

boolean isSelfTarget(String pkg, int userId) {
    return BuildConfig.APPLICATION_ID.equals(pkg) && userId == UserHandleHidden.myUserId();
}

Try / catch

try {
    FreezeUtils.freeze(packageName, userId, freezeType);
} catch (RemoteException e) {
    Log.w(TAG, "Cannot freeze: " + e.getMessage());
}

Prevention

When it happens

Trigger: Calling freeze(packageName, userId, freezeType) with packageName == "io.github.muntashirakon.AppManager" (or whatever the build's application ID is) while userId == UserHandleHidden.myUserId().

Common situations: Bulk 'freeze all selected apps' operations that accidentally include App Manager; UI list filtering bugs that do not exclude the app itself; scripted/automation flows that freeze every installed package.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/8bbbe6e355d567a7. Report an issue: GitHub.