1/*
2**
3** Copyright 2010, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9**     http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18package android.app.admin;
19
20import android.app.admin.NetworkEvent;
21import android.app.IApplicationThread;
22import android.app.IServiceConnection;
23import android.app.admin.SystemUpdateInfo;
24import android.app.admin.SystemUpdatePolicy;
25import android.app.admin.PasswordMetrics;
26import android.content.ComponentName;
27import android.content.Intent;
28import android.content.IntentFilter;
29import android.content.pm.ParceledListSlice;
30import android.content.pm.StringParceledListSlice;
31import android.graphics.Bitmap;
32import android.net.ProxyInfo;
33import android.net.Uri;
34import android.os.Bundle;
35import android.os.PersistableBundle;
36import android.os.RemoteCallback;
37import android.os.UserHandle;
38
39import java.util.List;
40
41/**
42 * Internal IPC interface to the device policy service.
43 * {@hide}
44 */
45interface IDevicePolicyManager {
46    void setPasswordQuality(in ComponentName who, int quality, boolean parent);
47    int getPasswordQuality(in ComponentName who, int userHandle, boolean parent);
48
49    void setPasswordMinimumLength(in ComponentName who, int length, boolean parent);
50    int getPasswordMinimumLength(in ComponentName who, int userHandle, boolean parent);
51
52    void setPasswordMinimumUpperCase(in ComponentName who, int length, boolean parent);
53    int getPasswordMinimumUpperCase(in ComponentName who, int userHandle, boolean parent);
54
55    void setPasswordMinimumLowerCase(in ComponentName who, int length, boolean parent);
56    int getPasswordMinimumLowerCase(in ComponentName who, int userHandle, boolean parent);
57
58    void setPasswordMinimumLetters(in ComponentName who, int length, boolean parent);
59    int getPasswordMinimumLetters(in ComponentName who, int userHandle, boolean parent);
60
61    void setPasswordMinimumNumeric(in ComponentName who, int length, boolean parent);
62    int getPasswordMinimumNumeric(in ComponentName who, int userHandle, boolean parent);
63
64    void setPasswordMinimumSymbols(in ComponentName who, int length, boolean parent);
65    int getPasswordMinimumSymbols(in ComponentName who, int userHandle, boolean parent);
66
67    void setPasswordMinimumNonLetter(in ComponentName who, int length, boolean parent);
68    int getPasswordMinimumNonLetter(in ComponentName who, int userHandle, boolean parent);
69
70    void setPasswordHistoryLength(in ComponentName who, int length, boolean parent);
71    int getPasswordHistoryLength(in ComponentName who, int userHandle, boolean parent);
72
73    void setPasswordExpirationTimeout(in ComponentName who, long expiration, boolean parent);
74    long getPasswordExpirationTimeout(in ComponentName who, int userHandle, boolean parent);
75
76    long getPasswordExpiration(in ComponentName who, int userHandle, boolean parent);
77
78    boolean isActivePasswordSufficient(int userHandle, boolean parent);
79    boolean isProfileActivePasswordSufficientForParent(int userHandle);
80    int getCurrentFailedPasswordAttempts(int userHandle, boolean parent);
81    int getProfileWithMinimumFailedPasswordsForWipe(int userHandle, boolean parent);
82
83    void setMaximumFailedPasswordsForWipe(in ComponentName admin, int num, boolean parent);
84    int getMaximumFailedPasswordsForWipe(in ComponentName admin, int userHandle, boolean parent);
85
86    boolean resetPassword(String password, int flags);
87
88    void setMaximumTimeToLock(in ComponentName who, long timeMs, boolean parent);
89    long getMaximumTimeToLock(in ComponentName who, int userHandle, boolean parent);
90    long getMaximumTimeToLockForUserAndProfiles(int userHandle);
91
92    void setRequiredStrongAuthTimeout(in ComponentName who, long timeMs, boolean parent);
93    long getRequiredStrongAuthTimeout(in ComponentName who, int userId, boolean parent);
94
95    void lockNow(int flags, boolean parent);
96
97    void wipeData(int flags);
98
99    ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
100    ComponentName getGlobalProxyAdmin(int userHandle);
101    void setRecommendedGlobalProxy(in ComponentName admin, in ProxyInfo proxyInfo);
102
103    int setStorageEncryption(in ComponentName who, boolean encrypt);
104    boolean getStorageEncryption(in ComponentName who, int userHandle);
105    int getStorageEncryptionStatus(in String callerPackage, int userHandle);
106
107    boolean requestBugreport(in ComponentName who);
108
109    void setCameraDisabled(in ComponentName who, boolean disabled);
110    boolean getCameraDisabled(in ComponentName who, int userHandle);
111
112    void setScreenCaptureDisabled(in ComponentName who, boolean disabled);
113    boolean getScreenCaptureDisabled(in ComponentName who, int userHandle);
114
115    void setKeyguardDisabledFeatures(in ComponentName who, int which, boolean parent);
116    int getKeyguardDisabledFeatures(in ComponentName who, int userHandle, boolean parent);
117
118    void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing, int userHandle);
119    boolean isAdminActive(in ComponentName policyReceiver, int userHandle);
120    List<ComponentName> getActiveAdmins(int userHandle);
121    boolean packageHasActiveAdmins(String packageName, int userHandle);
122    void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result, int userHandle);
123    void removeActiveAdmin(in ComponentName policyReceiver, int userHandle);
124    void forceRemoveActiveAdmin(in ComponentName policyReceiver, int userHandle);
125    boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy, int userHandle);
126
127    void setActivePasswordState(in PasswordMetrics metrics, int userHandle);
128    void reportPasswordChanged(int userId);
129    void reportFailedPasswordAttempt(int userHandle);
130    void reportSuccessfulPasswordAttempt(int userHandle);
131    void reportFailedFingerprintAttempt(int userHandle);
132    void reportSuccessfulFingerprintAttempt(int userHandle);
133    void reportKeyguardDismissed(int userHandle);
134    void reportKeyguardSecured(int userHandle);
135
136    boolean setDeviceOwner(in ComponentName who, String ownerName, int userId);
137    ComponentName getDeviceOwnerComponent(boolean callingUserOnly);
138    boolean hasDeviceOwner();
139    String getDeviceOwnerName();
140    void clearDeviceOwner(String packageName);
141    int getDeviceOwnerUserId();
142
143    boolean setProfileOwner(in ComponentName who, String ownerName, int userHandle);
144    ComponentName getProfileOwner(int userHandle);
145    String getProfileOwnerName(int userHandle);
146    void setProfileEnabled(in ComponentName who);
147    void setProfileName(in ComponentName who, String profileName);
148    void clearProfileOwner(in ComponentName who);
149    boolean hasUserSetupCompleted();
150
151    void setDeviceOwnerLockScreenInfo(in ComponentName who, CharSequence deviceOwnerInfo);
152    CharSequence getDeviceOwnerLockScreenInfo();
153
154    String[] setPackagesSuspended(in ComponentName admin, in String callerPackage, in String[] packageNames, boolean suspended);
155    boolean isPackageSuspended(in ComponentName admin, in String callerPackage, String packageName);
156
157    boolean installCaCert(in ComponentName admin, String callerPackage, in byte[] certBuffer);
158    void uninstallCaCerts(in ComponentName admin, String callerPackage, in String[] aliases);
159    void enforceCanManageCaCerts(in ComponentName admin, in String callerPackage);
160    boolean approveCaCert(in String alias, int userHandle, boolean approval);
161    boolean isCaCertApproved(in String alias, int userHandle);
162
163    boolean installKeyPair(in ComponentName who, in String callerPackage, in byte[] privKeyBuffer,
164            in byte[] certBuffer, in byte[] certChainBuffer, String alias, boolean requestAccess);
165    boolean removeKeyPair(in ComponentName who, in String callerPackage, String alias);
166    void choosePrivateKeyAlias(int uid, in Uri uri, in String alias, IBinder aliasCallback);
167
168    void setDelegatedScopes(in ComponentName who, in String delegatePackage, in List<String> scopes);
169    List<String> getDelegatedScopes(in ComponentName who, String delegatePackage);
170    List<String> getDelegatePackages(in ComponentName who, String scope);
171
172    void setCertInstallerPackage(in ComponentName who, String installerPackage);
173    String getCertInstallerPackage(in ComponentName who);
174
175    boolean setAlwaysOnVpnPackage(in ComponentName who, String vpnPackage, boolean lockdown);
176    String getAlwaysOnVpnPackage(in ComponentName who);
177
178    void addPersistentPreferredActivity(in ComponentName admin, in IntentFilter filter, in ComponentName activity);
179    void clearPackagePersistentPreferredActivities(in ComponentName admin, String packageName);
180
181    void setApplicationRestrictions(in ComponentName who, in String callerPackage, in String packageName, in Bundle settings);
182    Bundle getApplicationRestrictions(in ComponentName who, in String callerPackage, in String packageName);
183    boolean setApplicationRestrictionsManagingPackage(in ComponentName admin, in String packageName);
184    String getApplicationRestrictionsManagingPackage(in ComponentName admin);
185    boolean isCallerApplicationRestrictionsManagingPackage(in String callerPackage);
186
187    void setRestrictionsProvider(in ComponentName who, in ComponentName provider);
188    ComponentName getRestrictionsProvider(int userHandle);
189
190    void setUserRestriction(in ComponentName who, in String key, boolean enable);
191    Bundle getUserRestrictions(in ComponentName who);
192    void addCrossProfileIntentFilter(in ComponentName admin, in IntentFilter filter, int flags);
193    void clearCrossProfileIntentFilters(in ComponentName admin);
194
195    boolean setPermittedAccessibilityServices(in ComponentName admin,in List packageList);
196    List getPermittedAccessibilityServices(in ComponentName admin);
197    List getPermittedAccessibilityServicesForUser(int userId);
198    boolean isAccessibilityServicePermittedByAdmin(in ComponentName admin, String packageName, int userId);
199
200    boolean setPermittedInputMethods(in ComponentName admin,in List packageList);
201    List getPermittedInputMethods(in ComponentName admin);
202    List getPermittedInputMethodsForCurrentUser();
203    boolean isInputMethodPermittedByAdmin(in ComponentName admin, String packageName, int userId);
204
205    boolean setPermittedCrossProfileNotificationListeners(in ComponentName admin, in List<String> packageList);
206    List<String> getPermittedCrossProfileNotificationListeners(in ComponentName admin);
207    boolean isNotificationListenerServicePermitted(in String packageName, int userId);
208
209    Intent createAdminSupportIntent(in String restriction);
210    boolean setApplicationHidden(in ComponentName admin, in String callerPackage, in String packageName, boolean hidden);
211    boolean isApplicationHidden(in ComponentName admin, in String callerPackage, in String packageName);
212
213    UserHandle createAndManageUser(in ComponentName who, in String name, in ComponentName profileOwner, in PersistableBundle adminExtras, in int flags);
214    boolean removeUser(in ComponentName who, in UserHandle userHandle);
215    boolean switchUser(in ComponentName who, in UserHandle userHandle);
216
217    void enableSystemApp(in ComponentName admin, in String callerPackage, in String packageName);
218    int enableSystemAppWithIntent(in ComponentName admin, in String callerPackage, in Intent intent);
219
220    void setAccountManagementDisabled(in ComponentName who, in String accountType, in boolean disabled);
221    String[] getAccountTypesWithManagementDisabled();
222    String[] getAccountTypesWithManagementDisabledAsUser(int userId);
223
224    void setLockTaskPackages(in ComponentName who, in String[] packages);
225    String[] getLockTaskPackages(in ComponentName who);
226    boolean isLockTaskPermitted(in String pkg);
227
228    void setGlobalSetting(in ComponentName who, in String setting, in String value);
229    void setSecureSetting(in ComponentName who, in String setting, in String value);
230
231    void setMasterVolumeMuted(in ComponentName admin, boolean on);
232    boolean isMasterVolumeMuted(in ComponentName admin);
233
234    void notifyLockTaskModeChanged(boolean isEnabled, String pkg, int userId);
235
236    void setUninstallBlocked(in ComponentName admin, in String callerPackage, in String packageName, boolean uninstallBlocked);
237    boolean isUninstallBlocked(in ComponentName admin, in String packageName);
238
239    void setCrossProfileCallerIdDisabled(in ComponentName who, boolean disabled);
240    boolean getCrossProfileCallerIdDisabled(in ComponentName who);
241    boolean getCrossProfileCallerIdDisabledForUser(int userId);
242    void setCrossProfileContactsSearchDisabled(in ComponentName who, boolean disabled);
243    boolean getCrossProfileContactsSearchDisabled(in ComponentName who);
244    boolean getCrossProfileContactsSearchDisabledForUser(int userId);
245    void startManagedQuickContact(String lookupKey, long contactId, boolean isContactIdIgnored, long directoryId, in Intent originalIntent);
246
247    void setBluetoothContactSharingDisabled(in ComponentName who, boolean disabled);
248    boolean getBluetoothContactSharingDisabled(in ComponentName who);
249    boolean getBluetoothContactSharingDisabledForUser(int userId);
250
251    void setTrustAgentConfiguration(in ComponentName admin, in ComponentName agent,
252            in PersistableBundle args, boolean parent);
253    List<PersistableBundle> getTrustAgentConfiguration(in ComponentName admin,
254            in ComponentName agent, int userId, boolean parent);
255
256    boolean addCrossProfileWidgetProvider(in ComponentName admin, String packageName);
257    boolean removeCrossProfileWidgetProvider(in ComponentName admin, String packageName);
258    List<String> getCrossProfileWidgetProviders(in ComponentName admin);
259
260    void setAutoTimeRequired(in ComponentName who, boolean required);
261    boolean getAutoTimeRequired();
262
263    void setForceEphemeralUsers(in ComponentName who, boolean forceEpehemeralUsers);
264    boolean getForceEphemeralUsers(in ComponentName who);
265
266    boolean isRemovingAdmin(in ComponentName adminReceiver, int userHandle);
267
268    void setUserIcon(in ComponentName admin, in Bitmap icon);
269
270    void setSystemUpdatePolicy(in ComponentName who, in SystemUpdatePolicy policy);
271    SystemUpdatePolicy getSystemUpdatePolicy();
272
273    boolean setKeyguardDisabled(in ComponentName admin, boolean disabled);
274    boolean setStatusBarDisabled(in ComponentName who, boolean disabled);
275    boolean getDoNotAskCredentialsOnBoot();
276
277    void notifyPendingSystemUpdate(in SystemUpdateInfo info);
278    SystemUpdateInfo getPendingSystemUpdate(in ComponentName admin);
279
280    void setPermissionPolicy(in ComponentName admin, in String callerPackage, int policy);
281    int  getPermissionPolicy(in ComponentName admin);
282    boolean setPermissionGrantState(in ComponentName admin, in String callerPackage, String packageName,
283            String permission, int grantState);
284    int getPermissionGrantState(in ComponentName admin, in String callerPackage, String packageName, String permission);
285    boolean isProvisioningAllowed(String action, String packageName);
286    int checkProvisioningPreCondition(String action, String packageName);
287    void setKeepUninstalledPackages(in ComponentName admin, in String callerPackage, in List<String> packageList);
288    List<String> getKeepUninstalledPackages(in ComponentName admin, in String callerPackage);
289    boolean isManagedProfile(in ComponentName admin);
290    boolean isSystemOnlyUser(in ComponentName admin);
291    String getWifiMacAddress(in ComponentName admin);
292    void reboot(in ComponentName admin);
293
294    void setShortSupportMessage(in ComponentName admin, in CharSequence message);
295    CharSequence getShortSupportMessage(in ComponentName admin);
296    void setLongSupportMessage(in ComponentName admin, in CharSequence message);
297    CharSequence getLongSupportMessage(in ComponentName admin);
298
299    CharSequence getShortSupportMessageForUser(in ComponentName admin, int userHandle);
300    CharSequence getLongSupportMessageForUser(in ComponentName admin, int userHandle);
301
302    boolean isSeparateProfileChallengeAllowed(int userHandle);
303
304    void setOrganizationColor(in ComponentName admin, in int color);
305    void setOrganizationColorForUser(in int color, in int userId);
306    int getOrganizationColor(in ComponentName admin);
307    int getOrganizationColorForUser(int userHandle);
308
309    void setOrganizationName(in ComponentName admin, in CharSequence title);
310    CharSequence getOrganizationName(in ComponentName admin);
311    CharSequence getDeviceOwnerOrganizationName();
312    CharSequence getOrganizationNameForUser(int userHandle);
313
314    int getUserProvisioningState();
315    void setUserProvisioningState(int state, int userHandle);
316
317    void setAffiliationIds(in ComponentName admin, in List<String> ids);
318    List<String> getAffiliationIds(in ComponentName admin);
319    boolean isAffiliatedUser();
320
321    void setSecurityLoggingEnabled(in ComponentName admin, boolean enabled);
322    boolean isSecurityLoggingEnabled(in ComponentName admin);
323    ParceledListSlice retrieveSecurityLogs(in ComponentName admin);
324    ParceledListSlice retrievePreRebootSecurityLogs(in ComponentName admin);
325
326    boolean isUninstallInQueue(String packageName);
327    void uninstallPackageWithActiveAdmins(String packageName);
328
329    boolean isDeviceProvisioned();
330    boolean isDeviceProvisioningConfigApplied();
331    void setDeviceProvisioningConfigApplied();
332
333    void forceUpdateUserSetupComplete();
334
335    void setBackupServiceEnabled(in ComponentName admin, boolean enabled);
336    boolean isBackupServiceEnabled(in ComponentName admin);
337
338    void setNetworkLoggingEnabled(in ComponentName admin, boolean enabled);
339    boolean isNetworkLoggingEnabled(in ComponentName admin);
340    List<NetworkEvent> retrieveNetworkLogs(in ComponentName admin, long batchToken);
341
342    boolean bindDeviceAdminServiceAsUser(in ComponentName admin,
343        IApplicationThread caller, IBinder token, in Intent service,
344        IServiceConnection connection, int flags, int targetUserId);
345    List<UserHandle> getBindDeviceAdminTargetUsers(in ComponentName admin);
346
347    long getLastSecurityLogRetrievalTime();
348    long getLastBugReportRequestTime();
349    long getLastNetworkLogRetrievalTime();
350
351    boolean setResetPasswordToken(in ComponentName admin, in byte[] token);
352    boolean clearResetPasswordToken(in ComponentName admin);
353    boolean isResetPasswordTokenActive(in ComponentName admin);
354    boolean resetPasswordWithToken(in ComponentName admin, String password, in byte[] token, int flags);
355
356    boolean isCurrentInputMethodSetByOwner();
357    StringParceledListSlice getOwnerInstalledCaCerts(in UserHandle user);
358}
359