Search in sources :

Example 31 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project android_frameworks_base by ResurrectionRemix.

the class TrustAgentWrapper method updateDevicePolicyFeatures.

boolean updateDevicePolicyFeatures() {
    boolean trustDisabled = false;
    if (DEBUG)
        Slog.v(TAG, "updateDevicePolicyFeatures(" + mName + ")");
    try {
        if (mTrustAgentService != null) {
            DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
            if ((dpm.getKeyguardDisabledFeatures(null, mUserId) & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0) {
                List<PersistableBundle> config = dpm.getTrustAgentConfiguration(null, mName, mUserId);
                trustDisabled = true;
                if (DEBUG)
                    Slog.v(TAG, "Detected trust agents disabled. Config = " + config);
                if (config != null && config.size() > 0) {
                    if (DEBUG) {
                        Slog.v(TAG, "TrustAgent " + mName.flattenToShortString() + " disabled until it acknowledges " + config);
                    }
                    mSetTrustAgentFeaturesToken = new Binder();
                    mTrustAgentService.onConfigure(config, mSetTrustAgentFeaturesToken);
                }
            } else {
                mTrustAgentService.onConfigure(Collections.EMPTY_LIST, null);
            }
            final long maxTimeToLock = dpm.getMaximumTimeToLockForUserAndProfiles(mUserId);
            if (maxTimeToLock != mMaximumTimeToLock) {
                // If the timeout changes, cancel the alarm and send a timeout event to have
                // the agent re-evaluate trust.
                mMaximumTimeToLock = maxTimeToLock;
                if (mAlarmPendingIntent != null) {
                    mAlarmManager.cancel(mAlarmPendingIntent);
                    mAlarmPendingIntent = null;
                    mHandler.sendEmptyMessage(MSG_TRUST_TIMEOUT);
                }
            }
        }
    } catch (RemoteException e) {
        onError(e);
    }
    if (mTrustDisabledByDpm != trustDisabled) {
        mTrustDisabledByDpm = trustDisabled;
        mTrustManagerService.updateTrust(mUserId, 0);
    }
    return trustDisabled;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) IBinder(android.os.IBinder) Binder(android.os.Binder) PersistableBundle(android.os.PersistableBundle) RemoteException(android.os.RemoteException)

Example 32 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project android_frameworks_base by ResurrectionRemix.

the class AccountManagerService method canUserModifyAccountsForType.

private boolean canUserModifyAccountsForType(int userId, String accountType, int callingUid) {
    // the managing app can always modify accounts
    if (isProfileOwner(callingUid)) {
        return true;
    }
    DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
    String[] typesArray = dpm.getAccountTypesWithManagementDisabledAsUser(userId);
    if (typesArray == null) {
        return true;
    }
    for (String forbiddenType : typesArray) {
        if (forbiddenType.equals(accountType)) {
            return false;
        }
    }
    return true;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager)

Example 33 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConfirmDeviceCredentialBaseFragment method setWorkChallengeBackground.

private void setWorkChallengeBackground(View baseView, int userId) {
    View mainContent = getActivity().findViewById(com.android.settings.R.id.main_content);
    if (mainContent != null) {
        // Remove the main content padding so that the background image is full screen.
        mainContent.setPadding(0, 0, 0, 0);
    }
    DevicePolicyManager dpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    baseView.setBackground(new ColorDrawable(dpm.getOrganizationColorForUser(userId)));
    ImageView imageView = (ImageView) baseView.findViewById(R.id.background_image);
    if (imageView != null) {
        Drawable image = getResources().getDrawable(R.drawable.work_challenge_background);
        image.setColorFilter(getResources().getColor(R.color.confirm_device_credential_transparent_black), PorterDuff.Mode.DARKEN);
        imageView.setImageDrawable(image);
        Point screenSize = new Point();
        getActivity().getWindowManager().getDefaultDisplay().getSize(screenSize);
        imageView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, screenSize.y));
    }
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) ColorDrawable(android.graphics.drawable.ColorDrawable) FrameLayout(android.widget.FrameLayout) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) Point(android.graphics.Point) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 34 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConfirmDeviceCredentialBaseFragment method isFingerprintDisabledByAdmin.

private boolean isFingerprintDisabledByAdmin() {
    DevicePolicyManager dpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    final int disabledFeatures = dpm.getKeyguardDisabledFeatures(null, mEffectiveUserId);
    return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) != 0;
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) Point(android.graphics.Point)

Example 35 with DevicePolicyManager

use of android.app.admin.DevicePolicyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProxySelector method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final DevicePolicyManager dpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    final boolean userSetGlobalProxy = (dpm.getGlobalProxyAdmin() == null);
    // Disable UI if the Global Proxy is being controlled by a Device Admin
    mHostnameField.setEnabled(userSetGlobalProxy);
    mPortField.setEnabled(userSetGlobalProxy);
    mExclusionListField.setEnabled(userSetGlobalProxy);
    mOKButton.setEnabled(userSetGlobalProxy);
    mClearButton.setEnabled(userSetGlobalProxy);
    mDefaultButton.setEnabled(userSetGlobalProxy);
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager)

Aggregations

DevicePolicyManager (android.app.admin.DevicePolicyManager)159 ComponentName (android.content.ComponentName)45 UserManager (android.os.UserManager)29 UserInfo (android.content.pm.UserInfo)25 RemoteException (android.os.RemoteException)24 LockPatternUtils (com.android.internal.widget.LockPatternUtils)19 Intent (android.content.Intent)18 PackageManager (android.content.pm.PackageManager)14 PersistableBundle (android.os.PersistableBundle)8 PendingIntent (android.app.PendingIntent)6 IBinder (android.os.IBinder)6 UserHandle (android.os.UserHandle)6 IPackageManager (android.content.pm.IPackageManager)5 Uri (android.net.Uri)5 VrManagerInternal (com.android.server.vr.VrManagerInternal)5 ResolveInfo (android.content.pm.ResolveInfo)4 Point (android.graphics.Point)4 Binder (android.os.Binder)4 KeyStore (android.security.KeyStore)4 ArraySet (android.util.ArraySet)4