Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
4cb85979
Commit
4cb85979
authored
Dec 18, 2018
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
无root判断
parent
b0b74fdf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+10
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
4cb85979
...
@@ -86,6 +86,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -86,6 +86,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
private
static
final
int
COPY_SO_OK
=
0
;
private
static
final
int
COPY_SO_OK
=
0
;
private
static
final
int
COPY_SO_EXCEPTION
=
1
;
private
static
final
int
COPY_SO_EXCEPTION
=
1
;
private
static
final
int
COPY_SO_NO_ROOT
=
2
;
public
SettingFragment
()
{
public
SettingFragment
()
{
...
@@ -371,6 +372,11 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -371,6 +372,11 @@ public class SettingFragment extends PreferenceFragmentPlus {
try
{
try
{
String
cmd
=
"chmod -R 777 "
+
soFile
.
getAbsolutePath
();
String
cmd
=
"chmod -R 777 "
+
soFile
.
getAbsolutePath
();
process
=
Runtime
.
getRuntime
().
exec
(
"su"
);
//切换到root帐号
process
=
Runtime
.
getRuntime
().
exec
(
"su"
);
//切换到root帐号
if
(
process
==
null
){
me
.
what
=
COPY_SO_NO_ROOT
;
handler
.
sendMessage
(
me
);
return
;
}
os
=
new
DataOutputStream
(
process
.
getOutputStream
());
os
=
new
DataOutputStream
(
process
.
getOutputStream
());
os
.
writeBytes
(
cmd
+
"\n"
);
os
.
writeBytes
(
cmd
+
"\n"
);
os
.
writeBytes
(
"exit\n"
);
os
.
writeBytes
(
"exit\n"
);
...
@@ -395,6 +401,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -395,6 +401,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
if
(
process
!=
null
)
process
.
destroy
();
process
.
destroy
();
}
}
...
@@ -419,6 +426,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -419,6 +426,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
case
COPY_SO_EXCEPTION:
case
COPY_SO_EXCEPTION:
Toast
.
makeText
(
getActivity
(),
"替换失败,原因为"
+
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getActivity
(),
"替换失败,原因为"
+
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
break
;
break
;
case
COPY_SO_NO_ROOT:
Toast
.
makeText
(
getActivity
(),
"没有root权限"
,
Toast
.
LENGTH_SHORT
).
show
();
break
;
}
}
}
}
};
};
...
...
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