Update demo for DPM encryption controls
* Follow revised API * Show more status Bug: 3346770 Change-Id: I6c5cd8d8f055ceb3a3a78cf3868dbc0f2d535acf
This commit is contained in:
@@ -847,7 +847,7 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
|
|||||||
builder.show();
|
builder.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mDPM.getStorageEncryption(mDeviceAdminSample) ==
|
if (mDPM.getStorageEncryptionStatus() ==
|
||||||
DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) {
|
DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(Controller.this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(Controller.this);
|
||||||
builder.setMessage("Encryption is unsupported on this device.");
|
builder.setMessage("Encryption is unsupported on this device.");
|
||||||
@@ -866,8 +866,18 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void updateEncryptionStatus() {
|
private void updateEncryptionStatus() {
|
||||||
|
boolean sampleAdminStatusValue = mDPM.getStorageEncryption(mDeviceAdminSample);
|
||||||
|
String sampleAdminStatus = Boolean.toString(sampleAdminStatusValue);
|
||||||
|
boolean adminStatusValue = mDPM.getStorageEncryption(null);
|
||||||
|
String adminStatus = Boolean.toString(adminStatusValue);
|
||||||
|
int deviceStatusCode = mDPM.getStorageEncryptionStatus();
|
||||||
|
String deviceStatus = statusCodeToString(deviceStatusCode);
|
||||||
|
mEncryptionStatus.setText("sample:" + sampleAdminStatus + " admins:" + adminStatus
|
||||||
|
+ " device:" + deviceStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String statusCodeToString(int newStatusCode) {
|
||||||
String newStatus = "unknown";
|
String newStatus = "unknown";
|
||||||
int newStatusCode = mDPM.getStorageEncryption(mDeviceAdminSample);
|
|
||||||
switch (newStatusCode) {
|
switch (newStatusCode) {
|
||||||
case DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED:
|
case DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED:
|
||||||
newStatus = "unsupported";
|
newStatus = "unsupported";
|
||||||
@@ -875,9 +885,6 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
|
|||||||
case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
|
case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
|
||||||
newStatus = "inactive";
|
newStatus = "inactive";
|
||||||
break;
|
break;
|
||||||
case DevicePolicyManager.ENCRYPTION_STATUS_REQUESTED:
|
|
||||||
newStatus = "requested";
|
|
||||||
break;
|
|
||||||
case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING:
|
case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING:
|
||||||
newStatus = "activating";
|
newStatus = "activating";
|
||||||
break;
|
break;
|
||||||
@@ -885,7 +892,7 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
|
|||||||
newStatus = "active";
|
newStatus = "active";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mEncryptionStatus.setText(newStatus);
|
return newStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user