Official KitKat support

This commit is contained in:
topjohnwu 2018-12-28 16:03:23 +08:00
parent e6942e0122
commit 0be158afa1
4 changed files with 22 additions and 13 deletions

View File

@ -6,7 +6,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import com.google.android.material.snackbar.Snackbar;
@ -23,6 +22,7 @@ import java.util.List;
import java.util.Set;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
@ -144,9 +144,9 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
@BindView(R.id.app_name) TextView appName;
@BindView(R.id.package_name) TextView packageName;
@BindView(R.id.app_icon) ImageView appIcon;
@BindView(R.id.master_switch) Switch masterSwitch;
@BindView(R.id.notification_switch) Switch notificationSwitch;
@BindView(R.id.logging_switch) Switch loggingSwitch;
@BindView(R.id.master_switch) SwitchCompat masterSwitch;
@BindView(R.id.notification_switch) SwitchCompat notificationSwitch;
@BindView(R.id.logging_switch) SwitchCompat loggingSwitch;
@BindView(R.id.expand_layout) ViewGroup expandLayout;
@BindView(R.id.delete) ImageView delete;

View File

@ -67,7 +67,7 @@
</LinearLayout>
<Switch
<androidx.appcompat.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/master_switch"
@ -105,7 +105,7 @@
android:tint="@color/icon_grey"
android:layout_marginEnd="10dp" />
<Switch
<androidx.appcompat.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/notification_switch"
@ -132,7 +132,7 @@
android:tint="@color/icon_grey"
android:layout_marginEnd="10dp" />
<Switch
<androidx.appcompat.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/logging_switch"

View File

@ -17,9 +17,10 @@
#include "utils.h"
#include "su.h"
#define AM_PATH "/system/bin/app_process", "/system/bin", "com.android.commands.am.Am"
#define AM_PATH "/system/bin/app_process", "/system/bin", "com.android.commands.am.Am"
#define RECEIVER "a.h"
static const char *get_command(const struct su_request *to) {
static inline const char *get_command(const struct su_request *to) {
if (to->command[0])
return to->command;
if (to->shell[0])
@ -71,10 +72,13 @@ void app_log(struct su_context *ctx) {
char policy[2];
sprintf(policy, "%d", ctx->info->access.policy);
char component[128];
sprintf(component, "%s/" RECEIVER, ctx->info->str[SU_MANAGER]);
const char *cmd[] = {
AM_PATH, "broadcast",
"-a", "android.intent.action.BOOT_COMPLETED",
"-p", ctx->info->str[SU_MANAGER],
"-n", component,
"-f", "0x00000020",
"--user", user,
"--es", "action", "log",
@ -101,10 +105,13 @@ void app_notify(struct su_context *ctx) {
char policy[2];
sprintf(policy, "%d", ctx->info->access.policy);
char component[128];
sprintf(component, "%s/" RECEIVER, ctx->info->str[SU_MANAGER]);
const char *cmd[] = {
AM_PATH, "broadcast",
"-a", "android.intent.action.BOOT_COMPLETED",
"-p", ctx->info->str[SU_MANAGER],
"-n", component,
"-f", "0x00000020",
"--user", user,
"--es", "action", "notify",
@ -118,10 +125,12 @@ void app_notify(struct su_context *ctx) {
void app_connect(const char *socket, struct su_info *info) {
char user[8];
setup_user(user, info);
char component[128];
sprintf(component, "%s/" RECEIVER, info->str[SU_MANAGER]);
const char *cmd[] = {
AM_PATH, "broadcast",
"-a", "android.intent.action.BOOT_COMPLETED",
"-p", info->str[SU_MANAGER],
"-n", component,
"-f", "0x00000020",
"--user", user,
"--es", "action", "request",

View File

@ -57,7 +57,7 @@ ui_print "- Target image: $BOOTIMAGE"
# Detect version and architecture
api_level_arch_detect
[ $API -lt 21 ] && abort "! Magisk is only for Lollipop and above (5.0+) (SDK 21+)"
[ $API -lt 19 ] && abort "! Magisk is only for KitKat and above (4.4+) (SDK 19+)"
ui_print "- Device platform: $ARCH"