修复闪退

serial
BlueMatthew 1 year ago
parent 5cdbba26bc
commit 80b0a2f2cf

@ -627,13 +627,19 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
IDevice* dev = pTerminal->GetDevice();
if (dev != NULL)
{
const char *pathStr = env->GetStringUTFChars(path, 0);
const char *pathStr = NULL;
if (path != NULL)
{
pathStr = env->GetStringUTFChars(path, 0);
}
// camera->Open(pathStr, fileNameStr);
unsigned long photoId = videoId;
((CPhoneDevice *)dev)->OnVideoReady(result != JNI_FALSE, pathStr, photoId);
env->ReleaseStringUTFChars(path, pathStr);
if (path != NULL)
{
env->ReleaseStringUTFChars(path, pathStr);
}
}
}

@ -569,14 +569,16 @@ public class VideoFragment extends Fragment implements View.OnClickListener, Med
manager.openCamera(Integer.toString(mCameraId), mStateCallback, null);
} catch (CameraAccessException e) {
// Toast.makeText(activity, "Cannot access the camera.", Toast.LENGTH_SHORT).show();
broadcastVideoFile(false, mNextVideoAbsolutePath);
activity.finish();
} catch (NullPointerException e) {
// Currently an NPE is thrown when the Camera2API is used but not supported on the
// device this code runs.
ErrorDialog.newInstance(getString(R.string.camera_error))
.show(getChildFragmentManager(), FRAGMENT_DIALOG);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted while trying to lock camera opening.");
broadcastVideoFile(false, mNextVideoAbsolutePath);
activity.finish();
} catch (Exception e) {
broadcastVideoFile(false, mNextVideoAbsolutePath);
activity.finish();
}
}
@ -592,8 +594,9 @@ public class VideoFragment extends Fragment implements View.OnClickListener, Med
mMediaRecorder.release();
mMediaRecorder = null;
}
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted while trying to lock camera closing.");
} catch (Exception e) {
broadcastVideoFile(false, mNextVideoAbsolutePath);
getActivity().finish();
} finally {
mCameraOpenCloseLock.release();
}
@ -655,6 +658,9 @@ public class VideoFragment extends Fragment implements View.OnClickListener, Med
} catch (CameraAccessException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
private void setUpCaptureRequestBuilder(CaptureRequest.Builder builder) {
@ -824,6 +830,11 @@ public class VideoFragment extends Fragment implements View.OnClickListener, Med
}, mBackgroundHandler);
} catch (CameraAccessException | IOException e) {
e.printStackTrace();
broadcastVideoFile(false, "");
}
catch (Exception e) {
e.printStackTrace();
broadcastVideoFile(false, "");
}
}

Loading…
Cancel
Save