diff --git a/README.md b/README.md index efdaad4..6d54f0d 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Q1. 大多数情况下,替换前置摄像头的视频需要水平翻转并右旋 Q2. 画面黑屏,相机启动失败? -A2. 目前有些应用并不能成功替换(特别是系统相机)。或者是因为视频路径不对。 +A2. 目前有些应用并不能成功替换(特别是系统相机)。或者是因为视频路径不对(是否创建了两级Camera1目录,如`./DCIM/Camera1/Camera1/virtual.mp4`,但只需要一级目录)。 Q3. 画面花屏? diff --git a/README_en.md b/README_en.md index b3f754b..652ad69 100644 --- a/README_en.md +++ b/README_en.md @@ -34,7 +34,7 @@ Q1. The problems of front camera? A1. In most cases , the video for replacing front camera need to be flipped horizontally and rotated right 90 degrees. The video's resolution **after being processed** need to same with that in toast message. But in some came, it doesn't need to make adjustment, so you need to judge it according to situation. Q2. Black screen ? Open camera fail ? -A2. Till now ,there are a few apps that can't be hooked, especially the system camera. Or it caused by wrong `Camera1` directory. +A2. Till now ,there are a few apps that can't be hooked, especially the system camera. Or it caused by wrong `Camera1` directory(Whether two levels of Camera1 directory were created, like `./DCIM/Camera1/Camera1/virtual.mp4`, only one level is needed). Q3. Blurred screen? A3. The resolution of video is wrong. diff --git a/README_tc.md b/README_tc.md index e28608d..5361396 100644 --- a/README_tc.md +++ b/README_tc.md @@ -34,7 +34,7 @@ A1. 前置攝影機方向問題? Q1.大多數情况下,替換前置攝影機的影片需要水准翻轉並右旋90度,並且影片***處理後***的解析度應與氣泡消息內解析度相同。 但有時這並不需要,具體請根據實際情況判斷。 Q2. 畫面黑屏,相機啟動失敗? -A2. 現時有些應用並不能成功替換(特別是系統相機)。 或者是因為影片路徑不對。 +A2. 現時有些應用並不能成功替換(特別是系統相機)。 或者是因為影片路徑不對(是否創建了兩級Camera1目錄,如`./DCIM/Camera1/Camera1/virtual.mp4`,但只需要一級目錄)。 Q3. 畫面花屏? A3. 影片解析度不對。 diff --git a/app/build.gradle b/app/build.gradle index b0dce34..5b921dc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,9 +8,9 @@ android { defaultConfig { applicationId "com.example.vcam" minSdk 21 - targetSdk 28 - versionCode 18 - versionName "3.5" + targetSdk 29 + versionCode 19 + versionName "3.6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/release/app-release.apk b/app/release/app-release.apk index e9da87d..40f2272 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 1a47272..b525302 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 18, - "versionName": "3.5", + "versionCode": 19, + "versionName": "3.6", "outputFile": "app-release.apk" } ], diff --git a/app/src/main/java/com/example/vcam/HookMain.java b/app/src/main/java/com/example/vcam/HookMain.java index 78c8641..a1d8dc8 100644 --- a/app/src/main/java/com/example/vcam/HookMain.java +++ b/app/src/main/java/com/example/vcam/HookMain.java @@ -275,27 +275,39 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】"+ee.toString()); } if (toast_content != null){ + int auth_statue = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - int auth_statue = PackageManager.PERMISSION_DENIED; try { - auth_statue = toast_content.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE); - }catch (Exception eee){ + auth_statue += (toast_content.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) + 1); + } catch (Exception ignored) { } try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - auth_statue = toast_content.checkSelfPermission(Manifest.permission.MANAGE_EXTERNAL_STORAGE); + auth_statue += (toast_content.checkSelfPermission(Manifest.permission.MANAGE_EXTERNAL_STORAGE) + 1); } - }catch (Exception eee){ + } catch (Exception ignored) { } - if ( auth_statue != PackageManager.PERMISSION_GRANTED){ - File shown_file = new File(Environment.getExternalStorageDirectory()+"/Android/data/"+lpparam.packageName+"/files/Camera1/" + "has_shown.jpg"); + }else { + File DCIM_dic = new File(Environment.getExternalStorageDirectory() + "/DCIM/"); + if ((!DCIM_dic.canRead()) && auth_statue < 1){ + auth_statue = -1; + } + } + if ( auth_statue < 1 ){ + File shown_file = new File(toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/"); + if ((!shown_file.isDirectory()) && shown_file.exists()){ + shown_file.delete(); + } + if (!shown_file.exists()){ + shown_file.mkdir(); + } + shown_file = new File(toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/"+ "has_shown"); if (!(lpparam.packageName.equals(BuildConfig.APPLICATION_ID) || shown_file.exists())) { - Toast.makeText(toast_content, "未授予读取本地目录权限,请检查权限\nCamera1目前重定向为 " + Environment.getExternalStorageDirectory() + "/Android/data/" + lpparam.packageName + "/files/Camera1/", Toast.LENGTH_LONG).show(); - String path = Environment.getExternalStorageDirectory()+"/Android/data/"+lpparam.packageName+"/files/Camera1/" ; + Toast.makeText(toast_content, "未授予读取本地目录权限,请检查权限\nCamera1目前重定向为 " + toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/", Toast.LENGTH_LONG).show(); try { - FileOutputStream fos = new FileOutputStream(path+ "has_shown.jpg"); + FileOutputStream fos = new FileOutputStream(toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/" + "has_shown"); String info = "shown"; fos.write(info.getBytes()); fos.flush(); @@ -304,13 +316,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { XposedBridge.log("【VCAM】"+ e.toString()); } } - video_path = Environment.getExternalStorageDirectory()+"/Android/data/"+lpparam.packageName+"/files/Camera1/"; + video_path = toast_content.getExternalFilesDir(null).getAbsolutePath() + "/Camera1/"; }else { video_path = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/"; } - }else { - video_path = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/"; - } + }else { + video_path = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera1/"; } } }