修复闪退

serial
BlueMatthew 1 year ago
parent 5cdbba26bc
commit 80b0a2f2cf

@ -627,14 +627,20 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
IDevice* dev = pTerminal->GetDevice(); IDevice* dev = pTerminal->GetDevice();
if (dev != NULL) 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); // camera->Open(pathStr, fileNameStr);
unsigned long photoId = videoId; unsigned long photoId = videoId;
((CPhoneDevice *)dev)->OnVideoReady(result != JNI_FALSE, pathStr, photoId); ((CPhoneDevice *)dev)->OnVideoReady(result != JNI_FALSE, pathStr, photoId);
if (path != NULL)
{
env->ReleaseStringUTFChars(path, pathStr); env->ReleaseStringUTFChars(path, pathStr);
} }
}
} }

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

Loading…
Cancel
Save