jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.7KB

  1. #include "BnAndroidShm.h"
  2. #include <binder/Parcel.h>
  3. namespace android {
  4. status_t BnAndroidShm::onTransact( uint32_t code,
  5. const Parcel &data,
  6. Parcel *reply,
  7. uint32_t flags)
  8. {
  9. switch(code) {
  10. case HW_SENDCOMMAND:{
  11. CHECK_INTERFACE(IAndroidShm, data, reply);
  12. const char *str;
  13. str = data.readCString();
  14. reply->writeInt32(sendCommand(str));
  15. return NO_ERROR;
  16. }break;
  17. case HW_GETBUFFER:{
  18. CHECK_INTERFACE(IAndroidShm, data, reply);
  19. int32_t index;
  20. data.readInt32(&index);
  21. sp<IMemoryHeap> Data = getBuffer(index);
  22. if(Data != NULL){
  23. reply->writeStrongBinder(Data->asBinder());
  24. }
  25. return NO_ERROR;
  26. }break;
  27. case HW_ALLOC_SHM:{
  28. CHECK_INTERFACE(IAndroidShm, data, reply);
  29. int32_t size;
  30. data.readInt32(&size);
  31. reply->writeInt32(allocShm(size));
  32. return NO_ERROR;
  33. }break;
  34. case HW_REMOVE_SHM:{
  35. CHECK_INTERFACE(IAndroidShm, data, reply);
  36. int32_t index;
  37. data.readInt32(&index);
  38. reply->writeInt32(removeShm(index));
  39. return NO_ERROR;
  40. }break;
  41. case HW_IS_ALLOCATED:{
  42. CHECK_INTERFACE(IAndroidShm, data, reply);
  43. int32_t index;
  44. data.readInt32(&index);
  45. reply->writeInt32(isAllocated(index));
  46. return NO_ERROR;
  47. }break;
  48. case HW_SET_REGISTRY_INDEX:{
  49. CHECK_INTERFACE(IAndroidShm, data, reply);
  50. int32_t index;
  51. data.readInt32(&index);
  52. reply->writeInt32(setRegistryIndex(index));
  53. return NO_ERROR;
  54. }break;
  55. case HW_GET_REGISTRY_INDEX:{
  56. CHECK_INTERFACE(IAndroidShm, data, reply);
  57. reply->writeInt32(getRegistryIndex());
  58. return NO_ERROR;
  59. }break;
  60. case HW_INIT_SEMAPHORE:{
  61. CHECK_INTERFACE(IAndroidShm, data, reply);
  62. const char *name;
  63. name = data.readCString();
  64. sp<IMemoryHeap> Data = InitSemaphore(name);
  65. if(Data != NULL){
  66. reply->writeStrongBinder(Data->asBinder());
  67. }
  68. return NO_ERROR;
  69. }break;
  70. default:
  71. return BBinder::onTransact(code, data, reply, flags);
  72. }
  73. }
  74. };