settings.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package shell
  2. func (d DeviceShell) putGlobal(key, value string) ([]byte, error) {
  3. return d.putSettings("global", key, value)
  4. }
  5. // func (d DeviceShell) putSecure(key, value string) ([]byte, error) {
  6. // return d.putSettings("secure", key, value)
  7. // }
  8. func (d DeviceShell) putSystem(key, value string) ([]byte, error) {
  9. return d.putSettings("system", key, value)
  10. }
  11. func (d DeviceShell) putSettings(namespace, key, value string) ([]byte, error) {
  12. return d.RunSync("settings", "put", namespace, key, value)
  13. }
  14. // ShowTouches enables touch pointer and touch coordinates showing
  15. func (d DeviceShell) ShowTouches() ([]byte, error) {
  16. var response []byte
  17. for _, val := range [...]string{"show_touches", "pointer_location"} {
  18. res, err := d.putSystem(val, "1")
  19. if err != nil {
  20. return res, err
  21. } else {
  22. response = append(response, res...)
  23. }
  24. }
  25. return response, nil
  26. }
  27. // DisableAnimations disables "transition_animation_scale", "window_animation_scale" and "animator_duration_scale"
  28. func (d DeviceShell) DisableAnimations() ([]byte, error) {
  29. var response []byte
  30. params := [...]string{"transition_animation_scale", "window_animation_scale", "animator_duration_scale"}
  31. for i := range params {
  32. res, err := d.putGlobal(params[i], "0.0")
  33. if err != nil {
  34. return res, err
  35. } else {
  36. response = append(response, res...)
  37. }
  38. }
  39. return response, nil
  40. }