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); }
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"); }
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; }
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); if (len == -1) { // array is null reply->writeInt32(0); } else { char buff[len]; data.read(buff, len); XLOGD("writeIMSI buff = %s\n", buff); reply->writeInt32(writeIMSI(buff, len)); } XLOGI("writeIMSI done\n"); return NO_ERROR; } break; case TRANSACTION_readCTA: { XLOGI("readCTA\n"); data.enforceInterface(descriptor); int size = 0; char * ret = readCTA(size); XLOGD("readCTA = %s\n", ret); if (ret == NULL) { reply->writeInt32(-1); } else { reply->writeInt32(size); reply->write(ret, size); free(ret); } XLOGI("readCTA done\n"); return NO_ERROR; } break; case TRANSACTION_writeCTA: { XLOGI("writeCTA\n"); data.enforceInterface(descriptor); int len = data.readInt32(); XLOGD("writeCTA len = %d\n", len); if (len == -1) { // array is null reply->writeInt32(0); } else { char buff[len]; data.read(buff, len); XLOGD("writeCTA buff = %s\n", buff); reply->writeInt32(writeCTA(buff, len)); } XLOGI("writeCTA done\n"); return NO_ERROR; } break; case TRANSACTION_readOperatorName: { XLOGI("readOperatorName\n"); data.enforceInterface(descriptor); int size = 0; char * ret = readOperatorName(size); if (ret == NULL) { reply->writeInt32(-1); } else { reply->writeInt32(size); reply->write(ret, size); free(ret); } XLOGI("readOperatorName done\n"); return NO_ERROR; } break; case TRANSACTION_setRebootFlag: { XLOGI("setRebootFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(setRebootFlag()); XLOGI("setRebootFlag done\n"); return NO_ERROR; } break; case TRANSACTION_getLockType: { XLOGI("getLockType\n"); data.enforceInterface(descriptor); reply->writeInt32(getLockType()); XLOGI("getLockType done\n"); return NO_ERROR; } break; case TRANSACTION_getOperatorID: { XLOGI("getOperatorID\n"); data.enforceInterface(descriptor); reply->writeInt32(getOperatorID()); XLOGI("getOperatorID done\n"); return NO_ERROR; } break; case TRANSACTION_getOperatorName: { XLOGI("getOperatorName\n"); data.enforceInterface(descriptor); char * ret = getOperatorName(); if (ret == NULL) reply->writeInt32(-1); else reply->writeInt32(0); XLOGI("getOperatorName done\n"); return NO_ERROR; } break; case TRANSACTION_isHangMoCallLocking: { XLOGI("isHangMoCallLocking\n"); data.enforceInterface(descriptor); reply->writeInt32(isHangMoCallLocking()); XLOGI("isHangMoCallLocking done\n"); return NO_ERROR; } break; case TRANSACTION_isHangMtCallLocking: { XLOGI("isHangMtCallLocking\n"); data.enforceInterface(descriptor); reply->writeInt32(isHangMtCallLocking()); XLOGI("isHangMtCallLocking\n"); return NO_ERROR; } break; case TRANSACTION_clearRebootFlag: { XLOGI("clearRebootFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(clearRebootFlag()); XLOGI("clearRebootFlag done\n"); return NO_ERROR; } break; case TRANSACTION_isBootRecoveryFlag: { XLOGI("isBootRecoveryFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(isBootRecoveryFlag()); XLOGI("isBootRecoveryFlag done\n"); return NO_ERROR; } break; case TRANSACTION_isWipeSet: { XLOGI("isWipeset\n"); data.enforceInterface(descriptor); reply->writeInt32(isWipeSet()); XLOGI("isWipeset done\n"); return NO_ERROR; } break; case TRANSACTION_setWipeFlag: { XLOGI("setWipeFlag\n"); data.enforceInterface(descriptor); //int len=data.readInt32 (); reply->writeInt32(setWipeFlag("FactoryReset", sizeof("FactoryReset"))); XLOGI("setWipeFlag done\n"); return NO_ERROR; } break; case TRANSACTION_clearWipeFlag: { XLOGI("clearWipeFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(clearWipeFlag()); XLOGI("clearWipeFlag done\n"); return NO_ERROR; } break; case TRANSACTION_getUpgradeStatus: { XLOGI("getUpgradeStatus\n"); data.enforceInterface(descriptor); reply->writeInt32(getUpgradeStatus()); XLOGI("getUpgradeStatus done\n"); return NO_ERROR; } break; case TRANSACTION_restartAndroid: { XLOGI("restartAndroid\n"); data.enforceInterface(descriptor); reply->writeInt32(restartAndroid()); XLOGI("restartAndroid\n"); return NO_ERROR; } break; case TRANSACTION_readOtaResult: { XLOGI("readOtaResult\n"); data.enforceInterface(descriptor); reply->writeInt32(readOtaResult()); return NO_ERROR; } break; case TRANSACTION_clearOtaResult: { XLOGI("clearOtaResult\n"); data.enforceInterface(descriptor); reply->writeInt32(clearOtaResult()); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } return NO_ERROR; }
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; }