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