ICellsPrivateService.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. #define LOG_TAG "CELLSSERVICE"
  2. #include <utils/Errors.h>
  3. #include <utils/RefBase.h>
  4. #include <utils/Vector.h>
  5. #include <utils/Timers.h>
  6. #include <utils/String16.h>
  7. #include <binder/Parcel.h>
  8. #include <binder/IInterface.h>
  9. #include <cutils/log.h>
  10. #include "ICellsPrivateService.h"
  11. namespace android {
  12. class BpCellsPrivateService : public BpInterface<ICellsPrivateService>
  13. {
  14. public:
  15. BpCellsPrivateService(const sp<IBinder>& impl) : BpInterface<ICellsPrivateService>(impl)
  16. {
  17. }
  18. virtual status_t setProperty(const String16& name,const String16& value)
  19. {
  20. Parcel data, reply;
  21. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  22. data.writeString16(name);
  23. data.writeString16(value);
  24. status_t result = remote()->transact(SETPROPERTY, data, &reply);
  25. if (result != NO_ERROR) {
  26. ALOGE("could not set property\n");
  27. return result;
  28. }
  29. result = reply.readInt32();
  30. return result;
  31. }
  32. virtual status_t startCellsVM(const String16& name)
  33. {
  34. Parcel data, reply;
  35. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  36. data.writeString16(name);
  37. status_t result = remote()->transact(STARTCELLSVM, data, &reply);
  38. if (result != NO_ERROR) {
  39. ALOGE("could not start cellsvm\n");
  40. return result;
  41. }
  42. result = reply.readInt32();
  43. return result;
  44. }
  45. virtual status_t stopCellsVM(const String16& name)
  46. {
  47. Parcel data, reply;
  48. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  49. data.writeString16(name);
  50. status_t result = remote()->transact(STOPCELLSVM, data, &reply);
  51. if (result != NO_ERROR) {
  52. ALOGE("could not stop cellsvm\n");
  53. return result;
  54. }
  55. result = reply.readInt32();
  56. return result;
  57. }
  58. virtual status_t cellsSwitchVM(const String16& name)
  59. {
  60. Parcel data, reply;
  61. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  62. data.writeString16(name);
  63. status_t result = remote()->transact(CELLSSWITCHVM, data, &reply);
  64. if (result != NO_ERROR) {
  65. ALOGE("could not cells switch vm. \n");
  66. return result;
  67. }
  68. result = reply.readInt32();
  69. return result;
  70. }
  71. virtual status_t cellsSwitchHOST(const String16& name)
  72. {
  73. Parcel data, reply;
  74. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  75. data.writeString16(name);
  76. status_t result = remote()->transact(CELLSSWITCHHOST, data, &reply);
  77. if (result != NO_ERROR) {
  78. ALOGE("could not cells switch host. \n");
  79. return result;
  80. }
  81. result = reply.readInt32();
  82. return result;
  83. }
  84. virtual status_t enterCell(const String16& name)
  85. {
  86. Parcel data, reply;
  87. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  88. data.writeString16(name);
  89. status_t result = remote()->transact(ENTERCELL, data, &reply);
  90. if (result != NO_ERROR) {
  91. ALOGE("could not enter cell. \n");
  92. return result;
  93. }
  94. result = reply.readInt32();
  95. return result;
  96. }
  97. virtual status_t enterHost(const String16& name)
  98. {
  99. Parcel data, reply;
  100. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  101. data.writeString16(name);
  102. status_t result = remote()->transact(ENTERHOST, data, &reply);
  103. if (result != NO_ERROR) {
  104. ALOGE("could not enter host. \n");
  105. return result;
  106. }
  107. result = reply.readInt32();
  108. return result;
  109. }
  110. virtual status_t exitCell(const String16& name)
  111. {
  112. Parcel data, reply;
  113. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  114. data.writeString16(name);
  115. status_t result = remote()->transact(EXITCELL, data, &reply);
  116. if (result != NO_ERROR) {
  117. ALOGE("could not exit cell. \n");
  118. return result;
  119. }
  120. result = reply.readInt32();
  121. return result;
  122. }
  123. virtual status_t exitHost(const String16& name)
  124. {
  125. Parcel data, reply;
  126. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  127. data.writeString16(name);
  128. status_t result = remote()->transact(EXITHOST, data, &reply);
  129. if (result != NO_ERROR) {
  130. ALOGE("could not exit host. \n");
  131. return result;
  132. }
  133. result = reply.readInt32();
  134. return result;
  135. }
  136. virtual status_t switchCellsVM(const String16& name)
  137. {
  138. Parcel data, reply;
  139. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  140. data.writeString16(name);
  141. status_t result = remote()->transact(SWITCHCELLSVM, data, &reply);
  142. if (result != NO_ERROR) {
  143. ALOGE("could not switch cellsvm\n");
  144. return result;
  145. }
  146. result = reply.readInt32();
  147. return result;
  148. }
  149. virtual status_t uploadCellsVM(const String16& name)
  150. {
  151. Parcel data, reply;
  152. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  153. data.writeString16(name);
  154. status_t result = remote()->transact(UPLOADCELLSVM, data, &reply);
  155. if (result != NO_ERROR) {
  156. ALOGE("could not upload cellsvm\n");
  157. return result;
  158. }
  159. result = reply.readInt32();
  160. return result;
  161. }
  162. virtual status_t downloadCellsVM(const String16& name)
  163. {
  164. Parcel data, reply;
  165. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  166. data.writeString16(name);
  167. status_t result = remote()->transact(DOWNLOADCELLSVM, data, &reply);
  168. if (result != NO_ERROR) {
  169. ALOGE("could not download cellsvm\n");
  170. return result;
  171. }
  172. result = reply.readInt32();
  173. return result;
  174. }
  175. virtual status_t untarCellsVM(const String16& name)
  176. {
  177. Parcel data, reply;
  178. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  179. data.writeString16(name);
  180. status_t result = remote()->transact(UNTARCELLSVM, data, &reply);
  181. if (result != NO_ERROR) {
  182. ALOGE("could not untar cellsvm\n");
  183. return result;
  184. }
  185. result = reply.readInt32();
  186. return result;
  187. }
  188. virtual status_t tarCellsVM(const String16& name)
  189. {
  190. Parcel data, reply;
  191. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  192. data.writeString16(name);
  193. status_t result = remote()->transact(TARCELLSVM, data, &reply);
  194. if (result != NO_ERROR) {
  195. ALOGE("could not tar cellsvm\n");
  196. return result;
  197. }
  198. result = reply.readInt32();
  199. return result;
  200. }
  201. virtual status_t vmSystemReady(const String16& name)
  202. {
  203. Parcel data, reply;
  204. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  205. data.writeString16(name);
  206. status_t result = remote()->transact(SYSTEMREADY, data, &reply);
  207. if (result != NO_ERROR) {
  208. ALOGE("vm system ready err!\n");
  209. return result;
  210. }
  211. result = reply.readInt32();
  212. return result;
  213. }
  214. virtual status_t sendCellsVM(const String16& path, const String16& address)
  215. {
  216. Parcel data, reply;
  217. data.writeInterfaceToken(ICellsPrivateService::getInterfaceDescriptor());
  218. data.writeString16(path);
  219. data.writeString16(address);
  220. status_t result = remote()->transact(SENDCELLSVM, data, &reply);
  221. if (result != NO_ERROR) {
  222. ALOGE("send VM err!\n");
  223. return result;
  224. }
  225. result = reply.readInt32();
  226. return result;
  227. }
  228. };
  229. IMPLEMENT_META_INTERFACE(CellsPrivateService, "CellsPrivateService");
  230. status_t BnCellsPrivateService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
  231. {
  232. switch(code)
  233. {
  234. case SETPROPERTY:
  235. {
  236. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  237. String16 name = data.readString16();
  238. String16 value = data.readString16();
  239. status_t result = setProperty(name, value);
  240. reply->writeInt32(result);
  241. return NO_ERROR;
  242. }
  243. break;
  244. case STARTCELLSVM:
  245. {
  246. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  247. String16 name = data.readString16();
  248. status_t result = startCellsVM(name);
  249. reply->writeInt32(result);
  250. return NO_ERROR;
  251. }
  252. break;
  253. case STOPCELLSVM:
  254. {
  255. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  256. String16 name = data.readString16();
  257. status_t result = stopCellsVM(name);
  258. reply->writeInt32(result);
  259. return NO_ERROR;
  260. }
  261. break;
  262. case CELLSSWITCHVM:
  263. {
  264. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  265. String16 name = data.readString16();
  266. status_t result = cellsSwitchVM(name);
  267. reply->writeInt32(result);
  268. return NO_ERROR;
  269. }
  270. break;
  271. case CELLSSWITCHHOST:
  272. {
  273. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  274. String16 name = data.readString16();
  275. status_t result = cellsSwitchHOST(name);
  276. reply->writeInt32(result);
  277. return NO_ERROR;
  278. }
  279. break;
  280. case ENTERCELL:
  281. {
  282. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  283. String16 name = data.readString16();
  284. status_t result = enterCell(name);
  285. reply->writeInt32(result);
  286. return NO_ERROR;
  287. }
  288. break;
  289. case ENTERHOST:
  290. {
  291. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  292. String16 name = data.readString16();
  293. status_t result = enterHost(name);
  294. reply->writeInt32(result);
  295. return NO_ERROR;
  296. }
  297. break;
  298. case EXITCELL:
  299. {
  300. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  301. String16 name = data.readString16();
  302. status_t result = exitCell(name);
  303. reply->writeInt32(result);
  304. return NO_ERROR;
  305. }
  306. break;
  307. case EXITHOST:
  308. {
  309. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  310. String16 name = data.readString16();
  311. status_t result = exitHost(name);
  312. reply->writeInt32(result);
  313. return NO_ERROR;
  314. }
  315. break;
  316. case SWITCHCELLSVM:
  317. {
  318. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  319. String16 name = data.readString16();
  320. status_t result = switchCellsVM(name);
  321. reply->writeInt32(result);
  322. return NO_ERROR;
  323. }
  324. break;
  325. case UPLOADCELLSVM:
  326. {
  327. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  328. String16 name = data.readString16();
  329. status_t result = uploadCellsVM(name);
  330. reply->writeInt32(result);
  331. return NO_ERROR;
  332. }
  333. break;
  334. case DOWNLOADCELLSVM:
  335. {
  336. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  337. String16 name = data.readString16();
  338. status_t result = downloadCellsVM(name);
  339. reply->writeInt32(result);
  340. return NO_ERROR;
  341. }
  342. break;
  343. case UNTARCELLSVM:
  344. {
  345. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  346. String16 name = data.readString16();
  347. status_t result = untarCellsVM(name);
  348. reply->writeInt32(result);
  349. return NO_ERROR;
  350. }
  351. break;
  352. case TARCELLSVM:
  353. {
  354. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  355. String16 name = data.readString16();
  356. status_t result = tarCellsVM(name);
  357. reply->writeInt32(result);
  358. return NO_ERROR;
  359. }
  360. break;
  361. case SYSTEMREADY:
  362. {
  363. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  364. String16 name = data.readString16();
  365. status_t result = vmSystemReady(name);
  366. reply->writeInt32(result);
  367. return NO_ERROR;
  368. }
  369. break;
  370. case SENDCELLSVM:
  371. {
  372. CHECK_INTERFACE(ICellsPrivateService, data, reply);
  373. String16 path = data.readString16();
  374. String16 address = data.readString16();
  375. status_t result = sendCellsVM(path, address);
  376. reply->writeInt32(result);
  377. return NO_ERROR;
  378. }
  379. break;
  380. }
  381. return BBinder::onTransact(code, data, reply, flags);
  382. }
  383. };