1 /*
2  * Copyright (C) 2015 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 android.content.pm;
18 
19 import android.content.ComponentName;
20 import android.content.pm.PackageManager.NameNotFoundException;
21 import android.util.SparseArray;
22 
23 import java.util.List;
24 
25 /**
26  * Package manager local system service interface.
27  *
28  * @hide Only for use within the system server.
29  */
30 public abstract class PackageManagerInternal {
31 
32     /**
33      * Provider for package names.
34      */
35     public interface PackagesProvider {
36 
37         /**
38          * Gets the packages for a given user.
39          * @param userId The user id.
40          * @return The package names.
41          */
getPackages(int userId)42         public String[] getPackages(int userId);
43     }
44 
45     /**
46      * Provider for package names.
47      */
48     public interface SyncAdapterPackagesProvider {
49 
50         /**
51          * Gets the sync adapter packages for given authority and user.
52          * @param authority The authority.
53          * @param userId The user id.
54          * @return The package names.
55          */
getPackages(String authority, int userId)56         public String[] getPackages(String authority, int userId);
57     }
58 
59     /**
60      * Sets the location provider packages provider.
61      * @param provider The packages provider.
62      */
setLocationPackagesProvider(PackagesProvider provider)63     public abstract void setLocationPackagesProvider(PackagesProvider provider);
64 
65     /**
66      * Sets the voice interaction packages provider.
67      * @param provider The packages provider.
68      */
setVoiceInteractionPackagesProvider(PackagesProvider provider)69     public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider);
70 
71     /**
72      * Sets the SMS packages provider.
73      * @param provider The packages provider.
74      */
setSmsAppPackagesProvider(PackagesProvider provider)75     public abstract void setSmsAppPackagesProvider(PackagesProvider provider);
76 
77     /**
78      * Sets the dialer packages provider.
79      * @param provider The packages provider.
80      */
setDialerAppPackagesProvider(PackagesProvider provider)81     public abstract void setDialerAppPackagesProvider(PackagesProvider provider);
82 
83     /**
84      * Sets the sim call manager packages provider.
85      * @param provider The packages provider.
86      */
setSimCallManagerPackagesProvider(PackagesProvider provider)87     public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider);
88 
89     /**
90      * Sets the sync adapter packages provider.
91      * @param provider The provider.
92      */
setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider)93     public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider);
94 
95     /**
96      * Requests granting of the default permissions to the current default SMS app.
97      * @param packageName The default SMS package name.
98      * @param userId The user for which to grant the permissions.
99      */
grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId)100     public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId);
101 
102     /**
103      * Requests granting of the default permissions to the current default dialer app.
104      * @param packageName The default dialer package name.
105      * @param userId The user for which to grant the permissions.
106      */
grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId)107     public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId);
108 
109     /**
110      * Requests granting of the default permissions to the current default sim call manager.
111      * @param packageName The default sim call manager package name.
112      * @param userId The user for which to grant the permissions.
113      */
grantDefaultPermissionsToDefaultSimCallManager(String packageName, int userId)114     public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName,
115             int userId);
116 
117     /**
118      * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has
119      * currently installed it. The apps are not preloaded.
120      * @param packageList List of package names to keep cached.
121      */
setKeepUninstalledPackages(List<String> packageList)122     public abstract void setKeepUninstalledPackages(List<String> packageList);
123 
124     /**
125      * Gets whether some of the permissions used by this package require a user
126      * review before any of the app components can run.
127      * @param packageName The package name for which to check.
128      * @param userId The user under which to check.
129      * @return True a permissions review is required.
130      */
isPermissionsReviewRequired(String packageName, int userId)131     public abstract boolean isPermissionsReviewRequired(String packageName, int userId);
132 
133     /**
134      * Gets all of the information we know about a particular package.
135      *
136      * @param packageName The package name to find.
137      * @param userId The user under which to check.
138      *
139      * @return An {@link ApplicationInfo} containing information about the
140      *         package.
141      * @throws NameNotFoundException if a package with the given name cannot be
142      *             found on the system.
143      */
getApplicationInfo(String packageName, int userId)144     public abstract ApplicationInfo getApplicationInfo(String packageName, int userId);
145 
146     /**
147      * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}.
148      */
getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, int userId)149     public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates,
150             int userId);
151 
152     /**
153      * Called by DeviceOwnerManagerService to set the package names of device owner and profile
154      * owners.
155      */
setDeviceAndProfileOwnerPackages( int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners)156     public abstract void setDeviceAndProfileOwnerPackages(
157             int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners);
158 
159     /**
160      * Whether a package's data be cleared.
161      */
canPackageBeWiped(int userId, String packageName)162     public abstract boolean canPackageBeWiped(int userId, String packageName);
163 }
164