PackageManagerInternal.java revision 700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4b
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
17package android.content.pm;
18
19import android.content.ComponentName;
20import android.content.pm.PackageManager.NameNotFoundException;
21import android.util.SparseArray;
22
23import java.util.List;
24
25/**
26 * Package manager local system service interface.
27 *
28 * @hide Only for use within the system server.
29 */
30public 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         */
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         */
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     */
63    public abstract void setLocationPackagesProvider(PackagesProvider provider);
64
65    /**
66     * Sets the voice interaction packages provider.
67     * @param provider The packages provider.
68     */
69    public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider);
70
71    /**
72     * Sets the SMS packages provider.
73     * @param provider The packages provider.
74     */
75    public abstract void setSmsAppPackagesProvider(PackagesProvider provider);
76
77    /**
78     * Sets the dialer packages provider.
79     * @param provider The packages provider.
80     */
81    public abstract void setDialerAppPackagesProvider(PackagesProvider provider);
82
83    /**
84     * Sets the sim call manager packages provider.
85     * @param provider The packages provider.
86     */
87    public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider);
88
89    /**
90     * Sets the sync adapter packages provider.
91     * @param provider The provider.
92     */
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     */
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     */
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     */
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     */
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     */
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     */
144    public abstract ApplicationInfo getApplicationInfo(String packageName, int userId);
145
146    /**
147     * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}.
148     */
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     */
156    public abstract void setDeviceAndProfileOwnerPackages(
157            int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners);
158
159    /**
160     * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}.
161     */
162    public abstract boolean isPackageDataProtected(int userId, String packageName);
163
164    /**
165     * Gets whether the package was ever launched.
166     * @param packageName The package name.
167     * @param userId The user for which to check.
168     * @return Whether was launched.
169     */
170    public abstract boolean wasPackageEverLaunched(String packageName, int userId);
171
172    /**
173     * Grants a runtime permission
174     * @param packageName The package name.
175     * @param name The name of the permission.
176     * @param userId The userId for which to grant the permission.
177     * @param overridePolicy If true, grant this permission even if it is fixed by policy.
178     */
179    public abstract void grantRuntimePermission(String packageName, String name, int userId,
180            boolean overridePolicy);
181
182    /**
183     * Revokes a runtime permission
184     * @param packageName The package name.
185     * @param name The name of the permission.
186     * @param userId The userId for which to revoke the permission.
187     * @param overridePolicy If true, revoke this permission even if it is fixed by policy.
188     */
189    public abstract void revokeRuntimePermission(String packageName, String name, int userId,
190            boolean overridePolicy);
191
192}
193