Fix some small issues

This commit is contained in:
topjohnwu
2017-01-25 16:45:55 +08:00
parent bcc695234c
commit 6eb814ef0b
5 changed files with 37 additions and 18 deletions
@@ -194,7 +194,7 @@ public class Async {
publishProgress(mContext.getString(R.string.copying_msg));
mCachedFile = new File(mContext.getCacheDir().getAbsolutePath() + "/install.zip");
if (mCachedFile.exists() && !mCachedFile.delete()) {
Log.e(Logger.TAG, "FlashZip: Error while deleting already existing file");
Logger.error("FlashZip: Error while deleting already existing file");
throw new IOException();
}
try (
@@ -203,15 +203,16 @@ public class Async {
) {
byte buffer[] = new byte[1024];
int length;
if (in == null) throw new FileNotFoundException();
while ((length = in.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
Logger.dev("FlashZip: File created successfully - " + mCachedFile.getPath());
} catch (FileNotFoundException e) {
Log.e(Logger.TAG, "FlashZip: Invalid Uri");
Logger.error("FlashZip: Invalid Uri");
throw e;
} catch (IOException e) {
Log.e(Logger.TAG, "FlashZip: Error in creating file");
Logger.error("FlashZip: Error in creating file");
throw e;
}
}
@@ -331,7 +332,7 @@ public class Async {
}
@Override
protected void onPostExecute(Void aVoid) {
protected void onPostExecute(Void v) {
Global.Events.blockDetectionDone.trigger();
}
}
@@ -7,26 +7,28 @@ import com.topjohnwu.magisk.Global;
public class Logger {
public static final String TAG = "Magisk";
public static final String DEV_TAG = "Magisk: DEV";
public static final String DEBUG_TAG = "Magisk: DEBUG";
public static void debug(String msg) {
Log.d(DEBUG_TAG, msg);
Log.d(TAG, "DEBUG: " + msg);
}
public static void error(String msg) {
Log.e(TAG, "ERROR: " + msg);
}
public static void dev(String msg, Object... args) {
if (Global.Configs.devLogging) {
if (args.length == 1 && args[0] instanceof Throwable) {
Log.d(DEV_TAG, msg, (Throwable) args[0]);
Log.d(TAG, "DEV: " + msg, (Throwable) args[0]);
} else {
Log.d(DEV_TAG, String.format(msg, args));
Log.d(TAG, "DEV: " + String.format(msg, args));
}
}
}
public static void dev(String msg) {
if (Global.Configs.devLogging) {
Log.d(DEV_TAG, msg);
Log.d(TAG, "DEBUG: " + msg);
}
}