Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1964ea50 authored by Rubin Xu's avatar Rubin Xu Committed by Android (Google) Code Review
Browse files

Merge "Enable system service to notify device owners about pending update"

parents aba29b77 dc105cc9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5651,6 +5651,7 @@ package android.app.admin {
    method public void onProfileProvisioningComplete(android.content.Context, android.content.Intent);
    method public void onReadyForUserInitialization(android.content.Context, android.content.Intent);
    method public void onReceive(android.content.Context, android.content.Intent);
    method public void onSystemUpdatePending(android.content.Context, android.content.Intent, long);
    field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLED = "android.app.action.DEVICE_ADMIN_DISABLED";
    field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED";
    field public static final java.lang.String ACTION_DEVICE_ADMIN_ENABLED = "android.app.action.DEVICE_ADMIN_ENABLED";
+2 −0
Original line number Diff line number Diff line
@@ -5746,6 +5746,7 @@ package android.app.admin {
    method public void onProfileProvisioningComplete(android.content.Context, android.content.Intent);
    method public void onReadyForUserInitialization(android.content.Context, android.content.Intent);
    method public void onReceive(android.content.Context, android.content.Intent);
    method public void onSystemUpdatePending(android.content.Context, android.content.Intent, long);
    field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLED = "android.app.action.DEVICE_ADMIN_DISABLED";
    field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED";
    field public static final java.lang.String ACTION_DEVICE_ADMIN_ENABLED = "android.app.action.DEVICE_ADMIN_ENABLED";
@@ -5851,6 +5852,7 @@ package android.app.admin {
    method public boolean isProfileOwnerApp(java.lang.String);
    method public boolean isUninstallBlocked(android.content.ComponentName, java.lang.String);
    method public void lockNow();
    method public void notifyPendingSystemUpdate(long);
    method public void removeActiveAdmin(android.content.ComponentName);
    method public boolean removeCrossProfileWidgetProvider(android.content.ComponentName, java.lang.String);
    method public boolean removeUser(android.content.ComponentName, android.os.UserHandle);
+33 −0
Original line number Diff line number Diff line
@@ -263,6 +263,20 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
    /** @hide */
    public static final String EXTRA_CHOOSE_PRIVATE_KEY_RESPONSE = "android.app.extra.CHOOSE_PRIVATE_KEY_RESPONSE";

    /**
     * Broadcast action: notify device owner that there is a pending system update.
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_NOTIFY_PENDING_SYSTEM_UPDATE = "android.app.action.NOTIFY_PENDING_SYSTEM_UPDATE";

    /**
     * A long type extra for {@link #onSystemUpdatePending} recording the system time as given by
     * {@link System#currentTimeMillis()} when the current pending system update is first available.
     * @hide
     */
    public static final String EXTRA_SYSTEM_UPDATE_RECEIVED_TIME = "android.app.extra.SYSTEM_UPDATE_RECEIVED_TIME";

    /**
     * Name under which a DevicePolicy component publishes information
     * about itself.  This meta-data must reference an XML resource containing
@@ -485,6 +499,22 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
        return null;
    }

    /**
     * Allows the receiver to be notified when information about a pending system update is
     * available from the system update service. The same pending system update can trigger multiple
     * calls to this method, so it is necessary to examine the incoming parameters for details about
     * the update.
     * <p>
     * This callback is only applicable to device owners.
     *
     * @param context The running context as per {@link #onReceive}.
     * @param intent The received intent as per {@link #onReceive}.
     * @param receivedTime The time as given by {@link System#currentTimeMillis()} indicating when
     *        the current pending update was first available. -1 if no pending update is available.
     */
    public void onSystemUpdatePending(Context context, Intent intent, long receivedTime) {
    }

    /**
     * Intercept standard device administrator broadcasts.  Implementations
     * should not override this method; it is better to implement the
@@ -530,6 +560,9 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
            onLockTaskModeExiting(context, intent);
        } else if (ACTION_READY_FOR_USER_INITIALIZATION.equals(action)) {
            onReadyForUserInitialization(context, intent);
        } else if (ACTION_NOTIFY_PENDING_SYSTEM_UPDATE.equals(action)) {
            long receivedTime = intent.getLongExtra(EXTRA_SYSTEM_UPDATE_RECEIVED_TIME, -1);
            onSystemUpdatePending(context, intent, receivedTime);
        }
    }
}
+20 −0
Original line number Diff line number Diff line
@@ -4301,4 +4301,24 @@ public class DevicePolicyManager {
            Log.w(TAG, "Failed talking with device policy service", re);
        }
    }

    /**
     * Callable by the system update service to notify device owners about pending updates.
     * The caller must hold {@link android.Manifest.permission#NOTIFY_PENDING_SYSTEM_UPDATE}
     * permission.
     *
     * @param updateReceivedTime The time as given by {@link System#currentTimeMillis()} indicating
     *        when the current pending update was first available. -1 if no update is available.
     * @hide
     */
    @SystemApi
    public void notifyPendingSystemUpdate(long updateReceivedTime) {
        if (mService != null) {
            try {
                mService.notifyPendingSystemUpdate(updateReceivedTime);
            } catch (RemoteException re) {
                Log.w(TAG, "Could not notify device owner about pending system update", re);
            }
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -225,4 +225,6 @@ interface IDevicePolicyManager {
    boolean setKeyguardEnabledState(in ComponentName admin, boolean enabled);
    void setStatusBarEnabledState(in ComponentName who, boolean enabled);
    boolean getDoNotAskCredentialsOnBoot();

    void notifyPendingSystemUpdate(in long updateReceivedTime);
}
Loading