Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

AccessibilityService でできてしまうこと

441 views

Published on

DroidKaigi 2018のセッション「AccessibilityService でできてしまうこと」のセッションスライドです。
動画が埋め込まれている都合、当日使用したものと完全に同じではないことをご了承ください

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

AccessibilityService でできてしまうこと

  1. 1. AccessibilityService DroidKaigi 2018 (2/8~2/9) by Tamaki Hidetsugu (Ralph) @r_ralph_h
  2. 2. Tamaki Hidetsugu (Ralph) • 4 • Twitter: @r_ralph_h • 2015/2 ~ Holiday • 2018/4 ~ LINE
  3. 3. • • •
  4. 4. AccessibilityService ?
  5. 5. AccessibilityService • • • FB • https://developer.android.com/training/accessibility/service.html
  6. 6. AccessibilityService • DroidKaigi 2017 • AccessibilityService https://speakerdeck.com/litmon/accessibilityservicewoshi- tuteapurifalseke-neng-xing-woguang-geyou
  7. 7. • Google TalkBack
  8. 8. AccessibilityService
  9. 9. AS • •
  10. 10. AS • • AS • View • View
  11. 11. AccessibilityService • AccessibilityService • AccessibilityService
  12. 12. AccessibilityService • onAccessibilityEvent() • • onAccessibilityEvent()
  13. 13. AccessibilityNodeInfo • View • ViewGroup child NodeInfo • View
  14. 14. getRootInActiveWindow() • AccessibilityNodeInfo • Activity NodeInfo • View
  15. 15. View Read • • contentDescription nodeInfo.text nodeInfo.contentDescription
  16. 16. View Write • EditText • View val text = "Hello World" val args = Bundle().also { it.putString( AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text) } nodeInfo.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args) nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK)
  17. 17. AccessibilityService
  18. 18. Android https://www.symantec.com/connect/nl/blogs/android-33
  19. 19. 1.
  20. 20. • ChatKit stfalcon-studio/ChatKit
  21. 21. View fun logViewHierarchy(nodeInfo: AccessibilityNodeInfo?, depth: Int) { when (nodeInfo?.childCount) { null -> return 0 -> Log.d(TAG, "${" ".repeat(depth)} " + "View: ${nodeInfo.className} " + "(id=${nodeInfo.viewIdResourceName})") else -> (0 until nodeInfo.childCount) .map { nodeInfo.getChild(it) } .forEach { logViewHierarchy(it, depth + 1) } } } getRootInActiveWindow() NodeInfo
  22. 22. View View: android.widget.TextView (id=null) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageText) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageText) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageTime) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageText) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageTime) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageTime) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageText) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageText) View: android.widget.TextView (id=ms.ralph.dk2018_sample1:id/messageTime) View: android.widget.EditText (id=ms.ralph.dk2018_sample1:id/messageInput) View: android.widget.ImageButton (id=ms.ralph.dk2018_sample1:id/ messageSendButton) id AccessibilityNodeInfo
  23. 23. rootInActiveWindow.findAccessibilityNodeInfosByViewId( "ms.ralph.android.dk2018_sample1:id/messageText") // <=id .forEach { Log.d(TAG, it.text.toString()) }
  24. 24. val editNode = rootInActiveWindow .findAccessibilityNodeInfosByViewId( "ms.ralph.dk2018_sample1:id/messageInput")[0] pasteText(editNode, System.currentTimeMillis().toString()) pasteText() EditText
  25. 25. val time = System.currentTimeMillis() pasteText(editNode, time.toString()) if (time % 10 == 0L) { val btnNode = rootInActiveWindow .findAccessibilityNodeInfosByViewId( "ms.ralph.dk2018_sample1:id/messageSendButton")[0] tapButton(btnNode) } UNIX 1 0 tapButton() View
  26. 26. 2. Runtime Permission
  27. 27. Runtime Permission? Android 6.0
  28. 28. Runtime Permission
  29. 29. ( )
  30. 30. • • •
  31. 31. • PlayStore 2017/11 http://www.androidpolice.com/2017/11/12/google-will-remove-play-store-apps-use- accessibility-services-anything-except-helping-disabled-users/
  32. 32. • • • • •
  33. 33. Thank you !

×