-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzego_check_android_offline_notification.py
98 lines (83 loc) · 4.39 KB
/
zego_check_android_offline_notification.py
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
import os
import json
import xml.etree.ElementTree as ET
class AndroidConfigChecker:
def __init__(self) -> None:
self._google_service_json_path = "./android/app/google-services.json"
self._android_manifest_xml_path = "./android/app/src/main/AndroidManifest.xml"
self._project_gradle_path = "./android/build.gradle"
self._app_gradle_path = "./android/app/build.gradle"
def start_check(self):
if self.is_google_service_json_in_right_location():
print("✅ The google-service.json is in the right location.")
if self.is_google_service_json_match_package_name():
print("✅ The package name matches google-service.json.")
else:
print("❌ The package name does NOT match google-service.json.")
else:
print("❌ The google-service.json is NOT in the right location.")
if self.is_project_gradle_correct():
print("✅ The project level gradle file is ready.")
else:
print("❌ Missing dependencies in project-level gradle file.")
if self.is_app_gradle_plugin_correct():
print("✅ The plugin config in the app-level gradle file is correct.")
else:
print("❌ Missing com.google.gms.google-services plugin in the app-level gradle file.")
if self.is_app_gradle_firebase_dependencies_correct():
print("✅ Firebase dependencies config in the app-level gradle file is correct.")
else:
print("❌ Missing com.google.firebase:firebase-bom dependencies in the app-level gradle file.")
if self.is_app_gradle_firebase_messaging_dependencies_correct():
print("✅ Firebase-Messaging dependencies config in the app-level gradle file is correct.")
else:
print("❌ Missing com.google.firebase:firebase-messaging dependencies in the app-level gradle file.")
def is_google_service_json_in_right_location(self):
gs_path = os.path.abspath(self._google_service_json_path)
return os.path.exists(gs_path)
def is_google_service_json_match_package_name(self):
gs_path = os.path.abspath(self._google_service_json_path)
package_name_list = []
with open(gs_path) as json_file:
data = json.load(json_file)
client = data['client']
for c in client:
package_name = c["client_info"]["android_client_info"]["package_name"]
package_name_list.append(package_name)
android_manifest_root = ET.parse(self._android_manifest_xml_path).getroot()
project_package_name = android_manifest_root.get("package")
return project_package_name in package_name_list
def is_project_gradle_correct(self):
with open(os.path.abspath(self._project_gradle_path)) as file:
content = file.read()
if "com.google.gms:google-services:" in content:
return True
return False
def is_app_gradle_plugin_correct(self):
with open(os.path.abspath(self._app_gradle_path)) as file:
content = file.read()
if "com.google.gms.google-services" in content:
return True
return False
def is_app_gradle_firebase_dependencies_correct(self):
with open(os.path.abspath(self._app_gradle_path)) as file:
content = file.read()
if "com.google.firebase:firebase-bom" in content:
return True
return False
def is_app_gradle_firebase_messaging_dependencies_correct(self):
with open(os.path.abspath(self._app_gradle_path)) as file:
content = file.read()
if "com.google.firebase:firebase-messaging:" in content:
return True
return False
#传参数进行 Debug Release的选择,默认为Debug 比如 python3 generate.py Release
if __name__ == "__main__":
android_checker = AndroidConfigChecker()
android_checker.start_check()
# script_dir = sys.argv[0][0:sys.argv[0].rfind("generate.py")]
# os.chdir(script_dir)
# os.system('cmake -H../TalkLineSDK -B../build/TalkLineSDK -DCMAKE_BUILD_TYPE=%s' % build_type)
# os.system('cmake --build ../build/TalkLineSDK --config %s -- -j 10' % build_type)
# os.system('cmake -H../Demo -B../build/Demo -DCMAKE_BUILD_TYPE=%s' % build_type)
# os.system('cmake --build ../build/Demo --config %s -- -j 10' % build_type)