List of usage examples for android.content Context DEVICE_POLICY_SERVICE
String DEVICE_POLICY_SERVICE
To view the source code for android.content Context DEVICE_POLICY_SERVICE.
Click Source Link
From source file:org.wso2.emm.agent.AuthenticationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_authentication); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(R.layout.custom_sherlock_bar); getSupportActionBar().setTitle(Constants.EMPTY_STRING); context = this; deviceInfo = new DeviceInfo(context); etDomain = (EditText) findViewById(R.id.etDomain); etUsername = (EditText) findViewById(R.id.etUsername); etPassword = (EditText) findViewById(R.id.etPassword); radioBYOD = (RadioButton) findViewById(R.id.radioBYOD); loginLayout = (LinearLayout) findViewById(R.id.errorLayout); etDomain.setFocusable(true);//from ww w . jav a 2s .c om etDomain.requestFocus(); btnRegister = (Button) findViewById(R.id.btnRegister); btnRegister.setOnClickListener(onClickAuthenticate); btnRegister.setEnabled(false); // change button color background till user enters a valid input btnRegister.setBackground(getResources().getDrawable(R.drawable.btn_grey)); btnRegister.setTextColor(getResources().getColor(R.color.black)); if (Constants.HIDE_LOGIN_UI) { loginLayout.setVisibility(View.GONE); } if (Constants.DEFAULT_OWNERSHIP == Constants.OWNERSHIP_COSU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { startLockTask(); } } textViewWipeData = (TextView) this.findViewById(R.id.textViewWipeData); if (Constants.DEFAULT_OWNERSHIP == Constants.OWNERSHIP_COSU && Constants.DISPLAY_WIPE_DEVICE_BUTTON) { textViewWipeData.setVisibility(View.VISIBLE); textViewWipeData.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { new AlertDialog.Builder(AuthenticationActivity.this).setTitle(getString(R.string.app_name)) .setMessage(R.string.wipe_confirmation) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getApplicationContext() .getSystemService(Context.DEVICE_POLICY_SERVICE); devicePolicyManager.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE | DevicePolicyManager.WIPE_RESET_PROTECTION_DATA); } }).setNegativeButton(android.R.string.no, null).show(); } }); } etUsername.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { enableSubmitIfReady(); } @Override public void afterTextChanged(Editable s) { enableSubmitIfReady(); } }); etPassword.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { enableSubmitIfReady(); } @Override public void afterTextChanged(Editable s) { enableSubmitIfReady(); } }); if (org.wso2.emm.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE .equals(org.wso2.emm.agent.proxy.utils.Constants.Authenticator.MUTUAL_SSL_AUTHENTICATOR)) { AuthenticatorFactory authenticatorFactory = new AuthenticatorFactory(); authenticator = authenticatorFactory.getClient( org.wso2.emm.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE, AuthenticationActivity.this, Constants.AUTHENTICATION_REQUEST_CODE); authenticator.doAuthenticate(); } //This is an override to ownership type. if (Constants.DEFAULT_OWNERSHIP != null) { deviceType = Constants.DEFAULT_OWNERSHIP; Preference.putString(context, Constants.DEVICE_TYPE, deviceType); } // This is added so that in case due to an agent customisation, if the authentication // activity is called the AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED is set, the activity // must be finished. if (Constants.AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED == true) { finish(); } }
From source file:com.weihuoya.bboo._G.java
public static DevicePolicyManager getDevicePolicyManager() { if (mDPM == null) { mDPM = (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE); }//from w w w . j ava2 s .c o m return mDPM; }
From source file:com.decad3nce.aegis.AegisActivity.java
@Override public void onResume() { super.onResume(); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); if (mDevicePolicyManager.getActiveAdmins() != null) { if (!mDevicePolicyManager.isAdminActive(DEVICE_ADMIN_COMPONENT)) { if (mLockEnabledPreference != null) { mLockEnabledPreference.setChecked(false); lockEnabled = false;/*from ww w .j a v a 2 s. c om*/ } if (mWipeEnabledPreference != null) { mWipeEnabledPreference.setChecked(false); wipeEnabled = false; } } } }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme, Field field, Object forWho) { Resources resources = context.getResources(); switch (type) { case STRING://w w w. j a v a2 s . com setField(field, forWho, resources.getString(idRes)); break; case COLOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, resources.getColor(idRes, theme)); } else { //noinspection deprecation setField(field, forWho, resources.getColor(idRes)); } break; case INTEGER: setField(field, forWho, resources.getInteger(idRes)); break; case BOOL: setField(field, forWho, resources.getBoolean(idRes)); break; case STRING_ARRAY: setField(field, forWho, resources.getStringArray(idRes)); break; case INT_ARRAY: setField(field, forWho, resources.getIntArray(idRes)); break; case PM: setField(field, forWho, context.getSystemService(Context.POWER_SERVICE)); break; case ACCOUNT: setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE)); break; case ALARM: setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE)); break; case AM: setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE)); break; case WM: setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE)); break; case NM: setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE)); break; case TM: setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE)); break; case TCM: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE)); } break; case SP: setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context)); break; case PKM: setField(field, forWho, context.getPackageManager()); break; case HANDLE: setField(field, forWho, new Handler(Looper.getMainLooper())); break; case ASM: setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE)); break; case CAP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE)); } break; case KGD: setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE)); break; case LOCATION: setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE)); break; case SEARCH: setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE)); break; case SENSOR: setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE)); break; case STORAGE: setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE)); break; case WALLPAPER: setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE)); break; case VIBRATOR: setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE)); break; case CONNECT: setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE)); break; case NETWORK_STATUS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE)); } break; case WIFI: setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE)); break; case AUDIO: setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE)); break; case FP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE)); } break; case MEDIA_ROUTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE)); } break; case SUB: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)); } break; case IME: setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE)); break; case CLIP_BOARD: setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE)); break; case APP_WIDGET: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE)); } break; case DEVICE_POLICY: setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE)); break; case DOWNLOAD: setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE)); break; case BATTERY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE)); } break; case NFC: setField(field, forWho, context.getSystemService(Context.NFC_SERVICE)); break; case DISPLAY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE)); } break; case USER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.USER_SERVICE)); } break; case APP_OPS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE)); } break; case BITMAP: setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null)); break; } }
From source file:org.wso2.iot.agent.api.ApplicationManager.java
public ApplicationManager(Context context) { this.context = context; this.resources = context.getResources(); this.packageManager = context.getPackageManager(); this.policyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); }
From source file:com.achep.acdisplay.ui.activities.MainActivity.java
/** * Turns screen off and sends a test notification. * * @param cheat {@code true} if it simply starts {@link AcDisplayActivity}, * {@code false} if it turns device off and then uses notification * to wake it up.//from w w w . j a v a 2 s . c o m */ private void startAcDisplayTest(boolean cheat) { if (cheat) { startActivity(new Intent(this, AcDisplayActivity.class)); sendTestNotification(this); return; } int delay = getResources().getInteger(R.integer.config_test_notification_delay); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test notification."); wakeLock.acquire(delay); try { // Go sleep DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); dpm.lockNow(); new Handler().postDelayed(new Runnable() { private final Context context = getApplicationContext(); @Override public void run() { sendTestNotification(context); } }, delay); } catch (SecurityException e) { Log.wtf(TAG, "Failed to turn screen off!"); wakeLock.release(); } }
From source file:com.toppatch.mv.ui.activities.LoginActivity2.java
private void enableAdmin() { DevicePolicyManager mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); ComponentName mDeviceAdmin = new ComponentName(this, TopPatchAdmin.class); if (mDPM != null) { try {/*from w w w . ja v a 2 s . c om*/ //Add filter to listen to the choice made by the user to accept the terms or not. IntentFilter filter = new IntentFilter(); filter.addAction(EnterpriseLicenseManager.ACTION_LICENSE_STATUS); actionReceiver = new SamsungReceiver(); registerReceiver(actionReceiver, filter); Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdmin); intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Please Activate The Admin To Let Us Steal All Your Data And Sell It To Obama!"); startActivityForResult(intent, RESULT_ENABLE); } catch (Exception e) { Log.w(TAG, "Exception: " + e); } } else { Log.e(TAG, "mDPM is null"); //TODO device doesn't support MDM...report this shit. } }
From source file:com.bullmobi.message.ui.activities.MainActivity.java
/** * Turns screen off and sends a test notification. * * @param cheat {@code true} if it simply starts {@link EasyNotificationActivity}, * {@code false} if it turns device off and then uses notification * to wake it up./*from www .j a va2 s. c o m*/ */ private void startEasyNotificationTest(boolean cheat) { if (cheat) { startActivity(new Intent(this, EasyNotificationActivity.class)); sendTestNotification(this); return; } int delay = getResources().getInteger(R.integer.config_test_notification_delay); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test notification."); wakeLock.acquire(delay); try { // Go sleep DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); dpm.lockNow(); new Handler().postDelayed(new Runnable() { private final Context context = getApplicationContext(); @Override public void run() { sendTestNotification(context); } }, delay); } catch (SecurityException e) { Log.wtf(TAG, "Failed to turn screen off!"); wakeLock.release(); } }
From source file:com.afwsamples.testdpc.common.preference.DpcPreferenceHelper.java
private int getCurrentAdmin() { final DevicePolicyManager dpm = (DevicePolicyManager) mContext .getSystemService(Context.DEVICE_POLICY_SERVICE); final String packageName = mContext.getPackageName(); if (dpm.isDeviceOwnerApp(packageName)) { return ADMIN_DEVICE_OWNER; }// ww w.ja v a 2s .c om if (dpm.isProfileOwnerApp(packageName)) { return ADMIN_PROFILE_OWNER; } return ADMIN_NONE; }
From source file:com.android.settings.accessibility.AccessibilitySettings.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.accessibility_settings); initializeAllPreferences();/*from w ww. j a v a 2s . co m*/ mDpm = (DevicePolicyManager) (getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE)); }