Skip to content

Commit

Permalink
fix android l
Browse files Browse the repository at this point in the history
  • Loading branch information
nnjun committed Jun 3, 2021
1 parent 6583317 commit 57b9def
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public BStorageManagerService() {

@Override
public StorageVolume[] getVolumeList(int uid, String packageName, int flags, int userId) throws RemoteException {
if (reflection.android.os.storage.StorageManager.getVolumeList == null) {
return null;
}
try {
StorageVolume[] storageVolumes = reflection.android.os.storage.StorageManager.getVolumeList.call(BUserHandle.getUserId(Process.myUid()), 0);
for (StorageVolume storageVolume : storageVolumes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.IInterface;
import android.os.Process;
import android.os.storage.StorageVolume;

import java.lang.reflect.Method;

Expand Down Expand Up @@ -55,12 +56,24 @@ public static class GetVolumeList extends MethodHook {
@Override
protected Object hook(Object who, Method method, Object[] args) throws Throwable {
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;
}
int uid = (int) args[0];
String packageName = (String) args[1];
int flags = (int) args[2];
return BlackBoxCore.getBStorageManager().getVolumeList(uid, packageName, flags, BActivityThread.getUserId());
try {
int uid = (int) args[0];
String packageName = (String) args[1];
int flags = (int) args[2];
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);
}
}
}

0 comments on commit 57b9def

Please sign in to comment.