BaseIDevicePolicyManager.java revision 5416468217e5c79b54d795cb6227e5b9312c24d6
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 */
16package com.android.server.devicepolicy;
17
18import android.annotation.UserIdInt;
19import android.app.admin.IDevicePolicyManager;
20import android.content.ComponentName;
21import android.os.PersistableBundle;
22import android.security.keymaster.KeymasterCertificateChain;
23import android.security.keystore.ParcelableKeyGenParameterSpec;
24import android.telephony.data.ApnSetting;
25
26import com.android.server.SystemService;
27
28import java.util.ArrayList;
29import java.util.Collections;
30import java.util.List;
31
32/**
33 * Defines the required interface for IDevicePolicyManager implemenation.
34 *
35 * <p>The interface consists of public parts determined by {@link IDevicePolicyManager} and also
36 * several package private methods required by internal infrastructure.
37 *
38 * <p>Whenever adding an AIDL method to {@link IDevicePolicyManager}, an empty override method
39 * should be added here to avoid build breakage in downstream branches.
40 */
41abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub {
42    /**
43     * To be called by {@link DevicePolicyManagerService#Lifecycle} during the various boot phases.
44     *
45     * @see {@link SystemService#onBootPhase}.
46     */
47    abstract void systemReady(int phase);
48    /**
49     * To be called by {@link DevicePolicyManagerService#Lifecycle} when a new user starts.
50     *
51     * @see {@link SystemService#onStartUser}
52     */
53    abstract void handleStartUser(int userId);
54    /**
55     * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being unlocked.
56     *
57     * @see {@link SystemService#onUnlockUser}
58     */
59    abstract void handleUnlockUser(int userId);
60    /**
61     * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being stopped.
62     *
63     * @see {@link SystemService#onStopUser}
64     */
65    abstract void handleStopUser(int userId);
66
67    public void setSystemSetting(ComponentName who, String setting, String value){}
68
69    public void transferOwnership(ComponentName admin, ComponentName target, PersistableBundle bundle) {}
70
71    public PersistableBundle getTransferOwnershipBundle() {
72        return null;
73    }
74
75    public boolean generateKeyPair(ComponentName who, String callerPackage, String algorithm,
76            ParcelableKeyGenParameterSpec keySpec, int idAttestationFlags,
77            KeymasterCertificateChain attestationChain) {
78        return false;
79    }
80
81    @Override
82    public boolean setPasswordBlacklist(ComponentName who, String name, List<String> blacklist,
83            boolean parent) {
84        return false;
85    }
86
87    @Override
88    public String getPasswordBlacklistName(ComponentName who, @UserIdInt int userId,
89            boolean parent) {
90        return null;
91    }
92
93    @Override
94    public boolean isPasswordBlacklisted(@UserIdInt int userId, String password) {
95        return false;
96    }
97
98    public boolean isUsingUnifiedPassword(ComponentName who) {
99        return true;
100    }
101
102    public boolean setKeyPairCertificate(ComponentName who, String callerPackage, String alias,
103            byte[] cert, byte[] chain, boolean isUserSelectable) {
104        return false;
105    }
106
107    @Override
108    public void setStartUserSessionMessage(
109            ComponentName admin, CharSequence startUserSessionMessage) {}
110
111    @Override
112    public void setEndUserSessionMessage(ComponentName admin, CharSequence endUserSessionMessage) {}
113
114    @Override
115    public String getStartUserSessionMessage(ComponentName admin) {
116        return null;
117    }
118
119    @Override
120    public String getEndUserSessionMessage(ComponentName admin) {
121        return null;
122    }
123
124    @Override
125    public List<String> setMeteredDataDisabledPackages(ComponentName admin, List<String> packageNames) {
126        return packageNames;
127    }
128
129    @Override
130    public List<String> getMeteredDataDisabledPackages(ComponentName admin) {
131        return new ArrayList<>();
132    }
133
134    @Override
135    public int addOverrideApn(ComponentName admin, ApnSetting apnSetting) {
136        return -1;
137    }
138
139    @Override
140    public boolean updateOverrideApn(ComponentName admin, int apnId, ApnSetting apnSetting) {
141        return false;
142    }
143
144    @Override
145    public boolean removeOverrideApn(ComponentName admin, int apnId) {
146        return false;
147    }
148
149    @Override
150    public List<ApnSetting> getOverrideApns(ComponentName admin) {
151        return Collections.emptyList();
152    }
153
154    @Override
155    public void setOverrideApnsEnabled(ComponentName admin, boolean enabled) {}
156
157    @Override
158    public boolean isOverrideApnEnabled(ComponentName admin) {
159        return false;
160    }
161
162    public void clearSystemUpdatePolicyFreezePeriodRecord() {
163    }
164
165    @Override
166    public boolean isMeteredDataDisabledPackageForUser(ComponentName admin,
167            String packageName, int userId) {
168        return false;
169    }
170
171    @Override
172    public long forceSecurityLogs() {
173        return 0;
174    }
175
176    @Override
177    public void setDefaultSmsApplication(ComponentName admin, String packageName) {
178    }
179}
180