RILCall(const Parcel& data) {
	state              = static_cast<RIL_CallState>(data.readInt32());
	index              = data.readInt32();
	toa                = data.readInt32();
	isMpty             = (data.readInt32() != 0);
	isMT               = (data.readInt32() != 0);
	als                = data.readInt32();
	isVoice            = data.readInt32();
	isVoicePrivacy     = data.readInt32();
	number             = data.readString16();
	numberPresentation = data.readInt32();
	name               = data.readString16();
	namePresentation   = data.readInt32();
	hasUusInfo         = (data.readInt32() != 0);
	if (hasUusInfo) {
	    // ### TODO:  Check this with something that has UUS
	    uusType   = static_cast<RIL_UUS_Type>(data.readInt32());
	    uusDcs    = static_cast<RIL_UUS_DCS>(data.readInt32());
	    uusLength = data.readInt32();
	    uusData   = NULL;
	    if (uusLength > 0) {
		uusData = new char[uusLength];
		data.read(uusData, uusLength);
	    }
	}
    }
status_t BnSensorServer::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case GET_SENSOR_LIST: {
            CHECK_INTERFACE(ISensorServer, data, reply);
            const String16& opPackageName = data.readString16();
            Vector<Sensor> v(getSensorList(opPackageName));
            size_t n = v.size();
            reply->writeUint32(static_cast<uint32_t>(n));
            for (size_t i = 0; i < n; i++) {
                reply->write(v[i]);
            }
            return NO_ERROR;
        }
        case CREATE_SENSOR_EVENT_CONNECTION: {
            CHECK_INTERFACE(ISensorServer, data, reply);
            String8 packageName = data.readString8();
            int32_t mode = data.readInt32();
            const String16& opPackageName = data.readString16();
            sp<ISensorEventConnection> connection(createSensorEventConnection(packageName, mode,
                    opPackageName));
            reply->writeStrongBinder(IInterface::asBinder(connection));
            return NO_ERROR;
        }
        case ENABLE_DATA_INJECTION: {
            CHECK_INTERFACE(ISensorServer, data, reply);
            int32_t ret = isDataInjectionEnabled();
            reply->writeInt32(static_cast<int32_t>(ret));
            return NO_ERROR;
        }
    }
    return BBinder::onTransact(code, data, reply, flags);
}
Exemple #3
0
// Notes about data transaction:
// Java Binder Wrapper call readInt32 before reading return data
// It treet this in value as exception code
// OnTransact method support this feature
status_t BnOpenCVEngine::onTransact(uint32_t code, const Parcel& data, android::Parcel* reply, uint32_t flags)
{
    LOGD("OpenCVEngine::OnTransact(%u,%u)", code, flags);

    switch(code)
    {
        case OCVE_GET_ENGINE_VERSION:
        {
            LOGD("OpenCVEngine OCVE_GET_ENGINE_VERSION request");
            CHECK_INTERFACE(IOpenCVEngine, data, reply);
            LOGD("OpenCVEngine::GetVersion()");
            reply->writeInt32(0);
            return reply->writeInt32(GetVersion());
        } break;
        case OCVE_GET_LIB_PATH_BY_VERSION:
        {
            LOGD("OpenCVEngine OCVE_GET_LIB_PATH_BY_VERSION request");
            CHECK_INTERFACE(IOpenCVEngine, data, reply);
            const String16 version = data.readString16();
            LOGD("OpenCVEngine::GetLibPathByVersion(%s)", String8(version).string());
            String16 path = GetLibPathByVersion(version);
            reply->writeInt32(0);
            return reply->writeString16(path);
        } break;
        case OCVE_GET_LIB_LIST:
        {
            LOGD("OpenCVEngine OCVE_GET_LIB_LIST request");
            CHECK_INTERFACE(IOpenCVEngine, data, reply);
            const String16 version = data.readString16();
            LOGD("OpenCVEngine::GetLibraryList(%s)", String8(version).string());
            String16 path = GetLibraryList(version);
            reply->writeInt32(0);
            return reply->writeString16(path);
        } break;
        case OCVE_INSTALL_VERSION:
        {
            LOGD("OpenCVEngine OCVE_INSTALL_VERSION request");
            CHECK_INTERFACE(IOpenCVEngine, data, reply);
            const String16 version = data.readString16();
            LOGD("OpenCVEngine::InstallVersion(%s)", String8(version).string());
            bool result = InstallVersion(version);
            reply->writeInt32(0);
            int res = reply->writeInt32(static_cast<int32_t>(result));
            LOGD("InstallVersion call to Binder finished with res %d", res);
            return res;
        } break;
        default:
        {
            LOGD("OpenCVEngine unknown request");
            return BBinder::onTransact(code, data, reply, flags);
        }
    }

    return android::NO_ERROR;
}
Exemple #4
0
status_t BBinder::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t /*flags*/)
{
    switch (code) {
        case INTERFACE_TRANSACTION:
            reply->writeString16(getInterfaceDescriptor());
            return NO_ERROR;

        case DUMP_TRANSACTION: {
            int fd = data.readFileDescriptor();
            int argc = data.readInt32();
            Vector<String16> args;
            for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
               args.add(data.readString16());
            }
            return dump(fd, args);
        }

        case SHELL_COMMAND_TRANSACTION: {
            int in = data.readFileDescriptor();
            int out = data.readFileDescriptor();
            int err = data.readFileDescriptor();
            int argc = data.readInt32();
            Vector<String16> args;
            for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
               args.add(data.readString16());
            }
            sp<IShellCallback> shellCallback = IShellCallback::asInterface(
                    data.readStrongBinder());
            sp<IResultReceiver> resultReceiver = IResultReceiver::asInterface(
                    data.readStrongBinder());

            // XXX can't add virtuals until binaries are updated.
            //return shellCommand(in, out, err, args, resultReceiver);
            (void)in;
            (void)out;
            (void)err;

            if (resultReceiver != NULL) {
                resultReceiver->send(INVALID_OPERATION);
            }

            return NO_ERROR;
        }

        case SYSPROPS_TRANSACTION: {
            report_sysprop_change();
            return NO_ERROR;
        }

        default:
            return UNKNOWN_TRANSACTION;
    }
}
status_t BBinder::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {
        case INTERFACE_TRANSACTION:
            reply->writeString16(getInterfaceDescriptor());
            return NO_ERROR;

        case DUMP_TRANSACTION: {
            int fd = data.readFileDescriptor();
            int argc = data.readInt32();
            Vector<String16> args;
            for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
               args.add(data.readString16());
            }
            return dump(fd, args);
        }

        case SYSPROPS_TRANSACTION: {
            report_sysprop_change();
            return NO_ERROR;
        }

        default:
            return UNKNOWN_TRANSACTION;
    }
}
status_t Status::readFromParcel(const Parcel& parcel) {
    status_t status = parcel.readInt32(&mException);
    if (status != OK) {
        setFromStatusT(status);
        return status;
    }

    // Skip over fat response headers.  Not used (or propagated) in native code.
    if (mException == EX_HAS_REPLY_HEADER) {
        // Note that the header size includes the 4 byte size field.
        const int32_t header_start = parcel.dataPosition();
        int32_t header_size;
        status = parcel.readInt32(&header_size);
        if (status != OK) {
            setFromStatusT(status);
            return status;
        }
        parcel.setDataPosition(header_start + header_size);
        // And fat response headers are currently only used when there are no
        // exceptions, so act like there was no error.
        mException = EX_NONE;
    }

    if (mException == EX_NONE) {
        return status;
    }

    // The remote threw an exception.  Get the message back.
    mMessage = String8(parcel.readString16());

    return status;
}
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);
}
/* BnHelloWorld */
status_t BnHelloWorld::onTransact(uint32_t code,
                                                const Parcel &data,
                                                Parcel *reply,
                                                uint32_t flags)
{
        LOGE("OnTransact(%u,%u)", code, flags);
        CHECK_INTERFACE(IHelloWorld, data, reply);
        switch(code) {
        case HW_HELLOTHERE: {
                /**
                 * Checking permissions is always a good idea.
                 *
                 * Note that the native client will also be granted these permissions in two cases
                 * 1) you run the client code as root or system user.
                 * 2) you run the client code as user who was granted this permission.
                 * @see http://github.com/keesj/gomo/wiki/AndroidSecurity for more information
                 **/
                if (checkCallingPermission(String16("org.credil.helloworldservice.permissions.CALL_HELLOTHERE")) == false){
                    return   PERMISSION_DENIED;
                }
                String16 str = data.readString16();
                hellothere(String8(str).string());
                ///reply->writeString16(str);
                return NO_ERROR;
        } break;
		case RETURN_INT_SHANQUAN:{
                if (checkCallingPermission(String16("org.credil.helloworldservice.permissions.CALL_HELLOTHERE")) == false){
                    return   PERMISSION_DENIED;
                }
                String16 str = data.readString16();
                helloint(String8(str).string());
				int tmp= str.size();
				printf("servie str.size():%i\n",tmp);
				status_t status = reply->writeInt32(tmp);
				if( status == NO_ERROR)
					printf("file:%s,line:%i,no error\n",__FILE__,__LINE__);
				else
					printf("file:%s,line:%i, error\n",__FILE__,__LINE__);
                return NO_ERROR;
		} break;
        default:
                return BBinder::onTransact(code, data, reply, flags);
        }
        return NO_ERROR;
}
status_t BnServiceManager::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    //printf("ServiceManager received: "); data.print();
    switch(code) {
        case GET_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp<IBinder> b = const_cast<BnServiceManager*>(this)->getService(which);
            reply->writeStrongBinder(b);
            return NO_ERROR;
        } break;
        case CHECK_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp<IBinder> b = const_cast<BnServiceManager*>(this)->checkService(which);
            reply->writeStrongBinder(b);
            return NO_ERROR;
        } break;
        case ADD_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp<IBinder> b = data.readStrongBinder();
            status_t err = addService(which, b);
            reply->writeInt32(err);
            return NO_ERROR;
        } break;
        case LIST_SERVICES_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            Vector<String16> list = listServices();
            const size_t N = list.size();
            reply->writeInt32(N);
            for (size_t i=0; i<N; i++) {
                reply->writeString16(list[i]);
            }
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
void PhoneMachine::receiveUnsolicited(const Parcel& data)
{
    int message = data.readInt32();
    int ivalue  = 0;
    String16 svalue;
    UnsolicitedMessages flags = UM_NONE;
    MAPTYPE *pmap = eventmap;

    SLOGD("<<< Unsolicited message=%s [%d]\n", rilMessageStr(message), message);
    while (pmap->flags != UM_NONE && message != pmap->message)
        pmap++;
    if (pmap->flags)
	flags = pmap->flags;
    switch (message) {
    case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: 
	ivalue = data.readInt32(); 
	SLOGD("    RIL Radio state changed to %d\n", ivalue);
	if (ivalue == RADIO_STATE_OFF) {
	    RILRequest * request = new RILRequest(NULL, -1, RIL_REQUEST_RADIO_POWER);
	    request->writeInt(1);  // One value
	    request->writeInt(1);  // Turn the radio on
	    sendToRILD(request);
	}
	break;
    case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
	sendToRILD(new RILRequest(NULL, -1, RIL_REQUEST_GET_CURRENT_CALLS));
	break;
    case RIL_UNSOL_NITZ_TIME_RECEIVED:
	svalue = data.readString16();
        break;
    case RIL_UNSOL_SIGNAL_STRENGTH:
	ivalue = data.readInt32();
	SLOGD("     Signal strength changed %d\n", ivalue);
	break;
#if defined(SHORT_PLATFORM_VERSION) && (SHORT_PLATFORM_VERSION == 23)
#else
    case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
	break;
    case RIL_UNSOL_RIL_CONNECTED: {
	int n = data.readInt32();  // Number of integers
	ivalue = data.readInt32();  // RIL Version
	SLOGD("    RIL connected version=%d\n", ivalue);
        break;
        }
#endif
    default:
	SLOGD("### Unhandled unsolicited message received from RIL: %d\n", message);
	break;
    }
    if (flags)
	mService->broadcastUnsolicited(flags, message, ivalue, svalue);
}
static jint _setResult(JNIEnv* env, jobject obj, jobject java_result)
{
  sp<DMRDeviceClient> dmr_device = getDMRDeviceClient(env, obj);
  if (dmr_device == NULL ) {
      return UNKNOWN_ERROR;
  }

  Parcel *result = parcelForJavaObject(env, java_result);

  String8 order(result->readString16());

  return dmr_device->setResult(order);
}
Exemple #12
0
status_t BnChatSessionManager::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
	status_t result = 0x80000000;
	_TRACE("ChatSessionManager::onTransact[pid:%d] >>:code 0x%x",GetCallerPID(),code); //data.print();
	switch(code) {
	case ICSM_GetSessionNames: {
		CHECK_INTERFACE(IChatSessionManager, data, reply);
		Vector<String16> list = GetSessionNames();
		const size_t N = list.size();
		reply->writeInt32(N);
		for (size_t i=0; i<N; i++) {
		    reply->writeString16(list[i]);
		}
		result = NO_ERROR;
	} break;
	case ICSM_FindSession: {
		CHECK_INTERFACE(IChatSessionManager, data, reply);
		String16 name = data.readString16();
		BOOL bDontCreate = data.readInt32();
		BOOL bAllowAnonymousAccess = data.readInt32();	
		sp<IChatSession> b = FindSession(name,bDontCreate,bAllowAnonymousAccess);			
		reply->writeStrongBinder(b->asBinder());
		result =  NO_ERROR;
	} break;
	case ICSM_DeleteSession: {
		CHECK_INTERFACE(IChatSessionManager, data, reply);
		String16 name = data.readString16();
		status_t err = DeleteSession(name);
		reply->writeInt32(err);
		result =  NO_ERROR;
	} break;		
	default:
		result =  BBinder::onTransact(code, data, reply, flags);
	}
	_TRACE("ChatSessionManager::onTransact[pid:%d] <<:result %d",GetCallerPID(),result); //reply.print();
	return result;
}
status_t BnMountServiceListener::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case TRANSACTION_onUsbMassStorageConnectionChanged: {
            CHECK_INTERFACE(IMountServiceListener, data, reply);
            bool connected = (data.readInt32() != 0);
            onUsbMassStorageConnectionChanged(connected);
            reply->writeNoException();
            return NO_ERROR;
        } break;
        case TRANSACTION_onStorageStateChanged: {
            CHECK_INTERFACE(IMountServiceListener, data, reply);
            String16 path = data.readString16();
            String16 oldState = data.readString16();
            String16 newState = data.readString16();
            onStorageStateChanged(path, oldState, newState);
            reply->writeNoException();
            return NO_ERROR;
        }
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Exemple #14
0
  status_t Service::onTransact(uint32_t code,
					 const Parcel &data,
					 Parcel *reply,
					 uint32_t flags)
  {
    CHECK_INTERFACE(IHelloWorld, data, reply);
    if (code == HW_SAYHELLO)
      {
	if (checkCallingPermission(String16("cn.bjtu.helloworldservice.permissions.CALL_SAYHELLO")) == false)
	  return   PERMISSION_DENIED;
	String16 str = data.readString16();
	sayHello(String8(str).string());
	return NO_ERROR;
      }
    return BBinder::onTransact(code, data, reply, flags);
  }
