mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 17:07:43 +00:00
Support .img.tar as input
This commit is contained in:
parent
a9dc15bda5
commit
ce4b742b25
@ -8,7 +8,7 @@ android {
|
|||||||
applicationId "com.topjohnwu.magisk"
|
applicationId "com.topjohnwu.magisk"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 52
|
versionCode 53
|
||||||
versionName "5.2.0"
|
versionName "5.2.0"
|
||||||
ndk {
|
ndk {
|
||||||
moduleName 'zipadjust'
|
moduleName 'zipadjust'
|
||||||
@ -54,10 +54,10 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation project(':resource')
|
implementation project(':resource')
|
||||||
implementation 'com.android.support:recyclerview-v7:26.0.1'
|
implementation 'com.android.support:recyclerview-v7:26.0.2'
|
||||||
implementation 'com.android.support:cardview-v7:26.0.1'
|
implementation 'com.android.support:cardview-v7:26.0.2'
|
||||||
implementation 'com.android.support:design:26.0.1'
|
implementation 'com.android.support:design:26.0.2'
|
||||||
implementation 'com.android.support:support-v4:26.0.1'
|
implementation 'com.android.support:support-v4:26.0.2'
|
||||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||||
implementation 'com.atlassian.commonmark:commonmark:0.9.0'
|
implementation 'com.atlassian.commonmark:commonmark:0.9.0'
|
||||||
implementation 'org.bouncycastle:bcprov-jdk15on:1.57'
|
implementation 'org.bouncycastle:bcprov-jdk15on:1.57'
|
||||||
|
@ -51,7 +51,7 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
setSupportActionBar(toolbar);
|
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
|
@Override
|
||||||
public void onDrawerOpened(View drawerView) {
|
public void onDrawerOpened(View drawerView) {
|
||||||
super.onDrawerOpened(drawerView);
|
super.onDrawerOpened(drawerView);
|
||||||
|
@ -10,8 +10,10 @@ import com.topjohnwu.magisk.MagiskManager;
|
|||||||
import com.topjohnwu.magisk.utils.AdaptiveList;
|
import com.topjohnwu.magisk.utils.AdaptiveList;
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.TarEntry;
|
import com.topjohnwu.magisk.utils.TarEntry;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||||
|
|
||||||
|
import org.kamranzafar.jtar.TarInputStream;
|
||||||
import org.kamranzafar.jtar.TarOutputStream;
|
import org.kamranzafar.jtar.TarOutputStream;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -113,12 +115,27 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
// Copy boot image to local
|
// Copy boot image to local
|
||||||
try (
|
try (
|
||||||
InputStream in = mm.getContentResolver().openInputStream(mBootImg);
|
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 (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];
|
byte buffer[] = new byte[1024];
|
||||||
int length;
|
int length;
|
||||||
while ((length = in.read(buffer)) > 0)
|
while ((length = source.read(buffer)) > 0)
|
||||||
out.write(buffer, 0, length);
|
out.write(buffer, 0, length);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
mList.add("! Invalid Uri");
|
mList.add("! Invalid Uri");
|
||||||
@ -141,7 +158,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
getShell().sh(mList,
|
getShell().sh(mList,
|
||||||
"cd " + install,
|
"cd " + install,
|
||||||
"KEEPFORCEENCRYPT=" + mKeepEnc + " KEEPVERITY=" + mKeepVerity + " sh " +
|
"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!'"
|
" && echo 'Success!' || echo 'Failed!'"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user