Support .img.tar as input
This commit is contained in:
parent
a9dc15bda5
commit
ce4b742b25
@ -8,7 +8,7 @@ android {
|
||||
applicationId "com.topjohnwu.magisk"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 26
|
||||
versionCode 52
|
||||
versionCode 53
|
||||
versionName "5.2.0"
|
||||
ndk {
|
||||
moduleName 'zipadjust'
|
||||
@ -54,10 +54,10 @@ repositories {
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation project(':resource')
|
||||
implementation 'com.android.support:recyclerview-v7:26.0.1'
|
||||
implementation 'com.android.support:cardview-v7:26.0.1'
|
||||
implementation 'com.android.support:design:26.0.1'
|
||||
implementation 'com.android.support:support-v4:26.0.1'
|
||||
implementation 'com.android.support:recyclerview-v7:26.0.2'
|
||||
implementation 'com.android.support:cardview-v7:26.0.2'
|
||||
implementation 'com.android.support:design:26.0.2'
|
||||
implementation 'com.android.support:support-v4:26.0.2'
|
||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||
implementation 'com.atlassian.commonmark:commonmark:0.9.0'
|
||||
implementation 'org.bouncycastle:bcprov-jdk15on:1.57'
|
||||
|
@ -51,7 +51,7 @@ public class MainActivity extends Activity
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.magisk, R.string.magisk) {
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
super.onDrawerOpened(drawerView);
|
||||
|
@ -10,8 +10,10 @@ import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.utils.AdaptiveList;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.TarEntry;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||
|
||||
import org.kamranzafar.jtar.TarInputStream;
|
||||
import org.kamranzafar.jtar.TarOutputStream;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
@ -113,12 +115,27 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
// Copy boot image to local
|
||||
try (
|
||||
InputStream in = mm.getContentResolver().openInputStream(mBootImg);
|
||||
OutputStream out = new FileOutputStream(boot);
|
||||
OutputStream out = new FileOutputStream(boot)
|
||||
) {
|
||||
InputStream source;
|
||||
if (in == null) throw new FileNotFoundException();
|
||||
|
||||
if (Utils.getNameFromUri(mm, mBootImg).endsWith(".tar")) {
|
||||
// Extract boot.img from tar
|
||||
TarInputStream tar = new TarInputStream(new BufferedInputStream(in));
|
||||
org.kamranzafar.jtar.TarEntry entry;
|
||||
while ((entry = tar.getNextEntry()) != null) {
|
||||
if (entry.getName().equals("boot.img"))
|
||||
break;
|
||||
}
|
||||
source = tar;
|
||||
} else {
|
||||
// Direct copy raw image
|
||||
source = in;
|
||||
}
|
||||
byte buffer[] = new byte[1024];
|
||||
int length;
|
||||
while ((length = in.read(buffer)) > 0)
|
||||
while ((length = source.read(buffer)) > 0)
|
||||
out.write(buffer, 0, length);
|
||||
} catch (FileNotFoundException e) {
|
||||
mList.add("! Invalid Uri");
|
||||
@ -141,7 +158,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
getShell().sh(mList,
|
||||
"cd " + install,
|
||||
"KEEPFORCEENCRYPT=" + mKeepEnc + " KEEPVERITY=" + mKeepVerity + " sh " +
|
||||
"update-binary indep boot_patch.sh " + boot +
|
||||
"update-binary indep boot_patch.sh " + boot + " 2>&1" +
|
||||
" && echo 'Success!' || echo 'Failed!'"
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user