|
|
|
@ -2,6 +2,7 @@ package com.xypower.mpapp.adb;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
@ -26,6 +27,16 @@ public class CameraAdb {
|
|
|
|
|
private String mAppPath;
|
|
|
|
|
private AdbKeyPair mAdbKeyPair;
|
|
|
|
|
private String mDeviceIp = "127.0.0.1";
|
|
|
|
|
private String mTargetPath;
|
|
|
|
|
private Runnable mRunnable;
|
|
|
|
|
|
|
|
|
|
public String getTargetPath() {
|
|
|
|
|
return mTargetPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCallback(Runnable runnable) {
|
|
|
|
|
mRunnable = runnable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CameraAdb(Context context, String appPath) {
|
|
|
|
|
|
|
|
|
@ -90,17 +101,20 @@ public class CameraAdb {
|
|
|
|
|
takePhoto(true);
|
|
|
|
|
takingTime = System.currentTimeMillis() / 1000;
|
|
|
|
|
sleep(250);
|
|
|
|
|
movePhoto(true, requestTime, takingTime);
|
|
|
|
|
String path = movePhoto(true, requestTime, takingTime);
|
|
|
|
|
|
|
|
|
|
sleep(200);
|
|
|
|
|
|
|
|
|
|
SysApi.forceStopApp(mContext, "com.mediatek.camera");
|
|
|
|
|
|
|
|
|
|
MicroPhotoService.restartApp(mContext, MicroPhotoContext.PACKAGE_NAME_MPAPP);
|
|
|
|
|
if (mRunnable != null) {
|
|
|
|
|
mRunnable.run();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void movePhoto(boolean frontCamera, long requestTime, long takingTime) {
|
|
|
|
|
private String movePhoto(boolean frontCamera, long requestTime, long takingTime) {
|
|
|
|
|
|
|
|
|
|
String targetPath = null;
|
|
|
|
|
String photoPath = mAppPath + "photos/";
|
|
|
|
|
String photoFile = "IMG_" + Long.toHexString(requestTime).toUpperCase() + "_"
|
|
|
|
|
+ (frontCamera ? "2" : "1") + "_FF_0_" + Long.toHexString(requestTime).toUpperCase()
|
|
|
|
@ -119,6 +133,7 @@ public class CameraAdb {
|
|
|
|
|
for (int idx = 0; idx < 10; idx++) {
|
|
|
|
|
res = srcFile.renameTo(targetFile);
|
|
|
|
|
if (res) {
|
|
|
|
|
targetPath = targetFile.getAbsolutePath();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sleep(200);
|
|
|
|
@ -130,6 +145,8 @@ public class CameraAdb {
|
|
|
|
|
Log.e(TAG, "Failed to copy photo from Camera");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return targetPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sleep(long timeout) {
|
|
|
|
|