Forráskód Böngészése

增加卸载二代系统app功能,默认关闭

weizhengliang 2 éve
szülő
commit
3bc6ee2bf5

+ 0 - 9
app/src/main/AndroidManifest.xml

@@ -42,15 +42,6 @@
             android:name="design_height_in_dp"
             android:value="600"/>
 
-        <activity android:name="com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity"
-            android:screenOrientation="landscape">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-
-                <category android:name="android.intent.category.LAUNCHER"/>
-            </intent-filter>
-        </activity>
-
         <activity android:name="com.wdkl.app.ncs.activity.SchemeActivity">
 
             <!-- Schame -->

+ 42 - 1
app/src/main/code/com/wdkl/app/ncs/application/Application.kt

@@ -3,6 +3,7 @@ package com.wdkl.app.ncs.application
 import android.content.Context
 import android.content.res.Configuration
 import android.os.Build
+import android.util.Log
 import com.enation.javashop.android.jrouter.JRouter
 import com.wdkl.ncs.android.lib.base.BaseApplication
 import com.enation.javashop.net.engine.config.NetEngineConfig
@@ -17,6 +18,7 @@ import com.wdkl.app.ncs.callingdoor.helper.XCrashUtils
 import com.wdkl.app.ncs.callingdoor.settings.SettingConfig
 import serialporttest.utils.SerialPortUtil
 import serialporttest.utils.SerialPortUtil433
+import java.io.PrintWriter
 
 /**
  * @author LDD
@@ -25,7 +27,9 @@ import serialporttest.utils.SerialPortUtil433
  * @Note   应用Application
  */
 class Application : BaseApplication() {
-
+    private val TAG = "wdkl_app"
+    private val uninstallApk = false
+    private val APP_NAME = "com.wdkl.callingdoor"
 
     /**
      * @author LDD
@@ -98,6 +102,15 @@ class Application : BaseApplication() {
 
             //打开433串口0
             SerialPortUtil433.getInstance().openSerialPort()
+
+            //卸载原来二代系统apk
+            if (uninstallApk) {
+                Thread {
+                    if (checkAppExist()) {
+                        uninstallApp()
+                    }
+                }.start()
+            }
         }
 
         //屏幕适配方案
@@ -121,6 +134,34 @@ class Application : BaseApplication() {
         Utils.checkCameraSupport()
     }
 
+    private fun checkAppExist() : Boolean {
+        val packageInfo = packageManager.getInstalledPackages(0)
+        var appExist = false
+        for (pInfo in packageInfo) {
+            if (APP_NAME == pInfo.packageName) {
+                appExist = true
+                break
+            }
+        }
+        Log.e(TAG, "callingdoor app exist: " + appExist)
+        return appExist
+    }
+
+    private fun uninstallApp() {
+        val process: Process
+        val printWriter: PrintWriter
+        try {
+            process = Runtime.getRuntime().exec("su")
+            printWriter = PrintWriter(process.outputStream)
+            printWriter.println("pm uninstall " + APP_NAME)
+            printWriter.flush()
+            printWriter.close()
+            Log.e(TAG, "uninstall end")
+        } catch (e: java.lang.Exception) {
+            Log.e(TAG, "uninstall e:" + e.message)
+        }
+    }
+
     override fun attachBaseContext(base: Context) {
         val languageId: Int = SettingConfig.getLanguageId(base)
         LocaleMangerUtils.setApplicationLanguageByIndex(base, languageId)

+ 0 - 38
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -233,15 +233,6 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         //初始化soundpool
         SoundPoolManager.getInstance().init()
 
-        //卸载原来二代系统apk
-        if (uninstallApk) {
-            Thread {
-                if (checkAppExist()) {
-                    uninstallApp()
-                }
-            }.start()
-        }
-
         checkServer()
 
         if ("rk3128".equals(Build.MODEL)) {
@@ -257,35 +248,6 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         Log.d(TAG, "device orientation: ${Constant.DEVICE_ORIENTATION}, width: ${dm.widthPixels}, height: ${dm.heightPixels}")
     }
 
-    private fun checkAppExist() : Boolean {
-        val packageInfo = packageManager.getInstalledPackages(0)
-        var appExist = false
-        for (pInfo in packageInfo) {
-            val appName = "com.wdkl.callingdoor"
-            if (appName == pInfo.packageName) {
-                appExist = true
-                break
-            }
-        }
-        Log.e("callingbed", "callingbed app exist: " + appExist)
-        return appExist
-    }
-
-    private fun uninstallApp() {
-        val process: Process
-        val printWriter: PrintWriter
-        try {
-            process = Runtime.getRuntime().exec("su")
-            printWriter = PrintWriter(process.outputStream)
-            printWriter.println("pm uninstall com.wdkl.callingbed")
-            printWriter.flush()
-            printWriter.close()
-            Log.e("uninstall", "uninstall end")
-        } catch (e: java.lang.Exception) {
-            Log.e("uninstall", "uninstall e:" + e.message)
-        }
-    }
-
     //检查launch版本
     private fun checkLaunch() {
         Log.d(TAG, "start check launch")

+ 7 - 1
welcome/src/main/AndroidManifest.xml

@@ -5,8 +5,14 @@
         android:allowBackup="true"
         android:label="@string/app_name"
         android:supportsRtl="true">
+
         <activity android:name="com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity"
-            >
+            android:screenOrientation="landscape">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
         </activity>
     </application>
 </manifest>

+ 0 - 24
welcome/src/main/ApkBuildDir/AndroidManifest.xml

@@ -1,24 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.enation.javashop.android.welcome">
-    <uses-permission android:name="android.permission.INTERNET"/>
-
-    <application
-        android:allowBackup="true"
-        android:label="@string/app_name"
-        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
-        android:name="apkbuild.WelcomeApplication"
-        android:supportsRtl="true">
-        <activity android:name="com.wdkl.ncs.android.component.welcome.activity.WelcomeActivity"
-            android:theme="@style/AppSplash"
-            >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-
-                <category android:name="android.intent.category.LAUNCHER"/>
-            </intent-filter>
-        </activity>
-    </application>
-</manifest>
-
-    <!--单独Module调试 需要往Application作用域下加入皮肤-->
-    <!--android:theme="@style/Theme.AppCompat.Light.NoActionBar"-->