123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- #define LOG_TAG "CELLSSERVICE"
- #include <utils/Errors.h>
- #include <utils/RefBase.h>
- #include <utils/Vector.h>
- #include <utils/Timers.h>
- #include <utils/String16.h>
- #include <binder/Parcel.h>
- #include <binder/IInterface.h>
- #include <cutils/log.h>
- #include "ICellsPrivateService.h"
- namespace android {
- class BpCellsPrivateService : public BpInterface<ICellsPrivateService>
- {
- public:
- BpCellsPrivateService(const sp<IBinder>& impl) : BpInterface<ICellsPrivateService>(impl)
- {
- }
- virtual status_t setProperty(const String16& name,const String16& value)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- data.writeString16(value);
- status_t result = remote()->transact(SETPROPERTY, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not set property\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t startCellsVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(STARTCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not start cellsvm\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t stopCellsVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(STOPCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not stop cellsvm\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t cellsSwitchVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(CELLSSWITCHVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not cells switch vm. \n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t cellsSwitchHOST(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(CELLSSWITCHHOST, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not cells switch host. \n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t enterCell(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(ENTERCELL, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not enter cell. \n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t enterHost(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(ENTERHOST, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not enter host. \n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t exitCell(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(EXITCELL, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not exit cell. \n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t exitHost(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(EXITHOST, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not exit host. \n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t switchCellsVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(SWITCHCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not switch cellsvm\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t uploadCellsVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(UPLOADCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not upload cellsvm\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t downloadCellsVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(DOWNLOADCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not download cellsvm\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t untarCellsVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(UNTARCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not untar cellsvm\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t tarCellsVM(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(TARCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("could not tar cellsvm\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t vmSystemReady(const String16& name)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(name);
- status_t result = remote()->transact(SYSTEMREADY, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("vm system ready err!\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- virtual status_t sendCellsVM(const String16& path, const String16& address)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
- data.writeString16(path);
- data.writeString16(address);
- status_t result = remote()->transact(SENDCELLSVM, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("send VM err!\n");
- return result;
- }
- result = reply.readInt32();
- return result;
- }
- };
- IMPLEMENT_META_INTERFACE(CellsPrivateService, "CellsPrivateService");
- status_t BnCellsPrivateService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
- {
- switch(code)
- {
- case SETPROPERTY:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- String16 value = data.readString16();
- status_t result = setProperty(name, value);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case STARTCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = startCellsVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case STOPCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = stopCellsVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case CELLSSWITCHVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = cellsSwitchVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case CELLSSWITCHHOST:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = cellsSwitchHOST(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case ENTERCELL:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = enterCell(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case ENTERHOST:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = enterHost(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case EXITCELL:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = exitCell(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case EXITHOST:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = exitHost(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case SWITCHCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = switchCellsVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case UPLOADCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = uploadCellsVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case DOWNLOADCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = downloadCellsVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case UNTARCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = untarCellsVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case TARCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = tarCellsVM(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case SYSTEMREADY:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 name = data.readString16();
- status_t result = vmSystemReady(name);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- case SENDCELLSVM:
- {
- CHECK_INTERFACE(ICellsPrivateService, data, reply);
- String16 path = data.readString16();
- String16 address = data.readString16();
- status_t result = sendCellsVM(path, address);
- reply->writeInt32(result);
- return NO_ERROR;
- }
- break;
- }
- return BBinder::onTransact(code, data, reply, flags);
- }
- };
|