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.accounts.Account; 19 import android.annotation.NonNull; 20 import android.annotation.UserIdInt; 21 import android.app.admin.DevicePolicyDrawableResource; 22 import android.app.admin.DevicePolicySafetyChecker; 23 import android.app.admin.DevicePolicyStringResource; 24 import android.app.admin.FullyManagedDeviceProvisioningParams; 25 import android.app.admin.IDevicePolicyManager; 26 import android.app.admin.ManagedProfileProvisioningParams; 27 import android.app.admin.ParcelableResource; 28 import android.content.ComponentName; 29 import android.os.UserHandle; 30 import android.util.Slog; 31 32 import com.android.server.SystemService; 33 34 import java.util.Collections; 35 import java.util.List; 36 37 /** 38 * Defines the required interface for IDevicePolicyManager implemenation. 39 * 40 * <p>The interface consists of public parts determined by {@link IDevicePolicyManager} and also 41 * several package private methods required by internal infrastructure. 42 * 43 * <p>Whenever adding an AIDL method to {@link IDevicePolicyManager}, an empty override method 44 * should be added here to avoid build breakage in downstream branches. 45 */ 46 abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub { 47 48 private static final String TAG = BaseIDevicePolicyManager.class.getSimpleName(); 49 50 /** 51 * To be called by {@link DevicePolicyManagerService#Lifecycle} during the various boot phases. 52 * 53 * @see {@link SystemService#onBootPhase}. 54 */ systemReady(int phase)55 abstract void systemReady(int phase); 56 /** 57 * To be called by {@link DevicePolicyManagerService#Lifecycle} when a new user starts. 58 * 59 * @see {@link SystemService#onUserStarting} 60 */ handleStartUser(int userId)61 abstract void handleStartUser(int userId); 62 /** 63 * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being unlocked. 64 * 65 * @see {@link SystemService#onUserUnlocking} 66 */ handleUnlockUser(int userId)67 abstract void handleUnlockUser(int userId); 68 /** 69 * To be called by {@link DevicePolicyManagerService#Lifecycle} after a user is being unlocked. 70 * 71 * @see {@link SystemService#onUserUnlocked} 72 */ handleOnUserUnlocked(int userId)73 abstract void handleOnUserUnlocked(int userId); 74 /** 75 * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being stopped. 76 * 77 * @see {@link SystemService#onUserStopping} 78 */ handleStopUser(int userId)79 abstract void handleStopUser(int userId); 80 81 /** 82 * Sets the {@link DevicePolicySafetyChecker}. 83 * 84 * <p>Currently, it's called only by {@code SystemServer} on 85 * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE automotive builds} 86 */ setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker)87 public void setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker) { 88 Slog.w(TAG, "setDevicePolicySafetyChecker() not implemented by " + getClass()); 89 } 90 clearSystemUpdatePolicyFreezePeriodRecord()91 public void clearSystemUpdatePolicyFreezePeriodRecord() { 92 } 93 setKeyGrantForApp(ComponentName admin, String callerPackage, String alias, String packageName, boolean hasGrant)94 public boolean setKeyGrantForApp(ComponentName admin, String callerPackage, String alias, 95 String packageName, boolean hasGrant) { 96 return false; 97 } 98 setLocationEnabled(ComponentName who, boolean locationEnabled)99 public void setLocationEnabled(ComponentName who, boolean locationEnabled) {} 100 isOrganizationOwnedDeviceWithManagedProfile()101 public boolean isOrganizationOwnedDeviceWithManagedProfile() { 102 return false; 103 } 104 getPersonalAppsSuspendedReasons(ComponentName admin)105 public int getPersonalAppsSuspendedReasons(ComponentName admin) { 106 return 0; 107 } 108 setPersonalAppsSuspended(ComponentName admin, boolean suspended)109 public void setPersonalAppsSuspended(ComponentName admin, boolean suspended) { 110 } 111 setManagedProfileMaximumTimeOff(ComponentName admin, long timeoutMs)112 public void setManagedProfileMaximumTimeOff(ComponentName admin, long timeoutMs) { 113 } 114 getManagedProfileMaximumTimeOff(ComponentName admin)115 public long getManagedProfileMaximumTimeOff(ComponentName admin) { 116 return 0; 117 } 118 119 @Override acknowledgeDeviceCompliant()120 public void acknowledgeDeviceCompliant() {} 121 122 @Override isComplianceAcknowledgementRequired()123 public boolean isComplianceAcknowledgementRequired() { 124 return false; 125 } 126 canProfileOwnerResetPasswordWhenLocked(int userId)127 public boolean canProfileOwnerResetPasswordWhenLocked(int userId) { 128 return false; 129 } 130 getEnrollmentSpecificId(String callerPackage)131 public String getEnrollmentSpecificId(String callerPackage) { 132 return ""; 133 } 134 setOrganizationIdForUser( @onNull String callerPackage, @NonNull String enterpriseId, int userId)135 public void setOrganizationIdForUser( 136 @NonNull String callerPackage, @NonNull String enterpriseId, int userId) {} 137 createAndProvisionManagedProfile( @onNull ManagedProfileProvisioningParams provisioningParams, String callerPackage)138 public UserHandle createAndProvisionManagedProfile( 139 @NonNull ManagedProfileProvisioningParams provisioningParams, String callerPackage) { 140 return null; 141 } 142 finalizeWorkProfileProvisioning( UserHandle managedProfileUser, Account migratedAccount)143 public void finalizeWorkProfileProvisioning( 144 UserHandle managedProfileUser, Account migratedAccount) { 145 146 } 147 provisionFullyManagedDevice( FullyManagedDeviceProvisioningParams provisioningParams, String callerPackage)148 public void provisionFullyManagedDevice( 149 FullyManagedDeviceProvisioningParams provisioningParams, String callerPackage) { 150 } 151 152 @Override setDeviceOwnerType(@onNull ComponentName admin, int deviceOwnerType)153 public void setDeviceOwnerType(@NonNull ComponentName admin, int deviceOwnerType) { 154 } 155 156 @Override getDeviceOwnerType(@onNull ComponentName admin)157 public int getDeviceOwnerType(@NonNull ComponentName admin) { 158 return 0; 159 } 160 resetDefaultCrossProfileIntentFilters(@serIdInt int userId)161 public void resetDefaultCrossProfileIntentFilters(@UserIdInt int userId) {} 162 canAdminGrantSensorsPermissionsForUser(int userId)163 public boolean canAdminGrantSensorsPermissionsForUser(int userId) { 164 return false; 165 } 166 167 @Override setKeyGrantToWifiAuth(String callerPackage, String alias, boolean hasGrant)168 public boolean setKeyGrantToWifiAuth(String callerPackage, String alias, boolean hasGrant) { 169 return false; 170 } 171 172 @Override isKeyPairGrantedToWifiAuth(String callerPackage, String alias)173 public boolean isKeyPairGrantedToWifiAuth(String callerPackage, String alias) { 174 return false; 175 } 176 177 @Override setDrawables(@onNull List<DevicePolicyDrawableResource> drawables)178 public void setDrawables(@NonNull List<DevicePolicyDrawableResource> drawables){} 179 180 @Override resetDrawables(@onNull List<String> drawableIds)181 public void resetDrawables(@NonNull List<String> drawableIds){} 182 183 @Override getDrawable( String drawableId, String drawableStyle, String drawableSource)184 public ParcelableResource getDrawable( 185 String drawableId, String drawableStyle, String drawableSource) { 186 return null; 187 } 188 189 @Override setStrings(@onNull List<DevicePolicyStringResource> strings)190 public void setStrings(@NonNull List<DevicePolicyStringResource> strings){} 191 192 @Override resetStrings(@onNull List<String> stringIds)193 public void resetStrings(@NonNull List<String> stringIds){} 194 195 @Override getString(String stringId)196 public ParcelableResource getString(String stringId) { 197 return null; 198 } 199 200 @Override shouldAllowBypassingDevicePolicyManagementRoleQualification()201 public boolean shouldAllowBypassingDevicePolicyManagementRoleQualification() { 202 return false; 203 } 204 205 @Override getPolicyManagedProfiles(UserHandle userHandle)206 public List<UserHandle> getPolicyManagedProfiles(UserHandle userHandle) { 207 return Collections.emptyList(); 208 } 209 } 210