summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2015-04-23 09:05:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-23 09:05:07 +0000
commit1964ea500b2760b9cc67aa87987459d0b8cb43da (patch)
tree9e34d48e38882cf5e23760329955f8438ebba1e6 /services
parentaba29b77a5742fc920ec62dbc9ddb6f025759d65 (diff)
parentdc105cc91c63c27479d73a21702cd4ba0304acc4 (diff)
downloadframeworks_base-1964ea500b2760b9cc67aa87987459d0b8cb43da.zip
frameworks_base-1964ea500b2760b9cc67aa87987459d0b8cb43da.tar.gz
frameworks_base-1964ea500b2760b9cc67aa87987459d0b8cb43da.tar.bz2
Merge "Enable system service to notify device owners about pending update"
Diffstat (limited to 'services')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index dc7fad6..80d075d 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -22,6 +22,7 @@ import static android.app.admin.DevicePolicyManager.WIPE_EXTERNAL_STORAGE;
import static android.app.admin.DevicePolicyManager.WIPE_RESET_PROTECTION_DATA;
import static android.content.pm.PackageManager.GET_UNINSTALLED_PACKAGES;
+import android.Manifest.permission;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.accounts.AccountManager;
import android.app.Activity;
@@ -45,6 +46,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
@@ -6088,4 +6090,42 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
return false;
}
+
+ @Override
+ public void notifyPendingSystemUpdate(long updateReceivedTime) {
+ mContext.enforceCallingOrSelfPermission(permission.NOTIFY_PENDING_SYSTEM_UPDATE,
+ "Only the system update service can broadcast update information");
+
+ if (UserHandle.getCallingUserId() != UserHandle.USER_OWNER) {
+ Slog.w(LOG_TAG, "Only the system update service in the primary user" +
+ "can broadcast update information.");
+ return;
+ }
+ Intent intent = new Intent(DeviceAdminReceiver.ACTION_NOTIFY_PENDING_SYSTEM_UPDATE);
+ intent.putExtra(DeviceAdminReceiver.EXTRA_SYSTEM_UPDATE_RECEIVED_TIME,
+ updateReceivedTime);
+
+ synchronized (this) {
+ String deviceOwnerPackage = getDeviceOwner();
+ if (deviceOwnerPackage == null) {
+ return;
+ }
+
+ try {
+ ActivityInfo[] receivers = mContext.getPackageManager().getPackageInfo(
+ deviceOwnerPackage, PackageManager.GET_RECEIVERS).receivers;
+ if (receivers != null) {
+ for (int i = 0; i < receivers.length; i++) {
+ if (permission.BIND_DEVICE_ADMIN.equals(receivers[i].permission)) {
+ intent.setComponent(new ComponentName(deviceOwnerPackage,
+ receivers[i].name));
+ mContext.sendBroadcastAsUser(intent, UserHandle.OWNER);
+ }
+ }
+ }
+ } catch (NameNotFoundException e) {
+ Log.e(LOG_TAG, "Cannot find device owner package", e);
+ }
+ }
+ }
}