mirror of
				https://github.com/topjohnwu/Magisk.git
				synced 2025-10-31 08:44:07 +00:00 
			
		
		
		
	Updated downloading magisk to pull the zip from cache if eligible
This commit is contained in:
		 Viktor De Pasquale
					Viktor De Pasquale
				
			
				
					committed by
					
						 John Wu
						John Wu
					
				
			
			
				
	
			
			
			 John Wu
						John Wu
					
				
			
						parent
						
							4c8f357978
						
					
				
				
					commit
					188ea2644a
				
			| @@ -15,9 +15,11 @@ import com.topjohnwu.magisk.utils.Utils | ||||
| import com.topjohnwu.magisk.view.ProgressNotification | ||||
| import com.topjohnwu.magisk.view.SnackbarMaker | ||||
| import com.topjohnwu.net.Networking | ||||
| import com.topjohnwu.superuser.ShellUtils | ||||
| import java.io.File | ||||
|  | ||||
| internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List<String>) : AlertDialog.Builder(activity) { | ||||
| internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List<String>) : | ||||
|     AlertDialog.Builder(activity) { | ||||
|  | ||||
|     init { | ||||
|         setTitle(R.string.select_method) | ||||
| @@ -60,17 +62,31 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List | ||||
|                 val filename = "Magisk-v${Info.remote.magisk.version}" + | ||||
|                         "(${Info.remote.magisk.versionCode}).zip" | ||||
|                 val zip = File(Const.EXTERNAL_PATH, filename) | ||||
|                 val cachedZip = File(activity.cacheDir, "magisk.zip") | ||||
|  | ||||
|                 fun onSuccess() { | ||||
|                     SnackbarMaker.make( | ||||
|                         activity, | ||||
|                         activity.getString(R.string.internal_storage, "/Download/$filename"), | ||||
|                         Snackbar.LENGTH_LONG | ||||
|                     ).show() | ||||
|                 } | ||||
|  | ||||
|                 if (ShellUtils.checkSum("MD5", cachedZip, Info.remote.magisk.hash)) { | ||||
|                     cachedZip.copyTo(zip, true) | ||||
|                     onSuccess() | ||||
|                 } else { | ||||
|                     val progress = ProgressNotification(filename) | ||||
|                     Networking.get(Info.remote.magisk.link) | ||||
|                         .setDownloadProgressListener(progress) | ||||
|                         .setErrorHandler { _, _ -> progress.dlFail() } | ||||
|                         .getAsFile(zip) { | ||||
|                             progress.dlDone() | ||||
|                             SnackbarMaker.make(activity, | ||||
|                                     activity.getString(R.string.internal_storage, "/Download/$filename"), | ||||
|                                     Snackbar.LENGTH_LONG).show() | ||||
|                             onSuccess() | ||||
|                         } | ||||
|                 } | ||||
|  | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user