Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 246ad02e authored by Felipe Leme's avatar Felipe Leme Committed by Automerger Merge Worker
Browse files

Merge "Split DevicePolicyManagerInternal into...

Merge "Split DevicePolicyManagerInternal into DevicePolicyManagerLiteInternal." into sc-dev am: 60ec24eb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14948897

Change-Id: I3dccb36f49e871f2fa08a8268ed07b92a4fdeb12
parents dd211bab 60ec24eb
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -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;
@@ -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);
}
+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);
}
+5 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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);
@@ -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);
@@ -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);
@@ -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