|
2 | 2 | # scripts/core/module.sh |
3 | 3 | # Module creation functions |
4 | 4 |
|
5 | | -create_module() { |
6 | | - # local api_level="$1" # Currently unused but kept for future use |
7 | | - local device_name="$2" |
8 | | - local version_name="$3" |
9 | | - |
10 | | - log "Creating module using FrameworkPatcherModule for $device_name (v$version_name)" |
11 | | - |
12 | | - local build_dir="build_module" |
13 | | - rm -rf "$build_dir" |
14 | | - |
15 | | - # Copy FrameworkPatcherModule template |
16 | | - cp -r "templates/framework-patcher-module" "$build_dir" || { |
17 | | - err "FrameworkPatcherModule template not found: templates/framework-patcher-module" |
18 | | - return 1 |
19 | | - } |
20 | | - |
21 | | - # Clean up unnecessary files from FrameworkPatcherModule template |
22 | | - rm -f "$build_dir/.git" "$build_dir/.gitignore" "$build_dir/.gitattributes" |
23 | | - rm -f "$build_dir/README.md" "$build_dir/changelog.md" "$build_dir/LICENSE" |
24 | | - rm -f "$build_dir/update.json" "$build_dir/install.zip" |
25 | | - rm -rf "$build_dir/common/addon" "$build_dir/zygisk" |
26 | | - rm -f "$build_dir/system/placeholder" "$build_dir/common/addon/placeholder" "$build_dir/zygisk/placeholder" |
27 | | - |
28 | | - # Update module.prop for universal compatibility |
29 | | - local module_prop="$build_dir/module.prop" |
30 | | - if [ -f "$module_prop" ]; then |
31 | | - # Update basic properties |
32 | | - sed -i "s/^id=.*/id=mod_frameworks/" "$module_prop" |
33 | | - sed -i "s/^name=.*/name=Framework Patch V2/" "$module_prop" |
34 | | - sed -i "s/^version=.*/version=$version_name/" "$module_prop" |
35 | | - sed -i "s/^versionCode=.*/versionCode=$version_name/" "$module_prop" |
36 | | - sed -i "s/^author=.*/author=Jᴇғɪɴᴏ ⚝/" "$module_prop" |
37 | | - sed -i "s/^description=.*/description=Framework patcher compatible with Magisk, KernelSU (KSU), and SUFS. Patched using jefino9488.github.io\/FrameworkPatcherV2/" "$module_prop" |
38 | | - |
39 | | - # Remove updateJson line |
40 | | - sed -i "/^updateJson=/d" "$module_prop" |
41 | | - |
42 | | - # Add universal compatibility properties |
43 | | - { |
44 | | - echo "minMagisk=20400" |
45 | | - echo "ksu=1" |
46 | | - echo "minKsu=10904" |
47 | | - echo "sufs=1" |
48 | | - echo "minSufs=10000" |
49 | | - echo "minApi=34" |
50 | | - echo "maxApi=34" |
51 | | - echo "requireReboot=true" |
52 | | - echo "support=https://t.me/Jefino9488" |
53 | | - } >>"$module_prop" |
54 | | - fi |
55 | | - |
56 | | - # Update customize.sh with framework replacements |
57 | | - local customize_sh="$build_dir/customize.sh" |
58 | | - if [ -f "$customize_sh" ]; then |
59 | | - # Replace the empty REPLACE section with our framework files |
60 | | - sed -i '/^REPLACE="/,/^"/c\ |
61 | | -REPLACE="\ |
62 | | -/system/framework/framework.jar\ |
63 | | -/system/framework/services.jar\ |
64 | | -/system/system_ext/framework/miui-services.jar\ |
65 | | -"' "$customize_sh" |
66 | | - fi |
67 | | - |
68 | | - # Create required directories and copy patched files |
69 | | - mkdir -p "$build_dir/system/framework" |
70 | | - mkdir -p "$build_dir/system/system_ext/framework" |
71 | | - |
72 | | - # copy patched files (if present in cwd) |
73 | | - [ -f "framework_patched.jar" ] && cp "framework_patched.jar" "$build_dir/system/framework/framework.jar" |
74 | | - [ -f "services_patched.jar" ] && cp "services_patched.jar" "$build_dir/system/framework/services.jar" |
75 | | - [ -f "miui-services_patched.jar" ] && cp "miui-services_patched.jar" "$build_dir/system/system_ext/framework/miui-services.jar" |
76 | | - |
77 | | - # Copy Kaorios Toolbox files if present |
78 | | - if [ -d "kaorios_toolbox" ]; then |
79 | | - log "Including Kaorios Toolbox components in module" |
80 | | - mkdir -p "$build_dir/kaorios" |
81 | | - |
82 | | - # Copy APK and permission XML |
83 | | - [ -f "kaorios_toolbox/KaoriosToolbox.apk" ] && cp "kaorios_toolbox/KaoriosToolbox.apk" "$build_dir/kaorios/" |
84 | | - [ -f "kaorios_toolbox/privapp_whitelist_com.kousei.kaorios.xml" ] && cp "kaorios_toolbox/privapp_whitelist_com.kousei.kaorios.xml" "$build_dir/kaorios/" |
85 | | - |
86 | | - # Data files removed - app fetches from its own repository |
87 | | - # Version info for tracking |
88 | | - [ -f "kaorios_toolbox/version.txt" ] && cp "kaorios_toolbox/version.txt" "$build_dir/kaorios/" |
89 | | - |
90 | | - log "✓ Kaorios Toolbox files added to module" |
91 | | - fi |
92 | | - |
93 | | - local safe_version |
94 | | - safe_version=$(printf "%s" "$version_name" | sed 's/[. ]/-/g') |
95 | | - local zip_name="Framework-Patcher-${device_name}-${safe_version}.zip" |
96 | | - |
97 | | - if command -v 7z >/dev/null 2>&1; then |
98 | | - (cd "$build_dir" && 7z a -tzip "../$zip_name" "*" >/dev/null) || { |
99 | | - err "7z failed to create $zip_name" |
100 | | - return 1 |
101 | | - } |
102 | | - elif command -v zip >/dev/null 2>&1; then |
103 | | - (cd "$build_dir" && zip -r "../$zip_name" . >/dev/null) || { |
104 | | - err "zip failed to create $zip_name" |
105 | | - return 1 |
106 | | - } |
107 | | - else |
108 | | - err "No archiver found (7z or zip). Install one to create module archive." |
109 | | - return 1 |
110 | | - fi |
111 | | - |
112 | | - log "Created module: $zip_name" |
113 | | - echo "$zip_name" |
114 | | -} |
115 | | - |
116 | | -# Legacy function for backward compatibility |
117 | | -create_magisk_module() { |
118 | | - create_module "$1" "$2" "$3" "magisk" |
119 | | -} |
120 | 5 |
|
121 | 6 | create_kaorios_module() { |
| 7 | + # shellcheck disable=SC2034 |
122 | 8 | local device_name="Generic" |
123 | 9 | local version_name="1.0" |
124 | 10 | local template_url="https://github.com/Zackptg5/MMT-Extended/archive/refs/heads/master.zip" |
@@ -225,15 +111,9 @@ while [ "\$(getprop sys.boot_completed)" != "1" ]; do |
225 | 111 | sleep 1 |
226 | 112 | done |
227 | 113 |
|
228 | | -# Install the APK if not already installed or if updated |
229 | | -APK_PATH="\$MODDIR/system/product/priv-app/KaoriosToolbox/KaoriosToolbox.apk" |
230 | | -PKG_NAME="com.kousei.kaorios" |
231 | | -
|
232 | | -if [ -f "\$APK_PATH" ]; then |
233 | | - # Check if package is installed |
234 | | - if ! pm list packages | grep -q "\$PKG_NAME"; then |
235 | | - pm install -r "\$APK_PATH" |
236 | | - fi |
| 114 | +# Install Kaorios Toolbox as user app (update) if present |
| 115 | +if [ -f "\$MODDIR/system/product/priv-app/KaoriosToolbox/KaoriosToolbox.apk" ]; then |
| 116 | + pm install -r "\$MODDIR/system/product/priv-app/KaoriosToolbox/KaoriosToolbox.apk" >/dev/null 2>&1 |
237 | 117 | fi |
238 | 118 | EOF |
239 | 119 | chmod +x "$build_dir/service.sh" |
|
248 | 128 | else |
249 | 129 | warn "framework_patched.jar not found!" |
250 | 130 | fi |
251 | | - |
252 | | - if [ -f "services_patched.jar" ]; then |
253 | | - cp "services_patched.jar" "$build_dir/system/framework/services.jar" |
254 | | - log "✓ Added services_patched.jar" |
255 | | - fi |
256 | 131 |
|
257 | 132 | local apk_source="kaorios_toolbox/KaoriosToolbox.apk" |
258 | 133 | if [ -f "$apk_source" ]; then |
|
268 | 143 | unzip -q "$apk_source" "lib/*" -d "$temp_extract" 2>/dev/null |
269 | 144 |
|
270 | 145 | if [ -d "$temp_extract/lib" ]; then |
271 | | - cp -r "$temp_extract/lib/"* "$build_dir/system/product/priv-app/KaoriosToolbox/lib/" |
272 | | - log "✓ Extracted native libraries from APK" |
| 146 | + # Extract and rename libraries to simplified names |
| 147 | + [ -d "$temp_extract/lib/armeabi-v7a" ] && cp -r "$temp_extract/lib/armeabi-v7a" "$build_dir/system/product/priv-app/KaoriosToolbox/lib/arm" |
| 148 | + [ -d "$temp_extract/lib/arm64-v8a" ] && cp -r "$temp_extract/lib/arm64-v8a" "$build_dir/system/product/priv-app/KaoriosToolbox/lib/arm64" |
| 149 | + [ -d "$temp_extract/lib/x86" ] && cp -r "$temp_extract/lib/x86" "$build_dir/system/product/priv-app/KaoriosToolbox/lib/x86" |
| 150 | + [ -d "$temp_extract/lib/x86_64" ] && cp -r "$temp_extract/lib/x86_64" "$build_dir/system/product/priv-app/KaoriosToolbox/lib/x86_64" |
| 151 | + |
| 152 | + log "✓ Extracted and renamed native libraries from APK" |
273 | 153 | else |
274 | 154 | warn "No native libraries found in APK or extraction failed" |
275 | 155 | fi |
|
0 commit comments