1 /* 2 * Copyright (C) 2020 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_APP_INFO_FETCHER_H 18 #define ANDROID_FRAMEWORKS_ML_NN_RUNTIME_APP_INFO_FETCHER_H 19 20 #include <string> 21 22 namespace android { 23 namespace nn { 24 25 // Manages client app information. 26 // 27 // This class gathers information about client application 28 // and provides a unified way to access it. 29 class AppInfoFetcher { 30 public: get()31 static AppInfoFetcher* get() { 32 static AppInfoFetcher info; 33 return &info; 34 } 35 36 // Collection of NNAPI client app-related information 37 struct AppInfo { 38 // Path of the binary (/proc/$PID/exe) 39 std::string binaryPath; 40 // Package name of the Android app (empty string if not Android app). 41 std::string appPackageName; 42 // Is the app a system app? (false if not an Android app) 43 bool appIsSystemApp; 44 // Is the app preinstalled on vendor image? (false if not an Android app) 45 bool appIsOnVendorImage; 46 // Is the app preinstalled on product image? (false if not an Android app) 47 bool appIsOnProductImage; 48 }; 49 50 // Get App-replated information getAppInfo()51 const AppInfo& getAppInfo() const { return appInfo; } 52 53 private: 54 AppInfoFetcher(); 55 56 AppInfo appInfo; 57 }; 58 59 } // namespace nn 60 } // namespace android 61 62 #endif // ANDROID_FRAMEWORKS_ML_NN_RUNTIME_APP_PACKAGE_INFO_H 63