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
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
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
|
||||
|
|
@ -298,10 +309,14 @@ public class LSPosedContext extends XposedContext {
|
|||
|
||||
@Override
|
||||
public FileInputStream openFileInput(String name) throws FileNotFoundException {
|
||||
try {
|
||||
return new FileInputStream(service.openRemoteFile(name).getFileDescriptor());
|
||||
} catch (RemoteException e) {
|
||||
throw new FileNotFoundException(e.getMessage());
|
||||
if (name.startsWith("remote://")) {
|
||||
try {
|
||||
return new FileInputStream(service.openRemoteFile(name.substring(9)).getFileDescriptor());
|
||||
} 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.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
@ -49,14 +50,10 @@ public class LSPosedRemotePreferences implements SharedPreferences {
|
|||
}
|
||||
};
|
||||
|
||||
public LSPosedRemotePreferences(ILSPInjectedModuleService service, String group) {
|
||||
try {
|
||||
Bundle output = service.requestRemotePreferences(group, callback);
|
||||
if (output.containsKey("map")) {
|
||||
mMap.putAll((Map<String, Object>) output.getSerializable("map"));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
XposedBridge.log(e);
|
||||
public LSPosedRemotePreferences(ILSPInjectedModuleService service, String group) throws RemoteException {
|
||||
Bundle output = service.requestRemotePreferences(group, callback);
|
||||
if (output.containsKey("map")) {
|
||||
mMap.putAll((Map<String, Object>) output.getSerializable("map"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue