Loading core/java/android/app/admin/DevicePolicyManagerInternal.java +0 −10 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.app.admin; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.admin.DevicePolicyManager.OperationSafetyReason; import android.content.ComponentName; import android.content.Intent; import android.os.UserHandle; Loading Loading @@ -256,13 +255,4 @@ public abstract class DevicePolicyManagerInternal { * {@link #supportsResetOp(int)} is true. */ public abstract void resetOp(int op, String packageName, @UserIdInt int userId); /** * Notifies the system that an unsafe operation reason has changed. * * @throws IllegalArgumentException if {@code checker} is not the same as set on * {@code DevicePolicyManagerService}. */ public abstract void notifyUnsafeOperationStateChanged(DevicePolicySafetyChecker checker, @OperationSafetyReason int reason, boolean isSafe); } core/java/android/app/admin/DevicePolicyManagerLiteInternal.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.admin; import android.app.admin.DevicePolicyManager.OperationSafetyReason; /** * Device policy manager local system service interface for methods that don't require the * {@code device_admin} feature. * * Maintenance note: if you need to expose information from DPMS to lower level services such as * PM/UM/AM/etc, then exposing it from DevicePolicyManagerInternal is not safe because it may cause * lock order inversion. Consider using {@link DevicePolicyCache} instead. * * @hide Only for use within the system server. */ public interface DevicePolicyManagerLiteInternal { /** * Notifies the system that an unsafe operation reason has changed. * * @throws IllegalArgumentException if {@code checker} is not the same as set on * {@code DevicePolicyManagerService.setDevicePolicySafetyChecker()}. */ void notifyUnsafeOperationStateChanged(DevicePolicySafetyChecker checker, @OperationSafetyReason int reason, boolean isSafe); } services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ import android.app.admin.DevicePolicyManager.OperationSafetyReason; import android.app.admin.DevicePolicyManager.PasswordComplexity; import android.app.admin.DevicePolicyManager.PersonalAppsSuspensionReason; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerLiteInternal; import android.app.admin.DevicePolicySafetyChecker; import android.app.admin.DeviceStateCache; import android.app.admin.FactoryResetProtectionPolicy; Loading Loading @@ -1748,6 +1749,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mTransferOwnershipMetadataManager = mInjector.newTransferOwnershipMetadataManager(); mBugreportCollectionManager = new RemoteBugreportManager(this, mInjector); // "Lite" interface is available even when the device doesn't have the feature LocalServices.addService(DevicePolicyManagerLiteInternal.class, mLocalService); if (!mHasFeature) { // Skip the rest of the initialization mSetupContentObserver = null; Loading Loading @@ -12612,7 +12615,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } @VisibleForTesting final class LocalService extends DevicePolicyManagerInternal { final class LocalService extends DevicePolicyManagerInternal implements DevicePolicyManagerLiteInternal { private List<OnCrossProfileWidgetProvidersChangeListener> mWidgetProviderListeners; @Override services/devicepolicy/java/com/android/server/devicepolicy/OneTimeSafetyChecker.java +3 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import static android.app.admin.DevicePolicyManager.operationToString; import android.app.admin.DevicePolicyManager.DevicePolicyOperation; import android.app.admin.DevicePolicyManager.OperationSafetyReason; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerLiteInternal; import android.app.admin.DevicePolicySafetyChecker; import android.os.Handler; import android.os.Looper; Loading Loading @@ -80,8 +80,8 @@ final class OneTimeSafetyChecker implements DevicePolicySafetyChecker { + ", should be " + operationToString(mOperation)); } String reasonName = operationSafetyReasonToString(reason); DevicePolicyManagerInternal dpmi = LocalServices .getService(DevicePolicyManagerInternal.class); DevicePolicyManagerLiteInternal dpmi = LocalServices .getService(DevicePolicyManagerLiteInternal.class); Slog.i(TAG, "notifying " + reasonName + " is UNSAFE"); dpmi.notifyUnsafeOperationStateChanged(this, reason, /* isSafe= */ false); Loading services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceMigrationTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import static org.mockito.Mockito.when; import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerLiteInternal; import android.content.ComponentName; import android.content.Intent; import android.content.pm.PackageManager; Loading Loading @@ -158,6 +159,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading Loading @@ -271,6 +273,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading Loading @@ -339,6 +342,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { // (Need clearCallingIdentity() to pass permission checks.) final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading Loading @@ -499,6 +503,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { DevicePolicyManagerServiceTestable dpms; final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading Loading
core/java/android/app/admin/DevicePolicyManagerInternal.java +0 −10 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.app.admin; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.admin.DevicePolicyManager.OperationSafetyReason; import android.content.ComponentName; import android.content.Intent; import android.os.UserHandle; Loading Loading @@ -256,13 +255,4 @@ public abstract class DevicePolicyManagerInternal { * {@link #supportsResetOp(int)} is true. */ public abstract void resetOp(int op, String packageName, @UserIdInt int userId); /** * Notifies the system that an unsafe operation reason has changed. * * @throws IllegalArgumentException if {@code checker} is not the same as set on * {@code DevicePolicyManagerService}. */ public abstract void notifyUnsafeOperationStateChanged(DevicePolicySafetyChecker checker, @OperationSafetyReason int reason, boolean isSafe); }
core/java/android/app/admin/DevicePolicyManagerLiteInternal.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.admin; import android.app.admin.DevicePolicyManager.OperationSafetyReason; /** * Device policy manager local system service interface for methods that don't require the * {@code device_admin} feature. * * Maintenance note: if you need to expose information from DPMS to lower level services such as * PM/UM/AM/etc, then exposing it from DevicePolicyManagerInternal is not safe because it may cause * lock order inversion. Consider using {@link DevicePolicyCache} instead. * * @hide Only for use within the system server. */ public interface DevicePolicyManagerLiteInternal { /** * Notifies the system that an unsafe operation reason has changed. * * @throws IllegalArgumentException if {@code checker} is not the same as set on * {@code DevicePolicyManagerService.setDevicePolicySafetyChecker()}. */ void notifyUnsafeOperationStateChanged(DevicePolicySafetyChecker checker, @OperationSafetyReason int reason, boolean isSafe); }
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ import android.app.admin.DevicePolicyManager.OperationSafetyReason; import android.app.admin.DevicePolicyManager.PasswordComplexity; import android.app.admin.DevicePolicyManager.PersonalAppsSuspensionReason; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerLiteInternal; import android.app.admin.DevicePolicySafetyChecker; import android.app.admin.DeviceStateCache; import android.app.admin.FactoryResetProtectionPolicy; Loading Loading @@ -1748,6 +1749,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { mTransferOwnershipMetadataManager = mInjector.newTransferOwnershipMetadataManager(); mBugreportCollectionManager = new RemoteBugreportManager(this, mInjector); // "Lite" interface is available even when the device doesn't have the feature LocalServices.addService(DevicePolicyManagerLiteInternal.class, mLocalService); if (!mHasFeature) { // Skip the rest of the initialization mSetupContentObserver = null; Loading Loading @@ -12612,7 +12615,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } @VisibleForTesting final class LocalService extends DevicePolicyManagerInternal { final class LocalService extends DevicePolicyManagerInternal implements DevicePolicyManagerLiteInternal { private List<OnCrossProfileWidgetProvidersChangeListener> mWidgetProviderListeners; @Override
services/devicepolicy/java/com/android/server/devicepolicy/OneTimeSafetyChecker.java +3 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import static android.app.admin.DevicePolicyManager.operationToString; import android.app.admin.DevicePolicyManager.DevicePolicyOperation; import android.app.admin.DevicePolicyManager.OperationSafetyReason; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerLiteInternal; import android.app.admin.DevicePolicySafetyChecker; import android.os.Handler; import android.os.Looper; Loading Loading @@ -80,8 +80,8 @@ final class OneTimeSafetyChecker implements DevicePolicySafetyChecker { + ", should be " + operationToString(mOperation)); } String reasonName = operationSafetyReasonToString(reason); DevicePolicyManagerInternal dpmi = LocalServices .getService(DevicePolicyManagerInternal.class); DevicePolicyManagerLiteInternal dpmi = LocalServices .getService(DevicePolicyManagerLiteInternal.class); Slog.i(TAG, "notifying " + reasonName + " is UNSAFE"); dpmi.notifyUnsafeOperationStateChanged(this, reason, /* isSafe= */ false); Loading
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceMigrationTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import static org.mockito.Mockito.when; import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerLiteInternal; import android.content.ComponentName; import android.content.Intent; import android.content.pm.PackageManager; Loading Loading @@ -158,6 +159,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading Loading @@ -271,6 +273,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading Loading @@ -339,6 +342,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { // (Need clearCallingIdentity() to pass permission checks.) final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading Loading @@ -499,6 +503,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase { DevicePolicyManagerServiceTestable dpms; final long ident = mContext.binder.clearCallingIdentity(); try { LocalServices.removeServiceForTest(DevicePolicyManagerLiteInternal.class); LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); dpms = new DevicePolicyManagerServiceTestable(getServices(), mContext); Loading