300300# Set permissions
301301ui_print " "
302302ui_print " - Setting Permissions"
303-
304- # KSU Storage Protection - Ensure storage remains accessible
305- if $KSU ; then
306- ui_print " - Applying KSU storage protection"
307- # Prevent /sdcard unmounting during module installation
308- if [ -d " /sdcard" ]; then
309- mount | grep -q " /sdcard" || {
310- ui_print " - Remounting /sdcard for KSU compatibility"
311- mount -t sdcardfs -o rw,nosuid,nodev,noexec,relatime /data/media /sdcard 2> /dev/null || {
312- ui_print " ! Warning: Could not remount /sdcard"
313- }
314- }
315- fi
316-
317- # Fix framework.jar storage paths for KSU
318- if [ -f " $MODPATH /system/framework/framework.jar" ]; then
319- ui_print " - Securing framework.jar storage path"
320- # Create backup directory for safety
321- mkdir -p " /data/local/tmp/framework_backup" 2> /dev/null
322- # Ensure proper permissions for framework files
323- chmod 644 " $MODPATH /system/framework/" * .jar 2> /dev/null || true
324- fi
325- fi
326-
327- # Framework Storage Protection for all root methods
328- if [ -f " $MODPATH /system/framework/framework.jar" ]; then
329- ui_print " - Securing framework file storage"
330- # Ensure framework files have proper permissions and are accessible
331- find " $MODPATH /system/framework" -name " *.jar" -exec chmod 644 {} \; 2> /dev/null || true
332- find " $MODPATH /system/system_ext/framework" -name " *.jar" -exec chmod 644 {} \; 2> /dev/null || true
333- fi
334303set_perm_recursive $MODPATH 0 0 0755 0644
335304for i in /system/vendor /vendor /system/vendor/app /vendor/app /system/vendor/etc /vendor/etc /system/odm/etc /odm/etc /system/vendor/odm/etc /vendor/odm/etc /system/vendor/overlay /vendor/overlay; do
336305 if [ -d " $MODPATH$i " ] && [ ! -L " $MODPATH$i " ]; then
@@ -347,61 +316,5 @@ for i in $(find $MODPATH/system/vendor $MODPATH/vendor -type f -name *".apk" 2>/
347316done
348317set_permissions
349318
350- # #########################################################################################
351- # Storage Remount Protection Function
352- # #########################################################################################
353-
354- protect_storage () {
355- ui_print " "
356- ui_print " - Protecting Storage Access"
357-
358- # Protect /sdcard from being unmounted
359- if [ -d " /sdcard" ]; then
360- if ! mount | grep -q " /sdcard" ; then
361- ui_print " - Remounting /sdcard"
362- mount -t sdcardfs -o rw,nosuid,nodev,noexec,relatime /data/media /sdcard 2> /dev/null || {
363- ui_print " ! Failed to remount /sdcard"
364- }
365- fi
366- fi
367-
368- # Protect emulated storage
369- if [ -d " /storage/emulated/0" ]; then
370- if ! mount | grep -q " /storage/emulated/0" ; then
371- ui_print " - Remounting emulated storage"
372- mount -t sdcardfs -o rw,nosuid,nodev,noexec,relatime /data/media /storage/emulated/0 2> /dev/null || true
373- fi
374- fi
375-
376- # Protect external storage
377- for storage_path in /storage/* ; do
378- if [ -d " $storage_path " ] && [ " $storage_path " != " /storage/emulated" ]; then
379- if ! mount | grep -q " $storage_path " ; then
380- ui_print " - Checking external storage: $( basename $storage_path ) "
381- # Try to mount external storage if accessible
382- mountpoint -q " $storage_path " || {
383- ui_print " ! External storage $( basename $storage_path ) not accessible"
384- }
385- fi
386- fi
387- done
388-
389- # Test storage accessibility
390- ui_print " - Testing storage access"
391- for test_path in " /sdcard" " /storage/emulated/0" ; do
392- if [ -d " $test_path " ]; then
393- if echo " test" > " $test_path /.storage_test" 2> /dev/null; then
394- rm -f " $test_path /.storage_test" 2> /dev/null
395- ui_print " ✓ $test_path is accessible"
396- else
397- ui_print " ✗ $test_path is not writable"
398- fi
399- fi
400- done
401- }
402-
403- # Call storage protection at the end of installation
404- protect_storage
405-
406319# Complete install
407- cleanup
320+ cleanup
0 commit comments