[core] Close inputstream (#864)
This commit is contained in:
parent
ca91e87aeb
commit
e68b412664
|
|
@ -1656,19 +1656,6 @@ public final class XposedHelpers {
|
|||
return buf.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes the {@link Closeable#close()} method, ignoring IOExceptions.
|
||||
*/
|
||||
/*package*/
|
||||
static void closeSilently(Closeable c) {
|
||||
if (c != null) {
|
||||
try {
|
||||
c.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lowercase hex string representation of a file's MD5 hash sum.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import static de.robv.android.xposed.XposedBridge.sInitPackageResourcesCallbacks
|
|||
import static de.robv.android.xposed.XposedBridge.sInitZygoteCallbacks;
|
||||
import static de.robv.android.xposed.XposedBridge.sLoadedPackageCallbacks;
|
||||
import static de.robv.android.xposed.XposedHelpers.callMethod;
|
||||
import static de.robv.android.xposed.XposedHelpers.closeSilently;
|
||||
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
|
||||
import static de.robv.android.xposed.XposedHelpers.getObjectField;
|
||||
import static de.robv.android.xposed.XposedHelpers.getParameterIndexByType;
|
||||
|
|
@ -281,24 +280,20 @@ public final class XposedInit {
|
|||
* It will only store the so names but not doing anything.
|
||||
*/
|
||||
private static boolean initNativeModule(ClassLoader mcl, String name) {
|
||||
InputStream is = mcl.getResourceAsStream("assets/native_init");
|
||||
if (is == null) return true;
|
||||
BufferedReader moduleLibraryReader = new BufferedReader(new InputStreamReader(is));
|
||||
String moduleLibraryName;
|
||||
try {
|
||||
try (InputStream is = mcl.getResourceAsStream("assets/native_init")) {
|
||||
if (is == null) return true;
|
||||
BufferedReader moduleLibraryReader = new BufferedReader(new InputStreamReader(is));
|
||||
String moduleLibraryName;
|
||||
while ((moduleLibraryName = moduleLibraryReader.readLine()) != null) {
|
||||
if (!moduleLibraryName.startsWith("#")) {
|
||||
NativeAPI.recordNativeEntrypoint(moduleLibraryName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, " Failed to load native library list from " + name, e);
|
||||
return false;
|
||||
} finally {
|
||||
closeSilently(is);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private static boolean initModule(ClassLoader mcl, String name, String apk) {
|
||||
|
|
@ -306,8 +301,7 @@ public final class XposedInit {
|
|||
if (is == null) {
|
||||
return true;
|
||||
}
|
||||
BufferedReader moduleClassesReader = new BufferedReader(new InputStreamReader(is));
|
||||
try {
|
||||
try (BufferedReader moduleClassesReader = new BufferedReader(new InputStreamReader(is))) {
|
||||
String moduleClassName;
|
||||
while ((moduleClassName = moduleClassesReader.readLine()) != null) {
|
||||
moduleClassName = moduleClassName.trim();
|
||||
|
|
@ -349,13 +343,11 @@ public final class XposedInit {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, " Failed to load module " + name + " from " + apk, e);
|
||||
return false;
|
||||
} finally {
|
||||
closeSilently(is);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
2
service
2
service
|
|
@ -1 +1 @@
|
|||
Subproject commit 18e53fa376d982731d6cf9ab02d592f6deae4210
|
||||
Subproject commit 94b4ba3018e594a840d026acdd18b6bd79361922
|
||||
Loading…
Reference in New Issue