|
@@ -481,6 +481,48 @@ def change_huawei_file(path_dest, huawei_file, package):
|
|
|
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 run_build(path_dest):
|
|
|
gradlew = os.path.join(path_dest, "gradlew")
|
|
|
error = ""
|
|
@@ -548,6 +590,7 @@ def build_apk():
|
|
|
url = None
|
|
|
keystore = None
|
|
|
huawei_file = None
|
|
|
+ fms_file = None
|
|
|
key_exists = False
|
|
|
# tabs = ["1", "2", "3", "4"]
|
|
|
fb_order = "1,2,3,4,5"
|
|
@@ -618,6 +661,11 @@ 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 'alias' in request.form:
|
|
|
if request.form['alias']:
|
|
|
key["alias"] = request.form['alias']
|
|
@@ -736,6 +784,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)
|
|
|
except BaseException as e:
|
|
|
vprint(traceback.format_exc())
|
|
|
return {"status": "2", "message": "Process failure\n{}\n".format(str(e))}
|