From 635ea803320be8692b495c7bee6e7872c551fc1b Mon Sep 17 00:00:00 2001 From: Vladislav Kuzkokov Date: Fri, 19 Jan 2018 17:35:31 +0100 Subject: [PATCH] Unhide printing policy API. Bug: 64140119 Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPrintingPolicy Change-Id: Ic3fc78bda168217788111860ce40ad7ba2256d7d --- api/current.txt | 2 ++ api/system-current.txt | 1 + .../java/android/app/admin/DevicePolicyManager.java | 13 +++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index c065fe98bce40..4826ed5efc6a7 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6470,6 +6470,7 @@ package android.app.admin { method public boolean isMasterVolumeMuted(android.content.ComponentName); method public boolean isNetworkLoggingEnabled(android.content.ComponentName); method public boolean isPackageSuspended(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException; + method public boolean isPrintingEnabled(); method public boolean isProfileOwnerApp(java.lang.String); method public boolean isProvisioningAllowed(java.lang.String); method public boolean isResetPasswordTokenActive(android.content.ComponentName); @@ -6539,6 +6540,7 @@ package android.app.admin { method public boolean setPermittedAccessibilityServices(android.content.ComponentName, java.util.List); method public boolean setPermittedCrossProfileNotificationListeners(android.content.ComponentName, java.util.List); method public boolean setPermittedInputMethods(android.content.ComponentName, java.util.List); + method public void setPrintingEnabled(android.content.ComponentName, boolean); method public void setProfileEnabled(android.content.ComponentName); method public void setProfileName(android.content.ComponentName, java.lang.String); method public void setRecommendedGlobalProxy(android.content.ComponentName, android.net.ProxyInfo); diff --git a/api/system-current.txt b/api/system-current.txt index f35984aaf8d1d..9886269f41070 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -380,6 +380,7 @@ package android.app.admin { method public java.lang.CharSequence getDeviceOwnerOrganizationName(); method public java.util.List getPermittedAccessibilityServices(int); method public java.util.List getPermittedInputMethodsForCurrentUser(); + method public java.lang.CharSequence getPrintingDisabledReason(); method public android.content.ComponentName getProfileOwner() throws java.lang.IllegalArgumentException; method public java.lang.String getProfileOwnerNameAsUser(int) throws java.lang.IllegalArgumentException; method public int getUserProvisioningState(); diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 0be55642d4cf1..2e2b4f1f96c68 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -9201,10 +9201,13 @@ public class DevicePolicyManager { /** * Allows/disallows printing. * + * Called by a device owner or a profile owner. + * Device owner changes policy for all users. Profile owner can override it if present. + * Printing is enabled by default. If {@code FEATURE_PRINTING} is absent, the call is ignored. + * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @param enabled whether printing should be allowed or not. * @throws SecurityException if {@code admin} is neither device, nor profile owner. - * @hide */ public void setPrintingEnabled(@NonNull ComponentName admin, boolean enabled) { try { @@ -9215,10 +9218,12 @@ public class DevicePolicyManager { } /** - * Returns whether printing is enabled for current user. + * Returns whether printing is enabled for this user. + * + * Always {@code false} if {@code FEATURE_PRINTING} is absent. + * Otherwise, {@code true} by default. * * @return {@code true} iff printing is enabled. - * @hide */ public boolean isPrintingEnabled() { try { @@ -9233,9 +9238,9 @@ public class DevicePolicyManager { * * Used only by PrintService. * @return Localized error message. - * @throws SecurityException if caller is not system. * @hide */ + @SystemApi public CharSequence getPrintingDisabledReason() { try { return mService.getPrintingDisabledReason();