1 /*
2  * Copyright (C) 2019 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 
17 #ifndef ANDROID_PACKAGES_MODULES_NEURALNETWORKS_RUNTIME_PACKAGEINFO_PACKAGE_INFO_H
18 #define ANDROID_PACKAGES_MODULES_NEURALNETWORKS_RUNTIME_PACKAGEINFO_PACKAGE_INFO_H
19 
20 #include <sys/cdefs.h>
21 #include <sys/types.h>
22 
23 //
24 // Define a C interface to the neuralnetworks APEX helper functionality
25 //
26 
27 __BEGIN_DECLS
28 
29 // Collection of app-related information retreived from Package Manager.
30 typedef struct ANeuralNetworks_PackageInfo {
31     // Null-terminated package name (nullptr if not an Android app).
32     // Referenced memory is allocated by the ANeuralNetworks_fetch_PackageInfo
33     // method, and MUST be released by a ANeuralNetworks_free_PackageInfo call.
34     char* appPackageName;
35 
36     // Is the app a system app? (false if not an Android app)
37     bool appIsSystemApp;
38     // Is the app preinstalled on vendor image? (false if not an Android app)
39     bool appIsOnVendorImage;
40     // Is the app preinstalled on product image? (false if not an Android app)
41     bool appIsOnProductImage;
42 } ANeuralNetworks_PackageInfo;
43 
44 // Query PackageManagerNative service about Android app properties.
45 // On success, it will allocate memory for PackageInfo fields, which must be
46 // released by a ANeuralNetworks_free_PackageInfo call
47 bool ANeuralNetworks_fetch_PackageInfo(uid_t uid, ANeuralNetworks_PackageInfo* appPackageInfo);
48 
49 // Free memory allocated for PackageInfo fields (doesn't free the actual package info
50 // struct).
51 void ANeuralNetworks_free_PackageInfo(ANeuralNetworks_PackageInfo* appPackageInfo);
52 
53 __END_DECLS
54 
55 #endif  // ANDROID_PACKAGES_MODULES_NEURALNETWORKS_RUNTIME_PACKAGEINFO_PACKAGE_INFO_H
56