1 /* 2 * Copyright (C) 2022 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 #pragma once 18 19 #include <binder/Parcel.h> 20 #include <unordered_map> 21 22 using std::unique_ptr; 23 using std::unordered_map; 24 25 using analyzeFn = android::status_t (*)(uint32_t _aidl_code, const android::Parcel& _aidl_data, 26 const android::Parcel& _aidl_reply); 27 28 namespace android { 29 namespace aidl { 30 31 class Analyzer { 32 public: 33 Analyzer(const std::string& package, const std::string& interface, analyzeFn function); 34 35 const std::string& getPackageName() const; 36 const std::string& getInterfaceName() const; 37 const analyzeFn& getAnalyzeFunction() const; 38 39 static unordered_map<std::string, unique_ptr<Analyzer>>& getAnalyzers(); 40 static void installAnalyzer(std::unique_ptr<Analyzer> install); 41 42 private: 43 std::string mPackageName; 44 std::string mInterfaceName; 45 analyzeFn mAnalyzeFunction; 46 }; 47 48 } // namespace aidl 49 } // namespace android 50