Todd Kennedy | 757186e | 2017-08-02 07:49:20 -0700 | [diff] [blame] | 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 | |
Yan Wang | 3468414 | 2020-03-04 15:37:55 -0800 | [diff] [blame] | 20 | import android.content.pm.IPackageChangeObserver; |
| 21 | |
Todd Kennedy | 757186e | 2017-08-02 07:49:20 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Parallel implementation of certain {@link PackageManager} APIs that need to |
| 24 | * be exposed to native code. |
| 25 | * <p>These APIs are a parallel definition to the APIs in PackageManager, so, |
| 26 | * they can technically diverge. However, it's good practice to keep these |
| 27 | * APIs in sync with each other. |
| 28 | * <p>Because these APIs are exposed to native code, it's possible they will |
| 29 | * be exposed to privileged components [such as UID 0]. Care should be taken |
| 30 | * to avoid exposing potential security holes for methods where permission |
| 31 | * checks are bypassed based upon UID alone. |
| 32 | * |
| 33 | * @hide |
| 34 | */ |
| 35 | interface IPackageManagerNative { |
| 36 | /** |
| 37 | * Returns a set of names for the given UIDs. |
| 38 | * IMPORTANT: Unlike the Java version of this API, unknown UIDs are |
| 39 | * not represented by 'null's. Instead, they are represented by empty |
| 40 | * strings. |
| 41 | */ |
| 42 | @utf8InCpp String[] getNamesForUids(in int[] uids); |
Ray Essick | 13afdfc | 2017-09-19 08:49:23 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Returns the name of the installer (a package) which installed the named |
| 46 | * package. Preloaded packages return the string "preload". Sideloaded packages |
| 47 | * return an empty string. Unknown or unknowable are returned as empty strings. |
| 48 | */ |
| 49 | |
| 50 | @utf8InCpp String getInstallerForPackage(in String packageName); |
| 51 | |
| 52 | /** |
| 53 | * Returns the version code of the named package. |
| 54 | * Unknown or unknowable versions are returned as 0. |
| 55 | */ |
| 56 | |
Dianne Hackborn | e2a8e8d | 2017-11-27 14:02:15 -0800 | [diff] [blame] | 57 | long getVersionCodeForPackage(in String packageName); |
Ray Essick | 13afdfc | 2017-09-19 08:49:23 -0700 | [diff] [blame] | 58 | |
Kevin Rocard | e45eb31 | 2019-02-22 09:49:24 -0800 | [diff] [blame] | 59 | /** |
| 60 | * Return if each app, identified by its package name allows its audio to be recorded. |
| 61 | * Unknown packages are mapped to false. |
| 62 | */ |
| 63 | boolean[] isAudioPlaybackCaptureAllowed(in @utf8InCpp String[] packageNames); |
Przemyslaw Szczepaniak | 097e295 | 2019-03-07 11:04:18 +0000 | [diff] [blame] | 64 | |
| 65 | /* ApplicationInfo.isSystemApp() == true */ |
| 66 | const int LOCATION_SYSTEM = 0x1; |
| 67 | /* ApplicationInfo.isVendor() == true */ |
| 68 | const int LOCATION_VENDOR = 0x2; |
| 69 | /* ApplicationInfo.isProduct() == true */ |
| 70 | const int LOCATION_PRODUCT = 0x4; |
Przemyslaw Szczepaniak | 097e295 | 2019-03-07 11:04:18 +0000 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Returns a set of bitflags about package location. |
| 74 | * LOCATION_SYSTEM: getApplicationInfo(packageName).isSystemApp() |
| 75 | * LOCATION_VENDOR: getApplicationInfo(packageName).isVendor() |
| 76 | * LOCATION_PRODUCT: getApplicationInfo(packageName).isProduct() |
Przemyslaw Szczepaniak | 097e295 | 2019-03-07 11:04:18 +0000 | [diff] [blame] | 77 | */ |
| 78 | int getLocationFlags(in @utf8InCpp String packageName); |
Brian Stack | 7aa40b6 | 2019-04-18 17:14:59 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * Returns the target SDK version for the given package. |
| 82 | * Unknown packages will cause the call to fail. The caller must check the |
| 83 | * returned Status before using the result of this function. |
| 84 | */ |
| 85 | int getTargetSdkVersionForPackage(in String packageName); |
Nikita Ioffe | 535e1ac | 2019-05-16 18:16:59 +0100 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Returns the name of module metadata package, or empty string if device doesn't have such |
| 89 | * package. |
| 90 | */ |
| 91 | @utf8InCpp String getModuleMetadataPackageName(); |
Yan Wang | 7851e17 | 2020-02-04 11:44:03 -0800 | [diff] [blame] | 92 | |
| 93 | /* Returns the names of all packages. */ |
| 94 | @utf8InCpp String[] getAllPackages(); |
Yan Wang | 3468414 | 2020-03-04 15:37:55 -0800 | [diff] [blame] | 95 | |
| 96 | /** Register an extra package change observer to receive the multi-cast. */ |
| 97 | void registerPackageChangeObserver(in IPackageChangeObserver observer); |
| 98 | |
| 99 | /** |
| 100 | * Unregister an existing package change observer. |
| 101 | * This does nothing if this observer was not already registered. |
| 102 | */ |
| 103 | void unregisterPackageChangeObserver(in IPackageChangeObserver observer); |
Todd Kennedy | 757186e | 2017-08-02 07:49:20 -0700 | [diff] [blame] | 104 | } |