|
10 | 10 |
|
11 | 11 | REPLACE=" |
12 | 12 | " |
13 | | - |
14 | | -########################################################################################## |
15 | | -# Storage Compatibility for KSU and SUFS |
16 | | -########################################################################################## |
17 | | - |
18 | | -# Ensure proper storage paths for different root methods |
19 | | -# This handles cases where MODPATH might not be set correctly |
20 | | -if [ -z "$MODPATH" ]; then |
21 | | - if [ "$KSU" = "true" ] || [ "$SUFS" = "true" ]; then |
22 | | - MODPATH="/data/adb/modules/mod_frameworks" |
23 | | - else |
24 | | - MODPATH="/data/adb/modules/mod_frameworks" |
25 | | - fi |
26 | | -fi |
27 | | - |
28 | | -# Additional compatibility for different storage locations |
29 | | -if [ ! -d "$MODPATH" ]; then |
30 | | - if [ -d "/data/adb/modules_update/mod_frameworks" ]; then |
31 | | - MODPATH="/data/adb/modules_update/mod_frameworks" |
32 | | - elif [ -d "/data/modules/mod_frameworks" ]; then |
33 | | - MODPATH="/data/modules/mod_frameworks" |
34 | | - fi |
35 | | -fi |
36 | | - |
37 | | -########################################################################################## |
38 | | -# KSU Storage Protection - Prevent /sdcard unmounting |
39 | | -########################################################################################## |
40 | | - |
41 | | -# Fix KSU storage issues that cause /sdcard to become unusable |
42 | | -if [ "$KSU" = "true" ]; then |
43 | | - # Prevent /sdcard from being unmounted during module installation |
44 | | - # This is a common KSU issue where storage becomes inaccessible |
45 | | - if [ -d "/sdcard" ]; then |
46 | | - # Ensure /sdcard remains accessible |
47 | | - mount | grep -q "/sdcard" || { |
48 | | - # Try to remount /sdcard if it's not mounted |
49 | | - mount -t sdcardfs -o rw,nosuid,nodev,noexec,relatime /data/media /sdcard 2>/dev/null || { |
50 | | - ui_print "Warning: Could not remount /sdcard, storage may be inaccessible" |
51 | | - } |
52 | | - } |
53 | | - fi |
54 | | - |
55 | | - # Fix framework.jar storage path issues in KSU |
56 | | - # KSU sometimes has incorrect paths for system files |
57 | | - if [ ! -f "/system/framework/framework.jar" ] && [ -f "$MODPATH/system/framework/framework.jar" ]; then |
58 | | - ui_print "Fixing framework.jar path for KSU compatibility" |
59 | | - # Ensure the original framework.jar exists before replacement |
60 | | - if [ ! -d "/data/local/tmp/framework_backup" ]; then |
61 | | - mkdir -p "/data/local/tmp/framework_backup" |
62 | | - fi |
63 | | - fi |
64 | | -fi |
65 | | - |
66 | | -# Additional storage protection for all root methods |
67 | | -# Ensure external storage remains accessible |
68 | | -if [ -d "/storage/emulated/0" ]; then |
69 | | - mount | grep -q "/storage/emulated/0" || { |
70 | | - mount -t sdcardfs -o rw,nosuid,nodev,noexec,relatime /data/media /storage/emulated/0 2>/dev/null || true |
71 | | - } |
72 | | -fi |
73 | | - |
74 | | -# Fix common storage path issues |
75 | | -STORAGE_PATHS="/sdcard /storage/emulated/0 /data/media /storage" |
76 | | -for path in $STORAGE_PATHS; do |
77 | | - if [ -d "$path" ]; then |
78 | | - # Test if storage is writable |
79 | | - echo "test" > "$path/.access_test" 2>/dev/null && rm -f "$path/.access_test" 2>/dev/null || { |
80 | | - ui_print "Warning: Storage path $path is not writable" |
81 | | - } |
82 | | - fi |
83 | | -done |
84 | | - |
85 | 13 | ########################################################################################## |
86 | 14 | # Permissions |
87 | 15 | ########################################################################################## |
|
0 commit comments