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