|
|
|
@ -11,6 +11,7 @@ import com.xypower.mpapp.MicroPhotoService;
|
|
|
|
|
import com.xypower.mpapp.v2.Camera2VideoActivity;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FilenameFilter;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
@ -31,6 +32,25 @@ public class CameraAdb {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mAppPath = appPath;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
File cameraPath = new File("/sdcard/DCIM/Camera/");
|
|
|
|
|
FilenameFilter filter = new FilenameFilter() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean accept(File dir, String name) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
File[] files = cameraPath.listFiles(filter);
|
|
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
if (file.lastModified() > 1722960000000L) {
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
File file = new File( new File(appPath), "data/.keypair");
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
@ -59,19 +79,20 @@ public class CameraAdb {
|
|
|
|
|
long requestTime = System.currentTimeMillis() / 1000;
|
|
|
|
|
takePhoto(false);
|
|
|
|
|
long takingTime = System.currentTimeMillis() / 1000;
|
|
|
|
|
sleep(1500);
|
|
|
|
|
movePhoto(false, requestTime, takingTime);
|
|
|
|
|
|
|
|
|
|
sleep(1000);
|
|
|
|
|
sleep(100);
|
|
|
|
|
SysApi.forceStopApp(mContext, "com.mediatek.camera");
|
|
|
|
|
|
|
|
|
|
sleep(1000);
|
|
|
|
|
sleep(200);
|
|
|
|
|
|
|
|
|
|
requestTime = System.currentTimeMillis() / 1000;
|
|
|
|
|
takePhoto(true);
|
|
|
|
|
takingTime = System.currentTimeMillis() / 1000;
|
|
|
|
|
sleep(250);
|
|
|
|
|
movePhoto(true, requestTime, takingTime);
|
|
|
|
|
|
|
|
|
|
sleep(1000);
|
|
|
|
|
sleep(200);
|
|
|
|
|
|
|
|
|
|
SysApi.forceStopApp(mContext, "com.mediatek.camera");
|
|
|
|
|
|
|
|
|
@ -95,7 +116,13 @@ public class CameraAdb {
|
|
|
|
|
File targetFile = new File(new File(photoPath), photoFile);
|
|
|
|
|
try {
|
|
|
|
|
File srcFile = opFile.get();
|
|
|
|
|
res = srcFile.renameTo(targetFile);
|
|
|
|
|
for (int idx = 0; idx < 10; idx++) {
|
|
|
|
|
res = srcFile.renameTo(targetFile);
|
|
|
|
|
if (res) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sleep(200);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -127,19 +154,20 @@ public class CameraAdb {
|
|
|
|
|
"content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0",
|
|
|
|
|
"content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1",
|
|
|
|
|
"am force-stop com.mediatek.camera",
|
|
|
|
|
"wait 1000",
|
|
|
|
|
"setprop mtk.camera.app.keycode.enable 1",
|
|
|
|
|
"setprop mtk.camera.switch.camera.debug 1",
|
|
|
|
|
"setprop mtk.camera.switch.id.debug back-1",
|
|
|
|
|
"am start -a android.media.action.STILL_IMAGE_CAMERA " +
|
|
|
|
|
(frontCamera ? "--ez com.google.assistant.extra.USE_FRONT_CAMERA true" : "") + " -f " + Integer.toString(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP),
|
|
|
|
|
"wait",
|
|
|
|
|
"am start -a android.media.action.STILL_IMAGE_CAMERA" +
|
|
|
|
|
(frontCamera ? " --ez com.google.assistant.extra.USE_FRONT_CAMERA true" : "") + " -f " + Integer.toString(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP),
|
|
|
|
|
"wait 3000",
|
|
|
|
|
"input keyevent 27"};
|
|
|
|
|
|
|
|
|
|
AdbShellResponse adbShellResponse = null;
|
|
|
|
|
for (String cmd : cmds) {
|
|
|
|
|
if (cmd.equals("wait")) {
|
|
|
|
|
if (cmd.startsWith("wait ")) {
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(3000);
|
|
|
|
|
Thread.sleep(Long.parseLong(cmd.substring(5)));
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|