summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-11-11 04:42:43 -0800
committerMichael Bestas <mikeioannina@gmail.com>2017-01-04 22:00:40 +0200
commit13ca178c2f1c614bc6c615b29986fc6002a89d5a (patch)
tree2e2f9885db8ffc0c9c20d41e6415b0aac1a33b1e
parentf4b0a07e3e9f7ab325660b0c8dca82eb392e8168 (diff)
downloadandroid_packages_apps_Snap-13ca178c2f1c614bc6c615b29986fc6002a89d5a.zip
android_packages_apps_Snap-13ca178c2f1c614bc6c615b29986fc6002a89d5a.tar.gz
android_packages_apps_Snap-13ca178c2f1c614bc6c615b29986fc6002a89d5a.tar.bz2
snap: Get rid of static Context member
* These are never a good thing. Instead pass the activity thru CameraUtil. Change-Id: I30d73fa329e174b20e0075a49e6d1e059e30aa3e
-rw-r--r--src/com/android/camera/CameraButtonIntentReceiver.java2
-rw-r--r--src/com/android/camera/CameraHolder.java6
-rwxr-xr-xsrc/com/android/camera/PhotoModule.java27
-rw-r--r--src/com/android/camera/app/CameraApp.java9
-rw-r--r--src/com/android/camera/util/CameraUtil.java2
5 files changed, 14 insertions, 32 deletions
diff --git a/src/com/android/camera/CameraButtonIntentReceiver.java b/src/com/android/camera/CameraButtonIntentReceiver.java
index 253105a..3f0be1d 100644
--- a/src/com/android/camera/CameraButtonIntentReceiver.java
+++ b/src/com/android/camera/CameraButtonIntentReceiver.java
@@ -38,7 +38,7 @@ public class CameraButtonIntentReceiver extends BroadcastReceiver {
CameraHolder holder = CameraHolder.instance();
ComboPreferences pref = new ComboPreferences(context);
int cameraId = CameraSettings.readPreferredCameraId(pref);
- if (holder.tryOpen(null, cameraId, null) == null) {
+ if (holder.tryOpen(context, null, cameraId, null) == null) {
return;
}
diff --git a/src/com/android/camera/CameraHolder.java b/src/com/android/camera/CameraHolder.java
index ee62eb2..9e0e322 100644
--- a/src/com/android/camera/CameraHolder.java
+++ b/src/com/android/camera/CameraHolder.java
@@ -193,11 +193,10 @@ public class CameraHolder {
}
public synchronized CameraProxy open(
+ Context context,
Handler handler, int cameraId,
CameraManager.CameraOpenErrorCallback cb) {
- Context context = CameraApp.getContext();
-
if (DEBUG_OPEN_RELEASE) {
collectState(cameraId, mCameraDevice);
if (mCameraOpened) {
@@ -263,8 +262,9 @@ public class CameraHolder {
* unavailable then return {@code null}.
*/
public synchronized CameraProxy tryOpen(
+ Context context,
Handler handler, int cameraId, CameraManager.CameraOpenErrorCallback cb) {
- return (!mCameraOpened ? open(handler, cameraId, cb) : null);
+ return (!mCameraOpened ? open(context, handler, cameraId, cb) : null);
}
public synchronized void release() {
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 5eff069..55dfbaa 100755
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -57,6 +57,7 @@ import android.view.KeyEvent;
import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.View;
+import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Toast;
import android.widget.SeekBar;
@@ -253,8 +254,6 @@ public class PhotoModule
private byte[] mLastJpegData;
private int mLastJpegOrientation = 0;
- private static Context mApplicationContext = null;
-
private Runnable mDoSnapRunnable = new Runnable() {
@Override
public void run() {
@@ -571,7 +570,6 @@ public class PhotoModule
CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(), activity);
mCameraId = getPreferredCameraId(mPreferences);
mContentResolver = mActivity.getContentResolver();
- mApplicationContext = CameraApp.getContext();
// Surface texture is from camera screen nail and startPreview needs it.
// This must be done before startPreview.
@@ -601,9 +599,7 @@ public class PhotoModule
mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1"));
// LGE HDR mode
- if (mApplicationContext != null) {
- mLgeHdrMode = mApplicationContext.getResources().getBoolean(R.bool.lge_hdr_mode);
- }
+ mLgeHdrMode = mActivity.getResources().getBoolean(R.bool.lge_hdr_mode);
}
private void initializeControlByIntent() {
@@ -1322,11 +1318,8 @@ public class PhotoModule
ExifInterface exif = Exif.getExif(jpegData);
boolean overrideMakerAndModelTag = false;
- if (mApplicationContext != null) {
- overrideMakerAndModelTag =
- mApplicationContext.getResources()
- .getBoolean(R.bool.override_maker_and_model_tag);
- }
+ overrideMakerAndModelTag = mActivity.getResources()
+ .getBoolean(R.bool.override_maker_and_model_tag);
if (overrideMakerAndModelTag) {
ExifTag maker = exif.buildTag(ExifInterface.TAG_MAKE, Build.MANUFACTURER);
@@ -1376,12 +1369,10 @@ public class PhotoModule
boolean backCameraRestartPreviewOnPictureTaken = false;
boolean frontCameraRestartPreviewOnPictureTaken = false;
- if (mApplicationContext != null) {
- backCameraRestartPreviewOnPictureTaken =
- mApplicationContext.getResources().getBoolean(R.bool.back_camera_restart_preview_onPictureTaken);
- frontCameraRestartPreviewOnPictureTaken =
- mApplicationContext.getResources().getBoolean(R.bool.front_camera_restart_preview_onPictureTaken);
- }
+ backCameraRestartPreviewOnPictureTaken =
+ mActivity.getResources().getBoolean(R.bool.back_camera_restart_preview_onPictureTaken);
+ frontCameraRestartPreviewOnPictureTaken =
+ mActivity.getResources().getBoolean(R.bool.front_camera_restart_preview_onPictureTaken);
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
if ((info.facing == CameraInfo.CAMERA_FACING_BACK
@@ -3861,7 +3852,7 @@ public class PhotoModule
// Get default preview resolution from overlay
String previewSizeForPhoto =
- mApplicationContext.getResources().getString(R.string.preview_size_for_photo);
+ mActivity.getResources().getString(R.string.preview_size_for_photo);
try {
android.util.Size previewSize = android.util.Size.parseSize(previewSizeForPhoto);
diff --git a/src/com/android/camera/app/CameraApp.java b/src/com/android/camera/app/CameraApp.java
index b5a5f4d..6261159 100644
--- a/src/com/android/camera/app/CameraApp.java
+++ b/src/com/android/camera/app/CameraApp.java
@@ -19,7 +19,6 @@ package com.android.camera.app;
import android.app.ActivityManager;
import android.app.Application;
-import android.content.Context;
import com.android.camera.SDCard;
import com.android.camera.util.CameraUtil;
@@ -29,7 +28,6 @@ public class CameraApp extends Application {
private static long mMaxSystemMemory;
public static boolean mIsLowMemoryDevice = false;
private static final long LOW_MEMORY_DEVICE_THRESHOLD = 2L*1024*1024*1024;
- private static Application mApp = null;
@Override
public void onCreate() {
@@ -42,15 +40,8 @@ public class CameraApp extends Application {
mIsLowMemoryDevice = true;
}
- mApp = this;
-
UsageStatistics.initialize(this);
CameraUtil.initialize(this);
SDCard.initialize(this);
}
-
- public static Context getContext()
- {
- return mApp.getApplicationContext();
- }
}
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index a5bd123..ba6768e 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -381,7 +381,7 @@ public class CameraUtil {
Handler handler, final CameraManager.CameraOpenErrorCallback cb) {
try {
throwIfCameraDisabled(activity);
- return CameraHolder.instance().open(handler, cameraId, cb);
+ return CameraHolder.instance().open(activity, handler, cameraId, cb);
} catch (CameraDisabledException ex) {
handler.post(new Runnable() {
@Override