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;
}
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;
}
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));
}
}
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;
}
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);
}
Aggregations