Home | History | Annotate | Download | only in admin
      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 say that an action is disallowed by
     84      * the device/profile owner.
     85      *
     86      * <p>This method does not take the DPMS lock.  Safe to be called from anywhere.
     87      * @param userId The user where the action is disallowed.
     88      * @param useDefaultIfNoAdmin If true, a non-null intent will be returned, even if we couldn't
     89      * find a profile/device owner.
     90      * @return The intent to trigger the admin support dialog.
     91      */
     92     public abstract Intent createShowAdminSupportIntent(int userId, boolean useDefaultIfNoAdmin);
     93 
     94     /**
     95      * Creates an intent to show the admin support dialog showing the admin who has set a user
     96      * restriction.
     97      *
     98      * <p>This method does not take the DPMS lock. Safe to be called from anywhere.
     99      * @param userId The user where the user restriction is set.
    100      * @return The intent to trigger the admin support dialog, or null if the user restriction is
    101      * not enforced by the profile/device owner.
    102      */
    103     public abstract Intent createUserRestrictionSupportIntent(int userId, String userRestriction);
    104 }
    105