Skip to content

Commit

Permalink
Update uiautomator lib (#59)
Browse files Browse the repository at this point in the history
* use github workflows to replace .travis.yml
* upgrade gradle from 4.6 to 7.3.3
* update androidx.test.uiautomator:uiautomator from 2.2.0 to 2.3.0
* update minSdkVersion from 18 to 19, compileSdkVersion from 28 to 34
* update jdk from 8 to 17
* remove permission READ_PHONE_STATE
  • Loading branch information
codeskyblue authored Apr 8, 2024
1 parent a6f6d16 commit 80231ec
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 64 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Android CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

# ref: https://github.com/marketplace/actions/automated-build-android-app-with-github-action
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- name: set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'oracle'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Print generated version
run: ./gradlew --quiet androidGitVersion

- name: Build with Gradle
run: ./gradlew build

- name: Build apk debug project (APK)
run: ./gradlew packageDebugAndroidTest
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:

runs-on: ubuntu-latest

# ref: https://github.com/marketplace/actions/automated-build-android-app-with-github-action
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- name: set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'oracle'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Print generated version
run: ./gradlew --quiet androidGitVersion

- name: Build with Gradle
run: ./gradlew build

- name: Build apk debug project (APK)
run: ./gradlew packageDebugAndroidTest

- name: Copy Apks to dist folder
run: |
rm -fr dist && mkdir -p dist
mv app/build/outputs/apk/debug/app-debug.apk dist/app-uiautomator.apk
mv app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk dist/app-uiautomator-test.apk
- name: Publish APKs
uses: actions/upload-artifact@v3
with:
name: app-uiautomator
path: dist/



3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ local.properties
build
captures
.idea
gradle.properties
app/app.iml
android-uiautomator-server.iml
*.iml
.settings/
.project
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Purpose
[![Build Status](https://travis-ci.org/openatx/android-uiautomator-server.svg?branch=master)](https://travis-ci.org/openatx/android-uiautomator-server)
[![Android CI](https://github.com/openatx/android-uiautomator-server/actions/workflows/android.yml/badge.svg)](https://github.com/openatx/android-uiautomator-server/actions/workflows/android.yml)

[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
Expand Down Expand Up @@ -171,3 +171,4 @@ Clipboard, Thanks to @fplust
- https://github.com/willerce/WhatsInput
- https://github.com/senzhk/ADBKeyBoard
- https://github.com/amotzte/android-mock-location-for-development
- https://github.com/gladed/gradle-android-git-version
18 changes: 11 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,26 @@ buildscript {
}

plugins {
id 'com.gladed.androidgitversion' version '0.4.3'
id 'com.gladed.androidgitversion' version '0.4.14'
}

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 34

// version code history
// 1: original version
// 2: update all dependencies to latest
// 6: input method, battery,rotation monitor
androidGitVersion {
baseCode 1
}

defaultConfig {
applicationId "com.github.uiautomator"
minSdkVersion 18
targetSdkVersion 28
minSdkVersion 19
targetSdkVersion 32
versionCode androidGitVersion.code()
versionName androidGitVersion.name()
}
Expand Down Expand Up @@ -102,12 +104,14 @@ dependencies {

// test
androidTestImplementation 'androidx.test:runner:1.3.0'

androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.core:core:1.3.0'
androidTestImplementation 'androidx.annotation:annotation:1.1.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'

implementation project(':permission')
}
Expand Down
Binary file removed app/libs/SaaS_AppAnalytics_Android_SDK_V4.0.39.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* @author xiaocong@gmail.com
*/
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = 18)
@SdkSuppress(minSdkVersion = 19)
public class Stub {
private final String TAG = "UIAUTOMATOR";
private static final int LAUNCH_TIMEOUT = 5000;
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTask">
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -108,7 +109,6 @@
tools:ignore="MockLocation,ProtectedPermissions" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
Expand All @@ -117,5 +117,6 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />-->

</manifest>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:7.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.useAndroidX=true
android.suppressUnsupportedCompileSdk=33,34
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Oct 26 09:47:17 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
9 changes: 3 additions & 6 deletions permission/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 34

defaultConfig {
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
minSdkVersion 19
targetSdkVersion 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
14 changes: 11 additions & 3 deletions permission/src/main/java/com/android/permission/rom/VivoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ public static int getFloatPermissionStatus(Context context) {
if (cursor != null) {
cursor.getColumnNames();
if (cursor.moveToFirst()) {
int currentmode = cursor.getInt(cursor.getColumnIndex("currentlmode"));
int columnIndex = cursor.getColumnIndex("currentlmode");
int currentMode = 0;
if (columnIndex != -1) {
currentMode = cursor.getInt(columnIndex);
}
cursor.close();
return currentmode;
return currentMode;
} else {
cursor.close();
return getFloatPermissionStatus2(context);
Expand All @@ -134,7 +138,11 @@ private static int getFloatPermissionStatus2(Context context) {
.query(uri2, null, selection, selectionArgs, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
int currentmode = cursor.getInt(cursor.getColumnIndex("currentmode"));
int columnIndex = cursor.getColumnIndex("currentmode");
int currentmode = 0;
if (columnIndex != -1) {
cursor.getInt(columnIndex);
}
cursor.close();
return currentmode;
} else {
Expand Down

0 comments on commit 80231ec

Please sign in to comment.