Only call remote file when starts with remote://
This commit is contained in:
parent
bbdc6084b9
commit
2dd0080956
|
|
@ -283,7 +283,18 @@ public class LSPosedContext extends XposedContext {
|
||||||
@Override
|
@Override
|
||||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||||
if (name == null) throw new IllegalArgumentException("name must not be null");
|
if (name == null) throw new IllegalArgumentException("name must not be null");
|
||||||
return mRemotePrefs.computeIfAbsent(name, __ -> new LSPosedRemotePreferences(service, name));
|
if (name.startsWith("remote://")) {
|
||||||
|
return mRemotePrefs.computeIfAbsent(name.substring(9), n -> {
|
||||||
|
try {
|
||||||
|
return new LSPosedRemotePreferences(service, n);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.e(TAG, "Failed to get remote preferences", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return mBase.getSharedPreferences(name, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -298,10 +309,14 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileInputStream openFileInput(String name) throws FileNotFoundException {
|
public FileInputStream openFileInput(String name) throws FileNotFoundException {
|
||||||
try {
|
if (name.startsWith("remote://")) {
|
||||||
return new FileInputStream(service.openRemoteFile(name).getFileDescriptor());
|
try {
|
||||||
} catch (RemoteException e) {
|
return new FileInputStream(service.openRemoteFile(name.substring(9)).getFileDescriptor());
|
||||||
throw new FileNotFoundException(e.getMessage());
|
} catch (RemoteException e) {
|
||||||
|
throw new FileNotFoundException(e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return mBase.openFileInput(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.lsposed.lspd.impl;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
@ -49,14 +50,10 @@ public class LSPosedRemotePreferences implements SharedPreferences {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public LSPosedRemotePreferences(ILSPInjectedModuleService service, String group) {
|
public LSPosedRemotePreferences(ILSPInjectedModuleService service, String group) throws RemoteException {
|
||||||
try {
|
Bundle output = service.requestRemotePreferences(group, callback);
|
||||||
Bundle output = service.requestRemotePreferences(group, callback);
|
if (output.containsKey("map")) {
|
||||||
if (output.containsKey("map")) {
|
mMap.putAll((Map<String, Object>) output.getSerializable("map"));
|
||||||
mMap.putAll((Map<String, Object>) output.getSerializable("map"));
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
XposedBridge.log(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue