Skip to content

Commit

Permalink
Small native code reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Mar 9, 2020
1 parent d6fdbfe commit a099800
Show file tree
Hide file tree
Showing 85 changed files with 216 additions and 317 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ tools/** binary
*.png binary
*.jpg binary
*.ttf binary

# Help GitHub detect languages
native/jni/external/** linguist-vendored
native/jni/systemproperties/** linguist-language=C++
4 changes: 0 additions & 4 deletions native/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ LOCAL_SRC_FILES := \
magiskhide/hide_policy.cpp \
resetprop/persist_properties.cpp \
resetprop/resetprop.cpp \
resetprop/system_property_api.cpp \
resetprop/system_property_set.cpp \
su/su.cpp \
su/connect.cpp \
su/pts.cpp \
Expand Down Expand Up @@ -167,8 +165,6 @@ LOCAL_SRC_FILES := \
core/applet_stub.cpp \
resetprop/persist_properties.cpp \
resetprop/resetprop.cpp \
resetprop/system_property_api.cpp \
resetprop/system_property_set.cpp

LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=resetprop_main
LOCAL_LDFLAGS := -static
Expand Down
2 changes: 1 addition & 1 deletion native/jni/core/applet_stub.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <sys/stat.h>

#include <magisk.h>
#include <magisk.hpp>

int main(int argc, char *argv[]) {
umask(0);
Expand Down
6 changes: 3 additions & 3 deletions native/jni/core/applets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <sys/types.h>
#include <sys/stat.h>

#include <magisk.h>
#include <selinux.h>
#include <utils.h>
#include <magisk.hpp>
#include <selinux.hpp>
#include <utils.hpp>

using namespace std::literals;

Expand Down
12 changes: 6 additions & 6 deletions native/jni/core/bootstages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include <vector>
#include <string>

#include <magisk.h>
#include <db.h>
#include <utils.h>
#include <daemon.h>
#include <resetprop.h>
#include <selinux.h>
#include <magisk.hpp>
#include <db.hpp>
#include <utils.hpp>
#include <daemon.hpp>
#include <resetprop.hpp>
#include <selinux.hpp>
#include <flags.h>

using namespace std;
Expand Down
12 changes: 6 additions & 6 deletions native/jni/core/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <sys/types.h>
#include <sys/mount.h>

#include <magisk.h>
#include <utils.h>
#include <daemon.h>
#include <selinux.h>
#include <db.h>
#include <resetprop.h>
#include <magisk.hpp>
#include <utils.hpp>
#include <daemon.hpp>
#include <selinux.hpp>
#include <db.hpp>
#include <resetprop.hpp>
#include <flags.h>

int SDK_INT = -1;
Expand Down
8 changes: 4 additions & 4 deletions native/jni/core/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include <dlfcn.h>
#include <sys/stat.h>

#include <magisk.h>
#include <db.h>
#include <daemon.h>
#include <utils.h>
#include <magisk.hpp>
#include <db.hpp>
#include <daemon.hpp>
#include <utils.hpp>

#define DB_VERSION 10

Expand Down
8 changes: 4 additions & 4 deletions native/jni/core/magisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <libgen.h>
#include <string.h>

#include <utils.h>
#include <magisk.h>
#include <daemon.h>
#include <selinux.h>
#include <utils.hpp>
#include <magisk.hpp>
#include <daemon.hpp>
#include <selinux.hpp>
#include <flags.h>

using namespace std::literals;
Expand Down
6 changes: 3 additions & 3 deletions native/jni/core/scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <string>
#include <vector>

#include <magisk.h>
#include <utils.h>
#include <selinux.h>
#include <magisk.hpp>
#include <utils.hpp>
#include <selinux.hpp>

using namespace std;

Expand Down
6 changes: 3 additions & 3 deletions native/jni/core/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <fcntl.h>
#include <endian.h>

#include <daemon.h>
#include <utils.h>
#include <logging.h>
#include <daemon.hpp>
#include <utils.hpp>
#include <logging.hpp>

#define ABS_SOCKET_LEN(sun) (sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1)

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <logging.h>
#include <logging.hpp>

#define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591"
#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <stdlib.h>
#include <selinux.h>
#include <selinux.hpp>

#define ALL NULL

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions native/jni/init/getinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <fcntl.h>
#include <vector>

#include <utils.h>
#include <logging.h>
#include <utils.hpp>
#include <logging.hpp>

#include "init.h"
#include "init.hpp"

using namespace std;

Expand Down
8 changes: 4 additions & 4 deletions native/jni/init/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <vector>

#include <xz.h>
#include <magisk.h>
#include <cpio.h>
#include <utils.h>
#include <magisk.hpp>
#include <cpio.hpp>
#include <utils.hpp>
#include <flags.h>

#include "binaries.h"
Expand All @@ -20,7 +20,7 @@
#include "binaries_arch.h"
#endif

#include "init.h"
#include "init.hpp"

using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion native/jni/init/init.h → native/jni/init/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdlib.h>
#include <vector>

#include <magisk.h>
#include <magisk.hpp>

struct cmdline {
bool skip_initramfs;
Expand Down
4 changes: 2 additions & 2 deletions native/jni/init/magiskrc.h → native/jni/init/magiskrc.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <magisk.h>
#include <selinux.h>
#include <magisk.hpp>
#include <selinux.hpp>

constexpr char magiskrc[] =
"\n"
Expand Down
10 changes: 5 additions & 5 deletions native/jni/init/mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <stdio.h>
#include <vector>

#include <utils.h>
#include <logging.h>
#include <selinux.h>
#include <magisk.h>
#include <utils.hpp>
#include <logging.hpp>
#include <selinux.hpp>
#include <magisk.hpp>

#include "init.h"
#include "init.hpp"

using namespace std;

Expand Down
10 changes: 5 additions & 5 deletions native/jni/init/rootdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <fcntl.h>
#include <vector>

#include <magisk.h>
#include <magiskpolicy.h>
#include <utils.h>
#include <magisk.hpp>
#include <magiskpolicy.hpp>
#include <utils.hpp>

#include "init.h"
#include "magiskrc.h"
#include "init.hpp"
#include "magiskrc.inc"

#ifdef USE_64BIT
#define LIBNAME "lib64"
Expand Down
10 changes: 5 additions & 5 deletions native/jni/magiskboot/bootimg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

#include <mincrypt/sha.h>
#include <mincrypt/sha256.h>
#include <utils.h>
#include <logging.h>
#include <utils.hpp>
#include <logging.hpp>

#include "bootimg.h"
#include "magiskboot.h"
#include "compress.h"
#include "bootimg.hpp"
#include "magiskboot.hpp"
#include "compress.hpp"

using namespace std;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stdint.h>
#include <utility>
#include "format.h"
#include "format.hpp"

/****************
* Other Headers
Expand Down
8 changes: 4 additions & 4 deletions native/jni/magiskboot/compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#include <lz4frame.h>
#include <lz4hc.h>

#include <logging.h>
#include <utils.h>
#include <logging.hpp>
#include <utils.hpp>

#include "magiskboot.h"
#include "compress.h"
#include "magiskboot.hpp"
#include "compress.hpp"

using namespace std;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <stream.h>
#include <stream.hpp>

#include "format.h"
#include "format.hpp"

stream_ptr get_encoder(format_t type, stream_ptr &&base);

Expand Down
6 changes: 3 additions & 3 deletions native/jni/magiskboot/dtb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
extern "C" {
#include <libfdt.h>
}
#include <utils.h>
#include <utils.hpp>

#include "magiskboot.h"
#include "dtb.h"
#include "magiskboot.hpp"
#include "dtb.hpp"

using namespace std;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion native/jni/magiskboot/format.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <string.h>

#include "format.h"
#include "format.hpp"

std::map<std::string_view, format_t> name2fmt;
Fmt2Name fmt2name;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions native/jni/magiskboot/hexpatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <string.h>
#include <sys/mman.h>

#include <utils.h>
#include <utils.hpp>

#include "magiskboot.h"
#include "magiskboot.hpp"

static void hex2byte(uint8_t *hex, uint8_t *str) {
char high, low;
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions native/jni/magiskboot/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include <sys/mman.h>

#include <mincrypt/sha.h>
#include <logging.h>
#include <utils.h>
#include <logging.hpp>
#include <utils.hpp>
#include <flags.h>

#include "magiskboot.h"
#include "compress.h"
#include "magiskboot.hpp"
#include "compress.hpp"

using namespace std;

Expand Down
4 changes: 2 additions & 2 deletions native/jni/magiskboot/pattern.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <malloc.h>
#include <string.h>

#include <utils.h>
#include <utils.hpp>

#include "magiskboot.h"
#include "magiskboot.hpp"

#define MATCH(p) else if (strncmp(s + skip, p, sizeof(p) - 1) == 0) skip += (sizeof(p) - 1)

Expand Down
8 changes: 4 additions & 4 deletions native/jni/magiskboot/ramdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include <stdlib.h>
#include <sys/stat.h>

#include <utils.h>
#include <cpio.h>
#include <utils.hpp>
#include <cpio.hpp>

#include "magiskboot.h"
#include "compress.h"
#include "magiskboot.hpp"
#include "compress.hpp"

using namespace std;

Expand Down
10 changes: 5 additions & 5 deletions native/jni/magiskhide/hide_policy.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <sys/mount.h>

#include <magisk.h>
#include <utils.h>
#include <selinux.h>
#include <resetprop.h>
#include <magisk.hpp>
#include <utils.hpp>
#include <selinux.hpp>
#include <resetprop.hpp>

#include "magiskhide.h"
#include "magiskhide.hpp"

using namespace std;

Expand Down
Loading

0 comments on commit a099800

Please sign in to comment.