|
@@ -439,11 +439,19 @@ def change_certificate(path_dest, key, keyfile, keytool):
|
|
|
with open(build_gradle, "w") as f:
|
|
|
f.write(replaced)
|
|
|
|
|
|
-def change_huawei_file(path_dest, huawei_file, package):
|
|
|
+def change_huawei_file(path_dest, huawei_file, package_id):
|
|
|
huaweifile_name = "agconnect-services.json"
|
|
|
huaweifile_path = os.path.join(path_dest, "app/{}".format(huaweifile_name))
|
|
|
if huawei_file:
|
|
|
huawei_file.save(huaweifile_path)
|
|
|
+ path_package_id = package_id.replace(".", "/")
|
|
|
+ code_path = "app/src/main/java/"
|
|
|
+ main_code_path = os.path.join(path_dest, code_path, path_package_id, "MAB.java")
|
|
|
+ with open(main_code_path, "r") as f:
|
|
|
+ file_source = f.read()
|
|
|
+ replaced = file_source.replace('isHMSEnabled = false', 'isHMSEnabled = true')
|
|
|
+ with open(main_code_path, "w") as f:
|
|
|
+ f.write(replaced)
|
|
|
else:
|
|
|
gradle = os.path.join(path_dest, "build.gradle")
|
|
|
with open(gradle, "r") as f:
|
|
@@ -463,65 +471,17 @@ def change_huawei_file(path_dest, huawei_file, package):
|
|
|
continue
|
|
|
else:
|
|
|
f.write(line)
|
|
|
- manifest_path = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
|
|
|
- with open(manifest_path, "r") as f:
|
|
|
- lines = f.readlines()
|
|
|
- with open(manifest_path, "w") as f:
|
|
|
- counter = 0
|
|
|
- for line in lines:
|
|
|
- if counter == 0:
|
|
|
- if "<!-- huawei -->" in line:
|
|
|
- counter = 11
|
|
|
- continue
|
|
|
- else:
|
|
|
- f.write(line)
|
|
|
- else:
|
|
|
- counter = counter - 1
|
|
|
- path_package_id = package.replace(".", "/")
|
|
|
- push_service_file = os.path.join(path_dest, "app/src/main/java",path_package_id,"MyPushService.java")
|
|
|
- os.remove(push_service_file)
|
|
|
-
|
|
|
-def change_fms_file(path_dest, fms_file, package):
|
|
|
- fmsfile_name = "google-services.json"
|
|
|
- fmsfile_path = os.path.join(path_dest, "app/{}".format(fmsfile_name))
|
|
|
- if fms_file:
|
|
|
- fms_file.save(fmsfile_path)
|
|
|
- else:
|
|
|
- gradle = os.path.join(path_dest, "build.gradle")
|
|
|
- with open(gradle, "r") as f:
|
|
|
- lines = f.readlines()
|
|
|
- with open(gradle, "w") as f:
|
|
|
- for line in lines:
|
|
|
- if "//FMS" in line:
|
|
|
- continue
|
|
|
- else:
|
|
|
- f.write(line)
|
|
|
- gradle_app = os.path.join(path_dest, "app/build.gradle")
|
|
|
- with open(gradle_app, "r") as f:
|
|
|
- lines = f.readlines()
|
|
|
- with open(gradle_app, "w") as f:
|
|
|
- for line in lines:
|
|
|
- if "//FMS" in line:
|
|
|
- continue
|
|
|
- else:
|
|
|
- f.write(line)
|
|
|
- manifest_path = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
|
|
|
- with open(manifest_path, "r") as f:
|
|
|
- lines = f.readlines()
|
|
|
- with open(manifest_path, "w") as f:
|
|
|
- counter = 0
|
|
|
- for line in lines:
|
|
|
- if counter == 0:
|
|
|
- if "<!-- FMS -->" in line:
|
|
|
- counter = 13
|
|
|
- continue
|
|
|
- else:
|
|
|
- f.write(line)
|
|
|
- else:
|
|
|
- counter = counter - 1
|
|
|
- path_package_id = package.replace(".", "/")
|
|
|
- push_service_file = os.path.join(path_dest, "app/src/main/java",path_package_id,"MyPushServiceFMS.java")
|
|
|
- os.remove(push_service_file)
|
|
|
+
|
|
|
+def change_fms_file(path_dest, fms_enable, package_id):
|
|
|
+ if fms_enable == 1:
|
|
|
+ path_package_id = package_id.replace(".", "/")
|
|
|
+ code_path = "app/src/main/java/"
|
|
|
+ main_code_path = os.path.join(path_dest, code_path, path_package_id, "MAB.java")
|
|
|
+ with open(main_code_path, "r") as f:
|
|
|
+ file_source = f.read()
|
|
|
+ replaced = file_source.replace('isFMSEnabled = false', 'isFMSEnabled = true')
|
|
|
+ with open(main_code_path, "w") as f:
|
|
|
+ f.write(replaced)
|
|
|
|
|
|
def run_build(path_dest):
|
|
|
gradlew = os.path.join(path_dest, "gradlew")
|
|
@@ -590,7 +550,7 @@ def build_apk():
|
|
|
url = None
|
|
|
keystore = None
|
|
|
huawei_file = None
|
|
|
- fms_file = None
|
|
|
+ fms_enable = 0
|
|
|
key_exists = False
|
|
|
# tabs = ["1", "2", "3", "4"]
|
|
|
fb_order = "1,2,3,4,5"
|
|
@@ -661,10 +621,8 @@ def build_apk():
|
|
|
elif 'huawei_file' in request.form:
|
|
|
huawei_file = request.form['huawei_file']
|
|
|
|
|
|
- if 'fms_file' in request.files:
|
|
|
- fms_file = request.files['fms_file']
|
|
|
- elif 'fms_file' in request.form:
|
|
|
- fms_file = request.form['fms_file']
|
|
|
+ if 'fms_enable' in request.form:
|
|
|
+ fms_enable = int(request.form['fms_enable'])
|
|
|
|
|
|
if 'alias' in request.form:
|
|
|
if request.form['alias']:
|
|
@@ -784,7 +742,7 @@ def build_apk():
|
|
|
change_access(path_dest, access_model, package_id)
|
|
|
change_tab(path_dest, tabs, tab_icon, package_id, tab3_mode, tab_amount)
|
|
|
change_huawei_file(path_dest, huawei_file, package_id)
|
|
|
- change_fms_file(path_dest, fms_file, package_id)
|
|
|
+ change_fms_file(path_dest, fms_enable, package_id)
|
|
|
except BaseException as e:
|
|
|
vprint(traceback.format_exc())
|
|
|
return {"status": "2", "message": "Process failure\n{}\n".format(str(e))}
|