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

Commit e1a96063 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "calendar-package"

* changes:
  Handle null for the return of getCrossProfileCalendarPackages.
  API change for cross profile calendar feature.
parents 07182c86 f5ea386d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -6579,7 +6579,6 @@ package android.app.admin {
  }
  public class DevicePolicyManager {
    method public void addCrossProfileCalendarPackage(@NonNull android.content.ComponentName, @NonNull String);
    method public void addCrossProfileIntentFilter(@NonNull android.content.ComponentName, android.content.IntentFilter, int);
    method public boolean addCrossProfileWidgetProvider(@NonNull android.content.ComponentName, String);
    method public int addOverrideApn(@NonNull android.content.ComponentName, @NonNull android.telephony.data.ApnSetting);
@@ -6609,7 +6608,7 @@ package android.app.admin {
    method public boolean getBluetoothContactSharingDisabled(@NonNull android.content.ComponentName);
    method public boolean getCameraDisabled(@Nullable android.content.ComponentName);
    method @Deprecated @Nullable public String getCertInstallerPackage(@NonNull android.content.ComponentName) throws java.lang.SecurityException;
    method @NonNull public java.util.Set<java.lang.String> getCrossProfileCalendarPackages(@NonNull android.content.ComponentName);
    method @Nullable public java.util.Set<java.lang.String> getCrossProfileCalendarPackages(@NonNull android.content.ComponentName);
    method public boolean getCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName);
    method public boolean getCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName);
    method @NonNull public java.util.List<java.lang.String> getCrossProfileWidgetProviders(@NonNull android.content.ComponentName);
