AdsVideoUtils.java
4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.gimi.common.cinema.utils;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
import java.io.IOException;
/**
* Created by wugian on 2016/7/22
*/
public class AdsVideoUtils {
private static final String ADS_VIDEO_NAME = "qnyk.mp4";
private static final String HASH_2D_DEMO = "c07f43798492d8c0cf58875e134e3793;0a00e1041ee59f4c12069f36c50acb9f;e763eb29a837b7609a0b4e8c8c0b3fb2;b241f1909e3fc8e36af7a1f28706bf07";
//918
private static final String Z4_PATH = "/sdcard/media/XgimiVideo/2D_DEMO.mp4";
//928
private static final String H1_PATH = "/sdcard/0/XgimiVideo/2D_DEMO.mp4";
/**
* 规则:服务器上的视频文件 -> 开机广告(目前只有z4x及z4xp上有path: /data/local/bootvideo.mp4) -> 2D_DEMO 视频
*
* @param sambaRootPath sambaRootPath
* @return adsPath
*/
public static String getAdsVideoPath(String sambaRootPath) {
String videoPath = sambaRootPath + ADS_VIDEO_NAME;
if (SambaFileCharge.fileExist(videoPath)) {
String infoPath = sambaRootPath + ".video.inf";
if (SambaFileCharge.fileExist(infoPath)) {
String s = FileReadUtils.readDate(infoPath);
String fileHash = FileHashUtils.getFileHash(videoPath);
if (!TextUtils.isEmpty(s) && !TextUtils.isEmpty(fileHash)) {
if (s.equals(fileHash)) {
//charge the md5 right?
return videoPath;
}
}
}
}
if (new File("/data/local/bootvideo.mp4").exists()) {
return "/data/local/bootvideo.mp4";
}
if (new File(Z4_PATH).exists()) {
String fileHash = FileHashUtils.getFileHash(Z4_PATH);
if (HASH_2D_DEMO.equals(fileHash)) {
return Z4_PATH;
}
}
if (new File(H1_PATH).exists()) {
String fileHash = FileHashUtils.getFileHash(H1_PATH);
if (HASH_2D_DEMO.equals(fileHash)) {
return H1_PATH;
}
}
return "file not exist or not legal";
}
public static String getAdsVideoHash(String sambaRootPath) {
String videoPath = sambaRootPath + ADS_VIDEO_NAME;
//存在合理就不再验证直接返回空
if (SambaFileCharge.fileExist(videoPath)) {
String infoPath = sambaRootPath + ".video.inf";
if (SambaFileCharge.fileExist(infoPath)) {
String s = FileReadUtils.readDate(infoPath);
String fileHash = FileHashUtils.getFileHash(videoPath);
if (!TextUtils.isEmpty(s) && !TextUtils.isEmpty(fileHash)) {
if (s.equals(fileHash)) {
Log.d("lovely", "╔════════════════════════════════════════════");
Log.d("lovely", "╟hash right return empty ");
Log.d("lovely", "╚════════════════════════════════════════════");
return "";
}
}
}
}
if (SambaFileCharge.fileExist(videoPath)) {
return FileHashUtils.getFileHash(videoPath);
}
return "";
}
public static void writeAdsVideoInfo(String sambaRootPath, String videoInfo) {
String infoPath = sambaRootPath + ".video.inf";
if (!SambaFileCharge.fileExist(infoPath)) {
try {
new File(infoPath).createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
if (SambaFileCharge.fileExist(infoPath)) {
FileReadUtils.writeDate(infoPath, videoInfo);
} else {
Log.d("lovely", "╔════════════════════════════════════════════");
Log.d("lovely", "╟广告信息写入失败");
Log.d("lovely", "╚════════════════════════════════════════════");
}
}
}