This commit is contained in:
2022-09-20 10:31:01 +08:00
parent 2b44a4e262
commit 383f8a9a80
139 changed files with 501 additions and 3423 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:allowBackup="false"
android:supportsRtl="true">
@@ -7,6 +7,7 @@ import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -43,6 +44,7 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayout());
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
mContext = this;
setStatusBarColor(R.color.colorPrimaryDark);
initView(savedInstanceState);
@@ -0,0 +1,51 @@
package com.dahe.mylibrary.utils;
import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @ClassName RootCheck
* @Author 用户
* @Date 2022/9/20 9:37
* @Description 判断Android设备是否拥有Root权限
*/
public class RootCheck {
private final static String TAG = "RootUtil";
public static boolean isRoot() {
String binPath = "/system/bin/su";
String xBinPath = "/system/xbin/su";
if (new File(binPath).exists() && isExecutable(binPath))
return true;
if (new File(xBinPath).exists() && isExecutable(xBinPath))
return true;
return false;
}
private static boolean isExecutable(String filePath) {
Process p = null;
try {
p = Runtime.getRuntime().exec("ls -l " + filePath);
// 获取返回内容
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String str = in.readLine();
Log.i(TAG, str);
if (str != null && str.length() >= 4) {
char flag = str.charAt(3);
if (flag == 's' || flag == 'x')
return true;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (p != null) {
p.destroy();
}
}
return false;
}
}