Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
super-appium
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
super-appium
Commits
59cb90c1
Commit
59cb90c1
authored
Aug 28, 2019
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udpate
parent
6f57a0a6
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
251 additions
and
3 deletions
+251
-3
settings.gradle
settings.gradle
+1
-1
build.gradle
stub/build.gradle
+9
-0
ArrayMap.java
stub/src/main/java/android/util/ArrayMap.java
+67
-0
build.gradle
super-appium/build.gradle
+1
-0
ViewImage.java
...ppium/src/main/java/com/virjar/superappium/ViewImage.java
+12
-0
ActivityObserver.java
...java/com/virjar/superappium/promise/ActivityObserver.java
+9
-0
FocusActivityOccurEvent.java
...m/virjar/superappium/promise/FocusActivityOccurEvent.java
+13
-0
MainThreadEventLoop.java
...a/com/virjar/superappium/promise/MainThreadEventLoop.java
+60
-0
HiddenAPIEnforcementPolicyUtils.java
...jar/superappium/util/HiddenAPIEnforcementPolicyUtils.java
+55
-0
ReflectUtil.java
...rc/main/java/com/virjar/superappium/util/ReflectUtil.java
+14
-1
XpathEvaluator.java
...va/com/virjar/superappium/xpath/model/XpathEvaluator.java
+10
-1
No files found.
settings.gradle
View file @
59cb90c1
include
':XposedDriver'
include
':XposedDriver'
,
':stub'
include
'super-appium'
include
'super-appium'
stub/build.gradle
0 → 100644
View file @
59cb90c1
apply
plugin:
'java-library'
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
compileOnly
'com.google.android:android:4.1.1.4'
}
sourceCompatibility
=
"7"
targetCompatibility
=
"7"
stub/src/main/java/android/util/ArrayMap.java
0 → 100644
View file @
59cb90c1
package
android
.
util
;
import
java.util.Collection
;
import
java.util.Map
;
import
java.util.Set
;
public
class
ArrayMap
<
K
,
V
>
implements
Map
<
K
,
V
>
{
@Override
public
int
size
()
{
return
0
;
}
@Override
public
boolean
isEmpty
()
{
return
false
;
}
@Override
public
boolean
containsKey
(
Object
o
)
{
return
false
;
}
@Override
public
boolean
containsValue
(
Object
o
)
{
return
false
;
}
@Override
public
V
get
(
Object
o
)
{
return
null
;
}
@Override
public
V
put
(
K
k
,
V
v
)
{
return
null
;
}
@Override
public
V
remove
(
Object
o
)
{
return
null
;
}
@Override
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
map
)
{
}
@Override
public
void
clear
()
{
}
@Override
public
Set
<
K
>
keySet
()
{
return
null
;
}
@Override
public
Collection
<
V
>
values
()
{
return
null
;
}
@Override
public
Set
<
Entry
<
K
,
V
>>
entrySet
()
{
return
null
;
}
}
super-appium/build.gradle
View file @
59cb90c1
...
@@ -6,6 +6,7 @@ dependencies {
...
@@ -6,6 +6,7 @@ dependencies {
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
compileOnly
'com.google.android:android:4.1.1.4'
compileOnly
'com.google.android:android:4.1.1.4'
compileOnly
'org.projectlombok:lombok:1.18.2'
compileOnly
'org.projectlombok:lombok:1.18.2'
compileOnly
project
(
':stub'
)
annotationProcessor
'org.projectlombok:lombok:1.18.2'
annotationProcessor
'org.projectlombok:lombok:1.18.2'
}
}
...
...
super-appium/src/main/java/com/virjar/superappium/ViewImage.java
View file @
59cb90c1
...
@@ -9,6 +9,9 @@ import com.virjar.superappium.traversor.Collector;
...
@@ -9,6 +9,9 @@ import com.virjar.superappium.traversor.Collector;
import
com.virjar.superappium.traversor.Evaluator
;
import
com.virjar.superappium.traversor.Evaluator
;
import
com.virjar.superappium.util.Constants
;
import
com.virjar.superappium.util.Constants
;
import
com.virjar.superappium.util.Lists
;
import
com.virjar.superappium.util.Lists
;
import
com.virjar.superappium.xpath.XpathParser
;
import
com.virjar.superappium.xpath.model.XNode
;
import
com.virjar.superappium.xpath.model.XNodes
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -183,4 +186,13 @@ public class ViewImage {
...
@@ -183,4 +186,13 @@ public class ViewImage {
}
}
return
jsonObject
.
toString
();
return
jsonObject
.
toString
();
}
}
public
ViewImages
xpath
(
String
xpath
)
{
return
XpathParser
.
compileNoError
(
xpath
).
evaluateToElement
(
new
XNodes
(
XNode
.
e
(
this
)));
}
public
String
xpath4String
(
String
xpath
)
{
return
XpathParser
.
compileNoError
(
xpath
).
evaluateToSingleString
(
new
XNodes
(
XNode
.
e
(
this
)));
}
}
}
super-appium/src/main/java/com/virjar/superappium/promise/ActivityObserver.java
0 → 100644
View file @
59cb90c1
package
com
.
virjar
.
superappium
.
promise
;
import
android.app.Activity
;
import
com.virjar.superappium.ViewImage
;
public
interface
ActivityObserver
{
void
onActivity
(
Activity
activity
,
ViewImage
viewImage
);
}
super-appium/src/main/java/com/virjar/superappium/promise/FocusActivityOccurEvent.java
0 → 100644
View file @
59cb90c1
package
com
.
virjar
.
superappium
.
promise
;
import
android.app.Activity
;
public
interface
FocusActivityOccurEvent
{
boolean
onFocusActivityOccur
(
Activity
activity
);
void
onActivityEmpty
();
//onLostFocus
void
onAppBackend
();
}
super-appium/src/main/java/com/virjar/superappium/promise/MainThreadEventLoop.java
0 → 100644
View file @
59cb90c1
package
com
.
virjar
.
superappium
.
promise
;
import
android.app.Activity
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.util.ArrayMap
;
import
com.virjar.superappium.util.ReflectUtil
;
public
class
MainThreadEventLoop
{
private
static
Object
mainThread
=
ReflectUtil
.
getMainThread
();
private
static
Handler
mainThreadHandler
=
new
Handler
(
Looper
.
getMainLooper
());
// private static LinkedList<EventTaskDriver> mTaskQueue = new LinkedList<>();
//
//
// private static class EventTaskDriver implements Runnable {
// @Override
// public void run() {
// if (mTaskQueue.size() == 0) {
// mainThreadHandler.postDelayed(this, 500);
// return;
// }
// mainThreadHandler.post(mTaskQueue.removeFirst());
// }
// }
public
static
void
runOnFocusActivity
(
FocusActivityOccurEvent
focusActivityOccurEvent
)
{
if
(
Looper
.
myLooper
()
==
Looper
.
getMainLooper
())
{
findAndFire
(
focusActivityOccurEvent
);
}
else
{
mainThreadHandler
.
post
(()
->
findAndFire
(
focusActivityOccurEvent
));
}
}
private
static
void
findAndFire
(
FocusActivityOccurEvent
focusActivityOccurEvent
)
{
ArrayMap
mActivities
=
ReflectUtil
.
getObjectField
(
mainThread
,
"mActivities"
);
Activity
topActivity
=
null
;
if
(
mActivities
.
values
().
size
()
==
0
)
{
focusActivityOccurEvent
.
onActivityEmpty
();
return
;
}
for
(
Object
activityClientRecord
:
mActivities
.
values
())
{
Activity
tempActivity
=
ReflectUtil
.
getObjectField
(
activityClientRecord
,
"activity"
);
if
(
tempActivity
.
hasWindowFocus
())
{
topActivity
=
tempActivity
;
break
;
}
}
if
(
topActivity
==
null
)
{
focusActivityOccurEvent
.
onAppBackend
();
return
;
}
focusActivityOccurEvent
.
onFocusActivityOccur
(
topActivity
);
}
}
super-appium/src/main/java/com/virjar/superappium/util/HiddenAPIEnforcementPolicyUtils.java
0 → 100644
View file @
59cb90c1
package
com
.
virjar
.
superappium
.
util
;
import
android.util.Log
;
import
java.lang.reflect.Method
;
//
// Created by Swift Gan on 2019/3/15.
//
//bypass hidden api on Android 9 - 10
public
class
HiddenAPIEnforcementPolicyUtils
{
private
static
Method
forNameMethod
;
private
static
Method
getMethodMethod
;
static
Class
vmRuntimeClass
;
static
Method
addWhiteListMethod
;
static
Object
vmRuntime
;
static
{
try
{
getMethodMethod
=
Class
.
class
.
getDeclaredMethod
(
"getDeclaredMethod"
,
String
.
class
,
Class
[].
class
);
forNameMethod
=
Class
.
class
.
getDeclaredMethod
(
"forName"
,
String
.
class
);
vmRuntimeClass
=
(
Class
)
forNameMethod
.
invoke
(
null
,
"dalvik.system.VMRuntime"
);
addWhiteListMethod
=
(
Method
)
getMethodMethod
.
invoke
(
vmRuntimeClass
,
"setHiddenApiExemptions"
,
new
Class
[]{
String
[].
class
});
Method
getVMRuntimeMethod
=
(
Method
)
getMethodMethod
.
invoke
(
vmRuntimeClass
,
"getRuntime"
,
null
);
vmRuntime
=
getVMRuntimeMethod
.
invoke
(
null
);
}
catch
(
Exception
e
)
{
Log
.
e
(
"ReflectionUtils"
,
"error get methods"
,
e
);
}
}
public
static
boolean
passApiCheck
()
{
try
{
addReflectionWhiteList
(
"Landroid/"
,
"Lcom/android/"
,
"Ljava/lang/"
,
"Ldalvik/system/"
,
"Llibcore/io/"
,
"Lsun/misc/"
);
return
true
;
}
catch
(
Throwable
throwable
)
{
Log
.
w
(
Constants
.
TAG
,
"pass Hidden API enforcement policy failed"
,
throwable
);
return
false
;
}
}
//methidSigs like Lcom/swift/sandhook/utils/ReflectionUtils;->vmRuntime:java/lang/Object; (from hidden policy list)
private
static
void
addReflectionWhiteList
(
String
...
memberSigs
)
throws
Throwable
{
addWhiteListMethod
.
invoke
(
vmRuntime
,
new
Object
[]{
memberSigs
});
}
}
super-appium/src/main/java/com/virjar/superappium/util/ReflectUtil.java
View file @
59cb90c1
...
@@ -3,6 +3,7 @@ package com.virjar.superappium.util;
...
@@ -3,6 +3,7 @@ package com.virjar.superappium.util;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.app.Application
;
import
android.app.Application
;
import
android.os.Handler
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Constructor
;
...
@@ -33,6 +34,15 @@ public class ReflectUtil {
...
@@ -33,6 +34,15 @@ public class ReflectUtil {
return
(
Application
)
Class
.
forName
(
"android.app.ActivityThread"
).
getMethod
(
"currentApplication"
).
invoke
(
null
);
return
(
Application
)
Class
.
forName
(
"android.app.ActivityThread"
).
getMethod
(
"currentApplication"
).
invoke
(
null
);
}
}
@SuppressLint
(
"PrivateApi"
)
public
static
Object
getMainThread
()
{
try
{
return
Class
.
forName
(
"android.app.ActivityThread"
).
getMethod
(
"currentActivityThread"
).
invoke
(
null
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
static
void
makeAccessible
(
Field
field
)
{
private
static
void
makeAccessible
(
Field
field
)
{
if
(!
Modifier
.
isPublic
(
field
.
getModifiers
()))
{
if
(!
Modifier
.
isPublic
(
field
.
getModifiers
()))
{
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
...
@@ -52,7 +62,7 @@ public class ReflectUtil {
...
@@ -52,7 +62,7 @@ public class ReflectUtil {
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
get
FieldValue
(
Object
object
,
String
fieldName
)
{
public
static
<
T
>
T
get
ObjectField
(
Object
object
,
String
fieldName
)
{
try
{
try
{
return
(
T
)
findField
(
object
.
getClass
(),
fieldName
).
get
(
object
);
return
(
T
)
findField
(
object
.
getClass
(),
fieldName
).
get
(
object
);
}
catch
(
IllegalAccessException
e
)
{
}
catch
(
IllegalAccessException
e
)
{
...
@@ -934,4 +944,7 @@ public class ReflectUtil {
...
@@ -934,4 +944,7 @@ public class ReflectUtil {
}
}
return
toClass
.
isAssignableFrom
(
cls
);
return
toClass
.
isAssignableFrom
(
cls
);
}
}
}
}
super-appium/src/main/java/com/virjar/superappium/xpath/model/XpathEvaluator.java
View file @
59cb90c1
...
@@ -21,7 +21,16 @@ public abstract class XpathEvaluator {
...
@@ -21,7 +21,16 @@ public abstract class XpathEvaluator {
return
XpathUtil
.
transformToString
(
evaluate
(
xNodes
));
return
XpathUtil
.
transformToString
(
evaluate
(
xNodes
));
}
}
public
List
<
ViewImage
>
evaluateToElement
(
XNodes
xNodes
)
{
public
String
evaluateToSingleString
(
XNodes
xNodes
)
{
List
<
String
>
strings
=
evaluateToString
(
xNodes
);
if
(
strings
.
size
()
==
0
)
{
return
null
;
}
return
strings
.
get
(
0
);
}
public
ViewImages
evaluateToElement
(
XNodes
xNodes
)
{
return
XpathUtil
.
transformToElement
(
evaluate
(
xNodes
));
return
XpathUtil
.
transformToElement
(
evaluate
(
xNodes
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment