Merge "Change DEVICE_POLICY_RESOURCE_UPDATED broadcast extras" into tm-dev

This commit is contained in:
Kholoud Mohamed
2022-02-24 13:11:00 +00:00
committed by Android (Google) Code Review
4 changed files with 33 additions and 28 deletions

View File

@@ -7704,9 +7704,10 @@ package android.app.admin {
field public static final String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE = "android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE";
field public static final String EXTRA_PROVISIONING_WIFI_SSID = "android.app.extra.PROVISIONING_WIFI_SSID";
field public static final String EXTRA_PROVISIONING_WIFI_USER_CERTIFICATE = "android.app.extra.PROVISIONING_WIFI_USER_CERTIFICATE";
field public static final String EXTRA_RESOURCE_ID = "android.app.extra.RESOURCE_ID";
field public static final String EXTRA_RESOURCE_TYPE_DRAWABLE = "android.app.extra.RESOURCE_TYPE_DRAWABLE";
field public static final String EXTRA_RESOURCE_TYPE_STRING = "android.app.extra.RESOURCE_TYPE_STRING";
field public static final String EXTRA_RESOURCE_IDS = "android.app.extra.RESOURCE_IDS";
field public static final String EXTRA_RESOURCE_TYPE = "android.app.extra.RESOURCE_TYPE";
field public static final int EXTRA_RESOURCE_TYPE_DRAWABLE = 1; // 0x1
field public static final int EXTRA_RESOURCE_TYPE_STRING = 2; // 0x2
field public static final String EXTRA_RESULT_LAUNCH_INTENT = "android.app.extra.RESULT_LAUNCH_INTENT";
field public static final int FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY = 1; // 0x1
field public static final int FLAG_MANAGED_CAN_ACCESS_PARENT = 2; // 0x2

View File

@@ -3611,42 +3611,45 @@ public class DevicePolicyManager {
/**
* Broadcast action: notify system apps (e.g. settings, SysUI, etc) that the device management
* resources with IDs {@link #EXTRA_RESOURCE_ID} has been updated, the updated resources can be
* resources with IDs {@link #EXTRA_RESOURCE_IDS} has been updated, the updated resources can be
* retrieved using {@link #getDrawable} and {@code #getString}.
*
* <p>This broadcast is sent to registered receivers only.
*
* <p> The following extras will be included to identify the type of resource being updated:
* <ul>
* <li>{@link #EXTRA_RESOURCE_TYPE_DRAWABLE} for drawable resources</li>
* <li>{@link #EXTRA_RESOURCE_TYPE_STRING} for string resources</li>
* </ul>
* <p> {@link #EXTRA_RESOURCE_TYPE} will be included to identify the type of resource being
* updated.
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_DEVICE_POLICY_RESOURCE_UPDATED =
"android.app.action.DEVICE_POLICY_RESOURCE_UPDATED";
/**
* A boolean extra for {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to indicate that a
* resource of type {@link Drawable} is being updated.
* An {@code int} extra for {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to indicate the type
* of the resource being updated, the type can be {@link #EXTRA_RESOURCE_TYPE_DRAWABLE} or
* {@link #EXTRA_RESOURCE_TYPE_STRING}
*/
public static final String EXTRA_RESOURCE_TYPE_DRAWABLE =
"android.app.extra.RESOURCE_TYPE_DRAWABLE";
public static final String EXTRA_RESOURCE_TYPE =
"android.app.extra.RESOURCE_TYPE";
/**
* A boolean extra for {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to indicate that a
* resource of type {@link String} is being updated.
* A {@code int} value for {@link #EXTRA_RESOURCE_TYPE} to indicate that a resource of type
* {@link Drawable} is being updated.
*/
public static final String EXTRA_RESOURCE_TYPE_STRING =
"android.app.extra.RESOURCE_TYPE_STRING";
public static final int EXTRA_RESOURCE_TYPE_DRAWABLE = 1;
/**
* A {@code int} value for {@link #EXTRA_RESOURCE_TYPE} to indicate that a resource of type
* {@link String} is being updated.
*/
public static final int EXTRA_RESOURCE_TYPE_STRING = 2;
/**
* An integer array extra for {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to indicate which
* resource IDs (see {@link DevicePolicyResources.UpdatableDrawableId} and
* {@link DevicePolicyResources.UpdatableStringId}) have been updated.
* resource IDs (see {@link DevicePolicyResources.Drawables} and
* {@link DevicePolicyResources.Strings}) have been updated.
*/
public static final String EXTRA_RESOURCE_ID =
"android.app.extra.RESOURCE_ID";
public static final String EXTRA_RESOURCE_IDS =
"android.app.extra.RESOURCE_IDS";
/** @hide */
@NonNull

View File

@@ -26,6 +26,7 @@ import static android.app.ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN;
import static android.app.ActivityOptions.ANIM_THUMBNAIL_SCALE_UP;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_TYPE;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_TYPE_DRAWABLE;
import static android.app.admin.DevicePolicyResources.Drawables.Source.PROFILE_SWITCH_ANIMATION;
import static android.app.admin.DevicePolicyResources.Drawables.Style.OUTLINE;
@@ -156,9 +157,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
private BroadcastReceiver mEnterpriseResourceUpdatedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
boolean isDrawable = intent.getBooleanExtra(
EXTRA_RESOURCE_TYPE_DRAWABLE, /* default= */ false);
if (!isDrawable) {
if (intent.getIntExtra(EXTRA_RESOURCE_TYPE, /* default= */ -1)
!= EXTRA_RESOURCE_TYPE_DRAWABLE) {
return;
}
updateEnterpriseThumbnailDrawable();

View File

@@ -45,7 +45,8 @@ import static android.app.admin.DevicePolicyManager.DELEGATION_SECURITY_LOGGING;
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT;
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
import static android.app.admin.DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_PER_USER;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_ID;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_IDS;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_TYPE;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_TYPE_DRAWABLE;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_TYPE_STRING;
import static android.app.admin.DevicePolicyManager.ID_TYPE_BASE_INFO;
@@ -18692,10 +18693,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
sendResourceUpdatedBroadcast(EXTRA_RESOURCE_TYPE_STRING, stringIds);
}
private void sendResourceUpdatedBroadcast(String resourceType, String[] resourceIds) {
private void sendResourceUpdatedBroadcast(int resourceType, String[] resourceIds) {
final Intent intent = new Intent(ACTION_DEVICE_POLICY_RESOURCE_UPDATED);
intent.putExtra(EXTRA_RESOURCE_ID, resourceIds);
intent.putExtra(resourceType, /* value= */ true);
intent.putExtra(EXTRA_RESOURCE_IDS, resourceIds);
intent.putExtra(EXTRA_RESOURCE_TYPE, resourceType);
intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);