Android 系统APK-Camera 使用闪光灯拍照后查看图片详细信息都为“未使用闪光灯”
Posted 王睿丶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android 系统APK-Camera 使用闪光灯拍照后查看图片详细信息都为“未使用闪光灯”相关的知识,希望对你有一定的参考价值。
packages/apps/Camera2 / src/com/android/camera/ButtonManager.java
// wangrui Get AppController as a global object, we need it in SettingsManager
++ public static AppController appController;
/**
* Get a new global ButtonManager.
*/
public ButtonManager(AppController app)
mAppController = app;
// wangrui Get AppController as a global object, we need it in SettingsManager
++ appController = mAppController;
Context context = app.getAndroidContext();
sGcamIndex = context.getResources().getInteger(R.integer.camera_mode_gcam);
mSettingsManager = app.getSettingsManager();
mSettingsManager.addListener(this);
packages/apps/Camera2 / src/com/android/camera/CameraActivity.java
// wangrui Get whether the current camera is front or back, 0-back shot 1-front shot
public static int mCameraId = 0;
// wangrui Get the global context, we will use it in ExifUtil
public static Context myContext;
@Override
public String getCameraScope()
CameraId cameraId = mCameraController.getCurrentCameraId();
//wangrui Get whether the current camera is front or back, 0-back shot 1-front shot
++ try
++ mCameraId = Integer.parseInt(cameraId.getValue());
++ catch (Exception e)
++ e.printStackTrace();
++
if(cameraId == null)
Log.e(TAG, "Retrieving Camera Setting Scope with -1");
return SettingsManager.getCameraSettingScope("-1");
return SettingsManager.getCameraSettingScope(cameraId.getValue());
packages/apps/Camera2 / src/com/android/camera/settings/SettingsManager.java
++ import com.android.camera.ButtonManager;
++ import static android.content.Context.MODE_PRIVATE;
private OnSharedPreferenceChangeListener getSharedPreferenceListener(
final OnSettingChangedListener listener)
return new OnSharedPreferenceChangeListener()
@Override
public void onSharedPreferenceChanged(
SharedPreferences sharedPreferences, String key)
// wangrui Get the flash status and store the value in the database
++ if (ButtonManager.appController!= null)
++ if (key.equals(Keys.KEY_FLASH_MODE))
++ int index = SettingsManager.this.getIndexOfCurrentValue(ButtonManager.appController.getCameraScope(),
Keys.KEY_FLASH_MODE);
++ SharedPreferences.Editor editor = mContext.getSharedPreferences("camera_flash_state",MODE_PRIVATE).edit();
++ editor.putInt("state",index);
++ editor.apply();
++
++
listener.onSettingChanged(SettingsManager.this, key);
;
packages/apps/Camera2 / src/com/android/camera/util/ExifUtil.java
++ import android.content.SharedPreferences;
++ import com.android.camera.CameraActivity;
++ import static android.content.Context.MODE_PRIVATE;
private void addCaptureResultToExif(CaptureResultProxy result)
++ // wangrui If the camera is switched to the front, then the flash must not be turned on
++ if (CameraActivity.mCameraId==1)
++ addExifTag(ExifInterface.TAG_FLASH, ExifInterface.Flash.DID_NOT_FIRE);
++ else // wangrui Retrieve flash status from database Close-0, open-1, open-2
++ SharedPreferences pref = CameraActivity.myContext.getSharedPreferences("camera_flash_state",MODE_PRIVATE);
++ int index = pref.getInt("state",1);
++ switch (index)
++ case 0:
++ addExifTag(ExifInterface.TAG_FLASH, ExifInterface.Flash.DID_NOT_FIRE);break;
++ case 1:
++ case 2:
++ addExifTag(ExifInterface.TAG_FLASH, ExifInterface.Flash.FIRED);break;
++
++
// // Flash mode
// Integer flashMode = result.get(CaptureResult.FLASH_MODE);
// if (flashMode == CaptureResult.FLASH_MODE_OFF)
// addExifTag(ExifInterface.TAG_FLASH, ExifInterface.Flash.DID_NOT_FIRE);
// else
// addExifTag(ExifInterface.TAG_FLASH, ExifInterface.Flash.FIRED);
//
以上是关于Android 系统APK-Camera 使用闪光灯拍照后查看图片详细信息都为“未使用闪光灯”的主要内容,如果未能解决你的问题,请参考以下文章
Android 系统APK-Camera 设置默认90W像素
Android 系统APK-Camera 将200W像素改为90W像素