Search in sources :

Example 16 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecuritySettings method getActiveTrustAgents.

private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(Context context, LockPatternUtils utils, DevicePolicyManager dpm) {
    PackageManager pm = context.getPackageManager();
    ArrayList<TrustAgentComponentInfo> result = new ArrayList<TrustAgentComponentInfo>();
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT, PackageManager.GET_META_DATA);
    List<ComponentName> enabledTrustAgents = utils.getEnabledTrustAgents(MY_USER_ID);
    EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context, DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
    if (enabledTrustAgents != null && !enabledTrustAgents.isEmpty()) {
        for (int i = 0; i < resolveInfos.size(); i++) {
            ResolveInfo resolveInfo = resolveInfos.get(i);
            if (resolveInfo.serviceInfo == null)
                continue;
            if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm))
                continue;
            TrustAgentComponentInfo trustAgentComponentInfo = TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
            if (trustAgentComponentInfo.componentName == null || !enabledTrustAgents.contains(TrustAgentUtils.getComponentName(resolveInfo)) || TextUtils.isEmpty(trustAgentComponentInfo.title))
                continue;
            if (admin != null && dpm.getTrustAgentConfiguration(null, TrustAgentUtils.getComponentName(resolveInfo)) == null) {
                trustAgentComponentInfo.admin = admin;
            }
            result.add(trustAgentComponentInfo);
            if (ONLY_ONE_TRUST_AGENT)
                break;
        }
    }
    return result;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) TrustAgentComponentInfo(com.android.settings.TrustAgentUtils.TrustAgentComponentInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 17 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecuritySettings method disableIfPasswordQualityManaged.

/*
     * Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
     * The preference must be a RestrictedPreference.
     */
private void disableIfPasswordQualityManaged(String preferenceKey, int userId) {
    final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(getActivity(), userId);
    if (admin != null && mDPM.getPasswordQuality(admin.component, userId) == DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
        final RestrictedPreference pref = (RestrictedPreference) getPreferenceScreen().findPreference(preferenceKey);
        pref.setDisabledByAdmin(admin);
    }
}
Also used : RestrictedPreference(com.android.settingslib.RestrictedPreference) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 18 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RestrictedSettingsFragment method onDataSetChanged.

@Override
protected void onDataSetChanged() {
    highlightPreferenceIfNeeded();
    if (mAdminSupportDetails != null && isUiRestrictedByOnlyAdmin()) {
        final EnforcedAdmin admin = getRestrictionEnforcedAdmin();
        ShowAdminSupportDetailsDialog.setAdminSupportDetails(getActivity(), mAdminSupportDetails, admin, false);
        setEmptyView(mAdminSupportDetails);
    } else if (mEmptyTextView != null) {
        setEmptyView(mEmptyTextView);
    }
    super.onDataSetChanged();
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 19 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TrustAgentSettings method updateAgents.

private void updateAgents() {
    final Context context = getActivity();
    if (mAvailableAgents == null) {
        mAvailableAgents = findAvailableTrustAgents();
    }
    if (mLockPatternUtils == null) {
        mLockPatternUtils = new LockPatternUtils(getActivity());
    }
    loadActiveAgents();
    PreferenceGroup category = (PreferenceGroup) getPreferenceScreen().findPreference("trust_agents");
    category.removeAll();
    final EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context, DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
    final int count = mAvailableAgents.size();
    for (int i = 0; i < count; i++) {
        AgentInfo agent = mAvailableAgents.valueAt(i);
        final RestrictedSwitchPreference preference = new RestrictedSwitchPreference(getPrefContext());
        preference.useAdminDisabledSummary(true);
        agent.preference = preference;
        preference.setPersistent(false);
        preference.setTitle(agent.label);
        preference.setIcon(agent.icon);
        preference.setPersistent(false);
        preference.setOnPreferenceChangeListener(this);
        preference.setChecked(mActiveAgents.contains(agent.component));
        if (admin != null && mDpm.getTrustAgentConfiguration(null, agent.component) == null) {
            preference.setChecked(false);
            preference.setDisabledByAdmin(admin);
        }
        category.addPreference(agent.preference);
    }
}
Also used : Context(android.content.Context) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) LockPatternUtils(com.android.internal.widget.LockPatternUtils) PreferenceGroup(android.support.v7.preference.PreferenceGroup) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 20 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InstalledAppDetails method onClick.

/*
     * Method implementing functionality of buttons clicked
     * @see android.view.View.OnClickListener#onClick(android.view.View)
     */
public void onClick(View v) {
    if (mAppEntry == null) {
        setIntentAndFinish(true, true);
        return;
    }
    String packageName = mAppEntry.info.packageName;
    if (v == mUninstallButton) {
        if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
            stopListeningToPackageRemove();
            Activity activity = getActivity();
            Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class);
            uninstallDAIntent.putExtra(DeviceAdminAdd.EXTRA_DEVICE_ADMIN_PACKAGE_NAME, mPackageName);
            activity.startActivityForResult(uninstallDAIntent, REQUEST_REMOVE_DEVICE_ADMIN);
            return;
        }
        EnforcedAdmin admin = RestrictedLockUtils.checkIfUninstallBlocked(getActivity(), packageName, mUserId);
        boolean uninstallBlockedBySystem = mAppsControlDisallowedBySystem || RestrictedLockUtils.hasBaseUserRestriction(getActivity(), packageName, mUserId);
        if (admin != null && !uninstallBlockedBySystem) {
            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), admin);
        } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
            if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
                // app for this user.
                if (mUpdatedSysApp && isSingleUser()) {
                    showDialogInner(DLG_SPECIAL_DISABLE, 0);
                } else {
                    showDialogInner(DLG_DISABLE, 0);
                }
            } else {
                new DisableChanger(this, mAppEntry.info, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).execute((Object) null);
            }
        } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
            uninstallPkg(packageName, true, false);
        } else {
            uninstallPkg(packageName, false, false);
        }
    } else if (v == mForceStopButton) {
        if (mAppsControlDisallowedAdmin != null && !mAppsControlDisallowedBySystem) {
            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), mAppsControlDisallowedAdmin);
        } else {
            showDialogInner(DLG_FORCE_STOP, 0);
        //forceStopPackage(mAppInfo.packageName);
        }
    }
}
Also used : SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) Intent(android.content.Intent) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Aggregations

EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)42 View (android.view.View)5 Context (android.content.Context)4 UserManager (android.os.UserManager)3 RestrictedPreference (com.android.settingslib.RestrictedPreference)3 ComponentName (android.content.ComponentName)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Preference (android.support.v7.preference.Preference)2 TextView (android.widget.TextView)2 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)1 Activity (android.app.Activity)1 DevicePolicyManager (android.app.admin.DevicePolicyManager)1 ContentResolver (android.content.ContentResolver)1 ActivityInfo (android.content.pm.ActivityInfo)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 ServiceInfo (android.content.pm.ServiceInfo)1 ConnectivityManager (android.net.ConnectivityManager)1 Bundle (android.os.Bundle)1