react-native-navigation的迁移库

AndroidUtils.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. const exec = require('shell-utils').exec;
  2. module.exports = {
  3. pressBack: () => {
  4. exec.execSync('adb shell input keyevent 4');
  5. },
  6. pressMenu: () => {
  7. exec.execSync('adb shell input keyevent 82');
  8. },
  9. pressEnter: (keyCode) => {
  10. exec.execSync(`adb shell input keyevent 66`);
  11. },
  12. pressLockButton: () => {
  13. exec.execSync(`adb shell input keyevent 26`);
  14. },
  15. pressKeyCode: (keyCode) => {
  16. exec.execSync(`adb shell input keyevent ${keyCode}`);
  17. },
  18. grantPermission: () => {
  19. exec.execSync('adb shell pm grant com.reactnativenavigation.playground android.permission.READ_PHONE_STATE');
  20. },
  21. revokePermission: () => {
  22. exec.execSync('adb shell pm revoke com.reactnativenavigation.playground android.permission.READ_PHONE_STATE');
  23. },
  24. openActivity: () => {
  25. exec.execSync('adb shell am start -n com.reactnativenavigation.playground/.MainActivity');
  26. },
  27. executeShellCommand: (command) => {
  28. exec.execSync(`adb shell ${command}`);
  29. },
  30. enterText: (text) => {
  31. exec.execSync(`adb shell input text ${text}`);
  32. },
  33. swipeUp: () => {
  34. exec.execSync('adb shell input touchscreen swipe 300 1200 500 0 100');
  35. }
  36. };