當前位置: 首頁>>代碼示例>>Java>>正文


Java DevicePolicyManager.ACTION_START_ENCRYPTION屬性代碼示例

本文整理匯總了Java中android.app.admin.DevicePolicyManager.ACTION_START_ENCRYPTION屬性的典型用法代碼示例。如果您正苦於以下問題:Java DevicePolicyManager.ACTION_START_ENCRYPTION屬性的具體用法?Java DevicePolicyManager.ACTION_START_ENCRYPTION怎麽用?Java DevicePolicyManager.ACTION_START_ENCRYPTION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.app.admin.DevicePolicyManager的用法示例。


在下文中一共展示了DevicePolicyManager.ACTION_START_ENCRYPTION屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPreferenceClick

@Override
public boolean onPreferenceClick(Preference preference) {
    if (super.onPreferenceClick(preference)) {
        return true;
    }
    if (preference == mActivateEncryption) {
        if (alertIfMonkey(mActivity, R.string.monkey_encryption)) {
            return true;
        }
        // Check to see if encryption is even supported on this device (it's optional).
        if (mDPM.getStorageEncryptionStatus() ==
                DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) {
            AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
            builder.setMessage(R.string.encryption_not_supported);
            builder.setPositiveButton(R.string.encryption_not_supported_ok, null);
            builder.show();
            return true;
        }
        // Launch the activity to activate encryption.  May or may not return!
        Intent intent = new org.bbs.apklauncher.emb.IntentHelper(DevicePolicyManager.ACTION_START_ENCRYPTION);
        startActivityForResult(intent, REQUEST_CODE_START_ENCRYPTION);
        return true;
    }
    return false;
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:25,代碼來源:DeviceAdminSample.java

示例2: onPreferenceClick

@Override
public boolean onPreferenceClick(Preference preference) {
    if (super.onPreferenceClick(preference)) {
        return true;
    }
    if (preference == mActivateEncryption) {
        if (alertIfMonkey(mActivity, R.string.monkey_encryption)) {
            return true;
        }
        // Check to see if encryption is even supported on this device (it's optional).
        if (mDPM.getStorageEncryptionStatus() ==
                DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) {
            AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
            builder.setMessage(R.string.encryption_not_supported);
            builder.setPositiveButton(R.string.encryption_not_supported_ok, null);
            builder.show();
            return true;
        }
        // Launch the activity to activate encryption.  May or may not return!
        Intent intent = new Intent(DevicePolicyManager.ACTION_START_ENCRYPTION);
        startActivityForResult(intent, REQUEST_CODE_START_ENCRYPTION);
        return true;
    }
    return false;
}
 
開發者ID:Sherchen,項目名稱:ApiDemos,代碼行數:25,代碼來源:DeviceAdminSample.java

示例3: encryptStorage

@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");
    }
}
 
開發者ID:wso2-attic,項目名稱:product-emm,代碼行數:46,代碼來源:OperationManagerOlderSdk.java

示例4: encryptStorage

/**
 * 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);

}
 
開發者ID:wso2-attic,項目名稱:product-emm,代碼行數:60,代碼來源:Operation.java


注:本文中的android.app.admin.DevicePolicyManager.ACTION_START_ENCRYPTION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。