ApplicationFeatureProvider.java revision d7414259d03f00b08d2ad4bc223ff1d417c4c4a8
1/*
2 * Copyright (C) 2016 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
17package com.android.settings.applications;
18
19import android.annotation.UserIdInt;
20import android.app.Fragment;
21import android.content.Intent;
22import android.view.View;
23
24import com.android.settings.applications.instantapps.InstantAppButtonsController;
25
26import java.util.List;
27
28public interface ApplicationFeatureProvider {
29
30    /**
31     * Returns a new {@link InstantAppButtonsController} instance for showing buttons
32     * only relevant to instant apps.
33     */
34    InstantAppButtonsController newInstantAppButtonsController(Fragment fragment,
35            View view, InstantAppButtonsController.ShowDialogDelegate showDialogDelegate);
36
37    /**
38     * Calculates the total number of apps installed on the device via policy in the current user
39     * and all its managed profiles.
40     *
41     * @param async    Whether to count asynchronously in a background thread
42     * @param callback The callback to invoke with the result
43     */
44    void calculateNumberOfPolicyInstalledApps(boolean async, NumberOfAppsCallback callback);
45
46    /**
47     * Asynchronously builds the list of apps installed on the device via policy in the current user
48     * and all its managed profiles.
49     *
50     * @param callback The callback to invoke with the result
51     */
52    void listPolicyInstalledApps(ListOfAppsCallback callback);
53
54    /**
55     * Asynchronously calculates the total number of apps installed in the current user and all its
56     * managed profiles that have been granted one or more of the given permissions by the admin.
57     *
58     * @param permissions Only consider apps that have been granted one or more of these
59     *                    permissions by the admin, either at run-time or install-time
60     * @param async       Whether to count asynchronously in a background thread
61     * @param callback    The callback to invoke with the result
62     */
63    void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions, boolean async,
64            NumberOfAppsCallback callback);
65
66    /**
67     * Asynchronously builds the list of apps installed in the current user and all its
68     * managed profiles that have been granted one or more of the given permissions by the admin.
69     *
70     * @param permissions Only consider apps that have been granted one or more of these
71     *                    permissions by the admin, either at run-time or install-time
72     * @param callback    The callback to invoke with the result
73     */
74    void listAppsWithAdminGrantedPermissions(String[] permissions, ListOfAppsCallback callback);
75
76    /**
77     * Return the persistent preferred activities configured by the admin for the given user.
78     * A persistent preferred activity is an activity that the admin configured to always handle a
79     * given intent (e.g. open browser), even if the user has other apps installed that would also
80     * be able to handle the intent.
81     *
82     * @param userId  ID of the user for which to find persistent preferred activities
83     * @param intents The intents for which to find persistent preferred activities
84     * @return the persistent preferred activities for the given intents, ordered first by user id,
85     * then by package name
86     */
87    List<UserAppInfo> findPersistentPreferredActivities(@UserIdInt int userId, Intent[] intents);
88
89    /**
90     * Callback that receives the number of packages installed on the device.
91     */
92    interface NumberOfAppsCallback {
93        void onNumberOfAppsResult(int num);
94    }
95
96    /**
97     * Callback that receives the list of packages installed on the device.
98     */
99    interface ListOfAppsCallback {
100        void onListOfAppsResult(List<UserAppInfo> result);
101    }
102}
103