@@ -6699,7 +6698,6 @@ package android.app.admin {
    method public int logoutUser(@NonNull android.content.ComponentName);
    method public void reboot(@NonNull android.content.ComponentName);
    method public void removeActiveAdmin(@NonNull android.content.ComponentName);
    method public boolean removeCrossProfileCalendarPackage(@NonNull android.content.ComponentName, @NonNull String);
    method public boolean removeCrossProfileWidgetProvider(@NonNull android.content.ComponentName, String);
    method public boolean removeKeyPair(@Nullable android.content.ComponentName, @NonNull String);
    method public boolean removeOverrideApn(@NonNull android.content.ComponentName, int);
@@ -6721,6 +6719,7 @@ package android.app.admin {
    method public void setBluetoothContactSharingDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setCameraDisabled(@NonNull android.content.ComponentName, boolean);
    method @Deprecated public void setCertInstallerPackage(@NonNull android.content.ComponentName, @Nullable String) throws java.lang.SecurityException;
    method public void setCrossProfileCalendarPackages(@NonNull android.content.ComponentName, @Nullable java.util.Set<java.lang.String>);
    method public void setCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setDelegatedScopes(@NonNull android.content.ComponentName, @NonNull String, @NonNull java.util.List<java.lang.String>);
+28 −52
Original line number Diff line number Diff line
@@ -10428,76 +10428,53 @@ public class DevicePolicyManager {
    }

    /**
     * Whitelists a package that is allowed to access cross profile calendar APIs.
     * Whitelists a set of packages that are allowed to access cross-profile calendar APIs.
     *
     * <p>Called by a profile owner of a managed profile.
     *
     * @param admin which {@link DeviceAdminReceiver} this request is associated with.
     * @param packageName name of the package to be whitelisted.
     * @throws SecurityException if {@code admin} is not a profile owner.
     *
     * @see #removeCrossProfileCalendarPackage(ComponentName, String)
     * @see #getCrossProfileCalendarPackages(ComponentName)
     */
    public void addCrossProfileCalendarPackage(@NonNull ComponentName admin,
            @NonNull String packageName) {
        throwIfParentInstance("addCrossProfileCalendarPackage");
        if (mService != null) {
            try {
                mService.addCrossProfileCalendarPackage(admin, packageName);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Removes a package that was allowed to access cross profile calendar APIs
     * from the whitelist.
     *
     * <p>Called by a profile owner of a managed profile.
     * <p>Calling with a null value for the set disables the restriction so that all packages
     * are allowed to access cross-profile calendar APIs. Calling with an empty set disallows
     * all packages from accessing cross-profile calendar APIs. If this method isn't called,
     * no package will be allowed to access cross-profile calendar APIs by default.
     *
     * @param admin which {@link DeviceAdminReceiver} this request is associated with.
     * @param packageName name of the package to be removed from the whitelist.
     * @return {@code true} if the package is successfully removed from the whitelist,
     * {@code false} otherwise.
     * @param packageNames set of packages to be whitelisted.
     * @throws SecurityException if {@code admin} is not a profile owner.
     *
     * @see #addCrossProfileCalendarPackage(ComponentName, String)
     * @see #getCrossProfileCalendarPackages(ComponentName)
     */
    public boolean removeCrossProfileCalendarPackage(@NonNull ComponentName admin,
            @NonNull String packageName) {
        throwIfParentInstance("removeCrossProfileCalendarPackage");
    public void setCrossProfileCalendarPackages(@NonNull ComponentName admin,
            @Nullable Set<String> packageNames) {
        throwIfParentInstance("setCrossProfileCalendarPackages");
        if (mService != null) {
            try {
                return mService.removeCrossProfileCalendarPackage(admin, packageName);
                mService.setCrossProfileCalendarPackages(admin, packageNames == null ? null
                        : new ArrayList<>(packageNames));
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return false;
    }

    /**
     * Gets a set of package names that are whitelisted to access cross profile calendar APIs.
     * Gets a set of package names that are whitelisted to access cross-profile calendar APIs.
     *
     * <p>Called by a profile owner of a managed profile.
     *
     * @param admin which {@link DeviceAdminReceiver} this request is associated with.
     * @return the set of names of packages that were previously whitelisted via
     * {@link #addCrossProfileCalendarPackage(ComponentName, String)}, or an
     * {@link #setCrossProfileCalendarPackages(ComponentName, Set)}, or an
     * empty set if none have been whitelisted.
     * @throws SecurityException if {@code admin} is not a profile owner.
     *
     * @see #addCrossProfileCalendarPackage(ComponentName, String)
     * @see #removeCrossProfileCalendarPackage(ComponentName, String)
     * @see #setCrossProfileCalendarPackages(ComponentName, Set)
     */
    public @NonNull Set<String> getCrossProfileCalendarPackages(@NonNull ComponentName admin) {
    public @Nullable Set<String> getCrossProfileCalendarPackages(@NonNull ComponentName admin) {
        throwIfParentInstance("getCrossProfileCalendarPackages");
        if (mService != null) {
            try {
                return new ArraySet<>(mService.getCrossProfileCalendarPackages(admin));
                final List<String> packageNames = mService.getCrossProfileCalendarPackages(admin);
                return packageNames == null ? null : new ArraySet<>(packageNames);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
@@ -10506,22 +10483,21 @@ public class DevicePolicyManager {
    }

    /**
     * Returns if a package is whitelisted to access cross profile calendar APIs.
     * Returns if a package is whitelisted to access cross-profile calendar APIs.
     *
     * <p>To query for a specific user, use
     * {@link Context#createPackageContextAsUser(String, int, UserHandle)} to create a context for
     * that user, and get a {@link DevicePolicyManager} from this context.
     *
     * @param packageName the name of the package
     * @return {@code true} if the package is whitelisted to access cross profile calendar APIs.
     * @return {@code true} if the package is whitelisted to access cross-profile calendar APIs.
     * {@code false} otherwise.
     *
     * @see #addCrossProfileCalendarPackage(ComponentName, String)
     * @see #removeCrossProfileCalendarPackage(ComponentName, String)
     * @see #setCrossProfileCalendarPackages(ComponentName, Set)
     * @see #getCrossProfileCalendarPackages(ComponentName)
     * @hide
     */
    public @NonNull boolean isPackageAllowedToAccessCalendar(@NonNull  String packageName) {
    public boolean isPackageAllowedToAccessCalendar(@NonNull  String packageName) {
        throwIfParentInstance("isPackageAllowedToAccessCalendar");
        if (mService != null) {
            try {
@@ -10535,27 +10511,27 @@ public class DevicePolicyManager {
    }

    /**
     * Gets a set of package names that are whitelisted to access cross profile calendar APIs.
     * Gets a set of package names that are whitelisted to access cross-profile calendar APIs.
     *
     * <p>To query for a specific user, use
     * {@link Context#createPackageContextAsUser(String, int, UserHandle)} to create a context for
     * that user, and get a {@link DevicePolicyManager} from this context.
     *
     * @return the set of names of packages that were previously whitelisted via
     * {@link #addCrossProfileCalendarPackage(ComponentName, String)}, or an
     * {@link #setCrossProfileCalendarPackages(ComponentName, Set)}, or an
     * empty set if none have been whitelisted.
     *
     * @see #addCrossProfileCalendarPackage(ComponentName, String)
     * @see #removeCrossProfileCalendarPackage(ComponentName, String)
     * @see #setCrossProfileCalendarPackages(ComponentName, Set)
     * @see #getCrossProfileCalendarPackages(ComponentName)
     * @hide
     */
    public @NonNull Set<String>  getCrossProfileCalendarPackages() {
    public @Nullable Set<String> getCrossProfileCalendarPackages() {
        throwIfParentInstance("getCrossProfileCalendarPackages");
        if (mService != null) {
            try {
                return new ArraySet<>(mService.getCrossProfileCalendarPackagesForUser(
                        myUserId()));
                final List<String> packageNames = mService.getCrossProfileCalendarPackagesForUser(
                        myUserId());
                return packageNames == null ? null : new ArraySet<>(packageNames);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
+1 −2
Original line number Diff line number Diff line
@@ -424,8 +424,7 @@ interface IDevicePolicyManager {

    void installUpdateFromFile(in ComponentName admin, in ParcelFileDescriptor updateFileDescriptor, in StartInstallingUpdateCallback listener);

    void addCrossProfileCalendarPackage(in ComponentName admin, String packageName);
    boolean removeCrossProfileCalendarPackage(in ComponentName admin, String packageName);
    void setCrossProfileCalendarPackages(in ComponentName admin, in List<String> packageNames);
    List<String> getCrossProfileCalendarPackages(in ComponentName admin);
    boolean isPackageAllowedToAccessCalendarForUser(String packageName, int userHandle);
    List<String> getCrossProfileCalendarPackagesForUser(int userHandle);
+11 −7
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import android.util.Log;

import com.android.internal.util.Preconditions;

import java.util.Set;

/**
 * <p>
 * The contract between the calendar provider and applications. Contains
@@ -217,7 +219,7 @@ public final class CalendarContract {
     * The intent will have its action set to
     * {@link CalendarContract#ACTION_VIEW_WORK_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
     * cross-profile events viewing should handle this intent, parse the arguments
     * and show the appropriate UI.
     *
     * @param context the context.
@@ -767,9 +769,10 @@ public final class CalendarContract {
         * projection of the query to this uri that are not contained in the above list.
         *
         * <p>This uri will return an empty cursor if the calling user is not a parent profile
         * of a managed profile, or cross profile calendar is disabled in Settings, or this uri is
         * of a managed profile, or cross-profile calendar is disabled in Settings, or this uri is
         * queried from a package that is not whitelisted by profile owner of the managed profile
         * via {@link DevicePolicyManager#addCrossProfileCalendarPackage(ComponentName, String)}.
         * via
         * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
         *
         * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
         * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
@@ -1758,9 +1761,10 @@ public final class CalendarContract {
         * projection of the query to this uri that are not contained in the above list.
         *
         * <p>This uri will return an empty cursor if the calling user is not a parent profile
         * of a managed profile, or cross profile calendar is disabled in Settings, or this uri is
         * of a managed profile, or cross-profile calendar is disabled in Settings, or this uri is
         * queried from a package that is not whitelisted by profile owner of the managed profile
         * via {@link DevicePolicyManager#addCrossProfileCalendarPackage(ComponentName, String)}.
         * via
         * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
         *
         * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
         * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
@@ -1968,10 +1972,10 @@ public final class CalendarContract {
         * projection of the query to this uri that are not contained in the above list.
         *
         * <p>This uri will return an empty cursor if the calling user is not a parent profile
         * of a managed profile, or cross profile calendar for the managed profile is disabled in
         * of a managed profile, or cross-profile calendar for the managed profile is disabled in
         * Settings, or this uri is queried from a package that is not whitelisted by
         * profile owner of the managed profile via
         * {@link DevicePolicyManager#addCrossProfileCalendarPackage(ComponentName, String)}.
         * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
         *
         * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
         * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
+1 −2
Original line number Diff line number Diff line
@@ -92,8 +92,7 @@ enum EventId {
  SET_UNINSTALL_BLOCKED = 67;
  SET_PACKAGES_SUSPENDED = 68;
  ON_LOCK_TASK_MODE_ENTERING = 69;
  ADD_CROSS_PROFILE_CALENDAR_PACKAGE = 70;
  REMOVE_CROSS_PROFILE_CALENDAR_PACKAGE = 71;
  SET_CROSS_PROFILE_CALENDAR_PACKAGES = 70;
  GET_USER_PASSWORD_COMPLEXITY_LEVEL = 72;
  INSTALL_SYSTEM_UPDATE = 73;
  INSTALL_SYSTEM_UPDATE_ERROR = 74;
Loading