本文整理汇总了C++中String8::format方法的典型用法代码示例。如果您正苦于以下问题:C++ String8::format方法的具体用法?C++ String8::format怎么用?C++ String8::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String8
的用法示例。
在下文中一共展示了String8::format方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throwExceptionAsNecessary
static bool throwExceptionAsNecessary(
JNIEnv *env, status_t err, const char *msg = NULL) {
const char *drmMessage = NULL;
switch(err) {
case ERROR_DRM_UNKNOWN:
drmMessage = "General DRM error";
break;
case ERROR_DRM_NO_LICENSE:
drmMessage = "No license";
break;
case ERROR_DRM_LICENSE_EXPIRED:
drmMessage = "License expired";
break;
case ERROR_DRM_SESSION_NOT_OPENED:
drmMessage = "Session not opened";
break;
case ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED:
drmMessage = "Not initialized";
break;
case ERROR_DRM_DECRYPT:
drmMessage = "Decrypt error";
break;
case ERROR_DRM_CANNOT_HANDLE:
drmMessage = "Unsupported scheme or data format";
break;
case ERROR_DRM_TAMPER_DETECTED:
drmMessage = "Invalid state";
break;
default:
break;
}
String8 vendorMessage;
if (err >= ERROR_DRM_VENDOR_MIN && err <= ERROR_DRM_VENDOR_MAX) {
vendorMessage.format("DRM vendor-defined error: %d", err);
drmMessage = vendorMessage.string();
}
if (err == BAD_VALUE) {
jniThrowException(env, "java/lang/IllegalArgumentException", msg);
return true;
} else if (err == ERROR_DRM_NOT_PROVISIONED) {
jniThrowException(env, "android/media/NotProvisionedException", msg);
return true;
} else if (err == ERROR_DRM_DEVICE_REVOKED) {
jniThrowException(env, "android/media/DeniedByServerException", msg);
return true;
} else if (err != OK) {
String8 errbuf;
if (drmMessage != NULL) {
if (msg == NULL) {
msg = drmMessage;
} else {
errbuf.format("%s: %s", msg, drmMessage);
msg = errbuf.string();
}
}
ALOGE("Illegal state exception: %s", msg);
jniThrowException(env, "java/lang/IllegalStateException", msg);
return true;
}
return false;
}