mirror of
				https://github.com/topjohnwu/Magisk
				synced 2025-10-30 09:00:52 +01:00 
			
		
		
		
	Compare commits
	
		
			17 Commits
		
	
	
		
			manager-v4
			...
			manager-v4
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 435251ca41 | ||
|   | 324a0dd38f | ||
|   | cc77d93918 | ||
|   | 0ea7d8bd8c | ||
|   | 849b217143 | ||
|   | 9af6efba59 | ||
|   | 079d6f06ef | ||
|   | 9cf0757689 | ||
|   | b54c438948 | ||
|   | c3ff4bfdad | ||
|   | 5d62e066e2 | ||
|   | e94219c5a3 | ||
|   | 8ed9634adf | ||
|   | 0aefa9599f | ||
|   | e279cf0575 | ||
|   | a3f0ef8e77 | ||
|   | 8eba05ed4a | 
| @@ -8,8 +8,8 @@ android { | ||||
|         applicationId "com.topjohnwu.magisk" | ||||
|         minSdkVersion 21 | ||||
|         targetSdkVersion 25 | ||||
|         versionCode 23 | ||||
|         versionName "4.2" | ||||
|         versionCode 26 | ||||
|         versionName "4.2.7" | ||||
|         jackOptions { | ||||
|             enabled true | ||||
|             jackInProcess true | ||||
| @@ -47,10 +47,10 @@ repositories { | ||||
| dependencies { | ||||
|     compile fileTree(include: ['*.jar'], dir: 'libs') | ||||
|  | ||||
|     compile 'com.android.support:recyclerview-v7:25.1.1' | ||||
|     compile 'com.android.support:cardview-v7:25.1.1' | ||||
|     compile 'com.android.support:design:25.1.1' | ||||
|     compile 'com.android.support:support-v4:25.1.1' | ||||
|     compile 'com.android.support:recyclerview-v7:25.3.0' | ||||
|     compile 'com.android.support:cardview-v7:25.3.0' | ||||
|     compile 'com.android.support:design:25.3.0' | ||||
|     compile 'com.android.support:support-v4:25.3.0' | ||||
|     compile 'com.jakewharton:butterknife:8.5.1' | ||||
|     compile 'com.github.clans:fab:1.6.4' | ||||
|     compile 'com.thoughtbot:expandablerecyclerview:1.4' | ||||
|   | ||||
| @@ -1,21 +1,20 @@ | ||||
| #!/system/bin/sh | ||||
|  | ||||
| [ -z $BOOTMODE ] && BOOTMODE=false | ||||
| TMPDIR=/tmp | ||||
| ($BOOTMODE) && TMPDIR=/dev/tmp | ||||
|  | ||||
| BINDIR=/data/magisk | ||||
| CHROMEDIR=$BINDIR/chromeos | ||||
| # This path should work in any cases | ||||
| TMPDIR=/dev/tmp | ||||
|  | ||||
| NEWBOOT=$TMPDIR/boottmp/new-boot.img | ||||
| UNPACKDIR=$TMPDIR/boottmp/bootunpack | ||||
| RAMDISK=$TMPDIR/boottmp/ramdisk | ||||
| BOOTTMP=$TMPDIR/boottmp | ||||
| MAGISKBIN=/data/magisk | ||||
| CHROMEDIR=$MAGISKBIN/chromeos | ||||
|  | ||||
| SYSTEMLIB=/system/lib | ||||
| [ -d /system/lib64 ] && SYSTEMLIB=/system/lib64 | ||||
|  | ||||
| ui_print() { | ||||
|   echo "$1" | ||||
| # Default permissions | ||||
| umask 022 | ||||
|  | ||||
| ui_print_wrapper() { | ||||
|   type ui_print >/dev/null && ui_print "$1" || echo "$1" | ||||
| } | ||||
|  | ||||
| grep_prop() { | ||||
| @@ -25,7 +24,7 @@ grep_prop() { | ||||
|   if [ -z "$FILES" ]; then | ||||
|     FILES='/system/build.prop' | ||||
|   fi | ||||
|   cat $FILES 2>/dev/null | sed -n $REGEX | head -n 1 | ||||
|   cat $FILES 2>/dev/null | sed -n "$REGEX" | head -n 1 | ||||
| } | ||||
|  | ||||
| find_boot_image() { | ||||
| @@ -42,109 +41,93 @@ find_boot_image() { | ||||
|   fi | ||||
| } | ||||
|  | ||||
| unpack_boot() { | ||||
|   rm -rf $UNPACKDIR $RAMDISK 2>/dev/null | ||||
|   mkdir -p $UNPACKDIR | ||||
|   mkdir -p $RAMDISK | ||||
|   cd $UNPACKDIR | ||||
|   LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/bootimgtools --extract $1 | ||||
|  | ||||
|   cd $RAMDISK | ||||
|   $BINDIR/busybox gunzip -c < $UNPACKDIR/ramdisk.gz | cpio -i | ||||
| } | ||||
|  | ||||
| repack_boot() { | ||||
|   cd $RAMDISK | ||||
|   find . | cpio -o -H newc 2>/dev/null | gzip -9 > $UNPACKDIR/ramdisk.gz | ||||
|   cd $UNPACKDIR | ||||
|   LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/bootimgtools --repack $BOOTIMAGE | ||||
|   if [ -f chromeos ]; then | ||||
|     echo " " > config | ||||
|     echo " " > bootloader | ||||
|     LD_LIBRARY_PATH=$SYSTEMLIB $CHROMEDIR/futility vbutil_kernel --pack new-boot.img.signed --keyblock $CHROMEDIR/kernel.keyblock --signprivate $CHROMEDIR/kernel_data_key.vbprivk --version 1 --vmlinuz new-boot.img --config config --arch arm --bootloader bootloader --flags 0x1 | ||||
|     rm -f new-boot.img | ||||
|     mv new-boot.img.signed new-boot.img | ||||
|   fi | ||||
|   if ($SAMSUNG); then | ||||
|     SAMSUNG_CHECK=$(cat new-boot.img | grep SEANDROIDENFORCE) | ||||
|     if [ $? -ne 0 ]; then | ||||
|       echo -n "SEANDROIDENFORCE" >> new-boot.img | ||||
|     fi | ||||
|   fi | ||||
|   if ($LGE_G); then | ||||
|     # Prevent secure boot error on LG G2/G3. | ||||
|     # Just for know, It's a pattern which bootloader verifies at boot. Thanks to LG hackers. | ||||
|     echo -n -e "\x41\xa9\xe4\x67\x74\x4d\x1d\x1b\xa4\x29\xf2\xec\xea\x65\x52\x79" >> new-boot.img | ||||
|   fi | ||||
|   mv new-boot.img $NEWBOOT | ||||
| } | ||||
|  | ||||
| # Environments | ||||
| # Set permissions | ||||
| chmod -R 755 $CHROMEDIR/futility $BINDIR | ||||
| chmod -R 755 $CHROMEDIR/futility $MAGISKBIN 2>/dev/null | ||||
| # Temporary busybox for installation | ||||
| mkdir -p $TMPDIR/busybox | ||||
| $MAGISKBIN/busybox --install -s $TMPDIR/busybox | ||||
| rm -f $TMPDIR/busybox/su $TMPDIR/busybox/sh $TMPDIR/busybox/reboot | ||||
| PATH=$TMPDIR/busybox:$PATH | ||||
|  | ||||
| # Find the boot image | ||||
| find_boot_image | ||||
| if [ -z "$BOOTIMAGE" ]; then | ||||
|   ui_print "! Unable to detect boot image" | ||||
|   ui_print_wrapper "! Unable to detect boot image" | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| ui_print "- Found Boot Image: $BOOTIMAGE" | ||||
| ui_print_wrapper "- Found Boot Image: $BOOTIMAGE" | ||||
|  | ||||
| # Detect special vendors  | ||||
| SAMSUNG=false | ||||
| SAMSUNG_CHECK=$(cat /system/build.prop | grep "ro.build.fingerprint=" | grep -i "samsung") | ||||
| if [ $? -eq 0 ]; then | ||||
|   SAMSUNG=true | ||||
| fi | ||||
| LGE_G=false | ||||
| RBRAND=$(grep_prop ro.product.brand) | ||||
| RMODEL=$(grep_prop ro.product.device) | ||||
| if [ "$RBRAND" = "lge" ] || [ "$RBRAND" = "LGE" ];  then  | ||||
|   if [ "$RMODEL" = "*D80*" ] ||  | ||||
|      [ "$RMODEL" = "*S98*" ] ||  | ||||
|      [ "$RMODEL" = "*D85*" ] || | ||||
|      [ "$RMODEL" = "*F40*" ]; then | ||||
|     LGE_G=true | ||||
|     ui_print "! Bump device detected" | ||||
|   fi | ||||
| rm -rf $BOOTTMP 2>/dev/null | ||||
| mkdir -p $BOOTTMP | ||||
| cd $BOOTTMP | ||||
|  | ||||
| ui_print_wrapper "- Unpacking boot image" | ||||
| LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --unpack $BOOTIMAGE | ||||
| if [ $? -ne 0 ]; then | ||||
|   ui_print_wrapper "! Unable to unpack boot image" | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| # First unpack the boot image | ||||
| unpack_boot $BOOTIMAGE | ||||
| # Update our previous backup to new format if exists | ||||
| if [ -f /data/stock_boot.img ]; then | ||||
|   SHA1=`LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --sha1 /data/stock_boot.img | tail -n 1` | ||||
|   STOCKDUMP=/data/stock_boot_${SHA1}.img | ||||
|   mv /data/stock_boot.img $STOCKDUMP | ||||
|   LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --compress $STOCKDUMP | ||||
| fi | ||||
|  | ||||
| SUPERSU=false | ||||
| [ -f sbin/launch_daemonsu.sh ] && SUPERSU=true | ||||
|  | ||||
| if ($SUPERSU); then | ||||
|   ui_print "- SuperSU patched image detected" | ||||
|   rm -f magisk sbin/init.magisk.rc sbin/magic_mask.sh | ||||
|   repack_boot | ||||
| else | ||||
|   if [ -f /data/stock_boot.img ]; then | ||||
|     ui_print "- Boot image backup found!" | ||||
|     NEWBOOT=/data/stock_boot.img | ||||
|   else | ||||
|     ui_print "! Boot image backup unavailable" | ||||
|     if [ -d ".backup" ]; then | ||||
|       ui_print "- Restoring ramdisk with backup" | ||||
|       cp -af .backup/. . | ||||
| # Detect boot image state | ||||
| LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --cpio-test ramdisk.cpio | ||||
| case $? in | ||||
|   0 ) | ||||
|     ui_print_wrapper "! Magisk is not installed!" | ||||
|     ui_print_wrapper "! Nothing to uninstall" | ||||
|     exit | ||||
|     ;; | ||||
|   1 ) | ||||
|     # Find SHA1 of stock boot image | ||||
|     if [ -z $SHA1 ]; then | ||||
|       LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --cpio-extract ramdisk.cpio init.magisk.rc init.magisk.rc | ||||
|       SHA1=`grep_prop "# STOCKSHA1" init.magisk.rc` | ||||
|       [ ! -z $SHA1 ] && STOCKDUMP=/data/stock_boot_${SHA1}.img | ||||
|       rm -f init.magisk.rc | ||||
|     fi | ||||
|     rm -f magisk sbin/init.magisk.rc sbin/magic_mask.sh | ||||
|     repack_boot | ||||
|   fi | ||||
|     if [ -f ${STOCKDUMP}.gz ]; then | ||||
|       ui_print_wrapper "- Boot image backup found!" | ||||
|       LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --decompress ${STOCKDUMP}.gz stock_boot.img | ||||
|     else | ||||
|       ui_print_wrapper "! Boot image backup unavailable" | ||||
|       ui_print_wrapper "- Restoring ramdisk with backup" | ||||
|       LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --cpio-restore ramdisk.cpio | ||||
|       LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --repack $BOOTIMAGE stock_boot.img | ||||
|     fi | ||||
|     ;; | ||||
|   2 ) | ||||
|     ui_print_wrapper "- SuperSU patched image detected" | ||||
|     LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --cpio-restore ramdisk.cpio | ||||
|     LD_LIBRARY_PATH=$SYSTEMLIB $MAGISKBIN/magiskboot --repack $BOOTIMAGE stock_boot.img | ||||
|     ;; | ||||
| esac | ||||
|  | ||||
| # Sign chromeos boot | ||||
| if [ -f chromeos ]; then | ||||
|   echo > config | ||||
|   echo > bootloader | ||||
|   LD_LIBRARY_PATH=$SYSTEMLIB $CHROMEDIR/futility vbutil_kernel --pack stock_boot.img.signed --keyblock $CHROMEDIR/kernel.keyblock --signprivate $CHROMEDIR/kernel_data_key.vbprivk --version 1 --vmlinuz stock_boot.img --config config --arch arm --bootloader bootloader --flags 0x1 | ||||
|   rm -f stock_boot.img | ||||
|   mv stock_boot.img.signed stock_boot.img | ||||
| fi | ||||
|  | ||||
| chmod 644 $NEWBOOT | ||||
|  | ||||
| ui_print "- Flashing stock/reverted image" | ||||
| ui_print_wrapper "- Flashing stock/reverted image" | ||||
| [ ! -L "$BOOTIMAGE" ] && dd if=/dev/zero of=$BOOTIMAGE bs=4096 2>/dev/null | ||||
| dd if=$NEWBOOT of=$BOOTIMAGE bs=4096 | ||||
| dd if=stock_boot.img of=$BOOTIMAGE bs=4096 | ||||
|  | ||||
| ui_print "- Removing Magisk files" | ||||
| ui_print_wrapper "- Removing Magisk files" | ||||
| rm -rf  /cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log /cache/.disable_magisk \ | ||||
|         /cache/magisk /cache/magisk_merge /cache/magisk_mount  /cache/unblock /cache/magisk_uninstaller.sh \ | ||||
|         /data/Magisk.apk /data/magisk.apk /data/magisk.img /data/magisk_merge.img \ | ||||
|         /data/busybox /data/magisk /data/custom_ramdisk_patch.sh 2>/dev/null | ||||
|  | ||||
| ($BOOTMODE) && reboot | ||||
| $BOOTMODE && reboot | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -71,8 +71,9 @@ public class MagiskHideFragment extends Fragment implements CallbackEvent.Listen | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         if (getApplication().magiskHideDone.isTriggered) | ||||
|         if (getApplication().magiskHideDone.isTriggered) { | ||||
|             onTrigger(getApplication().magiskHideDone); | ||||
|         } | ||||
|  | ||||
|         return view; | ||||
|     } | ||||
|   | ||||
| @@ -162,8 +162,9 @@ public class MagiskLogFragment extends Fragment { | ||||
|                         return false; | ||||
|                     } | ||||
|  | ||||
|                     if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) | ||||
|                     if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { | ||||
|                         return false; | ||||
|                     } | ||||
|  | ||||
|                     Calendar now = Calendar.getInstance(); | ||||
|                     String filename = String.format( | ||||
| @@ -175,8 +176,9 @@ public class MagiskLogFragment extends Fragment { | ||||
|                     targetFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MagiskManager/" + filename); | ||||
|  | ||||
|                     if ((!targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs()) | ||||
|                             || (targetFile.exists() && !targetFile.delete())) | ||||
|                             || (targetFile.exists() && !targetFile.delete())) { | ||||
|                         return false; | ||||
|                     } | ||||
|  | ||||
|                     List<String> in = Utils.readFile(MAGISK_LOG); | ||||
|  | ||||
| @@ -214,10 +216,11 @@ public class MagiskLogFragment extends Fragment { | ||||
|                     break; | ||||
|                 case 2: | ||||
|                     bool = (boolean) o; | ||||
|                     if (bool) | ||||
|                     if (bool) { | ||||
|                         Toast.makeText(getActivity(), targetFile.toString(), Toast.LENGTH_LONG).show(); | ||||
|                     else | ||||
|                     } else { | ||||
|                         Toast.makeText(getActivity(), getString(R.string.logs_save_failed), Toast.LENGTH_LONG).show(); | ||||
|                     } | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -25,6 +25,7 @@ public class MagiskManager extends Application { | ||||
|     public static final String MAGISK_HIDE_PATH = "/magisk/.core/magiskhide/"; | ||||
|     public static final String TMP_FOLDER_PATH = "/dev/tmp"; | ||||
|     public static final String MAGISK_PATH = "/magisk"; | ||||
|     public static final String INTENT_SECTION = "section"; | ||||
|  | ||||
|     // Events | ||||
|     public final CallbackEvent<Void> blockDetectionDone = new CallbackEvent<>(); | ||||
| @@ -62,6 +63,7 @@ public class MagiskManager extends Application { | ||||
|  | ||||
|     public boolean magiskHide; | ||||
|     public boolean isDarkTheme; | ||||
|     public boolean updateNotification; | ||||
|     public int suRequestTimeout; | ||||
|     public int suLogTimeout = 14; | ||||
|     public int suAccessState; | ||||
| @@ -91,6 +93,7 @@ public class MagiskManager extends Application { | ||||
|         devLogging = prefs.getBoolean("developer_logging", false); | ||||
|         shellLogging = prefs.getBoolean("shell_logging", false); | ||||
|         magiskHide = prefs.getBoolean("magiskhide", false); | ||||
|         updateNotification = prefs.getBoolean("notification", true); | ||||
|         // Always start a new root shell manually, just for safety | ||||
|         Shell.init(); | ||||
|         updateMagiskInfo(); | ||||
| @@ -100,6 +103,7 @@ public class MagiskManager extends Application { | ||||
|         prefs.edit() | ||||
|                 .putBoolean("dark_theme", isDarkTheme) | ||||
|                 .putBoolean("magiskhide", magiskHide) | ||||
|                 .putBoolean("notification", updateNotification) | ||||
|                 .putBoolean("busybox", Utils.commandExists("busybox")) | ||||
|                 .putBoolean("hosts", new File("/magisk/.core/hosts").exists()) | ||||
|                 .putBoolean("disable", Utils.itemExist(MAGISK_DISABLE_FILE)) | ||||
| @@ -124,9 +128,9 @@ public class MagiskManager extends Application { | ||||
|         } | ||||
|         if (isSuClient) { | ||||
|             ret = Shell.sh("getprop persist.sys.root_access"); | ||||
|             if (Utils.isValidShellResponse(ret)) | ||||
|             if (Utils.isValidShellResponse(ret)) { | ||||
|                 suAccessState = Integer.parseInt(ret.get(0)); | ||||
|             else { | ||||
|             } else { | ||||
|                 Shell.su(true, "setprop persist.sys.root_access 3"); | ||||
|                 suAccessState = 3; | ||||
|             } | ||||
| @@ -159,8 +163,9 @@ public class MagiskManager extends Application { | ||||
|             magiskHideStarted = false; | ||||
|         } | ||||
|  | ||||
|         if (!magiskHide && magiskHideStarted) | ||||
|         if (magiskHideStarted) { | ||||
|             magiskHide = true; | ||||
|         } | ||||
|          | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -29,8 +29,6 @@ import butterknife.ButterKnife; | ||||
| public class MainActivity extends Activity | ||||
|         implements NavigationView.OnNavigationItemSelectedListener, CallbackEvent.Listener<Void> { | ||||
|  | ||||
|     public static final String SECTION = "section"; | ||||
|  | ||||
|     private final Handler mDrawerHandler = new Handler(); | ||||
|     private SharedPreferences prefs; | ||||
|     private int mDrawerItem; | ||||
| @@ -79,7 +77,7 @@ public class MainActivity extends Activity | ||||
|         toggle.syncState(); | ||||
|  | ||||
|         if (savedInstanceState == null) | ||||
|             navigate(getIntent().getStringExtra(SECTION)); | ||||
|             navigate(getIntent().getStringExtra(MagiskManager.INTENT_SECTION)); | ||||
|  | ||||
|         navigationView.setNavigationItemSelectedListener(this); | ||||
|         getApplicationContext().reloadMainActivity.register(this); | ||||
| @@ -95,13 +93,13 @@ public class MainActivity extends Activity | ||||
|     @Override | ||||
|     protected void onRestoreInstanceState(Bundle savedInstanceState) { | ||||
|         super.onRestoreInstanceState(savedInstanceState); | ||||
|         navigate(savedInstanceState.getInt(SECTION, R.id.status)); | ||||
|         navigate(savedInstanceState.getInt(MagiskManager.INTENT_SECTION, R.id.status)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onSaveInstanceState(Bundle outState) { | ||||
|         super.onSaveInstanceState(outState); | ||||
|         outState.putInt(SECTION, mDrawerItem); | ||||
|         outState.putInt(MagiskManager.INTENT_SECTION, mDrawerItem); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -133,14 +131,16 @@ public class MainActivity extends Activity | ||||
|  | ||||
|     private void checkHideSection() { | ||||
|         Menu menu = navigationView.getMenu(); | ||||
|         if (Shell.rootAccess()) { | ||||
|             menu.findItem(R.id.magiskhide).setVisible( | ||||
|                     getApplicationContext().magiskVersion >= 8 && prefs.getBoolean("magiskhide", false)); | ||||
|             menu.findItem(R.id.modules).setVisible(getApplicationContext().magiskVersion >= 4); | ||||
|             menu.findItem(R.id.downloads).setVisible(getApplicationContext().magiskVersion >= 4); | ||||
|             menu.findItem(R.id.log).setVisible(true); | ||||
|             menu.findItem(R.id.superuser).setVisible(getApplicationContext().isSuClient); | ||||
|         } | ||||
|         menu.findItem(R.id.magiskhide).setVisible( | ||||
|                 Shell.rootAccess() && getApplicationContext().magiskVersion >= 8 | ||||
|                         && prefs.getBoolean("magiskhide", false)); | ||||
|         menu.findItem(R.id.modules).setVisible( | ||||
|                 Shell.rootAccess() && getApplicationContext().magiskVersion >= 4); | ||||
|         menu.findItem(R.id.downloads).setVisible( | ||||
|                 Shell.rootAccess() && getApplicationContext().magiskVersion >= 4); | ||||
|         menu.findItem(R.id.log).setVisible(Shell.rootAccess()); | ||||
|         menu.findItem(R.id.superuser).setVisible( | ||||
|                 Shell.rootAccess() && getApplicationContext().isSuClient); | ||||
|         menu.findItem(R.id.install).setVisible(getApplicationContext().remoteMagiskVersion > 0); | ||||
|     } | ||||
|  | ||||
| @@ -181,6 +181,7 @@ public class MainActivity extends Activity | ||||
|     } | ||||
|  | ||||
|     public void navigate(int itemId) { | ||||
|         int bak = mDrawerItem; | ||||
|         mDrawerItem = itemId; | ||||
|         navigationView.setCheckedItem(itemId); | ||||
|         switch (itemId) { | ||||
| @@ -207,9 +208,11 @@ public class MainActivity extends Activity | ||||
|                 break; | ||||
|             case R.id.settings: | ||||
|                 startActivity(new Intent(this, SettingsActivity.class)); | ||||
|                 mDrawerItem = bak; | ||||
|                 break; | ||||
|             case R.id.app_about: | ||||
|                 startActivity(new Intent(this, AboutActivity.class)); | ||||
|                 mDrawerItem = bak; | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -133,10 +133,11 @@ public class ReposFragment extends Fragment implements CallbackEvent.Listener<Vo | ||||
|         for (Repo repo : getApplication().repoMap.values()) { | ||||
|             Module module = getApplication().moduleMap.get(repo.getId()); | ||||
|             if (module != null) { | ||||
|                 if (repo.getVersionCode() > module.getVersionCode()) | ||||
|                 if (repo.getVersionCode() > module.getVersionCode()) { | ||||
|                     mUpdateRepos.add(repo); | ||||
|                 else | ||||
|                 } else { | ||||
|                     mInstalledRepos.add(repo); | ||||
|                 } | ||||
|             } else { | ||||
|                 mOthersRepos.add(repo); | ||||
|             } | ||||
|   | ||||
| @@ -112,10 +112,12 @@ public class SettingsActivity extends Activity { | ||||
|                 prefScreen.removePreference(magiskCategory); | ||||
|                 prefScreen.removePreference(suCategory); | ||||
|             } else { | ||||
|                 if (!getApplication().isSuClient) | ||||
|                 if (!getApplication().isSuClient) { | ||||
|                     prefScreen.removePreference(suCategory); | ||||
|                 if (getApplication().magiskVersion < 11) | ||||
|                 } | ||||
|                 if (getApplication().magiskVersion < 11) { | ||||
|                     prefScreen.removePreference(magiskCategory); | ||||
|                 } | ||||
|                 if (getApplication().disabled) { | ||||
|                     busybox.setEnabled(false); | ||||
|                     magiskHide.setEnabled(false); | ||||
| @@ -147,7 +149,6 @@ public class SettingsActivity extends Activity { | ||||
|                     if (getApplication().isDarkTheme != enabled) { | ||||
|                         getApplication().isDarkTheme = enabled; | ||||
|                         getApplication().reloadMainActivity.trigger(); | ||||
|                         getActivity().finish(); | ||||
|                         getActivity().recreate(); | ||||
|                     } | ||||
|                     break; | ||||
| @@ -196,9 +197,12 @@ public class SettingsActivity extends Activity { | ||||
|                                     .setPositiveButton(R.string.understand, (dialog, which) -> new MagiskHide().enable()) | ||||
|                                     .setCancelable(false) | ||||
|                                     .show(); | ||||
|                         } else new MagiskHide().enable(); | ||||
|                     } else | ||||
|                         } else { | ||||
|                             new MagiskHide().enable(); | ||||
|                         } | ||||
|                     } else { | ||||
|                         new MagiskHide().disable(); | ||||
|                     } | ||||
|                     break; | ||||
|                 case "hosts": | ||||
|                     enabled = prefs.getBoolean("hosts", false); | ||||
|   | ||||
| @@ -31,7 +31,7 @@ public class SplashActivity extends Activity{ | ||||
|         magiskManager.init(); | ||||
|  | ||||
|         // Initialize the update check service, notify every 3 hours | ||||
|         if (!"install".equals(getIntent().getStringExtra(MainActivity.SECTION))) { | ||||
|         if (!"install".equals(getIntent().getStringExtra(MagiskManager.INTENT_SECTION))) { | ||||
|             ComponentName service = new ComponentName(magiskManager, UpdateCheckService.class); | ||||
|             JobInfo jobInfo = new JobInfo.Builder(UPDATE_SERVICE_ID, service) | ||||
|                     .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) | ||||
| @@ -60,8 +60,11 @@ public class SplashActivity extends Activity{ | ||||
|             @Override | ||||
|             protected void onPostExecute(Void v) { | ||||
|                 super.onPostExecute(v); | ||||
|                 Intent intent = getIntent().setClass(magiskManager, MainActivity.class) | ||||
|                         .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||||
|                 String section = getIntent().getStringExtra(MagiskManager.INTENT_SECTION); | ||||
|                 Intent intent = new Intent(magiskManager, MainActivity.class); | ||||
|                 if (section != null) { | ||||
|                     intent.putExtra(MagiskManager.INTENT_SECTION, section); | ||||
|                 } | ||||
|                 startActivity(intent); | ||||
|                 finish(); | ||||
|             } | ||||
|   | ||||
| @@ -2,7 +2,6 @@ package com.topjohnwu.magisk; | ||||
|  | ||||
| import android.os.Bundle; | ||||
| import android.support.annotation.Nullable; | ||||
| import android.support.v4.app.FragmentTransaction; | ||||
| import android.support.v4.widget.SwipeRefreshLayout; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| @@ -22,6 +21,7 @@ import com.topjohnwu.magisk.utils.Utils; | ||||
| import butterknife.BindColor; | ||||
| import butterknife.BindView; | ||||
| import butterknife.ButterKnife; | ||||
| import butterknife.OnClick; | ||||
| import butterknife.Unbinder; | ||||
|  | ||||
| public class StatusFragment extends Fragment implements CallbackEvent.Listener<Void> { | ||||
| @@ -53,7 +53,22 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V | ||||
|     @BindColor(R.color.grey500) int colorNeutral; | ||||
|     @BindColor(R.color.blue500) int colorInfo; | ||||
|     @BindColor(android.R.color.transparent) int trans; | ||||
|     int defaultColor; | ||||
|  | ||||
|     @OnClick(R.id.safetyNet_container) | ||||
|     public void safetyNet() { | ||||
|         safetyNetProgress.setVisibility(View.VISIBLE); | ||||
|         safetyNetContainer.setBackgroundColor(trans); | ||||
|         safetyNetIcon.setImageResource(0); | ||||
|         safetyNetStatusText.setText(R.string.checking_safetyNet_status); | ||||
|         Utils.checkSafetyNet(getApplication()); | ||||
|     } | ||||
|  | ||||
|     @OnClick(R.id.magisk_status_container) | ||||
|     public void gotoInstall() { | ||||
|         ((MainActivity) getActivity()).navigate(R.id.install); | ||||
|     } | ||||
|  | ||||
|     private int defaultColor; | ||||
|  | ||||
|     @Nullable | ||||
|     @Override | ||||
| @@ -83,37 +98,13 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V | ||||
|             new CheckUpdates(getActivity()).exec(); | ||||
|         }); | ||||
|  | ||||
|         safetyNetContainer.setOnClickListener(view -> { | ||||
|             safetyNetProgress.setVisibility(View.VISIBLE); | ||||
|             safetyNetContainer.setBackgroundColor(trans); | ||||
|             safetyNetIcon.setImageResource(0); | ||||
|             safetyNetStatusText.setText(R.string.checking_safetyNet_status); | ||||
|             Utils.checkSafetyNet(getApplication()); | ||||
|         }); | ||||
|  | ||||
|         magiskStatusContainer.setOnClickListener(view -> { | ||||
|             ((MainActivity) getActivity()).navigationView.setCheckedItem(R.id.install); | ||||
|             FragmentTransaction transaction = getFragmentManager().beginTransaction(); | ||||
|             transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); | ||||
|             try { | ||||
|                 transaction.replace(R.id.content_frame, new InstallFragment(), "install").commit(); | ||||
|             } catch (IllegalStateException ignored) {} | ||||
|         }); | ||||
|  | ||||
|         if (getApplication().magiskVersion < 0 && Shell.rootAccess() && !noDialog) { | ||||
|             noDialog = true; | ||||
|             new AlertDialogBuilder(getActivity()) | ||||
|                     .setTitle(R.string.no_magisk_title) | ||||
|                     .setMessage(R.string.no_magisk_msg) | ||||
|                     .setCancelable(true) | ||||
|                     .setPositiveButton(R.string.goto_install, (dialogInterface, i) -> { | ||||
|                         ((MainActivity) getActivity()).navigationView.setCheckedItem(R.id.install); | ||||
|                         FragmentTransaction transaction = getFragmentManager().beginTransaction(); | ||||
|                         transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); | ||||
|                         try { | ||||
|                             transaction.replace(R.id.content_frame, new InstallFragment(), "install").commit(); | ||||
|                         } catch (IllegalStateException ignored) {} | ||||
|                     }) | ||||
|                     .setPositiveButton(R.string.goto_install, (d, i) -> gotoInstall()) | ||||
|                     .setNegativeButton(R.string.no_thanks, null) | ||||
|                     .show(); | ||||
|         } | ||||
|   | ||||
| @@ -109,7 +109,9 @@ public class SuLogAdapter { | ||||
|         @Override | ||||
|         public void onBindGroupViewHolder(LogGroupViewHolder holder, int flatPosition, ExpandableGroup group) { | ||||
|             holder.date.setText(group.getTitle()); | ||||
|             if (isGroupExpanded(flatPosition)) holder.expand(); | ||||
|             if (isGroupExpanded(flatPosition)) { | ||||
|                 holder.expand(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import android.content.Intent; | ||||
| import android.support.v4.app.TaskStackBuilder; | ||||
| import android.support.v7.app.NotificationCompat; | ||||
|  | ||||
| import com.topjohnwu.magisk.MainActivity; | ||||
| import com.topjohnwu.magisk.MagiskManager; | ||||
| import com.topjohnwu.magisk.R; | ||||
| import com.topjohnwu.magisk.SplashActivity; | ||||
| import com.topjohnwu.magisk.utils.Utils; | ||||
| @@ -48,7 +48,8 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> { | ||||
|  | ||||
|     @Override | ||||
|     protected void onPostExecute(Void v) { | ||||
|         if (magiskManager.magiskVersion < magiskManager.remoteMagiskVersion && showNotification) { | ||||
|         if (magiskManager.magiskVersion < magiskManager.remoteMagiskVersion | ||||
|                 && showNotification && magiskManager.updateNotification) { | ||||
|             NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager); | ||||
|             builder.setSmallIcon(R.drawable.ic_magisk) | ||||
|                     .setContentTitle(magiskManager.getString(R.string.magisk_update_title)) | ||||
| @@ -56,7 +57,7 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> { | ||||
|                     .setVibrate(new long[]{0, 100, 100, 100}) | ||||
|                     .setAutoCancel(true); | ||||
|             Intent intent = new Intent(magiskManager, SplashActivity.class); | ||||
|             intent.putExtra(MainActivity.SECTION, "install"); | ||||
|             intent.putExtra(MagiskManager.INTENT_SECTION, "install"); | ||||
|             TaskStackBuilder stackBuilder = TaskStackBuilder.create(magiskManager); | ||||
|             stackBuilder.addParentStack(SplashActivity.class); | ||||
|             stackBuilder.addNextIntent(intent); | ||||
|   | ||||
| @@ -13,10 +13,9 @@ public class GetBootBlocks extends SerialTask<Void, Void, Void> { | ||||
|  | ||||
|     @Override | ||||
|     protected Void doInBackground(Void... params) { | ||||
|         if (Shell.rootAccess()) { | ||||
|             magiskManager.blockList = Shell.su("ls /dev/block | grep mmc"); | ||||
|             if (magiskManager.bootBlock == null) | ||||
|                 magiskManager.bootBlock = Utils.detectBootImage(); | ||||
|         magiskManager.blockList = Shell.su("ls /dev/block | grep mmc"); | ||||
|         if (magiskManager.bootBlock == null) { | ||||
|             magiskManager.bootBlock = Utils.detectBootImage(); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|   | ||||
| @@ -22,8 +22,9 @@ public class LoadApps extends ParallelTask<Void, Void, Void> { | ||||
|         List<ApplicationInfo> list = pm.getInstalledApplications(0); | ||||
|         for (Iterator<ApplicationInfo> i = list.iterator(); i.hasNext(); ) { | ||||
|             ApplicationInfo info = i.next(); | ||||
|             if (ApplicationAdapter.BLACKLIST.contains(info.packageName) || !info.enabled) | ||||
|             if (ApplicationAdapter.BLACKLIST.contains(info.packageName) || !info.enabled) { | ||||
|                 i.remove(); | ||||
|             } | ||||
|         } | ||||
|         Collections.sort(list, (a, b) -> a.loadLabel(pm).toString().toLowerCase() | ||||
|                 .compareTo(b.loadLabel(pm).toString().toLowerCase())); | ||||
|   | ||||
| @@ -96,8 +96,9 @@ public class LoadRepos extends ParallelTask<Void, Void, Void> { | ||||
|                             Logger.dev("LoadRepos: Update cached repo " + id); | ||||
|                             repo.update(updatedDate); | ||||
|                         } | ||||
|                         if (repo.getId() != null) | ||||
|                         if (repo.getId() != null) { | ||||
|                             magiskManager.repoMap.put(id, repo); | ||||
|                         } | ||||
|                     } catch (BaseModule.CacheModException ignored) {} | ||||
|                 } | ||||
|  | ||||
|   | ||||
| @@ -21,15 +21,17 @@ public class MagiskHide extends SerialTask<Object, Void, Void> { | ||||
|     protected Void doInBackground(Object... params) { | ||||
|         String command = (String) params[0]; | ||||
|         List<String> ret = Shell.su(MagiskManager.MAGISK_HIDE_PATH + command); | ||||
|         if (isList) | ||||
|         if (isList) { | ||||
|             magiskManager.magiskHideList = ret; | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onPostExecute(Void v) { | ||||
|         if (isList) | ||||
|         if (isList) { | ||||
|             magiskManager.magiskHideDone.trigger(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void add(CharSequence packageName) { | ||||
| @@ -50,8 +52,7 @@ public class MagiskHide extends SerialTask<Object, Void, Void> { | ||||
|  | ||||
|     public void list() { | ||||
|         isList = true; | ||||
|         if (magiskManager == null) | ||||
|             return; | ||||
|         if (magiskManager == null) return; | ||||
|         exec("list"); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -45,7 +45,8 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> { | ||||
|                 ZipUtils.unzip(magiskManager.getContentResolver().openInputStream(mUri), tempdir); | ||||
|                 // Running in parallel mode, open new shell | ||||
|                 Shell.su(true, | ||||
|                         "echo \"BOOTIMAGE=/dev/block/" + mBoot + "\" > /dev/.magisk", | ||||
|                         "rm -f /dev/.magisk", | ||||
|                         (mBoot != null) ? "echo \"BOOTIMAGE=/dev/block/" + mBoot + "\" >> /dev/.magisk" : "", | ||||
|                         "echo \"KEEPFORCEENCRYPT=" + String.valueOf(mEnc) + "\" >> /dev/.magisk", | ||||
|                         "echo \"KEEPVERITY=" + String.valueOf(mVerity) + "\" >> /dev/.magisk", | ||||
|                         "mkdir -p " + MagiskManager.TMP_FOLDER_PATH, | ||||
| @@ -66,13 +67,14 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> { | ||||
|     @Override | ||||
|     protected void onPostExecute(Boolean result) { | ||||
|         progressDialog.dismiss(); | ||||
|         if (result) | ||||
|         if (result) { | ||||
|             new FlashZip(activity, mUri) { | ||||
|                 @Override | ||||
|                 protected boolean unzipAndCheck() throws Exception { | ||||
|                     // Don't need to check, as it is downloaded in correct form | ||||
|                     return true; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 protected void onSuccess() { | ||||
|                     new SerialTask<Void, Void, Void>(activity) { | ||||
| @@ -87,7 +89,8 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> { | ||||
|                     super.onSuccess(); | ||||
|                 } | ||||
|             }.exec(); | ||||
|         else | ||||
|         } else { | ||||
|             Utils.showUriSnack(activity, mUri); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -103,10 +103,11 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> { | ||||
|     protected void onPostExecute(Boolean result) { | ||||
|         progressDialog.dismiss(); | ||||
|         if (result) { | ||||
|             if (Shell.rootAccess() && mInstall) | ||||
|             if (Shell.rootAccess() && mInstall) { | ||||
|                 new FlashZip(activity, mUri).exec(); | ||||
|             else | ||||
|             } else { | ||||
|                 Utils.showUriSnack(activity, mUri); | ||||
|             } | ||||
|  | ||||
|         } else { | ||||
|             Toast.makeText(activity, R.string.process_error, Toast.LENGTH_LONG).show(); | ||||
|   | ||||
| @@ -8,6 +8,6 @@ public class Activity extends AppCompatActivity { | ||||
|  | ||||
|     @Override | ||||
|     public MagiskManager getApplicationContext() { | ||||
|         return (MagiskManager) getApplication(); | ||||
|         return (MagiskManager) super.getApplicationContext(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -93,8 +93,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder { | ||||
|         positive.setText(text); | ||||
|         positiveListener = listener; | ||||
|         positive.setOnClickListener((v) -> { | ||||
|             if (positiveListener != null) | ||||
|             if (positiveListener != null) { | ||||
|                 positiveListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); | ||||
|             } | ||||
|             dialog.dismiss(); | ||||
|         }); | ||||
|         return this; | ||||
| @@ -112,8 +113,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder { | ||||
|         negative.setText(text); | ||||
|         negativeListener = listener; | ||||
|         negative.setOnClickListener((v) -> { | ||||
|             if (negativeListener != null) | ||||
|             if (negativeListener != null) { | ||||
|                 negativeListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE); | ||||
|             } | ||||
|             dialog.dismiss(); | ||||
|         }); | ||||
|         return this; | ||||
| @@ -131,8 +133,9 @@ public class AlertDialogBuilder extends AlertDialog.Builder { | ||||
|         neutral.setText(text); | ||||
|         neutralListener = listener; | ||||
|         neutral.setOnClickListener((v) -> { | ||||
|             if (neutralListener != null) | ||||
|             if (neutralListener != null) { | ||||
|                 neutralListener.onClick(dialog, DialogInterface.BUTTON_NEUTRAL); | ||||
|             } | ||||
|             dialog.dismiss(); | ||||
|         }); | ||||
|         return this; | ||||
|   | ||||
| @@ -3,7 +3,6 @@ package com.topjohnwu.magisk.components; | ||||
| import android.app.Activity; | ||||
| import android.support.annotation.StringRes; | ||||
| import android.support.design.widget.Snackbar; | ||||
| import android.text.TextUtils; | ||||
| import android.view.View; | ||||
| import android.widget.TextView; | ||||
|  | ||||
| @@ -34,8 +33,7 @@ public class SnackbarMaker { | ||||
|  | ||||
|     private static void setup(Snackbar snack) { | ||||
|         TextView text = ButterKnife.findById(snack.getView(), android.support.design.R.id.snackbar_text); | ||||
|         text.setMaxLines(2); | ||||
|         text.setEllipsize(TextUtils.TruncateAt.START); | ||||
|         text.setMaxLines(Integer.MAX_VALUE); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -40,8 +40,9 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper { | ||||
|     public void addRepoMap(ValueSortedMap<String, Repo> map) { | ||||
|         SQLiteDatabase db = getWritableDatabase(); | ||||
|         Collection<Repo> list = map.values(); | ||||
|         for (Repo repo : list) | ||||
|         for (Repo repo : list) { | ||||
|             db.replace(TABLE_NAME, null, repo.getContentValues()); | ||||
|         } | ||||
|         db.close(); | ||||
|     } | ||||
|  | ||||
| @@ -54,8 +55,9 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper { | ||||
|     public void removeRepo(ValueSortedMap<String, Repo> map) { | ||||
|         SQLiteDatabase db = getWritableDatabase(); | ||||
|         Collection<Repo> list = map.values(); | ||||
|         for (Repo repo : list) | ||||
|         for (Repo repo : list) { | ||||
|             db.delete(TABLE_NAME, "id=?", new String[] { repo.getId() }); | ||||
|         } | ||||
|         db.close(); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -22,15 +22,18 @@ public class SuDatabaseHelper extends SQLiteOpenHelper { | ||||
|  | ||||
|     @Override | ||||
|     public void onCreate(SQLiteDatabase db) { | ||||
|         db.execSQL( | ||||
|                 "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " " + | ||||
|                 "(uid INT, package_name TEXT, app_name TEXT, policy INT, " + | ||||
|                 "until INT, logging INT, notification INT, " + | ||||
|                 "PRIMARY KEY(uid))"); | ||||
|         onUpgrade(db, 0, DATABASE_VER); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | ||||
|         if (oldVersion == 0) { | ||||
|             db.execSQL( | ||||
|                     "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " " + | ||||
|                     "(uid INT, package_name TEXT, app_name TEXT, policy INT, " + | ||||
|                     "until INT, logging INT, notification INT, " + | ||||
|                     "PRIMARY KEY(uid))"); | ||||
|         } | ||||
|         // Currently new database, no upgrading | ||||
|     } | ||||
|  | ||||
| @@ -45,8 +48,9 @@ public class SuDatabaseHelper extends SQLiteOpenHelper { | ||||
|         Policy policy = null; | ||||
|         SQLiteDatabase db = getReadableDatabase(); | ||||
|         try (Cursor c = db.query(TABLE_NAME, null, "uid=?", new String[] { String.valueOf(uid) }, null, null, null)) { | ||||
|             if (c.moveToNext()) | ||||
|             if (c.moveToNext()) { | ||||
|                 policy = new Policy(c); | ||||
|             } | ||||
|         } | ||||
|         db.close(); | ||||
|         return policy; | ||||
|   | ||||
| @@ -25,14 +25,17 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper { | ||||
|  | ||||
|     @Override | ||||
|     public void onCreate(SQLiteDatabase db) { | ||||
|         db.execSQL( | ||||
|                 "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT, " + | ||||
|                 "from_uid INT, package_name TEXT, app_name TEXT, from_pid INT, " + | ||||
|                 "to_uid INT, action INT, time INT, command TEXT)"); | ||||
|         onUpgrade(db, 0, DATABASE_VER); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | ||||
|         if (oldVersion == 0) { | ||||
|             db.execSQL( | ||||
|                     "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT, " + | ||||
|                     "from_uid INT, package_name TEXT, app_name TEXT, from_pid INT, " + | ||||
|                     "to_uid INT, action INT, time INT, command TEXT)"); | ||||
|         } | ||||
|         // Currently new database, no upgrading | ||||
|     } | ||||
|  | ||||
| @@ -63,8 +66,9 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper { | ||||
|         db.delete(TABLE_NAME, "time < ?", new String[] { String.valueOf( | ||||
|                 System.currentTimeMillis() / 1000 - magiskManager.suLogTimeout * 86400) }); | ||||
|         try (Cursor c = db.query(TABLE_NAME, null, selection, null, null, null, "time DESC")) { | ||||
|             while (c.moveToNext()) | ||||
|             while (c.moveToNext()) { | ||||
|                 ret.add(new SuLogEntry(c)); | ||||
|             } | ||||
|         } | ||||
|         db.close(); | ||||
|         return ret; | ||||
|   | ||||
| @@ -21,8 +21,9 @@ public class Module extends BaseModule { | ||||
|             setId(path.substring(sep + 1)); | ||||
|         } | ||||
|  | ||||
|         if (getName() == null) | ||||
|         if (getName() == null) { | ||||
|             setName(getId()); | ||||
|         } | ||||
|  | ||||
|         Logger.dev("Creating Module, id: " + getId()); | ||||
|  | ||||
|   | ||||
| @@ -60,10 +60,6 @@ public class Repo extends BaseModule { | ||||
|         return String.format(ZIP_URL, repoName); | ||||
|     } | ||||
|  | ||||
|     public String getLogUrl() { | ||||
|         return String.format(FILE_URL, repoName, "changelog.txt"); | ||||
|     } | ||||
|  | ||||
|     public String getManifestUrl() { | ||||
|         return String.format(FILE_URL, repoName, "module.prop"); | ||||
|     } | ||||
|   | ||||
| @@ -12,6 +12,7 @@ public class UpdateCheckService extends JobService { | ||||
|             @Override | ||||
|             protected Void doInBackground(Void... voids) { | ||||
|                 magiskManager.updateMagiskInfo(); | ||||
|                 magiskManager.updateNotification = magiskManager.prefs.getBoolean("notification", true); | ||||
|                 return super.doInBackground(voids); | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -38,10 +38,12 @@ public class SuReceiver extends BroadcastReceiver { | ||||
|  | ||||
|         SuDatabaseHelper suDbHelper = new SuDatabaseHelper(context); | ||||
|         policy = suDbHelper.getPolicy(fromUid); | ||||
|         if (policy == null) try { | ||||
|             policy = new Policy(fromUid, context.getPackageManager()); | ||||
|         } catch (Throwable throwable) { | ||||
|             return; | ||||
|         if (policy == null) { | ||||
|             try { | ||||
|                 policy = new Policy(fromUid, context.getPackageManager()); | ||||
|             } catch (Throwable throwable) { | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         magiskManager.initSuConfigs(); | ||||
|   | ||||
| @@ -76,8 +76,9 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene | ||||
|             @Override | ||||
|             public void onEvent(int fileEvent, String path) { | ||||
|                 if (fileEvent == FileObserver.DELETE_SELF) { | ||||
|                     if (event != null) | ||||
|                     if (event != null) { | ||||
|                         event.trigger(); | ||||
|                     } | ||||
|                     finish(); | ||||
|                 } | ||||
|             } | ||||
| @@ -147,8 +148,9 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene | ||||
|     public void onTrigger(CallbackEvent<Policy> event) { | ||||
|         Policy policy = event.getResult(); | ||||
|         String response = "socket:DENY"; | ||||
|         if (policy != null &&policy.policy == Policy.ALLOW ) | ||||
|         if (policy != null &&policy.policy == Policy.ALLOW ) { | ||||
|             response = "socket:ALLOW"; | ||||
|         } | ||||
|         try { | ||||
|             socket.getOutputStream().write((response).getBytes()); | ||||
|         } catch (Exception ignored) {} | ||||
| @@ -176,7 +178,7 @@ public class SuRequestActivity extends Activity implements CallbackEvent.Listene | ||||
|  | ||||
|         @Override | ||||
|         protected Boolean doInBackground(Void... params) { | ||||
|             try{ | ||||
|             try { | ||||
|                 socket = new LocalSocket(); | ||||
|                 socket.connect(new LocalSocketAddress(socketPath, LocalSocketAddress.Namespace.FILESYSTEM)); | ||||
|  | ||||
|   | ||||
| @@ -10,8 +10,9 @@ public class CallbackEvent<Result> { | ||||
|     private Set<Listener<Result>> listeners; | ||||
|  | ||||
|     public void register(Listener<Result> l) { | ||||
|         if (listeners == null) | ||||
|         if (listeners == null) { | ||||
|             listeners = new HashSet<>(); | ||||
|         } | ||||
|         listeners.add(l); | ||||
|     } | ||||
|  | ||||
| @@ -20,8 +21,9 @@ public class CallbackEvent<Result> { | ||||
|     } | ||||
|  | ||||
|     public void unRegister(Listener<Result> l) { | ||||
|         if (listeners != null) | ||||
|         if (listeners != null) { | ||||
|             listeners.remove(l); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void trigger() { | ||||
| @@ -32,8 +34,9 @@ public class CallbackEvent<Result> { | ||||
|         result = r; | ||||
|         isTriggered = true; | ||||
|         if (listeners != null) { | ||||
|             for (Listener<Result> listener : listeners) | ||||
|             for (Listener<Result> listener : listeners) { | ||||
|                 listener.onTrigger(this); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -120,11 +120,13 @@ public class Shell { | ||||
|         StreamGobbler STDOUT; | ||||
|  | ||||
|         // Create the default shell if not init | ||||
|         if (!newShell && !isInit) | ||||
|         if (!newShell && !isInit) { | ||||
|             init(); | ||||
|         } | ||||
|  | ||||
|         if (!newShell && !rootAccess()) | ||||
|         if (!newShell && !rootAccess()) { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         if (newShell) { | ||||
|             res = Collections.synchronizedList(new ArrayList<String>()); | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user