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