Skip to content

Commit

Permalink
Clean code (LSPosed#2335)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvb2060 authored Jan 16, 2023
1 parent 7826b68 commit 10804df
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.zip.ZipEntry;

import sun.net.www.ParseUtil;
import sun.net.www.protocol.jar.Handler;

final class ClassPathURLStreamHandler extends Handler {
private final String fileUri;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected URLConnection openConnection(URL url) throws IOException {
}

@Override
protected void finalize() throws Throwable {
protected void finalize() throws IOException {
jarFile.close();
}

Expand Down
192 changes: 0 additions & 192 deletions core/src/main/java/org/lsposed/lspd/util/Handler.java

This file was deleted.

40 changes: 0 additions & 40 deletions core/src/main/java/org/lsposed/lspd/util/InstallerVerifier.java

This file was deleted.

21 changes: 9 additions & 12 deletions core/src/main/java/org/lsposed/lspd/util/LspModuleClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import java.util.List;
import java.util.Objects;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;

import hidden.ByteBufferDexClassLoader;
import sun.misc.CompoundEnumeration;

@SuppressWarnings("ConstantConditions")
public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
Expand Down Expand Up @@ -135,7 +135,12 @@ public String getLdLibraryPath() {
protected URL findResource(String name) {
try {
var urlHandler = new ClassPathURLStreamHandler(apk);
return urlHandler.getEntryUrlOrNull(name);
var url = urlHandler.getEntryUrlOrNull(name);
if (url == null) {
// noinspection FinalizeCalledExplicitly
urlHandler.finalize();
}
return url;
} catch (IOException e) {
return null;
}
Expand Down Expand Up @@ -171,16 +176,8 @@ public Enumeration<URL> getResources(String name) throws IOException {
@NonNull
@Override
public String toString() {
if (apk == null) {
return "LspModuleClassLoader[instantiating]";
}
var nativeLibraryDirsString = nativeLibraryDirs.stream()
.map(File::getPath)
.collect(Collectors.joining(", "));
return "LspModuleClassLoader[" +
"module=" + apk + ", " +
"nativeLibraryDirs=" + nativeLibraryDirsString + ", " +
super.toString() + "]";
if (apk == null) return "LspModuleClassLoader[instantiating]";
return "LspModuleClassLoader[module=" + apk + ", " + super.toString() + "]";
}

public static ClassLoader loadApk(String apk,
Expand Down
5 changes: 5 additions & 0 deletions hiddenapi/stubs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@
plugins {
`java-library`
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

This file was deleted.

28 changes: 0 additions & 28 deletions hiddenapi/stubs/src/main/java/android/content/pm/ShortcutInfo.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package android.os;

public class ShellCallback implements Parcelable {
public static final Parcelable.Creator<ShellCallback> CREATOR = new Creator<>() {
public static final Parcelable.Creator<ShellCallback> CREATOR = new Creator<ShellCallback>() {
@Override
public ShellCallback createFromParcel(Parcel source) {
throw new IllegalArgumentException("STUB");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.lsposed.lspd.util;
package sun.misc;

import java.util.Enumeration;
import java.util.NoSuchElementException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package sun.net.www.protocol.jar;

public abstract class Handler extends java.net.URLStreamHandler {
}
Loading

0 comments on commit 10804df

Please sign in to comment.