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

Commit bf4372be authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Modify DevicePolicyManagerService to extend IDevicePolicyManager.aidl"

parents bf6c9746 01ed6212
Loading
Loading
Loading
Loading
+15 −19
Original line number Original line Diff line number Diff line
@@ -221,6 +221,7 @@ import android.app.admin.DevicePolicyStringResource;
import android.app.admin.DeviceStateCache;
import android.app.admin.DeviceStateCache;
import android.app.admin.FactoryResetProtectionPolicy;
import android.app.admin.FactoryResetProtectionPolicy;
import android.app.admin.FullyManagedDeviceProvisioningParams;
import android.app.admin.FullyManagedDeviceProvisioningParams;
import android.app.admin.IDevicePolicyManager;
import android.app.admin.ManagedProfileProvisioningParams;
import android.app.admin.ManagedProfileProvisioningParams;
import android.app.admin.ManagedSubscriptionsPolicy;
import android.app.admin.ManagedSubscriptionsPolicy;
import android.app.admin.NetworkEvent;
import android.app.admin.NetworkEvent;
@@ -442,7 +443,7 @@ import java.util.stream.Collectors;
/**
/**
 * Implementation of the device policy APIs.
 * Implementation of the device policy APIs.
 */
 */
public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    protected static final String LOG_TAG = "DevicePolicyManager";
    protected static final String LOG_TAG = "DevicePolicyManager";
@@ -920,25 +921,26 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    private final ArrayList<Object> mPendingUserCreatedCallbackTokens = new ArrayList<>();
    private final ArrayList<Object> mPendingUserCreatedCallbackTokens = new ArrayList<>();
    public static final class Lifecycle extends SystemService {
    public static final class Lifecycle extends SystemService {
        private BaseIDevicePolicyManager mService;
        private DevicePolicyManagerService mService;
        public Lifecycle(Context context) {
        public Lifecycle(Context context) {
            super(context);
            super(context);
            String dpmsClassName = context.getResources()
            String dpmsClassName = context.getResources()
                    .getString(R.string.config_deviceSpecificDevicePolicyManagerService);
                    .getString(R.string.config_deviceSpecificDevicePolicyManagerService);
            if (TextUtils.isEmpty(dpmsClassName)) {
            if (TextUtils.isEmpty(dpmsClassName)) {
                dpmsClassName = DevicePolicyManagerService.class.getName();
                mService = new DevicePolicyManagerService(context);
            }
            } else {
                try {
                try {
                    Class<?> serviceClass = Class.forName(dpmsClassName);
                    Class<?> serviceClass = Class.forName(dpmsClassName);
                    Constructor<?> constructor = serviceClass.getConstructor(Context.class);
                    Constructor<?> constructor = serviceClass.getConstructor(Context.class);
                mService = (BaseIDevicePolicyManager) constructor.newInstance(context);
                    mService = (DevicePolicyManagerService) constructor.newInstance(context);
                } catch (Exception e) {
                } catch (Exception e) {
                    throw new IllegalStateException(
                    throw new IllegalStateException(
                        "Failed to instantiate DevicePolicyManagerService with class name: "
                        "Failed to instantiate DevicePolicyManagerService with class name: "
                        + dpmsClassName, e);
                        + dpmsClassName, e);
                }
                }
            }
            }
        }
        /** Sets the {@link DevicePolicySafetyChecker}. */
        /** Sets the {@link DevicePolicySafetyChecker}. */
        public void setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker) {
        public void setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker) {
@@ -1348,7 +1350,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        }
    }
    }
    @Override
    public void setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker) {
    public void setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker) {
        CallerIdentity callerIdentity = getCallerIdentity();
        CallerIdentity callerIdentity = getCallerIdentity();
        Preconditions.checkCallAuthorization(mIsAutomotive || isAdb(callerIdentity), "can only set "
        Preconditions.checkCallAuthorization(mIsAutomotive || isAdb(callerIdentity), "can only set "
@@ -3090,7 +3091,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    }
    @VisibleForTesting
    @VisibleForTesting
    @Override
    void systemReady(int phase) {
    void systemReady(int phase) {
        if (!mHasFeature) {
        if (!mHasFeature) {
            return;
            return;
@@ -3289,7 +3289,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        }
    }
    }
    @Override
    void handleStartUser(int userId) {
    void handleStartUser(int userId) {
        synchronized (getLockObject()) {
        synchronized (getLockObject()) {
            pushScreenCapturePolicy(userId);
            pushScreenCapturePolicy(userId);
@@ -3337,7 +3336,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                        targetUserId, protectedPackages));
                        targetUserId, protectedPackages));
    }
    }
    @Override
    void handleUnlockUser(int userId) {
    void handleUnlockUser(int userId) {
        startOwnerService(userId, "unlock-user");
        startOwnerService(userId, "unlock-user");
        if (isCoexistenceFlagEnabled()) {
        if (isCoexistenceFlagEnabled()) {
@@ -3345,12 +3343,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        }
    }
    }
    @Override
    void handleOnUserUnlocked(int userId) {
    void handleOnUserUnlocked(int userId) {
        showNewUserDisclaimerIfNecessary(userId);
        showNewUserDisclaimerIfNecessary(userId);
    }
    }
    @Override
    void handleStopUser(int userId) {
    void handleStopUser(int userId) {
        updateNetworkPreferenceForUser(userId, List.of(PreferentialNetworkServiceConfig.DEFAULT));
        updateNetworkPreferenceForUser(userId, List.of(PreferentialNetworkServiceConfig.DEFAULT));
        mDeviceAdminServiceController.stopServicesForUser(userId, /* actionForLog= */ "stop-user");
        mDeviceAdminServiceController.stopServicesForUser(userId, /* actionForLog= */ "stop-user");