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