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.IStagedApexObserver; 21 import android.content.pm.StagedApexInfo; 22 23 /** 24 * Parallel implementation of certain {@link PackageManager} APIs that need to 25 * be exposed to native code. 26 * <p>These APIs are a parallel definition to the APIs in PackageManager, so, 27 * they can technically diverge. However, it's good practice to keep these 28 * APIs in sync with each other. 29 * <p>Because these APIs are exposed to native code, it's possible they will 30 * be exposed to privileged components [such as UID 0]. Care should be taken 31 * to avoid exposing potential security holes for methods where permission 32 * checks are bypassed based upon UID alone. 33 * 34 * @hide 35 */ 36 interface IPackageManagerNative { 37 /** 38 * Returns a set of names for the given UIDs. 39 * IMPORTANT: Unlike the Java version of this API, unknown UIDs are 40 * not represented by 'null's. Instead, they are represented by empty 41 * strings. 42 */ getNamesForUids(in int[] uids)43 @utf8InCpp String[] getNamesForUids(in int[] uids); 44 45 /** 46 * Returns the name of the installer (a package) which installed the named 47 * package. Preloaded packages return the string "preload". Sideloaded packages 48 * return an empty string. Unknown or unknowable are returned as empty strings. 49 */ 50 getInstallerForPackage(in String packageName)51 @utf8InCpp String getInstallerForPackage(in String packageName); 52 53 /** 54 * Returns the version code of the named package. 55 * Unknown or unknowable versions are returned as 0. 56 */ 57 getVersionCodeForPackage(in String packageName)58 long getVersionCodeForPackage(in String packageName); 59 60 /** 61 * Return if each app, identified by its package name allows its audio to be recorded. 62 * Unknown packages are mapped to false. 63 */ isAudioPlaybackCaptureAllowed(in @tf8InCpp String[] packageNames)64 boolean[] isAudioPlaybackCaptureAllowed(in @utf8InCpp String[] packageNames); 65 66 /* ApplicationInfo.isSystemApp() == true */ 67 const int LOCATION_SYSTEM = 0x1; 68 /* ApplicationInfo.isVendor() == true */ 69 const int LOCATION_VENDOR = 0x2; 70 /* ApplicationInfo.isProduct() == true */ 71 const int LOCATION_PRODUCT = 0x4; 72 73 /** 74 * Returns a set of bitflags about package location. 75 * LOCATION_SYSTEM: getApplicationInfo(packageName).isSystemApp() 76 * LOCATION_VENDOR: getApplicationInfo(packageName).isVendor() 77 * LOCATION_PRODUCT: getApplicationInfo(packageName).isProduct() 78 */ getLocationFlags(in @tf8InCpp String packageName)79 int getLocationFlags(in @utf8InCpp String packageName); 80 81 /** 82 * Returns the target SDK version for the given package. 83 * Unknown packages will cause the call to fail. The caller must check the 84 * returned Status before using the result of this function. 85 */ getTargetSdkVersionForPackage(in String packageName)86 int getTargetSdkVersionForPackage(in String packageName); 87 88 /** 89 * Returns the name of module metadata package, or empty string if device doesn't have such 90 * package. 91 */ getModuleMetadataPackageName()92 @utf8InCpp String getModuleMetadataPackageName(); 93 94 /** 95 * Returns true if the package has the SHA 256 version of the signing certificate. 96 * @see PackageManager#hasSigningCertificate(String, byte[], int), where type 97 * has been set to {@link PackageManager#CERT_INPUT_SHA256}. 98 */ hasSha256SigningCertificate(in @tf8InCpp String packageName, in byte[] certificate)99 boolean hasSha256SigningCertificate(in @utf8InCpp String packageName, in byte[] certificate); 100 101 /** 102 * Returns the debug flag for the given package. 103 * Unknown packages will cause the call to fail. 104 */ isPackageDebuggable(in String packageName)105 boolean isPackageDebuggable(in String packageName); 106 107 /** 108 * Check whether the given feature name and version is one of the available 109 * features as returned by {@link PackageManager#getSystemAvailableFeatures()}. Since 110 * features are defined to always be backwards compatible, this returns true 111 * if the available feature version is greater than or equal to the 112 * requested version. 113 */ hasSystemFeature(in String featureName, in int version)114 boolean hasSystemFeature(in String featureName, in int version); 115 116 /** Register a observer for change in set of staged APEX ready for installation */ registerStagedApexObserver(in IStagedApexObserver observer)117 void registerStagedApexObserver(in IStagedApexObserver observer); 118 119 /** 120 * Unregister an existing staged apex observer. 121 * This does nothing if this observer was not already registered. 122 */ unregisterStagedApexObserver(in IStagedApexObserver observer)123 void unregisterStagedApexObserver(in IStagedApexObserver observer); 124 125 /** 126 * Get APEX module names of all APEX that are staged ready for installation 127 */ getStagedApexModuleNames()128 @utf8InCpp String[] getStagedApexModuleNames(); 129 130 /** 131 * Get information of APEX which is staged ready for installation. 132 * Returns null if no such APEX is found. 133 */ getStagedApexInfo(in @tf8InCpp String moduleName)134 @nullable StagedApexInfo getStagedApexInfo(in @utf8InCpp String moduleName); 135 } 136