Loading core/java/android/app/admin/DevicePolicyManager.java +11 −2 Original line number Diff line number Diff line Loading @@ -4160,6 +4160,10 @@ public class DevicePolicyManager { * The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} to be able to call this method; * if not, a security exception will be thrown. * <p> * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to set the configuration for * the parent profile. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param target Component name of the agent to be enabled. Loading @@ -4180,7 +4184,7 @@ public class DevicePolicyManager { @NonNull ComponentName target, PersistableBundle configuration) { if (mService != null) { try { mService.setTrustAgentConfiguration(admin, target, configuration); mService.setTrustAgentConfiguration(admin, target, configuration, mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -4191,6 +4195,10 @@ public class DevicePolicyManager { * Gets configuration for the given trust agent based on aggregating all calls to * {@link #setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)} for * all device admins. * <p> * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to retrieve the configuration set * on the parent profile. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. If null, * this function returns a list of configurations for all admins that declare Loading @@ -4211,7 +4219,8 @@ public class DevicePolicyManager { @NonNull ComponentName agent, int userHandle) { if (mService != null) { try { return mService.getTrustAgentConfiguration(admin, agent, userHandle); return mService.getTrustAgentConfiguration(admin, agent, userHandle, mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/android/app/admin/IDevicePolicyManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -228,9 +228,9 @@ interface IDevicePolicyManager { boolean getBluetoothContactSharingDisabledForUser(int userId); void setTrustAgentConfiguration(in ComponentName admin, in ComponentName agent, in PersistableBundle args); in PersistableBundle args, boolean parent); List<PersistableBundle> getTrustAgentConfiguration(in ComponentName admin, in ComponentName agent, int userId); in ComponentName agent, int userId, boolean parent); boolean addCrossProfileWidgetProvider(in ComponentName admin, String packageName); boolean removeCrossProfileWidgetProvider(in ComponentName admin, String packageName); Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +27 −32 Original line number Diff line number Diff line Loading @@ -1131,9 +1131,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } String tagDAM = parser.getName(); if (TAG_TRUST_AGENT_COMPONENT_OPTIONS.equals(tagDAM)) { PersistableBundle bundle = new PersistableBundle(); bundle.restoreFromXml(parser); result.options = bundle; result.options = PersistableBundle.restoreFromXml(parser); } else { Slog.w(LOG_TAG, "Unknown tag under " + tag + ": " + tagDAM); } Loading Loading @@ -6408,17 +6406,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public void setTrustAgentConfiguration(ComponentName admin, ComponentName agent, PersistableBundle args) { PersistableBundle args, boolean parent) { if (!mHasFeature) { return; } Preconditions.checkNotNull(admin, "admin is null"); Preconditions.checkNotNull(agent, "agent is null"); final int userHandle = UserHandle.getCallingUserId(); enforceNotManagedProfile(userHandle, "set trust agent configuration"); synchronized (this) { ActiveAdmin ap = getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES); DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES, parent); ap.trustAgentInfos.put(agent.flattenToString(), new TrustAgentInfo(args)); saveSettingsLocked(userHandle); } Loading @@ -6426,7 +6423,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public List<PersistableBundle> getTrustAgentConfiguration(ComponentName admin, ComponentName agent, int userHandle) { ComponentName agent, int userHandle, boolean parent) { if (!mHasFeature) { return null; } Loading @@ -6436,35 +6433,34 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (this) { final String componentName = agent.flattenToString(); if (admin != null) { final ActiveAdmin ap = getActiveAdminUncheckedLocked(admin, userHandle); final ActiveAdmin ap = getActiveAdminUncheckedLocked(admin, userHandle, parent); if (ap == null) return null; TrustAgentInfo trustAgentInfo = ap.trustAgentInfos.get(componentName); if (trustAgentInfo == null || trustAgentInfo.options == null) return null; List<PersistableBundle> result = new ArrayList<PersistableBundle>(); List<PersistableBundle> result = new ArrayList<>(); result.add(trustAgentInfo.options); return result; } // Return strictest policy for this user and profiles that are visible from this user. final List<UserInfo> profiles = mUserManager.getProfiles(userHandle); List<PersistableBundle> result = null; // Search through all admins that use KEYGUARD_DISABLE_TRUST_AGENTS and keep track // of the options. If any admin doesn't have options, discard options for the rest // and return null. List<ActiveAdmin> admins = getActiveAdminsForLockscreenPoliciesLocked(userHandle, parent); boolean allAdminsHaveOptions = true; for (UserInfo userInfo : profiles) { DevicePolicyData policy = getUserDataUnchecked(userInfo.id); final int N = policy.mAdminList.size(); final int N = admins.size(); for (int i = 0; i < N; i++) { final ActiveAdmin active = policy.mAdminList.get(i); final ActiveAdmin active = admins.get(i); final boolean disablesTrust = (active.disabledKeyguardFeatures & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0; final TrustAgentInfo info = active.trustAgentInfos.get(componentName); if (info != null && info.options != null && !info.options.isEmpty()) { if (disablesTrust) { if (result == null) { result = new ArrayList<PersistableBundle>(); result = new ArrayList<>(); } result.add(info.options); } else { Loading @@ -6477,7 +6473,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { break; } } } return allAdminsHaveOptions ? result : null; } } Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +11 −2 Original line number Diff line number Diff line Loading @@ -4160,6 +4160,10 @@ public class DevicePolicyManager { * The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} to be able to call this method; * if not, a security exception will be thrown. * <p> * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to set the configuration for * the parent profile. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param target Component name of the agent to be enabled. Loading @@ -4180,7 +4184,7 @@ public class DevicePolicyManager { @NonNull ComponentName target, PersistableBundle configuration) { if (mService != null) { try { mService.setTrustAgentConfiguration(admin, target, configuration); mService.setTrustAgentConfiguration(admin, target, configuration, mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -4191,6 +4195,10 @@ public class DevicePolicyManager { * Gets configuration for the given trust agent based on aggregating all calls to * {@link #setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)} for * all device admins. * <p> * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to retrieve the configuration set * on the parent profile. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. If null, * this function returns a list of configurations for all admins that declare Loading @@ -4211,7 +4219,8 @@ public class DevicePolicyManager { @NonNull ComponentName agent, int userHandle) { if (mService != null) { try { return mService.getTrustAgentConfiguration(admin, agent, userHandle); return mService.getTrustAgentConfiguration(admin, agent, userHandle, mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -228,9 +228,9 @@ interface IDevicePolicyManager { boolean getBluetoothContactSharingDisabledForUser(int userId); void setTrustAgentConfiguration(in ComponentName admin, in ComponentName agent, in PersistableBundle args); in PersistableBundle args, boolean parent); List<PersistableBundle> getTrustAgentConfiguration(in ComponentName admin, in ComponentName agent, int userId); in ComponentName agent, int userId, boolean parent); boolean addCrossProfileWidgetProvider(in ComponentName admin, String packageName); boolean removeCrossProfileWidgetProvider(in ComponentName admin, String packageName); Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +27 −32 Original line number Diff line number Diff line Loading @@ -1131,9 +1131,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } String tagDAM = parser.getName(); if (TAG_TRUST_AGENT_COMPONENT_OPTIONS.equals(tagDAM)) { PersistableBundle bundle = new PersistableBundle(); bundle.restoreFromXml(parser); result.options = bundle; result.options = PersistableBundle.restoreFromXml(parser); } else { Slog.w(LOG_TAG, "Unknown tag under " + tag + ": " + tagDAM); } Loading Loading @@ -6408,17 +6406,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public void setTrustAgentConfiguration(ComponentName admin, ComponentName agent, PersistableBundle args) { PersistableBundle args, boolean parent) { if (!mHasFeature) { return; } Preconditions.checkNotNull(admin, "admin is null"); Preconditions.checkNotNull(agent, "agent is null"); final int userHandle = UserHandle.getCallingUserId(); enforceNotManagedProfile(userHandle, "set trust agent configuration"); synchronized (this) { ActiveAdmin ap = getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES); DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES, parent); ap.trustAgentInfos.put(agent.flattenToString(), new TrustAgentInfo(args)); saveSettingsLocked(userHandle); } Loading @@ -6426,7 +6423,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public List<PersistableBundle> getTrustAgentConfiguration(ComponentName admin, ComponentName agent, int userHandle) { ComponentName agent, int userHandle, boolean parent) { if (!mHasFeature) { return null; } Loading @@ -6436,35 +6433,34 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (this) { final String componentName = agent.flattenToString(); if (admin != null) { final ActiveAdmin ap = getActiveAdminUncheckedLocked(admin, userHandle); final ActiveAdmin ap = getActiveAdminUncheckedLocked(admin, userHandle, parent); if (ap == null) return null; TrustAgentInfo trustAgentInfo = ap.trustAgentInfos.get(componentName); if (trustAgentInfo == null || trustAgentInfo.options == null) return null; List<PersistableBundle> result = new ArrayList<PersistableBundle>(); List<PersistableBundle> result = new ArrayList<>(); result.add(trustAgentInfo.options); return result; } // Return strictest policy for this user and profiles that are visible from this user. final List<UserInfo> profiles = mUserManager.getProfiles(userHandle); List<PersistableBundle> result = null; // Search through all admins that use KEYGUARD_DISABLE_TRUST_AGENTS and keep track // of the options. If any admin doesn't have options, discard options for the rest // and return null. List<ActiveAdmin> admins = getActiveAdminsForLockscreenPoliciesLocked(userHandle, parent); boolean allAdminsHaveOptions = true; for (UserInfo userInfo : profiles) { DevicePolicyData policy = getUserDataUnchecked(userInfo.id); final int N = policy.mAdminList.size(); final int N = admins.size(); for (int i = 0; i < N; i++) { final ActiveAdmin active = policy.mAdminList.get(i); final ActiveAdmin active = admins.get(i); final boolean disablesTrust = (active.disabledKeyguardFeatures & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0; final TrustAgentInfo info = active.trustAgentInfos.get(componentName); if (info != null && info.options != null && !info.options.isEmpty()) { if (disablesTrust) { if (result == null) { result = new ArrayList<PersistableBundle>(); result = new ArrayList<>(); } result.add(info.options); } else { Loading @@ -6477,7 +6473,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { break; } } } return allAdminsHaveOptions ? result : null; } } Loading