main_cells.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #define LOG_TAG "CellsService"
  2. #include <fcntl.h>
  3. #include <cutils/log.h>
  4. #include <cutils/properties.h>
  5. #include <binder/BinderService.h>
  6. #include <CellsPrivateService.h>
  7. #include "cellnet.h"
  8. using namespace android;
  9. static void init_vm_exit()
  10. {
  11. /*int vmfd = open("/.cell",O_RDONLY);
  12. if(vmfd >= 0){
  13. char buf[10];
  14. int len = read(vmfd, buf, 10);
  15. if(len > 0){
  16. if(strcmp(buf,"0") == 0){
  17. property_set("persist.sys.exit", "0");
  18. }else{
  19. property_set("persist.sys.exit", "1");
  20. }
  21. }
  22. close(vmfd);
  23. }*/
  24. property_set("persist.sys.exit", "1");
  25. }
  26. static int init_vm_name()
  27. {
  28. int vmfd = open("/.name",O_RDONLY);
  29. if(vmfd >= 0){
  30. char buf[125];
  31. int len = read(vmfd, buf, 125);
  32. if(len > 0){
  33. buf[len]='\0';
  34. property_set("persist.sys.vm.name", buf);
  35. close(vmfd);
  36. ALOGI("persist.sys.vm.name = %s ", buf);
  37. int i = 0;
  38. sscanf(buf, "cell%d",&i);
  39. return i;
  40. }
  41. close(vmfd);
  42. }
  43. return 0;
  44. }
  45. int main(int /*argc*/, char** /*argv*/)
  46. {
  47. ALOGI("GuiExt service start...");
  48. char value[PROPERTY_VALUE_MAX];
  49. property_get("ro.boot.vm", value, "1");
  50. if((strcmp(value, "0") == 0)){
  51. property_set("persist.sys.exit", "0");
  52. property_set("persist.sys.vm.name", "");
  53. property_set("persist.sys.active", "");
  54. }else{
  55. init_vm_exit();
  56. int i = init_vm_name();
  57. if(i > 0){
  58. rnameveth(i);
  59. }
  60. }
  61. CellsPrivateService::publishAndJoinThreadPool(true);
  62. ProcessState::self()->setThreadPoolMaxThreadCount(4);
  63. ALOGD("Cells service exit...");
  64. return 0;
  65. }