本文整理汇总了C++中Parcel::enforceInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::enforceInterface方法的具体用法?C++ Parcel::enforceInterface怎么用?C++ Parcel::enforceInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel::enforceInterface方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTransact
status_t ArcHmbPlayerBinder::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
ALOGE("ArcHmbPlayerBinder::onTransact(%i) %i", code, flags);
/*
* Before executing actual method, check whether the RPC are from expected client.
* Client will write interface token, to identify interface to which those methods
* belong.
*/
if (!data.enforceInterface(ArcHmbPlayerInterface::DESCRIPTOR)) {
ALOGE("failed to check Interface, you might call wrong service, this is for '%s'",
String8(ArcHmbPlayerInterface::DESCRIPTOR).string());
return BAD_TYPE;
}
data.print(aout);
endl(aout);
switch(code) {
case ArcHmbPlayerInterface::PRINT: {
String16 msg = data.readString16();
print(String8(msg).string());
return NO_ERROR;
}
case ArcHmbPlayerInterface::ADD: {
int32_t a = data.readInt32();
int32_t b = data.readInt32();
int32_t sum = add(a, b);
ALOGE("ArcHmbPlayerBinder:onTransact add(%i, %i) = %i", a, b, sum);
reply->print(aout); endl(aout);
reply->writeInt32(sum);
return NO_ERROR;
}
default:
ALOGE("ArcHmbPlayerBinder, bad requesting code, no match found");
}
return BBinder::onTransact(code, data, reply, flags);
}
示例2: android_os_Parcel_enforceInterface
static void android_os_Parcel_enforceInterface(JNIEnv* env, jclass clazz, jlong nativePtr, jstring name)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
const jchar* str = env->GetStringCritical(name, 0);
if (str) {
IPCThreadState* threadState = IPCThreadState::self();
const int32_t oldPolicy = threadState->getStrictModePolicy();
const bool isValid = parcel->enforceInterface(
String16(reinterpret_cast<const char16_t*>(str),
env->GetStringLength(name)),
threadState);
env->ReleaseStringCritical(name, str);
if (isValid) {
const int32_t newPolicy = threadState->getStrictModePolicy();
if (oldPolicy != newPolicy) {
// Need to keep the Java-level thread-local strict
// mode policy in sync for the libcore
// enforcements, which involves an upcall back
// into Java. (We can't modify the
// Parcel.enforceInterface signature, as it's
// pseudo-public, and used via AIDL
// auto-generation...)
set_dalvik_blockguard_policy(env, newPolicy);
}
return; // everything was correct -> return silently
}
}
}
// all error conditions wind up here
jniThrowException(env, "java/lang/SecurityException",
"Binder invocation to an incorrect interface");
}
示例3: onTransact
status_t BnGoogleOtaAgent::onTransact(uint32_t code,
const Parcel &data,
Parcel *reply,
uint32_t flags)
{
XLOGI("OnTransact (%u,%u)", code, flags);
switch(code) {
case TRANSACTION_SET_REBOOT_FLAG:
{
XLOGI("setRebootFlag\n");
data.enforceInterface (descriptor);
reply->writeInt32 (setRebootFlag());
return NO_ERROR;
}
break;
case TRANSACTION_CLEAR_UPGRADE_RESULT:
{
XLOGI("clearUpgradeResult\n");
data.enforceInterface(descriptor);
reply->writeInt32(clearUpgradeResult());
return NO_ERROR;
}
break;
case TRANSACTION_READ_UPGRADE_RESULT:
{
XLOGI("readOtaResult\n");
data.enforceInterface(descriptor);
reply->writeInt32(readUpgradeResult());
return NO_ERROR;
}
break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
return NO_ERROR;
}
示例4: onTransact
status_t BnDMAgent::onTransact(uint32_t code, const Parcel &data,
Parcel *reply, uint32_t flags) {
XLOGI("OnTransact (%u,%u)", code, flags);
reply->writeInt32(DM_READ_NO_EXCEPTION);//used for readException
switch (code) {
case TRANSACTION_setLockFlag: {
/* XLOGI("setLockFlag\n");
data.enforceInterface (descriptor);
reply->writeInt32 (setLockFlag ());
// XLOGI("locked\n");
return NO_ERROR;
*/
XLOGI("setLockFlag\n");
data.enforceInterface(descriptor);
int len = data.readInt32();
XLOGD("setLockFlag len = %d\n", len);
if (len == -1) { // array is null
reply->writeInt32(0);
} else {
char buff[len];
data.read(buff, len);
XLOGD("setLockFlag buff = %s\n", buff);
reply->writeInt32(setLockFlag(buff, len));
}
XLOGI("setLockFlag done\n");
return NO_ERROR;
}
break;
case TRANSACTION_clearLockFlag: {
XLOGI("clearLockFlag\n");
data.enforceInterface(descriptor);
reply->writeInt32(clearLockFlag());
XLOGI("cleared\n");
return NO_ERROR;
}
break;
case TRANSACTION_readDMTree: {
XLOGI("readDMTree\n");
data.enforceInterface(descriptor);
int size = 0;
char * ret = readDMTree(size);
if (ret == NULL) {
reply->writeInt32(-1);
} else {
reply->writeInt32(size);
reply->write(ret, size);
free(ret);
}
XLOGI("DMTree read done\n");
return NO_ERROR;
}
break;
case TRANSACTION_writeDMTree: {
XLOGI("writeDMTree\n");
data.enforceInterface(descriptor);
int len = data.readInt32();
if (len == -1) { // array is null
reply->writeInt32(0);
} else {
char buff[len];
data.read(buff, len);
reply->writeInt32(writeDMTree(buff, len));
}
XLOGI("DMTree wrote\n");
return NO_ERROR;
}
break;
case TRANSACTION_isLockFlagSet: {
XLOGI("isLockFlagSet\n");
data.enforceInterface(descriptor);
reply->writeInt32(isLockFlagSet());
XLOGI("isLockFlagSet done\n");
return NO_ERROR;
}
break;
case TRANSACTION_readIMSI: {
XLOGI("readIMSI\n");
data.enforceInterface(descriptor);
int size = 0;
char * ret = readIMSI(size);
XLOGD("readIMSI = %s\n", ret);
if (ret == NULL) {
reply->writeInt32(-1);
} else {
reply->writeInt32(size);
reply->write(ret, size);
free(ret);
}
XLOGI("readIMSI done\n");
return NO_ERROR;
}
break;
case TRANSACTION_writeIMSI: {
XLOGI("writeIMSI\n");
data.enforceInterface(descriptor);
int len = data.readInt32();
XLOGD("writeIMSI len = %d\n", len);
//.........这里部分代码省略.........
示例5: onTransact
status_t BnCitBinder::onTransact(uint32_t code,
const Parcel &data,
Parcel *reply,
uint32_t flags) {
//LOGI("OnTransact (%u,%u)", code, flags);
switch(code) {
case TRANSACTION_SET_CIT_AUTOTEST_FLAG: {
//LOGI("setCitAutoTestFlag\n");
data.enforceInterface (descriptor);
reply->writeInt32 (setCitAutoTestFlag(data.readInt32()));
return NO_ERROR;
} break;
case TRANSACTION_getFlag: {
//LOGI("getFlag\n");
data.enforceInterface (descriptor);
reply->writeInt32 (getFlag(data.readInt32()));
//LOGI("getFlag done\n");
return NO_ERROR;
} break;
case TRANSACTION_setPsCali_close: {
//LOGI("setPsCali_close\n");
data.enforceInterface (descriptor);
reply->writeInt32 (setPsCali_close(data.readInt32()));
//LOGI("setPsCali_close done\n");
return NO_ERROR;
} break;
case TRANSACTION_setPsCali_far: {
//LOGI("setPsCali_far\n");
data.enforceInterface (descriptor);
reply->writeInt32 (setPsCali_far(data.readInt32()));
//LOGI("setPsCali_far done\n");
return NO_ERROR;
} break;
case TRANSACTION_setPsCali_valid: {
//LOGI("setPsCali_valid\n");
data.enforceInterface (descriptor);
reply->writeInt32 (setPsCali_valid(data.readInt32()));
//LOGI("setPsCali_valid done\n");
return NO_ERROR;
} break;
case TRANSACTION_calisetGsCali_x: {
//LOGI("setGsCali_x\n");
data.enforceInterface (descriptor);
reply->writeInt32 (calisetGsCali_x(data.readInt32()));
//LOGI("setGsCali_x done x= %d\n",x);
return NO_ERROR;
} break;
case TRANSACTION_calisetGsCali_y: {
//LOGI("calisetGsCali_y\n");
data.enforceInterface (descriptor);
reply->writeInt32 (calisetGsCali_y(data.readInt32()));
//LOGI("calisetGsCali_y done y =%d\n",y);
return NO_ERROR;
} break;
case TRANSACTION_calisetGsCali_z: {
//LOGI("calisetGsCali_z\n");
data.enforceInterface (descriptor);
reply->writeInt32 (calisetGsCali_z(data.readInt32()));
//LOGI("calisetGsCali_z done z=%d\n",z);
return NO_ERROR;
} break;
case TRANSACTION_caliGsCali: {
//LOGI("_caliGsCali\n");
data.enforceInterface (descriptor);
reply->writeInt32 (caliGsCali());
//LOGI("_caliGsCali done\n");
return NO_ERROR;
} break;
case TRANSACTION_ClrGsCali: {
//LOGI("_ClrGsCali\n");
data.enforceInterface (descriptor);
reply->writeInt32 (ClrGsCali());
//LOGI("_ClrGsCali done\n");
return NO_ERROR;
} break;
case TRANSACTION_FirstPwrOnLed_getFlag: {
//LOGI("_getFirstPwrOn_Flag\n");
data.enforceInterface (descriptor);
reply->writeInt32 (getFirstPwrOn_Flag());
//LOGI("_getFirstPwrOn_Flag done\n");
return NO_ERROR;
} break;
case TRANSACTION_FirstPwrOnLed_setFlag: {
//LOGI("_setFirstPwrOn_Flag\n");
data.enforceInterface (descriptor);
reply->writeInt32 (setFirstPwrOn_Flag());
//LOGI("_setFirstPwrOn_Flag done\n");
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
return NO_ERROR;
//.........这里部分代码省略.........