1 /* 2 * Copyright (C) 2014 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 17 package android.app.admin; 18 19 import android.content.Intent; 20 21 import java.util.List; 22 23 /** 24 * Device policy manager local system service interface. 25 * 26 * @hide Only for use within the system server. 27 */ 28 public abstract class DevicePolicyManagerInternal { 29 30 /** 31 * Listener for changes in the white-listed packages to show cross-profile 32 * widgets. 33 */ 34 public interface OnCrossProfileWidgetProvidersChangeListener { 35 36 /** 37 * Called when the white-listed packages to show cross-profile widgets 38 * have changed for a given user. 39 * 40 * @param profileId The profile for which the white-listed packages changed. 41 * @param packages The white-listed packages. 42 */ 43 public void onCrossProfileWidgetProvidersChanged(int profileId, List<String> packages); 44 } 45 46 /** 47 * Gets the packages whose widget providers are white-listed to be 48 * available in the parent user. 49 * 50 * <p>This takes the DPMS lock. DO NOT call from PM/UM/AM with their lock held. 51 * 52 * @param profileId The profile id. 53 * @return The list of packages if such or empty list if there are 54 * no white-listed packages or the profile id is not a managed 55 * profile. 56 */ 57 public abstract List<String> getCrossProfileWidgetProviders(int profileId); 58 59 /** 60 * Adds a listener for changes in the white-listed packages to show 61 * cross-profile app widgets. 62 * 63 * <p>This takes the DPMS lock. DO NOT call from PM/UM/AM with their lock held. 64 * 65 * @param listener The listener to add. 66 */ 67 public abstract void addOnCrossProfileWidgetProvidersChangeListener( 68 OnCrossProfileWidgetProvidersChangeListener listener); 69 70 /** 71 * Checks if an app with given uid is an active device admin of its user and has the policy 72 * specified. 73 * 74 * <p>This takes the DPMS lock. DO NOT call from PM/UM/AM with their lock held. 75 * 76 * @param uid App uid. 77 * @param reqPolicy Required policy, for policies see {@link DevicePolicyManager}. 78 * @return true if the uid is an active admin with the given policy. 79 */ 80 public abstract boolean isActiveAdminWithPolicy(int uid, int reqPolicy); 81 82 /** 83 * Creates an intent to show the admin support dialog to let the user know that the package is 84 * suspended by the admin. This assumes that {@param packageName} is suspended by the 85 * device/profile owner. The caller should check if the package is suspended or not. 86 * 87 * <p>This method does not take the DPMS lock. Safe to be called from anywhere. 88 * 89 * @param packageName The package that is suspended 90 * @param userId The user having the suspended package. 91 * @return The intent to trigger the admin support dialog. 92 */ 93 public abstract Intent createPackageSuspendedDialogIntent(String packageName, int userId); 94 } 95