Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit faf3e3c

Browse files
committed
Fix-up previous commit.
1 parent 0026388 commit faf3e3c

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

app/src/main/java/com/fox2code/mmm/NotificationType.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,16 @@ public boolean shouldRemove() {
8383
try {
8484
boolean needPatch;
8585
try (ZipFile zipFile = new ZipFile(d)) {
86-
needPatch = zipFile.getEntry("module.prop") == null;
86+
needPatch = zipFile.getEntry("module.prop") == null &&
87+
zipFile.getEntry("anykernel.sh") == null;
8788
}
8889
if (needPatch) {
8990
Files.patchModuleSimple(Files.read(d),
9091
new FileOutputStream(d));
9192
}
9293
try (ZipFile zipFile = new ZipFile(d)) {
93-
needPatch = zipFile.getEntry("module.prop") == null;
94+
needPatch = zipFile.getEntry("module.prop") == null &&
95+
zipFile.getEntry("anykernel.sh") == null;
9496
}
9597
if (needPatch) {
9698
if (d.exists() && !d.delete())

app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,17 @@ protected void onCreate(Bundle savedInstanceState) {
122122
this.getWindow().setFlags( // Note: Doesn't require WAKELOCK permission
123123
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
124124
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
125-
final File moduleFile = urlMode ? null : new File(target);
126125
this.progressIndicator.setVisibility(View.VISIBLE);
127-
this.installerTerminal.addLine("- Downloading " + name);
126+
if (urlMode) this.installerTerminal.addLine("- Downloading " + name);
128127
new Thread(() -> {
129128
File moduleCache = this.toDelete = urlMode ?
130-
new File(this.moduleCache, "module.zip") : moduleFile;
131-
if (moduleCache.exists() && !moduleCache.delete() &&
129+
new File(this.moduleCache, "module.zip") : new File(target);
130+
if (urlMode && moduleCache.exists() && !moduleCache.delete() &&
132131
!new SuFile(moduleCache.getAbsolutePath()).delete())
133132
Log.e(TAG, "Failed to delete module cache");
134133
String errMessage = "Failed to download module zip";
135134
try {
136-
Log.i(TAG, "Downloading: " + target);
135+
Log.i(TAG, (urlMode ? "Downloading: " : "Loading: ") + target);
137136
byte[] rawModule = urlMode ? Http.doHttpGet(target, (progress, max, done) -> {
138137
if (max <= 0 && this.progressIndicator.isIndeterminate())
139138
return;
@@ -142,7 +141,7 @@ protected void onCreate(Bundle savedInstanceState) {
142141
this.progressIndicator.setMax(max);
143142
this.progressIndicator.setProgressCompat(progress, true);
144143
});
145-
}) : Files.readSU(moduleFile);
144+
}) : Files.readSU(moduleCache);
146145
this.runOnUiThread(() -> {
147146
this.progressIndicator.setVisibility(View.GONE);
148147
this.progressIndicator.setIndeterminate(true);

app/src/main/java/com/fox2code/mmm/utils/Files.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fox2code.mmm.utils;
22

33
import android.os.Build;
4+
import android.util.Log;
45

56
import androidx.annotation.NonNull;
67

@@ -45,6 +46,11 @@ public static void writeSU(File file, byte[] bytes) throws IOException {
4546
}
4647

4748
public static byte[] readSU(File file) throws IOException {
49+
if (file.isFile() && file.canRead()) {
50+
try { // Read as app if su not required
51+
return read(file);
52+
} catch (IOException ignored) {}
53+
}
4854
try (InputStream inputStream = SuFileInputStream.open(file)) {
4955
return readAllBytes(inputStream);
5056
}

app/src/main/java/com/fox2code/mmm/utils/IntentHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ public static void openFileTo(CompatActivity compatActivity, File destination,
371371
}
372372
outputStream = new FileOutputStream(destination);
373373
Files.copy(inputStream, outputStream);
374+
Log.d(TAG, "File saved at " + destination);
374375
success = true;
375376
} catch (Exception e) {
376377
Log.e(TAG, "failed copy of " + uri, e);

0 commit comments

Comments
 (0)