manager: Add the ability to get a list of active managers
This commit is contained in:
@@ -394,4 +394,43 @@ NativeBridgeNP(clearDynamicSign, jboolean) {
|
||||
bool result = clear_dynamic_sign();
|
||||
LogDebug("clearDynamicSign: result=%d", result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
NativeBridgeNP(getManagersList, jobject) {
|
||||
struct manager_list_info info;
|
||||
bool result = get_managers_list(&info);
|
||||
|
||||
if (!result) {
|
||||
LogDebug("getManagersList: failed to get managers list");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jclass cls = GetEnvironment()->FindClass(env, "com/sukisu/ultra/Natives$ManagersList");
|
||||
jmethodID constructor = GetEnvironment()->GetMethodID(env, cls, "<init>", "()V");
|
||||
jobject obj = GetEnvironment()->NewObject(env, cls, constructor);
|
||||
|
||||
jfieldID countField = GetEnvironment()->GetFieldID(env, cls, "count", "I");
|
||||
jfieldID managersField = GetEnvironment()->GetFieldID(env, cls, "managers", "Ljava/util/List;");
|
||||
|
||||
GetEnvironment()->SetIntField(env, obj, countField, (jint)info.count);
|
||||
|
||||
jclass arrayListCls = GetEnvironment()->FindClass(env, "java/util/ArrayList");
|
||||
jmethodID arrayListConstructor = GetEnvironment()->GetMethodID(env, arrayListCls, "<init>", "()V");
|
||||
jobject managersList = GetEnvironment()->NewObject(env, arrayListCls, arrayListConstructor);
|
||||
jmethodID addMethod = GetEnvironment()->GetMethodID(env, arrayListCls, "add", "(Ljava/lang/Object;)Z");
|
||||
|
||||
jclass managerInfoCls = GetEnvironment()->FindClass(env, "com/sukisu/ultra/Natives$ManagerInfo");
|
||||
jmethodID managerInfoConstructor = GetEnvironment()->GetMethodID(env, managerInfoCls, "<init>", "(II)V");
|
||||
|
||||
for (int i = 0; i < info.count; i++) {
|
||||
jobject managerInfo = GetEnvironment()->NewObject(env, managerInfoCls, managerInfoConstructor,
|
||||
(jint)info.managers[i].uid,
|
||||
(jint)info.managers[i].signature_index);
|
||||
GetEnvironment()->CallBooleanMethod(env, managersList, addMethod, managerInfo);
|
||||
}
|
||||
|
||||
GetEnvironment()->SetObjectField(env, obj, managersField, managersList);
|
||||
|
||||
LogDebug("getManagersList: count=%d", info.count);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#define CMD_HOOK_TYPE 101
|
||||
#define CMD_GET_SUSFS_FEATURE_STATUS 102
|
||||
#define CMD_DYNAMIC_SIGN 103
|
||||
#define CMD_GET_MANAGERS 104
|
||||
|
||||
#define DYNAMIC_SIGN_OP_SET 0
|
||||
#define DYNAMIC_SIGN_OP_GET 1
|
||||
@@ -173,4 +174,12 @@ bool clear_dynamic_sign() {
|
||||
struct dynamic_sign_user_config config;
|
||||
config.operation = DYNAMIC_SIGN_OP_CLEAR;
|
||||
return ksuctl(CMD_DYNAMIC_SIGN, &config, NULL);
|
||||
}
|
||||
|
||||
bool get_managers_list(struct manager_list_info* info) {
|
||||
if (info == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ksuctl(CMD_GET_MANAGERS, info, NULL);
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "prelude.h"
|
||||
#include <linux/capability.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
bool become_manager(const char *);
|
||||
|
||||
@@ -105,6 +106,14 @@ struct app_profile {
|
||||
};
|
||||
};
|
||||
|
||||
struct manager_list_info {
|
||||
int count;
|
||||
struct {
|
||||
uid_t uid;
|
||||
int signature_index;
|
||||
} managers[2];
|
||||
};
|
||||
|
||||
bool set_app_profile(const struct app_profile* profile);
|
||||
|
||||
bool get_app_profile(char* key, struct app_profile* profile);
|
||||
@@ -125,4 +134,6 @@ bool get_dynamic_sign(struct dynamic_sign_user_config* config);
|
||||
|
||||
bool clear_dynamic_sign();
|
||||
|
||||
bool get_managers_list(struct manager_list_info* info);
|
||||
|
||||
#endif //KERNELSU_KSU_H
|
||||
Reference in New Issue
Block a user