1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org
.chromium
.android
.support
;
7 import android
.content
.ComponentName
;
8 import android
.content
.Intent
;
9 import android
.content
.IntentFilter
;
10 import android
.content
.pm
.ActivityInfo
;
11 import android
.content
.pm
.ApplicationInfo
;
12 import android
.content
.pm
.ChangedPackages
;
13 import android
.content
.pm
.FeatureInfo
;
14 import android
.content
.pm
.InstrumentationInfo
;
15 import android
.content
.pm
.PackageInfo
;
16 import android
.content
.pm
.PackageInstaller
;
17 import android
.content
.pm
.PackageManager
;
18 import android
.content
.pm
.PermissionGroupInfo
;
19 import android
.content
.pm
.PermissionInfo
;
20 import android
.content
.pm
.ProviderInfo
;
21 import android
.content
.pm
.ResolveInfo
;
22 import android
.content
.pm
.ServiceInfo
;
23 import android
.content
.pm
.SharedLibraryInfo
;
24 import android
.content
.pm
.VersionedPackage
;
25 import android
.content
.res
.Resources
;
26 import android
.content
.res
.XmlResourceParser
;
27 import android
.graphics
.Rect
;
28 import android
.graphics
.drawable
.Drawable
;
29 import android
.os
.UserHandle
;
31 import java
.util
.List
;
33 // TODO(jbudorick): Remove this once a newer version of the multidex support
34 // library is released.
35 public class PackageManagerWrapper
extends PackageManager
{
36 private PackageManager mWrapped
;
38 public PackageManagerWrapper(PackageManager wrapped
) {
45 public void addPackageToPreferred(String packageName
) {
46 mWrapped
.addPackageToPreferred(packageName
);
50 public boolean addPermission(PermissionInfo info
) {
51 return mWrapped
.addPermission(info
);
55 public boolean addPermissionAsync(PermissionInfo info
) {
56 return mWrapped
.addPermissionAsync(info
);
61 public void addPreferredActivity(
62 IntentFilter filter
, int match
, ComponentName
[] set
, ComponentName activity
) {
63 mWrapped
.addPreferredActivity(filter
, match
, set
, activity
);
67 public String
[] canonicalToCurrentPackageNames(String
[] names
) {
68 return mWrapped
.canonicalToCurrentPackageNames(names
);
72 public int checkPermission(String permName
, String pkgName
) {
73 return mWrapped
.checkPermission(permName
, pkgName
);
77 public int checkSignatures(String pkg1
, String pkg2
) {
78 return mWrapped
.checkSignatures(pkg1
, pkg2
);
82 public int checkSignatures(int uid1
, int uid2
) {
83 return mWrapped
.checkSignatures(uid1
, uid2
);
87 public void clearInstantAppCookie() {
88 mWrapped
.clearInstantAppCookie();
92 public String
[] currentToCanonicalPackageNames(String
[] names
) {
93 return mWrapped
.currentToCanonicalPackageNames(names
);
97 public ActivityInfo
getActivityInfo(ComponentName component
, int flags
)
98 throws NameNotFoundException
{
99 return mWrapped
.getActivityInfo(component
, flags
);
103 public List
<PermissionGroupInfo
> getAllPermissionGroups(int flags
) {
104 return mWrapped
.getAllPermissionGroups(flags
);
108 public ApplicationInfo
getApplicationInfo(String packageName
, int flags
)
109 throws NameNotFoundException
{
110 return mWrapped
.getApplicationInfo(packageName
, flags
);
114 public List
<PackageInfo
> getInstalledPackages(int flags
) {
115 return mWrapped
.getInstalledPackages(flags
);
119 public Intent
getLaunchIntentForPackage(String packageName
) {
120 return mWrapped
.getLaunchIntentForPackage(packageName
);
124 public Intent
getLeanbackLaunchIntentForPackage(String packageName
) {
125 return mWrapped
.getLeanbackLaunchIntentForPackage(packageName
);
129 public int[] getPackageGids(String packageName
) throws NameNotFoundException
{
130 return mWrapped
.getPackageGids(packageName
);
134 public int[] getPackageGids(String packageName
, int flags
) throws NameNotFoundException
{
135 return mWrapped
.getPackageGids(packageName
, flags
);
139 public PackageInfo
getPackageInfo(String packageName
, int flags
) throws NameNotFoundException
{
140 return mWrapped
.getPackageInfo(packageName
, flags
);
144 public int getPackageUid(String packageName
, int flags
) throws NameNotFoundException
{
145 return mWrapped
.getPackageUid(packageName
, flags
);
149 public List
<PackageInfo
> getPackagesHoldingPermissions(String
[] permissions
, int flags
) {
150 return mWrapped
.getPackagesHoldingPermissions(permissions
, flags
);
154 public PermissionGroupInfo
getPermissionGroupInfo(String name
, int flags
)
155 throws NameNotFoundException
{
156 return mWrapped
.getPermissionGroupInfo(name
, flags
);
160 public PermissionInfo
getPermissionInfo(String name
, int flags
) throws NameNotFoundException
{
161 return mWrapped
.getPermissionInfo(name
, flags
);
165 public ProviderInfo
getProviderInfo(ComponentName component
, int flags
)
166 throws NameNotFoundException
{
167 return mWrapped
.getProviderInfo(component
, flags
);
171 public ActivityInfo
getReceiverInfo(ComponentName component
, int flags
)
172 throws NameNotFoundException
{
173 return mWrapped
.getReceiverInfo(component
, flags
);
177 public ServiceInfo
getServiceInfo(ComponentName component
, int flags
)
178 throws NameNotFoundException
{
179 return mWrapped
.getServiceInfo(component
, flags
);
183 public boolean isPermissionRevokedByPolicy(String permName
, String pkgName
) {
184 return mWrapped
.isPermissionRevokedByPolicy(permName
, pkgName
);
188 public List
<PermissionInfo
> queryPermissionsByGroup(String group
, int flags
)
189 throws NameNotFoundException
{
190 return mWrapped
.queryPermissionsByGroup(group
, flags
);
194 public void removePermission(String name
) {
195 mWrapped
.removePermission(name
);
199 public String
[] getPackagesForUid(int uid
) {
200 return mWrapped
.getPackagesForUid(uid
);
204 public String
getNameForUid(int uid
) {
205 return mWrapped
.getNameForUid(uid
);
209 public List
<ApplicationInfo
> getInstalledApplications(int flags
) {
210 return mWrapped
.getInstalledApplications(flags
);
214 public String
[] getSystemSharedLibraryNames() {
215 return mWrapped
.getSystemSharedLibraryNames();
219 public FeatureInfo
[] getSystemAvailableFeatures() {
220 return mWrapped
.getSystemAvailableFeatures();
224 public boolean hasSystemFeature(String name
) {
225 return mWrapped
.hasSystemFeature(name
);
229 public boolean hasSystemFeature(String name
, int version
) {
230 return mWrapped
.hasSystemFeature(name
, version
);
234 public ResolveInfo
resolveActivity(Intent intent
, int flags
) {
235 return mWrapped
.resolveActivity(intent
, flags
);
239 public List
<ResolveInfo
> queryIntentActivities(Intent intent
, int flags
) {
240 return mWrapped
.queryIntentActivities(intent
, flags
);
244 public List
<ResolveInfo
> queryIntentActivityOptions(
245 ComponentName caller
, Intent
[] specifics
, Intent intent
, int flags
) {
246 return mWrapped
.queryIntentActivityOptions(caller
, specifics
, intent
, flags
);
250 public List
<ResolveInfo
> queryBroadcastReceivers(Intent intent
, int flags
) {
251 return mWrapped
.queryBroadcastReceivers(intent
, flags
);
255 public ResolveInfo
resolveService(Intent intent
, int flags
) {
256 return mWrapped
.resolveService(intent
, flags
);
260 public List
<ResolveInfo
> queryIntentServices(Intent intent
, int flags
) {
261 return mWrapped
.queryIntentServices(intent
, flags
);
265 public List
<ResolveInfo
> queryIntentContentProviders(Intent intent
, int flags
) {
266 return mWrapped
.queryIntentContentProviders(intent
, flags
);
270 public ProviderInfo
resolveContentProvider(String name
, int flags
) {
271 return mWrapped
.resolveContentProvider(name
, flags
);
275 public List
<ProviderInfo
> queryContentProviders(String processName
, int uid
, int flags
) {
276 return mWrapped
.queryContentProviders(processName
, uid
, flags
);
280 public InstrumentationInfo
getInstrumentationInfo(ComponentName className
, int flags
)
281 throws NameNotFoundException
{
282 return mWrapped
.getInstrumentationInfo(className
, flags
);
286 public List
<InstrumentationInfo
> queryInstrumentation(String targetPackage
, int flags
) {
287 return mWrapped
.queryInstrumentation(targetPackage
, flags
);
291 public Drawable
getDrawable(String packageName
, int resid
, ApplicationInfo appInfo
) {
292 return mWrapped
.getDrawable(packageName
, resid
, appInfo
);
296 public Drawable
getActivityIcon(ComponentName activityName
) throws NameNotFoundException
{
297 return mWrapped
.getActivityIcon(activityName
);
301 public Drawable
getActivityIcon(Intent intent
) throws NameNotFoundException
{
302 return mWrapped
.getActivityIcon(intent
);
306 public Drawable
getActivityBanner(ComponentName activityName
) throws NameNotFoundException
{
307 return mWrapped
.getActivityBanner(activityName
);
311 public Drawable
getActivityBanner(Intent intent
) throws NameNotFoundException
{
312 return mWrapped
.getActivityBanner(intent
);
316 public Drawable
getDefaultActivityIcon() {
317 return mWrapped
.getDefaultActivityIcon();
321 public Drawable
getApplicationIcon(ApplicationInfo info
) {
322 return mWrapped
.getApplicationIcon(info
);
326 public Drawable
getApplicationIcon(String packageName
) throws NameNotFoundException
{
327 return mWrapped
.getApplicationIcon(packageName
);
331 public Drawable
getApplicationBanner(ApplicationInfo info
) {
332 return mWrapped
.getApplicationBanner(info
);
336 public Drawable
getApplicationBanner(String packageName
) throws NameNotFoundException
{
337 return mWrapped
.getApplicationBanner(packageName
);
341 public Drawable
getActivityLogo(ComponentName activityName
) throws NameNotFoundException
{
342 return mWrapped
.getActivityLogo(activityName
);
346 public Drawable
getActivityLogo(Intent intent
) throws NameNotFoundException
{
347 return mWrapped
.getActivityLogo(intent
);
351 public Drawable
getApplicationLogo(ApplicationInfo info
) {
352 return mWrapped
.getApplicationLogo(info
);
356 public Drawable
getApplicationLogo(String packageName
) throws NameNotFoundException
{
357 return mWrapped
.getApplicationLogo(packageName
);
361 public Drawable
getUserBadgedIcon(Drawable icon
, UserHandle user
) {
362 return mWrapped
.getUserBadgedIcon(icon
, user
);
366 public Drawable
getUserBadgedDrawableForDensity(
367 Drawable drawable
, UserHandle user
, Rect badgeLocation
, int badgeDensity
) {
368 return mWrapped
.getUserBadgedDrawableForDensity(
369 drawable
, user
, badgeLocation
, badgeDensity
);
373 public CharSequence
getUserBadgedLabel(CharSequence label
, UserHandle user
) {
374 return mWrapped
.getUserBadgedLabel(label
, user
);
378 public CharSequence
getText(String packageName
, int resid
, ApplicationInfo appInfo
) {
379 return mWrapped
.getText(packageName
, resid
, appInfo
);
383 public XmlResourceParser
getXml(String packageName
, int resid
, ApplicationInfo appInfo
) {
384 return mWrapped
.getXml(packageName
, resid
, appInfo
);
388 public CharSequence
getApplicationLabel(ApplicationInfo info
) {
389 return mWrapped
.getApplicationLabel(info
);
393 public Resources
getResourcesForActivity(ComponentName activityName
)
394 throws NameNotFoundException
{
395 return mWrapped
.getResourcesForActivity(activityName
);
399 public Resources
getResourcesForApplication(ApplicationInfo app
) throws NameNotFoundException
{
400 return mWrapped
.getResourcesForApplication(app
);
404 public Resources
getResourcesForApplication(String appPackageName
)
405 throws NameNotFoundException
{
406 return mWrapped
.getResourcesForApplication(appPackageName
);
410 public void verifyPendingInstall(int id
, int verificationCode
) {
411 mWrapped
.verifyPendingInstall(id
, verificationCode
);
415 public void extendVerificationTimeout(
416 int id
, int verificationCodeAtTimeout
, long millisecondsToDelay
) {
417 mWrapped
.extendVerificationTimeout(id
, verificationCodeAtTimeout
, millisecondsToDelay
);
421 public void setInstallerPackageName(String targetPackage
, String installerPackageName
) {
422 mWrapped
.setInstallerPackageName(targetPackage
, installerPackageName
);
426 public String
getInstallerPackageName(String packageName
) {
427 return mWrapped
.getInstallerPackageName(packageName
);
432 public void removePackageFromPreferred(String packageName
) {
433 mWrapped
.removePackageFromPreferred(packageName
);
437 public List
<PackageInfo
> getPreferredPackages(int flags
) {
438 return mWrapped
.getPreferredPackages(flags
);
442 public void clearPackagePreferredActivities(String packageName
) {
443 mWrapped
.clearPackagePreferredActivities(packageName
);
447 public int getPreferredActivities(
448 List
<IntentFilter
> outFilters
, List
<ComponentName
> outActivities
, String packageName
) {
449 return mWrapped
.getPreferredActivities(outFilters
, outActivities
, packageName
);
453 public void setComponentEnabledSetting(ComponentName componentName
, int newState
, int flags
) {
454 mWrapped
.setComponentEnabledSetting(componentName
, newState
, flags
);
458 public int getComponentEnabledSetting(ComponentName componentName
) {
459 return mWrapped
.getComponentEnabledSetting(componentName
);
463 public void setApplicationEnabledSetting(String packageName
, int newState
, int flags
) {
464 mWrapped
.setApplicationEnabledSetting(packageName
, newState
, flags
);
468 public int getApplicationEnabledSetting(String packageName
) {
469 return mWrapped
.getApplicationEnabledSetting(packageName
);
473 public boolean isSafeMode() {
474 return mWrapped
.isSafeMode();
478 public PackageInstaller
getPackageInstaller() {
479 return mWrapped
.getPackageInstaller();
482 // O Developer Preview
485 public boolean canRequestPackageInstalls() {
486 return mWrapped
.canRequestPackageInstalls();
490 public ChangedPackages
getChangedPackages(int sequenceNumber
) {
491 return mWrapped
.getChangedPackages(sequenceNumber
);
495 public byte[] getInstantAppCookie() {
496 return mWrapped
.getInstantAppCookie();
500 public int getInstantAppCookieMaxBytes() {
501 return mWrapped
.getInstantAppCookieMaxBytes();
505 public PackageInfo
getPackageInfo(VersionedPackage versionedPackage
, int flags
)
506 throws PackageManager
.NameNotFoundException
{
507 return mWrapped
.getPackageInfo(versionedPackage
, flags
);
511 public List
<SharedLibraryInfo
> getSharedLibraries(int flags
) {
512 return mWrapped
.getSharedLibraries(flags
);
516 public boolean isInstantApp() {
517 return mWrapped
.isInstantApp();
521 public boolean isInstantApp(String packageName
) {
522 return mWrapped
.isInstantApp(packageName
);
526 public void setApplicationCategoryHint(String packageName
, int categoryHint
) {
527 mWrapped
.setApplicationCategoryHint(packageName
, categoryHint
);
531 public void updateInstantAppCookie(byte[] cookie
) {
532 mWrapped
.updateInstantAppCookie(cookie
);