diff --git a/PermissionManager/.gitignore b/PermissionManager/.gitignore
new file mode 100644
index 00000000..aa724b77
--- /dev/null
+++ b/PermissionManager/.gitignore
@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+local.properties
diff --git a/PermissionManager/.idea/.gitignore b/PermissionManager/.idea/.gitignore
new file mode 100644
index 00000000..26d33521
--- /dev/null
+++ b/PermissionManager/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/PermissionManager/.idea/compiler.xml b/PermissionManager/.idea/compiler.xml
new file mode 100644
index 00000000..fb7f4a8a
--- /dev/null
+++ b/PermissionManager/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/.idea/gradle.xml b/PermissionManager/.idea/gradle.xml
new file mode 100644
index 00000000..526b4c25
--- /dev/null
+++ b/PermissionManager/.idea/gradle.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/.idea/misc.xml b/PermissionManager/.idea/misc.xml
new file mode 100644
index 00000000..652c48cb
--- /dev/null
+++ b/PermissionManager/.idea/misc.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/.gitignore b/PermissionManager/app/.gitignore
new file mode 100644
index 00000000..42afabfd
--- /dev/null
+++ b/PermissionManager/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/PermissionManager/app/build.gradle b/PermissionManager/app/build.gradle
new file mode 100644
index 00000000..4147f11e
--- /dev/null
+++ b/PermissionManager/app/build.gradle
@@ -0,0 +1,53 @@
+plugins {
+ id 'com.android.application'
+}
+
+android {
+ compileSdk 31
+
+ defaultConfig {
+ applicationId "com.linux.permissionmanager"
+ minSdk 23
+ targetSdk 31
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ externalNativeBuild {
+ cmake {
+ cppFlags '-std=c++17'
+ abiFilters "arm64-v8a" //需要什么构架的so,就在这边添加即
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ externalNativeBuild {
+ cmake {
+ path file('src/main/cpp/CMakeLists.txt')
+ version '3.18.1'
+ }
+ }
+ buildFeatures {
+ viewBinding true
+ }
+}
+
+dependencies {
+
+ implementation 'androidx.appcompat:appcompat:1.4.1'
+ implementation 'com.google.android.material:material:1.5.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+}
\ No newline at end of file
diff --git a/PermissionManager/app/proguard-rules.pro b/PermissionManager/app/proguard-rules.pro
new file mode 100644
index 00000000..481bb434
--- /dev/null
+++ b/PermissionManager/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/PermissionManager/app/src/androidTest/java/com/linux/permissionmanager/ExampleInstrumentedTest.java b/PermissionManager/app/src/androidTest/java/com/linux/permissionmanager/ExampleInstrumentedTest.java
new file mode 100644
index 00000000..e63884ad
--- /dev/null
+++ b/PermissionManager/app/src/androidTest/java/com/linux/permissionmanager/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.linux.permissionmanager;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.linux.permissionmanager", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/AndroidManifest.xml b/PermissionManager/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..882167a7
--- /dev/null
+++ b/PermissionManager/app/src/main/AndroidManifest.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/cpp/CMakeLists.txt b/PermissionManager/app/src/main/cpp/CMakeLists.txt
new file mode 100644
index 00000000..e021e239
--- /dev/null
+++ b/PermissionManager/app/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,53 @@
+# For more information about using CMake with Android Studio, read the
+# documentation: https://d.android.com/studio/projects/add-native-code.html
+
+# Sets the minimum version of CMake required to build the native library.
+
+cmake_minimum_required(VERSION 3.18.1)
+
+# Declares and names the project.
+
+project("permissionmanager")
+
+# Creates and names a library, sets it as either STATIC
+# or SHARED, and provides the relative paths to its source code.
+# You can define multiple libraries, and CMake builds them for you.
+# Gradle automatically packages shared libraries with your APK.
+
+add_library( # Sets the name of the library.
+ permissionmanager
+
+ # Sets the library as a shared library.
+ SHARED
+
+ # Provides a relative path to your source file(s).
+ ../../../../../testRoot/process64_inject.cpp
+ ../../../../../testRoot/adb64_helper.cpp
+ ../../../../../testRoot/ptrace_arm64_utils.cpp
+ ../../../../../testRoot/su_install_helper.cpp
+ ../../../../../testRoot/base64.cpp
+ root.cpp)
+
+# Searches for a specified prebuilt library and stores the path as a
+# variable. Because CMake includes system libraries in the search path by
+# default, you only need to specify the name of the public NDK library
+# you want to add. CMake verifies that the library exists before
+# completing its build.
+
+find_library( # Sets the name of the path variable.
+ log-lib
+
+ # Specifies the name of the NDK library that
+ # you want CMake to locate.
+ log)
+
+# Specifies libraries CMake should link to your target library. You
+# can link multiple libraries, such as libraries you define in this
+# build script, prebuilt third-party libraries, or system libraries.
+
+target_link_libraries( # Specifies the target library.
+ permissionmanager
+
+ # Links the target library to the log library
+ # included in the NDK.
+ ${log-lib})
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/cpp/root.cpp b/PermissionManager/app/src/main/cpp/root.cpp
new file mode 100644
index 00000000..b62dfaf3
--- /dev/null
+++ b/PermissionManager/app/src/main/cpp/root.cpp
@@ -0,0 +1,304 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../../testRoot/testRoot.h"
+#include "../../../../../testRoot/kernel_root_helper.h"
+#include "../../../../../testRoot/process64_inject.h"
+#include "../../../../../testRoot/adb64_helper.h"
+#include "../../../../../testRoot/init64_helper.h"
+#include "../../../../../testRoot/su_install_helper.h"
+
+using namespace std;
+
+std::string g_last_su_full_path;
+
+string getCapabilityInfo()
+{
+ __uid_t now_uid, now_euid, now_suid;
+ if (getresuid(&now_uid, &now_euid, &now_suid)) {
+ return "FAILED getresuid()";
+ }
+
+
+ __gid_t now_gid, now_egid, now_sgid;
+ if (getresgid(&now_gid, &now_egid, &now_sgid)) {
+ return "FAILED getresgid()";
+ }
+
+ stringstream sstrCapInfo;
+ sstrCapInfo<< "now_uid="<pid = getpid();
+ cap_header->version = _LINUX_CAPABILITY_VERSION_3; //_1、_2、_3
+
+ if (capget(cap_header, cap_data) < 0) {
+ return "FAILED capget()";
+ // perror("FAILED capget()");
+ //exit(1);
+ }
+ sstrCapInfo << "Cap data effective:"<<(uint64_t *) cap_data->effective<<", permitted:"<<(uint64_t *) cap_data->permitted<<", inheritable:"<<(uint64_t *) cap_data->inheritable<<"\n";
+ sstrCapInfo << "My native check SELinux: "<< (kernel_root::is_disable_selinux_status() ? "0" : "1") <<"\n";
+
+ FILE * fp = popen("getenforce", "r");
+ if (fp)
+ {
+ char cmd[512] = { 0 };
+ fread(cmd, 1, sizeof(cmd), fp);
+ pclose(fp);
+
+ sstrCapInfo<< "Read system SELinux: "<< cmd;
+ }
+
+ return sstrCapInfo.str();
+}
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_getCapabilityInfo(
+ JNIEnv* env,
+ jobject /* this */) {
+
+ return env->NewStringUTF(getCapabilityInfo().c_str());
+}
+
+extern "C" JNIEXPORT jint JNICALL
+Java_com_linux_permissionmanager_MainActivity_getRoot(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey) {
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+
+ return kernel_root::get_root(strRootKey.c_str());
+}
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_runRootCmd(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey,
+ jstring cmd) {
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+
+ str1 = env->GetStringUTFChars(cmd, 0);
+ string strCmd= str1;
+ env->ReleaseStringUTFChars(cmd, str1);
+
+ char szResult[0x1000] = {0};
+ ssize_t ret = kernel_root::safe_run_root_cmd(strRootKey.c_str(), strCmd.c_str(), szResult, sizeof(szResult));
+ stringstream sstr;
+ sstr << "runRootCmd ret val:" << ret << ", result:" << szResult;
+ return env->NewStringUTF(sstr.str().c_str());
+}
+
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_runInit64ProcessCmd(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey,
+ jstring cmd) {
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+
+ str1 = env->GetStringUTFChars(cmd, 0);
+ string strCmd= str1;
+ env->ReleaseStringUTFChars(cmd, str1);
+
+ stringstream sstr;
+ char szResult[0x1000] = {0};
+ ssize_t inject = safe_inject_init64_run_cmd_wrapper(strRootKey.c_str(), strCmd.c_str(), szResult, sizeof(szResult));
+ sstr << "runRootCmd ret val:" << inject << ", result:" << szResult;
+ return env->NewStringUTF(sstr.str().c_str());
+}
+
+extern "C" JNIEXPORT jint JNICALL
+Java_com_linux_permissionmanager_MainActivity_disableSElinux(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey) {
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+ return kernel_root::safe_disable_selinux(strRootKey.c_str());
+}
+
+extern "C" JNIEXPORT jint JNICALL
+Java_com_linux_permissionmanager_MainActivity_enableSElinux(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey) {
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+ return kernel_root::safe_enable_selinux(strRootKey.c_str());
+}
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_adbRoot(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey) {
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+ stringstream sstr;
+ ssize_t inject = safe_inject_adbd64_run_cmd_wrapper(strRootKey.c_str(), "id", NULL, 0, false, true ,false, false);
+ sstr << "adbRoot ret val:" << inject;
+ return env->NewStringUTF(sstr.str().c_str());
+}
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_installSu(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey,
+ jstring basePath,
+ jstring suFilePath) {
+
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+
+ str1 = env->GetStringUTFChars(basePath, 0);
+ string strBasePath= str1;
+ env->ReleaseStringUTFChars(basePath, str1);
+
+ str1 = env->GetStringUTFChars(suFilePath, 0);
+ string strSuFilePath= str1;
+ env->ReleaseStringUTFChars(suFilePath, str1);
+ stringstream sstr;
+
+ //安装su工具套件
+ std::string su_hide_folder_path;
+ int install_su_ret = safe_install_su(strRootKey.c_str(), strBasePath.c_str(), su_hide_folder_path);
+ sstr << "install_su ret val:" << install_su_ret<<", su_hide_folder_path:" << su_hide_folder_path << std::endl;
+
+ if (install_su_ret == -504) {
+ //需要补一下su文件的释放
+ std::string tmpCmd = "cp "+strSuFilePath + " " + su_hide_folder_path+"/su";
+ int cp_ret = kernel_root::safe_run_root_cmd(strRootKey.c_str(), tmpCmd.c_str(), NULL, 0);
+ if(cp_ret != 0) {
+ sstr << "safe_run_normal_cmd cp_ret val:" <NewStringUTF(sstr.str().c_str());
+ }
+ install_su_ret = safe_install_su(strRootKey.c_str(), strBasePath.c_str(), su_hide_folder_path);
+ sstr << "install_su ret val:" << install_su_ret<<", su_hide_folder_path:" << su_hide_folder_path << std::endl;
+ }
+ if (install_su_ret != 0) {
+ return env->NewStringUTF(sstr.str().c_str());
+ }
+
+ g_last_su_full_path = su_hide_folder_path + "su";
+ sstr << "installSu done."<< std::endl;
+ return env->NewStringUTF(sstr.str().c_str());
+}
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_getLastInstallSuFullPath(
+ JNIEnv* env,
+ jobject /* this */) {
+ return env->NewStringUTF(g_last_su_full_path.c_str());
+}
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_uninstallSu(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey,
+ jstring basePath) {
+
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+
+ str1 = env->GetStringUTFChars(basePath, 0);
+ string strBasePath= str1;
+ env->ReleaseStringUTFChars(basePath, str1);
+
+ stringstream sstr;
+
+ int uninstall_su_ret = safe_uninstall_su(strRootKey.c_str(), strBasePath.c_str());
+ sstr << "uninstallSu ret val:" << uninstall_su_ret << std::endl;
+ if (uninstall_su_ret != 0) {
+ return env->NewStringUTF(sstr.str().c_str());
+ }
+ sstr << "uninstallSu done.";
+ return env->NewStringUTF(sstr.str().c_str());
+}
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_com_linux_permissionmanager_MainActivity_autoSuEnvInject(
+ JNIEnv* env,
+ jobject /* this */,
+ jstring rootKey,
+ jstring targetProcessCmdline,
+ jstring basePath) {
+
+ const char *str1 = env->GetStringUTFChars(rootKey, 0);
+ string strRootKey= str1;
+ env->ReleaseStringUTFChars(rootKey, str1);
+
+ str1 = env->GetStringUTFChars(targetProcessCmdline, 0);
+ string strTargetProcessCmdline = str1;
+ env->ReleaseStringUTFChars(targetProcessCmdline, str1);
+
+ str1 = env->GetStringUTFChars(basePath, 0);
+ string strBasePath= str1;
+ env->ReleaseStringUTFChars(basePath, str1);
+
+ stringstream sstr;
+
+ //杀光所有历史进程
+ std::vector vOut;
+ int find_all_cmdline_process_ret = safe_find_all_cmdline_process(strRootKey.c_str(), strTargetProcessCmdline.c_str(), vOut);
+ sstr << "find_all_cmdline_process ret val:"<< find_all_cmdline_process_ret<<", cnt:"<NewStringUTF(sstr.str().c_str());
+ }
+ std::string kill_cmd;
+ for (pid_t t : vOut) {
+ kill_cmd += "kill -9 ";
+ kill_cmd += std::to_string(t);
+ kill_cmd += ";";
+ }
+ int kill_ret = kernel_root::safe_run_root_cmd(strRootKey.c_str(), kill_cmd.c_str());
+ sstr << "kill_ret ret val:"<< kill_ret << std::endl;
+ if (kill_ret != 0) {
+ return env->NewStringUTF(sstr.str().c_str());
+ }
+
+ //注入su环境变量到指定进程
+ std::string su_hide_path;
+ int install_su_ret = safe_install_su(strRootKey.c_str(), strBasePath.c_str(), su_hide_path);
+ sstr << "install_su ret val:" << install_su_ret<<", su_hide_path:" << su_hide_path << std::endl;
+ if (install_su_ret != 0) {
+ return env->NewStringUTF(sstr.str().c_str());
+ }
+
+ int pid = safe_wait_and_find_cmdline_process(strRootKey.c_str(), strTargetProcessCmdline.c_str());
+
+ sstr << "autoSuEnvInject("<< pid<<", " << su_hide_path<<")" << std::endl;
+ ssize_t ret = safe_inject_process_env64_PATH_wrapper(strRootKey.c_str(), pid, su_hide_path.c_str());
+ sstr << "autoSuEnvInject ret val:" << ret << std::endl;
+
+ if (ret != 0) {
+ return env->NewStringUTF(sstr.str().c_str());
+ }
+ sstr << "autoSuEnvInject done.";
+ return env->NewStringUTF(sstr.str().c_str());
+}
diff --git a/PermissionManager/app/src/main/java/com/linux/permissionmanager/Adapter/SelectAppRecyclerAdapter.java b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Adapter/SelectAppRecyclerAdapter.java
new file mode 100644
index 00000000..c2a8ec6b
--- /dev/null
+++ b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Adapter/SelectAppRecyclerAdapter.java
@@ -0,0 +1,110 @@
+package com.linux.permissionmanager.Adapter;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.text.Html;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.linux.permissionmanager.Model.SelectAppRecyclerItem;
+import com.linux.permissionmanager.R;
+
+import java.util.List;
+
+public class SelectAppRecyclerAdapter extends RecyclerView.Adapter {
+
+
+
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+ public View v;
+ public ImageView select_app_icon;
+ public TextView select_app_text;
+ public TextView select_package_name;
+ // TODO Auto-generated method stub
+ public ViewHolder(View v) {
+ super(v);
+ this.v = v;
+ }
+
+ }
+
+ private int resourceId;
+ private List objects;
+ private PopupWindow popupWindow;
+ private Handler selectAppItemCallback;
+ public SelectAppRecyclerAdapter(Context context, int textViewResourceId, List objects, PopupWindow popupWindow, Handler selectAppItemCallback) {
+ this.resourceId = textViewResourceId;
+ this.objects = objects;
+ this. popupWindow = popupWindow;
+ this. selectAppItemCallback = selectAppItemCallback;
+ }
+
+
+
+ @NonNull
+ @Override
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View v =LayoutInflater.from(parent.getContext()).inflate(resourceId,parent,false);
+ SelectAppRecyclerAdapter.ViewHolder holder = new SelectAppRecyclerAdapter.ViewHolder(v);
+
+ holder.select_app_icon = v.findViewById(R.id.select_app_icon);
+ holder.select_app_text=v.findViewById(R.id.select_app_text) ;
+ holder.select_package_name=v.findViewById(R.id.select_package_name) ;
+ return holder;
+ }
+
+
+ @Override
+ public void onBindViewHolder(@NonNull SelectAppRecyclerAdapter.ViewHolder holder, int position) {
+ SelectAppRecyclerItem appItem=objects.get(position); //获取当前项的实例
+
+ //图标+进程PID+名字+内存
+ holder.select_app_icon.setImageDrawable(appItem.getIcon());
+ String showText=""+appItem.getShowName() +" "
+ +" "+" ("+appItem.getPackageName()+")"+"";
+
+ holder.select_app_text.setText(Html.fromHtml(showText));
+ holder.select_package_name.setText(appItem.getPackageName());
+
+ //item被点击
+ holder.v.setOnClickListener(new ClickRecyclerItemListener(appItem));
+ }
+
+
+ @Override
+ public int getItemCount() {
+ return objects.size();
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ return position;
+ }
+
+
+ class ClickRecyclerItemListener implements View.OnClickListener {
+ SelectAppRecyclerItem appItem;
+ public ClickRecyclerItemListener( SelectAppRecyclerItem appItem){
+ this.appItem =appItem;
+ }
+ @Override
+ public void onClick(View v) {
+ popupWindow.dismiss();
+ Message msg = new Message();
+ msg.obj = (SelectAppRecyclerItem)appItem;
+ selectAppItemCallback.sendMessage(msg);
+ }
+ }
+
+
+
+
+}
diff --git a/PermissionManager/app/src/main/java/com/linux/permissionmanager/MainActivity.java b/PermissionManager/app/src/main/java/com/linux/permissionmanager/MainActivity.java
new file mode 100644
index 00000000..599f5790
--- /dev/null
+++ b/PermissionManager/app/src/main/java/com/linux/permissionmanager/MainActivity.java
@@ -0,0 +1,479 @@
+package com.linux.permissionmanager;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.graphics.Color;
+import android.graphics.PixelFormat;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.linux.permissionmanager.Adapter.SelectAppRecyclerAdapter;
+import com.linux.permissionmanager.Model.PopupWindowOnTouchClose;
+import com.linux.permissionmanager.Model.SelectAppRecyclerItem;
+import com.linux.permissionmanager.Utils.ScreenInfoUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MainActivity extends AppCompatActivity {
+
+ private String rootKey = "u24kKoPVSAG1tnwlcs1PJ1qp6HtVymj60CoTgsjmMd1UALve";
+ private String suBasePath = "/data/local/tmp";
+
+ //保存的本地配置信息
+ private SharedPreferences m_shareSave;
+ private ProgressDialog m_loadingDlg = null;
+
+ // Used to load the 'permissionmanager' library on application startup.
+ static {
+ System.loadLibrary("permissionmanager");
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+
+ m_shareSave = getSharedPreferences("zhcs", Context.MODE_PRIVATE);
+ try {
+ rootKey = m_shareSave.getString("rootKey", rootKey);
+ } catch (Exception e) {
+ }
+
+ //验证用户的KEY
+ final EditText inputKey = new EditText(MainActivity.this);
+ inputKey.setText(rootKey);
+ inputKey.setSelection(inputKey.length(), 0);
+ AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
+ builder.setCancelable(false);
+ builder.setTitle("请输入ROOT权限的KEY").setIcon(android.R.drawable.ic_dialog_info).setView(inputKey)
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ rootKey = inputKey.getText().toString();
+ //数值保存到本地
+ SharedPreferences.Editor mEdit = m_shareSave.edit();
+ mEdit.putString("rootKey", rootKey);
+ mEdit.commit();
+ }
+
+ ;
+ });
+ builder.show();
+
+
+ Button show_myself_info_btn = findViewById(R.id.show_myself_info_btn);
+ show_myself_info_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showConsoleMsg(getCapabilityInfo());
+ }
+ });
+
+ Button get_root_btn = findViewById(R.id.get_root_btn);
+ get_root_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int ret = getRoot(rootKey);
+ showConsoleMsg("getRoot: " + ret);
+ }
+ });
+
+ Button disable_selinux_btn = findViewById(R.id.disable_selinux_btn);
+ disable_selinux_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int ret = disableSElinux(rootKey);
+ showConsoleMsg("disableSElinux: " + ret);
+ }
+ });
+
+ Button enable_selinux_btn = findViewById(R.id.enable_selinux_btn);
+ enable_selinux_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int ret = enableSElinux(rootKey);
+ showConsoleMsg("enableSElinux: " + ret);
+ }
+ });
+
+ Button run_root_cmd_btn = findViewById(R.id.run_root_cmd_btn);
+ run_root_cmd_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ String defaultCmd = "id";
+ final EditText inputCMD = new EditText(MainActivity.this);
+ inputCMD.setText(defaultCmd);
+ inputCMD.setSelection(defaultCmd.length(), 0);
+ inputCMD.setFocusable(true);
+ AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
+ builder.setTitle("输入ROOT命令").setIcon(android.R.drawable.ic_dialog_info).setView(inputCMD)
+ .setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ });
+ builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ String text = inputCMD.getText().toString();
+ showConsoleMsg(text + "\n" + runRootCmd(rootKey, text));
+ }
+ });
+ builder.show();
+
+ }
+ });
+ Button run_init_process_cmd_btn = findViewById(R.id.run_init_process_cmd_btn);
+ run_init_process_cmd_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String defaultCmd = "id";
+ final EditText inputCMD = new EditText(MainActivity.this);
+ inputCMD.setText(defaultCmd);
+ inputCMD.setSelection(defaultCmd.length(), 0);
+ inputCMD.setFocusable(true);
+ AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
+ builder.setTitle("输入ROOT命令").setIcon(android.R.drawable.ic_dialog_info).setView(inputCMD)
+ .setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ });
+ builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ String text = inputCMD.getText().toString();
+ showConsoleMsg(text + "\n" + runInit64ProcessCmd(rootKey, text));
+ }
+ });
+ builder.show();
+
+ }
+ });
+ Button adb_root_btn = findViewById(R.id.adb_root_btn);
+ adb_root_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showConsoleMsg(adbRoot(rootKey));
+ }
+ });
+
+ Button su_env_install_btn = findViewById(R.id.su_env_install_btn);
+ su_env_install_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //1.获取su工具文件路径
+ String suFilePath = WirteSuToolsFilePath("su", MainActivity.this);
+ showConsoleMsg(suFilePath);
+
+ //2.安装su工具
+ String insRet = installSu(rootKey, suBasePath, suFilePath);
+ showConsoleMsg(insRet);
+ if(insRet.indexOf("installSu done.") == -1) {
+ return;
+ }
+
+ //3.复制su的路径到剪贴板
+ String suFullPath = getLastInstallSuFullPath();
+ copyEditText(suFullPath);
+ Toast.makeText(v.getContext(), "su路径已复制到剪贴板", Toast.LENGTH_SHORT).show();
+
+ }
+ });
+
+ Button su_env_inject_btn = findViewById(R.id.su_env_inject_btn);
+ su_env_inject_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showSelectAppWindow();
+ }
+ });
+
+ Button clean_su_btn = findViewById(R.id.clean_su_btn);
+ clean_su_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //让adbd自我重启
+ showConsoleMsg(uninstallSu(rootKey,suBasePath));
+ }
+ });
+
+ Button copy_info_btn = findViewById(R.id.copy_info_btn);
+ copy_info_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ EditText edit = findViewById(R.id.console_edit);
+ copyEditText(edit.getText().toString());
+ Toast.makeText(v.getContext(), "复制成功", Toast.LENGTH_SHORT).show();
+
+ }
+ });
+ Button clean_info_btn = findViewById(R.id.clean_info_btn);
+ clean_info_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ cleanConsoleMsg();
+ }
+ });
+ }
+
+ public void showConsoleMsg(String msg) {
+ EditText console_edit = findViewById(R.id.console_edit);
+ StringBuffer txt = new StringBuffer();
+ txt.append(console_edit.getText().toString());
+ if (txt.length() != 0) {
+ txt.append("\n");
+ }
+ txt.append(msg);
+ txt.append("\n");
+ console_edit.setText(txt.toString());
+ console_edit.setSelection(txt.length());
+ }
+
+ public void cleanConsoleMsg() {
+ EditText console_edit = findViewById(R.id.console_edit);
+ console_edit.setText("");
+ }
+
+ public void copyEditText(String text) {
+ //获取剪贴板管理器:
+ ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ // 创建普通字符型ClipData
+ ClipData mClipData = ClipData.newPlainText("Label", text);
+ // 将ClipData内容放到系统剪贴板里。
+ cm.setPrimaryClip(mClipData);
+
+ }
+
+ Handler selectAppItemCallback = new Handler() {
+ @Override
+ public void handleMessage(@NonNull Message msg) {
+
+ SelectAppRecyclerItem appItem = (SelectAppRecyclerItem) msg.obj;
+
+ if (m_loadingDlg == null) {
+ m_loadingDlg = new ProgressDialog(MainActivity.this);
+ m_loadingDlg.setCancelable(false);
+ }
+ m_loadingDlg.setTitle("");
+ m_loadingDlg.setMessage("请现在手动启动APP [" + appItem.getShowName() + "]");
+ m_loadingDlg.show();
+
+ new Thread() {
+ public void run() {
+ String ret = autoSuEnvInject(rootKey, appItem.getPackageName(), suBasePath);
+ runOnUiThread(new Runnable() {
+ public void run() {
+ showConsoleMsg(ret);
+ m_loadingDlg.cancel();
+
+ if(ret.indexOf("autoSuEnvInject done.")!= -1) {
+ //弹个提示,通知一下成功了
+ AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
+ .setCancelable(false)
+ .setTitle("提示")
+ .setIcon(appItem.getIcon())
+ .setMessage("已经授予ROOT权限到APP [" + appItem.getShowName() + "]")
+ .setNegativeButton("确定", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ });
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.BLACK);
+ }
+
+ }
+ });
+ }
+ }.start();
+ super.handleMessage(msg);
+ }
+ };
+
+ //显示选择应用程序窗口
+ public void showSelectAppWindow() {
+ final PopupWindow popupWindow = new PopupWindow(this);
+
+ View view = View.inflate(this, R.layout.select_app_wnd, null);
+ popupWindow.setContentView(view);
+
+ popupWindow.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
+ popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
+ popupWindow.setBackgroundDrawable(new ColorDrawable(0x9B000000)); //阴影半透明
+ popupWindow.setOutsideTouchable(true);
+ popupWindow.setFocusable(true);
+ popupWindow.setTouchable(true);
+
+ //全屏
+ View parent = View.inflate(MainActivity.this, R.layout.activity_main, null);
+ popupWindow.showAtLocation(parent, Gravity.NO_GRAVITY, 0, 0);
+ popupWindow.showAsDropDown(parent, 0, 0);
+
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() { //窗口即将关闭
+
+ }
+ });
+
+ //设置中心布局大小
+ final int screenWidth = ScreenInfoUtils.getRealWidth(this);
+ final int screenHeight = ScreenInfoUtils.getRealHeight(this);
+
+ final double centerWidth = ((double) screenWidth) * 0.80;
+ final double centerHeight = ((double) screenHeight) * 0.90;
+
+ LinearLayout center_layout = (LinearLayout) view.findViewById(R.id.center_layout);
+ android.view.ViewGroup.LayoutParams lp = center_layout.getLayoutParams();
+ lp.width = (int) centerWidth;
+ lp.height = (int) centerHeight;
+
+ //点击阴影部分可关闭窗口
+ popupWindow.setTouchInterceptor(new PopupWindowOnTouchClose(popupWindow,
+ screenWidth, screenHeight, (int) centerWidth, (int) centerHeight));
+
+ //显示APP列表
+ List appList = new ArrayList<>();
+
+ //获取已安装的APK列表
+ List packages = getPackageManager().getInstalledPackages(0);
+
+ //先判断cmdline与包名是否完全相同
+ for (int i = 0; i < packages.size(); i++) {
+ PackageInfo packageInfo = packages.get(i);
+
+ if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+ //系统应用
+ continue;
+ }
+ String showName = packageInfo.applicationInfo.loadLabel(getPackageManager()).toString();
+
+ Drawable icon = packageInfo.applicationInfo.loadIcon(getPackageManager());
+
+ String packageName = packageInfo.applicationInfo.packageName;
+ if(packageName.equals(getPackageName())){
+ //不显示自己
+ continue;
+ }
+ //加入到显示APP列表
+ appList.add(new SelectAppRecyclerItem(
+ icon,
+ showName,
+ packageName));
+ }
+ for (int i = 0; i < packages.size(); i++) {
+ PackageInfo packageInfo = packages.get(i);
+
+ if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
+ //非系统应用
+ continue;
+ }
+
+ String showName = packageInfo.applicationInfo.loadLabel(getPackageManager()).toString();
+
+ Drawable icon = packageInfo.applicationInfo.loadIcon(getPackageManager());
+
+ String packageName = packageInfo.applicationInfo.packageName;
+
+ //加入到显示APP列表
+ appList.add(new SelectAppRecyclerItem(
+ icon,
+ showName,
+ packageName));
+ }
+
+ SelectAppRecyclerAdapter adapter = new SelectAppRecyclerAdapter(
+ MainActivity.this, R.layout.select_app_recycler_item, appList, popupWindow, selectAppItemCallback);
+
+ RecyclerView select_app_recycler_view = (RecyclerView) view.findViewById(R.id.select_app_recycler_view);
+ // 设置布局管理器
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
+ linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
+ select_app_recycler_view.setLayoutManager(linearLayoutManager);
+ select_app_recycler_view.setAdapter(adapter);
+
+ }
+
+ public static String WirteSuToolsFilePath(String suName, Context context) {
+ String suFilePath = "";
+ try {
+ suFilePath = context.getFilesDir().getPath() + "/" + suName;
+ File file = new File(suFilePath);
+ if (!file.exists()) {
+ if (!file.getParentFile().exists()) file.getParentFile().mkdirs();
+ file.createNewFile();
+ }
+ if (file.exists()) {
+ InputStream inputStream = context.getAssets().open(suName);
+ FileOutputStream outputStream = new FileOutputStream(file);
+ byte[] content = new byte[1024];
+ while (inputStream.read(content) > 0) {
+ outputStream.write(content);
+ }
+ inputStream.close();
+ outputStream.flush();
+ outputStream.close();
+ }
+ } catch (Exception e) {
+ }
+ return suFilePath;
+ }
+
+
+ public native String getCapabilityInfo();
+
+ public native int getRoot(String rootKey);
+
+ public native String runRootCmd(String rootKey, String cmd);
+
+ public native String runInit64ProcessCmd(String rootKey, String cmd);
+
+ public native int disableSElinux(String rootKey);
+
+ public native int enableSElinux(String rootKey);
+
+ public native String adbRoot(String rootKey);
+
+ public native String installSu(String rootKey, String basePath, String suFilePath);
+
+ public native String getLastInstallSuFullPath();
+
+ public native String uninstallSu(String rootKey, String basePath);
+
+ public native String autoSuEnvInject(String rootKey, String targetProcessCmdline, String basePath);
+}
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/java/com/linux/permissionmanager/Model/PopupWindowOnTouchClose.java b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Model/PopupWindowOnTouchClose.java
new file mode 100644
index 00000000..3856843a
--- /dev/null
+++ b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Model/PopupWindowOnTouchClose.java
@@ -0,0 +1,48 @@
+package com.linux.permissionmanager.Model;
+
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.PopupWindow;
+
+public class PopupWindowOnTouchClose implements View.OnTouchListener {
+ private boolean lastVailedDown = true;
+ private int screenWidth, screenHeight, centerWidth, centerHeight;
+ private PopupWindow popupWindow;
+
+ public PopupWindowOnTouchClose(PopupWindow popupWindow, int screenWidth, int screenHeight, int centerWidth, int centerHeight) {
+ this.popupWindow = popupWindow;
+ this.screenWidth = screenWidth;
+ this.screenHeight = screenHeight;
+ this.centerWidth = centerWidth;
+ this.centerHeight = centerHeight;
+ }
+
+ private boolean isValiedRegion(View v, MotionEvent event) {
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+ double wndLeft = (screenWidth - centerWidth) / 2;
+ double wndTop = (screenHeight - centerHeight) / 2;
+ if (x < wndLeft || x > wndLeft + centerWidth || y < wndTop || y > wndTop + centerHeight) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ lastVailedDown = isValiedRegion(v, event);
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ if (!lastVailedDown) {
+ if (!isValiedRegion(v, event)) {
+ popupWindow.dismiss();
+ }
+ }
+ }
+ return false;
+ }
+}
+
+
+
diff --git a/PermissionManager/app/src/main/java/com/linux/permissionmanager/Model/SelectAppRecyclerItem.java b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Model/SelectAppRecyclerItem.java
new file mode 100644
index 00000000..f754bbd6
--- /dev/null
+++ b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Model/SelectAppRecyclerItem.java
@@ -0,0 +1,40 @@
+package com.linux.permissionmanager.Model;
+
+import android.graphics.drawable.Drawable;
+
+public class SelectAppRecyclerItem {
+ private Drawable icon=null;
+ private String showName;
+ private String packageName;
+
+ public SelectAppRecyclerItem(Drawable icon, String showName, String packageName){
+ this.icon=icon;
+ this.showName = showName;
+ this.packageName = packageName;
+ }
+
+ public Drawable getIcon() {
+ return icon;
+ }
+
+ public void setIcon(Drawable icon) {
+ this.icon = icon;
+ }
+
+ public String getShowName() {
+ return showName;
+ }
+
+ public void setShowName(String showName) {
+ this.showName = showName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+}
diff --git a/PermissionManager/app/src/main/java/com/linux/permissionmanager/Utils/ScreenInfoUtils.java b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Utils/ScreenInfoUtils.java
new file mode 100644
index 00000000..5e50159e
--- /dev/null
+++ b/PermissionManager/app/src/main/java/com/linux/permissionmanager/Utils/ScreenInfoUtils.java
@@ -0,0 +1,187 @@
+package com.linux.permissionmanager.Utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.Display;
+import android.view.WindowManager;
+
+/**
+ * Get Screen Information Utils
+ *
+ * @author yh
+ * @date 2018/12/18.
+ */
+public class ScreenInfoUtils {
+
+ private static final String TAG = "ScreenInfoUtils";
+
+ /**
+ * Get Screen Width
+ */
+ public static int getScreenWidth(Context context) {
+ return getDisplayMetrics(context).widthPixels;
+ }
+
+ /**
+ * Get Screen Height
+ */
+ public static int getScreenHeight(Context context) {
+ return getDisplayMetrics(context).heightPixels;
+ }
+
+
+ /**
+ * Get Screen Real Height
+ *
+ * @param context Context
+ * @return Real Height
+ */
+ public static int getRealHeight(Context context) {
+ Display display = getDisplay(context);
+ if (display == null) {
+ return 0;
+ }
+ DisplayMetrics dm = new DisplayMetrics();
+ display.getRealMetrics(dm);
+ return dm.heightPixels;
+ }
+
+ /**
+ * Get Screen Real Width
+ *
+ * @param context Context
+ * @return Real Width
+ */
+ public static int getRealWidth(Context context) {
+ Display display = getDisplay(context);
+ if (display == null) {
+ return 0;
+ }
+ DisplayMetrics dm = new DisplayMetrics();
+ display.getRealMetrics(dm);
+ return dm.widthPixels;
+ }
+
+ /**
+ * Get StatusBar Height
+ */
+ public static int getStatusBarHeight(Context mContext) {
+ int resourceId = mContext.getResources().getIdentifier("status_bar_height", "dimen", "android");
+ if (resourceId > 0) {
+ return mContext.getResources().getDimensionPixelSize(resourceId);
+ }
+ return 0;
+ }
+
+ /**
+ * Get ActionBar Height
+ */
+ public static int getActionBarHeight(Context mContext) {
+ TypedValue tv = new TypedValue();
+ if (mContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
+ return TypedValue.complexToDimensionPixelSize(tv.data, mContext.getResources().getDisplayMetrics());
+ }
+ return 0;
+ }
+
+ /**
+ * Get NavigationBar Height
+ */
+ public static int getNavigationBarHeight(Context mContext) {
+ Resources resources = mContext.getResources();
+ int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (resourceId > 0) {
+ return resources.getDimensionPixelSize(resourceId);
+ }
+ return 0;
+ }
+
+ /**
+ * Get Density
+ */
+ private static float getDensity(Context context) {
+ return getDisplayMetrics(context).density;
+ }
+
+ /**
+ * Get Dpi
+ */
+ private static int getDpi(Context context) {
+ return getDisplayMetrics(context).densityDpi;
+ }
+
+ /**
+ * Get Display
+ *
+ * @param context Context for get WindowManager
+ * @return Display
+ */
+ private static Display getDisplay(Context context) {
+ WindowManager wm;
+ if (context instanceof Activity) {
+ Activity activity = (Activity) context;
+ wm = activity.getWindowManager();
+ } else {
+ wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ }
+ if (wm != null) {
+ return wm.getDefaultDisplay();
+ }
+ return null;
+ }
+
+ /**
+ * Get DisplayMetrics
+ *
+ * @param context Context for get Resources
+ * @return DisplayMetrics
+ */
+ private static DisplayMetrics getDisplayMetrics(Context context) {
+ return context.getResources().getDisplayMetrics();
+ }
+
+
+ /**
+ * Get ScreenInfo
+ */
+ private static String getScreenInfo(Context context) {
+ return " \n" +
+ "--------ScreenInfo--------" + "\n" +
+ "Screen Width : " + getScreenWidth(context) + "px\n" +
+ "Screen RealWidth :" + getRealWidth(context) + "px\n" +
+ "Screen Height: " + getScreenHeight(context) + "px\n" +
+ "Screen RealHeight: " + getRealHeight(context) + "px\n" +
+ "Screen StatusBar Height: " + getStatusBarHeight(context)+ "px\n" +
+ "Screen ActionBar Height: " + getActionBarHeight(context)+ "px\n" +
+ "Screen NavigationBar Height: " + getNavigationBarHeight(context)+ "px\n" +
+ "Screen Dpi: " + getDpi(context) + "\n" +
+ "Screen Density: " + getDensity(context) + "\n" +
+ "--------------------------";
+ }
+
+
+ /**
+ * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
+ */
+ public static int dip2px(Context context, float dpValue) {
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (dpValue * scale);
+ }
+
+ /** * 根据手机的分辨率从 px(像素) 的单位 转成为 dp */
+ public static int px2dip(Context context, float pxValue) {
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (pxValue / scale);
+ }
+
+ /**
+ * Print screenInfo to logcat
+ */
+ public static void printScreenInfo(Context context) {
+ Log.d(TAG, getScreenInfo(context));
+ }
+}
diff --git a/PermissionManager/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/PermissionManager/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 00000000..2b068d11
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/drawable/ic_launcher_background.xml b/PermissionManager/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..07d5da9c
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PermissionManager/app/src/main/res/drawable/line.xml b/PermissionManager/app/src/main/res/drawable/line.xml
new file mode 100644
index 00000000..edc8c384
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable/line.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/drawable/line_drawable.xml b/PermissionManager/app/src/main/res/drawable/line_drawable.xml
new file mode 100644
index 00000000..963faca1
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable/line_drawable.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/drawable/ripple_grey.xml b/PermissionManager/app/src/main/res/drawable/ripple_grey.xml
new file mode 100644
index 00000000..9fe6ea1b
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable/ripple_grey.xml
@@ -0,0 +1,6 @@
+
+//点击时波纹的颜色
+ //未点击时控件的背景(可以是图片,可以是颜色,也可以是drawable里的xml背景(比如圆角))
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/drawable/shape_wnd_grey_corner.xml b/PermissionManager/app/src/main/res/drawable/shape_wnd_grey_corner.xml
new file mode 100644
index 00000000..1e51d694
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable/shape_wnd_grey_corner.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/drawable/thumb.xml b/PermissionManager/app/src/main/res/drawable/thumb.xml
new file mode 100644
index 00000000..347480a8
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable/thumb.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/drawable/thumb_drawable.xml b/PermissionManager/app/src/main/res/drawable/thumb_drawable.xml
new file mode 100644
index 00000000..f32eb927
--- /dev/null
+++ b/PermissionManager/app/src/main/res/drawable/thumb_drawable.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/layout/activity_main.xml b/PermissionManager/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..80242668
--- /dev/null
+++ b/PermissionManager/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/layout/select_app_recycler_item.xml b/PermissionManager/app/src/main/res/layout/select_app_recycler_item.xml
new file mode 100644
index 00000000..4a34d32d
--- /dev/null
+++ b/PermissionManager/app/src/main/res/layout/select_app_recycler_item.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PermissionManager/app/src/main/res/layout/select_app_wnd.xml b/PermissionManager/app/src/main/res/layout/select_app_wnd.xml
new file mode 100644
index 00000000..05eb7e24
--- /dev/null
+++ b/PermissionManager/app/src/main/res/layout/select_app_wnd.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PermissionManager/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/PermissionManager/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 00000000..eca70cfe
--- /dev/null
+++ b/PermissionManager/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/PermissionManager/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 00000000..eca70cfe
--- /dev/null
+++ b/PermissionManager/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/PermissionManager/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 00000000..c209e78e
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/PermissionManager/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..b2dfe3d1
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/PermissionManager/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 00000000..4f0f1d64
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/PermissionManager/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..62b611da
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/PermissionManager/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 00000000..948a3070
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/PermissionManager/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..1b9a6956
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/PermissionManager/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..28d4b77f
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/PermissionManager/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..9287f508
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/PermissionManager/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..aa7d6427
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/PermissionManager/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/PermissionManager/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..9126ae37
Binary files /dev/null and b/PermissionManager/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/PermissionManager/app/src/main/res/values-night/themes.xml b/PermissionManager/app/src/main/res/values-night/themes.xml
new file mode 100644
index 00000000..d5b6cfa7
--- /dev/null
+++ b/PermissionManager/app/src/main/res/values-night/themes.xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/values/colors.xml b/PermissionManager/app/src/main/res/values/colors.xml
new file mode 100644
index 00000000..bbb834e9
--- /dev/null
+++ b/PermissionManager/app/src/main/res/values/colors.xml
@@ -0,0 +1,13 @@
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+ #424242
+ #FF767676
+ #00000000
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/values/strings.xml b/PermissionManager/app/src/main/res/values/strings.xml
new file mode 100644
index 00000000..3c17a54a
--- /dev/null
+++ b/PermissionManager/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ PermissionManager
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/main/res/values/themes.xml b/PermissionManager/app/src/main/res/values/themes.xml
new file mode 100644
index 00000000..3a6641c8
--- /dev/null
+++ b/PermissionManager/app/src/main/res/values/themes.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PermissionManager/app/src/test/java/com/linux/permissionmanager/ExampleUnitTest.java b/PermissionManager/app/src/test/java/com/linux/permissionmanager/ExampleUnitTest.java
new file mode 100644
index 00000000..bd51fc00
--- /dev/null
+++ b/PermissionManager/app/src/test/java/com/linux/permissionmanager/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.linux.permissionmanager;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/PermissionManager/appKey.jks b/PermissionManager/appKey.jks
new file mode 100644
index 00000000..81b8ee7e
Binary files /dev/null and b/PermissionManager/appKey.jks differ
diff --git a/PermissionManager/build.gradle b/PermissionManager/build.gradle
new file mode 100644
index 00000000..f757f23e
--- /dev/null
+++ b/PermissionManager/build.gradle
@@ -0,0 +1,5 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
\ No newline at end of file
diff --git a/PermissionManager/gradle.properties b/PermissionManager/gradle.properties
new file mode 100644
index 00000000..9a4c7cc9
--- /dev/null
+++ b/PermissionManager/gradle.properties
@@ -0,0 +1,23 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app"s APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
\ No newline at end of file
diff --git a/PermissionManager/gradle/wrapper/gradle-wrapper.jar b/PermissionManager/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..e708b1c0
Binary files /dev/null and b/PermissionManager/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/PermissionManager/gradle/wrapper/gradle-wrapper.properties b/PermissionManager/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..d5be18ad
--- /dev/null
+++ b/PermissionManager/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sat Feb 19 21:34:04 CST 2022
+distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/PermissionManager/gradlew b/PermissionManager/gradlew
new file mode 100644
index 00000000..4f906e0c
--- /dev/null
+++ b/PermissionManager/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/PermissionManager/gradlew.bat b/PermissionManager/gradlew.bat
new file mode 100644
index 00000000..ac1b06f9
--- /dev/null
+++ b/PermissionManager/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/PermissionManager/settings.gradle b/PermissionManager/settings.gradle
new file mode 100644
index 00000000..1f40e56f
--- /dev/null
+++ b/PermissionManager/settings.gradle
@@ -0,0 +1,20 @@
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ google()
+ mavenCentral()
+ }
+ plugins {
+ id 'com.android.application' version '7.1.0-alpha11'
+ id 'com.android.library' version '7.1.0-alpha11'
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+rootProject.name = "PermissionManager"
+include ':app'
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..3ab1c46a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,25 @@
+# Linux ARM64 内核级完美隐藏ROOT演示
+新一代root,挑战全网root检测手段,跟面具完全不同思路,摆脱面具被检测的弱点,完美隐藏root功能,全程不需要暂停SELinux,实现真正的SELinux 0%触碰,通用性强,通杀所有内核,不需要内核源码,直接patch内核,兼容安卓APP直接JNI调用,稳定、流畅、不闪退。
+### 本工具功能列表:
+### 1.显示自身权限信息
+### 2.获取ROOT权限
+### 3.执行ROOT命令
+### 4.执行内核命令
+### 5.暂停全局SELinux
+### 6.恢复全局SELinux
+### 7.提升ADB为ROOT权限
+### 8.安装部署su
+### 9.注入su到指定进程
+### 10.完全卸载清理su
+
+此作品尚未对外正式发布,目前开发进度:100%,待我挑个良辰吉日再对外发布。
+
+
+
+
+
+
+
+
+
+
diff --git a/ScreenCap/0.png b/ScreenCap/0.png
new file mode 100644
index 00000000..54373217
Binary files /dev/null and b/ScreenCap/0.png differ
diff --git a/ScreenCap/1.png b/ScreenCap/1.png
new file mode 100644
index 00000000..189732a6
Binary files /dev/null and b/ScreenCap/1.png differ
diff --git a/ScreenCap/2.png b/ScreenCap/2.png
new file mode 100644
index 00000000..fcfb0e86
Binary files /dev/null and b/ScreenCap/2.png differ
diff --git a/ScreenCap/3.png b/ScreenCap/3.png
new file mode 100644
index 00000000..93559448
Binary files /dev/null and b/ScreenCap/3.png differ
diff --git a/ScreenCap/4.png b/ScreenCap/4.png
new file mode 100644
index 00000000..07004e0b
Binary files /dev/null and b/ScreenCap/4.png differ
diff --git a/ScreenCap/5.png b/ScreenCap/5.png
new file mode 100644
index 00000000..17a4b59a
Binary files /dev/null and b/ScreenCap/5.png differ
diff --git a/ScreenCap/6.png b/ScreenCap/6.png
new file mode 100644
index 00000000..167d65cc
Binary files /dev/null and b/ScreenCap/6.png differ
diff --git a/ScreenCap/7.png b/ScreenCap/7.png
new file mode 100644
index 00000000..922ada45
Binary files /dev/null and b/ScreenCap/7.png differ
diff --git a/ScreenCap/8.png b/ScreenCap/8.png
new file mode 100644
index 00000000..82bf5d18
Binary files /dev/null and b/ScreenCap/8.png differ
diff --git a/find_kernel_func/empty b/find_kernel_func/empty
new file mode 100644
index 00000000..e69de29b
diff --git a/patch_kernel_root/empty b/patch_kernel_root/empty
new file mode 100644
index 00000000..e69de29b
diff --git a/su/base64.cpp b/su/base64.cpp
new file mode 100644
index 00000000..56e166d7
--- /dev/null
+++ b/su/base64.cpp
@@ -0,0 +1,96 @@
+#include "base64.h"
+#include
+#include
+static const std::string base64_chars =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+"abcdefghijklmnopqrstuvwxyz"
+"0123456789+/";
+
+
+static inline bool is_base64(unsigned char c) {
+ return (isalnum(c) || (c == '+') || (c == '/'));
+}
+
+std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
+ std::string ret;
+ int i = 0;
+ int j = 0;
+ unsigned char char_array_3[3];
+ unsigned char char_array_4[4];
+
+ while (in_len--) {
+ char_array_3[i++] = *(bytes_to_encode++);
+ if (i == 3) {
+ char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
+ char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
+ char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
+ char_array_4[3] = char_array_3[2] & 0x3f;
+
+ for (i = 0; (i < 4); i++)
+ ret += base64_chars[char_array_4[i]];
+ i = 0;
+ }
+ }
+
+ if (i)
+ {
+ for (j = i; j < 3; j++)
+ char_array_3[j] = '\0';
+
+ char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
+ char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
+ char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
+ char_array_4[3] = char_array_3[2] & 0x3f;
+
+ for (j = 0; (j < i + 1); j++)
+ ret += base64_chars[char_array_4[j]];
+
+ while ((i++ < 3))
+ ret += '=';
+
+ }
+
+ return ret;
+
+}
+
+std::string base64_decode(std::string const& encoded_string) {
+ int in_len = encoded_string.size();
+ int i = 0;
+ int j = 0;
+ int in_ = 0;
+ unsigned char char_array_4[4], char_array_3[3];
+ std::string ret;
+
+ while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
+ char_array_4[i++] = encoded_string[in_]; in_++;
+ if (i == 4) {
+ for (i = 0; i < 4; i++)
+ char_array_4[i] = base64_chars.find(char_array_4[i]);
+
+ char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+ char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+ char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+ for (i = 0; (i < 3); i++)
+ ret += char_array_3[i];
+ i = 0;
+ }
+ }
+
+ if (i) {
+ for (j = i; j < 4; j++)
+ char_array_4[j] = 0;
+
+ for (j = 0; j < 4; j++)
+ char_array_4[j] = base64_chars.find(char_array_4[j]);
+
+ char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+ char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+ char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+ for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
+ }
+
+ return ret;
+}
diff --git a/su/base64.h b/su/base64.h
new file mode 100644
index 00000000..145e06fe
--- /dev/null
+++ b/su/base64.h
@@ -0,0 +1,6 @@
+#ifndef BASE_64_H
+#define BASE_64_H
+#include
+std::string base64_encode(unsigned char const*, unsigned int len);
+std::string base64_decode(std::string const& s);
+#endif
diff --git a/su/jni/Android.mk b/su/jni/Android.mk
new file mode 100644
index 00000000..cc3f69f1
--- /dev/null
+++ b/su/jni/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_CPPFLAGS += -std=c++17
+LOCAL_CFLAGS += -fPIE
+LOCAL_CFLAGS += -fvisibility=hidden
+LOCAL_LDFLAGS += -fPIE -pie
+LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true
+LOCAL_MODULE := su
+LOCAL_SRC_FILES := \
+../su.cpp \
+../base64.cpp \
+
+include $(BUILD_EXECUTABLE)
diff --git a/su/jni/Application.mk b/su/jni/Application.mk
new file mode 100644
index 00000000..d67ad626
--- /dev/null
+++ b/su/jni/Application.mk
@@ -0,0 +1,2 @@
+APP_ABI := arm64-v8a
+APP_STL := c++_static
\ No newline at end of file
diff --git a/su/log.h b/su/log.h
new file mode 100644
index 00000000..1cc37e83
--- /dev/null
+++ b/su/log.h
@@ -0,0 +1,16 @@
+#ifndef _LOG_H_
+#define _LOG_H_
+#include
+#include
+#include
+
+//安静输出模式
+#define QUIET_PRINTF
+
+#ifdef QUIET_PRINTF
+#define TRACE(fmt, ...)
+#else
+#define TRACE(fmt, ...) printf(fmt, ##__VA_ARGS__)
+#endif
+
+#endif /* _LOG_H_ */
diff --git a/su/su.cpp b/su/su.cpp
new file mode 100644
index 00000000..50e45c0a
--- /dev/null
+++ b/su/su.cpp
@@ -0,0 +1,168 @@
+#include "su.h"
+#include "log.h"
+#include "su_hide_path_utils.h"
+#include "../testRoot/kernel_root_helper.h"
+#include "../testRoot/myself_path_utils.h"
+
+namespace {
+ /*
+ * Bionic's atoi runs through strtol().
+ * Use our own implementation for faster conversion.
+ */
+ int parse_int(const char* s) {
+ int val = 0;
+ char c;
+ while ((c = *(s++))) {
+ if (c > '9' || c < '0')
+ return -1;
+ val = val * 10 + c - '0';
+ }
+ return val;
+ }
+
+}
+
+void usage(int status) {
+ FILE* stream = (status == EXIT_SUCCESS) ? stdout : stderr;
+
+ fprintf(stream,
+ "linux kernel root\n\n"
+ "Usage: su [options] [-] [user [argument...]]\n\n"
+ "Options:\n"
+ " -c, --command COMMAND pass COMMAND to the invoked shell\n"
+ " -h, --help display this help message and exit\n"
+ " -, -l, --login pretend the shell to be a login shell\n"
+ " -m, -p,\n"
+ " --preserve-environment preserve the entire environment\n"
+ " -s, --shell SHELL use SHELL instead of the default " DEFAULT_SHELL "\n"
+ " -v, --version display version number and exit\n"
+ " -V display version code and exit\n"
+ " -mm, -M,\n"
+ " --mount-master force run in the global mount namespace\n\n");
+ exit(status);
+}
+
+static inline std::string get_root_key() {
+ char myself_path[1024] = { 0 };
+ char processname[1024];
+ get_executable_path(myself_path, processname, sizeof(myself_path));
+ TRACE("su start: my directory:%s, processname:%s\n", myself_path, processname);
+ std::string str_root_key = parse_root_key_by_myself_path(myself_path);
+ return str_root_key;
+}
+
+int su_client_main(int argc, char* argv[]) {
+ int c;
+ struct option long_opts[] = {
+ { "command", required_argument, nullptr, 'c' },
+ { "help", no_argument, nullptr, 'h' },
+ { "login", no_argument, nullptr, 'l' },
+ { "preserve-environment", no_argument, nullptr, 'p' },
+ { "shell", required_argument, nullptr, 's' },
+ { "version", no_argument, nullptr, 'v' },
+ { "context", required_argument, nullptr, 'z' },
+ { "mount-master", no_argument, nullptr, 'M' },
+ { nullptr, 0, nullptr, 0 },
+ };
+
+ su_request su_req;
+
+ for (int i = 0; i < argc; i++) {
+ // Replace -cn with -z, -mm with -M for supporting getopt_long
+ if (strcmp(argv[i], "-cn") == 0)
+ strcpy(argv[i], "-z");
+ else if (strcmp(argv[i], "-mm") == 0)
+ strcpy(argv[i], "-M");
+ }
+
+ while ((c = getopt_long(argc, argv, "c:hlmps:Vvuz:M", long_opts, nullptr)) != -1) {
+ switch (c) {
+ case 'c':
+ for (int i = optind - 1; i < argc; ++i) {
+ if (!su_req.command.empty())
+ su_req.command += ' ';
+ su_req.command += argv[i];
+ }
+ optind = argc;
+ break;
+ case 'h':
+ usage(EXIT_SUCCESS);
+ break;
+ case 'l':
+ su_req.login = true;
+ break;
+ case 'm':
+ case 'p':
+ su_req.keepenv = true;
+ break;
+ case 's':
+ su_req.shell = optarg;
+ break;
+ case 'V':
+ printf("%d\n", ROOT_VER_CODE);
+ exit(EXIT_SUCCESS);
+ case 'v':
+ printf("%s\n", ROOT_VERSION);
+ exit(EXIT_SUCCESS);
+ case 'z':
+ // Do nothing, placed here for legacy support :)
+ break;
+ case 'M':
+ su_req.mount_master = true;
+ break;
+ default:
+ /* Bionic getopt_long doesn't terminate its error output by newline */
+ fprintf(stderr, "\n");
+ usage(2);
+ }
+ }
+
+ if (optind < argc && strcmp(argv[optind], "-") == 0) {
+ su_req.login = true;
+ optind++;
+ }
+
+ std::string root_key = get_root_key();
+ TRACE("root_key:%s\n", root_key.c_str());
+
+ if (fork() == 0) {
+ kernel_root::get_root(root_key.c_str());
+ TRACE("current uid:%d\n", getuid());
+
+ /* username or uid */
+ if (optind < argc) {
+ struct passwd* pw;
+ pw = getpwnam(argv[optind]);
+ if (pw) {
+ su_req.uid = pw->pw_uid;
+ } else {
+ su_req.uid = parse_int(argv[optind]);
+ }
+ optind++;
+ }
+ struct passwd* pw = getpwuid(su_req.uid);
+ if (pw) {
+ setenv("HOME", pw->pw_dir, 1);
+ setenv("USER", pw->pw_name, 1);
+ setenv("LOGNAME", pw->pw_name, 1);
+ setenv("SHELL", su_req.shell.data(), 1);
+ }
+
+ const char* new_argv[4] = { nullptr };
+ new_argv[0] = su_req.login ? "-" : su_req.shell.data();
+
+ if (!su_req.command.empty()) {
+ new_argv[1] = "-c";
+ new_argv[2] = su_req.command.data();
+ }
+ execvp(su_req.shell.data(), (char**)new_argv);
+ } else {
+ wait(NULL);
+ }
+ exit(0);
+ return 0;
+}
+
+int main(int argc, char* argv[]) {
+ return su_client_main(argc, argv);
+}
diff --git a/su/su.h b/su/su.h
new file mode 100644
index 00000000..9bcd53b7
--- /dev/null
+++ b/su/su.h
@@ -0,0 +1,62 @@
+#ifndef _SU_H_
+#define _SU_H_
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include