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 #pragma once 17 18 #include <android/hardware/contexthub/1.0/IContexthubCallback.h> 19 #include <log/log.h> 20 21 #include <cinttypes> 22 23 namespace android { 24 namespace hardware { 25 namespace contexthub { 26 namespace vts_utils { 27 28 // Base callback implementation that just logs all callbacks by default, but 29 // records a failure if 30 template <class CallbackType> 31 class ContexthubCallbackBase : public CallbackType { 32 public: handleClientMsg(const V1_0::ContextHubMsg &)33 virtual Return<void> handleClientMsg(const V1_0::ContextHubMsg& /*msg*/) override { 34 ALOGD("Got client message callback"); 35 return Void(); 36 } 37 handleTxnResult(uint32_t txnId,V1_0::TransactionResult result)38 virtual Return<void> handleTxnResult(uint32_t txnId, V1_0::TransactionResult result) override { 39 ALOGD("Got transaction result callback for txnId %" PRIu32 " with result %" PRId32, txnId, 40 result); 41 return Void(); 42 } 43 handleHubEvent(V1_0::AsyncEventType evt)44 virtual Return<void> handleHubEvent(V1_0::AsyncEventType evt) override { 45 ALOGD("Got hub event callback for event type %" PRIu32, evt); 46 return Void(); 47 } 48 handleAppAbort(uint64_t appId,uint32_t abortCode)49 virtual Return<void> handleAppAbort(uint64_t appId, uint32_t abortCode) override { 50 ALOGD("Got app abort notification for appId 0x%" PRIx64 " with abort code 0x%" PRIx32, 51 appId, abortCode); 52 return Void(); 53 } 54 handleAppsInfo(const hidl_vec<V1_0::HubAppInfo> &)55 virtual Return<void> handleAppsInfo(const hidl_vec<V1_0::HubAppInfo>& /*appInfo*/) override { 56 ALOGD("Got app info callback"); 57 return Void(); 58 } 59 }; 60 61 } // namespace vts_utils 62 } // namespace contexthub 63 } // namespace hardware 64 } // namespace android 65