Skip to content

Commit 3847476

Browse files
author
weishu.tws
committed
[VA]: fix redirect exception for media capture.
1 parent 3bec2e2 commit 3847476

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/am/MethodProxies.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.os.IBinder;
2828
import android.os.IInterface;
2929
import android.os.RemoteException;
30+
import android.provider.MediaStore;
3031
import android.text.TextUtils;
3132
import android.util.TypedValue;
3233

@@ -399,6 +400,10 @@ public Object call(Object who, Method method, Object... args) throws Throwable {
399400
if (handleUninstallRequest(intent)) {
400401
return 0;
401402
}
403+
} else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(intent.getAction()) ||
404+
MediaStore.ACTION_VIDEO_CAPTURE.equals(intent.getAction()) ||
405+
MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(intent.getAction())) {
406+
handleMediaCaptureRequest(intent);
402407
}
403408

404409
String resultWho = null;
@@ -499,6 +504,21 @@ private boolean handleUninstallRequest(Intent intent) {
499504
return false;
500505
}
501506

507+
private void handleMediaCaptureRequest(Intent intent) {
508+
Uri uri = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);
509+
if (uri == null || !SCHEME_FILE.equals(uri.getScheme())) {
510+
return;
511+
}
512+
String path = uri.getPath();
513+
String newPath = NativeEngine.getRedirectedPath(path);
514+
if (newPath == null) {
515+
return;
516+
}
517+
File realFile = new File(newPath);
518+
Uri newUri = Uri.fromFile(realFile);
519+
intent.putExtra(MediaStore.EXTRA_OUTPUT, newUri);
520+
}
521+
502522
}
503523

504524
static class StartActivities extends MethodProxy {

0 commit comments

Comments
 (0)