1 #ifndef UTILS_H_ 2 #define UTILS_H_ 3 4 #include <string> 5 6 #include "SessionLibrary.h" 7 8 #include <android/binder_auto_utils.h> 9 #include "aidl/android/hardware/drm/Status.h" 10 #include "CastKeyTypes.h" 11 12 namespace aidl { 13 namespace android { 14 namespace hardware { 15 namespace drm { 16 namespace castkey { 17 18 inline ::ndk::ScopedAStatus toNdkScopedAStatus(::aidl::android::hardware::drm::Status status, 19 const char* msg = nullptr) { 20 if (Status::OK == status) { 21 return ::ndk::ScopedAStatus::ok(); 22 } else { 23 auto err = static_cast<int32_t>(status); 24 if (msg) { 25 return ::ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(err, msg); 26 } else { 27 return ::ndk::ScopedAStatus::fromServiceSpecificError(err); 28 } 29 } 30 } 31 toNdkScopedAStatus(castkeydrm::CdmResponseType res)32inline ::ndk::ScopedAStatus toNdkScopedAStatus(castkeydrm::CdmResponseType res) { 33 return toNdkScopedAStatus(static_cast<::aidl::android::hardware::drm::Status>(res)); 34 } 35 36 #define UNUSED(x) (void)(x); 37 38 } // namespace castkey 39 } // namespace drm 40 } // namespace hardware 41 } // namespace android 42 } // namespace aidl 43 44 #endif // UTILS_H_ 45