/** Load metadata for 10 items ahead of our current. */
private static final int FILMSTRIP_PRELOAD_AHEAD_ITEMS = 10;
private static final int PERMISSIONS_ACTIVITY_REQUEST_CODE = 1;
- private static final int PERMISSIONS_RESULT_CODE_OK = 0;
- private static final int PERMISSIONS_RESULT_CODE_FAILED = 1;
+ private static final int PERMISSIONS_RESULT_CODE_OK = 1;
+ private static final int PERMISSIONS_RESULT_CODE_FAILED = 2;
/** Should be used wherever a context is needed. */
private Context mAppContext;
getServices().getMemoryManager());
mFatalErrorHandler = new FatalErrorHandlerImpl(this);
checkPermissions();
+ if (!mHasCriticalPermissions) {
+ Log.v(TAG, "onCreate: Missing critical permissions.");
+ finish();
+ return;
+ }
profile.mark();
if (!Glide.isSetup()) {
Context context = getAndroidContext();
mCurrentModule.init(this, isSecureCamera(), isCaptureIntent());
profile.mark("Init CurrentModule");
+ preloadFilmstripItems();
+
setupNfcBeamPush();
mLocalImagesObserver = new FilmstripContentObserver();
@Override
public void onResumeTasks() {
mPaused = false;
+ checkPermissions();
+ if (!mHasCriticalPermissions) {
+ Log.v(TAG, "onResume: Missing critical permissions.");
+ finish();
+ return;
+ }
if (!mSecureCamera) {
// Show the dialog if necessary. The rest resume logic will be invoked
// at the onFirstRunStateReady() callback.
!mSettingsManager.getBoolean(SettingsManager.SCOPE_GLOBAL, Keys.KEY_HAS_SEEN_PERMISSIONS_DIALOGS)) ||
!mHasCriticalPermissions) {
Intent intent = new Intent(this, PermissionsActivity.class);
- startActivityForResult(intent, PERMISSIONS_ACTIVITY_REQUEST_CODE);
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- // Close the app if critical permissions are missing.
- if (requestCode == PERMISSIONS_ACTIVITY_REQUEST_CODE && resultCode == PERMISSIONS_RESULT_CODE_FAILED) {
+ startActivity(intent);
finish();
}
}
Profile profile = mProfiler.create("CameraActivity.resume").start();
CameraPerformanceTracker.onEvent(CameraPerformanceTracker.ACTIVITY_RESUME);
Log.v(TAG, "Build info: " + Build.DISPLAY);
- if (!mHasCriticalPermissions) {
- Log.v(TAG, "Missing critical permissions.");
- return;
- }
- preloadFilmstripItems();
updateStorageSpaceAndHint(null);
mLastLayoutOrientation = getResources().getConfiguration().orientation;
mCameraController.removeCallbackReceiver();
mCameraController.setCameraExceptionHandler(null);
}
- getContentResolver().unregisterContentObserver(mLocalImagesObserver);
- getContentResolver().unregisterContentObserver(mLocalVideosObserver);
+ if (mLocalImagesObserver != null) {
+ getContentResolver().unregisterContentObserver(mLocalImagesObserver);
+ }
+ if (mLocalVideosObserver != null) {
+ getContentResolver().unregisterContentObserver(mLocalVideosObserver);
+ }
getServices().getCaptureSessionManager().removeSessionListener(mSessionListener);
- mCameraAppUI.onDestroy();
- mModeListView.setVisibilityChangedListener(null);
+ if (mCameraAppUI != null) {
+ mCameraAppUI.onDestroy();
+ }
+ if (mModeListView != null) {
+ mModeListView.setVisibilityChangedListener(null);
+ }
mCameraController = null;
mSettingsManager = null;
mOrientationManager = null;
mButtonManager = null;
- mSoundPlayer.release();
+ if (mSoundPlayer != null) {
+ mSoundPlayer.release();
+ }
CameraAgentFactory.recycle(CameraAgentFactory.CameraApi.API_1);
CameraAgentFactory.recycle(CameraAgentFactory.CameraApi.AUTO);
}