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

Commit 05896da8 authored by yuemingw's avatar yuemingw Committed by Yueming Wang
Browse files

Update startViewCalendarEventInManagedProfile API according to API review

1. Replaced ACTION_VIEW_WORK_CALENDAR_EVENT with
ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT
2. Improved the javadoc for EXTRA_EVENT_ID
3. Improved the javadoc for startMs and endMs

Bug: 122899642
Bug: 122898273
Bug: 122900059
Test: atest ManagedProfileTest#testCrossProfileCalendar
Change-Id: Ida84cd0d7d941e18acb9140c8fffc27b1ebd0a6c
parent 4607116f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -36522,7 +36522,7 @@ package android.provider {
    field public static final String ACCOUNT_TYPE_LOCAL = "LOCAL";
    field public static final String ACTION_EVENT_REMINDER = "android.intent.action.EVENT_REMINDER";
    field public static final String ACTION_HANDLE_CUSTOM_EVENT = "android.provider.calendar.action.HANDLE_CUSTOM_EVENT";
    field public static final String ACTION_VIEW_WORK_CALENDAR_EVENT = "android.provider.calendar.action.VIEW_WORK_CALENDAR_EVENT";
    field public static final String ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT = "android.provider.calendar.action.VIEW_MANAGED_PROFILE_CALENDAR_EVENT";
    field public static final String AUTHORITY = "com.android.calendar";
    field public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
    field public static final android.net.Uri CONTENT_URI;
+11 −11
Original line number Diff line number Diff line
@@ -138,8 +138,8 @@ public final class CalendarContract {
     * Action used to help apps show calendar events in the managed profile.
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_VIEW_WORK_CALENDAR_EVENT =
            "android.provider.calendar.action.VIEW_WORK_CALENDAR_EVENT";
    public static final String ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT =
            "android.provider.calendar.action.VIEW_MANAGED_PROFILE_CALENDAR_EVENT";

    /**
     * Intent Extras key: {@link EventsColumns#CUSTOM_APP_URI} for the event in
@@ -166,7 +166,7 @@ public final class CalendarContract {
    public static final String EXTRA_EVENT_ALL_DAY = "allDay";

    /**
     * Intent Extras key: The id of an event.
     * Intent Extras key: An extra of type {@code long} holding the id of an event.
     */
    public static final String EXTRA_EVENT_ID = "id";

@@ -218,7 +218,7 @@ public final class CalendarContract {
     * When this API is called, the system will attempt to start an activity
     * in the managed profile with an intent targeting the same caller package.
     * The intent will have its action set to
     * {@link CalendarContract#ACTION_VIEW_WORK_CALENDAR_EVENT} and contain extras
     * {@link CalendarContract#ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT} and contain extras
     * corresponding to the API's arguments. A calendar app intending to support
     * cross-profile events viewing should handle this intent, parse the arguments
     * and show the appropriate UI.
@@ -226,10 +226,10 @@ public final class CalendarContract {
     * @param context the context.
     * @param eventId the id of the event to be viewed. Will be put into {@link #EXTRA_EVENT_ID}
     *                field of the intent.
     * @param start the start time of the event. Will be put into {@link #EXTRA_EVENT_BEGIN_TIME}
     *              field of the intent.
     * @param end the end time of the event. Will be put into {@link #EXTRA_EVENT_END_TIME} field
     *            of the intent.
     * @param startMs the start time of the event in milliseconds since epoch.
     *                Will be put into {@link #EXTRA_EVENT_BEGIN_TIME} field of the intent.
     * @param endMs the end time of the event in milliseconds since epoch.
     *              Will be put into {@link #EXTRA_EVENT_END_TIME} field of the intent.
     * @param allDay if the event is an all-day event. Will be put into
     *               {@link #EXTRA_EVENT_ALL_DAY} field of the intent.
     * @param flags flags to be set on the intent via {@link Intent#setFlags}
@@ -241,12 +241,12 @@ public final class CalendarContract {
     * @see #EXTRA_EVENT_ALL_DAY
     */
    public static boolean startViewCalendarEventInManagedProfile(@NonNull Context context,
            long eventId, long start, long end, boolean allDay, int flags) {
            long eventId, long startMs, long endMs, boolean allDay, int flags) {
        Preconditions.checkNotNull(context, "Context is null");
        final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
                Context.DEVICE_POLICY_SERVICE);
        return dpm.startViewCalendarEventInManagedProfile(eventId, start,
                end, allDay, flags);
        return dpm.startViewCalendarEventInManagedProfile(eventId, startMs,
                endMs, allDay, flags);
    }

    /**
+5 −10
Original line number Diff line number Diff line
@@ -74,20 +74,14 @@ import static android.app.admin.DevicePolicyManager.WIPE_SILENTLY;
import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES;
import static android.provider.Settings.Global.PRIVATE_DNS_MODE;
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
import static android.provider.Telephony.Carriers.DPC_URI;
import static android.provider.Telephony.Carriers.ENFORCE_KEY;
import static android.provider.Telephony.Carriers.ENFORCE_MANAGED_URI;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent
        .PROVISIONING_ENTRY_POINT_ADB;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker
        .STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.PROVISIONING_ENTRY_POINT_ADB;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static com.android.server.devicepolicy.TransferOwnershipMetadataManager.ADMIN_TYPE_DEVICE_OWNER;
import static com.android.server.devicepolicy.TransferOwnershipMetadataManager.ADMIN_TYPE_PROFILE_OWNER;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
@@ -240,11 +234,11 @@ import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.FunctionalUtils.ThrowingRunnable;
import com.android.internal.util.JournaledFile;
import com.android.internal.util.Preconditions;
import com.android.internal.util.StatLogger;
import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.server.LocalServices;
import com.android.server.LockGuard;
import com.android.internal.util.StatLogger;
import com.android.server.SystemServerInitThreadPool;
import com.android.server.SystemService;
import com.android.server.devicepolicy.DevicePolicyManagerService.ActiveAdmin.TrustAgentInfo;
@@ -14207,7 +14201,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                        + "calendar APIs", packageName));
                return false;
            }
            final Intent intent = new Intent(CalendarContract.ACTION_VIEW_WORK_CALENDAR_EVENT);
            final Intent intent = new Intent(
                    CalendarContract.ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT);
            intent.setPackage(packageName);
            intent.putExtra(CalendarContract.EXTRA_EVENT_ID, eventId);
            intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, start);