|
20
|
23
|
import java.lang.reflect.Field;
|
|
21
|
24
|
import java.lang.reflect.Method;
|
|
22
|
25
|
import java.sql.Date;
|
|
|
@ -29,53 +32,121 @@ import java.util.Properties;
|
|
29
|
32
|
* 如:判断手机类型、跳转到权限管理页面、设置状态栏中图文的颜色模式(深色或亮色)
|
|
30
|
33
|
*/
|
|
31
|
34
|
public class SystemTypeUtil {
|
|
32
|
|
private static final String TAG = SystemTypeUtil.class.getSimpleName();
|
|
33
|
|
private static final String KEY_EMUI_VERSION_CODE = "ro.build.version.emui";
|
|
34
|
|
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
|
|
35
|
|
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
|
|
36
|
|
private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
|
|
|
35
|
private static final String TAG = "SystemTypeUtil";
|
|
37
|
36
|
|
|
|
37
|
public static final String ROM_MIUI = "MIUI";
|
|
|
38
|
public static final String ROM_EMUI = "EMUI";
|
|
|
39
|
public static final String ROM_FLYME = "FLYME";
|
|
|
40
|
public static final String ROM_OPPO = "OPPO";
|
|
|
41
|
public static final String ROM_SMARTISAN = "SMARTISAN";
|
|
|
42
|
public static final String ROM_VIVO = "VIVO";
|
|
|
43
|
public static final String ROM_QIKU = "QIKU";
|
|
38
|
44
|
|
|
39
|
|
/**
|
|
40
|
|
* 是否为华为手机
|
|
41
|
|
*
|
|
42
|
|
* @return
|
|
43
|
|
*/
|
|
44
|
|
public static boolean isEMUI() {
|
|
45
|
|
try {
|
|
46
|
|
return getProperty(KEY_EMUI_VERSION_CODE, null) != null;
|
|
47
|
|
} catch (final IOException e) {
|
|
48
|
|
return false;
|
|
|
45
|
private static final String KEY_VERSION_MIUI = "ro.miui.ui.version.name";
|
|
|
46
|
private static final String KEY_VERSION_EMUI = "ro.build.version.emui";
|
|
|
47
|
private static final String KEY_VERSION_OPPO = "ro.build.version.opporom";
|
|
|
48
|
private static final String KEY_VERSION_SMARTISAN = "ro.smartisan.version";
|
|
|
49
|
private static final String KEY_VERSION_VIVO = "ro.vivo.os.version";
|
|
|
50
|
|
|
|
51
|
private static String sName;
|
|
|
52
|
private static String sVersion;
|
|
|
53
|
// 华为
|
|
|
54
|
public static boolean isEmui() {
|
|
|
55
|
return check(ROM_EMUI);
|
|
|
56
|
}
|
|
|
57
|
|
|
|
58
|
// 小米
|
|
|
59
|
public static boolean isMiui() {
|
|
|
60
|
return check(ROM_MIUI);
|
|
|
61
|
}
|
|
|
62
|
|
|
|
63
|
// VIVO
|
|
|
64
|
public static boolean isVivo() {
|
|
|
65
|
return check(ROM_VIVO);
|
|
|
66
|
}
|
|
|
67
|
|
|
|
68
|
// OPPO
|
|
|
69
|
public static boolean isOppo() {
|
|
|
70
|
return check(ROM_OPPO);
|
|
|
71
|
}
|
|
|
72
|
|
|
|
73
|
// 魅族
|
|
|
74
|
public static boolean isFlyme() {
|
|
|
75
|
return check(ROM_FLYME);
|
|
|
76
|
}
|
|
|
77
|
|
|
|
78
|
// 360
|
|
|
79
|
public static boolean is360() {
|
|
|
80
|
return check(ROM_QIKU) || check("360");
|
|
|
81
|
}
|
|
|
82
|
|
|
|
83
|
// 锤子
|
|
|
84
|
public static boolean isSmartisan() {
|
|
|
85
|
return check(ROM_SMARTISAN);
|
|
|
86
|
}
|
|
|
87
|
|
|
|
88
|
public static String getName() {
|
|
|
89
|
if (sName == null) {
|
|
|
90
|
check("");
|
|
49
|
91
|
}
|
|
|
92
|
return sName;
|
|
50
|
93
|
}
|
|
51
|
94
|
|
|
52
|
|
/**
|
|
53
|
|
* 是否为小米手机
|
|
54
|
|
*
|
|
55
|
|
* @return
|
|
56
|
|
*/
|
|
57
|
|
public static boolean isMIUI() {
|
|
58
|
|
try {
|
|
59
|
|
return getProperty(KEY_MIUI_VERSION_CODE, null) != null
|
|
60
|
|
|| getProperty(KEY_MIUI_VERSION_NAME, null) != null
|
|
61
|
|
|| getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null;
|
|
62
|
|
} catch (final IOException e) {
|
|
63
|
|
return false;
|
|
|
95
|
public static String getVersion() {
|
|
|
96
|
if (sVersion == null) {
|
|
|
97
|
check("");
|
|
64
|
98
|
}
|
|
|
99
|
return sVersion;
|
|
65
|
100
|
}
|
|
66
|
101
|
|
|
67
|
|
/**
|
|
68
|
|
* 是否为魅族手机
|
|
69
|
|
*
|
|
70
|
|
* @return
|
|
71
|
|
*/
|
|
72
|
|
public static boolean isFlyme() {
|
|
|
102
|
public static boolean check(String rom) {
|
|
|
103
|
if (sName != null) {
|
|
|
104
|
return sName.equals(rom);
|
|
|
105
|
}
|
|
|
106
|
|
|
|
107
|
if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_MIUI))) {
|
|
|
108
|
sName = ROM_MIUI;
|
|
|
109
|
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_EMUI))) {
|
|
|
110
|
sName = ROM_EMUI;
|
|
|
111
|
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_OPPO))) {
|
|
|
112
|
sName = ROM_OPPO;
|
|
|
113
|
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_VIVO))) {
|
|
|
114
|
sName = ROM_VIVO;
|
|
|
115
|
} else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_SMARTISAN))) {
|
|
|
116
|
sName = ROM_SMARTISAN;
|
|
|
117
|
} else {
|
|
|
118
|
sVersion = Build.DISPLAY;
|
|
|
119
|
if (sVersion.toUpperCase().contains(ROM_FLYME)) {
|
|
|
120
|
sName = ROM_FLYME;
|
|
|
121
|
} else {
|
|
|
122
|
sVersion = Build.UNKNOWN;
|
|
|
123
|
sName = Build.MANUFACTURER.toUpperCase();
|
|
|
124
|
}
|
|
|
125
|
}
|
|
|
126
|
return sName.equals(rom);
|
|
|
127
|
}
|
|
|
128
|
|
|
|
129
|
public static String getProp(String name) {
|
|
|
130
|
String line = null;
|
|
|
131
|
BufferedReader input = null;
|
|
73
|
132
|
try {
|
|
74
|
|
final Method method = Build.class.getMethod("hasSmartBar");
|
|
75
|
|
return method != null;
|
|
76
|
|
} catch (final Exception e) {
|
|
77
|
|
return false;
|
|
|
133
|
Process p = Runtime.getRuntime().exec("getprop " + name);
|
|
|
134
|
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
|
|
|
135
|
line = input.readLine();
|
|
|
136
|
input.close();
|
|
|
137
|
} catch (IOException ex) {
|
|
|
138
|
Log.e(TAG, "Unable to read prop " + name, ex);
|
|
|
139
|
return null;
|
|
|
140
|
} finally {
|
|
|
141
|
if (input != null) {
|
|
|
142
|
try {
|
|
|
143
|
input.close();
|
|
|
144
|
} catch (IOException e) {
|
|
|
145
|
e.printStackTrace();
|
|
|
146
|
}
|
|
|
147
|
}
|
|
78
|
148
|
}
|
|
|
149
|
return line;
|
|
79
|
150
|
}
|
|
80
|
151
|
|
|
81
|
152
|
|
|
|
@ -99,7 +170,7 @@ public class SystemTypeUtil {
|
|
99
|
170
|
e.printStackTrace();
|
|
100
|
171
|
context.startActivity(getAppDetailSettingIntent(context));
|
|
101
|
172
|
}
|
|
102
|
|
} else if (isMIUI()) {
|
|
|
173
|
} else if (isMiui()) {
|
|
103
|
174
|
// ToastUtil.show("我是小米");
|
|
104
|
175
|
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
|
|
105
|
176
|
ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
|
|
|
@ -111,7 +182,7 @@ public class SystemTypeUtil {
|
|
111
|
182
|
e.printStackTrace();
|
|
112
|
183
|
context.startActivity(getAppDetailSettingIntent(context));
|
|
113
|
184
|
}
|
|
114
|
|
} else if (isEMUI()) {
|
|
|
185
|
} else if (isEmui()) {
|
|
115
|
186
|
// ToastUtil.show("我是华为");
|
|
116
|
187
|
try {
|
|
117
|
188
|
Intent intent = new Intent();
|
|
|
@ -86,7 +86,7 @@
|
|
86
|
86
|
android:background="@drawable/textviewhuiline_style"
|
|
87
|
87
|
android:gravity="center"
|
|
88
|
88
|
android:layout_below="@+id/tv_2"
|
|
89
|
|
android:layout_marginTop="252px"
|
|
|
89
|
android:layout_marginTop="40dp"
|
|
90
|
90
|
android:layout_centerHorizontal="true"/>
|
|
91
|
91
|
|
|
92
|
92
|
<TextView
|
|
|
@ -101,7 +101,20 @@
|
|
101
|
101
|
|
|
102
|
102
|
|
|
103
|
103
|
<TextView
|
|
104
|
|
android:text="《用户协议和隐私政策》"
|
|
|
104
|
android:text="《充电桩APP用户使用协议》"
|
|
|
105
|
android:layout_width="wrap_content"
|
|
|
106
|
android:layout_above="@+id/privacy"
|
|
|
107
|
android:textSize="15sp"
|
|
|
108
|
android:textColor="#1e90ff"
|
|
|
109
|
android:layout_centerHorizontal="true"
|
|
|
110
|
android:onClick="onAgreementView"
|
|
|
111
|
android:clickable="true"
|
|
|
112
|
android:layout_marginBottom="8dp"
|
|
|
113
|
android:layout_height="wrap_content"/>
|
|
|
114
|
|
|
|
115
|
<TextView
|
|
|
116
|
android:id="@+id/privacy"
|
|
|
117
|
android:text="《充电桩隐私政策》"
|
|
105
|
118
|
android:layout_width="wrap_content"
|
|
106
|
119
|
android:layout_above="@+id/android"
|
|
107
|
120
|
android:textSize="15sp"
|