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


Java DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE屬性代碼示例

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


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

示例1: statusCodeToString

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);
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:18,代碼來源:DeviceAdminSample.java

示例2: isEncryptionEnabled

/**
 * 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;
}
 
開發者ID:wso2-attic,項目名稱:product-emm,代碼行數:19,代碼來源:DeviceInfo.java

示例3: warning

private Warning warning() {
    final int storageEncryptionStatus = devicePolicyManager.getStorageEncryptionStatus();
    if (config.remindBackup())
        return Warning.BACKUP;
    else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
            && (storageEncryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE
                    || storageEncryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY))
        return Warning.STORAGE_ENCRYPTION;
    else
        return null;
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:11,代碼來源:WalletTransactionsFragment.java

示例4: 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

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