From 5b46509f8d2e670bf39031670a01581993e9435a Mon Sep 17 00:00:00 2001 From: niostack Date: Thu, 13 Feb 2025 10:33:34 +0800 Subject: [PATCH] first commit --- .github/workflows/build-apk.yml | 45 + .gitignore | 9 + .vscode/launch.json | 24 + .vscode/settings.json | 3 + LICENSE | 20 + README.md | 171 ++ app/.gitignore | 1 + app/build.gradle | 96 + app/proguard-rules.pro | 17 + .../stub/AccessibilityEventListener.java | 57 + .../stub/AccessibilityNodeInfoDumper.java | 241 ++ .../com/tikfarm/stub/AutomatorHttpServer.java | 140 ++ .../com/tikfarm/stub/AutomatorService.java | 1276 +++++++++++ .../tikfarm/stub/AutomatorServiceImpl.java | 1976 +++++++++++++++++ .../com/tikfarm/stub/ConfiguratorInfo.java | 96 + .../java/com/tikfarm/stub/DeviceInfo.java | 156 ++ .../java/com/tikfarm/stub/Helper.java | 39 + .../java/com/tikfarm/stub/Log.java | 40 + .../tikfarm/stub/NotImplementedException.java | 43 + .../java/com/tikfarm/stub/ObjInfo.java | 239 ++ .../java/com/tikfarm/stub/Point.java | 56 + .../java/com/tikfarm/stub/Rect.java | 84 + .../java/com/tikfarm/stub/Selector.java | 563 +++++ .../java/com/tikfarm/stub/Stub.java | 102 + .../com/tikfarm/stub/TouchController.java | 179 ++ .../stub/watcher/ClickUiObjectWatcher.java | 60 + .../stub/watcher/PressKeysWatcher.java | 95 + .../tikfarm/stub/watcher/SelectorWatcher.java | 56 + app/src/main/AndroidManifest.xml | 103 + .../aidl/android/view/IRotationWatcher.aidl | 25 + .../tikmatrix/AdbBroadcastReceiver.java | 59 + .../com/github/tikmatrix/FastInputIME.java | 341 +++ .../com/github/tikmatrix/MainActivity.java | 330 +++ .../tikmatrix/MockLocationProvider.java | 46 + .../com/github/tikmatrix/ScreenClient.java | 46 + .../github/tikmatrix/ScreenHttpServer.java | 281 +++ .../java/com/github/tikmatrix/Service.java | 84 + .../tikmatrix/compat/InputManagerWrapper.java | 122 + .../tikmatrix/monitor/AbstractMonitor.java | 31 + .../tikmatrix/monitor/BatteryMonitor.java | 58 + .../tikmatrix/monitor/HttpPostNotifier.java | 52 + .../tikmatrix/monitor/RotationMonitor.java | 59 + .../github/tikmatrix/util/InternalApi.java | 86 + .../github/tikmatrix/util/MemoryManager.java | 219 ++ .../github/tikmatrix/util/OkhttpManager.java | 56 + .../github/tikmatrix/util/Permissons4App.java | 113 + .../res/drawable-hdpi/ic_notification.png | Bin 0 -> 4592 bytes .../res/drawable-mdpi/ic_notification.png | Bin 0 -> 1902 bytes .../res/drawable-xhdpi/ic_notification.png | Bin 0 -> 4592 bytes app/src/main/res/drawable/btn_bg.xml | 10 + app/src/main/res/drawable/btn_nor_down.xml | 8 + app/src/main/res/drawable/check_border.xml | 10 + app/src/main/res/drawable/ic_random_24dp.xml | 9 + app/src/main/res/drawable/icon.png | Bin 0 -> 1902 bytes app/src/main/res/drawable/rounded_corner.xml | 5 + app/src/main/res/layout/activity_main.xml | 176 ++ app/src/main/res/layout/keyboard.xml | 9 + app/src/main/res/layout/preview.xml | 9 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes app/src/main/res/values-w820dp/dimens.xml | 29 + app/src/main/res/values/colors.xml | 296 +++ app/src/main/res/values/dimens.xml | 28 + app/src/main/res/values/strings.xml | 44 + app/src/main/res/values/styles.xml | 50 + app/src/main/res/xml/file_paths.xml | 5 + app/src/main/res/xml/keyboard.xml | 26 + app/src/main/res/xml/method.xml | 6 + .../main/res/xml/network_security_config.xml | 7 + build.gradle | 23 + build.ps1 | 2 + build.sh | 5 + gradle.properties | 14 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43504 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 252 +++ gradlew.bat | 94 + install.ps1 | 6 + release.keystore | Bin 0 -> 2174 bytes settings.gradle | 1 + 82 files changed, 9126 insertions(+) create mode 100644 .github/workflows/build-apk.yml create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 LICENSE create mode 100644 README.md create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/com/tikfarm/stub/AccessibilityEventListener.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/AccessibilityNodeInfoDumper.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/AutomatorHttpServer.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/AutomatorService.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/AutomatorServiceImpl.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/ConfiguratorInfo.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/DeviceInfo.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/Helper.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/Log.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/NotImplementedException.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/ObjInfo.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/Point.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/Rect.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/Selector.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/Stub.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/TouchController.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/watcher/ClickUiObjectWatcher.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/watcher/PressKeysWatcher.java create mode 100644 app/src/androidTest/java/com/tikfarm/stub/watcher/SelectorWatcher.java create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/aidl/android/view/IRotationWatcher.aidl create mode 100644 app/src/main/java/com/github/tikmatrix/AdbBroadcastReceiver.java create mode 100644 app/src/main/java/com/github/tikmatrix/FastInputIME.java create mode 100644 app/src/main/java/com/github/tikmatrix/MainActivity.java create mode 100644 app/src/main/java/com/github/tikmatrix/MockLocationProvider.java create mode 100644 app/src/main/java/com/github/tikmatrix/ScreenClient.java create mode 100644 app/src/main/java/com/github/tikmatrix/ScreenHttpServer.java create mode 100644 app/src/main/java/com/github/tikmatrix/Service.java create mode 100644 app/src/main/java/com/github/tikmatrix/compat/InputManagerWrapper.java create mode 100644 app/src/main/java/com/github/tikmatrix/monitor/AbstractMonitor.java create mode 100644 app/src/main/java/com/github/tikmatrix/monitor/BatteryMonitor.java create mode 100644 app/src/main/java/com/github/tikmatrix/monitor/HttpPostNotifier.java create mode 100644 app/src/main/java/com/github/tikmatrix/monitor/RotationMonitor.java create mode 100644 app/src/main/java/com/github/tikmatrix/util/InternalApi.java create mode 100644 app/src/main/java/com/github/tikmatrix/util/MemoryManager.java create mode 100644 app/src/main/java/com/github/tikmatrix/util/OkhttpManager.java create mode 100644 app/src/main/java/com/github/tikmatrix/util/Permissons4App.java create mode 100644 app/src/main/res/drawable-hdpi/ic_notification.png create mode 100644 app/src/main/res/drawable-mdpi/ic_notification.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_notification.png create mode 100644 app/src/main/res/drawable/btn_bg.xml create mode 100644 app/src/main/res/drawable/btn_nor_down.xml create mode 100644 app/src/main/res/drawable/check_border.xml create mode 100644 app/src/main/res/drawable/ic_random_24dp.xml create mode 100644 app/src/main/res/drawable/icon.png create mode 100644 app/src/main/res/drawable/rounded_corner.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/keyboard.xml create mode 100644 app/src/main/res/layout/preview.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/values-w820dp/dimens.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/dimens.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/main/res/xml/file_paths.xml create mode 100644 app/src/main/res/xml/keyboard.xml create mode 100644 app/src/main/res/xml/method.xml create mode 100644 app/src/main/res/xml/network_security_config.xml create mode 100644 build.gradle create mode 100644 build.ps1 create mode 100644 build.sh create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 install.ps1 create mode 100644 release.keystore create mode 100644 settings.gradle diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml new file mode 100644 index 0000000..2cd66c6 --- /dev/null +++ b/.github/workflows/build-apk.yml @@ -0,0 +1,45 @@ +name: Release +run-name: ${{ github.actor }} is building Release 🚀 +on: + push: + tags: + - 'v*' +permissions: + contents: write +jobs: + deploy: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Checkout main repository + uses: actions/checkout@v3 + with: + ref: main + - name: Build APK + run: | + chmod +x ./gradlew + ./gradlew build + ./gradlew packageDebugAndroidTest + mkdir -p app/build/apk + mv app/build/outputs/apk/debug/app-debug.apk app/build/apk/com.github.tikmatrix.apk + mv app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk app/build/apk/com.github.tikmatrix.test.apk + - name: Upload APK + uses: ryand56/r2-upload-action@v1.2.3 + with: + r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} + r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} + r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} + r2-bucket: tikmatrix + source-dir: app/build/apk/ + destination-dir: ./ + - name: Update Version + run: | + TAG_NAME="${GITHUB_REF#refs/tags/}" + curl -X PUT https://pro.api.tikmatrix.com/ci/update_core_version \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer ${{ secrets.API_KEY }}" \ + -d '{ + "apk_version": "'"${TAG_NAME}"'", + "test_apk_version": "'"${TAG_NAME}"'" + }' + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b109139 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.gradle +local.properties +.DS_Store +build +captures +.idea +app/app.iml +tikmatrix-android.iml +*.iml diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..1809bfa --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "android", + "request": "launch", + "name": "Android launch", + "appSrcRoot": "${workspaceRoot}/app/src/main", + "apkFile": "${workspaceRoot}/app/build/outputs/apk/debug/app-debug.apk", + "adbPort": 5037 + }, + { + "type": "android", + "request": "attach", + "name": "Android attach", + "appSrcRoot": "${workspaceRoot}/app/src/main", + "adbPort": 5037, + "processId": "${command:PickAndroidProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e0f15db --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9920fcc --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) +Copyright (c) 2015 xiaocong@gmail.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..90ac67a --- /dev/null +++ b/README.md @@ -0,0 +1,171 @@ +# Purpose + +Support Android 5.0+ +[UIAutomator](http://developer.android.com/tools/testing/testing_ui.html) is a +great tool to perform Android UI testing, but to do it, you have to write java +code, compile it, install the jar, and run. It's a complex steps for all +testers... + +This project is to build a light weight jsonrpc server in Android device, so +that we can just write PC side script to write UIAutomator tests. + +# Github Actions + +## R2_ACCOUNT_ID + +Your Cloudflare account ID. + +## R2_ACCESS_KEY_ID + +Your Cloudflare R2 bucket access key ID. + +## R2_SECRET_ACCESS_KEY + +Your Cloudflare R2 bucket secret access key. + +# Build + +- Run command: + +```bash +./gradlew build +./gradlew packageDebugAndroidTest +mv app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/com.github.tikmatrix.apk +mv app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk app/build/outputs/apk/com.github.tikmatrix.test.apk +``` + +- Run the jsonrpc server on Android device + +```bash +./gradlew cC +adb forward tcp:9008 tcp:9008 # tcp forward +``` + +If debug apk already installed, There is no need to use gradle. + +simply run the following command + +``` +adb forward tcp:9008 tcp:9008 +adb shell am instrument -w -r -e debug false -e class com.github.tikmatrix.stub.Stub com.github.tikmatrix.test/androidx.test.runner.AndroidJUnitRunner +adb shell am startservice com.github.tikmatrix/.Service + +``` + +# Run + +```bash +$ curl -X POST -d '{"jsonrpc": "2.0", "id": "1f0f2655716023254ed2b57ba4198815", "method": "deviceInfo", "params": {}}' 'http://127.0.0.1:9008/jsonrpc/0' +{'currentPackageName': 'com.smartisanos.launcher', + 'displayHeight': 1920, + 'displayRotation': 0, + 'displaySizeDpX': 360, + 'displaySizeDpY': 640, + 'displayWidth': 1080, + 'productName': 'surabaya', + 'screenOn': True, + 'sdkInt': 23, + 'naturalOrientation': True} +``` + +# The buildin input method + +**Fast input method** + +Encode the text into UTF-8 and then Base64 + +For example: + + "Hello 你好" -> (UTF-8 && Base64) = SGVsbG8g5L2g5aW9 + +Send to FastInputIME with broadcast + +```bash +# Append text to input field +$ adb shell am broadcast -a ADB_INPUT_TEXT --es text SGVsbG8g5L2g5aW9 + +# Clear text +$ adb shell am broadcast -a ADB_CLEAR_TEXT + +# Clear text before append text +$ adb shell am broadcast -a ADB_SET_TEXT --es text SGVsbG8g5L2g5aW9 + +# Send keycode, eg: ENTER +$ adb shell am broadcast -a ADB_INPUT_KEYCODE --ei code 66 + +# Send Editor code +$ adb shell am broadcast -a ADB_EDITOR_CODE --ei code 2 # IME_ACTION_GO + +# Get clipboard (without data) +$ adb shell am broadcast -a ADB_GET_CLIPBOARD +Broadcasting: Intent { act=ADB_GET_CLIPBOARD flg=0x400000 } +Broadcast completed: result=0 + +# Get clipboard (with data, base64 encoded) +$ adb shell am broadcast -a ADB_GET_CLIPBOARD +Broadcasting: Intent { act=ADB_GET_CLIPBOARD flg=0x400000 } +Broadcast completed: result=-1, data="5LqG6Kej5Lyg57uf5paH5YyW" +``` + +- [Editor Code](https://developer.android.com/reference/android/view/inputmethod/EditorInfo) +- [Key Event](https://developer.android.com/reference/android/view/KeyEvent) + +# Change GPS mock location + +You can change mock location from terminal using adb in order to test GPS on real devices. + +``` +adb [-s ] shell am broadcast -a send.mock [-e lat ] [-e lon ] + [-e alt ] [-e accurate ] +``` + +For example: + +``` +adb shell am broadcast -a send.mock -e lat 15.3 -e lon 99 +``` + +## Show toast + +``` +adb shell am start -n com.github.tikmatrix/.ToastActivity -e message hello +``` + +## Float window + +``` +adb shell am start -n com.github.tikmatrix/.ToastActivity -e showFloatWindow true # show +adb shell am start -n com.github.tikmatrix/.ToastActivity -e showFloatWindow false # hide +``` + +## Change language and timezone + +``` +adb shell am start -n com.github.tikmatrix/.ToastActivity --es language en --es timezone Europe/London +``` + +# How to generate changelog + +[conventional-changelog](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-cli) + +```bash +npm install -g conventional-changelog-cli +conventional-changelog -p grunt -i CHANGELOG.md -s -r 0 +``` + +# Dependencies + +- [nanohttpd](https://github.com/NanoHttpd/nanohttpd) +- [jsonrpc4j](https://github.com/briandilley/jsonrpc4j) +- [jackson](https://github.com/FasterXML/jackson) +- [androidx.test.uiautomator](https://mvnrepository.com/artifact/androidx.test.uiautomator/uiautomator-v18) + +# Added features + +- [x] support unicode input + +# Resources + +- [Google UiAutomator Tutorial](https://developer.android.com/training/testing/ui-testing/uiautomator-testing?hl=zh-cn) +- [Google UiAutomator API](https://developer.android.com/reference/android/support/test/uiautomator/package-summary?hl=zh-cn) +- [Maven repository of uiautomator-v18](https://mvnrepository.com/artifact/androidx.test.uiautomator/uiautomator-v18) diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..b5f5f92 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,96 @@ + +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.8.0' // Ensure this is 3.0.0 or higher + } +} + +apply plugin: 'com.android.application' + +android { + compileSdk 34 + // version code history + // 1: original version + // 2: update all dependencies to latest + // 6: input method, battery,rotation monitor + namespace 'com.github.tikmatrix' + defaultConfig { + applicationId "com.github.tikmatrix" + minSdkVersion 21 + targetSdkVersion 34 + versionName "0.0.1" + versionCode 2025001 + } + + signingConfigs { + release { + storeFile file("../release.keystore") + storePassword "uiautomator-release-2015" + keyAlias "uiautomator" + keyPassword "uiautomator" + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + + android { + lintOptions { + abortOnError false + } + } + packagingOptions { + resources { + excludes += ['LICENSE.txt', 'META-INF/LICENSE', 'META-INF/NOTICE'] + } + } + + defaultConfig { + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + } + + + // fix try-with-resource warning + // ref: https://stackoverflow.com/questions/40408628/try-with-resources-requires-api-level-19-okhttp + compileOptions { + sourceCompatibility agp_version + targetCompatibility agp_version + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + // server + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'org.nanohttpd:nanohttpd:2.3.1' + implementation 'com.squareup.okhttp3:okhttp:3.11.0' + implementation 'commons-cli:commons-cli:1.3.1' + + // test + + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.3.0' + androidTestImplementation 'com.github.briandilley.jsonrpc4j:jsonrpc4j:1.5.0' + androidTestImplementation 'com.fasterxml.jackson.core:jackson-core:2.5.3' + androidTestImplementation 'com.fasterxml.jackson.core:jackson-annotations:2.5.3' + androidTestImplementation 'com.fasterxml.jackson.core:jackson-databind:2.5.3' + +} + + +repositories { + google() + mavenCentral() +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..4e1d64f --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/xiaocong/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/com/tikfarm/stub/AccessibilityEventListener.java b/app/src/androidTest/java/com/tikfarm/stub/AccessibilityEventListener.java new file mode 100644 index 0000000..c5c993a --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/AccessibilityEventListener.java @@ -0,0 +1,57 @@ +package com.github.tikmatrix.stub; + +import android.app.Notification; +import android.app.UiAutomation; +import android.os.Parcelable; +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.UiDevice; +import android.view.accessibility.AccessibilityEvent; + +import java.util.HashSet; + +/** + * Used to skip apk auto install && permission popups + * Called in method: setPermissionPatterns + *

