提交 9e9aef89 编写于 作者: F fancy

添加Root检测

上级 6b1093da
......@@ -16,6 +16,7 @@ import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.base.BaseMVPActivity
import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.bbs.main.BBSMainActivity
import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.calendar.CalendarMainActivity
import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.clouddrive.CloudDriveActivity
import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.clouddrive.v2.CloudDiskActivity
import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.cms.index.CMSIndexActivity
import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.meeting.main.MeetingMainActivity
import net.zoneland.x.bpm.mobile.v1.zoneXBPM.app.o2.webview.TaskWebViewActivity
......@@ -122,7 +123,8 @@ class O2InstantMessageActivity : BaseMVPActivity<O2InstantMessageContract.View,
}
}else if (type.startsWith("attachment_")) {
setLinkStyle(textView) {
go<CloudDriveActivity>()
// go<CloudDriveActivity>()
go<CloudDiskActivity>()
}
}else if (type.startsWith("calendar_")) {
setLinkStyle(textView) {
......
......@@ -120,21 +120,25 @@ class LaunchActivity : BaseMVPActivity<LaunchContract.View, LaunchContract.Prese
fun start() {
tv_launch_status.text = getString(R.string.launch_start) //开始启动
circleProgressBar_launch.visible()
PermissionRequester(this)
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.o2Subscribe {
onNext { (granted, shouldShowRequestPermissionRationale, deniedPermissions) ->
Log.d("LaunchActivity", "granted:$granted, show:$shouldShowRequestPermissionRationale, deniedList:$deniedPermissions")
if (!granted) {
O2DialogSupport.openAlertDialog(this@LaunchActivity, "非常抱歉,应用需要存储权限才能正常运行, 马上去设置", { permissionSetting() })
} else {
checkNetwork()
if (CheckRoot.isDeviceRooted()) {
O2DialogSupport.openAlertDialog(this, "当前是Root环境,App禁止使用!")
}else {
PermissionRequester(this)
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.o2Subscribe {
onNext { (granted, shouldShowRequestPermissionRationale, deniedPermissions) ->
Log.d("LaunchActivity", "granted:$granted, show:$shouldShowRequestPermissionRationale, deniedList:$deniedPermissions")
if (!granted) {
O2DialogSupport.openAlertDialog(this@LaunchActivity, "非常抱歉,应用需要存储权限才能正常运行, 马上去设置", { permissionSetting() })
} else {
checkNetwork()
}
}
onError { e, _ ->
Log.e("LaunchActivity", "检查权限出错", e)
}
}
onError { e, _ ->
Log.e("LaunchActivity", "检查权限出错", e)
}
}
}
}
/**
......
......@@ -81,7 +81,8 @@ class IndexFragment : BaseMVPViewPagerFragment<IndexContract.View, IndexContract
ApplicationEnum.READCOMPLETED.key -> activity.go<ReadCompletedListActivity>()
ApplicationEnum.BBS.key -> activity.go<BBSMainActivity>()
ApplicationEnum.CMS.key -> activity.go<CMSIndexActivity>()
ApplicationEnum.YUNPAN.key -> activity.go<CloudDriveActivity>()
ApplicationEnum.YUNPAN.key -> activity.go<CloudDiskActivity>()
// ApplicationEnum.YUNPAN.key -> activity.go<CloudDriveActivity>()
ApplicationEnum.clouddisk.key -> activity.go<CloudDiskActivity>()
ApplicationEnum.MEETING.key -> activity.go<MeetingMainActivity>()
ApplicationEnum.ATTENDANCE.key -> activity.go<AttendanceMainActivity>()
......
......@@ -35,10 +35,10 @@ class MyAppPresenter : BasePresenterImpl<MyAppContract.View>(), MyAppContract.Pr
obj.appTitle = it.name
result.add(obj)
}
val newCloudDiskApp = MyAppListObject()
newCloudDiskApp.appId = ApplicationEnum.clouddisk.key
newCloudDiskApp.appTitle = ApplicationEnum.clouddisk.appName
result.add(newCloudDiskApp)
// val newCloudDiskApp = MyAppListObject()
// newCloudDiskApp.appId = ApplicationEnum.clouddisk.key
// newCloudDiskApp.appTitle = ApplicationEnum.clouddisk.appName
// result.add(newCloudDiskApp)
service.findAllPortalList()
}
?.flatMap { list ->
......@@ -66,10 +66,10 @@ class MyAppPresenter : BasePresenterImpl<MyAppContract.View>(), MyAppContract.Pr
obj.appTitle = it.name
result.add(obj)
}
val newCloudDiskApp = MyAppListObject()
newCloudDiskApp.appId = ApplicationEnum.clouddisk.key
newCloudDiskApp.appTitle = ApplicationEnum.clouddisk.appName
result.add(newCloudDiskApp)
// val newCloudDiskApp = MyAppListObject()
// newCloudDiskApp.appId = ApplicationEnum.clouddisk.key
// newCloudDiskApp.appTitle = ApplicationEnum.clouddisk.appName
// result.add(newCloudDiskApp)
portalList.filter { portal -> portal.enable }.map {
val obj = MyAppListObject()
obj.appId = it.id
......
package net.zoneland.x.bpm.mobile.v1.zoneXBPM.utils;
/**
* Created by fancyLou on 2020-09-28.
* Copyright © 2020 O2. All rights reserved.
*/
import android.util.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
public class CheckRoot {
private static String LOG_TAG = CheckRoot.class.getName();
public static boolean isDeviceRooted() {
if (checkDeviceDebuggable()) {
return true;
}//check buildTags
if (checkSuperuserApk()) {
return true;
}//Superuser.apk
//if (checkRootPathSU()){return true;}//find su in some path
//if (checkRootWhichSU()){return true;}//find su use 'which'
if (checkBusybox()) {
return true;
}//find su use 'which'
if (checkAccessRootData()) {
return true;
}//find su use 'which'
if (checkGetRootAuth()) {
return true;
}//exec su
return false;
}
public static boolean checkDeviceDebuggable() {
String buildTags = android.os.Build.TAGS;
if (buildTags != null && buildTags.contains("test-keys")) {
Log.i(LOG_TAG, "buildTags=" + buildTags);
return true;
}
return false;
}
public static boolean checkSuperuserApk() {
try {
File file = new File("/system/app/Superuser.apk");
if (file.exists()) {
Log.i(LOG_TAG, "/system/app/Superuser.apk exist");
return true;
}
} catch (Exception e) {
}
return false;
}
public static synchronized boolean checkGetRootAuth() {
Process process = null;
DataOutputStream os = null;
try {
Log.i(LOG_TAG, "to exec su");
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes("exit\n");
os.flush();
int exitValue = process.waitFor();
Log.i(LOG_TAG, "exitValue=" + exitValue);
if (exitValue == 0) {
return true;
} else {
return false;
}
} catch (Exception e) {
Log.i(LOG_TAG, "Unexpected error - Here is what I know: "
+ e.getMessage());
return false;
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static synchronized boolean checkBusybox() {
try {
Log.i(LOG_TAG, "to exec busybox df");
String[] strCmd = new String[]{"busybox", "df"};
ArrayList<String> execResult = executeCommand(strCmd);
if (execResult != null) {
Log.i(LOG_TAG, "execResult=" + execResult.toString());
return true;
} else {
Log.i(LOG_TAG, "execResult=null");
return false;
}
} catch (Exception e) {
Log.i(LOG_TAG, "Unexpected error - Here is what I know: "
+ e.getMessage());
return false;
}
}
public static ArrayList<String> executeCommand(String[] shellCmd) {
String line = null;
ArrayList<String> fullResponse = new ArrayList<String>();
Process localProcess = null;
try {
Log.i(LOG_TAG, "to shell exec which for find su :");
localProcess = Runtime.getRuntime().exec(shellCmd);
} catch (Exception e) {
return null;
}
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(localProcess.getOutputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(localProcess.getInputStream()));
try {
while ((line = in.readLine()) != null) {
Log.i(LOG_TAG, "–> Line received: " + line);
fullResponse.add(line);
}
} catch (Exception e) {
e.printStackTrace();
}
Log.i(LOG_TAG, "–> Full response was: " + fullResponse);
return fullResponse;
}
public static synchronized boolean checkAccessRootData() {
try {
Log.i(LOG_TAG, "to write /data");
String fileContent = "test_ok";
Boolean writeFlag = writeFile("/data/su_test", fileContent);
if (writeFlag) {
Log.i(LOG_TAG, "write ok");
} else {
Log.i(LOG_TAG, "write failed");
}
Log.i(LOG_TAG, "to read /data");
String strRead = readFile("/data/su_test");
Log.i(LOG_TAG, "strRead=" + strRead);
if (fileContent.equals(strRead)) {
return true;
} else {
return false;
}
} catch (Exception e) {
Log.i(LOG_TAG, "Unexpected error - Here is what I know: "
+ e.getMessage());
return false;
}
}
//写文件
public static Boolean writeFile(String fileName, String message) {
try {
FileOutputStream fout = new FileOutputStream(fileName);
byte[] bytes = message.getBytes();
fout.write(bytes);
fout.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
//读文件
public static String readFile(String fileName) {
File file = new File(fileName);
try {
FileInputStream fis = new FileInputStream(file);
byte[] bytes = new byte[1024];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int len;
while ((len = fis.read(bytes)) > 0) {
bos.write(bytes, 0, len);
}
String result = new String(bos.toByteArray());
Log.i(LOG_TAG, result);
return result;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册