Skip to content

Commit ace8ca4

Browse files
author
Rubin Xu
committed
Clarify notification about received system update
Bug: 30163123 Change-Id: Ifedfb159ce03f83e26b7ffa1e1f22ab7de1bd0e7
1 parent f176a9d commit ace8ca4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

app/src/main/java/com/afwsamples/testdpc/DeviceAdminReceiver.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
package com.afwsamples.testdpc;
1818

19+
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE;
20+
import static android.app.admin.DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED;
21+
import static com.afwsamples.testdpc.policy.PolicyManagementFragment.OVERRIDE_KEY_SELECTION_KEY;
22+
1923
import android.accounts.Account;
2024
import android.accounts.AccountManager;
2125
import android.annotation.TargetApi;
@@ -61,10 +65,6 @@
6165
import java.util.Date;
6266
import java.util.List;
6367

64-
import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE;
65-
import static android.app.admin.DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED;
66-
import static com.afwsamples.testdpc.policy.PolicyManagementFragment.OVERRIDE_KEY_SELECTION_KEY;
67-
6868
/**
6969
* Handles events related to the managed profile.
7070
*/
@@ -309,8 +309,14 @@ private boolean isRuntimePermission(PackageManager packageManager, String permis
309309
@TargetApi(Build.VERSION_CODES.M)
310310
@Override
311311
public void onSystemUpdatePending(Context context, Intent intent, long receivedTime) {
312-
Toast.makeText(context, "System update received at: " + receivedTime,
313-
Toast.LENGTH_LONG).show();
312+
if (receivedTime != -1) {
313+
DateFormat sdf = new SimpleDateFormat("hh:mm:ss dd/MM/yyyy");
314+
String timeString = sdf.format(new Date(receivedTime));
315+
Toast.makeText(context, "System update received at: " + timeString,
316+
Toast.LENGTH_LONG).show();
317+
} else {
318+
// No system update is currently available on this device.
319+
}
314320
}
315321

316322
@TargetApi(Build.VERSION_CODES.M)

0 commit comments

Comments
 (0)