Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44af4828 authored by Andrei Stingaceanu's avatar Andrei Stingaceanu
Browse files

RestrictedLockUtils - introduce check for suspended apps

Used in Settings for restricting preferences.

Bug: 22776761
Change-Id: I6aad4400981cee00c734060ea3d6cf2641a721d9
parent c6486620
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.IPackageManager;
import android.content.pm.UserInfo;
import android.content.pm.UserInfo;
import android.graphics.Color;
import android.graphics.Color;
@@ -226,6 +227,26 @@ public class RestrictedLockUtils {
        return null;
        return null;
    }
    }


    /**
     * Check if an application is suspended.
     *
     * @return EnforcedAdmin Object containing the enforced admin component and admin user details,
     * or {@code null} if the application is not suspended.
     */
    public static EnforcedAdmin checkIfApplicationIsSuspended(Context context, String packageName,
            int userId) {
        IPackageManager ipm = AppGlobals.getPackageManager();
        try {
            ApplicationInfo ai = ipm.getApplicationInfo(packageName, 0, userId);
            if (ai != null && ((ai.flags & ApplicationInfo.FLAG_SUSPENDED) != 0)) {
                return getProfileOrDeviceOwnerOnCallingUser(context);
            }
        } catch (RemoteException e) {
            // Nothing to do
        }
        return null;
    }

    /**
    /**
     * Check if account management for a specific type of account is disabled by admin.
     * Check if account management for a specific type of account is disabled by admin.
     * Only a profile or device owner can disable account management. So, we check if account
     * Only a profile or device owner can disable account management. So, we check if account