Commit 7e25b94a by Baoxy

build: 去掉中间件

parent 6266843f
......@@ -26,7 +26,7 @@ MAVEN_URL=http://192.168.0.170:13000/nexus/content/repositories/releases/
MAVEN_URL_SNAPSHOT=http://192.168.0.170:13000/nexus/content/repositories/releases/
#32位有符号数2147483647(10)
versionIntCode=2020041101
versionIntCode=2020041301
versionNameMajor=1
versionNameMinor=0
......
......@@ -3,7 +3,6 @@ package com.secspace.lib.common.dpm
import android.content.ComponentName
import android.content.Context
import android.content.pm.PackageManager
import android.text.TextUtils
import com.huawei.android.app.admin.DeviceApplicationManager
import com.huawei.android.app.admin.DevicePackageManager
......@@ -18,29 +17,53 @@ class ApplicationManager private constructor() : BaseDeviceManager() {
}
}
fun addPersistentApp(list: MutableList<String>) = mDeviceApplicationManager.addPersistentApp(mComponent, list)
fun addPersistentApp(pkgs: MutableList<String>) {
if (!checkNull(pkgs))
mDeviceApplicationManager.addPersistentApp(mComponent, pkgs)
}
fun removePersistentApp(list: MutableList<String>) = mDeviceApplicationManager.removePersistentApp(mComponent, list)
fun removePersistentApp(pkgs: MutableList<String>) {
if (!checkNull(pkgs))
mDeviceApplicationManager.removePersistentApp(mComponent, pkgs)
}
fun getPersistentApp(): MutableList<String> = mDeviceApplicationManager.getPersistentApp(mComponent)
fun addDisallowedRunningApp(list: MutableList<String>) = mDeviceApplicationManager.addDisallowedRunningApp(mComponent, list)
fun addDisallowedRunningApp(pkgs: MutableList<String>) {
if (!checkNull(pkgs))
mDeviceApplicationManager.addDisallowedRunningApp(mComponent, pkgs)
}
fun removeDisallowedRunningApp(list: MutableList<String>) = mDeviceApplicationManager.removeDisallowedRunningApp(mComponent, list)
fun removeDisallowedRunningApp(pkgs: MutableList<String>) {
if (!checkNull(pkgs))
mDeviceApplicationManager.removeDisallowedRunningApp(mComponent, pkgs)
}
fun getDisallowedRunningApp(): MutableList<String> = mDeviceApplicationManager.getDisallowedRunningApp(mComponent)
fun killApplicationProcess(pkg: String) = mDeviceApplicationManager.killApplicationProcess(mComponent, pkg)
fun addDisallowedUninstallPackages(pkgs: MutableList<String>) = mDevicePackageManager.addDisallowedUninstallPackages(mComponent, pkgs)
fun addDisallowedUninstallPackages(pkgs: MutableList<String>) {
if (!checkNull(pkgs))
mDevicePackageManager.addDisallowedUninstallPackages(mComponent, pkgs)
}
fun removeDisallowedUninstallPackages(pkgs: MutableList<String>) = mDevicePackageManager.removeDisallowedUninstallPackages(mComponent, pkgs)
fun removeDisallowedUninstallPackages(pkgs: MutableList<String>){
if (!checkNull(pkgs))
mDevicePackageManager.removeDisallowedUninstallPackages(mComponent, pkgs)
}
fun getDisallowedUninstallPackageList(): MutableList<String> = mDevicePackageManager.getDisallowedUninstallPackageList(mComponent)
fun addDisabledDeactivateMdmPackages(pkgs: MutableList<String>) = mDevicePackageManager.addDisabledDeactivateMdmPackages(mComponent, pkgs)
fun addDisabledDeactivateMdmPackages(pkgs: MutableList<String>){
if (!checkNull(pkgs))
mDevicePackageManager.addDisabledDeactivateMdmPackages(mComponent, pkgs)
}
fun removeDisabledDeactivateMdmPackages(pkgs: MutableList<String>) = mDevicePackageManager.removeDisabledDeactivateMdmPackages(mComponent, pkgs)
fun removeDisabledDeactivateMdmPackages(pkgs: MutableList<String>){
if (!checkNull(pkgs))
mDevicePackageManager.removeDisabledDeactivateMdmPackages(mComponent, pkgs)
}
fun getDisabledDeactivateMdmPackageList(): MutableList<String> = mDevicePackageManager.getDisabledDeactivateMdmPackageList(mComponent)
......
......@@ -2,9 +2,15 @@ package com.secspace.lib.common.dpm
import android.content.ComponentName
open class BaseDeviceManager{
open class BaseDeviceManager {
lateinit var mComponent: ComponentName
open fun init(component: ComponentName){
open fun init(component: ComponentName) {
mComponent = component
}
}
\ No newline at end of file
open fun checkNull(list: MutableList<String>): Boolean = when (list.size) {
0 -> true
else -> false
}
}
......@@ -12,7 +12,15 @@ class HwSystemManager private constructor() : BaseDeviceManager() {
}
}
fun setSuperWhiteListForHwSystemManger(list: ArrayList<String>): Boolean = mDeviceHwSystemManager.setSuperWhiteListForHwSystemManger(mComponent, list)
fun setSuperWhiteListForHwSystemManger(pkgs: ArrayList<String>) {
if (!checkNull(pkgs))
mDeviceHwSystemManager.setSuperWhiteListForHwSystemManger(mComponent, pkgs)
}
fun removeSuperWhiteListForHwSystemManger(pkgs: ArrayList<String>) {
if (!checkNull(pkgs))
mDeviceHwSystemManager.removeSuperWhiteListForHwSystemManger(mComponent, pkgs)
}
fun removeSuperWhiteListForHwSystemManger(list: ArrayList<String>): Boolean = mDeviceHwSystemManager.removeSuperWhiteListForHwSystemManger(mComponent, list)
fun getSuperWhiteListForHwSystemManger() = mDeviceHwSystemManager.getSuperWhiteListForHwSystemManger(mComponent)
}
\ No newline at end of file
......@@ -23,11 +23,4 @@ class PolicyManager private constructor() : BaseDeviceManager() {
this.mContext = context
}
fun addDisallowedUninstallPackages(pkgs: MutableList<String>) = pkgs.forEach {
mDevicePolicyManager.setUninstallBlocked(mComponent, it, true)
}
fun removeDisallowedUninstallPackages(pkgs: MutableList<String>) = pkgs.forEach {
mDevicePolicyManager.setUninstallBlocked(mComponent, it, false)
}
}
\ No newline at end of file
......@@ -7,8 +7,11 @@ import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.util.Log
import com.secspace.lib.common.dpm.DpmManager
import com.secspace.lib.common.utils.*
import com.secspace.lib.common.utils.Package.ComponentNames
import com.secspace.lib.common.utils.PkgManager
import com.secspace.lib.common.utils.Prefs
import com.secspace.lib.common.utils.ReflectAmsUtil
import com.secspace.lib.common.utils.hiddenPkgIcon
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.util.*
......@@ -18,7 +21,6 @@ class SwitchInMdm constructor(var context: Context) : ISwitch() {
public override suspend fun init() {
Prefs.setInSpace(context, true)
setDefaultLauncher()
DpmManager.instance.applicationManager.let {
it.addDisabledDeactivateMdmPackages(getPersistentList(context))
it.addDisallowedUninstallPackages(getPersistentList(context))
......@@ -90,7 +92,7 @@ class SwitchInMdm constructor(var context: Context) : ISwitch() {
continue
}
Log.e(TAG, "clearProcesses:$packageName")
DpmManager.instance.applicationManager.killApplicationProcess(packageName)
PkgManager.getInstance(context).foceStopApp(packageName)
}
}
......@@ -101,11 +103,15 @@ class SwitchInMdm constructor(var context: Context) : ISwitch() {
val apps = packageManager?.queryIntentActivities(mainIntent, 0)
for (i in apps?.indices!!) {
val name = apps[i].activityInfo.packageName
val applicationInfo = packageManager.getApplicationInfo(name, 0)
Log.i(TAG, "killBackgroundApplication: $name")
if (getPersistentList(context).contains(name)) {
continue
}
PkgManager.getInstance(context).foceStopApp(name)
if(applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0){
continue
}
DpmManager.instance.applicationManager.killApplicationProcess(name)
}
}
......
......@@ -2,6 +2,8 @@ package com.secspace.lib.common.function
import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.util.Log
import com.secspace.lib.common.dpm.DpmManager
......@@ -35,39 +37,43 @@ class SwitchOutMdm constructor(var context: Context) : ISwitch() {
it.setAdbDisabled(false)
it.setUSBOtgDisabled(false)
it.setUSBDataDisabled(false)
it.setExternalStorageDisabled(false)
it.setStatusBarExpandPanelDisabled(false)
it.setSystemUpdateDisabled(false)
}
DpmManager.instance.settingsManager.setRestoreFactoryDisabled(false)
}
private fun clearProcesses() {
val packageManager: PackageManager = context.packageManager
val mainIntent = Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER)
val resolveInfos: List<ResolveInfo> = context.packageManager.queryIntentActivities(mainIntent, 0)
val resolveInfos: List<ResolveInfo> = packageManager.queryIntentActivities(mainIntent, 0)
for (resolveInfo in resolveInfos) {
val packageName = resolveInfo.activityInfo.packageName
if (getPersistentList(context).contains(packageName)) {
continue
}
Log.e(TAG, "clearProcesses:$packageName")
DpmManager.instance.applicationManager.killApplicationProcess(packageName)
PkgManager.getInstance(context).foceStopApp(packageName)
}
}
private fun killBackgroundApplication() {
val packageManager: PackageManager = context.packageManager
val mainIntent = Intent(Intent.ACTION_MAIN, null)
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER)
val apps = context.packageManager.queryIntentActivities(mainIntent, 0)
val apps = packageManager.queryIntentActivities(mainIntent, 0)
for (i in apps?.indices!!) {
val name = apps[i].activityInfo.packageName
val applicationInfo = packageManager.getApplicationInfo(name, 0)
Log.i(TAG, "killBackgroundApplication: $name")
if (getPersistentList(context).contains(name)) {
continue
}
PkgManager.getInstance(context).foceStopApp(name)
if(applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0){
continue
}
DpmManager.instance.applicationManager.killApplicationProcess(name)
}
}
......
......@@ -8,6 +8,7 @@ import android.os.Handler
import android.os.Looper
import android.os.SystemClock
import com.secspace.lib.common.R
import com.secspace.lib.common.dialog.LoadingDialog
import com.secspace.lib.common.dpm.DpmManager
import com.secspace.lib.common.env.SEnvironment
import com.secspace.lib.common.function.ActivationHelper.ActivationListener
......@@ -39,13 +40,15 @@ class WorkManager private constructor(var context: Context) {
}
GlobalScope.launch(Dispatchers.IO) {
launcher.openAccessibility()
runOnMain { LoadingDialog.getInstance(context).show("切换中") }
// launcher.openAccessibility()
SwitchInMdm.getInstance(context).init()
activate(launcher)
withContext(Dispatchers.Main) {
runOnMain {
if (Prefs.isTips(launcher)) {
DialogManager.showMessageDialogOnlySure(launcher, launcher.getString(R.string.common_remind), launcher.getString(R.string.edu_item_first_install_tips), null)
Prefs.setTips(launcher, false)
LoadingDialog.getInstance(context).dismiss()
}
}
checkLocalUpdateFile() //检查本地更新文件
......
......@@ -46,7 +46,7 @@ public class Package {
public static ComponentName COMPONENT_STARTUP_SETTINGS = new ComponentName("com.android.settings", "com.android.settings.HWSettings");
public static ComponentName COMPONENT_NAME_HW_HWOUC = new ComponentName("com.huawei.android.hwouc", "com.huawei.android.hwouc.ui.activities.MainEntranceActivity");//软件更新
public static ComponentName COMPONENT_HUAWEI_LUANCHER = new ComponentName("com.huawei.android.launcher", "com.huawei.android.launcher.unihome.UniHomeLauncher");
public static ComponentName COMPONENT_ENTERPRISE_PRIVACY_SETTING = new ComponentName("com.android.settings", "com.android.settings.Settings$COMPONENT_ENTERPRISE_PRIVACY_SETTING");
public static ComponentName COMPONENT_ENTERPRISE_PRIVACY_SETTING = new ComponentName("com.android.settings", "com.android.settings.Settings$EnterprisePrivacySettingsActivity");
}
}
......@@ -13,7 +13,9 @@ object UninstallUtil {
it.setStatusBarExpandPanelDisabled(false)
it.setSystemUpdateDisabled(false)
}
DpmManager.instance.hwSystemManager.let {
it.removeSuperWhiteListForHwSystemManger(it.getSuperWhiteListForHwSystemManger())
}
DpmManager.instance.applicationManager.let {
it.enableComponent(context, COMPONENT_HUAWEI_LUANCHER)
it.removeDisabledDeactivateMdmPackages(it.getDisabledDeactivateMdmPackageList())
......
......@@ -11,8 +11,7 @@ import android.util.Base64
import com.secspace.lib.common.function.service.EduAccessibilityService
import com.skr.activation.utils.DesUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.FileWriter
......@@ -122,4 +121,16 @@ fun Long.formatDateTime(): String = this.let {
stringTimes
}
fun hiddenPkgIcon(ctx: Context?) = Settings.Global.putInt(ctx?.contentResolver, "show_hidden_icon_apps_enabled", 0)
\ No newline at end of file
fun hiddenPkgIcon(ctx: Context?) = Settings.Global.putInt(ctx?.contentResolver, "show_hidden_icon_apps_enabled", 0)
suspend inline fun runOnMain(crossinline block: () -> Unit) {
withContext(Dispatchers.Main){
block()
}
}
suspend inline fun runOnIO(crossinline block: () -> Unit) {
withContext(Dispatchers.IO){
block()
}
}
\ No newline at end of file
......@@ -109,6 +109,7 @@ public static java.lang.String TABLENAME;
public <init>();
}
-keep class com.huawei.android.app.** {*;}
-keep class com.secspace.lib.common.dpm.** {*;}
# 如果不使用android.support.annotation.Keep则需加上此行
# -keep class com.my.pkg.SophixStubApplication$RealApplicationStub
#以上sophix热修复
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment