1/* 2 * Copyright (C) 2016 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#define LOG_TAG "android.hardware.drm@1.0-impl" 17 18#include "TypeConvert.h" 19 20namespace android { 21namespace hardware { 22namespace drm { 23namespace V1_0 { 24namespace implementation { 25 26Status toStatus(status_t legacyStatus) { 27 Status status; 28 switch(legacyStatus) { 29 case android::OK: 30 status = Status::OK; 31 break; 32 case android::ERROR_DRM_NO_LICENSE: 33 status = Status::ERROR_DRM_NO_LICENSE; 34 break; 35 case android::ERROR_DRM_LICENSE_EXPIRED: 36 status = Status::ERROR_DRM_LICENSE_EXPIRED; 37 break; 38 case android::ERROR_DRM_SESSION_NOT_OPENED: 39 status = Status::ERROR_DRM_SESSION_NOT_OPENED; 40 break; 41 case android::ERROR_DRM_CANNOT_HANDLE: 42 status = Status::ERROR_DRM_CANNOT_HANDLE; 43 break; 44 case android::ERROR_DRM_TAMPER_DETECTED: 45 status = Status::ERROR_DRM_INVALID_STATE; 46 break; 47 case android::BAD_VALUE: 48 status = Status::BAD_VALUE; 49 break; 50 case android::ERROR_DRM_NOT_PROVISIONED: 51 status = Status::ERROR_DRM_NOT_PROVISIONED; 52 break; 53 case android::ERROR_DRM_RESOURCE_BUSY: 54 status = Status::ERROR_DRM_RESOURCE_BUSY; 55 break; 56 case android::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION: 57 status = Status::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION; 58 break; 59 case android::ERROR_DRM_DEVICE_REVOKED: 60 status = Status::ERROR_DRM_DEVICE_REVOKED; 61 break; 62 case android::ERROR_DRM_DECRYPT: 63 status = Status::ERROR_DRM_DECRYPT; 64 break; 65 default: 66 ALOGW("Unable to convert legacy status: %d, defaulting to UNKNOWN", 67 legacyStatus); 68 status = Status::ERROR_DRM_UNKNOWN; 69 break; 70 } 71 return status; 72} 73 74} // namespace implementation 75} // namespace V1_0 76} // namespace drm 77} // namespace hardware 78} // namespace android 79