瀏覽代碼

add security android ionic

tama 1 年之前
父節點
當前提交
0b196212b8

+ 13 - 0
NexilisSampleCodeIonic-Android/android/app/src/main/java/com/example/paliolitesamplecodeionic/MainActivity.java

@@ -7,6 +7,8 @@ import com.getcapacitor.BridgeActivity;
 
 
 import io.nexilis.service.API;
 import io.nexilis.service.API;
 import io.nexilis.service.Callback;
 import io.nexilis.service.Callback;
+import io.nexilis.service.utils.callback.SimCardDetectionCallback;
+import io.nexilis.service.utils.xthunder.FloatingButton;
 
 
 public class MainActivity extends BridgeActivity {
 public class MainActivity extends BridgeActivity {
   @Override
   @Override
@@ -14,6 +16,16 @@ public class MainActivity extends BridgeActivity {
     registerPlugin(NativePlugin.class);
     registerPlugin(NativePlugin.class);
     super.onCreate(savedInstanceState);
     super.onCreate(savedInstanceState);
 
 
+    /**
+     *
+     * Nexilis provides an API security shield service, which functions to detect threats such as malware, ADB, screencapture, and Sim Swapping.
+     */
+
+    //SECURITY
+
+    //SMS
+    //EMAIL
+
     /*************************************
     /*************************************
      Connect to our server with your newuniverse.io Account, and implement the required Callback.
      Connect to our server with your newuniverse.io Account, and implement the required Callback.
      Please Subscribe or contact us to get your newuniverse.io Account.
      Please Subscribe or contact us to get your newuniverse.io Account.
@@ -47,6 +59,7 @@ public class MainActivity extends BridgeActivity {
         runOnUiThread(new Runnable() {
         runOnUiThread(new Runnable() {
           @Override
           @Override
           public void run() {
           public void run() {
+            //FLOATING
             Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID + " : " + getString(io.nexilis.service.R.string.pb_loading), Toast.LENGTH_LONG).show();
             Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID + " : " + getString(io.nexilis.service.R.string.pb_loading), Toast.LENGTH_LONG).show();
           }
           }
         });
         });

+ 131 - 0
main.py

@@ -551,6 +551,7 @@ def change(platform: str, mode: str, path_dest: str, features: dict, security: d
                     f.write(line)
                     f.write(line)
     elif platform == "android_ionic":
     elif platform == "android_ionic":
         main_act_path = os.path.join(path_dest,"src/app/app.component.ts")
         main_act_path = os.path.join(path_dest,"src/app/app.component.ts")
+        main_act_android = os.path.join(path_dest, "android/app/src/main/java/com/example/paliolitesamplecodeionic/MainActivity.java")
         with open(main_act_path, "r") as f:
         with open(main_act_path, "r") as f:
             lines = f.readlines()
             lines = f.readlines()
         with open(main_act_path, "w") as f:
         with open(main_act_path, "w") as f:
@@ -640,6 +641,136 @@ def change(platform: str, mode: str, path_dest: str, features: dict, security: d
                         f.write(indented_str(4, "// },", spaces=2))
                         f.write(indented_str(4, "// },", spaces=2))
                 else:
                 else:
                     f.write(line)
                     f.write(line)
+        with open(main_act_android, "r") as f:
+            lines = f.readlines()
+        with open(main_act_android, "w") as f:
+            for line in lines:
+                if "//SECURITY" in line:
+                    if security["show_security"]:
+                        f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);", spaces=2))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);", spaces=2))
+                        f.write(os.linesep)
+                    if security["emulator"]:
+                        f.write(indented_str(2, "API.setCheckEmulator(true);", spaces=2))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setCheckEmulator(true);", spaces=2))
+                        f.write(os.linesep)
+                    if security["debug"]:
+                        f.write(indented_str(2, "API.setCheckAdb(true);", spaces=2))
+                        f.write(os.linesep)
+                    if security["sim_swap"]:
+                        f.write(indented_str(2,
+                                             "API.setCheckSimCardSwapListener(MainActivity.this, new SimCardDetectionCallback() {", spaces=2))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override", spaces=2))
+                        f.write(indented_str(3, "public boolean onSimCardChange() {", spaces=2))
+                        f.write(indented_str(4, "return false;", spaces=2))
+                        f.write(indented_str(3, "}", spaces=2))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override", spaces=2))
+                        f.write(indented_str(3, "public void onError(String s) {", spaces=2))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "}", spaces=2))
+                        f.write(indented_str(2, "});", spaces=2))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2,
+                                             "/* API.setCheckSimCardSwapListener(MainActivity.this, new SimCardDetectionCallback() {", spaces=2))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override", spaces=2))
+                        f.write(indented_str(3, "public boolean onSimCardChange() {", spaces=2))
+                        f.write(indented_str(4, "return false;", spaces=2))
+                        f.write(indented_str(3, "}", spaces=2))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override", spaces=2))
+                        f.write(indented_str(3, "public void onError(String s) {", spaces=2))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "}", spaces=2))
+                        f.write(indented_str(2, "}); */", spaces=2))
+                        f.write(os.linesep)
+                    if security["malware"]:
+                        f.write(indented_str(2, "API.setCheckMalware(true);", spaces=2))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setCheckMalware(true);", spaces=2))
+                        f.write(os.linesep)
+                    if security["capture"]:
+                        f.write(indented_str(2, "API.setPreventScreenCapture(true);", spaces=2))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setPreventScreenCapture(true);", spaces=2))
+                        f.write(os.linesep)
+                    if security["call_forwarding"]:
+                        f.write(indented_str(2, "API.setCheckCallForwarding(true);", spaces=2))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setCheckCallForwarding(true);", spaces=2))
+                        f.write(os.linesep)
+                    if security["secure_folder"]:
+                        f.write(indented_str(2, "API.openSecureFolder();", spaces=2))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.openSecureFolder();", spaces=2))
+                        f.write(os.linesep)
+                elif "//SMS" in line:
+                    if features["sms"]["status"]:
+                        f.write(indented_str(2, "API.setEnabledSMS(true);", spaces=2))
+                    else:
+                        f.write(indented_str(2, "// API.setEnabledSMS(true);", spaces=2))
+                elif "//EMAIL" in line:
+                    if features["email"]["status"]:
+                        f.write(indented_str(2, "API.setEnabledEmail(true);", spaces=2))
+                    else:
+                        f.write(indented_str(2, "// API.setEnabledEmail(true);", spaces=2))
+                elif "//FLOATING" in line:
+                    if mode == "floating":
+                        f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();", spaces=2))
+                        if features["cc"]["status"]:
+                            f.write(indented_str(6,
+                                                 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));', spaces=2))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));', spaces=2))
+                        if features["nc"]["status"]:
+                            f.write(
+                                indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));', spaces=2))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));', spaces=2))
+                        if features["im"]["status"]:
+                            f.write(
+                                indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));', spaces=2))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));', spaces=2))
+                        if features["call"]["status"]:
+                            f.write(
+                                indented_str(6,
+                                             'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));', spaces=2))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));', spaces=2))
+                        if features["ls"]["status"]:
+                            f.write(
+                                indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));', spaces=2))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));', spaces=2))
+                        f.write(indented_str(6,
+                                             'API.configureFloating(fb);', spaces=2))
+                    else:
+                        f.write(indented_str(0, "", spaces=2))
+                elif "API.connect" in line:
+                    if mode == "floating":
+                        replaced = line.replace("0", "1")
+                        f.write(replaced)
+                    else:
+                        f.write(line)
+                else:
+                    f.write(line)
     elif platform == "android_react":
     elif platform == "android_react":
         main_act_path = os.path.join(path_dest, "App.tsx")
         main_act_path = os.path.join(path_dest, "App.tsx")
         with open(main_act_path, "r") as f:
         with open(main_act_path, "r") as f: