1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.server.devicepolicy; 17 18 import android.annotation.NonNull; 19 import android.annotation.UserIdInt; 20 import android.app.admin.DevicePolicySafetyChecker; 21 import android.app.admin.FullyManagedDeviceProvisioningParams; 22 import android.app.admin.IDevicePolicyManager; 23 import android.app.admin.ManagedProfileProvisioningParams; 24 import android.content.ComponentName; 25 import android.os.UserHandle; 26 import android.util.Slog; 27 28 import com.android.server.SystemService; 29 30 /** 31 * Defines the required interface for IDevicePolicyManager implemenation. 32 * 33 * <p>The interface consists of public parts determined by {@link IDevicePolicyManager} and also 34 * several package private methods required by internal infrastructure. 35 * 36 * <p>Whenever adding an AIDL method to {@link IDevicePolicyManager}, an empty override method 37 * should be added here to avoid build breakage in downstream branches. 38 */ 39 abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub { 40 41 private static final String TAG = BaseIDevicePolicyManager.class.getSimpleName(); 42 43 /** 44 * To be called by {@link DevicePolicyManagerService#Lifecycle} during the various boot phases. 45 * 46 * @see {@link SystemService#onBootPhase}. 47 */ systemReady(int phase)48 abstract void systemReady(int phase); 49 /** 50 * To be called by {@link DevicePolicyManagerService#Lifecycle} when a new user starts. 51 * 52 * @see {@link SystemService#onUserStarting} 53 */ handleStartUser(int userId)54 abstract void handleStartUser(int userId); 55 /** 56 * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being unlocked. 57 * 58 * @see {@link SystemService#onUserUnlocking} 59 */ handleUnlockUser(int userId)60 abstract void handleUnlockUser(int userId); 61 /** 62 * To be called by {@link DevicePolicyManagerService#Lifecycle} after a user is being unlocked. 63 * 64 * @see {@link SystemService#onUserUnlocked} 65 */ handleOnUserUnlocked(int userId)66 abstract void handleOnUserUnlocked(int userId); 67 /** 68 * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being stopped. 69 * 70 * @see {@link SystemService#onUserStopping} 71 */ handleStopUser(int userId)72 abstract void handleStopUser(int userId); 73 74 /** 75 * Sets the {@link DevicePolicySafetyChecker}. 76 * 77 * <p>Currently, it's called only by {@code SystemServer} on 78 * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE automotive builds} 79 */ setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker)80 public void setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker) { 81 Slog.w(TAG, "setDevicePolicySafetyChecker() not implemented by " + getClass()); 82 } 83 clearSystemUpdatePolicyFreezePeriodRecord()84 public void clearSystemUpdatePolicyFreezePeriodRecord() { 85 } 86 setKeyGrantForApp(ComponentName admin, String callerPackage, String alias, String packageName, boolean hasGrant)87 public boolean setKeyGrantForApp(ComponentName admin, String callerPackage, String alias, 88 String packageName, boolean hasGrant) { 89 return false; 90 } 91 setLocationEnabled(ComponentName who, boolean locationEnabled)92 public void setLocationEnabled(ComponentName who, boolean locationEnabled) {} 93 isOrganizationOwnedDeviceWithManagedProfile()94 public boolean isOrganizationOwnedDeviceWithManagedProfile() { 95 return false; 96 } 97 getPersonalAppsSuspendedReasons(ComponentName admin)98 public int getPersonalAppsSuspendedReasons(ComponentName admin) { 99 return 0; 100 } 101 setPersonalAppsSuspended(ComponentName admin, boolean suspended)102 public void setPersonalAppsSuspended(ComponentName admin, boolean suspended) { 103 } 104 setManagedProfileMaximumTimeOff(ComponentName admin, long timeoutMs)105 public void setManagedProfileMaximumTimeOff(ComponentName admin, long timeoutMs) { 106 } 107 getManagedProfileMaximumTimeOff(ComponentName admin)108 public long getManagedProfileMaximumTimeOff(ComponentName admin) { 109 return 0; 110 } 111 112 @Override acknowledgeDeviceCompliant()113 public void acknowledgeDeviceCompliant() {} 114 115 @Override isComplianceAcknowledgementRequired()116 public boolean isComplianceAcknowledgementRequired() { 117 return false; 118 } 119 canProfileOwnerResetPasswordWhenLocked(int userId)120 public boolean canProfileOwnerResetPasswordWhenLocked(int userId) { 121 return false; 122 } 123 getEnrollmentSpecificId(String callerPackage)124 public String getEnrollmentSpecificId(String callerPackage) { 125 return ""; 126 } 127 setOrganizationIdForUser( @onNull String callerPackage, @NonNull String enterpriseId, int userId)128 public void setOrganizationIdForUser( 129 @NonNull String callerPackage, @NonNull String enterpriseId, int userId) {} 130 createAndProvisionManagedProfile( @onNull ManagedProfileProvisioningParams provisioningParams, String callerPackage)131 public UserHandle createAndProvisionManagedProfile( 132 @NonNull ManagedProfileProvisioningParams provisioningParams, String callerPackage) { 133 return null; 134 } 135 provisionFullyManagedDevice( FullyManagedDeviceProvisioningParams provisioningParams, String callerPackage)136 public void provisionFullyManagedDevice( 137 FullyManagedDeviceProvisioningParams provisioningParams, String callerPackage) { 138 } 139 140 @Override setDeviceOwnerType(@onNull ComponentName admin, int deviceOwnerType)141 public void setDeviceOwnerType(@NonNull ComponentName admin, int deviceOwnerType) { 142 } 143 144 @Override getDeviceOwnerType(@onNull ComponentName admin)145 public int getDeviceOwnerType(@NonNull ComponentName admin) { 146 return 0; 147 } 148 resetDefaultCrossProfileIntentFilters(@serIdInt int userId)149 public void resetDefaultCrossProfileIntentFilters(@UserIdInt int userId) {} 150 canAdminGrantSensorsPermissionsForUser(int userId)151 public boolean canAdminGrantSensorsPermissionsForUser(int userId) { 152 return false; 153 } 154 155 @Override setKeyGrantToWifiAuth(String callerPackage, String alias, boolean hasGrant)156 public boolean setKeyGrantToWifiAuth(String callerPackage, String alias, boolean hasGrant) { 157 return false; 158 } 159 160 @Override isKeyPairGrantedToWifiAuth(String callerPackage, String alias)161 public boolean isKeyPairGrantedToWifiAuth(String callerPackage, String alias) { 162 return false; 163 } 164 } 165