• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 **
3 ** Copyright 2017, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 package android.content.pm;
19 
20 import android.content.pm.IPackageChangeObserver;
21 import android.content.pm.IStagedApexObserver;
22 import android.content.pm.StagedApexInfo;
23 
24 /**
25  * Parallel implementation of certain {@link PackageManager} APIs that need to
26  * be exposed to native code.
27  * <p>These APIs are a parallel definition to the APIs in PackageManager, so,
28  * they can technically diverge. However, it's good practice to keep these
29  * APIs in sync with each other.
30  * <p>Because these APIs are exposed to native code, it's possible they will
31  * be exposed to privileged components [such as UID 0]. Care should be taken
32  * to avoid exposing potential security holes for methods where permission
33  * checks are bypassed based upon UID alone.
34  *
35  * @hide
36  */
37 interface IPackageManagerNative {
38     /**
39      * Returns a set of names for the given UIDs.
40      * IMPORTANT: Unlike the Java version of this API, unknown UIDs are
41      * not represented by 'null's. Instead, they are represented by empty
42      * strings.
43      */
getNamesForUids(in int[] uids)44     @utf8InCpp String[] getNamesForUids(in int[] uids);
45 
46     /**
47      * Returns the name of the installer (a package) which installed the named
48      * package. Preloaded packages return the string "preload". Sideloaded packages
49      * return an empty string. Unknown or unknowable are returned as empty strings.
50      */
51 
getInstallerForPackage(in String packageName)52     @utf8InCpp String getInstallerForPackage(in String packageName);
53 
54     /**
55      * Returns the version code of the named package.
56      * Unknown or unknowable versions are returned as 0.
57      */
58 
getVersionCodeForPackage(in String packageName)59     long getVersionCodeForPackage(in String packageName);
60 
61     /**
62      * Return if each app, identified by its package name allows its audio to be recorded.
63      * Unknown packages are mapped to false.
64      */
isAudioPlaybackCaptureAllowed(in @tf8InCpp String[] packageNames)65     boolean[] isAudioPlaybackCaptureAllowed(in @utf8InCpp String[] packageNames);
66 
67     /*  ApplicationInfo.isSystemApp() == true */
68     const int LOCATION_SYSTEM = 0x1;
69     /*  ApplicationInfo.isVendor() == true */
70     const int LOCATION_VENDOR = 0x2;
71     /*  ApplicationInfo.isProduct() == true */
72     const int LOCATION_PRODUCT = 0x4;
73 
74     /**
75      * Returns a set of bitflags about package location.
76      * LOCATION_SYSTEM: getApplicationInfo(packageName).isSystemApp()
77      * LOCATION_VENDOR: getApplicationInfo(packageName).isVendor()
78      * LOCATION_PRODUCT: getApplicationInfo(packageName).isProduct()
79      */
getLocationFlags(in @tf8InCpp String packageName)80     int getLocationFlags(in @utf8InCpp String packageName);
81 
82     /**
83      * Returns the target SDK version for the given package.
84      * Unknown packages will cause the call to fail. The caller must check the
85      * returned Status before using the result of this function.
86      */
getTargetSdkVersionForPackage(in String packageName)87     int getTargetSdkVersionForPackage(in String packageName);
88 
89     /**
90      * Returns the name of module metadata package, or empty string if device doesn't have such
91      * package.
92      */
getModuleMetadataPackageName()93     @utf8InCpp String getModuleMetadataPackageName();
94 
95     /* Returns the names of all packages. */
getAllPackages()96     @utf8InCpp String[] getAllPackages();
97 
98     /** Register an extra package change observer to receive the multi-cast. */
registerPackageChangeObserver(in IPackageChangeObserver observer)99     void registerPackageChangeObserver(in IPackageChangeObserver observer);
100 
101     /**
102      * Unregister an existing package change observer.
103      * This does nothing if this observer was not already registered.
104      */
unregisterPackageChangeObserver(in IPackageChangeObserver observer)105     void unregisterPackageChangeObserver(in IPackageChangeObserver observer);
106 
107     /**
108      * Returns true if the package has the SHA 256 version of the signing certificate.
109      * @see PackageManager#hasSigningCertificate(String, byte[], int), where type
110      * has been set to {@link PackageManager#CERT_INPUT_SHA256}.
111      */
hasSha256SigningCertificate(in @tf8InCpp String packageName, in byte[] certificate)112     boolean hasSha256SigningCertificate(in @utf8InCpp String packageName, in byte[] certificate);
113 
114     /**
115      * Returns the debug flag for the given package.
116      * Unknown packages will cause the call to fail.
117      */
isPackageDebuggable(in String packageName)118     boolean isPackageDebuggable(in String packageName);
119 
120     /**
121      * Check whether the given feature name and version is one of the available
122      * features as returned by {@link PackageManager#getSystemAvailableFeatures()}. Since
123      * features are defined to always be backwards compatible, this returns true
124      * if the available feature version is greater than or equal to the
125      * requested version.
126      */
hasSystemFeature(in String featureName, in int version)127     boolean hasSystemFeature(in String featureName, in int version);
128 
129     /** Register a observer for change in set of staged APEX ready for installation */
registerStagedApexObserver(in IStagedApexObserver observer)130     void registerStagedApexObserver(in IStagedApexObserver observer);
131 
132     /**
133      * Unregister an existing staged apex observer.
134      * This does nothing if this observer was not already registered.
135      */
unregisterStagedApexObserver(in IStagedApexObserver observer)136     void unregisterStagedApexObserver(in IStagedApexObserver observer);
137 
138     /**
139      * Get APEX module names of all APEX that are staged ready for installation
140      */
getStagedApexModuleNames()141     @utf8InCpp String[] getStagedApexModuleNames();
142 
143     /**
144      * Get information of APEX which is staged ready for installation.
145      * Returns null if no such APEX is found.
146      */
getStagedApexInfo(in @tf8InCpp String moduleName)147     @nullable StagedApexInfo getStagedApexInfo(in @utf8InCpp String moduleName);
148 }
149