Fix Printing policy in profile owner.

Sometimes app inside profile can't get package info for its owner.
Instead of relying on calling user id, we make PrintManagerService switch to
system id and pass user that called print() explicitly.

Bug: 72309652
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPrintingPolicy
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPrintingPolicy
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedProfileOwnerTest#testPrintingPolicy
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: Ib97018f56693549fbca506dba6efaadb6dd010b3
This commit is contained in:
Vladislav Kuzkokov
2018-01-22 23:37:14 +01:00
parent ae992b6392
commit fef75eee1d
7 changed files with 63 additions and 76 deletions

View File

@@ -9284,22 +9284,6 @@ public class DevicePolicyManager {
}
}
/**
* Returns error message to be displayed when printing is disabled.
*
* Used only by PrintService.
* @return Localized error message.
* @hide
*/
@SystemApi
public CharSequence getPrintingDisabledReason() {
try {
return mService.getPrintingDisabledReason();
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
}
/**
* Called by device owner to add an override APN.
*

View File

@@ -132,4 +132,13 @@ public abstract class DevicePolicyManagerInternal {
* @param userId The user in question
*/
public abstract boolean canUserHaveUntrustedCredentialReset(@UserIdInt int userId);
/**
* Return text of error message if printing is disabled.
* Called by Print Service when printing is disabled by PO or DO when printing is attempted.
*
* @param userId The user in question
* @return localized error message
*/
public abstract CharSequence getPrintingDisabledReasonForUser(@UserIdInt int userId);
}

View File

@@ -400,7 +400,6 @@ interface IDevicePolicyManager {
void setPrintingEnabled(in ComponentName admin, boolean enabled);
boolean isPrintingEnabled();
CharSequence getPrintingDisabledReason();
List<String> setMeteredDataDisabled(in ComponentName admin, in List<String> packageNames);
List<String> getMeteredDataDisabled(in ComponentName admin);