ApplicationFeatureProvider.java revision b836da263d8559255c528fe68410649d979cf123
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 com.android.settings.applications.instantapps.InstantAppButtonsController; 20 21import android.app.Fragment; 22import android.content.Intent; 23import android.view.View; 24 25import java.util.Set; 26 27public interface ApplicationFeatureProvider { 28 29 /** 30 * Returns a new {@link AppHeaderController} instance to customize app header. 31 */ 32 AppHeaderController newAppHeaderController(Fragment fragment, View appHeader); 33 34 /** 35 * 36 * Returns a new {@link InstantAppButtonsController} instance for showing buttons 37 * only relevant to instant apps. 38 */ 39 InstantAppButtonsController newInstantAppButtonsController(Fragment fragment, 40 View view); 41 42 /** 43 * Calculates the total number of apps installed on the device via policy in the current user 44 * and all its managed profiles. 45 * 46 * @param async Whether to count asynchronously in a background thread 47 * @param callback The callback to invoke with the result 48 */ 49 void calculateNumberOfPolicyInstalledApps(boolean async, NumberOfAppsCallback callback); 50 51 /** 52 * Asynchronously calculates the total number of apps installed in the current user and all its 53 * managed profiles that have been granted one or more of the given permissions by the admin. 54 * 55 * @param permissions Only consider apps that have been granted one or more of these permissions 56 * by the admin, either at run-time or install-time 57 * @param async Whether to count asynchronously in a background thread 58 * @param callback The callback to invoke with the result 59 */ 60 void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions, boolean async, 61 NumberOfAppsCallback callback); 62 63 /** 64 * Return the persistent preferred activities configured by the admin for the current user and 65 * all its managed profiles. A persistent preferred activity is an activity that the admin 66 * configured to always handle a given intent (e.g. open browser), even if the user has other 67 * apps installed that would also be able to handle the intent. 68 * 69 * @param intent The intents for which to find persistent preferred activities 70 * 71 * @return the persistent preferred activites for the given intent 72 */ 73 Set<PersistentPreferredActivityInfo> findPersistentPreferredActivities(Intent[] intents); 74 75 /** 76 * Callback that receives the number of packages installed on the device. 77 */ 78 interface NumberOfAppsCallback { 79 void onNumberOfAppsResult(int num); 80 } 81 82 public static class PersistentPreferredActivityInfo { 83 public final String packageName; 84 public final int userId; 85 86 public PersistentPreferredActivityInfo(String packageName, int userId) { 87 this.packageName = packageName; 88 this.userId = userId; 89 } 90 91 @Override 92 public boolean equals(Object other) { 93 if (!(other instanceof PersistentPreferredActivityInfo)) { 94 return false; 95 } 96 final PersistentPreferredActivityInfo otherActivityInfo 97 = (PersistentPreferredActivityInfo) other; 98 return otherActivityInfo.packageName.equals(packageName) 99 && otherActivityInfo.userId == userId; 100 } 101 102 @Override 103 public int hashCode() { 104 return packageName.hashCode() ^ userId; 105 } 106 } 107} 108