private List < String > existingRWPaths ( ) { String [ ] lines = mountReader ( ) ; List < String > pathsFound = new ArrayList <> ( ) ; for ( String line : lines ) { // Split lines into parts String [ ] args = line . split ( " " ) ; if ( args . length < 4 ) { // If we don't have enough options per line, skip this and log an error Log . e ( TAG , String . format ( "Error formatting mount: %s" , line ) ) ; continue ; } String mountPoint = args [ 1 ] ; String mountOptions = args [ 3 ] ; for ( String pathToCheck : PATHS_THAT_SHOULD_NOT_BE_WRITABLE ) { if ( mountPoint . equalsIgnoreCase ( pathToCheck ) ) { // Split options out and compare against "rw" to avoid false positives for ( String option : mountOptions . split ( "," ) ) { if ( option . equalsIgnoreCase ( "rw" ) ) { pathsFound . add ( pathToCheck ) ; break ; } } } } } return pathsFound ; }
When you re root you can change the write permissions on common system directories . This method checks if any of the paths in PATHS_THAT_SHOULD_NOT_BE_WRITABLE are writable .