概述
接(四)handler分析:
case 4:
FireEye.UpdateRecordingTime();
break;
原始代码:
private void UpdateRecordingTime()
{
if (!this.mRecordingStatus);
while (true)
{
label7: return;
long l1 = System.currentTimeMillis();
millisecondToWaterMarkIndex(l1);
long l2 = l1 - this.mRecordingStartTime;
if (l2 < 0L)
{
StopRecording();
StartRecording();
}
String str = millisecondToTimeString(l2, false);
if (CODE_DEBUG)
Log.d(TAG, "milli second : " + str);
this.mRecordingTime.setText(str);
if (l2 < this.mRecordingRepeatTime)
break label184;
if (this.mConfig.mMotionStatus != 0)
break;
LoopRecording();
this.mHandler.sendEmptyMessageDelayed(4, 500L);
}
if (this.LastDet > 5)
{
this.openMotionDetect = true;
StopRecording();
this.mStartWork.setBackgroundResource(2130837584);
}
while (true)
{
this.LastDet = 0;
break label7:
LoopRecording();
this.mHandler.sendEmptyMessageDelayed(4, 500L);
}
if (this.mFlickerFlags == 0)
{
label184: this.mFlickerFlags = 1;
this.mRecordingFlag.setCompoundDrawablesWithIntrinsicBounds(2130837575, 0, 0, 0);
}
while (true)
{
this.mHandler.sendEmptyMessageDelayed(4, 500L);
if (this.StartDet > 20);
this.openMotionDetect = true;
StopRecording();
this.mStartWork.setBackgroundResource(2130837584);
this.StartDet = 0;
break label7:
this.mFlickerFlags = 0;
this.mRecordingFlag.setCompoundDrawablesWithIntrinsicBounds(2130837576, 0, 0, 0);
}
}
整理后的代码:
private void UpdateRecordingTime()
{
if (mRecordingStatus){ //处于录制状态
long l1 = System.currentTimeMillis();
millisecondToWaterMarkIndex(l1); //时间水印
long l2 = l1 - mRecordingStartTime;
if (l2 < 0L)//录制时间小于0,重新录制
{
StopRecording();
StartRecording();
}
String str = millisecondToTimeString(l2, false);
if (CODE_DEBUG)
Log.d(TAG, "milli second : " + str);
mRecordingTime.setText(str);
if (l2 < mRecordingRepeatTime){
mFlickerFlags = 1;
mRecordingFlag.setCompoundDrawablesWithIntrinsicBounds(R.drawable.camera_recording_label_green, 0, 0, 0);
}
if (mConfig.mMotionStatus == 0){//没有打开移动侦测的情况下,循环录像,每500ms更新时间
LoopRecording();
mHandler.sendEmptyMessageDelayed(4, 500L);
}
}
if (this.LastDet > 5)//这个LastDet没搞清楚什么意思,感觉像是检测运动侦测的幅度
{
openMotionDetect = true;
StopRecording();
this.mStartWork.setBackgroundResource(R.drawable.camera_stop_work);
}
else{
LoopRecording();
mHandler.sendEmptyMessageDelayed(4, 500L);
}
this.LastDet = 0;
// 一段段的来分析可以简化复杂度
if (mFlickerFlags != 0)
{
mFlickerFlags = 0;
mRecordingFlag.setCompoundDrawablesWithIntrinsicBounds(R.drawable.camera_recording_label_red, 0, 0, 0);
}
mHandler.sendEmptyMessageDelayed(4, 500L);
if (StartDet > 20);
openMotionDetect = true;
StopRecording();
mStartWork.setBackgroundResource(R.draw.camera_stop_work);
StartDet = 0;
}
重点来分析一下时间水印的函数:
反编译函数:
private void millisecondToWaterMarkIndex(long paramLong)
{
if ((!this.mConfig.getWaterMark()) && (!this.mConfig.getSpeedMark()));
while (true)
{
label20: return;
if ((this.mConfig.getWaterMark()) && (this.mConfig.getSpeedMark()))
{
Date localDate2 = new Date(paramLong);
Calendar localCalendar2 = Calendar.getInstance();
localCalendar2.setTime(localDate2);
int i4 = localCalendar2.get(1);
int i5 = 1 + localCalendar2.get(2);
int i6 = localCalendar2.get(5);
int i7 = localCalendar2.get(11);
int i8 = localCalendar2.get(12);
int i9 = localCalendar2.get(13);
int i10 = getCurrentSpeed();
if (CODE_DEBUG)
{
Log.d(TAG, "mYear : " + i4);
Log.d(TAG, "mMonth : " + i5);
Log.d(TAG, "mDate : " + i6);
Log.d(TAG, "mHour : " + i7);
Log.d(TAG, "mMinute" + i8);
Log.d(TAG, "mSecond : " + i9);
}
mMarkIndex[0] = (i4 / 1000);
mMarkIndex[1] = ((i4 - 1000 * mMarkIndex[0]) / 100);
mMarkIndex[2] = ((i4 - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1]) / 10);
mMarkIndex[3] = (i4 - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1] - 10 * mMarkIndex[2]);
mMarkIndex[4] = 11;
mMarkIndex[5] = (i5 / 10);
mMarkIndex[6] = (i5 - 10 * mMarkIndex[5]);
mMarkIndex[7] = 11;
mMarkIndex[8] = (i6 / 10);
mMarkIndex[9] = (i6 - 10 * mMarkIndex[8]);
mMarkIndex[10] = 10;
mMarkIndex[11] = (i7 / 10);
mMarkIndex[12] = (i7 - 10 * mMarkIndex[11]);
mMarkIndex[13] = 12;
mMarkIndex[14] = (i8 / 10);
mMarkIndex[15] = (i8 - 10 * mMarkIndex[14]);
mMarkIndex[16] = 12;
mMarkIndex[17] = (i9 / 10);
mMarkIndex[18] = (i9 - 10 * mMarkIndex[17]);
mMarkIndex[19] = 10;
mMarkIndex[20] = 13;
mMarkIndex[21] = 12;
if (i10 >= 100)
{
mMarkIndex[22] = (i10 / 100);
mMarkIndex[23] = ((i10 - 100 * mMarkIndex[20]) / 10);
mMarkIndex[24] = (i10 - 100 * mMarkIndex[20] - 10 * mMarkIndex[21]);
mMaxIndex = 25;
}
while (this.hasBackCamera == 1)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
break label20:
if (i10 >= 10)
{
mMarkIndex[22] = (i10 / 10);
mMarkIndex[23] = (i10 - 10 * mMarkIndex[20]);
mMaxIndex = 24;
}
if ((i10 < 0) || (i10 >= 10))
continue;
mMarkIndex[22] = i10;
mMaxIndex = 23;
}
if (this.mConfig.getRecordModeValue() == 0)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.BackSensorID);
}
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
}
if (this.mConfig.getSpeedMark())
{
int i3 = getCurrentSpeed();
mMarkIndex[0] = 13;
mMarkIndex[1] = 12;
if (i3 >= 100)
{
mMarkIndex[2] = (i3 / 100);
mMarkIndex[3] = ((i3 - 100 * mMarkIndex[0]) / 10);
mMarkIndex[4] = (i3 - 100 * mMarkIndex[0] - 10 * mMarkIndex[1]);
mMaxIndex = 5;
}
while (this.hasBackCamera == 1)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
break label20:
if (i3 >= 10)
{
mMarkIndex[2] = (i3 / 10);
mMarkIndex[3] = (i3 - 10 * mMarkIndex[0]);
mMaxIndex = 4;
}
if ((i3 < 0) || (i3 >= 10))
continue;
mMarkIndex[2] = i3;
mMaxIndex = 3;
}
if (this.mConfig.getRecordModeValue() == 0)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.BackSensorID);
}
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
}
if (!this.mConfig.getWaterMark())
continue;
Date localDate1 = new Date(paramLong);
Calendar localCalendar1 = Calendar.getInstance();
localCalendar1.setTime(localDate1);
int i = localCalendar1.get(1);
int j = 1 + localCalendar1.get(2);
int k = localCalendar1.get(5);
int l = localCalendar1.get(11);
int i1 = localCalendar1.get(12);
int i2 = localCalendar1.get(13);
if (CODE_DEBUG)
{
Log.d(TAG, "mYear : " + i);
Log.d(TAG, "mMonth : " + j);
Log.d(TAG, "mDate : " + k);
Log.d(TAG, "mHour : " + l);
Log.d(TAG, "mMinute" + i1);
Log.d(TAG, "mSecond : " + i2);
}
mMarkIndex[0] = (i / 1000);
mMarkIndex[1] = ((i - 1000 * mMarkIndex[0]) / 100);
mMarkIndex[2] = ((i - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1]) / 10);
mMarkIndex[3] = (i - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1] - 10 * mMarkIndex[2]);
mMarkIndex[4] = 11;
mMarkIndex[5] = (j / 10);
mMarkIndex[6] = (j - 10 * mMarkIndex[5]);
mMarkIndex[7] = 11;
mMarkIndex[8] = (k / 10);
mMarkIndex[9] = (k - 10 * mMarkIndex[8]);
mMarkIndex[10] = 10;
mMarkIndex[11] = (l / 10);
mMarkIndex[12] = (l - 10 * mMarkIndex[11]);
mMarkIndex[13] = 12;
mMarkIndex[14] = (i1 / 10);
mMarkIndex[15] = (i1 - 10 * mMarkIndex[14]);
mMarkIndex[16] = 12;
mMarkIndex[17] = (i2 / 10);
mMarkIndex[18] = (i2 - 10 * mMarkIndex[17]);
mMaxIndex = 19;
if (this.hasBackCamera == 1)
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
if (this.mConfig.getRecordModeValue() == 0)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.BackSensorID);
}
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, this.mConfig.FrontSensorID);
}
}
</pre><p>修改后的:</p><p></p><pre code_snippet_id="583753" snippet_file_name="blog_20150119_6_4344359" name="code" class="java"> private void millisecondToWaterMarkIndex(long paramLong)
{
if ((mConfig.getWaterMark()) || (mConfig.getSpeedMark())){ //时间水印,速度水印
if ((mConfig.getWaterMark()) && (mConfig.getSpeedMark()))
{
Date localDate2 = new Date(paramLong);
Calendar localCalendar2 = Calendar.getInstance();
localCalendar2.setTime(localDate2);
int i4 = localCalendar2.get(Calendar.Year);
int i5 = 1 + localCalendar2.get(Calendar.Month);
int i6 = localCalendar2.get(Calendar.Date);
int i7 = localCalendar2.get(Calendar.Hour);
int i8 = localCalendar2.get(Calendar.Minute);
int i9 = localCalendar2.get(Calendar.Second);
int i10 = getCurrentSpeed();
if (CODE_DEBUG)
{
Log.d(TAG, "mYear : " + i4);
Log.d(TAG, "mMonth : " + i5);
Log.d(TAG, "mDate : " + i6);
Log.d(TAG, "mHour : " + i7);
Log.d(TAG, "mMinute" + i8);
Log.d(TAG, "mSecond : " + i9);
}
mMarkIndex[0] = (i4 / 1000);
mMarkIndex[1] = ((i4 - 1000 * mMarkIndex[0]) / 100);
mMarkIndex[2] = ((i4 - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1]) / 10);
mMarkIndex[3] = (i4 - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1] - 10 * mMarkIndex[2]);
mMarkIndex[4] = 11;
mMarkIndex[5] = (i5 / 10);
mMarkIndex[6] = (i5 - 10 * mMarkIndex[5]);
mMarkIndex[7] = 11;
mMarkIndex[8] = (i6 / 10);
mMarkIndex[9] = (i6 - 10 * mMarkIndex[8]);
mMarkIndex[10] = 10;
mMarkIndex[11] = (i7 / 10);
mMarkIndex[12] = (i7 - 10 * mMarkIndex[11]);
mMarkIndex[13] = 12;
mMarkIndex[14] = (i8 / 10);
mMarkIndex[15] = (i8 - 10 * mMarkIndex[14]);
mMarkIndex[16] = 12;
mMarkIndex[17] = (i9 / 10);
mMarkIndex[18] = (i9 - 10 * mMarkIndex[17]);
mMarkIndex[19] = 10;
mMarkIndex[20] = 13;
mMarkIndex[21] = 12;
if (i10 >= 100)
{
mMarkIndex[22] = (i10 / 100);
mMarkIndex[23] = ((i10 - 100 * mMarkIndex[20]) / 10);
mMarkIndex[24] = (i10 - 100 * mMarkIndex[20] - 10 * mMarkIndex[21]);
mMaxIndex = 25;
}
else if (i10 >= 10)
{
mMarkIndex[22] = (i10 / 10);
mMarkIndex[23] = (i10 - 10 * mMarkIndex[20]);
mMaxIndex = 24;
}
else if ((i10 < 0) || (i10 >= 10)){
mMarkIndex[22] = i10;
mMaxIndex = 23;
}
if (hasBackCamera == 1)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID);
}
if (mConfig.getRecordModeValue() == 0)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID); //refreshWaterMark此函数是用邋c++来实现,应该被封在库里了
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.BackSensorID);
}
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID);
}
//step2
if (mConfig.getSpeedMark())
{
int i3 = getCurrentSpeed();
mMarkIndex[0] = 13;
mMarkIndex[1] = 12;
if (i3 >= 100)
{
mMarkIndex[2] = (i3 / 100);
mMarkIndex[3] = ((i3 - 100 * mMarkIndex[0]) / 10);
mMarkIndex[4] = (i3 - 100 * mMarkIndex[0] - 10 * mMarkIndex[1]);
mMaxIndex = 5;
}else if (i3 >= 10)
{
mMarkIndex[2] = (i3 / 10);
mMarkIndex[3] = (i3 - 10 * mMarkIndex[0]);
mMaxIndex = 4;
}
else if ((i3 < 0) || (i3 >= 10)){
mMarkIndex[2] = i3;
mMaxIndex = 3;
}
if (hasBackCamera == 1)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID);
}
if (mConfig.getRecordModeValue() == 0)
{
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID);
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.BackSensorID);
}
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID);
}
//step3
if (mConfig.getWaterMark())
{
Date localDate1 = new Date(paramLong);
Calendar localCalendar1 = Calendar.getInstance();
localCalendar1.setTime(localDate1);
int i = localCalendar1.get(1);
int j = 1 + localCalendar1.get(2);
int k = localCalendar1.get(5);
int l = localCalendar1.get(11);
int i1 = localCalendar1.get(12);
int i2 = localCalendar1.get(13);
if (CODE_DEBUG)
{
Log.d(TAG, "mYear : " + i);
Log.d(TAG, "mMonth : " + j);
Log.d(TAG, "mDate : " + k);
Log.d(TAG, "mHour : " + l);
Log.d(TAG, "mMinute" + i1);
Log.d(TAG, "mSecond : " + i2);
}
mMarkIndex[0] = (i / 1000);
mMarkIndex[1] = ((i - 1000 * mMarkIndex[0]) / 100);
mMarkIndex[2] = ((i - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1]) / 10);
mMarkIndex[3] = (i - 1000 * mMarkIndex[0] - 100 * mMarkIndex[1] - 10 * mMarkIndex[2]);
mMarkIndex[4] = 11;
mMarkIndex[5] = (j / 10);
mMarkIndex[6] = (j - 10 * mMarkIndex[5]);
mMarkIndex[7] = 11;
mMarkIndex[8] = (k / 10);
mMarkIndex[9] = (k - 10 * mMarkIndex[8]);
mMarkIndex[10] = 10;
mMarkIndex[11] = (l / 10);
mMarkIndex[12] = (l - 10 * mMarkIndex[11]);
mMarkIndex[13] = 12;
mMarkIndex[14] = (i1 / 10);
mMarkIndex[15] = (i1 - 10 * mMarkIndex[14]);
mMarkIndex[16] = 12;
mMarkIndex[17] = (i2 / 10);
mMarkIndex[18] = (i2 - 10 * mMarkIndex[17]);
mMaxIndex = 19;
if (hasBackCamera == 1)
mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID);
if (mConfig.getRecordModeValue() == 0)<pre name="code" class="java">import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
{ mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID); mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.BackSensorID); } mRecorder.refreshWaterMark(16, 16, mMaxIndex, mMarkIndex, mConfig.FrontSensorID);} } } 由于项目比较赶,只是大概的修改方便阅读,如果大家发现逻辑上的错误,请指正,以免误导其他读者!谢谢!其实正真有用的函数被封在库里了:refreshWaterMark
涉及的知识点:
java calendar类的用法。这个估计一般都知道,但是我真心不知道,平常都是用c比较多,java不是很熟,得从头来。
上面有简单的用法
java.util.Calendar
Date localDate2 = new Date(paramLong);
Calendar localCalendar2 = Calendar.getInstance();
localCalendar2.setTime(localDate2);
int i4 = localCalendar2.get(Calendar.Year);
真正的时间水印没有解决,后面再baidu一下,先看下速度是怎么获取的:
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
private Location currentLocation;
private int getCurrentSpeed()
{
if (currentLocation != null)
{
speedMS = currentLocation.getSpeed();
speedKMH = (3.6D * speedMS);
}
return (int)speedKMH;
}
用mtk自带的gps不知道在这里会不会有问题?
以下是网上搜索到的时间水印资料:
转自:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=561294
if (camera != null) {
camera.autoFocus(null);
camera.takePicture(null, null, new PictureCallback() {
@Override
public void onPictureTaken(byte[] data,
Camera camera) {
// Bitmap bitmap =
// BitmapFactory.decodeByteArray(data, 0,
// data.length);
// Matrix matrix = new Matrix();
// 设置缩放
// matrix.postScale(5f, 4f);
// bitmap.getWidth());
// bitmap.getHeight());
// bitmap = Bitmap.createBitmap(bitmap, 0, 0,
// 800, 400, matrix, true);
String path = Environment
.getExternalStorageDirectory()
.getAbsolutePath()
+ "/LingFeng/img/"
+ String.valueOf(cameraPosition) + "/";
fileName = new SimpleDateFormat(
"yyyyMMddHHmmss").format(new Date())
+ ".jpg";
File out = new File(path);
if (!out.exists()) {
out.mkdirs();
}
out = new File(path, fileName);
try {
FileOutputStream outStream = new FileOutputStream(
out);
outStream.write(data);
outStream.close();
camera.startPreview();
} catch (Exception e) {
e.printStackTrace();
}
showMsg("拍照成功");
}
});
}
这种属于纯上层的添加,下面还有一种基本上也是这样添加。
http://blog.csdn.net/mirkerson/article/details/38920107
通过查找资料,得出一个结论,那就是首先得把Android4.4上的camera流程梳理一变。
最后
以上就是成就柠檬为你收集整理的全志行车记录仪里面FireEyepublic.apk反编译的分析(六)——时间水印分析的全部内容,希望文章能够帮你解决全志行车记录仪里面FireEyepublic.apk反编译的分析(六)——时间水印分析所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复