Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
R
RatelExtension
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
ratel
RatelExtension
Commits
06cb5707
Commit
06cb5707
authored
May 26, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add FileExplorer
parent
bee54ef3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
1 deletion
+107
-1
FileExploreHandler.java
.../api/extension/superappium/sekiro/FileExploreHandler.java
+97
-0
SekiroStarter.java
...ratel/api/extension/superappium/sekiro/SekiroStarter.java
+10
-1
No files found.
src/main/java/com/virjar/ratel/api/extension/superappium/sekiro/FileExploreHandler.java
0 → 100644
View file @
06cb5707
package
com
.
virjar
.
ratel
.
api
.
extension
.
superappium
.
sekiro
;
import
android.util.Log
;
import
com.virjar.ratel.api.RatelToolKit
;
import
com.virjar.ratel.api.extension.superappium.SuperAppium
;
import
com.virjar.sekiro.api.SekiroRequest
;
import
com.virjar.sekiro.api.SekiroRequestHandler
;
import
com.virjar.sekiro.api.SekiroResponse
;
import
com.virjar.sekiro.api.databind.AutoBind
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
external.org.apache.commons.lang3.StringUtils
;
public
class
FileExploreHandler
implements
SekiroRequestHandler
{
@AutoBind
(
defaultStringValue
=
"/"
)
private
String
path
;
@AutoBind
(
defaultStringValue
=
"get"
)
private
String
op
;
@Override
public
void
handleRequest
(
SekiroRequest
sekiroRequest
,
SekiroResponse
sekiroResponse
)
{
if
(
StringUtils
.
isBlank
(
path
))
{
path
=
"/"
;
}
String
base
=
RatelToolKit
.
sContext
.
getFilesDir
().
getParentFile
().
getAbsolutePath
();
if
(
path
.
startsWith
(
base
))
{
path
=
path
.
substring
(
base
.
length
());
}
File
targetFile
=
new
File
(
RatelToolKit
.
sContext
.
getFilesDir
().
getParent
());
if
(!
"/"
.
equals
(
path
))
{
targetFile
=
new
File
(
RatelToolKit
.
sContext
.
getFilesDir
().
getParentFile
(),
path
);
}
if
(
"get"
.
equalsIgnoreCase
(
op
))
{
if
(!
targetFile
.
exists
())
{
sekiroResponse
.
failed
(
404
,
"the file :"
+
targetFile
.
getAbsolutePath
()
+
" not exist"
);
return
;
}
handleGet
(
sekiroRequest
,
sekiroResponse
,
targetFile
);
}
else
if
(
"post"
.
equalsIgnoreCase
(
op
))
{
if
(!
targetFile
.
exists
())
{
sekiroResponse
.
failed
(
404
,
"the file :"
+
targetFile
.
getAbsolutePath
()
+
" not exist"
);
return
;
}
handlePost
(
sekiroRequest
,
sekiroResponse
,
targetFile
);
}
else
if
(
"put"
.
equalsIgnoreCase
(
op
))
{
handlePut
(
sekiroRequest
,
sekiroResponse
,
targetFile
);
}
}
private
void
handleGet
(
SekiroRequest
sekiroRequest
,
SekiroResponse
sekiroResponse
,
File
targetFile
)
{
if
(
targetFile
.
isDirectory
())
{
List
<
String
>
ret
=
new
ArrayList
<>();
String
[]
list
=
targetFile
.
list
();
if
(
list
==
null
)
{
sekiroResponse
.
failed
(
"can not read dir file: "
+
targetFile
.
getAbsolutePath
());
return
;
}
String
base
=
RatelToolKit
.
sContext
.
getFilesDir
().
getParentFile
().
getAbsolutePath
();
for
(
String
str
:
list
)
{
if
(
str
.
startsWith
(
base
))
{
ret
.
add
(
str
.
substring
(
base
.
length
()));
}
else
{
ret
.
add
(
str
);
}
}
sekiroResponse
.
success
(
ret
);
return
;
}
if
(!
targetFile
.
canRead
())
{
sekiroResponse
.
failed
(
"can not read file: "
+
targetFile
.
getAbsolutePath
());
return
;
}
try
{
sekiroResponse
.
sendFile
(
targetFile
);
}
catch
(
IOException
e
)
{
Log
.
e
(
SuperAppium
.
TAG
,
"read filed failed"
,
e
);
sekiroResponse
.
failed
(
"can not read file: "
+
targetFile
.
getAbsolutePath
());
}
}
private
void
handlePost
(
SekiroRequest
sekiroRequest
,
SekiroResponse
sekiroResponse
,
File
targetFile
)
{
sekiroResponse
.
failed
(
"not implement now"
);
}
private
void
handlePut
(
SekiroRequest
sekiroRequest
,
SekiroResponse
sekiroResponse
,
File
targetFile
)
{
sekiroResponse
.
failed
(
"not implement now"
);
}
}
src/main/java/com/virjar/ratel/api/extension/superappium/sekiro/SekiroStarter.java
View file @
06cb5707
...
...
@@ -14,20 +14,25 @@ public class SekiroStarter {
private
static
final
String
dumpTopFragment
=
"dumpFragment"
;
private
static
final
String
screenShot
=
"screenShot"
;
private
static
final
String
executeJsOnWebView
=
"ExecuteJsOnWebView"
;
private
static
final
String
fileExplore
=
"fileExplore"
;
private
static
boolean
isStarted
=
false
;
private
static
SekiroClient
defaultSekiroClient
=
null
;
public
static
void
startService
(
String
host
,
int
port
,
String
token
)
{
if
(
isStarted
)
{
return
;
}
Log
.
i
(
SuperAppium
.
TAG
,
"start a supperAppium client: "
+
token
);
PageTriggerManager
.
getTopFragment
(
"insureComponentStarted"
);
SekiroClient
.
start
(
host
,
port
,
token
,
sekiroGroup
)
defaultSekiroClient
=
SekiroClient
.
start
(
host
,
port
,
token
,
sekiroGroup
)
.
registerHandler
(
dumpTopActivity
,
new
DumpTopActivityHandler
())
.
registerHandler
(
dumpTopFragment
,
new
DumpTopFragmentHandler
())
.
registerHandler
(
screenShot
,
new
ScreenShotHandler
())
.
registerHandler
(
executeJsOnWebView
,
new
ExecuteJsOnWebViewHandler
())
.
registerHandler
(
fileExplore
,
new
FileExploreHandler
())
;
isStarted
=
true
;
...
...
@@ -36,4 +41,8 @@ public class SekiroStarter {
public
static
void
startService
(
String
host
,
int
port
)
{
startService
(
host
,
port
,
UUID
.
randomUUID
().
toString
());
}
public
static
SekiroClient
getDefaultSekiroClient
()
{
return
defaultSekiroClient
;
}
}
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