status_t PVPlayerExtensionHandler::queryExtnIface(const Parcel& data, Parcel& reply)
{
    String16 iface= data.readString16();
    IDispatch* extPtr = NULL;
    extPtr = mPVPlayerExtnIfaceRegistry.createExtension(iface,*this);
    if (extPtr){
        LOGV("PVPlayerExtensionHandler::queryExtnIface extIface=%d",(int32_t)extPtr);
        status_t status = reply.writeInt32(NO_ERROR);
        if (NO_ERROR != status){
            return INVALID_OPERATION;
        }
        iExtensionInstancesList.add_element(extPtr);
        return reply.writeInt32((int32_t)extPtr);
    } else {
        return reply.writeInt32(NAME_NOT_FOUND);
    }
}
status_t BnPermissionController::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    //printf("PermissionController received: "); data.print();
    switch(code) {
        case CHECK_PERMISSION_TRANSACTION: {
            CHECK_INTERFACE(IPermissionController, data, reply);
            String16 permission = data.readString16();
            int32_t pid = data.readInt32();
            int32_t uid = data.readInt32();
            bool res = checkPermission(permission, pid, uid);
            // write exception
            reply->writeInt32(0);
            reply->writeInt32(res ? 1 : 0);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Exemple #17
0
status_t BnChatSessionEvents::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    	status_t result = 0x80000000;
	_TRACE("ChatSessionEvents::onTransact[pid:%d] >>:code 0x%x",GetCallerPID(),code); //data.print();
	
	switch(code) {
		case ICSE_OnNewUser: {
			CHECK_INTERFACE(IChatSessionEvents, data, reply);
			String16 name = data.readString16();
			OnNewUser(name);
			result = NO_ERROR;
		} break;		
		case ICSE_OnUserLeft: {
			CHECK_INTERFACE(IChatSessionEvents, data, reply);
			String16 name = data.readString16();
			OnUserLeft(name);
			result = NO_ERROR;
		} break;
		case ICSE_OnNewStatement: {
			CHECK_INTERFACE(IChatSessionEvents, data, reply);
			String16 name = data.readString16();
			String16 statement = data.readString16();		
			OnNewStatement(name,statement);
			result = NO_ERROR;
		} break;
		case ICSE_Sync_OnNewStatement: {
			CHECK_INTERFACE(IChatSessionEvents, data, reply);
			String16 name = data.readString16();
			String16 statement = data.readString16();		
			status_t err = Sync_OnNewStatement(name,statement);
			reply->writeInt32(err);
			result = NO_ERROR;
		} break;		
		case ICSE_GetUserName: {
			CHECK_INTERFACE(IChatSessionEvents, data, reply);
			String16 name = GetUserName();
			reply->writeString16(name);
			result = NO_ERROR;
		} break;		
		default:
			result = BBinder::onTransact(code, data, reply, flags);
	}
	
	_TRACE("ChatSessionEvents::onTransact[pid:%d] <<:result %d",GetCallerPID(),result); //reply.print();
	return result;	
}
status_t BnCameraService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case GET_NUMBER_OF_CAMERAS: {
            CHECK_INTERFACE(ICameraService, data, reply);
            reply->writeNoException();
            reply->writeInt32(getNumberOfCameras());
            return NO_ERROR;
        } break;
        case GET_CAMERA_INFO: {
            CHECK_INTERFACE(ICameraService, data, reply);
            CameraInfo cameraInfo = CameraInfo();
            memset(&cameraInfo, 0, sizeof(cameraInfo));
            status_t result = getCameraInfo(data.readInt32(), &cameraInfo);
            reply->writeNoException();
            reply->writeInt32(result);

            // Fake a parcelable object here
            reply->writeInt32(1); // means the parcelable is included
            reply->writeInt32(cameraInfo.facing);
            reply->writeInt32(cameraInfo.orientation);
            return NO_ERROR;
        } break;
        case GET_CAMERA_CHARACTERISTICS: {
            CHECK_INTERFACE(ICameraService, data, reply);
            CameraMetadata info;
            status_t result = getCameraCharacteristics(data.readInt32(), &info);
            reply->writeNoException();
            reply->writeInt32(result);

            // out-variables are after exception and return value
            reply->writeInt32(1); // means the parcelable is included
            info.writeToParcel(reply);
            return NO_ERROR;
        } break;
        case CONNECT: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraClient> cameraClient =
                    interface_cast<ICameraClient>(data.readStrongBinder());
            int32_t cameraId = data.readInt32();
            const String16 clientName = data.readString16();
            int32_t clientUid = data.readInt32();
            sp<ICamera> camera;
            status_t status = connect(cameraClient, cameraId,
                    clientName, clientUid, /*out*/ camera);
            reply->writeNoException();
            reply->writeInt32(status);
            if (camera != NULL) {
                reply->writeInt32(1);
                reply->writeStrongBinder(camera->asBinder());
            } else {
                reply->writeInt32(0);
            }
            return NO_ERROR;
        } break;
        case CONNECT_PRO: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<IProCameraCallbacks> cameraClient =
                interface_cast<IProCameraCallbacks>(data.readStrongBinder());
            int32_t cameraId = data.readInt32();
            const String16 clientName = data.readString16();
            int32_t clientUid = data.readInt32();
            sp<IProCameraUser> camera;
            status_t status = connectPro(cameraClient, cameraId,
                    clientName, clientUid, /*out*/ camera);
            reply->writeNoException();
            reply->writeInt32(status);
            if (camera != NULL) {
                reply->writeInt32(1);
                reply->writeStrongBinder(camera->asBinder());
            } else {
                reply->writeInt32(0);
            }
            return NO_ERROR;
        } break;
        case CONNECT_DEVICE: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraDeviceCallbacks> cameraClient =
                interface_cast<ICameraDeviceCallbacks>(data.readStrongBinder());
            int32_t cameraId = data.readInt32();
            const String16 clientName = data.readString16();
            int32_t clientUid = data.readInt32();
            sp<ICameraDeviceUser> camera;
            status_t status = connectDevice(cameraClient, cameraId,
                    clientName, clientUid, /*out*/ camera);
            reply->writeNoException();
            reply->writeInt32(status);
            if (camera != NULL) {
                reply->writeInt32(1);
                reply->writeStrongBinder(camera->asBinder());
            } else {
                reply->writeInt32(0);
            }
            return NO_ERROR;
        } break;
        case ADD_LISTENER: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraServiceListener> listener =
                interface_cast<ICameraServiceListener>(data.readStrongBinder());
            reply->writeNoException();
            reply->writeInt32(addListener(listener));
            return NO_ERROR;
        } break;
        case REMOVE_LISTENER: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraServiceListener> listener =
                interface_cast<ICameraServiceListener>(data.readStrongBinder());
            reply->writeNoException();
            reply->writeInt32(removeListener(listener));
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Exemple #19
0
status_t BnChatSession::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
	status_t result = 0x80000000;
	_TRACE("ChatSession::onTransact[pid:%d] >>:code 0x%x",GetCallerPID(),code); //data.print();
	
	switch(code) {
		case ICS_getName: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			String16 name = const_cast<BnChatSession*>(this)->GetName();			
			reply->writeString16(name);
			result =  NO_ERROR;
		} break;		
		case ICS_GetStatements: {

			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);
			Vector<String16> list = GetStatements();
			const size_t N = list.size();
			reply->writeInt32(N);
			_TRACE("GetStatements num %u",(unsigned int)N);
			for (size_t i=0; i<N; i++) {
				reply->writeString16(list[i]);
			}
			result = NO_ERROR;
			
		} break;
		case ICS_Say: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			String16 statement = data.readString16();
			status_t err = Say(statement);
			reply->writeInt32(err);
			result = NO_ERROR;
		} break;
		case ICS_AsyncSay: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			String16 statement = data.readString16();
			AsyncSay(statement);
			result = NO_ERROR;
		} break;
		case ICS_Advise: {
			CHECK_INTERFACE(IChatSession, data, reply);
			sp<IChatSessionEvents> eventSink = interface_cast<IChatSessionEvents>(data.readStrongBinder());
			Advise(eventSink);
			result = NO_ERROR;
		} break;
		case ICS_Unadvise: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			status_t err = Unadvise();
			reply->writeInt32(err);
			result = NO_ERROR;
		} break;		
		default:
			result = BBinder::onTransact(code, data, reply, flags);
	}
	
	_TRACE("ChatSession::onTransact[pid:%d] <<:result %d",GetCallerPID(),result); //reply.print();
	return result;
}
status_t BnPermissionController::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case CHECK_PERMISSION_TRANSACTION: {
            CHECK_INTERFACE(IPermissionController, data, reply);
            String16 permission = data.readString16();
            int32_t pid = data.readInt32();
            int32_t uid = data.readInt32();
            bool res = checkPermission(permission, pid, uid);
            reply->writeNoException();
            reply->writeInt32(res ? 1 : 0);
            return NO_ERROR;
        } break;

        case NOTE_OP_TRANSACTION: {
            CHECK_INTERFACE(IPermissionController, data, reply);
            String16 op = data.readString16();
            int32_t uid = data.readInt32();
            String16 packageName = data.readString16();
            int32_t res = noteOp(op, uid, packageName);
            reply->writeNoException();
            reply->writeInt32(res);
            return NO_ERROR;
        } break;

        case GET_PACKAGES_FOR_UID_TRANSACTION: {
            CHECK_INTERFACE(IPermissionController, data, reply);
            int32_t uid = data.readInt32();
            Vector<String16> packages;
            getPackagesForUid(uid, packages);
            reply->writeNoException();
            size_t size = packages.size();
            reply->writeInt32(size);
            for (size_t i = 0; i < size; i++) {
                reply->writeString16(packages[i]);
            }
            return NO_ERROR;
        } break;

        case IS_RUNTIME_PERMISSION_TRANSACTION: {
            CHECK_INTERFACE(IPermissionController, data, reply);
            String16 permission = data.readString16();
            const bool res = isRuntimePermission(permission);
            reply->writeNoException();
            reply->writeInt32(res ? 1 : 0);
            return NO_ERROR;
        } break;

        case GET_PACKAGE_UID_TRANSACTION: {
            CHECK_INTERFACE(IPermissionController, data, reply);
            String16 package = data.readString16();
            int flags = data.readInt32();
            const int uid = getPackageUid(package, flags);
            reply->writeNoException();
            reply->writeInt32(uid);
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
status_t BnAppOpsService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    //printf("AppOpsService received: "); data.print();
    switch(code) {
        case CHECK_OPERATION_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            int32_t code = data.readInt32();
            int32_t uid = data.readInt32();
            String16 packageName = data.readString16();
            int32_t res = checkOperation(code, uid, packageName);
            reply->writeNoException();
            reply->writeInt32(res);
            return NO_ERROR;
        } break;
        case NOTE_OPERATION_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            int32_t code = data.readInt32();
            int32_t uid = data.readInt32();
            String16 packageName = data.readString16();
            int32_t res = noteOperation(code, uid, packageName);
            reply->writeNoException();
            reply->writeInt32(res);
            return NO_ERROR;
        } break;
        case START_OPERATION_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            sp<IBinder> token = data.readStrongBinder();
            int32_t code = data.readInt32();
            int32_t uid = data.readInt32();
            String16 packageName = data.readString16();
            int32_t res = startOperation(token, code, uid, packageName);
            reply->writeNoException();
            reply->writeInt32(res);
            return NO_ERROR;
        } break;
        case FINISH_OPERATION_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            sp<IBinder> token = data.readStrongBinder();
            int32_t code = data.readInt32();
            int32_t uid = data.readInt32();
            String16 packageName = data.readString16();
            finishOperation(token, code, uid, packageName);
            reply->writeNoException();
            return NO_ERROR;
        } break;
        case START_WATCHING_MODE_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            int32_t op = data.readInt32();
            String16 packageName = data.readString16();
            sp<IAppOpsCallback> callback = interface_cast<IAppOpsCallback>(data.readStrongBinder());
            startWatchingMode(op, packageName, callback);
            reply->writeNoException();
            return NO_ERROR;
        } break;
        case STOP_WATCHING_MODE_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            sp<IAppOpsCallback> callback = interface_cast<IAppOpsCallback>(data.readStrongBinder());
            stopWatchingMode(callback);
            reply->writeNoException();
            return NO_ERROR;
        } break;
        case GET_TOKEN_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            sp<IBinder> clientToken = data.readStrongBinder();
            sp<IBinder> token = getToken(clientToken);
            reply->writeNoException();
            reply->writeStrongBinder(token);
            return NO_ERROR;
        } break;
        case PERMISSION_TO_OP_CODE_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            String16 permission = data.readString16();
            const int32_t opCode = permissionToOpCode(permission);
            reply->writeNoException();
            reply->writeInt32(opCode);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Exemple #22
0
status_t BnMMSdkService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case CONNECT_IMAGETRANSFORMUSER: {
            CHECK_INTERFACE(IMMSdkService, data, reply);
            
            sp<NSImageTransform::IImageTransformUser> client; 
            status_t status = connectImageTransformUser(client);
            reply->writeNoException();
            reply->writeInt32(status);
            if (client != 0)
            {                
                reply->writeInt32(1); 
                reply->writeStrongBinder(client->asBinder()); 
            }
            else 
            {
                reply->writeInt32(0);
            }
            return NO_ERROR;
        } break;
        case CONNECT_EFFECT: {
            CHECK_INTERFACE(IMMSdkService, data, reply);
            String16 clientName(data.readString16());
            sp<NSEffect::IEffectUser> client;             
            status_t status = connectEffect(String16(clientName), client);             
            reply->writeNoException();
            reply->writeInt32(status);
            if (client != 0)
            {
                reply->writeInt32(1);
                reply->writeStrongBinder(client->asBinder()); 
            }
            else 
            {
                reply->writeInt32(0); 
            }
            return NO_ERROR;
        } break;
        case CONNECT_GESTURE: {
            CHECK_INTERFACE(IMMSdkService, data, reply);
            sp<NSGesture::IGestureUser> client; 
            status_t status = connectGesture(client); 
            reply->writeNoException(); 
            reply->writeInt32(status);
            if (client != 0)
            {
                reply->writeInt32(1); 
                reply->writeStrongBinder(client->asBinder()); 
            }
            else 
            {
                reply->writeInt32(0); 
            }            
            return NO_ERROR;
        } break;

        case CONNECT_HEARTRATE: {
            CHECK_INTERFACE(IMMSdkService, data, reply);
            sp<NSHeartrate::IHeartrateUser> client; 
            status_t status = connectHeartrate(client); 
            reply->writeNoException(); 
            reply->writeInt32(status);
            if (client != 0)
            {
                reply->writeInt32(1); 
                reply->writeStrongBinder(client->asBinder()); 
            }
            else 
            {
                reply->writeInt32(0); 
            }            
            return NO_ERROR;
        } break;

        case DISCONNECT_HEARTRATE: {
            CHECK_INTERFACE(IMMSdkService, data, reply);
            status_t status = disconnectHeartrate();
            reply->writeNoException(); 
            reply->writeInt32(status);          
            return status;
        } break;
        
        case GET_MMSDK_FEAUTRE_MANAGER: {
            CHECK_INTERFACE(IMMSdkService, data, reply);
            sp<NSCam::IFeatureManager> client; 
            status_t status = connectFeatureManager(client); 
            reply->writeNoException(); 
            reply->writeInt32(status);
            if (client != 0)
            {
                reply->writeInt32(1); 
                reply->writeStrongBinder(client->asBinder()); 
            }
            else 
            {
                reply->writeInt32(0); 
            }            
            return NO_ERROR;
        } break;

        case REGISTER_CAMERA_1_DEVICE: {
            int callingPid =  android::IPCThreadState::self()->getCallingPid();
            if (callingPid != getpid())
            {
                status_t status = NO_ERROR; 
                ALOGW("Reject, (calling, current) = (%d, %d) only trust the device on the same process", 
                	       callingPid, getpid()); 
                reply->writeNoException(); 
                reply->writeInt32(status);

                return NO_ERROR; 
            }
            CHECK_INTERFACE(IMMSdkService, data, reply);
            NSCam::ICamDevice *pDevice = NULL; 
            data.read(reinterpret_cast<NSCam::ICamDevice*>(pDevice), sizeof(NSCam::ICamDevice *)); 

            status_t status = registerCamera1Device(pDevice); 
            reply->writeNoException(); 
            reply->writeInt32(status);
            return status; 
        } break;            
        case UNREGISTER_CAMERA_1_DEVICE: {
            int callingPid =  android::IPCThreadState::self()->getCallingPid();
            if (callingPid != getpid())
            {
                status_t status = NO_ERROR;             
                ALOGW("Reject, (calling, current) = (%d, %d) only trust the device on the same process", 
                	       callingPid, getpid()); 
                reply->writeNoException(); 
                reply->writeInt32(status);
                
                return NO_ERROR; 
            }
            //
            CHECK_INTERFACE(IMMSdkService, data, reply);
            //NSCam::ICamDevice *pDevice = reinterpret_cast<NSCam::ICamDevice*>(data.readPointer()); 
            NSCam::ICamDevice *pDevice = NULL; 
            data.read(reinterpret_cast<NSCam::ICamDevice*>(pDevice), sizeof(NSCam::ICamDevice *)); 

            status_t status = unRegisterCamera1Device(pDevice); 

            reply->writeNoException(); 
            reply->writeInt32(status);
            return NO_ERROR;         	 
        }break; 
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
void PhoneMachine::receiveSolicited(const Parcel& data)
{
    int serial = data.readInt32();
    int result = data.readInt32();
    RILRequest *request = getPending(serial);

    if (!request) {
	SLOGW("receiveSolicited: not requested serial=%d result=%d\n", serial, result);
	return;
    }
    SLOGV("<<< Solicited message=%s [%d] serial=%d result=%d\n", rilMessageStr(request->message()), 
	   request->message(), serial, result);
    int token   = request->token();
    int message = request->message();
    int ivalue  = 0;
    Parcel extra;
    switch (message) {
    case RIL_REQUEST_GET_SIM_STATUS: 
	ivalue = data.readInt32();   // Store the card state
	break;
    case RIL_REQUEST_GET_CURRENT_CALLS: {
	// We retrieve audio information for the client.
	// We also update the AudioFlinger audio state appropriately based
	//   on the current call state
	ivalue = data.readInt32();   // How many calls there are
	audio_mode_t audio_mode = AUDIO_MODE_NORMAL;
	for (int i = 0 ; i < ivalue ; i++) {
	    RILCall call(data);
	    CallState call_state(call.state, call.index, 
				 call.number, call.numberPresentation, 
				 call.name, call.namePresentation);
	    call_state.writeToParcel(&extra);
	    if (call.state == RIL_CALL_INCOMING)
		audio_mode = AUDIO_MODE_RINGTONE;
	    else if (call.state == RIL_CALL_ACTIVE || call.state == RIL_CALL_DIALING || call.state == RIL_CALL_ALERTING)
		audio_mode = AUDIO_MODE_IN_CALL;
	}
	SLOGV("    %d calls, audio_mode=%d\n", ivalue, audio_mode);
	updateAudioMode(audio_mode);
        break;
        }
    case RIL_REQUEST_DIAL:
    case RIL_REQUEST_HANGUP:
    case RIL_REQUEST_ANSWER:
    case RIL_REQUEST_UDUB:
    case RIL_REQUEST_SET_MUTE:
	break;
    case RIL_REQUEST_GET_MUTE:
	ivalue = data.readInt32();
	break;
    case RIL_REQUEST_SIGNAL_STRENGTH:
	// In actuality, we should probably read all 12 signal strengths
	ivalue = data.readInt32();
	break;
#if defined(SHORT_PLATFORM_VERSION) && (SHORT_PLATFORM_VERSION == 23)
#else
    case RIL_REQUEST_VOICE_REGISTRATION_STATE:
	ivalue = data.readInt32();   // Starts with the number of strings
	for (int i = 0 ; i < ivalue ; i++)
	    extra.writeString16(data.readString16());
	break;
#endif
    case RIL_REQUEST_OPERATOR: {
	ivalue = data.readInt32();
	assert(ivalue == 3);
	extra.writeString16(data.readString16());
	extra.writeString16(data.readString16());
	extra.writeString16(data.readString16());
        break;
        }
    case RIL_REQUEST_RADIO_POWER:
	SLOGV("    RIL Radio Power\n");
	// No response....
	break;
    default:
	SLOGV("Unhandled RIL request %d\n", message);
	break;
    }
    if (request->client() != NULL) {
	SLOGV("    Passing solicited message to client token=%d message=%d result=%d ivalue=%d...\n",
	       token, message, result, ivalue);
	request->client()->Response( token, message, result, ivalue, extra );
    }
    delete request;
}
status_t BnMediaRecorder::onTransact(
                                     uint32_t code, const Parcel& data, Parcel* reply,
                                     uint32_t flags)
{
    switch (code) {
        case RELEASE: {
            ALOGV("RELEASE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(release());
            return NO_ERROR;
        } break;
        case INIT: {
            ALOGV("INIT");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(init());
            return NO_ERROR;
        } break;
        case CLOSE: {
            ALOGV("CLOSE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(close());
            return NO_ERROR;
        } break;
        case RESET: {
            ALOGV("RESET");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(reset());
            return NO_ERROR;
        } break;
        case STOP: {
            ALOGV("STOP");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(stop());
            return NO_ERROR;
        } break;
        case START: {
            ALOGV("START");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(start());
            return NO_ERROR;
        } break;
        case PREPARE: {
            ALOGV("PREPARE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(prepare());
            return NO_ERROR;
        } break;
        case GET_MAX_AMPLITUDE: {
            ALOGV("GET_MAX_AMPLITUDE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int max = 0;
            status_t ret = getMaxAmplitude(&max);
            reply->writeInt32(max);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case SET_VIDEO_SOURCE: {
            ALOGV("SET_VIDEO_SOURCE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int vs = data.readInt32();
            reply->writeInt32(setVideoSource(vs));
            return NO_ERROR;
        } break;
        case SET_AUDIO_SOURCE: {
            ALOGV("SET_AUDIO_SOURCE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int as = data.readInt32();
            reply->writeInt32(setAudioSource(as));
            return NO_ERROR;
        } break;
        case SET_OUTPUT_FORMAT: {
            ALOGV("SET_OUTPUT_FORMAT");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int of = data.readInt32();
            reply->writeInt32(setOutputFormat(of));
            return NO_ERROR;
        } break;
        case SET_VIDEO_ENCODER: {
            ALOGV("SET_VIDEO_ENCODER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int ve = data.readInt32();
            reply->writeInt32(setVideoEncoder(ve));
            return NO_ERROR;
        } break;
        case SET_AUDIO_ENCODER: {
            ALOGV("SET_AUDIO_ENCODER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int ae = data.readInt32();
            reply->writeInt32(setAudioEncoder(ae));
            return NO_ERROR;

        } break;
        case SET_OUTPUT_FILE_FD: {
            ALOGV("SET_OUTPUT_FILE_FD");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int fd = dup(data.readFileDescriptor());
            int64_t offset = data.readInt64();
            int64_t length = data.readInt64();
            reply->writeInt32(setOutputFile(fd, offset, length));
            ::close(fd);
            return NO_ERROR;
        } break;
        case SET_VIDEO_SIZE: {
            ALOGV("SET_VIDEO_SIZE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int width = data.readInt32();
            int height = data.readInt32();
            reply->writeInt32(setVideoSize(width, height));
            return NO_ERROR;
        } break;
        case SET_VIDEO_FRAMERATE: {
            ALOGV("SET_VIDEO_FRAMERATE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int frames_per_second = data.readInt32();
            reply->writeInt32(setVideoFrameRate(frames_per_second));
            return NO_ERROR;
        } break;
        case SET_PARAMETERS: {
            ALOGV("SET_PARAMETER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(setParameters(data.readString8()));
            return NO_ERROR;
        } break;
        case SET_LISTENER: {
            ALOGV("SET_LISTENER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<IMediaRecorderClient> listener =
                interface_cast<IMediaRecorderClient>(data.readStrongBinder());
            reply->writeInt32(setListener(listener));
            return NO_ERROR;
        } break;
        case SET_CLIENT_NAME: {
            ALOGV("SET_CLIENT_NAME");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(setClientName(data.readString16()));
            return NO_ERROR;
        }
        case SET_PREVIEW_SURFACE: {
            ALOGV("SET_PREVIEW_SURFACE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(
                    data.readStrongBinder());
            reply->writeInt32(setPreviewSurface(surface));
            return NO_ERROR;
        } break;
        case SET_CAMERA: {
            ALOGV("SET_CAMERA");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<ICamera> camera = interface_cast<ICamera>(data.readStrongBinder());
            sp<ICameraRecordingProxy> proxy =
                interface_cast<ICameraRecordingProxy>(data.readStrongBinder());
            reply->writeInt32(setCamera(camera, proxy));
            return NO_ERROR;
        } break;
        case SET_INPUT_SURFACE: {
            ALOGV("SET_INPUT_SURFACE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<IGraphicBufferConsumer> surface = interface_cast<IGraphicBufferConsumer>(
                    data.readStrongBinder());
            reply->writeInt32(setInputSurface(surface));
            return NO_ERROR;
        } break;
        case QUERY_SURFACE_MEDIASOURCE: {
            ALOGV("QUERY_SURFACE_MEDIASOURCE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            // call the mediaserver side to create
            // a surfacemediasource
            sp<IGraphicBufferProducer> surfaceMediaSource = querySurfaceMediaSource();
            // The mediaserver might have failed to create a source
            int returnedNull= (surfaceMediaSource == NULL) ? 1 : 0 ;
            reply->writeInt32(returnedNull);
            if (!returnedNull) {
                reply->writeStrongBinder(IInterface::asBinder(surfaceMediaSource));
            }
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}