Java Code Examples for android.app.admin.DevicePolicyManager#ENCRYPTION_STATUS_INACTIVE
The following examples show how to use
android.app.admin.DevicePolicyManager#ENCRYPTION_STATUS_INACTIVE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceInfo.java From product-emm with Apache License 2.0 | 6 votes |
/** * This method is used to check the status of storage encryption. * @return Returns the current status. */ public boolean isEncryptionEnabled() { if (isDeviceAdminActive()) { switch (devicePolicyManager.getStorageEncryptionStatus()) { case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE: return true; case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE: return false; case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING: return false; default: return false; } } return false; }
Example 2
Source File: DeviceAdminSample.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
private String statusCodeToString(int newStatusCode) { int newStatus = R.string.encryption_status_unknown; switch (newStatusCode) { case DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED: newStatus = R.string.encryption_status_unsupported; break; case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE: newStatus = R.string.encryption_status_inactive; break; case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING: newStatus = R.string.encryption_status_activating; break; case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE: newStatus = R.string.encryption_status_active; break; } return mActivity.getString(newStatus); }
Example 3
Source File: OperationManagerOlderSdk.java From product-emm with Apache License 2.0 | 4 votes |
@Override public void encryptStorage(Operation operation) throws AndroidAgentException { boolean doEncrypt = operation.isEnabled(); JSONObject result = new JSONObject(); if (doEncrypt && getDevicePolicyManager().getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED && (getDevicePolicyManager().getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE)) { getDevicePolicyManager().setStorageEncryption(getCdmDeviceAdmin(), doEncrypt); Intent intent = new Intent(DevicePolicyManager.ACTION_START_ENCRYPTION); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); } else if (!doEncrypt && getDevicePolicyManager().getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED && (getDevicePolicyManager().getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE || getDevicePolicyManager().getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING)) { getDevicePolicyManager().setStorageEncryption(getCdmDeviceAdmin(), doEncrypt); } try { String status; if (getDevicePolicyManager().getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) { status = getContextResources().getString(R.string.shared_pref_default_status); result.put(getContextResources().getString(R.string.operation_status), status); } else { status = getContextResources().getString(R.string.shared_pref_false_status); result.put(getContextResources().getString(R.string.operation_status), status); } } catch (JSONException e) { operation.setStatus(getContextResources().getString(R.string.operation_value_error)); operation.setOperationResponse("Error in parsing ENCRYPT payload."); getResultBuilder().build(operation); throw new AndroidAgentException("Issue in parsing json", e); } operation.setPayLoad(result.toString()); operation.setStatus(getContextResources().getString(R.string.operation_value_completed)); getResultBuilder().build(operation); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Encryption process started"); } }
Example 4
Source File: OperationManagerDeviceOwner.java From product-emm with Apache License 2.0 | 4 votes |
@Override public void encryptStorage(Operation operation) throws AndroidAgentException { boolean doEncrypt = operation.isEnabled(); JSONObject result = new JSONObject(); if (doEncrypt && getDevicePolicyManager().getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED && (getDevicePolicyManager().getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE)) { getDevicePolicyManager().setStorageEncryption(getCdmDeviceAdmin(), doEncrypt); Intent intent = new Intent(DevicePolicyManager.ACTION_START_ENCRYPTION); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); } else if (!doEncrypt && getDevicePolicyManager().getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED && (getDevicePolicyManager().getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE || getDevicePolicyManager().getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING)) { getDevicePolicyManager().setStorageEncryption(getCdmDeviceAdmin(), doEncrypt); } try { String status; if (getDevicePolicyManager().getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) { status = getContextResources().getString(R.string.shared_pref_default_status); result.put(getContextResources().getString(R.string.operation_status), status); } else { status = getContextResources().getString(R.string.shared_pref_false_status); result.put(getContextResources().getString(R.string.operation_status), status); } } catch (JSONException e) { operation.setStatus(getContextResources().getString(R.string.operation_value_error)); operation.setOperationResponse("Error in parsing ENCRYPT payload."); getResultBuilder().build(operation); throw new AndroidAgentException("Issue in parsing json", e); } operation.setPayLoad(result.toString()); operation.setStatus(getContextResources().getString(R.string.operation_value_completed)); getResultBuilder().build(operation); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Encryption process started"); } }
Example 5
Source File: Operation.java From product-emm with Apache License 2.0 | 4 votes |
/** * Encrypt/Decrypt device storage. * @param code - Operation code. * @param data - Data required(Encryption enable/disable switch). * @param requestMode - Request mode(Normal mode or policy bundle mode). */ public void encryptStorage(String code, String data) { boolean doEncrypt = true; try { JSONObject encryptData = new JSONObject(data); if (!encryptData.isNull(resources.getString(R.string.intent_extra_function)) && encryptData.get(resources.getString(R.string.intent_extra_function)).toString() .equalsIgnoreCase(resources.getString(R.string.intent_extra_encrypt))) { doEncrypt = true; } else if (!encryptData.isNull(resources.getString(R.string.intent_extra_function)) && encryptData.get(resources.getString(R.string.intent_extra_function)) .toString() .equalsIgnoreCase( resources.getString(R.string.intent_extra_decrypt))) { doEncrypt = false; } else if (!encryptData.isNull(resources.getString(R.string.intent_extra_function))) { doEncrypt = Boolean.parseBoolean( encryptData.get(resources.getString(R.string.intent_extra_function)) .toString()); } } catch (JSONException e) { Log.e(TAG, "Invalid JSON format." + e); } ComponentName admin = new ComponentName(context, AgentDeviceAdminReceiver.class); if (doEncrypt && devicePolicyManager.getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED && (devicePolicyManager.getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE)) { devicePolicyManager.setStorageEncryption(admin, doEncrypt); Intent intent = new Intent(DevicePolicyManager.ACTION_START_ENCRYPTION); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else if (!doEncrypt && devicePolicyManager.getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED && (devicePolicyManager.getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE || devicePolicyManager.getStorageEncryptionStatus() == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING)) { devicePolicyManager.setStorageEncryption(admin, doEncrypt); } String status; if (devicePolicyManager.getStorageEncryptionStatus() != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) { status = resources.getString(R.string.shared_pref_default_status); } else { status = resources.getString(R.string.shared_pref_false_status); } resultBuilder.build(code, status); }