+ * Created by hzsunshx on 2018/3/7. + */ + +public class AccessibilityEventListener implements UiAutomation.OnAccessibilityEventListener { + public String toastMessage; + public Boolean triggerWatchers = false; + public long toastTime; + + private HashSet watchers; + private static AccessibilityEventListener instance; + private UiDevice device; + + public AccessibilityEventListener(UiDevice device, HashSet watchers) { + this.device = device; + this.watchers = watchers; + AccessibilityEventListener.instance = this; + } + + public static AccessibilityEventListener getInstance() { + if (instance == null) { + throw new RuntimeException(); // Must be init first. + } + return instance; + } + + @Override + public void onAccessibilityEvent(final AccessibilityEvent event) { + if (event.getPackageName() == null) { + return; + } else if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { + Parcelable parcelable = event.getParcelableData(); + if (!(parcelable instanceof Notification)) { // without Notification is Toast + String packageName = event.getPackageName().toString(); + if (event.getText().size() > 0) { + this.toastTime = System.currentTimeMillis(); + this.toastMessage = "" + event.getText().get(0); + Log.d("Toast:" + toastMessage + " Pkg:" + packageName + " Time:" + toastTime); + } + } + } + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/AccessibilityNodeInfoDumper.java b/app/src/androidTest/java/com/tikfarm/stub/AccessibilityNodeInfoDumper.java new file mode 100644 index 0000000..2890ece --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/AccessibilityNodeInfoDumper.java @@ -0,0 +1,241 @@ +package com.github.tikmatrix.stub; + +import android.app.UiAutomation; +import android.graphics.Rect; +import android.os.Build; +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.UiDevice; +import android.util.Log; +import android.util.Xml; +import android.view.accessibility.AccessibilityNodeInfo; +import android.view.accessibility.AccessibilityWindowInfo; +import android.widget.GridLayout; +import android.widget.GridView; +import android.widget.ListView; +import android.widget.TableLayout; + +import org.xmlpull.v1.XmlSerializer; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +// Note: +// Here is a copy of androidx.test.uiautomator.AccessibilitiNodeInfoDumper source code +// in order to fix dump hierarchy error +// +// Sync to new code: https://android.googlesource.com/platform/frameworks/testing/+/master/uiautomator/library/core-src/com/android/uiautomator/core/AccessibilityNodeInfoDumper.java +class AccessibilityNodeInfoDumper { + private static final String LOGTAG = AccessibilityNodeInfoDumper.class.getSimpleName(); + private static final String[] NAF_EXCLUDED_CLASSES = new String[] { + GridView.class.getName(), GridLayout.class.getName(), + ListView.class.getName(), TableLayout.class.getName() + }; + + AccessibilityNodeInfoDumper() { + } + + public static void dumpWindowHierarchy(UiDevice device, OutputStream out) throws IOException { + Log.i("----------------", "dumpWindowHierarchy start"); + XmlSerializer serializer = Xml.newSerializer(); + serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); + serializer.setOutput(out, "UTF-8"); + serializer.startDocument("UTF-8", true); + serializer.startTag("", "hierarchy"); + serializer.attribute("", "rotation", Integer.toString(device.getDisplayRotation())); + AccessibilityNodeInfo[] arr$ = getWindowRoots(device); // device.getWindowRoots(); + int len$ = arr$.length; + + for (int i$ = 0; i$ < len$; ++i$) { + AccessibilityNodeInfo root = arr$[i$]; + dumpNodeRec(root, serializer, 0, device.getDisplayWidth(), device.getDisplayHeight()); + } + + serializer.endTag("", "hierarchy"); + serializer.endDocument(); + Log.i("----------------", "dumpWindowHierarchy end:"); + } + + private static AccessibilityNodeInfo[] getWindowRoots(UiDevice device) { + device.waitForIdle(); + Set roots = new HashSet(); + UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation(); + AccessibilityNodeInfo activeRoot = uiAutomation.getRootInActiveWindow(); + if (activeRoot != null) { + roots.add(activeRoot); + } + + if (Build.VERSION.SDK_INT >= 21) { + // if (API_LEVEL_ACTUAL >= 21) { + Iterator i$ = uiAutomation.getWindows().iterator(); + + while (i$.hasNext()) { + AccessibilityWindowInfo window = (AccessibilityWindowInfo) i$.next(); + AccessibilityNodeInfo root = window.getRoot(); + if (root == null) { + Log.w(LOGTAG, String.format("Skipping null root node for window: %s", window.toString())); + } else { + roots.add(root); + } + } + } + + return (AccessibilityNodeInfo[]) roots.toArray(new AccessibilityNodeInfo[roots.size()]); + } + + private static void dumpNodeRec(AccessibilityNodeInfo node, XmlSerializer serializer, int index, int width, + int height) throws IOException { + serializer.startTag("", "node"); + if (!nafExcludedClass(node) && !nafCheck(node)) { + serializer.attribute("", "NAF", Boolean.toString(true)); + } + + serializer.attribute("", "index", Integer.toString(index)); + serializer.attribute("", "text", safeCharSeqToString(node.getText())); + serializer.attribute("", "resource-id", safeCharSeqToString(node.getViewIdResourceName())); + serializer.attribute("", "class", safeCharSeqToString(node.getClassName())); + serializer.attribute("", "package", safeCharSeqToString(node.getPackageName())); + serializer.attribute("", "content-desc", safeCharSeqToString(node.getContentDescription())); + serializer.attribute("", "checkable", Boolean.toString(node.isCheckable())); + serializer.attribute("", "checked", Boolean.toString(node.isChecked())); + serializer.attribute("", "clickable", Boolean.toString(node.isClickable())); + serializer.attribute("", "enabled", Boolean.toString(node.isEnabled())); + serializer.attribute("", "focusable", Boolean.toString(node.isFocusable())); + serializer.attribute("", "focused", Boolean.toString(node.isFocused())); + serializer.attribute("", "scrollable", Boolean.toString(node.isScrollable())); + serializer.attribute("", "long-clickable", Boolean.toString(node.isLongClickable())); + serializer.attribute("", "password", Boolean.toString(node.isPassword())); + serializer.attribute("", "selected", Boolean.toString(node.isSelected())); + serializer.attribute("", "visible-to-user", Boolean.toString(node.isVisibleToUser())); + serializer.attribute("", "bounds", getVisibleBoundsInScreen(node, width, height).toShortString()); + int count = node.getChildCount(); + + for (int i = 0; i < count; ++i) { + AccessibilityNodeInfo child = node.getChild(i); + if (child != null) { + if (child.isVisibleToUser()) { + dumpNodeRec(child, serializer, i, width, height); + child.recycle(); + } else { + android.util.Log.i(LOGTAG, String.format("Skipping invisible child: %s", child.toString())); + } + } else { + Log.i(LOGTAG, String.format("Null child %d/%d, parent: %s", i, count, node.toString())); + } + } + + serializer.endTag("", "node"); + } + + /** + * The list of classes to exclude my not be complete. We're attempting to + * only reduce noise from standard layout classes that may be falsely + * configured to accept clicks and are also enabled. + * + * @param node + * @return true if node is excluded. + */ + private static boolean nafExcludedClass(AccessibilityNodeInfo node) { + String className = safeCharSeqToString(node.getClassName()); + for (String excludedClassName : NAF_EXCLUDED_CLASSES) { + if (className.endsWith(excludedClassName)) + return true; + } + return false; + } + + /** + * We're looking for UI controls that are enabled, clickable but have no + * text nor content-description. Such controls configuration indicate an + * interactive control is present in the UI and is most likely not + * accessibility friendly. We refer to such controls here as NAF controls + * (Not Accessibility Friendly) + * + * @param node + * @return false if a node fails the check, true if all is OK + */ + private static boolean nafCheck(AccessibilityNodeInfo node) { + boolean isNaf = node.isClickable() && node.isEnabled() + && safeCharSeqToString(node.getContentDescription()).isEmpty() + && safeCharSeqToString(node.getText()).isEmpty(); + if (!isNaf) + return true; + // check children since sometimes the containing element is clickable + // and NAF but a child's text or description is available. Will assume + // such layout as fine. + return childNafCheck(node); + } + + /** + * This should be used when it's already determined that the node is NAF and + * a further check of its children is in order. A node maybe a container + * such as LinerLayout and may be set to be clickable but have no text or + * content description but it is counting on one of its children to fulfill + * the requirement for being accessibility friendly by having one or more of + * its children fill the text or content-description. Such a combination is + * considered by this dumper as acceptable for accessibility. + * + * @param node + * @return false if node fails the check. + */ + private static boolean childNafCheck(AccessibilityNodeInfo node) { + int childCount = node.getChildCount(); + for (int x = 0; x < childCount; x++) { + AccessibilityNodeInfo childNode = node.getChild(x); + if (childNode == null) { + Log.i(LOGTAG, String.format("Null child %d/%d, parent: %s", + x, childCount, node.toString())); + continue; + } + if (!safeCharSeqToString(childNode.getContentDescription()).isEmpty() + || !safeCharSeqToString(childNode.getText()).isEmpty()) + return true; + if (childNafCheck(childNode)) + return true; + } + return false; + } + + private static String safeCharSeqToString(CharSequence cs) { + return cs == null ? "" : stripInvalidXMLChars(cs); + } + + private static String stripInvalidXMLChars(CharSequence cs) { + // ref: + // https://stackoverflow.com/questions/4237625/removing-invalid-xml-characters-from-a-string-in-java + String xml10pattern = "[^" + + "\u0009\r\n" + + "\u0020-\uD7FF" + + "\uE000-\uFFFD" + + "\ud800\udc00-\udbff\udfff" + + "]"; + + return cs.toString().replaceAll(xml10pattern, "?"); + } + + static android.graphics.Rect getVisibleBoundsInScreen(AccessibilityNodeInfo node, int width, int height) { + if (node == null) { + return null; + } else { + android.graphics.Rect nodeRect = new android.graphics.Rect(); + node.getBoundsInScreen(nodeRect); + android.graphics.Rect displayRect = new android.graphics.Rect(); + displayRect.top = 0; + displayRect.left = 0; + displayRect.right = width; + displayRect.bottom = height; + nodeRect.intersect(displayRect); + if (Build.VERSION.SDK_INT >= 21) { // UiDevice.API_LEVEL_ACTUAL + android.graphics.Rect window = new Rect(); + if (node.getWindow() != null) { + node.getWindow().getBoundsInScreen(window); + nodeRect.intersect(window); + } + } + + return nodeRect; + } + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/AutomatorHttpServer.java b/app/src/androidTest/java/com/tikfarm/stub/AutomatorHttpServer.java new file mode 100644 index 0000000..269b8dc --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/AutomatorHttpServer.java @@ -0,0 +1,140 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.UiDevice; + +import com.googlecode.jsonrpc4j.JsonRpcServer; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import fi.iki.elonen.NanoHTTPD; + +public class AutomatorHttpServer extends NanoHTTPD { + + private AutomatorService automatorService; + + public AutomatorHttpServer(int port) { + super(port); + } + + private Map router = new HashMap(); + + public void route(String uri, JsonRpcServer rpc) { + router.put(uri, rpc); + } + + @Override + public Response serve(String uri, Method method, + Map headers, Map params, + Map files) { + Log.d(String.format("URI: %s, Method: %s, params, %s, files: %s", uri, method, params, files)); + + if ("/stop".equals(uri)) { + stop(); + return newFixedLengthResponse("Server stopped!!!"); + } else if ("/ping".equals(uri)) { + return newFixedLengthResponse("pong"); + } else if ("/hierarchy".equals(uri)) { + if (automatorService != null) { + String xml = automatorService.dumpWindowHierarchy(false); + Response response = newFixedLengthResponse(xml); + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS"); + response.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization"); + response.addHeader("Access-Control-Allow-Credentials", "true"); + return response; + } + return newFixedLengthResponse("automatorService stopped!!!"); + } else if ("/screenshot/0".equals(uri)) { + float scale = 1.0f; + if (params.containsKey("scale")) { + try { + scale = Float.parseFloat(params.get("scale")); + } catch (NumberFormatException e) { + } + } + int quality = 100; + if (params.containsKey("quality")) { + try { + quality = Integer.parseInt(params.get("quality")); + } catch (NumberFormatException e) { + } + } + File f = new File(InstrumentationRegistry.getTargetContext().getFilesDir(), "screenshot.png"); + UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).takeScreenshot(f, scale, quality); + + try { + Response response = newChunkedResponse(Response.Status.OK, "image/png", new FileInputStream(f)); + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS"); + response.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization"); + response.addHeader("Access-Control-Allow-Credentials", "true"); + return response; + } catch (FileNotFoundException e) { + Log.e(e.getMessage()); + Response response = newFixedLengthResponse(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, + "Internal Server Error!!!"); + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS"); + response.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization"); + response.addHeader("Access-Control-Allow-Credentials", "true"); + return response; + } + } else if (router.containsKey(uri)) { + JsonRpcServer jsonRpcServer = router.get(uri); + ByteArrayInputStream is = null; + if (params.get("NanoHttpd.QUERY_STRING") != null) + is = new ByteArrayInputStream(params.get("NanoHttpd.QUERY_STRING").getBytes()); + else if (files.get("postData") != null) + is = new ByteArrayInputStream(files.get("postData").getBytes()); + else + return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, + "Invalid http post data!"); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + try { + jsonRpcServer.handleRequest(is, os); + return newFixedLengthResponse(Response.Status.OK, "application/json", + new ByteArrayInputStream(os.toByteArray()), os.size()); + } catch (IOException e) { + return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, + "Internal Server Error!!!"); + } + } else + return newFixedLengthResponse(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "Not Found!!!"); + } + + public void setAutomatorService(AutomatorService automatorService) { + this.automatorService = automatorService; + + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/AutomatorService.java b/app/src/androidTest/java/com/tikfarm/stub/AutomatorService.java new file mode 100644 index 0000000..edf0c32 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/AutomatorService.java @@ -0,0 +1,1276 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import android.os.RemoteException; +import androidx.test.uiautomator.UiObjectNotFoundException; + +import com.googlecode.jsonrpc4j.JsonRpcError; +import com.googlecode.jsonrpc4j.JsonRpcErrors; + +public interface AutomatorService { + final static int ERROR_CODE_BASE = -32000; + + /** + * Deprecated APIs + * boolean hasWatchedOnWindowsChange(); + * void runWatchersOnWindowsChange(boolean enabled); # Auto click permission + * popups, This will slow uiautomator speed + */ + + /** + * It's to play a section music to test + * + * @return + */ + boolean playSound(String path); + + /** + * Capture toast or not + * + * @param enabled enable it of disable it + */ + void setToastListener(boolean enabled); + + /** + * It's to test if the service is alive. + * + * @return 'pong' + */ + String ping(); + + /** + * show toast text in seconds + * + * @param text the text to show + * @param duration text duration + * @return true if text is shown, false otherwise + */ + boolean makeToast(String text, int duration); + + /** + * get last toast text + * + * @param cacheDuration milliseconds + * @return the latest toast text or empty String + */ + String getLastToast(long cacheDuration); + + /** + * clear the last toast text and set + * + * @return true if we clear the last toast text, false otherwise + */ + boolean clearLastToast(); + + /*************************************************************************** + * Below section contains all methods from UiDevice. + ***************************************************************************/ + + /** + * Get the device info. + * + * @return device info. + */ + DeviceInfo deviceInfo(); + + /** + * Perform a click at arbitrary coordinates specified by the user. + * + * @param x coordinate + * @param y coordinate + * @return true if the click succeeded else false + */ + boolean click(int x, int y); + + /** + * Perform a click at arbitrary coordinates specified by the user + * + * @param x + * @param y + * @param milliseconds + * @return + */ + public boolean click(int x, int y, long milliseconds); + + /** + * Performs a swipe from one coordinate to another coordinate. You can control + * the smoothness and speed of the swipe by specifying the number of steps. Each + * step execution is throttled to 5 milliseconds per step, so for a 100 steps, + * the swipe will take around 0.5 seconds to complete. + * + * @param startX X-axis value for the starting coordinate + * @param startY Y-axis value for the starting coordinate + * @param endX X-axis value for the ending coordinate + * @param endY Y-axis value for the ending coordinate + * @param steps is the number of steps for the swipe action + * @return true if swipe is performed, false if the operation fails or the + * coordinates are invalid + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean drag(int startX, int startY, int endX, int endY, int steps) throws NotImplementedException; + + /** + * Performs a swipe from one coordinate to another using the number of steps to + * determine smoothness and speed. Each step execution is throttled to 5ms per + * step. So for a 100 steps, the swipe will take about 1/2 second to complete. + * + * @param startX X-axis value for the starting coordinate + * @param startY Y-axis value for the starting coordinate + * @param endX X-axis value for the ending coordinate + * @param endY Y-axis value for the ending coordinate + * @param steps is the number of move steps sent to the system + * @return false if the operation fails or the coordinates are invalid + */ + boolean swipe(int startX, int startY, int endX, int endY, int steps); + + /** + * Performs a swipe between points in the point array + * + * @param segments the point array + * @param segmentSteps steps to inject between two points, each step lasting 5ms + */ + boolean swipePoints(int[] segments, int segmentSteps); + + /** + * Inject a low-level InputEvent (MotionEvent) to the input stream + * + * @param action MotionEvent.ACTION_* + * @param x x coordinate + * @param y y coordinate + * @param metaState any meta info + */ + boolean injectInputEvent(int action, float x, float y, int metaState); + + /** + * Helper method used for debugging to dump the current window's layout + * hierarchy. The file root location is /data/local/tmp + * + * @param compressed use compressed layout hierarchy or not using + * setCompressedLayoutHeirarchy method. Ignore the parameter + * in case the API level lt 18. + * @param filename the filename to be stored. + * @return the absolute path name of dumped file. + */ + @Deprecated + String dumpWindowHierarchy(boolean compressed, String filename); + + /** + * Helper method used for debugging to dump the current window's layout + * hierarchy. + * + * @param compressed use compressed layout hierarchy or not using + * setCompressedLayoutHeirarchy method. Ignore the parameter + * in case the API level lt 18. + * @return the absolute path name of dumped file. + */ + String dumpWindowHierarchy(boolean compressed); + + /** + * Take a screenshot of current window and store it as PNG The screenshot is + * adjusted per screen rotation + * + * @param filename where the PNG should be written to + * @param scale scale the screenshot down if needed; 1.0f for original size + * @param quality quality of the PNG compression; range: 0-100 + * @return the file name of the screenshot. null if failed. + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + String takeScreenshot(String filename, float scale, int quality) throws NotImplementedException; + + /** + * Take a screenshot of current window and store it as JPEG The screenshot is + * adjusted per screen rotation + * + * @param scale + * @param quality + * @return base64 encoded image data + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + public String takeScreenshot(float scale, int quality) throws NotImplementedException; + + /** + * Disables the sensors and freezes the device rotation at its current rotation + * state, or enable it. + * + * @param freeze true to freeze the rotation, false to unfreeze the rotation. + * @throws RemoteException + */ + @JsonRpcErrors({ @JsonRpcError(exception = RemoteException.class, code = ERROR_CODE_BASE - 1) }) + void freezeRotation(boolean freeze) throws RemoteException; // freeze or unfreeze rotation, see also + // unfreezeRotation() + + /** + * Simulates orienting the device to the left/right/natural and also freezes + * rotation by disabling the sensors. + * + * @param dir Left or l, Right or r, Natural or n, case insensitive + * @throws RemoteException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = RemoteException.class, code = ERROR_CODE_BASE - 1), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + void setOrientation(String dir) throws RemoteException, NotImplementedException; + + /** + * Retrieves the text from the last UI traversal event received. + * + * @return the text from the last UI traversal event received. + */ + String getLastTraversedText(); + + /** + * Clears the text from the last UI traversal event. + */ + void clearLastTraversedText(); + + /** + * Opens the notification shade. + * + * @return true if successful, else return false + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean openNotification() throws NotImplementedException; + + /** + * Opens the Quick Settings shade. + * + * @return true if successful, else return false + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean openQuickSettings() throws NotImplementedException; + + /** + * Checks if a specific registered UiWatcher has triggered. See + * registerWatcher(String, UiWatcher). If a UiWatcher runs and its + * checkForCondition() call returned true, then the UiWatcher is considered + * triggered. This is helpful if a watcher is detecting errors from ANR or crash + * dialogs and the test needs to know if a UiWatcher has been triggered. + * + * @param watcherName the name of registered watcher. + * @return true if triggered else false + */ + boolean hasWatcherTriggered(String watcherName); // We should implement some watchers to treat some blocking issues, + // e.g. force close dialog + + /** + * Checks if any registered UiWatcher have triggered. + * + * @return true if any UiWatcher have triggered else false. + */ + boolean hasAnyWatcherTriggered(); + + /** + * Register a ClickUiObjectWatcher + * + * @param name Watcher name + * @param conditions If all UiObject in the conditions match, the watcher should + * be triggered. + * @param target The target UiObject should be clicked if all conditions + * match. + */ + void registerClickUiObjectWatcher(String name, Selector[] conditions, Selector target); + + /** + * Register a PressKeysWatcher + * + * @param name Watcher name + * @param conditions If all UiObject in the conditions match, the watcher should + * be triggered. + * @param keys All keys will be pressed in sequence. + */ + void registerPressKeyskWatcher(String name, Selector[] conditions, String[] keys); + + /** + * Removes a previously registered UiWatcher. + * + * @param name Watcher name + */ + void removeWatcher(String name); + + /** + * Resets a UiWatcher that has been triggered. If a UiWatcher runs and its + * checkForCondition() call returned true, then the UiWatcher is considered + * triggered. + */ + void resetWatcherTriggers(); + + /** + * Force to run all watchers. + */ + void runWatchers(); + + /** + * Get all registered UiWatchers + * + * @return UiWatcher names + */ + String[] getWatchers(); + + /** + * Simulates a short press using key name. + * + * @param key possible key name is home, back, left, right, up, down, center, + * menu, search, enter, delete(or del), recent(recent apps), + * volume_up, volume_down, volume_mute, camera, power + * @return true if successful, else return false + * @throws RemoteException + */ + @JsonRpcErrors({ @JsonRpcError(exception = RemoteException.class, code = ERROR_CODE_BASE - 1) }) + boolean pressKey(String key) throws RemoteException; + + /** + * Simulates a short press using a key code. See KeyEvent. + * + * @param keyCode the key code of the event. + * @return true if successful, else return false + */ + boolean pressKeyCode(int keyCode); + + /** + * Simulates a short press using a key code. See KeyEvent. + * + * @param keyCode the key code of the event. + * @param metaState an integer in which each bit set to 1 represents a pressed + * meta key + * @return true if successful, else return false + */ + boolean pressKeyCode(int keyCode, int metaState); + + /** + * This method simulates pressing the power button if the screen is OFF else it + * does nothing if the screen is already ON. If the screen was OFF and it just + * got turned ON, this method will insert a 500ms delay to allow the device time + * to wake up and accept input. + * + * @throws RemoteException + */ + @JsonRpcErrors({ @JsonRpcError(exception = RemoteException.class, code = ERROR_CODE_BASE - 1) }) + void wakeUp() throws RemoteException; + + /** + * This method simply presses the power button if the screen is ON else it does + * nothing if the screen is already OFF. + * + * @throws RemoteException + */ + @JsonRpcErrors({ @JsonRpcError(exception = RemoteException.class, code = ERROR_CODE_BASE - 1) }) + void sleep() throws RemoteException; + + /** + * Checks the power manager if the screen is ON. + * + * @return true if the screen is ON else false + * @throws RemoteException + */ + @JsonRpcErrors({ @JsonRpcError(exception = RemoteException.class, code = ERROR_CODE_BASE - 1) }) + boolean isScreenOn() throws RemoteException; + + /** + * Waits for the current application to idle. + * + * @param timeout in milliseconds + */ + void waitForIdle(long timeout); + + /** + * Waits for a window content update event to occur. If a package name for the + * window is specified, but the current window does not have the same package + * name, the function returns immediately. + * + * @param packageName the specified window package name (can be null). If null, + * a window update from any front-end window will end the + * wait. + * @param timeout the timeout for the wait + * @return true if a window update occurred, false if timeout has elapsed or if + * the current window does not have the specified package name + */ + boolean waitForWindowUpdate(String packageName, long timeout); + + /*************************************************************************** + * Below section contains all methods from UiObject. + ***************************************************************************/ + + /** + * Clears the existing text contents in an editable field. The UiSelector of + * this object must reference a UI element that is editable. When you call this + * method, the method first sets focus at the start edge of the field. The + * method then simulates a long-press to select the existing text, and deletes + * the selected text. If a "Select-All" option is displayed, the method will + * automatically attempt to use it to ensure full text selection. Note that it + * is possible that not all the text in the field is selected; for example, if + * the text contains separators such as spaces, slashes, at symbol etc. Also, + * not all editable fields support the long-press functionality. + * + * @param obj the selector of the UiObject. + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + void clearTextField(Selector obj) throws UiObjectNotFoundException; + + /** + * Reads the text property of the UI element + * + * @param obj the selector of the UiObject. + * @return text value of the current node represented by this UiObject + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String getText(Selector obj) throws UiObjectNotFoundException; + + /** + * Sets the text in an editable field, after clearing the field's content. The + * UiSelector selector of this object must reference a UI element that is + * editable. When you call this method, the method first simulates a click() on + * editable field to set focus. The method then clears the field's contents and + * injects your specified text into the field. If you want to capture the + * original contents of the field, call getText() first. You can then modify the + * text and use this method to update the field. + * + * @param obj the selector of the UiObject. + * @param text string to set + * @return true if operation is successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean setText(Selector obj, String text) throws UiObjectNotFoundException; + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject. + * + * @param obj the target ui object. + * @return true id successful else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean click(Selector obj) throws UiObjectNotFoundException; + + /** + * Clicks the bottom and right corner or top and left corner of the UI element + * + * @param obj the target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true on success + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean click(Selector obj, String corner) throws UiObjectNotFoundException; + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject and waits for window transitions. This method + * differ from click() only in that this method waits for a a new window + * transition as a result of the click. Some examples of a window transition: + * - launching a new activity + * - bringing up a pop-up menu + * - bringing up a dialog + * + * @param obj the target ui object. + * @param timeout timeout before giving up on waiting for a new window + * @return true if the event was triggered, else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean clickAndWaitForNewWindow(Selector obj, long timeout) throws UiObjectNotFoundException; + + /** + * Long clicks the center of the visible bounds of the UI element + * + * @param obj the target ui object. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean longClick(Selector obj) throws UiObjectNotFoundException; + + /** + * Long clicks bottom and right corner of the UI element + * + * @param obj the target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean longClick(Selector obj, String corner) throws UiObjectNotFoundException; + + /** + * Drags this object to a destination UiObject. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the ui object to be dragged. + * @param destObj the ui object to be dragged to. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean dragTo(Selector obj, Selector destObj, int steps) throws UiObjectNotFoundException, NotImplementedException; + + /** + * Drags this object to arbitrary coordinates. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the ui object to be dragged. + * @param destX the X-axis coordinate of destination. + * @param destY the Y-axis coordinate of destination. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean dragTo(Selector obj, int destX, int destY, int steps) + throws UiObjectNotFoundException, NotImplementedException; + + /** + * Check if view exists. This methods performs a waitForExists(long) with zero + * timeout. This basically returns immediately whether the view represented by + * this UiObject exists or not. + * + * @param obj the ui object. + * @return true if the view represented by this UiObject does exist + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean exist(Selector obj); + + /** + * Get the object info. + * + * @param obj the target ui object. + * @return object info. + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + ObjInfo objInfo(Selector obj) throws UiObjectNotFoundException; + + /** + * Get the count of the UiObject instances by the selector + * + * @param obj the selector of the ui object + * @return the count of instances. + */ + int count(Selector obj); + + /** + * Get the info of all instance by the selector. + * + * @param obj the selector of ui object. + * @return array of object info. + */ + ObjInfo[] objInfoOfAllInstances(Selector obj); + + /** + * Generates a two-pointer gesture with arbitrary starting and ending points. + * + * @param obj the target ui object. ?? + * @param startPoint1 start point of pointer 1 + * @param startPoint2 start point of pointer 2 + * @param endPoint1 end point of pointer 1 + * @param endPoint2 end point of pointer 2 + * @param steps the number of steps for the gesture. Steps are injected + * about 5 milliseconds apart, so 100 steps may take around + * 0.5 seconds to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean gesture(Selector obj, Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, int steps) + throws UiObjectNotFoundException, NotImplementedException; + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally toward + * the other, from the edges to the center of this UiObject . + * + * @param obj the target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean pinchIn(Selector obj, int percent, int steps) throws UiObjectNotFoundException, NotImplementedException; + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally opposite + * across the other, from the center out towards the edges of the this UiObject. + * + * @param obj the target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean pinchOut(Selector obj, int percent, int steps) throws UiObjectNotFoundException, NotImplementedException; + + /** + * Performs the swipe up/down/left/right action on the UiObject + * + * @param obj the target ui object. + * @param dir "u"/"up", "d"/"down", "l"/"left", "r"/"right" + * @param steps indicates the number of injected move steps into the system. + * Steps are injected about 5ms apart. So a 100 steps may take + * about 1/2 second to complete. + * @return true of successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean swipe(Selector obj, String dir, int steps) throws UiObjectNotFoundException; + + /** + * Performs the swipe up/down/left/right action on the UiObject + * + * @param obj the target ui object. + * @param dir "u"/"up", "d"/"down", "l"/"left", "r"/"right" + * @param percent expect value: percent >= 0.0F && percent <= 1.0F,The length of + * the swipe as a percentage of this object's size. + * @param steps indicates the number of injected move steps into the system. + * Steps are injected about 5ms apart. So a 100 steps may take + * about 1/2 second to complete. + * @return true of successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean swipe(Selector obj, String dir, float percent, int steps) throws UiObjectNotFoundException; + + /** + * Waits a specified length of time for a view to become visible. This method + * waits until the view becomes visible on the display, or until the timeout has + * elapsed. You can use this method in situations where the content that you + * want to select is not immediately displayed. + * + * @param obj the target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the view is displayed, else false if timeout elapsed while + * waiting + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean waitForExists(Selector obj, long timeout); + + /** + * Waits a specified length of time for a view to become undetectable. This + * method waits until a view is no longer matchable, or until the timeout has + * elapsed. A view becomes undetectable when the UiSelector of the object is + * unable to find a match because the element has either changed its state or is + * no longer displayed. You can use this method when attempting to wait for some + * long operation to compete, such as downloading a large file or connecting to + * a remote server. + * + * @param obj the target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the element is gone before timeout elapsed, else false if + * timeout elapsed but a matching element is still found. + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean waitUntilGone(Selector obj, long timeout); + + /*************************************************************************** + * Below section contains all methods from UiScrollable. + ***************************************************************************/ + + /** + * Performs a backwards fling action with the default number of fling steps (5). + * If the swipe direction is set to vertical, then the swipe will be performed + * from top to bottom. If the swipe direction is set to horizontal, then the + * swipes will be performed from left to right. Make sure to take into account + * devices configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @return true if scrolled, and false if can't scroll anymore + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean flingBackward(Selector obj, boolean isVertical) throws UiObjectNotFoundException; + + /** + * Performs a forward fling with the default number of fling steps (5). If the + * swipe direction is set to vertical, then the swipes will be performed from + * bottom to top. If the swipe direction is set to horizontal, then the swipes + * will be performed from right to left. Make sure to take into account devices + * configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @return true if scrolled, and false if can't scroll anymore + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean flingForward(Selector obj, boolean isVertical) throws UiObjectNotFoundException; + + /** + * Performs a fling gesture to reach the beginning of a scrollable layout + * element. The beginning can be at the top-most edge in the case of vertical + * controls, or the left-most edge for horizontal controls. Make sure to take + * into account devices configured with right-to-left languages like Arabic and + * Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to achieve beginning. + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean flingToBeginning(Selector obj, boolean isVertical, int maxSwipes) throws UiObjectNotFoundException; + + /** + * Performs a fling gesture to reach the end of a scrollable layout element. The + * end can be at the bottom-most edge in the case of vertical controls, or the + * right-most edge for horizontal controls. Make sure to take into account + * devices configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to achieve end. + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean flingToEnd(Selector obj, boolean isVertical, int maxSwipes) throws UiObjectNotFoundException; + + /** + * Performs a backward scroll. If the swipe direction is set to vertical, then + * the swipes will be performed from top to bottom. If the swipe direction is + * set to horizontal, then the swipes will be performed from left to right. Make + * sure to take into account devices configured with right-to-left languages + * like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param steps number of steps. Use this to control the speed of the + * scroll action. + * @return true if scrolled, false if can't scroll anymore + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean scrollBackward(Selector obj, boolean isVertical, int steps) throws UiObjectNotFoundException; + + /** + * Performs a forward scroll with the default number of scroll steps (55). If + * the swipe direction is set to vertical, then the swipes will be performed + * from bottom to top. If the swipe direction is set to horizontal, then the + * swipes will be performed from right to left. Make sure to take into account + * devices configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param steps number of steps. Use this to control the speed of the + * scroll action. + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean scrollForward(Selector obj, boolean isVertical, int steps) throws UiObjectNotFoundException; + + /** + * Scrolls to the beginning of a scrollable layout element. The beginning can be + * at the top-most edge in the case of vertical controls, or the left-most edge + * for horizontal controls. Make sure to take into account devices configured + * with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to be performed. + * @param steps use steps to control the speed, so that it may be a scroll, + * or fling + * @return true on scrolled else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean scrollToBeginning(Selector obj, boolean isVertical, int maxSwipes, int steps) + throws UiObjectNotFoundException; + + /** + * Scrolls to the end of a scrollable layout element. The end can be at the + * bottom-most edge in the case of vertical controls, or the right-most edge for + * horizontal controls. Make sure to take into account devices configured with + * right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to be performed. + * @param steps use steps to control the speed, so that it may be a scroll, + * or fling + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean scrollToEnd(Selector obj, boolean isVertical, int maxSwipes, int steps) throws UiObjectNotFoundException; + + /** + * Perform a scroll forward action to move through the scrollable layout element + * until a visible item that matches the selector is found. + * + * @param obj the selector of the scrollable object + * @param targetObj the item matches the selector to be found. + * @param isVertical vertical or horizontal + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean scrollTo(Selector obj, Selector targetObj, boolean isVertical) throws UiObjectNotFoundException; + + /*************************************************************************** + * Some time we have to use chained selection, e.g. + * new UiCollection(...).getChildByText(...).getChild().... + * So we should have a mechanism to save the previous UiObject. + ***************************************************************************/ + + /** + * Searches for child UI element within the constraints of this UiSelector + * selector. It looks for any child matching the childPattern argument that has + * a child UI element anywhere within its sub hierarchy that has a text + * attribute equal to text. The returned UiObject will point at the childPattern + * instance that matched the search and not at the identifying child element + * that matched the text attribute. + * + * @param collection Selector of UiCollection or UiScrollable. + * @param text String of the identifying child contents of of the + * childPattern + * @param child UiSelector selector of the child pattern to match and + * return + * @return A string ID represent the returned UiObject. + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String childByText(Selector collection, Selector child, String text) throws UiObjectNotFoundException; + + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String childByText(Selector collection, Selector child, String text, boolean allowScrollSearch) + throws UiObjectNotFoundException; + + /** + * Searches for child UI element within the constraints of this UiSelector + * selector. It looks for any child matching the childPattern argument that has + * a child UI element anywhere within its sub hierarchy that has + * content-description text. The returned UiObject will point at the + * childPattern instance that matched the search and not at the identifying + * child element that matched the content description. + * + * @param collection Selector of UiCollection or UiScrollable + * @param child UiSelector selector of the child pattern to match and + * return + * @param text String of the identifying child contents of of the + * childPattern + * @return A string ID represent the returned UiObject. + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String childByDescription(Selector collection, Selector child, String text) throws UiObjectNotFoundException; + + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String childByDescription(Selector collection, Selector child, String text, boolean allowScrollSearch) + throws UiObjectNotFoundException; + + /** + * Searches for child UI element within the constraints of this UiSelector. It + * looks for any child matching the childPattern argument that has a child UI + * element anywhere within its sub hierarchy that is at the instance specified. + * The operation is performed only on the visible items and no scrolling is + * performed in this case. + * + * @param collection Selector of UiCollection or UiScrollable + * @param child UiSelector selector of the child pattern to match and + * return + * @param instance int the desired matched instance of this childPattern + * @return A string ID represent the returned UiObject. + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String childByInstance(Selector collection, Selector child, int instance) throws UiObjectNotFoundException; + + /** + * Creates a new UiObject for a child view that is under the present UiObject. + * + * @param obj The ID string represent the parent UiObject. + * @param selector UiSelector selector of the child pattern to match and return + * @return A string ID represent the returned UiObject. + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String getChild(String obj, Selector selector) throws UiObjectNotFoundException; + + /** + * Creates a new UiObject for a sibling view or a child of the sibling view, + * relative to the present UiObject. + * + * @param obj The ID string represent the source UiObject. + * @param selector for a sibling view or children of the sibling view + * @return A string ID represent the returned UiObject. + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String getFromParent(String obj, Selector selector) throws UiObjectNotFoundException; + + /** + * Get a new UiObject from the selector. + * + * @param selector Selector of the UiObject + * @return A string ID represent the returned UiObject. + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String getUiObject(Selector selector) throws UiObjectNotFoundException; + + /** + * Remove the UiObject from memory. + */ + void removeUiObject(String obj); + + /** + * Get all named UiObjects. + * + * @return all names + */ + String[] getUiObjects(); + + /** + * Clears the existing text contents in an editable field. The UiSelector of + * this object must reference a UI element that is editable. When you call this + * method, the method first sets focus at the start edge of the field. The + * method then simulates a long-press to select the existing text, and deletes + * the selected text. If a "Select-All" option is displayed, the method will + * automatically attempt to use it to ensure full text selection. Note that it + * is possible that not all the text in the field is selected; for example, if + * the text contains separators such as spaces, slashes, at symbol etc. Also, + * not all editable fields support the long-press functionality. + * + * @param obj the id of the UiObject. + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + void clearTextField(String obj) throws UiObjectNotFoundException; + + /** + * Reads the text property of the UI element + * + * @param obj the id of the UiObject. + * @return text value of the current node represented by this UiObject + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + String getText(String obj) throws UiObjectNotFoundException; + + /** + * Sets the text in an editable field, after clearing the field's content. The + * UiSelector selector of this object must reference a UI element that is + * editable. When you call this method, the method first simulates a click() on + * editable field to set focus. The method then clears the field's contents and + * injects your specified text into the field. If you want to capture the + * original contents of the field, call getText() first. You can then modify the + * text and use this method to update the field. + * + * @param obj the id of the UiObject. + * @param text string to set + * @return true if operation is successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean setText(String obj, String text) throws UiObjectNotFoundException; + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject. + * + * @param obj the id of target ui object. + * @return true id successful else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean click(String obj) throws UiObjectNotFoundException; + + /** + * Clicks the bottom and right corner or top and left corner of the UI element + * + * @param obj the id of target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true on success + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean click(String obj, String corner) throws UiObjectNotFoundException; + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject and waits for window transitions. This method + * differ from click() only in that this method waits for a a new window + * transition as a result of the click. Some examples of a window transition: + * - launching a new activity + * - bringing up a pop-up menu + * - bringing up a dialog + * + * @param obj the id of target ui object. + * @param timeout timeout before giving up on waiting for a new window + * @return true if the event was triggered, else false + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean clickAndWaitForNewWindow(String obj, long timeout) throws UiObjectNotFoundException; + + /** + * Long clicks the center of the visible bounds of the UI element + * + * @param obj the id of target ui object. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean longClick(String obj) throws UiObjectNotFoundException; + + /** + * Long clicks bottom and right corner of the UI element + * + * @param obj the id of target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean longClick(String obj, String corner) throws UiObjectNotFoundException; + + /** + * Drags this object to a destination UiObject. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the id of ui object to be dragged. + * @param destObj the ui object to be dragged to. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean dragTo(String obj, Selector destObj, int steps) throws UiObjectNotFoundException, NotImplementedException; + + /** + * Drags this object to arbitrary coordinates. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the id of ui object to be dragged. + * @param destX the X-axis coordinate of destination. + * @param destY the Y-axis coordinate of destination. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean dragTo(String obj, int destX, int destY, int steps) + throws UiObjectNotFoundException, NotImplementedException; + + /** + * Check if view exists. This methods performs a waitForExists(long) with zero + * timeout. This basically returns immediately whether the view represented by + * this UiObject exists or not. + * + * @param obj the id of ui object. + * @return true if the view represented by this UiObject does exist + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean exist(String obj); + + /** + * Get the object info. + * + * @param obj the id of target ui object. + * @return object info. + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + ObjInfo objInfo(String obj) throws UiObjectNotFoundException; + + /** + * Generates a two-pointer gesture with arbitrary starting and ending points. + * + * @param obj the id of target ui object. ?? + * @param startPoint1 start point of pointer 1 + * @param startPoint2 start point of pointer 2 + * @param endPoint1 end point of pointer 1 + * @param endPoint2 end point of pointer 2 + * @param steps the number of steps for the gesture. Steps are injected + * about 5 milliseconds apart, so 100 steps may take around + * 0.5 seconds to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean gesture(String obj, Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, int steps) + throws UiObjectNotFoundException, NotImplementedException; + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally toward + * the other, from the edges to the center of this UiObject . + * + * @param obj the id of target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean pinchIn(String obj, int percent, int steps) throws UiObjectNotFoundException, NotImplementedException; + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally opposite + * across the other, from the center out towards the edges of the this UiObject. + * + * @param obj the id of target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2), + @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + boolean pinchOut(String obj, int percent, int steps) throws UiObjectNotFoundException, NotImplementedException; + + /** + * Performs the swipe up/down/left/right action on the UiObject + * + * @param obj the id of target ui object. + * @param dir "u"/"up", "d"/"down", "l"/"left", "r"/"right" + * @param steps indicates the number of injected move steps into the system. + * Steps are injected about 5ms apart. So a 100 steps may take + * about 1/2 second to complete. + * @return true of successful + * @throws UiObjectNotFoundException + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean swipe(String obj, String dir, int steps) throws UiObjectNotFoundException; + + /** + * Waits a specified length of time for a view to become visible. This method + * waits until the view becomes visible on the display, or until the timeout has + * elapsed. You can use this method in situations where the content that you + * want to select is not immediately displayed. + * + * @param obj the id of target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the view is displayed, else false if timeout elapsed while + * waiting + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean waitForExists(String obj, long timeout) throws UiObjectNotFoundException; + + /** + * Waits a specified length of time for a view to become undetectable. This + * method waits until a view is no longer matchable, or until the timeout has + * elapsed. A view becomes undetectable when the UiSelector of the object is + * unable to find a match because the element has either changed its state or is + * no longer displayed. You can use this method when attempting to wait for some + * long operation to compete, such as downloading a large file or connecting to + * a remote server. + * + * @param obj the id of target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the element is gone before timeout elapsed, else false if + * timeout elapsed but a matching element is still found. + */ + @JsonRpcErrors({ @JsonRpcError(exception = UiObjectNotFoundException.class, code = ERROR_CODE_BASE - 2) }) + boolean waitUntilGone(String obj, long timeout) throws UiObjectNotFoundException; + + /** + * Get Configurator + * + * @return Configurator information. + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + ConfiguratorInfo getConfigurator() throws NotImplementedException; + + /** + * Set Configurator. + * + * @param info the configurator information to be set. + * @throws NotImplementedException + */ + @JsonRpcErrors({ @JsonRpcError(exception = NotImplementedException.class, code = ERROR_CODE_BASE - 3) }) + ConfiguratorInfo setConfigurator(ConfiguratorInfo info) throws NotImplementedException; + + /** + * set Clipboard + * + * @param label User-visible label for the clip data. + * @param text The actual text in the clip. + */ + void setClipboard(String label, String text); + + /** + * get Clipboard data + * + * @return Clipboard data or null + */ + String getClipboard(); +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/AutomatorServiceImpl.java b/app/src/androidTest/java/com/tikfarm/stub/AutomatorServiceImpl.java new file mode 100644 index 0000000..76e3e4b --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/AutomatorServiceImpl.java @@ -0,0 +1,1976 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import android.app.Instrumentation; +import android.app.UiAutomation; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.media.AudioManager; +import android.media.SoundPool; +import android.os.Handler; +import android.os.Looper; +import android.os.RemoteException; +import android.os.SystemClock; +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.Configurator; +import androidx.test.uiautomator.Direction; +import androidx.test.uiautomator.StaleObjectException; +import androidx.test.uiautomator.UiCollection; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiObject; +import androidx.test.uiautomator.UiObject2; +import androidx.test.uiautomator.UiObjectNotFoundException; +import androidx.test.uiautomator.UiScrollable; +import androidx.test.uiautomator.UiSelector; +import androidx.test.uiautomator.Until; +import android.view.KeyEvent; +import android.view.MotionEvent; + +import com.github.tikmatrix.stub.watcher.ClickUiObjectWatcher; +import com.github.tikmatrix.stub.watcher.PressKeysWatcher; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.Base64; +import java.util.HashSet; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +public class AutomatorServiceImpl implements AutomatorService { + + private final HashSet watchers = new HashSet(); + private final ConcurrentHashMap uiObjects = new ConcurrentHashMap(); + private SoundPool soundPool = new SoundPool(100, AudioManager.STREAM_MUSIC, 0); + + Handler handler = new Handler(Looper.getMainLooper()); + + private UiDevice device; + private UiAutomation uiAutomation; + private Instrumentation mInstrumentation; + private TouchController touchController; + ClipboardManager clipboard; + + public AutomatorServiceImpl() { + mInstrumentation = InstrumentationRegistry.getInstrumentation(); + uiAutomation = mInstrumentation.getUiAutomation(); + device = UiDevice.getInstance(mInstrumentation); + touchController = new TouchController(mInstrumentation); + + handler.post(new Runnable() { + @Override + public void run() { + AutomatorServiceImpl.this.clipboard = (ClipboardManager) InstrumentationRegistry.getTargetContext() + .getSystemService(Context.CLIPBOARD_SERVICE); + } + }); + // play music when loaded + soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { + @Override + public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { + soundPool.play(sampleId, 1, 1, 1, 0, 1); + } + }); + + // Reset Configurator Wait Timeout + Configurator configurator = Configurator.getInstance(); + configurator.setWaitForSelectorTimeout(0L); // Default 10000 + configurator.setWaitForIdleTimeout(0L); // Default 10000 + configurator.setActionAcknowledgmentTimeout(500); // Default 3000 + configurator.setScrollAcknowledgmentTimeout(200); // Default 200 + configurator.setKeyInjectionDelay(0); // Default 0 + + uiAutomation.setOnAccessibilityEventListener(new AccessibilityEventListener(device, watchers)); + } + + private UiAutomation getUiAutomation() { + return uiAutomation; + } + + /** + * It's to play a section music to test + * + * @return + */ + @Override + public boolean playSound(String path) { + try { + soundPool.load(path, 1); + } catch (Exception e) { + return false; + } + return true; + } + + public void setToastListener(boolean enabled) { + if (enabled) { + // default uiAutomation serviceInfo.eventTypes is -1 + // this might means watch all eventTypes + getUiAutomation().setOnAccessibilityEventListener(new AccessibilityEventListener(device, watchers)); + } else { + getUiAutomation().setOnAccessibilityEventListener(null); + } + } + + /** + * It's to test if the service is alive. + * + * @return 'pong' + */ + @Override + public String ping() { + return "pong"; + } + + /** + * Get the device info. + * + * @return device info. + */ + @Override + public DeviceInfo deviceInfo() { + return DeviceInfo.getDeviceInfo(); + } + + @Override + public boolean makeToast(final String text, final int duration) { + Intent intent = new Intent(); + intent.setAction("com.github.tikmatrix.ACTION.SHOW_TOAST"); + intent.putExtra("toast_text", text); + intent.putExtra("duration", duration); + mInstrumentation.getTargetContext().sendBroadcast(intent); + return true; + } + + @Override + public String getLastToast(long cacheDuration) { + AccessibilityEventListener instance = AccessibilityEventListener.getInstance(); + if (System.currentTimeMillis() < cacheDuration + instance.toastTime) { + return instance.toastMessage; + } + return null; + } + + @Override + public boolean clearLastToast() { + AccessibilityEventListener.getInstance().toastMessage = null; + return true; + } + + /** + * Perform a click at arbitrary coordinates specified by the user. + * + * @param x coordinate + * @param y coordinate + * @return true if the click succeeded else false + */ + @Override + public boolean click(int x, int y) { + // The original implementation got bug here. + // when y >= getDiaplayHeight() return false, but getDisplayHeight() is not + // right in infinity display + // return device.click(x, y); + if (x < 0 || y < 0) { + return false; + } + touchController.touchDown(x, y); + SystemClock.sleep(100); // normally 100ms for click + return touchController.touchUp(x, y); + } + + public boolean click(int x, int y, long milliseconds) { + if (x < 0 || y < 0) { + return false; + } + touchController.touchDown(x, y); + SystemClock.sleep(milliseconds); + return touchController.touchUp(x, y); + } + + /** + * Performs a swipe from one coordinate to another coordinate. You can control + * the smoothness and speed of the swipe by specifying the number of steps. Each + * step execution is throttled to 5 milliseconds per step, so for a 100 steps, + * the swipe will take around 0.5 seconds to complete. + * + * @param startX X-axis value for the starting coordinate + * @param startY Y-axis value for the starting coordinate + * @param endX X-axis value for the ending coordinate + * @param endY Y-axis value for the ending coordinate + * @param steps is the number of steps for the swipe action + * @return true if swipe is performed, false if the operation fails or the + * coordinates are invalid + * @throws NotImplementedException + */ + @Override + public boolean drag(int startX, int startY, int endX, int endY, int steps) throws NotImplementedException { + return device.drag(startX, startY, endX, endY, steps); + } + + /** + * Performs a swipe from one coordinate to another using the number of steps to + * determine smoothness and speed. Each step execution is throttled to 5ms per + * step. So for a 100 steps, the swipe will take about 1/2 second to complete. + * + * @param startX X-axis value for the starting coordinate + * @param startY Y-axis value for the starting coordinate + * @param endX X-axis value for the ending coordinate + * @param endY Y-axis value for the ending coordinate + * @param steps is the number of move steps sent to the system + * @return false if the operation fails or the coordinates are invalid + */ + @Override + public boolean swipe(int startX, int startY, int endX, int endY, int steps) { + return device.swipe(startX, startY, endX, endY, steps); + } + + @Override + public boolean swipePoints(int[] segments, int segmentSteps) { + android.graphics.Point[] points = new android.graphics.Point[segments.length / 2]; + for (int i = 0; i < segments.length / 2; i++) { + points[i] = new android.graphics.Point(segments[2 * i], segments[2 * i + 1]); + } + return device.swipe(points, segmentSteps); + } + + // Multi touch is a little complicated + @Override + public boolean injectInputEvent(int action, float x, float y, int metaState) { + switch (action) { + case MotionEvent.ACTION_DOWN: // 0 + return touchController.touchDown(x, y); + case MotionEvent.ACTION_MOVE: // 2 + return touchController.touchMove(x, y); + case MotionEvent.ACTION_UP: // 1 + return touchController.touchUp(x, y); + default: + return false; + } + } + + /** + * Helper method used for debugging to dump the current window's layout + * hierarchy. The file root location is /data/local/tmp + * + * @param compressed use compressed layout hierarchy or not using + * setCompressedLayoutHeirarchy method. Ignore the parameter + * in case the API level lt 18. + * @param filename the filename to be stored. @deprecated + * @return the absolute path name of dumped file. + */ + @Deprecated + @Override + public String dumpWindowHierarchy(boolean compressed, String filename) { + return dumpWindowHierarchy(compressed); + } + + /** + * Helper method used for debugging to dump the current window's layout + * hierarchy. + * + * @param compressed use compressed layout hierarchy or not using + * setCompressedLayoutHeirarchy method. Ignore the parameter + * in case the API level lt 18. + * @return the absolute path name of dumped file. + */ + @Override + public String dumpWindowHierarchy(boolean compressed) { + device.setCompressedLayoutHeirarchy(compressed); + // ByteArrayOutputStream os1 = new ByteArrayOutputStream(); + ByteArrayOutputStream os2 = new ByteArrayOutputStream(); + try { + // Original code: + // device.dumpWindowHierarchy(os1); + // The bellow code fix xml encode error + AccessibilityNodeInfoDumper.dumpWindowHierarchy(device, os2); + String xml = os2.toString("UTF-8"); + android.util.Log.i("----------------", "dumpWindowHierarchy end:" + os2.size()); + android.util.Log.i("----------------", "dumpWindowHierarchy end:" + xml); + return xml; + } catch (IOException e) { + Log.d("dumpWindowHierarchy got IOException: " + e); + return e.getMessage(); + } finally { + try { + // os1.close(); + os2.close(); + } catch (IOException e) { + // ignore + } + } + + } + + /** + * Take a screenshot of current window and store it as PNG The screenshot is + * adjusted per screen rotation + * + * @param filename where the PNG should be written to + * @param scale scale the screenshot down if needed; 1.0f for original size + * @param quality quality of the PNG compression; range: 0-100 + * @return the file name of the screenshot. null if failed. + * @throws NotImplementedException + */ + @Override + public String takeScreenshot(String filename, float scale, int quality) throws NotImplementedException { + File f = new File(InstrumentationRegistry.getTargetContext().getFilesDir(), filename); + device.takeScreenshot(f, scale, quality); + if (f.exists()) + return f.getAbsolutePath(); + return null; + } + + @Override + public String takeScreenshot(float scale, int quality) throws NotImplementedException { + Bitmap screenshot = getUiAutomation().takeScreenshot(); + if (screenshot == null) { + return null; + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + screenshot.compress(Bitmap.CompressFormat.JPEG, quality, bos); + bos.flush(); + return Base64.getEncoder().encodeToString(bos.toByteArray()); + } catch (IOException ioe) { + Log.e("takeScreenshot error: " + ioe); + return null; + } finally { + try { + bos.close(); + } catch (IOException ioe) { + // Ignore + } + screenshot.recycle(); + } + } + + /** + * Disables the sensors and freezes the device rotation at its current rotation + * state, or enable it. + * + * @param freeze true to freeze the rotation, false to unfreeze the rotation. + * @throws RemoteException + */ + @Override + public void freezeRotation(boolean freeze) throws RemoteException { + if (freeze) + device.freezeRotation(); + else + device.unfreezeRotation(); + } + + /** + * Simulates orienting the device to the left/right/natural and also freezes + * rotation by disabling the sensors. + * + * @param dir Left or l, Right or r, Natural or n, case insensitive + * @throws RemoteException + * @throws NotImplementedException + */ + @Override + public void setOrientation(String dir) throws RemoteException, NotImplementedException { + dir = dir.toLowerCase(); + if ("left".equals(dir) || "l".equals(dir)) + device.setOrientationLeft(); + else if ("right".equals(dir) || "r".equals(dir)) + device.setOrientationRight(); + else if ("natural".equals(dir) || "n".equals(dir)) + device.setOrientationNatural(); + } + + /** + * Retrieves the text from the last UI traversal event received. + * + * @return the text from the last UI traversal event received. + */ + @Override + public String getLastTraversedText() { + return device.getLastTraversedText(); + } + + /** + * Clears the text from the last UI traversal event. + */ + @Override + public void clearLastTraversedText() { + device.clearLastTraversedText(); + } + + /** + * Opens the notification shade. + * + * @return true if successful, else return false + * @throws NotImplementedException + */ + @Override + public boolean openNotification() throws NotImplementedException { + return device.openNotification(); + } + + /** + * Opens the Quick Settings shade. + * + * @return true if successful, else return false + * @throws NotImplementedException + */ + @Override + public boolean openQuickSettings() throws NotImplementedException { + return device.openQuickSettings(); + } + + /** + * Checks if a specific registered UiWatcher has triggered. See + * registerWatcher(String, UiWatcher). If a UiWatcher runs and its + * checkForCondition() call returned true, then the UiWatcher is considered + * triggered. This is helpful if a watcher is detecting errors from ANR or crash + * dialogs and the test needs to know if a UiWatcher has been triggered. + * + * @param watcherName the name of registered watcher. + * @return true if triggered else false + */ + @Override + public boolean hasWatcherTriggered(String watcherName) { + return device.hasWatcherTriggered(watcherName); + } + + /** + * Checks if any registered UiWatcher have triggered. + * + * @return true if any UiWatcher have triggered else false. + */ + @Override + public boolean hasAnyWatcherTriggered() { + return device.hasAnyWatcherTriggered(); + } + + /** + * Register a ClickUiObjectWatcher + * + * @param name Watcher name + * @param conditions If all UiObject in the conditions match, the watcher should + * be triggered. + * @param target The target UiObject should be clicked if all conditions + * match. + */ + @Override + public void registerClickUiObjectWatcher(String name, Selector[] conditions, Selector target) { + synchronized (watchers) { + if (watchers.contains(name)) { + device.removeWatcher(name); + watchers.remove(name); + } + + UiSelector[] selectors = new UiSelector[conditions.length]; + for (int i = 0; i < conditions.length; i++) { + selectors[i] = conditions[i].toUiSelector(); + } + device.registerWatcher(name, new ClickUiObjectWatcher(selectors, target.toUiSelector())); + watchers.add(name); + } + } + + /** + * Register a PressKeysWatcher + * + * @param name Watcher name + * @param conditions If all UiObject in the conditions match, the watcher should + * be triggered. + * @param keys All keys will be pressed in sequence. + */ + @Override + public void registerPressKeyskWatcher(String name, Selector[] conditions, String[] keys) { + synchronized (watchers) { + if (watchers.contains(name)) { + device.removeWatcher(name); + watchers.remove(name); + } + + UiSelector[] selectors = new UiSelector[conditions.length]; + for (int i = 0; i < conditions.length; i++) { + selectors[i] = conditions[i].toUiSelector(); + } + device.registerWatcher(name, new PressKeysWatcher(selectors, keys)); + watchers.add(name); + } + } + + /** + * Removes a previously registered UiWatcher. + * + * @param name Watcher name + */ + @Override + public void removeWatcher(String name) { + synchronized (watchers) { + if (watchers.contains(name)) { + device.removeWatcher(name); + watchers.remove(name); + } + } + } + + /** + * Resets a UiWatcher that has been triggered. If a UiWatcher runs and its + * checkForCondition() call returned true, then the UiWatcher is considered + * triggered. + */ + @Override + public void resetWatcherTriggers() { + device.resetWatcherTriggers(); + } + + /** + * Force to run all watchers. + */ + @Override + public void runWatchers() { + device.runWatchers(); + } + + /** + * Get all registered UiWatchers + * + * @return UiWatcher names + */ + @Override + public String[] getWatchers() { + synchronized (watchers) { + return watchers.toArray(new String[watchers.size()]); + } + } + + /** + * Simulates a short press using key name. + * + * @param key possible key name is home, back, left, right, up, down, center, + * menu, search, enter, delete(or del), recent(recent apps), + * volume_up, volume_down, volume_mute, camera, power + * @return true if successful, else return false + * @throws RemoteException + */ + @Override + public boolean pressKey(String key) throws RemoteException { + boolean result; + key = key.toLowerCase(); + if ("home".equals(key)) + result = device.pressHome(); + else if ("back".equals(key)) + result = device.pressBack(); + else if ("left".equals(key)) + result = device.pressDPadLeft(); + else if ("right".equals(key)) + result = device.pressDPadRight(); + else if ("up".equals(key)) + result = device.pressDPadUp(); + else if ("down".equals(key)) + result = device.pressDPadDown(); + else if ("center".equals(key)) + result = device.pressDPadCenter(); + else if ("menu".equals(key)) + result = device.pressMenu(); + else if ("search".equals(key)) + result = device.pressSearch(); + else if ("enter".equals(key)) + result = device.pressEnter(); + else if ("delete".equals(key) || "del".equals(key)) + result = device.pressDelete(); + else if ("recent".equals(key)) + result = device.pressRecentApps(); + else if ("volume_up".equals(key)) + result = device.pressKeyCode(KeyEvent.KEYCODE_VOLUME_UP); + else if ("volume_down".equals(key)) + result = device.pressKeyCode(KeyEvent.KEYCODE_VOLUME_DOWN); + else if ("volume_mute".equals(key)) + result = device.pressKeyCode(KeyEvent.KEYCODE_VOLUME_MUTE); + else if ("camera".equals(key)) + result = device.pressKeyCode(KeyEvent.KEYCODE_CAMERA); + else + result = "power".equals(key) && device.pressKeyCode(KeyEvent.KEYCODE_POWER); + + return result; + } + + /** + * Simulates a short press using a key code. See KeyEvent. + * + * @param keyCode the key code of the event. + * @return true if successful, else return false + */ + @Override + public boolean pressKeyCode(int keyCode) { + return device.pressKeyCode(keyCode); + } + + /** + * Simulates a short press using a key code. See KeyEvent. + * + * @param keyCode the key code of the event. + * @param metaState an integer in which each bit set to 1 represents a pressed + * meta key + * @return true if successful, else return false + */ + @Override + public boolean pressKeyCode(int keyCode, int metaState) { + return device.pressKeyCode(keyCode, metaState); + } + + /** + * This method simulates pressing the power button if the screen is OFF else it + * does nothing if the screen is already ON. If the screen was OFF and it just + * got turned ON, this method will insert a 500ms delay to allow the device time + * to wake up and accept input. + * + * @throws RemoteException + */ + @Override + public void wakeUp() throws RemoteException { + device.wakeUp(); + } + + /** + * This method simply presses the power button if the screen is ON else it does + * nothing if the screen is already OFF. + * + * @throws RemoteException + */ + @Override + public void sleep() throws RemoteException { + device.sleep(); + } + + /** + * Checks the power manager if the screen is ON. + * + * @return true if the screen is ON else false + * @throws RemoteException + */ + @Override + public boolean isScreenOn() throws RemoteException { + return device.isScreenOn(); + } + + /** + * Waits for the current application to idle. + * + * @param timeout in milliseconds + */ + @Override + public void waitForIdle(long timeout) { + device.waitForIdle(timeout); + } + + /** + * Waits for a window content update event to occur. If a package name for the + * window is specified, but the current window does not have the same package + * name, the function returns immediately. + * + * @param packageName the specified window package name (can be null). If null, + * a window update from any front-end window will end the + * wait. + * @param timeout the timeout for the wait + * @return true if a window update occurred, false if timeout has elapsed or if + * the current window does not have the specified package name + */ + @Override + public boolean waitForWindowUpdate(String packageName, long timeout) { + return device.waitForWindowUpdate(packageName, timeout); + } + + /** + * Clears the existing text contents in an editable field. The UiSelector of + * this object must reference a UI element that is editable. When you call this + * method, the method first sets focus at the start edge of the field. The + * method then simulates a long-press to select the existing text, and deletes + * the selected text. If a "Select-All" option is displayed, the method will + * automatically attempt to use it to ensure full text selection. Note that it + * is possible that not all the text in the field is selected; for example, if + * the text contains separators such as spaces, slashes, at symbol etc. Also, + * not all editable fields support the long-press functionality. + * + * @param obj the selector of the UiObject. + * @throws UiObjectNotFoundException + */ + @Override + public void clearTextField(Selector obj) throws UiObjectNotFoundException { + try { + obj.toUiObject2().clear(); + } catch (NullPointerException | StaleObjectException e) { + device.findObject(obj.toUiSelector()).clearTextField(); + } + + } + + /** + * Reads the text property of the UI element + * + * @param obj the selector of the UiObject. + * @return text value of the current node represented by this UiObject + * @throws UiObjectNotFoundException + */ + @Override + public String getText(Selector obj) throws UiObjectNotFoundException { + if (obj.toUiObject2() == null) { + return device.findObject(obj.toUiSelector()).getText(); + } else { + return obj.toUiObject2().getText(); + } + } + + /** + * Sets the text in an editable field, after clearing the field's content. The + * UiSelector selector of this object must reference a UI element that is + * editable. When you call this method, the method first simulates a click() on + * editable field to set focus. The method then clears the field's contents and + * injects your specified text into the field. If you want to capture the + * original contents of the field, call getText() first. You can then modify the + * text and use this method to update the field. + * + * @param obj the selector of the UiObject. + * @param text string to set + * @return true if operation is successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean setText(Selector obj, String text) throws UiObjectNotFoundException { + try { + obj.toUiObject2().click(); + obj.toUiObject2().setText(text); + return true; + } catch (NullPointerException | StaleObjectException e) { + return device.findObject(obj.toUiSelector()).setText(text); + } + } + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject. + * + * @param obj the target ui object. + * @return true id successful else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean click(Selector obj) throws UiObjectNotFoundException { + if (obj.toUiObject2() == null) { + return device.findObject(obj.toUiSelector()).click(); + } else { + obj.toUiObject2().click(); + return true; + } + } + + /** + * Clicks the bottom and right corner or top and left corner of the UI element + * + * @param obj the target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true on success + * @throws UiObjectNotFoundException + */ + @Override + public boolean click(Selector obj, String corner) throws UiObjectNotFoundException { + return click(device.findObject(obj.toUiSelector()), corner); + } + + private boolean click(UiObject obj, String corner) throws UiObjectNotFoundException { + if (corner == null) + corner = "center"; + corner = corner.toLowerCase(); + if ("br".equals(corner) || "bottomright".equals(corner)) + return obj.clickBottomRight(); + else if ("tl".equals(corner) || "topleft".equals(corner)) + return obj.clickTopLeft(); + else if ("c".equals(corner) || "center".equals(corner)) + return obj.click(); + return false; + } + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject and waits for window transitions. This method + * differ from click() only in that this method waits for a a new window + * transition as a result of the click. Some examples of a window transition: + * - launching a new activity + * - bringing up a pop-up menu + * - bringing up a dialog + * + * @param obj the target ui object. + * @param timeout timeout before giving up on waiting for a new window + * @return true if the event was triggered, else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean clickAndWaitForNewWindow(Selector obj, long timeout) throws UiObjectNotFoundException { + if (obj.toUiObject2() == null) { + return device.findObject(obj.toUiSelector()).clickAndWaitForNewWindow(timeout); + } else { + return obj.toUiObject2().clickAndWait(Until.newWindow(), timeout); + } + } + + /** + * Long clicks the center of the visible bounds of the UI element + * + * @param obj the target ui object. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean longClick(Selector obj) throws UiObjectNotFoundException { + if (obj.toUiObject2() == null) { + return device.findObject(obj.toUiSelector()).longClick(); + } else { + obj.toUiObject2().longClick(); + return true; + } + } + + /** + * Long clicks bottom and right corner of the UI element + * + * @param obj the target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean longClick(Selector obj, String corner) throws UiObjectNotFoundException { + return longClick(device.findObject(obj.toUiSelector()), corner); + } + + private boolean longClick(UiObject obj, String corner) throws UiObjectNotFoundException { + if (corner == null) + corner = "center"; + + corner = corner.toLowerCase(); + if ("br".equals(corner) || "bottomright".equals(corner)) + return obj.longClickBottomRight(); + else if ("tl".equals(corner) || "topleft".equals(corner)) + return obj.longClickTopLeft(); + else if ("c".equals(corner) || "center".equals(corner)) + return obj.longClick(); + + return false; + } + + /** + * Drags this object to a destination UiObject. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the ui object to be dragged. + * @param destObj the ui object to be dragged to. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean dragTo(Selector obj, Selector destObj, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return dragTo(device.findObject(obj.toUiSelector()), destObj, steps); + } + + private boolean dragTo(UiObject obj, Selector destObj, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return obj.dragTo(device.findObject(destObj.toUiSelector()), steps); + } + + /** + * Drags this object to arbitrary coordinates. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the ui object to be dragged. + * @param destX the X-axis coordinate of destination. + * @param destY the Y-axis coordinate of destination. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean dragTo(Selector obj, int destX, int destY, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return dragTo(device.findObject(obj.toUiSelector()), destX, destY, steps); + } + + private boolean dragTo(UiObject obj, int destX, int destY, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return obj.dragTo(destX, destY, steps); + } + + /** + * Check if view exists. This methods performs a waitForExists(long) with zero + * timeout. This basically returns immediately whether the view represented by + * this UiObject exists or not. + * + * @param obj the ui object. + * @return true if the view represented by this UiObject does exist + */ + @Override + public boolean exist(Selector obj) { + if (obj.getChildOrSibling().length == 0 && obj.toBySelector() != null) + return device.wait(Until.hasObject(obj.toBySelector()), 0L); + return device.findObject(obj.toUiSelector()).exists(); + } + + /** + * Get the object info. + * + * @param obj the target ui object. + * @return object info. + * @throws UiObjectNotFoundException + */ + @Override + public ObjInfo objInfo(Selector obj) throws UiObjectNotFoundException { + try { + final UiObject2 obj2 = obj.toUiObject2(); // to avoid a race condition + if (obj2 != null) { + return ObjInfo.getObjInfo(obj2); + } + } catch (StaleObjectException e) { + Log.d("objInfo got StaleObjectException " + e); + // HotFix(ssx): Here always raise StaleObjectException + // Refs: https://github.com/openatx/uiautomator2/issues/138 + } + return ObjInfo.getObjInfo(device.findObject(obj.toUiSelector())); + } + + /** + * Get the count of the UiObject instances by the selector + * + * @param obj the selector of the ui object + * @return the count of instances. + */ + @Override + public int count(Selector obj) { + if ((obj.deepSelector().getMask() & Selector.MASK_INSTANCE) > 0) { + if (device.findObject(obj.toUiSelector()).exists()) + return 1; + else + return 0; + } else { + UiSelector sel = obj.toUiSelector(); + if (!device.findObject(sel).exists()) + return 0; + int low = 1; + int high = 2; + + // Note: can not use `sel = sel.instance(high -1)` + // because this will change first selector in chain not last. + sel = obj.toUiSelector(high - 1); + while (device.findObject(sel).exists()) { + low = high; + high = high * 2; + sel = obj.toUiSelector(high - 1); + } + while (high > low + 1) { + int mid = (low + high) / 2; + sel = obj.toUiSelector(mid - 1); + if (device.findObject(sel).exists()) + low = mid; + else + high = mid; + } + return low; + } + } + + /** + * Get the info of all instance by the selector. + * + * @param obj the selector of ui object. + * @return array of object info. + */ + @Override + public ObjInfo[] objInfoOfAllInstances(Selector obj) { + int total = count(obj); + ObjInfo objs[] = new ObjInfo[total]; + if ((obj.getMask() & Selector.MASK_INSTANCE) > 0 && total > 0) { + try { + objs[0] = objInfo(obj); + } catch (UiObjectNotFoundException e) { + } + } else { + UiSelector sel = obj.toUiSelector(); + for (int i = 0; i < total; i++) { + try { + objs[i] = ObjInfo.getObjInfo(sel.instance(i)); + } catch (UiObjectNotFoundException e) { + } + } + } + return objs; + } + + /** + * Generates a two-pointer gesture with arbitrary starting and ending points. + * + * @param obj the target ui object. ?? + * @param startPoint1 start point of pointer 1 + * @param startPoint2 start point of pointer 2 + * @param endPoint1 end point of pointer 1 + * @param endPoint2 end point of pointer 2 + * @param steps the number of steps for the gesture. Steps are injected + * about 5 milliseconds apart, so 100 steps may take around + * 0.5 seconds to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + */ + @Override + public boolean gesture(Selector obj, Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, + int steps) throws UiObjectNotFoundException, NotImplementedException { + return gesture(device.findObject(obj.toUiSelector()), startPoint1, startPoint2, endPoint1, endPoint2, steps); + } + + private boolean gesture(UiObject obj, Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, + int steps) throws UiObjectNotFoundException, NotImplementedException { + return obj.performTwoPointerGesture(startPoint1.toPoint(), startPoint2.toPoint(), endPoint1.toPoint(), + endPoint2.toPoint(), steps); + } + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally toward + * the other, from the edges to the center of this UiObject . + * + * @param obj the target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean pinchIn(Selector obj, int percent, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return pinchIn(device.findObject(obj.toUiSelector()), percent, steps); + } + + private boolean pinchIn(UiObject obj, int percent, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return obj.pinchIn(percent, steps); + } + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally opposite + * across the other, from the center out towards the edges of the this UiObject. + * + * @param obj the target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean pinchOut(Selector obj, int percent, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return pinchOut(device.findObject(obj.toUiSelector()), percent, steps); + } + + private boolean pinchOut(UiObject obj, int percent, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return obj.pinchOut(percent, steps); + } + + /** + * Performs the swipe up/down/left/right action on the UiObject + * + * @param obj the target ui object. + * @param dir "u"/"up", "d"/"down", "l"/"left", "r"/"right" + * @param steps indicates the number of injected move steps into the system. + * Steps are injected about 5ms apart. So a 100 steps may take + * about 1/2 second to complete. + * @return true of successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean swipe(Selector obj, String dir, int steps) throws UiObjectNotFoundException { + return swipe(device.findObject(obj.toUiSelector()), dir, steps); + } + + private boolean swipe(UiObject item, String dir, int steps) throws UiObjectNotFoundException { + dir = dir.toLowerCase(); + boolean result = false; + if ("u".equals(dir) || "up".equals(dir)) + result = item.swipeUp(steps); + else if ("d".equals(dir) || "down".equals(dir)) + result = item.swipeDown(steps); + else if ("l".equals(dir) || "left".equals(dir)) + result = item.swipeLeft(steps); + else if ("r".equals(dir) || "right".equals(dir)) + result = item.swipeRight(steps); + return result; + } + + /** + * Performs the swipe up/down/left/right action on the UiObject + * + * @param obj the target ui object. + * @param dir "u"/"up", "d"/"down", "l"/"left", "r"/"right" + * @param percent expect value: percent >= 0.0F && percent <= 1.0F,The length of + * the swipe as a percentage of this object's size. + * @param steps indicates the number of injected move steps into the system. + * Steps are injected about 5ms apart. So a 100 steps may take + * about 1/2 second to complete. + * @return true of successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean swipe(Selector obj, String dir, float percent, int steps) throws UiObjectNotFoundException { + if (obj.toUiObject2() == null) { + return swipe(device.findObject(obj.toUiSelector()), dir, steps); + } + return swipe(obj.toUiObject2(), dir, percent, steps); + } + + private boolean swipe(UiObject2 item, String dir, float percent, int steps) throws UiObjectNotFoundException { + dir = dir.toLowerCase(); + if ("u".equals(dir) || "up".equals(dir)) + item.swipe(Direction.UP, percent, steps); + else if ("d".equals(dir) || "down".equals(dir)) + item.swipe(Direction.DOWN, percent, steps); + else if ("l".equals(dir) || "left".equals(dir)) + item.swipe(Direction.LEFT, percent, steps); + else if ("r".equals(dir) || "right".equals(dir)) + item.swipe(Direction.RIGHT, percent, steps); + return true; + } + + /** + * Waits a specified length of time for a view to become visible. This method + * waits until the view becomes visible on the display, or until the timeout has + * elapsed. You can use this method in situations where the content that you + * want to select is not immediately displayed. + * + * @param obj the target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the view is displayed, else false if timeout elapsed while + * waiting + */ + @Override + public boolean waitForExists(Selector obj, long timeout) { + try { + if (obj.getChildOrSibling().length == 0 && obj.checkBySelectorNull(obj) == false) + return device.wait(Until.hasObject(obj.toBySelector()), timeout); + } catch (ClassCastException e) { + Log.d("waitForExists got ClassCastException " + e); + // Hotfix because of https://github.com/openatx/uiautomator2/issues/140 + } + // https://developer.android.com/reference/android/support/test/uiautomator/UiObject#waitforexists + return device.findObject(obj.toUiSelector()).waitForExists(timeout); + } + + /** + * Waits a specified length of time for a view to become undetectable. This + * method waits until a view is no longer matchable, or until the timeout has + * elapsed. A view becomes undetectable when the UiSelector of the object is + * unable to find a match because the element has either changed its state or is + * no longer displayed. You can use this method when attempting to wait for some + * long operation to compete, such as downloading a large file or connecting to + * a remote server. + * + * @param obj the target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the element is gone before timeout elapsed, else false if + * timeout elapsed but a matching element is still found. + */ + @Override + public boolean waitUntilGone(Selector obj, long timeout) { + try { + if (obj.getChildOrSibling().length == 0 && obj.checkBySelectorNull(obj) == false) + return device.wait(Until.gone(obj.toBySelector()), timeout); + } catch (ClassCastException e) { + Log.d("waitUntilGone got ClassCastException " + e); + } + return device.findObject(obj.toUiSelector()).waitUntilGone(timeout); + } + + /** + * Performs a backwards fling action with the default number of fling steps (5). + * If the swipe direction is set to vertical, then the swipe will be performed + * from top to bottom. If the swipe direction is set to horizontal, then the + * swipes will be performed from left to right. Make sure to take into account + * devices configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @return true if scrolled, and false if can't scroll anymore + * @throws UiObjectNotFoundException + */ + @Override + public boolean flingBackward(Selector obj, boolean isVertical) throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.flingBackward(); + } + + /** + * Performs a forward fling with the default number of fling steps (5). If the + * swipe direction is set to vertical, then the swipes will be performed from + * bottom to top. If the swipe direction is set to horizontal, then the swipes + * will be performed from right to left. Make sure to take into account devices + * configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @return true if scrolled, and false if can't scroll anymore + * @throws UiObjectNotFoundException + */ + @Override + public boolean flingForward(Selector obj, boolean isVertical) throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.flingForward(); + } + + /** + * Performs a fling gesture to reach the beginning of a scrollable layout + * element. The beginning can be at the top-most edge in the case of vertical + * controls, or the left-most edge for horizontal controls. Make sure to take + * into account devices configured with right-to-left languages like Arabic and + * Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to achieve beginning. + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean flingToBeginning(Selector obj, boolean isVertical, int maxSwipes) throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.flingToBeginning(maxSwipes); + } + + /** + * Performs a fling gesture to reach the end of a scrollable layout element. The + * end can be at the bottom-most edge in the case of vertical controls, or the + * right-most edge for horizontal controls. Make sure to take into account + * devices configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to achieve end. + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean flingToEnd(Selector obj, boolean isVertical, int maxSwipes) throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.flingToEnd(maxSwipes); + } + + /** + * Performs a backward scroll. If the swipe direction is set to vertical, then + * the swipes will be performed from top to bottom. If the swipe direction is + * set to horizontal, then the swipes will be performed from left to right. Make + * sure to take into account devices configured with right-to-left languages + * like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param steps number of steps. Use this to control the speed of the + * scroll action. + * @return true if scrolled, false if can't scroll anymore + * @throws UiObjectNotFoundException + */ + @Override + public boolean scrollBackward(Selector obj, boolean isVertical, int steps) throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.scrollBackward(steps); + } + + /** + * Performs a forward scroll with the default number of scroll steps (55). If + * the swipe direction is set to vertical, then the swipes will be performed + * from bottom to top. If the swipe direction is set to horizontal, then the + * swipes will be performed from right to left. Make sure to take into account + * devices configured with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param steps number of steps. Use this to control the speed of the + * scroll action. + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean scrollForward(Selector obj, boolean isVertical, int steps) throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.scrollForward(steps); + } + + /** + * Scrolls to the beginning of a scrollable layout element. The beginning can be + * at the top-most edge in the case of vertical controls, or the left-most edge + * for horizontal controls. Make sure to take into account devices configured + * with right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to be performed. + * @param steps use steps to control the speed, so that it may be a scroll, + * or fling + * @return true on scrolled else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean scrollToBeginning(Selector obj, boolean isVertical, int maxSwipes, int steps) + throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.scrollToBeginning(maxSwipes, steps); + } + + /** + * Scrolls to the end of a scrollable layout element. The end can be at the + * bottom-most edge in the case of vertical controls, or the right-most edge for + * horizontal controls. Make sure to take into account devices configured with + * right-to-left languages like Arabic and Hebrew. + * + * @param obj the selector of the scrollable object + * @param isVertical vertical or horizontal + * @param maxSwipes max swipes to be performed. + * @param steps use steps to control the speed, so that it may be a scroll, + * or fling + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean scrollToEnd(Selector obj, boolean isVertical, int maxSwipes, int steps) + throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.scrollToEnd(maxSwipes, steps); + } + + /** + * Perform a scroll forward action to move through the scrollable layout element + * until a visible item that matches the selector is found. + * + * @param obj the selector of the scrollable object + * @param targetObj the item matches the selector to be found. + * @param isVertical vertical or horizontal + * @return true on scrolled, else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean scrollTo(Selector obj, Selector targetObj, boolean isVertical) throws UiObjectNotFoundException { + UiScrollable scrollable = new UiScrollable(obj.toUiSelector()); + if (isVertical) + scrollable.setAsVerticalList(); + else + scrollable.setAsHorizontalList(); + return scrollable.scrollIntoView(targetObj.toUiSelector()); + } + + /** + * Name an UiObject and cache it. + * + * @param obj UiObject + * @return the name of the UiObject + */ + private String addUiObject(UiObject obj) { + String key = UUID.randomUUID().toString(); + uiObjects.put(key, obj); + // schedule the clear timer. + Timer clearTimer = new Timer(); + clearTimer.schedule(new ClearUiObjectTimerTask(key), 60000); + return key; + } + + class ClearUiObjectTimerTask extends TimerTask { + String name; + + public ClearUiObjectTimerTask(String name) { + this.name = name; + } + + @Override + public void run() { + uiObjects.remove(name); + } + } + + /** + * Searches for child UI element within the constraints of this UiSelector + * selector. It looks for any child matching the childPattern argument that has + * a child UI element anywhere within its sub hierarchy that has a text + * attribute equal to text. The returned UiObject will point at the childPattern + * instance that matched the search and not at the identifying child element + * that matched the text attribute. + * + * @param collection Selector of UiCollection or UiScrollable. + * @param text String of the identifying child contents of of the + * childPattern + * @param child UiSelector selector of the child pattern to match and + * return + * @return A string ID represent the returned UiObject. + */ + @Override + public String childByText(Selector collection, Selector child, String text) throws UiObjectNotFoundException { + UiObject obj; + if (exist(collection) && objInfo(collection).isScrollable()) { + obj = new UiScrollable(collection.toUiSelector()).getChildByText(child.toUiSelector(), text); + } else { + obj = new UiCollection(collection.toUiSelector()).getChildByText(child.toUiSelector(), text); + } + return addUiObject(obj); + } + + @Override + public String childByText(Selector collection, Selector child, String text, boolean allowScrollSearch) + throws UiObjectNotFoundException { + UiObject obj = new UiScrollable(collection.toUiSelector()).getChildByText(child.toUiSelector(), text, + allowScrollSearch); + return addUiObject(obj); + } + + /** + * Searches for child UI element within the constraints of this UiSelector + * selector. It looks for any child matching the childPattern argument that has + * a child UI element anywhere within its sub hierarchy that has + * content-description text. The returned UiObject will point at the + * childPattern instance that matched the search and not at the identifying + * child element that matched the content description. + * + * @param collection Selector of UiCollection or UiScrollable + * @param child UiSelector selector of the child pattern to match and + * return + * @param text String of the identifying child contents of of the + * childPattern + * @return A string ID represent the returned UiObject. + */ + @Override + public String childByDescription(Selector collection, Selector child, String text) + throws UiObjectNotFoundException { + UiObject obj; + if (exist(collection) && objInfo(collection).isScrollable()) { + obj = new UiScrollable(collection.toUiSelector()).getChildByDescription(child.toUiSelector(), text); + } else { + obj = new UiCollection(collection.toUiSelector()).getChildByDescription(child.toUiSelector(), text); + } + return addUiObject(obj); + } + + @Override + public String childByDescription(Selector collection, Selector child, String text, boolean allowScrollSearch) + throws UiObjectNotFoundException { + UiObject obj = new UiScrollable(collection.toUiSelector()).getChildByDescription(child.toUiSelector(), text, + allowScrollSearch); + return addUiObject(obj); + } + + /** + * Searches for child UI element within the constraints of this UiSelector. It + * looks for any child matching the childPattern argument that has a child UI + * element anywhere within its sub hierarchy that is at the instance specified. + * The operation is performed only on the visible items and no scrolling is + * performed in this case. + * + * @param collection Selector of UiCollection or UiScrollable + * @param child UiSelector selector of the child pattern to match and + * return + * @param instance int the desired matched instance of this childPattern + * @return A string ID represent the returned UiObject. + */ + @Override + public String childByInstance(Selector collection, Selector child, int instance) throws UiObjectNotFoundException { + UiObject obj; + if (exist(collection) && objInfo(collection).isScrollable()) { + obj = new UiScrollable(collection.toUiSelector()).getChildByInstance(child.toUiSelector(), instance); + } else { + obj = new UiCollection(collection.toUiSelector()).getChildByInstance(child.toUiSelector(), instance); + } + return addUiObject(obj); + } + + /** + * Creates a new UiObject for a child view that is under the present UiObject. + * + * @param obj The ID string represent the parent UiObject. + * @param selector UiSelector selector of the child pattern to match and return + * @return A string ID represent the returned UiObject. + */ + @Override + public String getChild(String obj, Selector selector) throws UiObjectNotFoundException { + UiObject ui = uiObjects.get(obj); + if (ui != null) { + return addUiObject(ui.getChild(selector.toUiSelector())); + } + return null; + } + + /** + * Creates a new UiObject for a sibling view or a child of the sibling view, + * relative to the present UiObject. + * + * @param obj The ID string represent the source UiObject. + * @param selector for a sibling view or children of the sibling view + * @return A string ID represent the returned UiObject. + */ + @Override + public String getFromParent(String obj, Selector selector) throws UiObjectNotFoundException { + UiObject ui = uiObjects.get(obj); + if (ui != null) { + return addUiObject(ui.getFromParent(selector.toUiSelector())); + } + return null; + } + + /** + * Get a new UiObject from the selector. + * + * @param selector Selector of the UiObject + * @return A string ID represent the returned UiObject. + * @throws UiObjectNotFoundException + */ + @Override + public String getUiObject(Selector selector) throws UiObjectNotFoundException { + return addUiObject(device.findObject(selector.toUiSelector())); + } + + /** + * Remove the UiObject from memory. + */ + @Override + public void removeUiObject(String obj) { + uiObjects.remove(obj); + } + + /** + * Get all named UiObjects. + * + * @return all names + */ + @Override + public String[] getUiObjects() { + Set strings = uiObjects.keySet(); + return strings.toArray(new String[strings.size()]); + } + + private UiObject getUiObject(String name) throws UiObjectNotFoundException { + if (uiObjects.containsKey(name)) { + return uiObjects.get(name); + } else { + throw new UiObjectNotFoundException("UiObject " + name + " not found!"); + } + } + + /** + * Clears the existing text contents in an editable field. The UiSelector of + * this object must reference a UI element that is editable. When you call this + * method, the method first sets focus at the start edge of the field. The + * method then simulates a long-press to select the existing text, and deletes + * the selected text. If a "Select-All" option is displayed, the method will + * automatically attempt to use it to ensure full text selection. Note that it + * is possible that not all the text in the field is selected; for example, if + * the text contains separators such as spaces, slashes, at symbol etc. Also, + * not all editable fields support the long-press functionality. + * + * @param obj the id of the UiObject. + * @throws UiObjectNotFoundException + */ + @Override + public void clearTextField(String obj) throws UiObjectNotFoundException { + getUiObject(obj).clearTextField(); + } + + /** + * Reads the text property of the UI element + * + * @param obj the id of the UiObject. + * @return text value of the current node represented by this UiObject + * @throws UiObjectNotFoundException + */ + @Override + public String getText(String obj) throws UiObjectNotFoundException { + return getUiObject(obj).getText(); + } + + /** + * Sets the text in an editable field, after clearing the field's content. The + * UiSelector selector of this object must reference a UI element that is + * editable. When you call this method, the method first simulates a click() on + * editable field to set focus. The method then clears the field's contents and + * injects your specified text into the field. If you want to capture the + * original contents of the field, call getText() first. You can then modify the + * text and use this method to update the field. + * + * @param obj the id of the UiObject. + * @param text string to set + * @return true if operation is successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean setText(String obj, String text) throws UiObjectNotFoundException { + return getUiObject(obj).setText(text); + } + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject. + * + * @param obj the id of target ui object. + * @return true id successful else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean click(String obj) throws UiObjectNotFoundException { + return getUiObject(obj).click(); + } + + /** + * Clicks the bottom and right corner or top and left corner of the UI element + * + * @param obj the id of target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true on success + * @throws UiObjectNotFoundException + */ + @Override + public boolean click(String obj, String corner) throws UiObjectNotFoundException { + return click(getUiObject(obj), corner); + } + + /** + * Performs a click at the center of the visible bounds of the UI element + * represented by this UiObject and waits for window transitions. This method + * differ from click() only in that this method waits for a a new window + * transition as a result of the click. Some examples of a window transition: + * - launching a new activity + * - bringing up a pop-up menu + * - bringing up a dialog + * + * @param obj the id of target ui object. + * @param timeout timeout before giving up on waiting for a new window + * @return true if the event was triggered, else false + * @throws UiObjectNotFoundException + */ + @Override + public boolean clickAndWaitForNewWindow(String obj, long timeout) throws UiObjectNotFoundException { + return getUiObject(obj).clickAndWaitForNewWindow(timeout); + } + + /** + * Long clicks the center of the visible bounds of the UI element + * + * @param obj the id of target ui object. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean longClick(String obj) throws UiObjectNotFoundException { + return getUiObject(obj).longClick(); + } + + /** + * Long clicks bottom and right corner of the UI element + * + * @param obj the id of target ui object. + * @param corner "br"/"bottomright" means BottomRight, "tl"/"topleft" means + * TopLeft, "center" means Center. + * @return true if operation was successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean longClick(String obj, String corner) throws UiObjectNotFoundException { + return longClick(getUiObject(obj), corner); + } + + /** + * Drags this object to a destination UiObject. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the id of ui object to be dragged. + * @param destObj the ui object to be dragged to. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean dragTo(String obj, Selector destObj, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return dragTo(getUiObject(obj), destObj, steps); + } + + /** + * Drags this object to arbitrary coordinates. The number of steps specified in + * your input parameter can influence the drag speed, and varying speeds may + * impact the results. Consider evaluating different speeds when using this + * method in your tests. + * + * @param obj the id of ui object to be dragged. + * @param destX the X-axis coordinate of destination. + * @param destY the Y-axis coordinate of destination. + * @param steps usually 40 steps. You can increase or decrease the steps to + * change the speed. + * @return true if successful + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean dragTo(String obj, int destX, int destY, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return dragTo(getUiObject(obj), destX, destY, steps); + } + + /** + * Check if view exists. This methods performs a waitForExists(long) with zero + * timeout. This basically returns immediately whether the view represented by + * this UiObject exists or not. + * + * @param obj the id of ui object. + * @return true if the view represented by this UiObject does exist + */ + @Override + public boolean exist(String obj) { + try { + return getUiObject(obj).exists(); + } catch (UiObjectNotFoundException e) { + return false; + } + } + + /** + * Get the object info. + * + * @param obj the id of target ui object. + * @return object info. + * @throws UiObjectNotFoundException + */ + @Override + public ObjInfo objInfo(String obj) throws UiObjectNotFoundException { + return ObjInfo.getObjInfo(getUiObject(obj)); + } + + /** + * Generates a two-pointer gesture with arbitrary starting and ending points. + * + * @param obj the id of target ui object. ?? + * @param startPoint1 start point of pointer 1 + * @param startPoint2 start point of pointer 2 + * @param endPoint1 end point of pointer 1 + * @param endPoint2 end point of pointer 2 + * @param steps the number of steps for the gesture. Steps are injected + * about 5 milliseconds apart, so 100 steps may take around + * 0.5 seconds to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + */ + @Override + public boolean gesture(String obj, Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, + int steps) throws UiObjectNotFoundException, NotImplementedException { + return gesture(getUiObject(obj), startPoint1, startPoint2, endPoint1, endPoint2, steps); + } + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally toward + * the other, from the edges to the center of this UiObject . + * + * @param obj the id of target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean pinchIn(String obj, int percent, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return pinchIn(getUiObject(obj), percent, steps); + } + + /** + * Performs a two-pointer gesture, where each pointer moves diagonally opposite + * across the other, from the center out towards the edges of the this UiObject. + * + * @param obj the id of target ui object. + * @param percent percentage of the object's diagonal length for the pinch + * gesture + * @param steps the number of steps for the gesture. Steps are injected about + * 5 milliseconds apart, so 100 steps may take around 0.5 seconds + * to complete. + * @return true if all touch events for this gesture are injected successfully, + * false otherwise + * @throws UiObjectNotFoundException + * @throws NotImplementedException + */ + @Override + public boolean pinchOut(String obj, int percent, int steps) + throws UiObjectNotFoundException, NotImplementedException { + return pinchOut(getUiObject(obj), percent, steps); + } + + /** + * Performs the swipe up/down/left/right action on the UiObject + * + * @param obj the id of target ui object. + * @param dir "u"/"up", "d"/"down", "l"/"left", "r"/"right" + * @param steps indicates the number of injected move steps into the system. + * Steps are injected about 5ms apart. So a 100 steps may take + * about 1/2 second to complete. + * @return true of successful + * @throws UiObjectNotFoundException + */ + @Override + public boolean swipe(String obj, String dir, int steps) throws UiObjectNotFoundException { + return swipe(getUiObject(obj), dir, steps); + } + + /** + * Waits a specified length of time for a view to become visible. This method + * waits until the view becomes visible on the display, or until the timeout has + * elapsed. You can use this method in situations where the content that you + * want to select is not immediately displayed. + * + * @param obj the id of target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the view is displayed, else false if timeout elapsed while + * waiting + */ + @Override + public boolean waitForExists(String obj, long timeout) throws UiObjectNotFoundException { + return getUiObject(obj).waitForExists(timeout); + } + + /** + * Waits a specified length of time for a view to become undetectable. This + * method waits until a view is no longer matchable, or until the timeout has + * elapsed. A view becomes undetectable when the UiSelector of the object is + * unable to find a match because the element has either changed its state or is + * no longer displayed. You can use this method when attempting to wait for some + * long operation to compete, such as downloading a large file or connecting to + * a remote server. + * + * @param obj the id of target ui object + * @param timeout time to wait (in milliseconds) + * @return true if the element is gone before timeout elapsed, else false if + * timeout elapsed but a matching element is still found. + */ + @Override + public boolean waitUntilGone(String obj, long timeout) throws UiObjectNotFoundException { + return getUiObject(obj).waitUntilGone(timeout); + } + + /** + * Get Configurator + * + * @return Configurator information. + * @throws NotImplementedException + */ + @Override + public ConfiguratorInfo getConfigurator() throws NotImplementedException { + return new ConfiguratorInfo(); + } + + /** + * Set Configurator. + * + * @param info the configurator information to be set. + * @throws NotImplementedException + */ + @Override + public ConfiguratorInfo setConfigurator(ConfiguratorInfo info) throws NotImplementedException { + ConfiguratorInfo.setConfigurator(info); + return new ConfiguratorInfo(); + } + + @Override + public void setClipboard(String label, String text) { + clipboard.setPrimaryClip(ClipData.newPlainText(label, text)); + } + + @Override + public String getClipboard() { + final ClipData clip = clipboard.getPrimaryClip(); + if (clip != null && clip.getItemCount() > 0 && clipboard.getPrimaryClip().getItemAt(0).getText() != null) { + return clipboard.getPrimaryClip().getItemAt(0).getText().toString(); + } + return null; + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/ConfiguratorInfo.java b/app/src/androidTest/java/com/tikfarm/stub/ConfiguratorInfo.java new file mode 100644 index 0000000..2a657bb --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/ConfiguratorInfo.java @@ -0,0 +1,96 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import androidx.test.uiautomator.Configurator; + +/** + * Created by xiaocong@gmail.com on 12/26/13. + */ +public class ConfiguratorInfo { + + public ConfiguratorInfo() { + Configurator config = Configurator.getInstance(); + this._actionAcknowledgmentTimeout = config.getActionAcknowledgmentTimeout(); + this._keyInjectionDelay = config.getKeyInjectionDelay(); + this._scrollAcknowledgmentTimeout = config.getScrollAcknowledgmentTimeout(); + this._waitForIdleTimeout = config.getWaitForIdleTimeout(); + this._waitForSelectorTimeout = config.getWaitForSelectorTimeout(); + } + + public long getActionAcknowledgmentTimeout() { + return _actionAcknowledgmentTimeout; + } + + public void setActionAcknowledgmentTimeout(long _actionAcknowledgmentTimeout) { + this._actionAcknowledgmentTimeout = _actionAcknowledgmentTimeout; + } + + public long getKeyInjectionDelay() { + return _keyInjectionDelay; + } + + public void setKeyInjectionDelay(long _keyInjectionDelay) { + this._keyInjectionDelay = _keyInjectionDelay; + } + + public long getScrollAcknowledgmentTimeout() { + return _scrollAcknowledgmentTimeout; + } + + public void setScrollAcknowledgmentTimeout(long _scrollAcknowledgmentTimeout) { + this._scrollAcknowledgmentTimeout = _scrollAcknowledgmentTimeout; + } + + public long getWaitForIdleTimeout() { + return _waitForIdleTimeout; + } + + public void setWaitForIdleTimeout(long _waitForIdleTimeout) { + this._waitForIdleTimeout = _waitForIdleTimeout; + } + + public long getWaitForSelectorTimeout() { + return _waitForSelectorTimeout; + } + + public void setWaitForSelectorTimeout(long _waitForSelectorTimeout) { + this._waitForSelectorTimeout = _waitForSelectorTimeout; + } + + public static void setConfigurator(ConfiguratorInfo info) { + Configurator config = Configurator.getInstance(); + config.setActionAcknowledgmentTimeout(info.getActionAcknowledgmentTimeout()); + config.setKeyInjectionDelay(info.getKeyInjectionDelay()); + config.setScrollAcknowledgmentTimeout(info.getScrollAcknowledgmentTimeout()); + config.setWaitForIdleTimeout(info.getWaitForIdleTimeout()); + config.setWaitForSelectorTimeout(info.getWaitForSelectorTimeout()); + } + + private long _actionAcknowledgmentTimeout; + private long _keyInjectionDelay; + private long _scrollAcknowledgmentTimeout; + private long _waitForIdleTimeout; + private long _waitForSelectorTimeout; +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/DeviceInfo.java b/app/src/androidTest/java/com/tikfarm/stub/DeviceInfo.java new file mode 100644 index 0000000..b55feb1 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/DeviceInfo.java @@ -0,0 +1,156 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import android.os.RemoteException; +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.UiDevice; + +public class DeviceInfo { + private String _currentPackageName; + private String _currentActivityName; + private int _displayWidth; + private int _displayHeight; + private int _displayRotation; + private int _displaySizeDpX; + private int _displaySizeDpY; + private String _productName; + private boolean _naturalOrientation; + private boolean _screenOn; + + private int _sdkInt; + + public static DeviceInfo getDeviceInfo() { + return new DeviceInfo(); + } + + private DeviceInfo() { + this._sdkInt = android.os.Build.VERSION.SDK_INT; + + UiDevice ud = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); + this._currentActivityName = ud.getCurrentActivityName(); + this._currentPackageName = ud.getCurrentPackageName(); + this._displayWidth = ud.getDisplayWidth(); + this._displayHeight = ud.getDisplayHeight(); + this._displayRotation = ud.getDisplayRotation(); + this._productName = ud.getProductName(); + this._naturalOrientation = ud.isNaturalOrientation(); + this._displaySizeDpX = ud.getDisplaySizeDp().x; + this._displaySizeDpY = ud.getDisplaySizeDp().y; + try { + this._screenOn = ud.isScreenOn(); + } catch (RemoteException e) { + e.printStackTrace(); + Log.e(e.getMessage()); + } + } + + public String getCurrentPackageName() { + return _currentPackageName; + } + + public void setCurrentPackageName(String currentPackageName) { + this._currentPackageName = currentPackageName; + } + + public int getDisplayWidth() { + return _displayWidth; + } + + public void setDisplayWidth(int displayWidth) { + this._displayWidth = displayWidth; + } + + public int getDisplayHeight() { + return _displayHeight; + } + + public void setDisplayHeight(int displayHeight) { + this._displayHeight = displayHeight; + } + + public int getDisplayRotation() { + return _displayRotation; + } + + public void setDisplayRotation(int displayRotation) { + this._displayRotation = displayRotation; + } + + public int getDisplaySizeDpX() { + return _displaySizeDpX; + } + + public void setDisplaySizeDpX(int displaySizeDpX) { + this._displaySizeDpX = displaySizeDpX; + } + + public int getDisplaySizeDpY() { + return _displaySizeDpY; + } + + public void setDisplaySizeDpY(int displaySizeDpY) { + this._displaySizeDpY = displaySizeDpY; + } + + public String getProductName() { + return _productName; + } + + public void setProductName(String productName) { + this._productName = productName; + } + + public boolean isNaturalOrientation() { + return _naturalOrientation; + } + + public void setNaturalOrientation(boolean naturalOrientation) { + this._naturalOrientation = naturalOrientation; + } + + public int getSdkInt() { + return _sdkInt; + } + + public void setSdkInt(int sdkInt) { + this._sdkInt = sdkInt; + } + + public boolean getScreenOn() { + return _screenOn; + } + + public void setScreenOn(boolean screenOn) { + this._screenOn = screenOn; + } + + public String getCurrentActivityName() { + return this._currentActivityName; + } + + public void setCurrentActivityName(String currentActivityName) { + this._currentActivityName = currentActivityName; + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/Helper.java b/app/src/androidTest/java/com/tikfarm/stub/Helper.java new file mode 100644 index 0000000..fb296b4 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/Helper.java @@ -0,0 +1,39 @@ +package com.github.tikmatrix.stub; + +import android.app.ActivityManager; +import android.content.Context; + +import java.util.List; + +/** + * Created by hzsunshx on 2017/9/5. + */ + +public class Helper { + public static boolean isAppRunning(final Context context, final String packageName) { + final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + final List procInfos = activityManager.getRunningAppProcesses(); + if (procInfos != null) { + for (final ActivityManager.RunningAppProcessInfo processInfo : procInfos) { + System.out.println("app:" + processInfo.processName); + if (processInfo.processName.equals(packageName)) { + return true; + } + } + } + return false; + } + + public static boolean isServiceRunning(final Context context, String serviceClassName) { + final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + final List services = activityManager.getRunningServices(Integer.MAX_VALUE); + + for (ActivityManager.RunningServiceInfo runningServiceInfo : services) { + System.out.println("service:" + runningServiceInfo.service.getClassName()); + if (runningServiceInfo.service.getClassName().equals(serviceClassName)) { + return true; + } + } + return false; + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/Log.java b/app/src/androidTest/java/com/tikfarm/stub/Log.java new file mode 100644 index 0000000..c984d6e --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/Log.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +public class Log { + public static final String TAG = "UIAutomatorStub"; + + public static void d(String msg) { + android.util.Log.d(TAG, msg); + } + + public static void i(String msg) { + android.util.Log.i(TAG, msg); + } + + public static void e(String msg) { + android.util.Log.e(TAG, msg); + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/NotImplementedException.java b/app/src/androidTest/java/com/tikfarm/stub/NotImplementedException.java new file mode 100644 index 0000000..7aa1498 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/NotImplementedException.java @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import android.os.Build; + +/** + * Created with IntelliJ IDEA. + * User: xiaocong@gmail.com + * Date: 8/13/13 + * Time: 10:45 AM + * To change this template use File | Settings | File Templates. + */ +public class NotImplementedException extends Exception { + public NotImplementedException() { + super("This method is not yet implemented in API level " + Build.VERSION.SDK_INT + "."); + } + + public NotImplementedException(String method) { + super(method + " is not yet implemented in API level " + Build.VERSION.SDK_INT + "."); + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/ObjInfo.java b/app/src/androidTest/java/com/tikfarm/stub/ObjInfo.java new file mode 100644 index 0000000..67dca95 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/ObjInfo.java @@ -0,0 +1,239 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiObject; +import androidx.test.uiautomator.UiObject2; +import androidx.test.uiautomator.UiObjectNotFoundException; +import androidx.test.uiautomator.UiSelector; + +public class ObjInfo { + + public static final ObjInfo getObjInfo(UiObject obj) throws UiObjectNotFoundException { + return new ObjInfo(obj); + } + + public static final ObjInfo getObjInfo(UiSelector selector) throws UiObjectNotFoundException { + return new ObjInfo(UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).findObject(selector)); + } + + public static final ObjInfo getObjInfo(UiObject2 obj) { + return new ObjInfo(obj); + } + + private ObjInfo(UiObject obj) throws UiObjectNotFoundException { + this._bounds = Rect.from(obj.getBounds()); + this._checkable = obj.isCheckable(); + this._checked = obj.isChecked(); + this._childCount = obj.getChildCount(); + this._clickable = obj.isClickable(); + this._contentDescription = obj.getContentDescription(); + this._enabled = obj.isEnabled(); + this._focusable = obj.isFocusable(); + this._focused = obj.isFocused(); + this._longClickable = obj.isLongClickable(); + this._packageName = obj.getPackageName(); + this._scrollable = obj.isScrollable(); + this._selected = obj.isSelected(); + this._text = obj.getText(); + this._visibleBounds = Rect.from(obj.getVisibleBounds()); + this._className = obj.getClassName(); + } + + private ObjInfo(UiObject2 obj) { + this._bounds = Rect.from(obj.getVisibleBounds()); + this._checkable = obj.isCheckable(); + this._checked = obj.isChecked(); + this._childCount = obj.getChildCount(); + this._clickable = obj.isClickable(); + this._contentDescription = obj.getContentDescription(); + this._enabled = obj.isEnabled(); + this._focusable = obj.isFocusable(); + this._focused = obj.isFocused(); + this._longClickable = obj.isLongClickable(); + this._packageName = obj.getApplicationPackage(); + this._scrollable = obj.isScrollable(); + this._selected = obj.isSelected(); + this._text = obj.getText(); + this._visibleBounds = Rect.from(obj.getVisibleBounds()); + this._className = obj.getClassName(); + this._resourceName = obj.getResourceName(); + } + + private Rect _bounds; + private Rect _visibleBounds; + private int _childCount; + private String _className; + private String _contentDescription; + private String _packageName; + private String _text; + private boolean _checkable; + private boolean _checked; + private boolean _clickable; + private boolean _enabled; + private boolean _focusable; + private boolean _focused; + private boolean _longClickable; + private boolean _scrollable; + private boolean _selected; + private String _resourceName; + + public Rect getBounds() { + return _bounds; + } + + public void setBounds(Rect bounds) { + this._bounds = bounds; + } + + public Rect getVisibleBounds() { + return _visibleBounds; + } + + public void setVisibleBounds(Rect visibleBounds) { + this._visibleBounds = visibleBounds; + } + + public int getChildCount() { + return _childCount; + } + + public void setChildCount(int childCount) { + this._childCount = childCount; + } + + public String getClassName() { + return _className; + } + + public void setClassName(String className) { + this._className = className; + } + + public String getContentDescription() { + return _contentDescription; + } + + public void setContentDescription(String contentDescription) { + this._contentDescription = contentDescription; + } + + public String getPackageName() { + return _packageName; + } + + public void setPackageName(String packageName) { + this._packageName = packageName; + } + + public String getText() { + return _text; + } + + public void setText(String text) { + this._text = text; + } + + public boolean isCheckable() { + return _checkable; + } + + public void setCheckable(boolean checkable) { + this._checkable = checkable; + } + + public boolean isChecked() { + return _checked; + } + + public void setChecked(boolean checked) { + this._checked = checked; + } + + public boolean isClickable() { + return _clickable; + } + + public void setClickable(boolean clickable) { + this._clickable = clickable; + } + + public boolean isEnabled() { + return _enabled; + } + + public void setEnabled(boolean enabled) { + this._enabled = enabled; + } + + public boolean isFocusable() { + return _focusable; + } + + public void setFocusable(boolean focusable) { + this._focusable = focusable; + } + + public boolean isFocused() { + return _focused; + } + + public void setFocused(boolean focused) { + this._focused = focused; + } + + public boolean isLongClickable() { + return _longClickable; + } + + public void setLongClickable(boolean longClickable) { + this._longClickable = longClickable; + } + + public boolean isScrollable() { + return _scrollable; + } + + public void setScrollable(boolean scrollable) { + this._scrollable = scrollable; + } + + public boolean isSelected() { + return _selected; + } + + public void setSelected(boolean selected) { + this._selected = selected; + } + + public String getResourceName() { + return _resourceName; + } + + public void setResourceName(String resourceName) { + this._resourceName = resourceName; + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/Point.java b/app/src/androidTest/java/com/tikfarm/stub/Point.java new file mode 100644 index 0000000..6ebc668 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/Point.java @@ -0,0 +1,56 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +/** + * Created with IntelliJ IDEA. + * User: xiaocong@gmail.com + * Date: 8/13/13 + * Time: 10:11 AM + * To change this template use File | Settings | File Templates. + */ +public class Point { + private int _x; + private int _y; + + public int getX() { + return _x; + } + + public void setX(int x) { + this._x = x; + } + + public int getY() { + return _y; + } + + public void setY(int y) { + this._y = y; + } + + public android.graphics.Point toPoint() { + return new android.graphics.Point(_x, _y); + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/Rect.java b/app/src/androidTest/java/com/tikfarm/stub/Rect.java new file mode 100644 index 0000000..67814be --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/Rect.java @@ -0,0 +1,84 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +/** + * Created with IntelliJ IDEA. + * User: xiaocong@gmail.com + * Date: 8/13/13 + * Time: 10:13 AM + * To change this template use File | Settings | File Templates. + */ +public class Rect { + private int _top; + private int _bottom; + private int _left; + private int _right; + + public static Rect from(android.graphics.Rect r) { + Rect rect = new Rect(); + rect._top = r.top; + rect._bottom = r.bottom; + rect._left = r.left; + rect._right = r.right; + + return rect; + } + + public int getTop() { + return _top; + } + + public void setTop(int top) { + this._top = top; + } + + public int getBottom() { + return _bottom; + } + + public void setBottom(int bottom) { + this._bottom = bottom; + } + + public int getLeft() { + return _left; + } + + public void setLeft(int left) { + this._left = left; + } + + public int getRight() { + return _right; + } + + public void setRight(int right) { + this._right = right; + } + + public android.graphics.Rect toRect() { + return new android.graphics.Rect(_left, _top, _right, _bottom); + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/Selector.java b/app/src/androidTest/java/com/tikfarm/stub/Selector.java new file mode 100644 index 0000000..a6876fa --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/Selector.java @@ -0,0 +1,563 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.By; +import androidx.test.uiautomator.BySelector; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiObject2; +import androidx.test.uiautomator.UiSelector; + +import java.util.regex.Pattern; + +public class Selector { + private String _text; + private String _textContains; + private String _textMatches; + private String _textStartsWith; + private String _className; + private String _classNameMatches; + private String _description; + private String _descriptionContains; + private String _descriptionMatches; + private String _descriptionStartsWith; + private boolean _checkable; + private boolean _checked; + private boolean _clickable; + private boolean _longClickable; + private boolean _scrollable; + private boolean _enabled; + private boolean _focusable; + private boolean _focused; + private boolean _selected; + private String _packageName; + private String _packageNameMatches; + private String _resourceId; + private String _resourceIdMatches; + private int _index; + private int _instance; + private Selector[] _childOrSiblingSelector = new Selector[] {}; + private String[] _childOrSibling = new String[] {}; + + private long _mask; + + public static final long MASK_TEXT = 0x01; + public static final long MASK_TEXTCONTAINS = 0x02; + public static final long MASK_TEXTMATCHES = 0x04; + public static final long MASK_TEXTSTARTSWITH = 0x08; + public static final long MASK_CLASSNAME = 0x10; + public static final long MASK_CLASSNAMEMATCHES = 0x20; + public static final long MASK_DESCRIPTION = 0x40; + public static final long MASK_DESCRIPTIONCONTAINS = 0x80; + public static final long MASK_DESCRIPTIONMATCHES = 0x0100; + public static final long MASK_DESCRIPTIONSTARTSWITH = 0x0200; + public static final long MASK_CHECKABLE = 0x0400; + public static final long MASK_CHECKED = 0x0800; + public static final long MASK_CLICKABLE = 0x1000; + public static final long MASK_LONGCLICKABLE = 0x2000; + public static final long MASK_SCROLLABLE = 0x4000; + public static final long MASK_ENABLED = 0x8000; + public static final long MASK_FOCUSABLE = 0x010000; + public static final long MASK_FOCUSED = 0x020000; + public static final long MASK_SELECTED = 0x040000; + public static final long MASK_PACKAGENAME = 0x080000; + public static final long MASK_PACKAGENAMEMATCHES = 0x100000; + public static final long MASK_RESOURCEID = 0x200000; + public static final long MASK_RESOURCEIDMATCHES = 0x400000; + public static final long MASK_INDEX = 0x800000; + public static final long MASK_INSTANCE = 0x01000000; + + private UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); + + public UiSelector toUiSelector() { + UiSelector s = new UiSelector(); + if ((getMask() & Selector.MASK_CHECKABLE) > 0 && android.os.Build.VERSION.SDK_INT >= 18) + s = s.checkable(this.isCheckable()); + if ((getMask() & Selector.MASK_CHECKED) > 0) + s = s.checked(isChecked()); + if ((getMask() & Selector.MASK_CLASSNAME) > 0) + s = s.className(getClassName()); // API level 16 should support it.... wrong in Android Java Doc + if ((getMask() & Selector.MASK_CLASSNAMEMATCHES) > 0 && android.os.Build.VERSION.SDK_INT >= 17) + s = s.classNameMatches(getClassNameMatches()); + if ((getMask() & Selector.MASK_CLICKABLE) > 0) + s = s.clickable(isClickable()); + if ((getMask() & Selector.MASK_DESCRIPTION) > 0) + s = s.description(getDescription()); + if ((getMask() & Selector.MASK_DESCRIPTIONCONTAINS) > 0) + s = s.descriptionContains(getDescriptionContains()); + if ((getMask() & Selector.MASK_DESCRIPTIONMATCHES) > 0 && android.os.Build.VERSION.SDK_INT >= 17) + s = s.descriptionMatches(getDescriptionMatches()); + if ((getMask() & Selector.MASK_DESCRIPTIONSTARTSWITH) > 0) + s = s.descriptionStartsWith(getDescriptionStartsWith()); + if ((getMask() & Selector.MASK_ENABLED) > 0) + s = s.enabled(isEnabled()); + if ((getMask() & Selector.MASK_FOCUSABLE) > 0) + s = s.focusable(isFocusable()); + if ((getMask() & Selector.MASK_FOCUSED) > 0) + s = s.focused(isFocused()); + if ((getMask() & Selector.MASK_INDEX) > 0) + s = s.index(getIndex()); + if ((getMask() & Selector.MASK_INSTANCE) > 0) + s = s.instance(getInstance()); + if ((getMask() & Selector.MASK_LONGCLICKABLE) > 0 && android.os.Build.VERSION.SDK_INT >= 17) + s = s.longClickable(isLongClickable()); + if ((getMask() & Selector.MASK_PACKAGENAME) > 0) + s = s.packageName(getPackageName()); + if ((getMask() & Selector.MASK_PACKAGENAMEMATCHES) > 0 && android.os.Build.VERSION.SDK_INT >= 17) + s = s.packageNameMatches(getPackageNameMatches()); + if ((getMask() & Selector.MASK_RESOURCEID) > 0 && android.os.Build.VERSION.SDK_INT >= 18) + s = s.resourceId(getResourceId()); + if ((getMask() & Selector.MASK_RESOURCEIDMATCHES) > 0 && android.os.Build.VERSION.SDK_INT >= 18) + s = s.resourceIdMatches(getResourceIdMatches()); + if ((getMask() & Selector.MASK_SCROLLABLE) > 0) + s = s.scrollable(isScrollable()); + if ((getMask() & Selector.MASK_SELECTED) > 0) + s = s.selected(isSelected()); + if ((getMask() & Selector.MASK_TEXT) > 0) + s = s.text(getText()); + if ((getMask() & Selector.MASK_TEXTCONTAINS) > 0) + s = s.textContains(getTextContains()); + if ((getMask() & Selector.MASK_TEXTSTARTSWITH) > 0) + s = s.textStartsWith(getTextStartsWith()); + if ((getMask() & Selector.MASK_TEXTMATCHES) > 0 && android.os.Build.VERSION.SDK_INT >= 17) + s = s.textMatches(getTextMatches()); + + for (int i = 0; i < this.getChildOrSibling().length && i < this.getChildOrSiblingSelector().length; i++) { + if (this.getChildOrSibling()[i].toLowerCase().equals("child")) + s = s.childSelector(getChildOrSiblingSelector()[i].toUiSelector()); + else if (this.getChildOrSibling()[i].toLowerCase().equals("sibling")) + s = s.fromParent((getChildOrSiblingSelector()[i].toUiSelector())); + } + + return s; + } + + public BySelector toBySelector() { + BySelector s = null; + if ((getMask() & Selector.MASK_CHECKABLE) > 0 && android.os.Build.VERSION.SDK_INT >= 18) + s = By.checkable(this.isCheckable()); + if ((getMask() & Selector.MASK_CHECKED) > 0) { + if (s == null) + s = By.checked(isChecked()); + else + s = s.checkable(isChecked()); + } + if ((getMask() & Selector.MASK_CLASSNAME) > 0) { + if (s == null) + s = By.clazz(getClassName()); + else + s = s.clazz(getClassName()); + } + if ((getMask() & Selector.MASK_CLASSNAMEMATCHES) > 0) { + if (s == null) + s = By.clazz(Pattern.compile(getClassNameMatches())); + else + s = s.clazz(Pattern.compile(getClassNameMatches())); + } + if ((getMask() & Selector.MASK_CLICKABLE) > 0) { + if (s == null) + s = By.clickable(isClickable()); + else + s = s.clickable(isClickable()); + } + if ((getMask() & Selector.MASK_DESCRIPTION) > 0) { + if (s == null) + s = By.desc(getDescription()); + else + s = s.desc(getDescription()); + } + if ((getMask() & Selector.MASK_DESCRIPTIONCONTAINS) > 0) { + if (s == null) + s = By.descContains(getDescriptionContains()); + else + s = s.descContains(getDescriptionContains()); + } + if ((getMask() & Selector.MASK_DESCRIPTIONMATCHES) > 0) { + if (s == null) + s = By.desc(Pattern.compile(getDescriptionMatches())); + else + s = s.desc(Pattern.compile(getDescriptionMatches())); + } + if ((getMask() & Selector.MASK_DESCRIPTIONSTARTSWITH) > 0) { + if (s == null) + s = By.descStartsWith(getDescriptionStartsWith()); + else + s = s.descStartsWith(getDescriptionStartsWith()); + } + if ((getMask() & Selector.MASK_ENABLED) > 0) { + if (s == null) + s = By.enabled(isEnabled()); + else + s = s.enabled(isEnabled()); + } + if ((getMask() & Selector.MASK_FOCUSABLE) > 0) { + if (s == null) + s = By.focusable(isFocusable()); + else + s = s.focusable(isFocusable()); + } + if ((getMask() & Selector.MASK_FOCUSED) > 0) { + if (s == null) + s = By.focused(isFocused()); + else + s = s.focused(isFocused()); + } + if ((getMask() & Selector.MASK_LONGCLICKABLE) > 0) { + if (s == null) + s = By.longClickable(isLongClickable()); + else + s = s.longClickable(isLongClickable()); + } + if ((getMask() & Selector.MASK_PACKAGENAME) > 0) { + if (s == null) + s = By.pkg(getPackageName()); + else + s = s.pkg(getPackageName()); + } + if ((getMask() & Selector.MASK_PACKAGENAMEMATCHES) > 0) { + if (s == null) + s = By.pkg(Pattern.compile(getPackageNameMatches())); + else + s = s.pkg(Pattern.compile(getPackageNameMatches())); + } + if ((getMask() & Selector.MASK_RESOURCEID) > 0) { + if (s == null) + s = By.res(getResourceId()); + else + s = s.res(getResourceId()); + } + if ((getMask() & Selector.MASK_RESOURCEIDMATCHES) > 0) { + if (s == null) + s = By.res(Pattern.compile(getResourceIdMatches())); + else + s = s.res(Pattern.compile(getResourceIdMatches())); + } + if ((getMask() & Selector.MASK_SCROLLABLE) > 0) { + if (s == null) + s = By.scrollable(isScrollable()); + else + s = s.scrollable(isScrollable()); + } + if ((getMask() & Selector.MASK_SELECTED) > 0) { + if (s == null) + s = By.selected(isSelected()); + else + s = s.selected(isSelected()); + } + if ((getMask() & Selector.MASK_TEXT) > 0) { + if (s == null) + s = By.text(getText()); + else + s = s.text(getText()); + } + if ((getMask() & Selector.MASK_TEXTCONTAINS) > 0) { + if (s == null) + s = By.textContains(getTextContains()); + else + s = s.textContains(getTextContains()); + } + if ((getMask() & Selector.MASK_TEXTSTARTSWITH) > 0) { + if (s == null) + s = By.textStartsWith(getTextStartsWith()); + else + s = s.textStartsWith(getTextStartsWith()); + } + if ((getMask() & Selector.MASK_TEXTMATCHES) > 0) { + if (s == null) + s = By.text(Pattern.compile(getTextMatches())); + else + s = s.text(Pattern.compile(getTextMatches())); + } + + return s; + } + + public boolean checkBySelectorNull(Selector s) { + if ((s.getMask() & Selector.MASK_INDEX) > 0 || (s.getMask() & Selector.MASK_INSTANCE) > 0) { + return true; + } + if (s.toBySelector() == null) { + return true; + } + return false; + } + + public UiObject2 toUiObject2() { + if (checkBySelectorNull(this)) + return null; + + UiObject2 obj2 = device.findObject(toBySelector()); + if (this.getChildOrSibling().length > 0) { + return null; + } + return obj2; + } + + public Selector deepSelector() { + if (this.getChildOrSibling().length == 0) { + return this; + } + return this.getChildOrSiblingSelector()[this.getChildOrSiblingSelector().length - 1]; + } + + public UiSelector toUiSelector(int instance) { + Selector sel = this.deepSelector(); + // remember last value + int oldInstance = sel.getInstance(); + long oldMask = sel.getMask(); + + sel.setMask(sel.getMask() | Selector.MASK_INSTANCE); + sel.setInstance(instance); + UiSelector uiSelector = this.toUiSelector(); + // recover last value + sel.setInstance(oldInstance); + sel.setMask(oldMask); + return uiSelector; + } + + public String getText() { + return _text; + } + + public void setText(String text) { + this._text = text; + } + + public String getClassName() { + return _className; + } + + public void setClassName(String className) { + this._className = className; + } + + public String getDescription() { + return _description; + } + + public void setDescription(String description) { + this._description = description; + } + + public String getTextContains() { + return _textContains; + } + + public void setTextContains(String _textContains) { + this._textContains = _textContains; + } + + public String getTextMatches() { + return _textMatches; + } + + public void setTextMatches(String _textMatches) { + this._textMatches = _textMatches; + } + + public String getTextStartsWith() { + return _textStartsWith; + } + + public void setTextStartsWith(String _textStartsWith) { + this._textStartsWith = _textStartsWith; + } + + public String getClassNameMatches() { + return _classNameMatches; + } + + public void setClassNameMatches(String _classNameMatches) { + this._classNameMatches = _classNameMatches; + } + + public String getDescriptionContains() { + return _descriptionContains; + } + + public void setDescriptionContains(String _descriptionContains) { + this._descriptionContains = _descriptionContains; + } + + public String getDescriptionMatches() { + return _descriptionMatches; + } + + public void setDescriptionMatches(String _descriptionMatches) { + this._descriptionMatches = _descriptionMatches; + } + + public String getDescriptionStartsWith() { + return _descriptionStartsWith; + } + + public void setDescriptionStartsWith(String _descriptionStartsWith) { + this._descriptionStartsWith = _descriptionStartsWith; + } + + public boolean isCheckable() { + return _checkable; + } + + public void setCheckable(boolean _checkable) { + this._checkable = _checkable; + } + + public boolean isChecked() { + return _checked; + } + + public void setChecked(boolean _checked) { + this._checked = _checked; + } + + public boolean isClickable() { + return _clickable; + } + + public void setClickable(boolean _clickable) { + this._clickable = _clickable; + } + + public boolean isScrollable() { + return _scrollable; + } + + public void setScrollable(boolean _scrollable) { + this._scrollable = _scrollable; + } + + public boolean isLongClickable() { + return _longClickable; + } + + public void setLongClickable(boolean _longClickable) { + this._longClickable = _longClickable; + } + + public boolean isEnabled() { + return _enabled; + } + + public void setEnabled(boolean _enabled) { + this._enabled = _enabled; + } + + public boolean isFocusable() { + return _focusable; + } + + public void setFocusable(boolean _focusable) { + this._focusable = _focusable; + } + + public boolean isFocused() { + return _focused; + } + + public void setFocused(boolean _focused) { + this._focused = _focused; + } + + public boolean isSelected() { + return _selected; + } + + public void setSelected(boolean _selected) { + this._selected = _selected; + } + + public String getPackageName() { + return _packageName; + } + + public void setPackageName(String _packageName) { + this._packageName = _packageName; + } + + public String getPackageNameMatches() { + return _packageNameMatches; + } + + public void setPackageNameMatches(String _packageNameMatches) { + this._packageNameMatches = _packageNameMatches; + } + + public String getResourceId() { + return _resourceId; + } + + public void setResourceId(String _resourceId) { + this._resourceId = _resourceId; + } + + public String getResourceIdMatches() { + return _resourceIdMatches; + } + + public void setResourceIdMatches(String _resourceIdMatches) { + this._resourceIdMatches = _resourceIdMatches; + } + + public int getIndex() { + return _index; + } + + public void setIndex(int _index) { + this._index = _index; + } + + public int getInstance() { + return _instance; + } + + public void setInstance(int _instance) { + this._instance = _instance; + } + + public long getMask() { + return _mask; + } + + public void setMask(long _mask) { + this._mask = _mask; + } + + public Selector[] getChildOrSiblingSelector() { + return _childOrSiblingSelector; + } + + public void setChildOrSiblingSelector(Selector[] _childOrSiblingSelector) { + this._childOrSiblingSelector = _childOrSiblingSelector; + } + + public String[] getChildOrSibling() { + return _childOrSibling; + } + + public void setChildOrSibling(String[] _childOrSibling) { + this._childOrSibling = _childOrSibling; + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/Stub.java b/app/src/androidTest/java/com/tikfarm/stub/Stub.java new file mode 100644 index 0000000..0ed56d2 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/Stub.java @@ -0,0 +1,102 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com, 2018 codeskyblue@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub; + +import android.content.Context; +import android.content.Intent; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.filters.SdkSuppress; +import androidx.test.runner.AndroidJUnit4; +import androidx.test.uiautomator.UiObjectNotFoundException; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.googlecode.jsonrpc4j.ErrorResolver; +import com.googlecode.jsonrpc4j.JsonRpcServer; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Method; +import java.util.List; + +/** + * Use JUnit test to start the uiautomator jsonrpc server. + * + * @author xiaocong@gmail.com + */ +@RunWith(AndroidJUnit4.class) +@SdkSuppress(minSdkVersion = 18) +public class Stub { + // http://www.jsonrpc.org/specification#error_object + private static final int CUSTOM_ERROR_CODE = -32001; + + int PORT = 9008; + AutomatorHttpServer server = new AutomatorHttpServer(PORT); + + @Before + public void setUp() throws Exception { + Log.i("Launch Stub Server"); + AutomatorService automatorService = new AutomatorServiceImpl(); + JsonRpcServer jrs = new JsonRpcServer(new ObjectMapper(), automatorService, AutomatorService.class); + jrs.setShouldLogInvocationErrors(true); + jrs.setErrorResolver(new ErrorResolver() { + @Override + public JsonError resolveError(Throwable throwable, Method method, List list) { + String data = throwable.getMessage(); + if (!throwable.getClass().equals(UiObjectNotFoundException.class)) { + throwable.printStackTrace(); + StringWriter sw = new StringWriter(); + throwable.printStackTrace(new PrintWriter(sw)); + data = sw.toString(); + } + return new JsonError(CUSTOM_ERROR_CODE, throwable.getClass().getName(), data); + } + }); + server.route("/jsonrpc/0", jrs); + server.setAutomatorService(automatorService); + server.start(); + } + + @After + public void tearDown() { + server.stop(); + } + + @Test + @LargeTest + public void testUIAutomatorStub() throws InterruptedException { + Context context = InstrumentationRegistry.getInstrumentation().getContext(); + while (server.isAlive()) { + context.sendBroadcast(new Intent("com.github.tikmatrix.stub.STUB_RUNNING")); + Thread.sleep(1000); + } + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/tikfarm/stub/TouchController.java b/app/src/androidTest/java/com/tikfarm/stub/TouchController.java new file mode 100644 index 0000000..5fe5fe4 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/TouchController.java @@ -0,0 +1,179 @@ +package com.github.tikmatrix.stub; + +import android.app.Instrumentation; +import android.app.Service; +import android.app.UiAutomation; +import android.content.Context; +import android.os.PowerManager; +import android.os.SystemClock; +import androidx.test.uiautomator.Configurator; +import androidx.test.uiautomator.UiDevice; +import android.util.Log; +import android.view.InputDevice; +import android.view.InputEvent; +import android.view.KeyCharacterMap; +import android.view.MotionEvent; + +public class TouchController { + private static final String LOG_TAG = TouchController.class.getSimpleName(); + private static final boolean DEBUG = Log.isLoggable(LOG_TAG, Log.DEBUG); + private static final int MOTION_EVENT_INJECTION_DELAY_MILLIS = 5; + + private final KeyCharacterMap mKeyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); + + private long mDownTime; + private final Instrumentation mInstrumentation; + + public TouchController(Instrumentation instrumentation) { + mInstrumentation = instrumentation; + } + + public boolean isScreenOn() { + PowerManager pm = (PowerManager) getContext().getSystemService(Service.POWER_SERVICE); + return pm.isScreenOn(); + } + + private boolean injectEventSync(InputEvent event) { + return getUiAutomation().injectInputEvent(event, true); + } + + public boolean touchDown(float x, float y) { + if (DEBUG) { + android.util.Log.d(LOG_TAG, "touchDown (" + x + ", " + y + ")"); + } + mDownTime = SystemClock.uptimeMillis(); + MotionEvent event = getMotionEvent(mDownTime, mDownTime, MotionEvent.ACTION_DOWN, x, y); + return injectEventSync(event); + } + + public boolean touchUp(float x, float y) { + if (DEBUG) { + android.util.Log.d(LOG_TAG, "touchUp (" + x + ", " + y + ")"); + } + final long eventTime = SystemClock.uptimeMillis(); + MotionEvent event = getMotionEvent(mDownTime, eventTime, MotionEvent.ACTION_UP, x, y); + mDownTime = 0; + return injectEventSync(event); + } + + public boolean touchMove(float x, float y) { + if (DEBUG) { + Log.d(LOG_TAG, "touchMove (" + x + ", " + y + ")"); + } + final long eventTime = SystemClock.uptimeMillis(); + MotionEvent event = getMotionEvent(mDownTime, eventTime, MotionEvent.ACTION_MOVE, x, y); + return injectEventSync(event); + } + + private static MotionEvent getMotionEvent(long downTime, long eventTime, int action, + float x, float y) { + + MotionEvent.PointerProperties properties = new MotionEvent.PointerProperties(); + properties.id = 0; + properties.toolType = Configurator.getInstance().getToolType(); + + MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords(); + coords.pressure = 1; + coords.size = 1; + coords.x = x; + coords.y = y; + + MotionEvent event = MotionEvent.obtain(downTime, eventTime, action, 1, + new MotionEvent.PointerProperties[] { properties }, new MotionEvent.PointerCoords[] { coords }, + 0, 0, 1.0f, 1.0f, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); + return event; + } + + public boolean performMultiPointerGesture(MotionEvent.PointerCoords[]... touches) { + boolean ret = true; + if (touches.length < 2) { + throw new IllegalArgumentException("Must provide coordinates for at least 2 pointers"); + } + + // Get the pointer with the max steps to inject. + int maxSteps = 0; + for (int x = 0; x < touches.length; x++) + maxSteps = (maxSteps < touches[x].length) ? touches[x].length : maxSteps; + + // specify the properties for each pointer as finger touch + MotionEvent.PointerProperties[] properties = new MotionEvent.PointerProperties[touches.length]; + MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[touches.length]; + for (int x = 0; x < touches.length; x++) { + MotionEvent.PointerProperties prop = new MotionEvent.PointerProperties(); + prop.id = x; + prop.toolType = Configurator.getInstance().getToolType(); + properties[x] = prop; + + // for each pointer set the first coordinates for touch down + pointerCoords[x] = touches[x][0]; + } + + // Touch down all pointers + long downTime = SystemClock.uptimeMillis(); + MotionEvent event; + event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 1, + properties, pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); + ret &= injectEventSync(event); + + for (int x = 1; x < touches.length; x++) { + event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), + getPointerAction(MotionEvent.ACTION_POINTER_DOWN, x), x + 1, properties, + pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); + ret &= injectEventSync(event); + } + + // Move all pointers + for (int i = 1; i < maxSteps - 1; i++) { + // for each pointer + for (int x = 0; x < touches.length; x++) { + // check if it has coordinates to move + if (touches[x].length > i) + pointerCoords[x] = touches[x][i]; + else + pointerCoords[x] = touches[x][touches[x].length - 1]; + } + + event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), + MotionEvent.ACTION_MOVE, touches.length, properties, pointerCoords, 0, 0, 1, 1, + 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); + + ret &= injectEventSync(event); + SystemClock.sleep(MOTION_EVENT_INJECTION_DELAY_MILLIS); + } + + // For each pointer get the last coordinates + for (int x = 0; x < touches.length; x++) + pointerCoords[x] = touches[x][touches[x].length - 1]; + + // touch up + for (int x = 1; x < touches.length; x++) { + event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), + getPointerAction(MotionEvent.ACTION_POINTER_UP, x), x + 1, properties, + pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); + ret &= injectEventSync(event); + } + + Log.i(LOG_TAG, "x " + pointerCoords[0].x); + // first to touch down is last up + event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 1, + properties, pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0); + ret &= injectEventSync(event); + return ret; + } + + private int getPointerAction(int motionEnvent, int index) { + return motionEnvent + (index << MotionEvent.ACTION_POINTER_INDEX_SHIFT); + } + + UiAutomation getUiAutomation() { + return getInstrumentation().getUiAutomation(); + } + + Context getContext() { + return getInstrumentation().getContext(); + } + + Instrumentation getInstrumentation() { + return mInstrumentation; + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/watcher/ClickUiObjectWatcher.java b/app/src/androidTest/java/com/tikfarm/stub/watcher/ClickUiObjectWatcher.java new file mode 100644 index 0000000..4150f90 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/watcher/ClickUiObjectWatcher.java @@ -0,0 +1,60 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub.watcher; + +import androidx.test.InstrumentationRegistry; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiObjectNotFoundException; +import androidx.test.uiautomator.UiSelector; + +import com.github.tikmatrix.stub.Log; + +/** + * Created with IntelliJ IDEA. + * User: xiaocong@gmail.com + * Date: 8/21/13 + * Time: 4:18 PM + * To change this template use File | Settings | File Templates. + */ +public class ClickUiObjectWatcher extends SelectorWatcher { + + private UiSelector target = null; + + public ClickUiObjectWatcher(UiSelector[] conditions, UiSelector target) { + super(conditions); + this.target = target; + } + + @Override + public void action() { + Log.d("ClickUiObjectWatcher triggered!"); + if (target != null) { + try { + UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).findObject(target).click(); + } catch (UiObjectNotFoundException e) { + Log.d(e.getMessage()); + } + } + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/watcher/PressKeysWatcher.java b/app/src/androidTest/java/com/tikfarm/stub/watcher/PressKeysWatcher.java new file mode 100644 index 0000000..582d8eb --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/watcher/PressKeysWatcher.java @@ -0,0 +1,95 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub.watcher; + +import android.os.RemoteException; +import androidx.test.InstrumentationRegistry; +import android.view.KeyEvent; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiSelector; +import com.github.tikmatrix.stub.Log; + +/** + * Created with IntelliJ IDEA. + * User: xiaocong@gmail.com + * Date: 8/21/13 + * Time: 4:24 PM + * To change this template use File | Settings | File Templates. + */ +public class PressKeysWatcher extends SelectorWatcher { + private String[] keys = new String[] {}; + private UiDevice device = null; + + public PressKeysWatcher(UiSelector[] conditions, String[] keys) { + super(conditions); + this.keys = keys; + device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); + } + + @Override + public void action() { + Log.d("PressKeysWatcher triggered!"); + for (String key : keys) { + key = key.toLowerCase(); + if ("home".equals(key)) + device.pressHome(); + else if ("back".equals(key)) + device.pressBack(); + else if ("left".equals(key)) + device.pressDPadLeft(); + else if ("right".equals(key)) + device.pressDPadRight(); + else if ("up".equals(key)) + device.pressDPadUp(); + else if ("down".equals(key)) + device.pressDPadDown(); + else if ("center".equals(key)) + device.pressDPadCenter(); + else if ("menu".equals(key)) + device.pressMenu(); + else if ("search".equals(key)) + device.pressSearch(); + else if ("enter".equals(key)) + device.pressEnter(); + else if ("delete".equals(key) || "del".equals(key)) + device.pressDelete(); + else if ("recent".equals(key)) + try { + device.pressRecentApps(); + } catch (RemoteException e) { + Log.d(e.getMessage()); + } + else if ("volume_up".equals(key)) + device.pressKeyCode(KeyEvent.KEYCODE_VOLUME_UP); + else if ("volume_down".equals(key)) + device.pressKeyCode(KeyEvent.KEYCODE_VOLUME_DOWN); + else if ("volume_mute".equals(key)) + device.pressKeyCode(KeyEvent.KEYCODE_VOLUME_MUTE); + else if ("camera".equals(key)) + device.pressKeyCode(KeyEvent.KEYCODE_CAMERA); + else if ("power".equals(key)) + device.pressKeyCode(KeyEvent.KEYCODE_POWER); + } + } +} diff --git a/app/src/androidTest/java/com/tikfarm/stub/watcher/SelectorWatcher.java b/app/src/androidTest/java/com/tikfarm/stub/watcher/SelectorWatcher.java new file mode 100644 index 0000000..b177073 --- /dev/null +++ b/app/src/androidTest/java/com/tikfarm/stub/watcher/SelectorWatcher.java @@ -0,0 +1,56 @@ +/* + * The MIT License (MIT) + * Copyright (c) 2015 xiaocong@gmail.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.github.tikmatrix.stub.watcher; + +import androidx.test.uiautomator.UiObject; +import androidx.test.uiautomator.UiSelector; +import androidx.test.uiautomator.UiWatcher; + +/** + * Created with IntelliJ IDEA. + * User: xiaocong@gmail.com + * Date: 8/21/13 + * Time: 1:57 PM + * To change this template use File | Settings | File Templates. + */ +public abstract class SelectorWatcher implements UiWatcher { + private UiSelector[] conditions = null; + + public SelectorWatcher(UiSelector[] conditions) { + this.conditions = conditions; + } + + @Override + public boolean checkForCondition() { + for (UiSelector s : conditions) { + UiObject obj = new UiObject(s); + if (!obj.exists()) + return false; + } + action(); + return true; + } + + public abstract void action(); +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2d126fa --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/aidl/android/view/IRotationWatcher.aidl b/app/src/main/aidl/android/view/IRotationWatcher.aidl new file mode 100644 index 0000000..2cc5e44 --- /dev/null +++ b/app/src/main/aidl/android/view/IRotationWatcher.aidl @@ -0,0 +1,25 @@ +/* //device/java/android/android/hardware/ISensorListener.aidl +** +** Copyright 2008, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package android.view; + +/** + * {@hide} + */ +interface IRotationWatcher { + oneway void onRotationChanged(int rotation); +} diff --git a/app/src/main/java/com/github/tikmatrix/AdbBroadcastReceiver.java b/app/src/main/java/com/github/tikmatrix/AdbBroadcastReceiver.java new file mode 100644 index 0000000..c608dea --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/AdbBroadcastReceiver.java @@ -0,0 +1,59 @@ +package com.github.tikmatrix; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.location.LocationManager; +import android.util.Log; +import android.widget.Toast; + +public class AdbBroadcastReceiver extends BroadcastReceiver { + + private MockLocationProvider mockGPS; + private MockLocationProvider mockWifi; + private static final String TAG = "AdbBroadcastReceiver"; + + @Override + public void onReceive(Context context, Intent intent) { + Log.i(TAG, "received intent: " + intent.getAction()); + String action = intent.getAction(); + if (action == null) { + return; + } + switch (action) { + case "send.mock": + mockGPS = new MockLocationProvider(LocationManager.GPS_PROVIDER, context); + mockWifi = new MockLocationProvider(LocationManager.NETWORK_PROVIDER, context); + + double lat = Double + .parseDouble(intent.getStringExtra("lat") != null ? intent.getStringExtra("lat") : "0"); + double lon = Double + .parseDouble(intent.getStringExtra("lon") != null ? intent.getStringExtra("lon") : "0"); + double alt = Double + .parseDouble(intent.getStringExtra("alt") != null ? intent.getStringExtra("alt") : "0"); + float accurate = Float.parseFloat( + intent.getStringExtra("accurate") != null ? intent.getStringExtra("accurate") : "0"); + Log.i(TAG, String.format("setting mock to Latitude=%f, Longitude=%f Altitude=%f Accuracy=%f", lat, lon, + alt, accurate)); + mockGPS.pushLocation(lat, lon, alt, accurate); + mockWifi.pushLocation(lat, lon, alt, accurate); + break; + case "stop.mock": + if (mockGPS != null) { + mockGPS.shutdown(); + } + if (mockWifi != null) { + mockWifi.shutdown(); + } + break; + case "com.github.tikmatrix.ACTION.SHOW_TOAST": + String message = intent.getStringExtra("toast_text"); + int duration = intent.getIntExtra("duration", Toast.LENGTH_SHORT); + Toast.makeText(context, message, duration).show(); + break; + default: + break; + } + + } +} diff --git a/app/src/main/java/com/github/tikmatrix/FastInputIME.java b/app/src/main/java/com/github/tikmatrix/FastInputIME.java new file mode 100644 index 0000000..2448966 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/FastInputIME.java @@ -0,0 +1,341 @@ +package com.github.tikmatrix; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.inputmethodservice.InputMethodService; +import android.inputmethodservice.Keyboard; +import android.inputmethodservice.KeyboardView; +import android.os.Build; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.util.Base64; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.inputmethod.ExtractedText; +import android.view.inputmethod.ExtractedTextRequest; +import android.view.inputmethod.InputConnection; +import android.view.inputmethod.InputMethodManager; + +import java.io.UnsupportedEncodingException; +import java.net.Socket; +import java.util.Random; + +@SuppressLint({ "SetTextI18n", "UnspecifiedRegisterReceiverFlag" }) +public class FastInputIME extends InputMethodService { + private static final String TAG = "FastInputIME"; + private BroadcastReceiver mReceiver = null; + protected static final int INPUT_EDIT = 1; + Socket socketClient; + + private Handler handler = new Handler(new Handler.Callback() { + @Override + public boolean handleMessage(Message msg) { + switch (msg.what) { + case INPUT_EDIT: + String text = msg.getData().getString("text"); + setText(text); + break; + default: + break; + } + return true; + } + }); + + @Override + public View onCreateInputView() { + KeyboardView keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard, null); + + Keyboard keyboard = new Keyboard(this, R.xml.keyboard); + keyboardView.setKeyboard(keyboard); + keyboardView.setOnKeyboardActionListener(new MyKeyboardActionListener()); + + return keyboardView; + } + + @Override + public void onCreate() { + super.onCreate(); + Log.i(TAG, "Input created"); + + if (mReceiver == null) { + IntentFilter filter = new IntentFilter(); + filter.addAction("ADB_INPUT_TEXT"); + filter.addAction("ADB_INPUT_KEYCODE"); + filter.addAction("ADB_CLEAR_TEXT"); + filter.addAction("ADB_SET_TEXT"); // Equals to: Clear then Input + filter.addAction("ADB_EDITOR_CODE"); + filter.addAction("ADB_GET_CLIPBOARD"); + // TODO: filter.addAction("ADB_INPUT_CHARS"); + + // NONEED: filter.addAction(USB_STATE_CHANGE); + mReceiver = new InputMessageReceiver(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + Log.i(TAG, "registerReceiver >= 8"); + registerReceiver(mReceiver, filter, null, null, Context.RECEIVER_EXPORTED); + } else { + Log.i(TAG, "registerReceiver < 8"); + registerReceiver(mReceiver, filter); + } + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + Log.i(TAG, "Input destroyed"); + if (mReceiver != null) { + unregisterReceiver(mReceiver); + } + } + + @Override + public boolean onEvaluateFullscreenMode() { + return false; + } + + public class InputMessageReceiver extends BroadcastReceiver { + private String charSequenceToString(CharSequence input) { + return input == null ? "" : input.toString(); + } + + private String getClipboardText(Context context) { + final ClipboardManager cm = (ClipboardManager) context + .getSystemService(Context.CLIPBOARD_SERVICE); + if (cm == null) { + Log.e(TAG, "Cannot get an instance of ClipboardManager"); + return null; + } + if (!cm.hasPrimaryClip()) { + return ""; + } + final ClipData cd = cm.getPrimaryClip(); + if (cd == null || cd.getItemCount() == 0) { + return ""; + } + return charSequenceToString(cd.getItemAt(0).coerceToText(context)); + } + + @Override + public void onReceive(Context context, Intent intent) { + + String action = intent.getAction(); + Log.i(TAG, action); + String msgText; + int code; + InputConnection ic = getCurrentInputConnection(); + if (ic == null) { + return; + } + switch (action) { + case "ADB_INPUT_TEXT": + /* + * test method + * TEXT=$(echo -n "Hello World" | base64) + * adb shell am broadcast -a ADB_INPUT_TEXT --es text + * ${TEXT:-"SGVsbG8gd29ybGQ="} + */ + msgText = intent.getStringExtra("text"); + if (msgText == null) { + return; + } + Log.i(TAG, "input text(base64): " + msgText); + inputTextBase64(msgText); + break; + case "ADB_INPUT_KEYCODE": + /* + * test method + * Enter code 66 + * adb shell am broadcast -a ADB_INPUT_KEYCODE --ei code 66 + */ + code = intent.getIntExtra("code", -1); + if (code != -1) { + ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, code)); + } + break; + case "ADB_CLEAR_TEXT": + Log.i(TAG, "receive ADB_CLEAR_TEXT"); + clearText(); + break; + case "ADB_SET_TEXT": + Log.i(TAG, "receive ADB_SET_TEXT"); + msgText = intent.getStringExtra("text"); + if (msgText == null) { + msgText = ""; + } + Log.i(TAG, "input text(base64): " + msgText); + ic.beginBatchEdit(); + clearText(); + inputTextBase64(msgText); + ic.endBatchEdit(); + break; + case "ADB_EDITOR_CODE": + code = intent.getIntExtra("code", -1); + if (code != -1) { + ic.performEditorAction(code); + } + break; + case "ADB_GET_CLIPBOARD": + Log.i(TAG, "Getting current clipboard content"); + final String clipboardContent = getClipboardText(context); + if (clipboardContent == null) { + setResultCode(Activity.RESULT_CANCELED); + setResultData(""); + } else { + try { + // TODO: Use StandardCharsets.UTF_8 after the minimum supported API version + // TODO: is bumped above 18 + // noinspection CharsetObjectCanBeUsed + String clipboardContentBase64 = Base64.encodeToString( + clipboardContent.getBytes("UTF-8"), Base64.NO_WRAP); + setResultCode(Activity.RESULT_OK); + setResultData(clipboardContentBase64); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + setResultCode(Activity.RESULT_CANCELED); + setResultData(""); + } + } + break; + } + } + } + + // Refs: https://www.jianshu.com/p/892168a57fe3 + private class MyKeyboardActionListener implements KeyboardView.OnKeyboardActionListener { + + @Override + public void onPress(int i) { + } + + @Override + public void onRelease(int i) { + } + + @Override + public void onKey(int primaryCode, int[] keyCodes) { + if (primaryCode == Keyboard.KEYCODE_CANCEL) { + Log.d(TAG, "Keyboard CANCEL not implemented"); + } else if (primaryCode == -10) { + clearText(); + } else if (primaryCode == -5) { + changeInputMethod(); + // switchToLastInputMethod(); + } else if (primaryCode == -7) { + InputConnection ic = getCurrentInputConnection(); + ic.commitText(randomString(1), 0); + } else { + Log.w(TAG, "Unknown primaryCode " + primaryCode); + } + } + + @Override + + public void onText(CharSequence charSequence) { + } + + @Override + public void swipeLeft() { + } + + @Override + public void swipeRight() { + } + + @Override + public void swipeDown() { + } + + @Override + public void swipeUp() { + } + } + + private void inputTextBase64(String base64text) { + byte[] data = Base64.decode(base64text, Base64.DEFAULT); + try { + String text = new String(data, "UTF-8"); + InputConnection ic = getCurrentInputConnection(); + ic.commitText(text, 1); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + private void clearText() { + // Refs: + // https://stackoverflow.com/questions/33082004/android-custom-soft-keyboard-how-to-clear-edit-text-commited-text + InputConnection ic = getCurrentInputConnection(); + if (ic == null) { + return; + } + ExtractedText text = ic.getExtractedText(new ExtractedTextRequest(), 0); + if (text == null) { + return; + } + CharSequence currentText = ic.getExtractedText(new ExtractedTextRequest(), 0).text; + CharSequence beforCursorText = ic.getTextBeforeCursor(currentText.length(), 0); + CharSequence afterCursorText = ic.getTextAfterCursor(currentText.length(), 0); + ic.deleteSurroundingText(beforCursorText.length(), afterCursorText.length()); + } + + private String getText() { + String text = ""; + try { + InputConnection ic = getCurrentInputConnection(); + ExtractedTextRequest req = new ExtractedTextRequest(); + req.hintMaxChars = 100000; + req.hintMaxLines = 10000; + req.flags = 0; + req.token = 0; + text = ic.getExtractedText(req, 0).text.toString(); + } catch (Throwable t) { + } + return text; + } + + private void setText(String text) { + InputConnection ic = getCurrentInputConnection(); + if (ic == null) { + return; + } + ic.beginBatchEdit(); + clearText(); + ic.commitText(text, 1); + ic.endBatchEdit(); + } + + private void changeInputMethod() { + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showInputMethodPicker(); + } + + private void switchToLastInputMethod() { + final IBinder token = getWindow().getWindow().getAttributes().token; + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.switchToLastInputMethod(token); + } + + private void makeToast(String msg) { + // Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); + } + + public String randomString(int length) { + String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + Random random = new Random(); + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < length; i++) { + int num = random.nextInt(62); + buf.append(str.charAt(num)); + } + return buf.toString(); + } +} diff --git a/app/src/main/java/com/github/tikmatrix/MainActivity.java b/app/src/main/java/com/github/tikmatrix/MainActivity.java new file mode 100644 index 0000000..6567139 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/MainActivity.java @@ -0,0 +1,330 @@ +package com.github.tikmatrix; + +import android.Manifest; +import android.annotation.SuppressLint; +import android.app.NotificationManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.graphics.Color; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.provider.Settings; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.SwitchCompat; +import androidx.core.app.NotificationManagerCompat; +import androidx.core.content.FileProvider; + +import android.text.format.Formatter; +import android.util.Log; +import android.view.View; +import android.widget.TextView; + +import com.github.tikmatrix.util.MemoryManager; +import com.github.tikmatrix.util.OkhttpManager; +import com.github.tikmatrix.util.Permissons4App; + +import java.io.File; +import java.io.IOException; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.TimeZone; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Request; +import okhttp3.Response; + +@SuppressLint({ "SetTextI18n", "UnspecifiedRegisterReceiverFlag" }) +public class MainActivity extends AppCompatActivity { + public static final String TAG = "TikMatrix"; + private TextView tvInStorage; + private TextView textViewIP; + private SwitchCompat switchNotification; + private SwitchCompat switchFloatingWindow; + private TextView tvWanIp; + private TextView tvRunningStatus; + private final OkhttpManager okhttpManager = OkhttpManager.getSingleton(); + private boolean isStubRunning = false; + public static final String STUB_STATUS_ACTION = "com.github.tikmatrix.stub.STUB_RUNNING"; + private BroadcastReceiver mStubStatusReceiver; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + setTitle("TikMatrix"); + + ((TextView) findViewById(R.id.product_name)).setText(Build.MANUFACTURER + " " + Build.MODEL); + ((TextView) findViewById(R.id.android_system_version)) + .setText("Android " + Build.VERSION.RELEASE + " SDK " + Build.VERSION.SDK_INT); + ((TextView) findViewById(R.id.language)) + .setText(Locale.getDefault().getCountry() + "-" + Locale.getDefault().getLanguage()); + ((TextView) findViewById(R.id.timezone)).setText(TimeZone.getDefault().getDisplayName()); + switchNotification = findViewById(R.id.notification_permission); + switchFloatingWindow = findViewById(R.id.floating_window_permission); + switchNotification.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (isChecked) { + requestNotificationPermission(); + } else { + NotificationManager notificationManager = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + notificationManager = getSystemService(NotificationManager.class); + } + if (notificationManager != null) { + notificationManager.cancelAll(); + } + } + }); + switchFloatingWindow.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (isChecked) { + requestFloatingWindowPermission(); + } + }); + Intent intent = getIntent(); + String action = intent.getAction(); + Log.i(TAG, "action: " + action); + boolean isHide = intent.getBooleanExtra("hide", false); + if (isHide) { + Log.i(TAG, "launch args hide:true, move to background"); + moveTaskToBack(true); + } + textViewIP = findViewById(R.id.ip_address); + + tvInStorage = findViewById(R.id.in_storage); + tvWanIp = findViewById(R.id.wan_ip_address); + tvRunningStatus = findViewById(R.id.running_status); + String[] permissions = new String[0]; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) { + permissions = new String[] { + Manifest.permission.READ_MEDIA_IMAGES, + Manifest.permission.READ_MEDIA_VIDEO + }; + } else { + permissions = new String[] { + Manifest.permission.READ_EXTERNAL_STORAGE + }; + } + Permissons4App.initPermissions(this, permissions); + mStubStatusReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (STUB_STATUS_ACTION.equals(intent.getAction())) { + // Stub 正在运行 + Log.i(TAG, "stub running"); + if (isStubRunning) { + return; + } + tvRunningStatus.setText("Success"); + tvRunningStatus.setTextColor(Color.GREEN); + isStubRunning = true; + } + } + }; + IntentFilter filter = new IntentFilter(STUB_STATUS_ACTION); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + Log.i(TAG, "registerReceiver >= 8"); + registerReceiver(mStubStatusReceiver, filter, null, null, Context.RECEIVER_EXPORTED); + } else { + Log.i(TAG, "registerReceiver < 8"); + registerReceiver(mStubStatusReceiver, filter); + } + + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + Log.i(TAG, "onNewIntent: " + intent.getAction()); + if ("android.intent.action.SEND_MULTIPLE".equals(intent.getAction())) { + // get extras + String extras = intent.getStringExtra(Intent.EXTRA_STREAM); + Log.i(TAG, "extras: " + extras); + if (extras == null || extras.isEmpty()) { + return; + } + ArrayList uris = new ArrayList(); + String packagename = "com.zhiliaoapp.musically"; + for (String uriString : extras.split(",")) { + Log.i(TAG, "uriString: " + uriString); + if (uriString.startsWith("com.")) { + packagename = uriString; + continue; + } + File file = new File(uriString); + Uri uri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", + file); + Log.i(TAG, "uri: " + uri); + uris.add(uri); + } + + // send to tiktok + Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND_MULTIPLE); + sendIntent.setType("image/*"); + sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); + sendIntent.setPackage(packagename); + sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + startActivity(sendIntent); + Log.d(TAG, "onReceive: sent to " + packagename); + moveTaskToBack(true); + + } + + } + + private void requestNotificationPermission() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationManager notificationManager = getSystemService(NotificationManager.class); + if (notificationManager != null) { + notificationManager.cancelAll(); + } + Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS); + intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); + startActivity(intent); + } + } + + private void requestFloatingWindowPermission() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); + intent.setData(Uri.parse("package:" + getPackageName())); + startActivity(intent); + } + + } + + private boolean isNotificationPermissionGranted() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + return NotificationManagerCompat.from(this).areNotificationsEnabled(); + } + return true; + } + + private boolean isFloatingWindowPermissionGranted() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + return Settings.canDrawOverlays(this); + } + return true; + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, + @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + Permissons4App.handleRequestPermissionsResult(requestCode, permissions, grantResults); + } + + public void testUiautomator() { + if (isStubRunning) { + tvRunningStatus.setText("Agent is running!"); + tvRunningStatus.setTextColor(Color.GREEN); + return; + } + boolean isInstalled = Permissons4App.isAppInstalled(MainActivity.this, "com.github.tikmatrix.test"); + if (!isInstalled) { + tvRunningStatus.setText("Agent not installed!"); + tvRunningStatus.setTextColor(Color.RED); + } else { + tvRunningStatus.setText("Agent not started!"); + tvRunningStatus.setTextColor(Color.RED); + } + } + + @SuppressLint("SetTextI18n") + @Override + protected void onResume() { + super.onResume(); + switchNotification.setChecked(isNotificationPermissionGranted()); + switchFloatingWindow.setChecked(isFloatingWindowPermissionGranted()); + tvInStorage.setText(Formatter.formatFileSize(this, MemoryManager.getAvailableInternalMemorySize()) + "/" + + Formatter.formatFileSize(this, MemoryManager.getTotalExternalMemorySize())); + checkNetworkAddress(null); + testUiautomator(); + } + + public String getEthernetIpAddress() { + try { + List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); + for (NetworkInterface networkInterface : interfaces) { + + // 排除回环接口和未活动的接口 + if (!networkInterface.isLoopback() && networkInterface.isUp()) { + List addresses = Collections.list(networkInterface.getInetAddresses()); + for (InetAddress address : addresses) { + if (!address.isLoopbackAddress() && address instanceof java.net.Inet4Address) { + if (Objects.equals(address.getHostAddress(), "0.0.0.0")) { + continue; + } + return address.getHostAddress(); + } + } + } + } + } catch (Exception e) { + Log.e(TAG, e.toString()); + } + return "0.0.0.0"; + } + + public void checkNetworkAddress(View v) { + String ipAddress = getEthernetIpAddress(); + textViewIP.setText(ipAddress); + textViewIP.setTextColor(Color.BLUE); + + Request request = new Request.Builder().url("https://pro.api.tikmatrix.com/front-api/ip") + .get() + .build(); + okhttpManager.newCall(request, new Callback() { + + @Override + public void onFailure(Call call, IOException e) { + Log.e(TAG, e.toString()); + runOnUiThread(() -> { + tvWanIp.setText("Network Error"); + tvWanIp.setTextColor(Color.RED); + }); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + if (response.isSuccessful()) { + String content = response.body().string(); + Log.i(TAG, content); + runOnUiThread(() -> { + tvWanIp.setText(content); + tvWanIp.setTextColor(Color.BLUE); + }); + } + } + }); + + } + + @Override + protected void onRestart() { + super.onRestart(); + } + + @Override + public void onBackPressed() { + moveTaskToBack(true); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + Log.i(TAG, "unbind service"); + if (mStubStatusReceiver != null) { + unregisterReceiver(mStubStatusReceiver); + } + } +} diff --git a/app/src/main/java/com/github/tikmatrix/MockLocationProvider.java b/app/src/main/java/com/github/tikmatrix/MockLocationProvider.java new file mode 100644 index 0000000..c58ab81 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/MockLocationProvider.java @@ -0,0 +1,46 @@ +package com.github.tikmatrix; + +import android.content.Context; +import android.location.Location; +import android.location.LocationManager; +import android.os.Build; +import android.os.SystemClock; + +class MockLocationProvider { + + private String providerName; + private Context ctx; + + MockLocationProvider(String name, Context ctx) { + this.providerName = name; + this.ctx = ctx; + + LocationManager lm = (LocationManager) ctx.getSystemService( + Context.LOCATION_SERVICE); + lm.addTestProvider(providerName, false, false, false, false, false, + true, true, 0, 5); + lm.setTestProviderEnabled(providerName, true); + } + + void pushLocation(double lat, double lon, double alt, float accuracy) { + LocationManager lm = (LocationManager) ctx.getSystemService( + Context.LOCATION_SERVICE); + + Location mockLocation = new Location(providerName); + mockLocation.setLatitude(lat); + mockLocation.setLongitude(lon); + mockLocation.setAltitude(alt); + mockLocation.setTime(System.currentTimeMillis()); + mockLocation.setAccuracy(accuracy); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); + } + lm.setTestProviderLocation(providerName, mockLocation); + } + + void shutdown() { + LocationManager lm = (LocationManager) ctx.getSystemService( + Context.LOCATION_SERVICE); + lm.removeTestProvider(providerName); + } +} diff --git a/app/src/main/java/com/github/tikmatrix/ScreenClient.java b/app/src/main/java/com/github/tikmatrix/ScreenClient.java new file mode 100644 index 0000000..be1ccd3 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/ScreenClient.java @@ -0,0 +1,46 @@ +package com.github.tikmatrix; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * Created by hzsunshx on 2017/8/30. + */ + +public class ScreenClient { + private static final String PROCESS_NAME = "screen.cli"; + private static final String VERSION = "1.0"; + + public static void main(String[] args) { + setArgV0(PROCESS_NAME); + + ScreenHttpServer server = new ScreenHttpServer(9010); + try { + server.initialize(); + server.start(); + System.out.println("Server started"); + + while (server.isAlive()) { + Thread.sleep(100); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + server.stop(); + System.out.println("Server stopped"); + } + } + + private static void setArgV0(String text) { + try { + Method setter = android.os.Process.class.getMethod("setArgV0", String.class); + setter.invoke(android.os.Process.class, text); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } +} diff --git a/app/src/main/java/com/github/tikmatrix/ScreenHttpServer.java b/app/src/main/java/com/github/tikmatrix/ScreenHttpServer.java new file mode 100644 index 0000000..059b91a --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/ScreenHttpServer.java @@ -0,0 +1,281 @@ +package com.github.tikmatrix; + +import android.annotation.TargetApi; +import android.app.Instrumentation; +import android.graphics.Bitmap; +import android.graphics.Rect; +import android.media.MediaCodec; +import android.media.MediaCodecInfo; +import android.media.MediaFormat; +import android.media.MediaMuxer; +import android.os.Build; +import android.os.IBinder; +import android.os.Looper; +import android.util.Log; +import android.view.Surface; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.nio.ByteBuffer; +import java.util.Map; + +import fi.iki.elonen.NanoHTTPD; + +/** + * Created by hzsunshx on 2017/8/31. + */ + +public class ScreenHttpServer extends NanoHTTPD { + private static final String TAG = "ScreenHttpServer"; + private static final String MIME_TYPE = "video/avc"; + + private int mWidth = 1080; + private int mHeight = 1920; + private boolean landscape = false; + private Boolean recording = false; + + private Class surfaceControl; + private java.lang.reflect.Method rDestroyDisplay; + private java.lang.reflect.Method rOpenTransaction; + private java.lang.reflect.Method rCloseTransaction; + private java.lang.reflect.Method rCreateDisplay; + + protected static final int TIMEOUT_USEC = 10000; // 10[msec] + + public ScreenHttpServer(int port) { + super(port); + } + + public void initialize() throws Exception { + this.surfaceControl = Class.forName("android.view.SurfaceControl"); + Bitmap bmp = this.takeScreenshot(); + this.mWidth = bmp.getWidth(); + this.mHeight = bmp.getHeight(); + this.landscape = false; + bmp.recycle(); + + System.out.println("System info:\n" + + String.format("\tSDK: %d\n\tDisplay: %dx%d", Build.VERSION.SDK_INT, this.mWidth, this.mHeight)); + if (Build.VERSION.SDK_INT < 21) { + System.out.println("Screenrecord require SDK >= 21"); + } + } + + @Override + public Response serve(String uri, Method method, + Map headers, Map params, + Map files) { + Log.d(TAG, String.format("URI: %s, Method: %s, params, %s, files: %s", uri, method, params, files)); + try { + if ("/stop".equals(uri)) { + stop(); + return newFixedLengthResponse("Server stopped"); + } else if ("/screenshot".equals(uri)) { + return handleGetScreenshot(); + } else if ("/screenrecord".equals(uri) && Method.POST == method) { + return handlePostScreenrecord(params); + } else if ("/screenrecord".equals(uri) && Method.PUT == method) { + return handlePutScreenrecord(); + } + } catch (Exception ex) { + ex.printStackTrace(); + System.out.println("Internal Error: " + ex.getMessage()); + return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, ex.getMessage()); + } + return newFixedLengthResponse("404 Not found"); + } + + private Response handleGetScreenshot() { + // Requires SDK >= 21 + java.lang.reflect.Method injector = null; + try { + Bitmap bmp = this.takeScreenshot(); + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + bmp.compress(Bitmap.CompressFormat.JPEG, 75, bout); + bmp.recycle(); + return newChunkedResponse(Response.Status.OK, "image/jpeg", new ByteArrayInputStream(bout.toByteArray())); + } catch (Exception e) { + e.printStackTrace(); + return newFixedLengthResponse("Screenshot exception: " + e.toString()); + } + } + + private Bitmap takeScreenshot() throws Exception { + try { + java.lang.reflect.Method rScreenshot = surfaceControl.getDeclaredMethod("screenshot", Integer.TYPE, + Integer.TYPE); + Bitmap bmp = (Bitmap) rScreenshot.invoke(null, new Object[] { 0, 0 }); + + mWidth = bmp.getWidth(); + mHeight = bmp.getHeight(); + return bmp; + } catch (Exception e) { + throw new Exception("Inject SurfaceControl fail", e); + } + } + + // Start VideoRecord + private Response handlePostScreenrecord(Map params) throws Exception { + if (Build.VERSION.SDK_INT < 21) { + return newFixedLengthResponse("Screenrecord require SDK >= 21"); + } + if (this.recording) { + return newFixedLengthResponse("Already started record!"); + } + this.recording = true; + this.landscape = "true".equals(params.get("landscape")) || "1".equals(params.get("landscape")); + + String videoPath = params.get("path"); + if (videoPath == null || "".equals(videoPath)) { + videoPath = "/sdcard/video.mp4"; + } + new File(videoPath).delete(); // delete file before create + + final MediaCodec avc = createAVC(); + final MediaMuxer muxer = new MediaMuxer(videoPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4); + + final String finalVideoPath = videoPath; + new Thread("ScreenRecord") { + @Override + public void run() { + IBinder virtualDisplay = null; + try { + virtualDisplay = createVirtualDisplay(avc); + System.out.println("> Recording started"); + startRecording(avc, muxer); + } catch (Exception e) { + e.printStackTrace(); + } finally { + System.out.println("> Recording finished, saved to " + finalVideoPath); + releaseRecording(avc, virtualDisplay, muxer); + } + } + }.start(); + + return newFixedLengthResponse("OK"); + } + + // Stop VideoRecord + private Response handlePutScreenrecord() throws Exception { + this.recording = false; + return newFixedLengthResponse("OK"); + } + + @TargetApi(21) + private void startRecording(MediaCodec avc, MediaMuxer muxer) { + MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo(); + int track = -1; + try { + while (this.recording) { + // get virtual display data + int index = avc.dequeueOutputBuffer(bufferInfo, TIMEOUT_USEC); + if (index == MediaCodec.INFO_TRY_AGAIN_LATER) { + // Nothing to do here, anyway, deuqueueOutputBuffer will block for 10ms if no + // buffer + } else if (index == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { + if (track != -1) { + throw new RuntimeException("format changed twice"); + } + // Should only call once + MediaFormat format = avc.getOutputFormat(); + System.out.println("Output format changed to " + format.toString()); + track = muxer.addTrack(format); + muxer.start(); + } else if (index >= 0) { + if (track == -1) { + throw new Exception("MediaCodec track index is not setted!"); + } + ByteBuffer data = avc.getOutputBuffer(index); + if ((bufferInfo.flags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) != 0) { + System.out.println("ignoring BUFFER_FLAG_CODEC_CONFIG"); + bufferInfo.size = 0; + } + if (bufferInfo.size == 0) { + System.out.println("Ignore data(size=0)"); + data = null; + } + if (data != null) { + data.position(bufferInfo.offset); + data.limit(bufferInfo.offset + bufferInfo.size); + muxer.writeSampleData(track, data, bufferInfo); + avc.releaseOutputBuffer(index, false); + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + private IBinder createVirtualDisplay(MediaCodec mediaCodec) throws Exception { + try { + rCreateDisplay = surfaceControl.getDeclaredMethod("createDisplay", String.class, Boolean.TYPE); + rOpenTransaction = surfaceControl.getDeclaredMethod("openTransaction"); + rCloseTransaction = surfaceControl.getDeclaredMethod("closeTransaction"); + rDestroyDisplay = surfaceControl.getDeclaredMethod("destroyDisplay", IBinder.class); + + IBinder mDisplay = (IBinder) rCreateDisplay.invoke(null, "UIAutomatorDisplay", Boolean.valueOf(false)); + java.lang.reflect.Method setDisplaySurface = surfaceControl.getDeclaredMethod("setDisplaySurface", + IBinder.class, Surface.class); + java.lang.reflect.Method setDisplayProjection = surfaceControl.getDeclaredMethod("setDisplayProjection", + IBinder.class, Integer.TYPE, Rect.class, Rect.class); + java.lang.reflect.Method setDisplayLayerStack = surfaceControl.getDeclaredMethod("setDisplayLayerStack", + IBinder.class, Integer.TYPE); + + Surface surface = mediaCodec.createInputSurface(); + mediaCodec.start(); // TODO + + rOpenTransaction.invoke(null); + setDisplaySurface.invoke(null, mDisplay, surface); + setDisplayProjection.invoke(null, mDisplay, 0, getCurrentDisplayRect(), getCurrentDisplayRect()); // make + // video + // smaller + setDisplayLayerStack.invoke(null, mDisplay, 0); + rCloseTransaction.invoke(null); + + return mDisplay; + } catch (Exception ex) { + ex.printStackTrace(); + throw new Exception("virtual display", ex); + } + } + + // avc: Video Encoding is AVC(H.264) + private void releaseRecording(MediaCodec avc, IBinder bDisplay, MediaMuxer muxer) { + try { + avc.stop(); + avc.release(); + rDestroyDisplay.invoke(null, bDisplay); + muxer.stop(); + // raise Null exception + // muxer.release(); + // TODO muxer + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) + private MediaCodec createAVC() throws Exception { + Rect display = getCurrentDisplayRect(); + MediaFormat format = MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_AVC, display.width(), + display.height()); + // Set color format + format.setInteger(MediaFormat.KEY_COLOR_FORMAT, + MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); + format.setInteger(MediaFormat.KEY_BIT_RATE, 1500000); // bit rate 1500000 + format.setInteger(MediaFormat.KEY_FRAME_RATE, 20); // FPS + format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 10); // Frame interval, unit seconds + MediaCodec mMediaCodec = MediaCodec.createEncoderByType(MediaFormat.MIMETYPE_VIDEO_AVC); // Output encoding + mMediaCodec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); // 配置好格式参数 + return mMediaCodec; + } + + private Rect getCurrentDisplayRect() { + if (landscape) { + return new Rect(0, 0, mHeight, mWidth); + } + return new Rect(0, 0, mWidth, mHeight); + } +} diff --git a/app/src/main/java/com/github/tikmatrix/Service.java b/app/src/main/java/com/github/tikmatrix/Service.java new file mode 100644 index 0000000..726b1d7 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/Service.java @@ -0,0 +1,84 @@ +package com.github.tikmatrix; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.IBinder; + +import androidx.core.app.NotificationCompat; + +import android.provider.Settings; +import android.util.Log; +import android.widget.Toast; + +public class Service extends android.app.Service { + private static final String CHANNEL_ID = "ForegroundServiceChannel"; + private static final String TAG = "UIAService"; + private static final int NOTIFICATION_ID = 0x1; + + @Override + public IBinder onBind(Intent intent) { + // We don't support binding to this service + return null; + } + + private void createNotificationChannel() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel serviceChannel = new NotificationChannel( + CHANNEL_ID, + "Foreground Service Channel", + NotificationManager.IMPORTANCE_DEFAULT); + NotificationManager manager = getSystemService(NotificationManager.class); + if (manager != null) { + manager.createNotificationChannel(serviceChannel); + } + } + } + + @Override + public void onCreate() { + super.onCreate(); + + createNotificationChannel(); + + } + + @Override + public void onDestroy() { + super.onDestroy(); + Log.i(TAG, "Stopping service"); + + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + super.onStartCommand(intent, flags, startId); + Log.i(TAG, "On StartCommand"); + + Intent notificationIntent = new Intent(this, MainActivity.class); + PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, + PendingIntent.FLAG_IMMUTABLE); + + Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID) + .setContentTitle("TikMatrix Service") + .setContentText("TikMatrix service is running") + .setSmallIcon(R.drawable.ic_notification) + .setContentIntent(pendingIntent) + .build(); + + startForeground(1, notification); + + // Do the work that should be done by this service + return START_NOT_STICKY; + } + + @Override + public void onLowMemory() { + Log.w(TAG, "Low memory"); + } + +} diff --git a/app/src/main/java/com/github/tikmatrix/compat/InputManagerWrapper.java b/app/src/main/java/com/github/tikmatrix/compat/InputManagerWrapper.java new file mode 100644 index 0000000..2fe75d8 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/compat/InputManagerWrapper.java @@ -0,0 +1,122 @@ +// +// Copied from https://github.com/openstf/STFService.apk/blob/master/app/src/main/java/jp/co/cyberagent/stf/compat/InputManagerWrapper.java + +package com.github.tikmatrix.compat; + +import android.view.InputEvent; +import android.view.KeyEvent; + +import com.github.tikmatrix.util.InternalApi; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class InputManagerWrapper { + private EventInjector eventInjector; + + public InputManagerWrapper() { + try { + eventInjector = new InputManagerEventInjector(); + } catch (UnsupportedOperationException e) { + // eventInjector = new WindowManagerEventInjector(); + } + } + + public boolean injectKeyEvent(KeyEvent event) { + return eventInjector.injectKeyEvent(event); + } + + public boolean injectInputEvent(InputEvent event) { + return eventInjector.injectInputEvent(event); + } + + private interface EventInjector { + boolean injectKeyEvent(KeyEvent event); + + boolean injectInputEvent(InputEvent event); + } + + /** + * EventInjector for SDK >=16 + */ + private class InputManagerEventInjector implements EventInjector { + public static final int INJECT_INPUT_EVENT_MODE_ASYNC = 0; + private Object inputManager; + private Method injector; + + public InputManagerEventInjector() { + try { + inputManager = InternalApi.getSingleton("android.hardware.input.InputManager"); + + // injectInputEvent() is @hidden + injector = inputManager.getClass() + // public boolean injectInputEvent(InputEvent event, int mode) + .getMethod("injectInputEvent", InputEvent.class, int.class); + } catch (NoSuchMethodException e) { + throw new UnsupportedOperationException("InputManagerEventInjector is not supported"); + } + } + + public boolean injectKeyEvent(KeyEvent event) { + return injectInputEvent(event); + } + + @Override + public boolean injectInputEvent(InputEvent event) { + try { + injector.invoke(inputManager, event, INJECT_INPUT_EVENT_MODE_ASYNC); + return true; + } catch (IllegalAccessException e) { + e.printStackTrace(); + return false; + } catch (InvocationTargetException e) { + e.printStackTrace(); + return false; + } + } + } + + /** + * EventInjector for SDK <16 + */ + // private class WindowManagerEventInjector implements EventInjector { + // private Object windowManager; + // private Method keyInjector; + // + // public WindowManagerEventInjector() { + // try { + // windowManager = WindowManagerWrapper.getWindowManager(); + // + // keyInjector = windowManager.getClass() + // // public boolean injectKeyEvent(android.view.KeyEvent ev, boolean sync) + // // throws android.os.RemoteException + // .getMethod("injectKeyEvent", KeyEvent.class, boolean.class); + // } + // catch (NoSuchMethodException e) { + // e.printStackTrace(); + // throw new UnsupportedOperationException("WindowManagerEventInjector is not + // supported"); + // } + // } + // + // public boolean injectKeyEvent(KeyEvent event) { + // try { + // keyInjector.invoke(windowManager, event, false); + // return true; + // } + // catch (IllegalAccessException e) { + // e.printStackTrace(); + // return false; + // } + // catch (InvocationTargetException e) { + // e.printStackTrace(); + // return false; + // } + // } + // + // @Override + // public boolean injectInputEvent(InputEvent event) { + // return false; + // } + // } +} diff --git a/app/src/main/java/com/github/tikmatrix/monitor/AbstractMonitor.java b/app/src/main/java/com/github/tikmatrix/monitor/AbstractMonitor.java new file mode 100644 index 0000000..835b6e1 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/monitor/AbstractMonitor.java @@ -0,0 +1,31 @@ +package com.github.tikmatrix.monitor; + +import android.content.Context; + +/** + * Created by hzsunshx on 2017/11/15. + */ + +abstract public class AbstractMonitor { + Context context; + HttpPostNotifier notifier; + + public AbstractMonitor(Context context, HttpPostNotifier notifier) { + this.context = context; + this.notifier = notifier; + init(); + try { + unregister(); + } catch (IllegalArgumentException e) { + // ignore + } + + this.register(); + } + + abstract public void init(); + + abstract public void register(); + + abstract public void unregister(); +} diff --git a/app/src/main/java/com/github/tikmatrix/monitor/BatteryMonitor.java b/app/src/main/java/com/github/tikmatrix/monitor/BatteryMonitor.java new file mode 100644 index 0000000..6b45630 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/monitor/BatteryMonitor.java @@ -0,0 +1,58 @@ +package com.github.tikmatrix.monitor; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.BatteryManager; +import android.util.Log; + +/** + * Created by hzsunshx on 2017/11/15. + */ + +public class BatteryMonitor extends AbstractMonitor { + private static final String TAG = "UIABatteryMonitor"; + + private static final String USB_STATE_CHANGE = "android.hardware.usb.action.USB_STATE"; + public BroadcastReceiver receiver = null; + + public BatteryMonitor(Context context, HttpPostNotifier notifier) { + super(context, notifier); + } + + @Override + public void init() { + Log.i(TAG, "Battery monitor init"); + this.receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + report(notifier, intent); + } + }; + } + + @Override + public void register() { + Log.i(TAG, "Register BatteryMonitor"); + + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_BATTERY_CHANGED); + filter.addAction(USB_STATE_CHANGE); + context.registerReceiver(receiver, filter); + } + + @Override + public void unregister() { + if (receiver != null) { + Log.i(TAG, "battery unregistered"); + context.unregisterReceiver(receiver); + } + } + + private void report(HttpPostNotifier notifier, Intent intent) { + Integer level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); + Log.d(TAG, "notify battery changed. current level " + level); + notifier.Notify("/info/battery", String.valueOf(level)); + } +} diff --git a/app/src/main/java/com/github/tikmatrix/monitor/HttpPostNotifier.java b/app/src/main/java/com/github/tikmatrix/monitor/HttpPostNotifier.java new file mode 100644 index 0000000..719acd8 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/monitor/HttpPostNotifier.java @@ -0,0 +1,52 @@ +package com.github.tikmatrix.monitor; + +import com.github.tikmatrix.util.OkhttpManager; + +import java.io.IOException; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +/** + * Created by hzsunshx on 2017/11/15. + */ + +public class HttpPostNotifier { + private String reportUrl; + private OkhttpManager okhttpManager; + + public HttpPostNotifier(String reportUrl) { + // reportUrl eg: http://127.0.0.1:7912 + this.reportUrl = reportUrl; + this.okhttpManager = OkhttpManager.getSingleton(); + } + + public void Notify(String baseUrl, String content) { + RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), content); + Notify(baseUrl, body); + } + + public void Notify(String baseUrl, RequestBody body) { + // baseUrl should have / prefix + Request request = new Request.Builder() + .url(reportUrl + baseUrl) + .post(body) + .build(); + okhttpManager.newCall(request, new Callback() { + @Override + public void onFailure(Call call, IOException e) { + e.printStackTrace(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + // Do nothing + } + }); + } +} diff --git a/app/src/main/java/com/github/tikmatrix/monitor/RotationMonitor.java b/app/src/main/java/com/github/tikmatrix/monitor/RotationMonitor.java new file mode 100644 index 0000000..4a848b9 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/monitor/RotationMonitor.java @@ -0,0 +1,59 @@ +package com.github.tikmatrix.monitor; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.util.Log; +import android.view.WindowManager; + +/** + * Created by hzsunshx on 2017/11/15. + * Deprecated, use RotationAgent to watch rotation. + */ + +public class RotationMonitor extends AbstractMonitor { + private static final String TAG = "UIARotationMonitor"; + + BroadcastReceiver receiver; + WindowManager windowService; + + public RotationMonitor(Context context, HttpPostNotifier notifier) { + super(context, notifier); + } + + @Override + public void init() { + Log.i(TAG, "Rotation monitor init"); + this.windowService = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + + receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + report(); + } + }; + } + + @Override + public void register() { + Log.i(TAG, "Rotation monitor starting"); + report(); // need to notify for the first time + + // FIXME(ssx): when change from 90 degree to 270 degree. no broadcast received + context.registerReceiver(receiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); + } + + @Override + public void unregister() { + if (receiver != null) { + context.unregisterReceiver(receiver); + } + } + + private void report() { + int rotation = windowService.getDefaultDisplay().getRotation(); + Log.i(TAG, "Orientation " + rotation); + notifier.Notify("/info/rotation", "" + rotation); + } +} diff --git a/app/src/main/java/com/github/tikmatrix/util/InternalApi.java b/app/src/main/java/com/github/tikmatrix/util/InternalApi.java new file mode 100644 index 0000000..5b2fd1c --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/util/InternalApi.java @@ -0,0 +1,86 @@ +package com.github.tikmatrix.util; + +import android.os.IBinder; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class InternalApi { + public static boolean hasService(String name) { + try { + // The ServiceManager class is @hidden in newer SDKs + Class ServiceManager = Class.forName("android.os.ServiceManager"); + Method getService = ServiceManager.getMethod("getService", String.class); + return getService.invoke(null, name) != null; + } catch (ClassNotFoundException e) { + return false; + } catch (NoSuchMethodException e) { + return false; + } catch (IllegalAccessException e) { + return false; + } catch (InvocationTargetException e) { + return false; + } + } + + public static Object getServiceBinder(String name) { + try { + // The ServiceManager class is @hidden in newer SDKs + Class ServiceManager = Class.forName("android.os.ServiceManager"); + Method getService = ServiceManager.getMethod("getService", String.class); + return getService.invoke(null, name); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + return null; + } catch (NoSuchMethodException e) { + e.printStackTrace(); + return null; + } catch (IllegalAccessException e) { + e.printStackTrace(); + return null; + } catch (InvocationTargetException e) { + e.printStackTrace(); + return null; + } + } + + public static Object getServiceAsInterface(String serviceName, String interfaceClass) { + try { + Object serviceBinder = getServiceBinder(serviceName); + + Class Stub = Class.forName(interfaceClass); + + // *.Stub.asInterface(IBinder obj) + Method asInterface = Stub.getMethod("asInterface", IBinder.class); + + return asInterface.invoke(null, serviceBinder); + } catch (ClassNotFoundException e) { + throw new UnsupportedOperationException("Unsupported service " + serviceName + ": " + e.getMessage()); + } catch (NoSuchMethodException e) { + throw new UnsupportedOperationException("Unsupported service " + serviceName + ": " + e.getMessage()); + } catch (IllegalAccessException e) { + throw new UnsupportedOperationException("Unsupported service " + serviceName + ": " + e.getMessage()); + } catch (InvocationTargetException e) { + throw new UnsupportedOperationException("Unsupported service " + serviceName + ": " + e.getMessage()); + } + } + + public static Object getSingleton(String className) { + try { + Class aClass = Class.forName(className); + + // getInstance() is @hidden + Method getInstance = aClass.getMethod("getInstance"); + + return getInstance.invoke(null); + } catch (ClassNotFoundException e) { + throw new UnsupportedOperationException("Unsupported singleton " + className + ": " + e.getMessage()); + } catch (NoSuchMethodException e) { + throw new UnsupportedOperationException("Unsupported singleton " + className + ": " + e.getMessage()); + } catch (IllegalAccessException e) { + throw new UnsupportedOperationException("Unsupported singleton " + className + ": " + e.getMessage()); + } catch (InvocationTargetException e) { + throw new UnsupportedOperationException("Unsupported singleton " + className + ": " + e.getMessage()); + } + } +} diff --git a/app/src/main/java/com/github/tikmatrix/util/MemoryManager.java b/app/src/main/java/com/github/tikmatrix/util/MemoryManager.java new file mode 100644 index 0000000..7c7d321 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/util/MemoryManager.java @@ -0,0 +1,219 @@ +package com.github.tikmatrix.util; + +import android.annotation.TargetApi; +import android.content.Context; +import android.os.Build; +import android.os.Environment; +import android.os.StatFs; +import android.os.storage.StorageManager; +import androidx.annotation.NonNull; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; + +public class MemoryManager { + /** + * 获取手机内部空间总大小 + * + * @return 大小,字节为单位 + */ + static public long getTotalInternalMemorySize() { + // 获取内部存储根目录 + File path = Environment.getDataDirectory(); + // 系统的空间描述类 + StatFs stat = new StatFs(path.getPath()); + // 每个区块占字节数 + long blockSize = stat.getBlockSize(); + // 区块总数 + long totalBlocks = stat.getBlockCount(); + return totalBlocks * blockSize; + } + + /** + * 获取手机内部可用空间大小 + * + * @return 大小,字节为单位 + */ + public static long getAvailableInternalMemorySize() { + File path = Environment.getDataDirectory(); + StatFs stat = new StatFs(path.getPath()); + long blockSize = stat.getBlockSize(); + // 获取可用区块数量 + long availableBlocks = stat.getAvailableBlocks(); + return availableBlocks * blockSize; + } + + /** + * 判断SD卡是否可用 + * + * @return true : 可用
+ * false : 不可用 + */ + private static boolean isSDCardEnable() { + return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); + } + + /** + * 获取手机外部总空间大小 + * + * @return 总大小,字节为单位 + */ + static public long getTotalExternalMemorySize() { + if (isSDCardEnable()) { + // 获取SDCard根目录 + File path = Environment.getExternalStorageDirectory(); + StatFs stat = new StatFs(path.getPath()); + long blockSize = stat.getBlockSize(); + long totalBlocks = stat.getBlockCount(); + return totalBlocks * blockSize; + } else { + return -1; + } + } + + private static String getSDCardPath() { + File path = Environment.getExternalStorageDirectory(); + return path.getPath(); + } + + /** + * 获取SD卡剩余空间 + * + * @return SD卡剩余空间 + */ + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) + public static long getFreeSpace(Context context) { + ArrayList volumes = MemoryManager.getVolume(context); + if (volumes != null && volumes.size() > 1) { + StatFs stat = new StatFs(getSDCardPath()); + long blockSize, availableBlocks; + availableBlocks = stat.getAvailableBlocksLong(); + blockSize = stat.getBlockSizeLong(); + return availableBlocks * blockSize; + } else { + return -1; + } + } + + /** + * 获取SD卡信息 + * + * @return SDCardInfo + */ + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) + public static String getSDCardInfo() { + SDCardInfo sd = new SDCardInfo(); + if (!isSDCardEnable()) + return "sdcard unable!"; + sd.isExist = true; + StatFs sf = new StatFs(Environment.getExternalStorageDirectory().getPath()); + sd.totalBlocks = sf.getBlockCountLong(); + sd.blockByteSize = sf.getBlockSizeLong(); + sd.availableBlocks = sf.getAvailableBlocksLong(); + sd.availableBytes = sf.getAvailableBytes(); + sd.freeBlocks = sf.getFreeBlocksLong(); + sd.freeBytes = sf.getFreeBytes(); + sd.totalBytes = sf.getTotalBytes(); + return sd.toString(); + } + + /* + * 获取全部存储设备信息封装对象 + */ + private static ArrayList getVolume(Context context) { + ArrayList list_storagevolume = new ArrayList(); + + StorageManager storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); + + try { + Method method_volumeList = StorageManager.class.getMethod("getVolumeList"); + + method_volumeList.setAccessible(true); + + Object[] volumeList = (Object[]) method_volumeList.invoke(storageManager); + if (volumeList != null) { + Volume volume; + for (int i = 0; i < volumeList.length; i++) { + try { + volume = new Volume(); + volume.setPath((String) volumeList[i].getClass().getMethod("getPath").invoke(volumeList[i])); + volume.setRemovable( + (boolean) volumeList[i].getClass().getMethod("isRemovable").invoke(volumeList[i])); + volume.setState((String) volumeList[i].getClass().getMethod("getState").invoke(volumeList[i])); + list_storagevolume.add(volume); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + } + } + } catch (Exception e1) { + e1.printStackTrace(); + } + + return list_storagevolume; + } + + /* + * 存储设备信息封装类 + */ + public static class Volume { + protected String path; + boolean removable; + protected String state; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public boolean isRemovable() { + return removable; + } + + void setRemovable(boolean removable) { + this.removable = removable; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + } + + public static class SDCardInfo { + boolean isExist; + long totalBlocks; + long freeBlocks; + long availableBlocks; + long blockByteSize; + long totalBytes; + long freeBytes; + long availableBytes; + + @NonNull + @Override + public String toString() { + return "isExist=" + isExist + + "\ntotalBlocks=" + totalBlocks + + "\nfreeBlocks=" + freeBlocks + + "\navailableBlocks=" + availableBlocks + + "\nblockByteSize=" + blockByteSize + + "\ntotalBytes=" + totalBytes + + "\nfreeBytes=" + freeBytes + + "\navailableBytes=" + availableBytes; + } + } +} diff --git a/app/src/main/java/com/github/tikmatrix/util/OkhttpManager.java b/app/src/main/java/com/github/tikmatrix/util/OkhttpManager.java new file mode 100644 index 0000000..d733dfc --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/util/OkhttpManager.java @@ -0,0 +1,56 @@ +package com.github.tikmatrix.util; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; + +public class OkhttpManager { + private static final String TAG = "OkhttpManager"; + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private OkHttpClient client; + + private volatile static OkhttpManager singleton; + + private OkhttpManager() { + client = new OkHttpClient.Builder().proxy(null).build(); + } + + public static OkhttpManager getSingleton() { + if (singleton == null) { + synchronized (OkhttpManager.class) { + if (singleton == null) { + singleton = new OkhttpManager(); + } + } + } + return singleton; + } + + public void newCall(Request request, Callback callback) { + client.newCall(request).enqueue(callback); + } + + public void post(final String url, String json, Callback callback) { + RequestBody body = RequestBody.create(JSON, json); + final Request request = new Request.Builder() + .url(url) + .post(body) + .build(); + Call call = client.newCall(request); + call.enqueue(callback); + } + + public void delete(final String url, String json, Callback callback) { + RequestBody body = RequestBody.create(JSON, json); + Request request = new Request.Builder() + .url(url) + .delete(body) + .build(); + Call call = client.newCall(request); + call.enqueue(callback); + } + +} diff --git a/app/src/main/java/com/github/tikmatrix/util/Permissons4App.java b/app/src/main/java/com/github/tikmatrix/util/Permissons4App.java new file mode 100644 index 0000000..4e44602 --- /dev/null +++ b/app/src/main/java/com/github/tikmatrix/util/Permissons4App.java @@ -0,0 +1,113 @@ +package com.github.tikmatrix.util; + +import android.app.Activity; +import android.app.ActivityManager; +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.Build; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import android.util.Log; + +import com.github.tikmatrix.MainActivity; + +import java.util.List; + +public class Permissons4App { + private static final String TAG = Permissons4App.class.getSimpleName(); + private static final int PERMISSION_REQUEST_CODE = 1000; + + /** + * init permissions + */ + public static void initPermissions(Activity activity, String[] permissions) { + initPermissions(activity, permissions, PERMISSION_REQUEST_CODE); + } + + /** + * init permissions with request code + */ + public static void initPermissions(Activity activity, String[] permissions, int requestCode) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (isAllGranted(activity, permissions)) { + Log.i(TAG, "Permissions all granted"); + } else { + Log.i(TAG, "Request permissions"); + ActivityCompat.requestPermissions(activity, permissions, requestCode); + } + } + } + + /** + * Determine whether all specified permissions have been authorized + */ + private static boolean isAllGranted(Context context, String[] permissions) { + return checkPermissionAllGranted(context, permissions); + } + + /** + * Check whether app have all the specified permissions + */ + private static boolean checkPermissionAllGranted(Context context, String[] permissions) { + // if permissions all granted, it will return true, otherwise it will return + // false. + for (int i = 0; i < permissions.length; i++) { + if (ContextCompat.checkSelfPermission(context, permissions[i]) != PackageManager.PERMISSION_GRANTED) { + return false; + } + } + return true; + } + + /** + * handle request permissions result + */ + public static void handleRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + handleRequestPermissionsResult(requestCode, permissions, grantResults, PERMISSION_REQUEST_CODE); + } + + /** + * handle request permissions result with request code + */ + public static void handleRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults, + int customRequestCode) { + if (requestCode == customRequestCode) { + boolean isAllGranted = true; + // Determine whether all specified permissions have been authorized + for (int i = 0; i < grantResults.length; i++) { + if (grantResults[i] != PackageManager.PERMISSION_GRANTED) { + isAllGranted = false; + break; + } + } + if (!isAllGranted) { + // TODO: Pop-up dialog box tells the user why he needs permission and guides the + // user to open permission manually in application permission management. + } + } + } + + public static boolean isAppInstalled(MainActivity mainActivity, String packageName) { + PackageManager pm = mainActivity.getPackageManager(); + try { + pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); + return true; + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return false; + } + + public static boolean isAppRunning(MainActivity mainActivity, String packageName) { + ActivityManager am = (ActivityManager) mainActivity.getSystemService(Context.ACTIVITY_SERVICE); + List runningAppProcesses = am.getRunningAppProcesses(); + Log.i("runningAppProcess: ", String.valueOf(runningAppProcesses.size())); + for (ActivityManager.RunningAppProcessInfo runningAppProcess : runningAppProcesses) { + Log.i("runningAppProcess: ", runningAppProcess.processName); + if (runningAppProcess.processName.equals(packageName)) { + return true; + } + } + return false; + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_notification.png b/app/src/main/res/drawable-hdpi/ic_notification.png new file mode 100644 index 0000000000000000000000000000000000000000..5ae6bb561c880344f45b435100f84e8cd264a97a GIT binary patch literal 4592 zcmVC z{FGlhmyRxHa(yMlXmju3*NLgGDS9)poi zAuzy{z>y9}_-<^W?0ZU4K$7V4O`FlGf`SaVu%04Z2wchstU~ZVH{TF&JEc)XhoPOV zK$xnaBs5gsxM9>+Ryt$Oanv$RI&E-xo=1jZFt%75i;B?mhhN-~w{Go0OvqQ^j)&m3 z1@jG%yA%VC0XRN44gG(v|NeI+e>nAFe`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No`?%zvi<@4+d zdGDnG8n8n5?`OW3`w(HZbjcFy_l}c0Ki>Q1*T|i$1*5{FHfcI?c%=XQ#k;mXzVrE2 zb=5ocqT*FjAP(vRpsWE*ZU&J2T^t4$o2n|O@Jq(~Ss)}g09TQS4-d7peRbr$ro&&J z_p^`r`#vc_Dra8Zth}KLMV3ax@T|c>5fBpEEG`a(uq;G#+Ho+V!y1T>3)^x0MkVAV o!Lx!-4fga1W?9~N;VYNxFDl3UWit*YDF6Tf07*qoM6N<$f*CWlg#Z8m literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_notification.png b/app/src/main/res/drawable-xhdpi/ic_notification.png new file mode 100644 index 0000000000000000000000000000000000000000..5ae6bb561c880344f45b435100f84e8cd264a97a GIT binary patch literal 4592 zcmVC z{FGlhmyRxHa(yMlXmju3*NLgGDS9)poi zAuzy{z>y9}_-<^W?0ZU4K$7V4O`FlGf`SaVu%04Z2wchstU~ZVH{TF&JEc)XhoPOV zK$xnaBs5gsxM9>+Ryt$Oanv$RI&E-xo=1jZFt%75i;B?mhhN-~w{Go0OvqQ^j)&m3 z1@jG%yA%VC0XRN44gG(v|NeI+e>nAFe`|d`vK0j(Q?dw8B}USsMb-=d^qrio8wy`e zn$|ZBHTe)@QA#l%05K!(VK)@S2}v2@Pm!Vj?4GHH!pId0-^K{L z{l>bQ+_84+mOEXI^%b41t@bSD0Yn&UOwcpg%a);nKYj9c@)kG=4!{k8x0*FacLP;!nXhUH~QcYa0t*C(R zJM7`%!B`SSx^wrQqC_8Yf)oFuPM^l1fZkv~qQFSz)0zqBPQ+{9sTKM~LJ0!WkwC zy|Mg8c&NK8*x%8vtX#NIG60-es%fTUEF+oB$X!=hxTv7;V%O~oyQwxf>(;Ifa00&! zQJ)N6sF>MIrfEo^&rsHqe0BfxU!#w%S^F6HTjdSSVGdAI6(!P9 zd&fw|VglGH2J*2`*5+hlt!(P-BU98iI7p8~v!F8>XbuV!CKz2SCnJP6EX`-nNH=Bx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#`>RDUcTgDmBL8k@`yoZslC1A7yokXdRUUaK{%nsGDiS<&|eKR zMwHke$cT_|M(A{BQ~k?7{pasQ49BaV2#$RR(=`B4%_pDYpC5bU4Azr}LWKl zKG&;6l#@$V@3^rbTaq|I$N|$m!`W+zi2Kk<52%R1P!NG|q;UCC0s%1s&LVL~Zu$pw z4m?cK*4xk5ws)}A?st9uNIM`W25Ajl3M7_fB)_6|2y-+uT@i3rv%0x zjH!5-@;WLjkg)-MY5x}Pp>0JQ^Or6y%3ivBonaaI5ZcOs@gtL0%yQfo$_NC|p)Wl_ zf&}|vn9#bu{#ePS(sb4nf+KAWnUd7n-rQWJw6xy1dj4$d?WmZXQ~>VIxZDNhf1)kG%~ncDy_{2L~a@Zh7Im85WjqhYSOS963#6 z6D{RoaE7z8P-As9qOGl7f9?0@SmwPa;xzYNvKMWzL>%&f8Y9#5xOfpr$0e}e_m=*P aLjDLXJvO7-V1m~G0000 + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_nor_down.xml b/app/src/main/res/drawable/btn_nor_down.xml new file mode 100644 index 0000000..71faf05 --- /dev/null +++ b/app/src/main/res/drawable/btn_nor_down.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/check_border.xml b/app/src/main/res/drawable/check_border.xml new file mode 100644 index 0000000..6deaf41 --- /dev/null +++ b/app/src/main/res/drawable/check_border.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_random_24dp.xml b/app/src/main/res/drawable/ic_random_24dp.xml new file mode 100644 index 0000000..b40d240 --- /dev/null +++ b/app/src/main/res/drawable/ic_random_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/icon.png b/app/src/main/res/drawable/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..bc8a640759a36a4ce4c0540cae887d63efb7178b GIT binary patch literal 1902 zcmV-!2a))RP)C~w$ow<%T~TpzkZ)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Mh2Q=0KUA8{e)oY+_#D@0jn25{tf z&TPB8yRGGinL645P-Z^(BAnwTEs^{}$ z*r1qR7m1)#?QOgIdV3h~92yqHzWZdm_1Sy-9@LGZwxW_^6}*unHJNo`?%zvi<@4+d zdGDnG8n8n5?`OW3`w(HZbjcFy_l}c0Ki>Q1*T|i$1*5{FHfcI?c%=XQ#k;mXzVrE2 zb=5ocqT*FjAP(vRpsWE*ZU&J2T^t4$o2n|O@Jq(~Ss)}g09TQS4-d7peRbr$ro&&J z_p^`r`#vc_Dra8Zth}KLMV3ax@T|c>5fBpEEG`a(uq;G#+Ho+V!y1T>3)^x0MkVAV o!Lx!-4fga1W?9~N;VYNxFDl3UWit*YDF6Tf07*qoM6N<$f*CWlg#Z8m literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/rounded_corner.xml b/app/src/main/res/drawable/rounded_corner.xml new file mode 100644 index 0000000..ea27ba7 --- /dev/null +++ b/app/src/main/res/drawable/rounded_corner.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..351329c --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/keyboard.xml b/app/src/main/res/layout/keyboard.xml new file mode 100644 index 0000000..e69dc2f --- /dev/null +++ b/app/src/main/res/layout/keyboard.xml @@ -0,0 +1,9 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/preview.xml b/app/src/main/res/layout/preview.xml new file mode 100644 index 0000000..5a172eb --- /dev/null +++ b/app/src/main/res/layout/preview.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..cde69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0)5$tPUg~$jVI6vFO zK^wG7t=**T40km@TNUK+WTx<1mL|6Tn6+kB+E$Gpt8SauF9E-CR9Uui_EHn_nmBqS z>o#G}58nHFtICqJPx<_?UZ;z0_(0&UqMnTftMKW@%AxYpa!g0fxGe060^xkRtYguj ze&fPtC!?RgE}FsE0*^2lnE>42K#jp^nJDyzp{JV*jU?{+%KzW37-q|d3i&%eooE6C8Z2t2 z9bBL;^fzVhdLxCQh1+Ms5P)ilz9MYFKdqYN%*u^ch(Fq~QJASr5V_=szAKA4Xm5M} z(Kka%r!noMtz6ZUbjBrJ?Hy&c+mHB{OFQ}=41Irej{0N90`E*~_F1&7Du+zF{Dky) z+KN|-mmIT`Thcij!{3=ibyIn830G zN{kI3d`NgUEJ|2If}J!?@w~FV+v?~tlo8ps3Nl`3^kI)WfZ0|ms6U8HEvD9HIDWkz6`T_QSewYZyzkRh)!g~R>!jaR9;K|#82kfE5^;R!~}H4C?q{1AG?O$5kGp)G$f%VML%aPD?{ zG6)*KodSZRXbl8OD=ETxQLJz)KMI7xjArKUNh3@0f|T|75?Yy=pD7056ja0W)O;Td zCEJ=7q?d|$3rZb+8Cvt6mybV-#1B2}Jai^DOjM2<90tpql|M5tmheg){2NyZR}x3w zL6u}F+C-PIzZ56q0x$;mVJXM1V0;F}y9F29ob51f;;+)t&7l30gloMMHPTuod530FC}j^4#qOJV%5!&e!H9#!N&XQvs5{R zD_FOomd-uk@?_JiWP%&nQ_myBlM6so1Ffa1aaL7B`!ZTXPg_S%TUS*>M^8iJRj1*~ e{{%>Z1YfTk|3C04d;8A^0$7;Zm{b|L#{L(;l>}-4 literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..bfa42f0e7b91d006d22352c9ff2f134e504e3c1d GIT binary patch literal 4842 zcmZ{oXE5C1x5t0WvTCfdv7&7fy$d2l*k#q|U5FAbL??P!61}%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8UaZv%-&?Yzp7gWNIo_x^(d75=x2c zv|LQ`HrKP(8TqFxTiP5gdT2>aTN0S7XW*pilASS$UkJ2*n+==D)0mgTGxv43t61fr z47GkfMnD-zSH@|mZ26r*d3WEtr+l-xH@L}BM)~ThoMvKqGw=Ifc}BdkL$^wC}=(XSf4YpG;sA9#OSJf)V=rs#Wq$?Wj+nTlu$YXn yn3SQon5>kvtkl(BT2@T#Mvca!|08g9w{vm``2PjZHg=b<1c17-HkzPl9sXa)&-Ts$ literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..324e72cdd7480cb983fa1bcc7ce686e51ef87fe7 GIT binary patch literal 7718 zcmZ{JWl)?=u?hpbj?h-6mfK3P*Eck~k0Tzeg5-hkABxtZea0_k$f-mlF z0S@Qqtva`>x}TYzc}9LrO?P#qj+P1@HZ?W?0C;Muih9o&|G$cb@ocx1*PEUJ%~tM} z901hB;rx4#{@jOHs_MN00ADr$2n+#$yJuJ64gh!x0KlF(07#?(0ENrf7G3D`0EUHz zisCaq%dJ9dz%zhdRNuG*01nCjDhiPCl@b8xIMfv7^t~4jVRrSTGYyZUWqY@yW=)V_ z&3sUP1SK9v1f{4lDSN(agrKYULc;#EGDVeU*5b@#MOSY5JBn#QG8wqxQh+mdR638{mo5f>O zLUdZIPSjFk0~F26zDrM3y_#P^P91oWtLlPaZrhnM$NR%qsbHHK#?fN?cX?EvAhY1Sr9A(1;Kw4@87~|;2QP~ z(kKOGvCdB}qr4m#)1DwQFlh^NdBZvNLkld&yg%&GU`+boBMsoj5o?8tVuY^b0?4;E zsxoLxz8?S$y~a~x0{?dqk+6~Dd(EG7px_yH(X&NX&qEtHPUhu*JHD258=5$JS12rQ zcN+7p>R>tbFJ3NzEcRIpS98?}YEYxBIA8}1Y8zH9wq0c{hx+EXY&ZQ!-Hvy03X zLTMo4EZwtKfwb294-cY5X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IX&I?B=|yoZ!&<`9&H5PtApt=VUIB4l0a1NH v0SQqt3DM`an1p};^>=lX|A*k@Y-MNT^ZzF}9G-1G696?OEyXH%^Pv9$0dR%J literal 0 HcmV?d00001 diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..3494ff4 --- /dev/null +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,29 @@ + + + + + 64dp + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..9c3e9da --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,296 @@ + + + #FFFFFF + + #FFFFF0 + + #FFFFE0 + + #FFFF00 + + #FFFAFA + + #FFFAF0 + + #FFFACD + + #FFF8DC + + #FFF5EE + + #FFF0F5 + + #FFEFD5 + + #FFEBCD + + #FFE4E1 + + #FFE4C4 + + #FFE4B5 + + #FFDEAD + + #FFDAB9 + + #FFD700 + + #FFC0CB + + #FFB6C1 + + #FFA500 + + #FFA07A + + #FF8C00 + + #FF7F50 + + #FF69B4 + + #FF6347 + + #FF4500 + + #FF1493 + + #FF00FF + + #FF00FF + + #FF0000 + + #FDF5E6 + + #FAFAD2 + + #FAF0E6 + + #FAEBD7 + + #FA8072 + + #F8F8FF + + #F5FFFA + + #F5F5F5 + + #F5F5DC + + #F5DEB3 + + #F4A460 + + #F0FFFF + + #F0FFF0 + + #F0F8FF + + #F0E68C + + #F08080 + + #EEE8AA + + #EE82EE + + #E9967A + + #E6E6FA + + #E0FFFF + + #DEB887 + + #DDA0DD + + #DCDCDC + + #DC143C + + #DB7093 + + #DAA520 + + #DA70D6 + + #D8BFD8 + + #D3D3D3 + + #D3D3D3 + + #D2B48C + + #D2691E + + #CD853F + + #CD5C5C + + #C71585 + + #C0C0C0 + + #BDB76B + + #BC8F8F + + #BA55D3 + + #B8860B + + #B22222 + + #B0E0E6 + + #B0C4DE + + #AFEEEE + + #ADFF2F + + #ADD8E6 + + #A9A9A9 + + #A52A2A + + #A0522D + + #9932CC + + #98FB98 + + #9400D3 + + #9370DB + + #90EE90 + + #8FBC8F + + #8B4513 + + #8B008B + + #8B0000 + + #8A2BE2 + + #87CEFA + + #87CEEB + + #808080 + + #808080 + + #808000 + + #800080 + + #800000 + + #7FFFD4 + + #7FFF00 + + #7CFC00 + + #7B68EE + + #778899 + + #778899 + + #708090 + + #708090 + + #6B8E23 + + #6A5ACD + + #696969 + + #696969 + + #66CDAA + + #6495ED + + #5F9EA0 + + #556B2F + + #4B0082 + + #48D1CC + + #483D8B + + #4682B4 + + #4169E1 + + #40E0D0 + + #3CB371 + + #32CD32 + + #2F4F4F + + #2F4F4F + + #2E8B57 + + #228B22 + + #20B2AA + + #1E90FF + + #191970 + + #00FFFF + + #00FFFF + + #00FF7F + + #00FF00 + + #00FA9A + + #00CED1 + + #00BFFF + + #008B8B + + #008080 + + #008000 + + #006400 + + #0000FF + + #0000CD + + #00008B + + #000080 + + #000000 + + #222222 + #F5F5F5 + #BDBDBD + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..4639dc5 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,28 @@ + + + + + 16dp + 16dp + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..78d4c21 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,44 @@ + + + + + TikMatrix + Settings + UIAutomator service started + TikMatrix + service is running! + FastInputIME + Status: + Develop Mode + No permission to write sd card + Storage: + IP: + WAN IP: + Available SD Card Storage: + Notification Permission + Floating Window Permission + Language: + Timezone: + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..033a1d2 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,50 @@ + + + + + + + + + + diff --git a/app/src/main/res/xml/file_paths.xml b/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..cdfedc8 --- /dev/null +++ b/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/keyboard.xml b/app/src/main/res/xml/keyboard.xml new file mode 100644 index 0000000..7a88266 --- /dev/null +++ b/app/src/main/res/xml/keyboard.xml @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/method.xml b/app/src/main/res/xml/method.xml new file mode 100644 index 0000000..d83b2a2 --- /dev/null +++ b/app/src/main/res/xml/method.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 0000000..e10e8b1 --- /dev/null +++ b/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,7 @@ + + + + ip.me + 127.0.0.1 + + diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f3e6d30 --- /dev/null +++ b/build.gradle @@ -0,0 +1,23 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext { + agp_version = '8.8.0' + } + repositories { + mavenCentral() + google() + } + dependencies { + classpath "com.android.tools.build:gradle:$agp_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + mavenCentral() + google() + } +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..6906f94 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,2 @@ +./gradlew build --warning-mode all +./gradlew packageDebugAndroidTest \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..0046cb6 --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +./gradlew build +./gradlew packageDebugAndroidTest +mv app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/com.github.tikmatrix.apk +mv app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk app/build/outputs/apk/com.github.tikmatrix.test.apk diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..69af2a8 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,14 @@ +## For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +#Tue Jan 14 12:23:51 CST 2025 +android.useAndroidX=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..2c3521197d7c4586c843d1d3e9090525f1898cde GIT binary patch literal 43504 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(?T0Ra(xUH{($5eN!MR#ZihR#HxkUPe+_R8Cn`RRs(P z_^*#_XlXmGv7!4;*Y%p4nw?{bNp@UZHv1?Um8r6)Fei3p@ClJn0ECfg1hkeuUU@Or zDaPa;U3fE=3L}DooL;8f;P0ipPt0Z~9P0)lbStMS)ag54=uL9ia-Lm3nh|@(Y?B`; zx_#arJIpXH!U{fbCbI^17}6Ri*H<>OLR%c|^mh8+)*h~K8Z!9)DPf zR2h?lbDZQ`p9P;&DQ4F0sur@TMa!Y}S8irn(%d-gi0*WxxCSk*A?3lGh=gcYN?FGl z7D=Js!i~0=u3rox^eO3i@$0=n{K1lPNU zwmfjRVmLOCRfe=seV&P*1Iq=^i`502keY8Uy-WNPwVNNtJFx?IwAyRPZo2Wo1+S(xF37LJZ~%i)kpFQ3Fw=mXfd@>%+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gdaVnBH$BM{_73?znS+R z*G2VHM!Jw6#<FfJ-J%-9AuDW$@mc-Eyk~F{Jbvt` zn;(%DbBDnKIYr~|I>ZTvbH@cxUyw%bp*)OSs}lwO^HTJ2M#u5QsPF0?Jv*OVPfdKv z+t$Z5P!~jzZ~Y!d#iP?S{?M_g%Ua0Q)WawbIx+2uYpcf(7Im%W=rAu4dSceo7RZh# zN38=RmwOJQE$qbPXIuO^E`wSeJKCx3Q76irp~QS#19dusEVCWPrKhK9{7cbIMg9U} TZiJi*F`$tkWLn) literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..df97d72 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..f5feea6 --- /dev/null +++ b/gradlew @@ -0,0 +1,252 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..9d21a21 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..73622b5 --- /dev/null +++ b/install.ps1 @@ -0,0 +1,6 @@ +# adb push app\build\libs\app-test.jar /data/local/tmp +# adb push app\build\compile_app +# adb shell am instrument -w -r -e debug true -e class com.github.tikmatrix.stub.Stub com.github.tikmatrix.test/androidx.test.runner.AndroidJUnitRunner CLASSPATH=/data/local/tmp/app-test.jar / com.github.tikmatrix.stub.Stub +adb install -r -t app\build\outputs\apk\debug\app-debug.apk +adb install -r -t app\build\outputs\apk\androidTest\debug\app-debug-androidTest.apk +adb shell am instrument -w -r -e debug false -e class com.github.tikmatrix.stub.Stub com.github.tikmatrix.test/androidx.test.runner.AndroidJUnitRunner \ No newline at end of file diff --git a/release.keystore b/release.keystore new file mode 100644 index 0000000000000000000000000000000000000000..d5a1e0c49d1f013feaa23fd753239903eb066b36 GIT binary patch literal 2174 zcmb_c`8U*!9-i-PGJ_byko_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q z^l{t;EBk=?Pnc%#y_qtb)~UheP|w3Pb&Jl>ne8?s zmS$C>8bgV7lszY1aQu8r`( z$$HK6D@`z)%`*x9zQ_3#$vfU>E@Wh5tzmdP~9 z#)*)T=NBpjZ=WH4x%W=ko?2d(X`|I$new_2OypyVN@CufWu~a?=v2f>ACu4%XxJ=D z*}fffPpFI|_weIxVNy^X?@s1WQc&E4AX8{-#Aaw;xIUxvy}fNhA2oQy=aqs3@vt_7 p(WHcOusJi{XumKmp#L3MU_AfG?;&kVqqT}-*IIj`G*-;@{smCDykGzT literal 0 HcmV?d00001 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'