fix android l

pull/15/head
Milk 4 years ago
parent 6583317f02
commit 57b9defca0
  1. 3
      Bcore/src/main/java/top/niunaijun/blackbox/core/system/os/BStorageManagerService.java
  2. 17
      Bcore/src/main/java/top/niunaijun/blackbox/fake/service/IStorageManagerProxy.java

@ -29,6 +29,9 @@ public class BStorageManagerService extends IBStorageManagerService.Stub impleme
@Override @Override
public StorageVolume[] getVolumeList(int uid, String packageName, int flags, int userId) throws RemoteException { public StorageVolume[] getVolumeList(int uid, String packageName, int flags, int userId) throws RemoteException {
if (reflection.android.os.storage.StorageManager.getVolumeList == null) {
return null;
}
try { try {
StorageVolume[] storageVolumes = reflection.android.os.storage.StorageManager.getVolumeList.call(BUserHandle.getUserId(Process.myUid()), 0); StorageVolume[] storageVolumes = reflection.android.os.storage.StorageManager.getVolumeList.call(BUserHandle.getUserId(Process.myUid()), 0);
for (StorageVolume storageVolume : storageVolumes) { for (StorageVolume storageVolume : storageVolumes) {

@ -2,6 +2,7 @@ package top.niunaijun.blackbox.fake.service;
import android.os.IInterface; import android.os.IInterface;
import android.os.Process; import android.os.Process;
import android.os.storage.StorageVolume;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -55,12 +56,24 @@ public class IStorageManagerProxy extends BinderInvocationStub {
@Override @Override
protected Object hook(Object who, Method method, Object[] args) throws Throwable { protected Object hook(Object who, Method method, Object[] args) throws Throwable {
if (args == null) { if (args == null) {
return BlackBoxCore.getBStorageManager().getVolumeList(Process.myUid(), null, 0, BActivityThread.getUserId()); StorageVolume[] volumeList = BlackBoxCore.getBStorageManager().getVolumeList(Process.myUid(), null, 0, BActivityThread.getUserId());
if (volumeList == null) {
return method.invoke(who, args);
} }
return volumeList;
}
try {
int uid = (int) args[0]; int uid = (int) args[0];
String packageName = (String) args[1]; String packageName = (String) args[1];
int flags = (int) args[2]; int flags = (int) args[2];
return BlackBoxCore.getBStorageManager().getVolumeList(uid, packageName, flags, BActivityThread.getUserId()); StorageVolume[] volumeList = BlackBoxCore.getBStorageManager().getVolumeList(uid, packageName, flags, BActivityThread.getUserId());
if (volumeList == null) {
return method.invoke(who, args);
}
} catch (Throwable t) {
return method.invoke(who, args);
}
return method.invoke(who, args);
} }
} }
} }

Loading…
Cancel
Save