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