Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6739,6 +6739,7 @@ package android.app.admin { 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.Set<java.lang.String> getCrossProfilePackages(@NonNull android.content.ComponentName); method @NonNull public java.util.List<java.lang.String> getCrossProfileWidgetProviders(@NonNull android.content.ComponentName); method public int getCurrentFailedPasswordAttempts(); method @Nullable public java.util.List<java.lang.String> getDelegatePackages(@NonNull android.content.ComponentName, @NonNull String); Loading Loading @@ -6856,6 +6857,7 @@ package android.app.admin { 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 setCrossProfilePackages(@NonNull android.content.ComponentName, @NonNull java.util.Set<java.lang.String>); method public void setDefaultSmsApplication(@NonNull android.content.ComponentName, @NonNull String); method public void setDelegatedScopes(@NonNull android.content.ComponentName, @NonNull String, @NonNull java.util.List<java.lang.String>); method public void setDeviceOwnerLockScreenInfo(@NonNull android.content.ComponentName, CharSequence); core/java/android/app/admin/DevicePolicyManager.java +47 −0 Original line number Diff line number Diff line Loading @@ -11084,6 +11084,53 @@ public class DevicePolicyManager { return Collections.emptySet(); } /** * Sets the set of package names that are allowed to request user consent for cross-profile * communication. * * <p>Assumes that the caller is a profile owner and is the given {@code admin}. * * <p>Previous calls are overridden by each subsequent call to this method. * * @param admin the {@link DeviceAdminReceiver} this request is associated with * @param packageNames the new cross-profile package names */ public void setCrossProfilePackages( @NonNull ComponentName admin, @NonNull Set<String> packageNames) { throwIfParentInstance("setCrossProfilePackages"); if (mService != null) { try { mService.setCrossProfilePackages(admin, new ArrayList<>(packageNames)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** * Returns the set of package names that the admin has previously set as allowed to request user * consent for cross-profile communication, via {@link * #setCrossProfilePackages(ComponentName, Set)}. * * <p>Assumes that the caller is a profile owner and is the given {@code admin}. * * @param admin the {@link DeviceAdminReceiver} this request is associated with * @return the set of package names the admin has previously set as allowed to request user * consent for cross-profile communication, via {@link * #setCrossProfilePackages(ComponentName, Set)} */ public @NonNull Set<String> getCrossProfilePackages(@NonNull ComponentName admin) { throwIfParentInstance("getCrossProfilePackages"); if (mService != null) { try { return new ArraySet<>(mService.getCrossProfilePackages(admin)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return Collections.emptySet(); } /** * Returns whether the device is being used as a managed kiosk. These requirements are as * follows: Loading core/java/android/app/admin/IDevicePolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -438,6 +438,9 @@ interface IDevicePolicyManager { boolean isPackageAllowedToAccessCalendarForUser(String packageName, int userHandle); List<String> getCrossProfileCalendarPackagesForUser(int userHandle); void setCrossProfilePackages(in ComponentName admin, in List<String> packageNames); List<String> getCrossProfilePackages(in ComponentName admin); boolean isManagedKiosk(); boolean isUnattendedManagedKiosk(); Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +40 −0 Original line number Diff line number Diff line Loading @@ -990,6 +990,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { "cross-profile-calendar-packages"; private static final String TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL = "cross-profile-calendar-packages-null"; private static final String TAG_CROSS_PROFILE_PACKAGES = "cross-profile-packages"; DeviceAdminInfo info; Loading Loading @@ -1104,6 +1105,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // is whitelisted. List<String> mCrossProfileCalendarPackages = Collections.emptyList(); // The whitelist of packages that the admin has enabled to be able to request consent from // the user to communicate cross-profile. By default, no packages are whitelisted, which is // represented as an empty list. List<String> mCrossProfilePackages = Collections.emptyList(); ActiveAdmin(DeviceAdminInfo _info, boolean parent) { info = _info; isParent = parent; Loading Loading @@ -1329,6 +1335,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { writePackageListToXml(out, TAG_CROSS_PROFILE_CALENDAR_PACKAGES, mCrossProfileCalendarPackages); } writePackageListToXml(out, TAG_CROSS_PROFILE_PACKAGES, mCrossProfilePackages); } void writeTextToXml(XmlSerializer out, String tag, String text) throws IOException { Loading Loading @@ -1560,6 +1567,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mCrossProfileCalendarPackages = readPackageList(parser, tag); } else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL.equals(tag)) { mCrossProfileCalendarPackages = null; } else if (TAG_CROSS_PROFILE_PACKAGES.equals(tag)) { mCrossProfilePackages = readPackageList(parser, tag); } else { Slog.w(LOG_TAG, "Unknown admin tag: " + tag); XmlUtils.skipCurrentTag(parser); Loading Loading @@ -1783,6 +1792,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { pw.print("mCrossProfileCalendarPackages="); pw.println(mCrossProfileCalendarPackages); } pw.print("mCrossProfilePackages="); pw.println(mCrossProfilePackages); } } Loading Loading @@ -14644,6 +14655,35 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return Collections.emptyList(); } @Override public void setCrossProfilePackages(ComponentName who, List<String> packageNames) { if (!mHasFeature) { return; } Preconditions.checkNotNull(who, "ComponentName is null"); Preconditions.checkNotNull(packageNames, "Package names is null"); synchronized (getLockObject()) { final ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); admin.mCrossProfilePackages = packageNames; saveSettingsLocked(mInjector.userHandleGetCallingUserId()); } } @Override public List<String> getCrossProfilePackages(ComponentName who) { if (!mHasFeature) { return Collections.emptyList(); } Preconditions.checkNotNull(who, "ComponentName is null"); synchronized (getLockObject()) { final ActiveAdmin admin = getActiveAdminForCallerLocked( who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); return admin.mCrossProfilePackages; } } @Override public boolean isManagedKiosk() { if (!mHasFeature) { services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -5548,6 +5548,38 @@ public class DevicePolicyManagerTest extends DpmTestBase { mServiceContext.binder.restoreCallingIdentity(ident); } public void testGetCrossProfilePackages_notSet_returnsEmpty() { setAsProfileOwner(admin1); assertTrue(dpm.getCrossProfilePackages(admin1).isEmpty()); } public void testGetCrossProfilePackages_notSet_dpmsReinitialized_returnsEmpty() { setAsProfileOwner(admin1); initializeDpms(); assertTrue(dpm.getCrossProfilePackages(admin1).isEmpty()); } public void testGetCrossProfilePackages_whenSet_returnsEqual() { setAsProfileOwner(admin1); Set<String> packages = Collections.singleton("TEST_PACKAGE"); dpm.setCrossProfilePackages(admin1, packages); assertEquals(packages, dpm.getCrossProfilePackages(admin1)); } public void testGetCrossProfilePackages_whenSet_dpmsReinitialized_returnsEqual() { setAsProfileOwner(admin1); Set<String> packages = Collections.singleton("TEST_PACKAGE"); dpm.setCrossProfilePackages(admin1, packages); initializeDpms(); assertEquals(packages, dpm.getCrossProfilePackages(admin1)); } // admin1 is the outgoing DPC, adminAnotherPakcage is the incoming one. private void assertDeviceOwnershipRevertedWithFakeTransferMetadata() throws Exception { writeFakeTransferMetadataFile(UserHandle.USER_SYSTEM, Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6739,6 +6739,7 @@ package android.app.admin { 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.Set<java.lang.String> getCrossProfilePackages(@NonNull android.content.ComponentName); method @NonNull public java.util.List<java.lang.String> getCrossProfileWidgetProviders(@NonNull android.content.ComponentName); method public int getCurrentFailedPasswordAttempts(); method @Nullable public java.util.List<java.lang.String> getDelegatePackages(@NonNull android.content.ComponentName, @NonNull String); Loading Loading @@ -6856,6 +6857,7 @@ package android.app.admin { 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 setCrossProfilePackages(@NonNull android.content.ComponentName, @NonNull java.util.Set<java.lang.String>); method public void setDefaultSmsApplication(@NonNull android.content.ComponentName, @NonNull String); method public void setDelegatedScopes(@NonNull android.content.ComponentName, @NonNull String, @NonNull java.util.List<java.lang.String>); method public void setDeviceOwnerLockScreenInfo(@NonNull android.content.ComponentName, CharSequence);
core/java/android/app/admin/DevicePolicyManager.java +47 −0 Original line number Diff line number Diff line Loading @@ -11084,6 +11084,53 @@ public class DevicePolicyManager { return Collections.emptySet(); } /** * Sets the set of package names that are allowed to request user consent for cross-profile * communication. * * <p>Assumes that the caller is a profile owner and is the given {@code admin}. * * <p>Previous calls are overridden by each subsequent call to this method. * * @param admin the {@link DeviceAdminReceiver} this request is associated with * @param packageNames the new cross-profile package names */ public void setCrossProfilePackages( @NonNull ComponentName admin, @NonNull Set<String> packageNames) { throwIfParentInstance("setCrossProfilePackages"); if (mService != null) { try { mService.setCrossProfilePackages(admin, new ArrayList<>(packageNames)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** * Returns the set of package names that the admin has previously set as allowed to request user * consent for cross-profile communication, via {@link * #setCrossProfilePackages(ComponentName, Set)}. * * <p>Assumes that the caller is a profile owner and is the given {@code admin}. * * @param admin the {@link DeviceAdminReceiver} this request is associated with * @return the set of package names the admin has previously set as allowed to request user * consent for cross-profile communication, via {@link * #setCrossProfilePackages(ComponentName, Set)} */ public @NonNull Set<String> getCrossProfilePackages(@NonNull ComponentName admin) { throwIfParentInstance("getCrossProfilePackages"); if (mService != null) { try { return new ArraySet<>(mService.getCrossProfilePackages(admin)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return Collections.emptySet(); } /** * Returns whether the device is being used as a managed kiosk. These requirements are as * follows: Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -438,6 +438,9 @@ interface IDevicePolicyManager { boolean isPackageAllowedToAccessCalendarForUser(String packageName, int userHandle); List<String> getCrossProfileCalendarPackagesForUser(int userHandle); void setCrossProfilePackages(in ComponentName admin, in List<String> packageNames); List<String> getCrossProfilePackages(in ComponentName admin); boolean isManagedKiosk(); boolean isUnattendedManagedKiosk(); Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +40 −0 Original line number Diff line number Diff line Loading @@ -990,6 +990,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { "cross-profile-calendar-packages"; private static final String TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL = "cross-profile-calendar-packages-null"; private static final String TAG_CROSS_PROFILE_PACKAGES = "cross-profile-packages"; DeviceAdminInfo info; Loading Loading @@ -1104,6 +1105,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { // is whitelisted. List<String> mCrossProfileCalendarPackages = Collections.emptyList(); // The whitelist of packages that the admin has enabled to be able to request consent from // the user to communicate cross-profile. By default, no packages are whitelisted, which is // represented as an empty list. List<String> mCrossProfilePackages = Collections.emptyList(); ActiveAdmin(DeviceAdminInfo _info, boolean parent) { info = _info; isParent = parent; Loading Loading @@ -1329,6 +1335,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { writePackageListToXml(out, TAG_CROSS_PROFILE_CALENDAR_PACKAGES, mCrossProfileCalendarPackages); } writePackageListToXml(out, TAG_CROSS_PROFILE_PACKAGES, mCrossProfilePackages); } void writeTextToXml(XmlSerializer out, String tag, String text) throws IOException { Loading Loading @@ -1560,6 +1567,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mCrossProfileCalendarPackages = readPackageList(parser, tag); } else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL.equals(tag)) { mCrossProfileCalendarPackages = null; } else if (TAG_CROSS_PROFILE_PACKAGES.equals(tag)) { mCrossProfilePackages = readPackageList(parser, tag); } else { Slog.w(LOG_TAG, "Unknown admin tag: " + tag); XmlUtils.skipCurrentTag(parser); Loading Loading @@ -1783,6 +1792,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { pw.print("mCrossProfileCalendarPackages="); pw.println(mCrossProfileCalendarPackages); } pw.print("mCrossProfilePackages="); pw.println(mCrossProfilePackages); } } Loading Loading @@ -14644,6 +14655,35 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return Collections.emptyList(); } @Override public void setCrossProfilePackages(ComponentName who, List<String> packageNames) { if (!mHasFeature) { return; } Preconditions.checkNotNull(who, "ComponentName is null"); Preconditions.checkNotNull(packageNames, "Package names is null"); synchronized (getLockObject()) { final ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); admin.mCrossProfilePackages = packageNames; saveSettingsLocked(mInjector.userHandleGetCallingUserId()); } } @Override public List<String> getCrossProfilePackages(ComponentName who) { if (!mHasFeature) { return Collections.emptyList(); } Preconditions.checkNotNull(who, "ComponentName is null"); synchronized (getLockObject()) { final ActiveAdmin admin = getActiveAdminForCallerLocked( who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); return admin.mCrossProfilePackages; } } @Override public boolean isManagedKiosk() { if (!mHasFeature) {
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -5548,6 +5548,38 @@ public class DevicePolicyManagerTest extends DpmTestBase { mServiceContext.binder.restoreCallingIdentity(ident); } public void testGetCrossProfilePackages_notSet_returnsEmpty() { setAsProfileOwner(admin1); assertTrue(dpm.getCrossProfilePackages(admin1).isEmpty()); } public void testGetCrossProfilePackages_notSet_dpmsReinitialized_returnsEmpty() { setAsProfileOwner(admin1); initializeDpms(); assertTrue(dpm.getCrossProfilePackages(admin1).isEmpty()); } public void testGetCrossProfilePackages_whenSet_returnsEqual() { setAsProfileOwner(admin1); Set<String> packages = Collections.singleton("TEST_PACKAGE"); dpm.setCrossProfilePackages(admin1, packages); assertEquals(packages, dpm.getCrossProfilePackages(admin1)); } public void testGetCrossProfilePackages_whenSet_dpmsReinitialized_returnsEqual() { setAsProfileOwner(admin1); Set<String> packages = Collections.singleton("TEST_PACKAGE"); dpm.setCrossProfilePackages(admin1, packages); initializeDpms(); assertEquals(packages, dpm.getCrossProfilePackages(admin1)); } // admin1 is the outgoing DPC, adminAnotherPakcage is the incoming one. private void assertDeviceOwnershipRevertedWithFakeTransferMetadata() throws Exception { writeFakeTransferMetadataFile(UserHandle.USER_SYSTEM, Loading