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 #include <binder/IBinder.h> 18 #include <binder/IServiceManager.h> 19 #include <perfstatsd.h> 20 #include <perfstatsd_service.h> 21 start()22android::status_t PerfstatsdPrivateService::start() { 23 return BinderService<PerfstatsdPrivateService>::publish(); 24 } 25 dumpHistory(std::string * _aidl_return)26android::binder::Status PerfstatsdPrivateService::dumpHistory(std::string *_aidl_return) { 27 perfstatsdSp->getHistory(_aidl_return); 28 return android::binder::Status::ok(); 29 } 30 setOptions(const std::string & key,const std::string & value)31android::binder::Status PerfstatsdPrivateService::setOptions(const std::string &key, 32 const std::string &value) { 33 perfstatsdSp->setOptions(std::forward<const std::string>(key), 34 std::forward<const std::string>(value)); 35 return android::binder::Status::ok(); 36 } 37 getPerfstatsdPrivateService()38android::sp<IPerfstatsdPrivate> getPerfstatsdPrivateService() { 39 android::sp<android::IServiceManager> sm = android::defaultServiceManager(); 40 if (sm == NULL) 41 return NULL; 42 43 android::sp<android::IBinder> binder = sm->getService(android::String16("perfstatsd_pri")); 44 if (binder == NULL) 45 return NULL; 46 47 return android::interface_cast<IPerfstatsdPrivate>(binder); 48 } 49