Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MobileManager
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wang Xu
MobileManager
Commits
b907eb49
Commit
b907eb49
authored
Mar 17, 2020
by
Baoxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: 修复bug
parent
02fd4a46
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1255 additions
and
522 deletions
+1255
-522
AndroidManifest-common.xml
Launcher3/AndroidManifest-common.xml
+1
-1
AndroidManifest.xml
Launcher3/AndroidManifest.xml
+3
-1
build.gradle
Launcher3/build.gradle
+3
-0
bg.jpg
Launcher3/res/drawable/bg.jpg
+0
-0
activity_setting.xml
Launcher3/res/layout/activity_setting.xml
+11
-1
strings.xml
Launcher3/res/values/strings.xml
+6
-0
App.java
Launcher3/src/com/android/launcher3/App.java
+13
-0
Launcher.java
Launcher3/src/com/android/launcher3/Launcher.java
+35
-183
MdmUtils.java
Launcher3/src/com/android/launcher3/mdm/MdmUtils.java
+12
-0
SettingActivity.java
...3/src/com/android/launcher3/settings/SettingActivity.java
+0
-285
SettingActivity.kt
...er3/src/com/android/launcher3/settings/SettingActivity.kt
+249
-0
MCS_SVN_1515.apk
assetsprovider/src/main/assets/MCS_SVN_1515.apk
+0
-0
Mdm_Service.apk
assetsprovider/src/main/assets/Mdm_Service.apk
+0
-0
NumasPad_v1.8.6.apk
assetsprovider/src/main/assets/NumasPad_v1.8.6.apk
+0
-0
toolV4.apk
assetsprovider/src/main/assets/toolV4.apk
+0
-0
gradle.properties
gradle.properties
+2
-2
build.gradle
lib_common/build.gradle
+5
-1
AndroidManifest.xml
lib_common/src/main/AndroidManifest.xml
+4
-1
InitEvent.java
...rc/main/java/com/secspace/lib/common/event/InitEvent.java
+14
-0
DialogManager.java
.../java/com/secspace/lib/common/function/DialogManager.java
+124
-0
DpmOwnerHelper.kt
...n/java/com/secspace/lib/common/function/DpmOwnerHelper.kt
+130
-0
SwitchInMdm.kt
...main/java/com/secspace/lib/common/function/SwitchInMdm.kt
+134
-0
WorkManager.kt
...main/java/com/secspace/lib/common/function/WorkManager.kt
+165
-0
CheckUpdateCore.java
.../java/com/secspace/lib/common/update/CheckUpdateCore.java
+1
-1
DisableCompat.java
...ain/java/com/secspace/lib/common/utils/DisableCompat.java
+53
-0
DpmHelper.java
...rc/main/java/com/secspace/lib/common/utils/DpmHelper.java
+1
-2
FileUtil.java
...src/main/java/com/secspace/lib/common/utils/FileUtil.java
+157
-19
IntentUtil.java
...c/main/java/com/secspace/lib/common/utils/IntentUtil.java
+4
-19
MdmUtils.java
...src/main/java/com/secspace/lib/common/utils/MdmUtils.java
+71
-0
Package.java
.../src/main/java/com/secspace/lib/common/utils/Package.java
+3
-3
Prefs.java
...on/src/main/java/com/secspace/lib/common/utils/Prefs.java
+23
-0
String2ListHelper.java
...java/com/secspace/lib/common/utils/String2ListHelper.java
+24
-0
strings.xml
lib_common/src/main/res/values/strings.xml
+7
-3
No files found.
Launcher3/AndroidManifest-common.xml
View file @
b907eb49
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
></uses-permission>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
></uses-permission>
<uses-permission
android:name=
"middleware.permission.MDM"
/>
<application
<application
android:persistent=
"true"
android:persistent=
"true"
android:backupAgent=
"com.android.launcher3.LauncherBackupAgent"
android:backupAgent=
"com.android.launcher3.LauncherBackupAgent"
...
...
Launcher3/AndroidManifest.xml
View file @
b907eb49
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
<uses-permission
android:name=
"com.android.launcher.permission.WRITE_SETTINGS"
/>
<uses-permission
android:name=
"com.android.launcher.permission.WRITE_SETTINGS"
/>
<uses-permission
android:name=
"com.android.launcher3.permission.READ_SETTINGS"
/>
<uses-permission
android:name=
"com.android.launcher3.permission.READ_SETTINGS"
/>
<uses-permission
android:name=
"com.android.launcher3.permission.WRITE_SETTINGS"
/>
<uses-permission
android:name=
"com.android.launcher3.permission.WRITE_SETTINGS"
/>
<uses-permission
android:name=
"middleware.permission.MDM"
/>
<application
<application
android:name=
".App"
android:name=
".App"
...
@@ -94,7 +95,8 @@
...
@@ -94,7 +95,8 @@
android:screenOrientation=
"sensor"
android:screenOrientation=
"sensor"
android:stateNotNeeded=
"true"
android:stateNotNeeded=
"true"
android:taskAffinity=
""
android:taskAffinity=
""
android:windowSoftInputMode=
"adjustPan|stateUnchanged"
>
android:windowSoftInputMode=
"adjustPan|stateUnchanged"
android:theme=
"@style/Theme.AppCompat"
>
<intent-filter>
<intent-filter>
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
...
...
Launcher3/build.gradle
View file @
b907eb49
...
@@ -130,6 +130,9 @@ dependencies {
...
@@ -130,6 +130,9 @@ dependencies {
api
project
(
path:
':lib_common'
)
api
project
(
path:
':lib_common'
)
implementation
files
(
'libs/activation.aar'
)
implementation
files
(
'libs/activation.aar'
)
implementation
files
(
'libs/update-excludePush-release.aar'
)
implementation
files
(
'libs/update-excludePush-release.aar'
)
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
}
...
...
Launcher3/res/drawable/bg.jpg
0 → 100644
View file @
b907eb49
1.94 MB
Launcher3/res/layout/activity_setting.xml
View file @
b907eb49
...
@@ -39,6 +39,16 @@
...
@@ -39,6 +39,16 @@
android:textColor=
"#000"
/>
android:textColor=
"#000"
/>
<Button
<Button
android:id=
"@+id/btn_reinforce"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"20dp"
android:layout_marginTop=
"10dp"
android:layout_marginRight=
"20dp"
android:text=
"加固桌面"
android:textColor=
"#000"
/>
<Button
android:id=
"@+id/btn_change_wallpaper"
android:id=
"@+id/btn_change_wallpaper"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
@@ -100,7 +110,7 @@
...
@@ -100,7 +110,7 @@
android:layout_marginLeft=
"20dp"
android:layout_marginLeft=
"20dp"
android:layout_marginTop=
"10dp"
android:layout_marginTop=
"10dp"
android:layout_marginRight=
"20dp"
android:layout_marginRight=
"20dp"
android:text=
"
允许新应用
添加"
android:text=
"
新安装应用自动
添加"
android:textColor=
"#000"
/>
android:textColor=
"#000"
/>
<Button
<Button
...
...
Launcher3/res/values/strings.xml
View file @
b907eb49
...
@@ -318,4 +318,10 @@
...
@@ -318,4 +318,10 @@
<string
name=
"set_auto_start_tip"
>
是否将学习空间设为自启状态
</string>
<string
name=
"set_auto_start_tip"
>
是否将学习空间设为自启状态
</string>
<string
name=
"not_user_prmission"
>
当前设备无权限使用,请联系管理员
</string>
<string
name=
"not_user_prmission"
>
当前设备无权限使用,请联系管理员
</string>
<string
name=
"work_sure"
>
sure
</string>
<string
name=
"work_sure"
>
sure
</string>
<string
name=
"edu_version"
>
V%1$s
</string>
<string
name=
"edu_check_update"
>
正在检测更新,请稍后
</string>
<string
name=
"edu_uninstall"
>
正在卸载中,请稍后
</string>
<string
name=
"edu_reinforce"
>
因部分系统版本自身原因,从学习空间内设置回到空间主页时,可能会出现提示设置默认桌面的问题,可在此处确认进行加固处理
</string>
<string
name=
"edu_uninstall_tip"
>
继续操作将卸载学习空间,请确认是否继续
</string>
</resources>
</resources>
Launcher3/src/com/android/launcher3/App.java
View file @
b907eb49
...
@@ -4,11 +4,20 @@ import android.app.Application;
...
@@ -4,11 +4,20 @@ import android.app.Application;
import
android.content.Context
;
import
android.content.Context
;
import
com.secspace.lib.common.update.CheckUpdateCore
;
import
com.secspace.lib.common.update.CheckUpdateCore
;
import
com.secspace.lib.common.utils.DpmHelper
;
import
com.secspace.lib.common.utils.ImeiUtil
;
import
com.secspace.lib.common.utils.ImeiUtil
;
import
com.secspace.lib.common.utils.PkgManager
;
import
com.secspace.lib.common.utils.PkgManager
;
import
com.secspace.mdmengine.api.annotation.WhichFactory
;
import
com.secspace.mdmengine.api.manager.IMiddleWareManager
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
com.skr.activation.api.ActivationApi
;
import
com.skr.activation.api.ActivationApi
;
import
com.skr.update.AppUpdateManager
;
import
com.skr.update.AppUpdateManager
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_MDMENHANCE
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_MDMTEST
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_UNINSTALL_TOOL
;
public
class
App
extends
Application
{
public
class
App
extends
Application
{
private
Context
mApp
;
private
Context
mApp
;
...
@@ -31,5 +40,9 @@ public class App extends Application {
...
@@ -31,5 +40,9 @@ public class App extends Application {
}
}
}
}
});
});
DpmHelper
dpmHelper
=
DpmHelper
.
getInstance
(
mApp
);
if
(
dpmHelper
.
isMiddlewareLatest
())
{
dpmHelper
.
initMiddleWare
();
}
}
}
}
}
Launcher3/src/com/android/launcher3/Launcher.java
View file @
b907eb49
...
@@ -22,7 +22,6 @@ import android.animation.AnimatorSet;
...
@@ -22,7 +22,6 @@ import android.animation.AnimatorSet;
import
android.animation.ValueAnimator
;
import
android.animation.ValueAnimator
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
android.annotation.TargetApi
;
import
android.app.ActivityManager
;
import
android.app.ActivityOptions
;
import
android.app.ActivityOptions
;
import
android.app.AlertDialog
;
import
android.app.AlertDialog
;
import
android.app.SearchManager
;
import
android.app.SearchManager
;
...
@@ -41,9 +40,7 @@ import android.content.IntentSender;
...
@@ -41,9 +40,7 @@ import android.content.IntentSender;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
;
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
;
import
android.content.pm.ActivityInfo
;
import
android.content.pm.ActivityInfo
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.BitmapFactory
;
...
@@ -51,8 +48,8 @@ import android.graphics.Point;
...
@@ -51,8 +48,8 @@ import android.graphics.Point;
import
android.graphics.Rect
;
import
android.graphics.Rect
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.net.wifi.WifiManager
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.net.wifi.WifiManager
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -70,7 +67,6 @@ import android.text.TextUtils;
...
@@ -70,7 +67,6 @@ import android.text.TextUtils;
import
android.text.method.TextKeyListener
;
import
android.text.method.TextKeyListener
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.Display
;
import
android.view.Gravity
;
import
android.view.HapticFeedbackConstants
;
import
android.view.HapticFeedbackConstants
;
import
android.view.KeyEvent
;
import
android.view.KeyEvent
;
import
android.view.KeyboardShortcutGroup
;
import
android.view.KeyboardShortcutGroup
;
...
@@ -117,7 +113,6 @@ import com.android.launcher3.keyboard.CustomActionsPopup;
...
@@ -117,7 +113,6 @@ import com.android.launcher3.keyboard.CustomActionsPopup;
import
com.android.launcher3.keyboard.ViewGroupFocusHelper
;
import
com.android.launcher3.keyboard.ViewGroupFocusHelper
;
import
com.android.launcher3.logging.FileLog
;
import
com.android.launcher3.logging.FileLog
;
import
com.android.launcher3.logging.UserEventDispatcher
;
import
com.android.launcher3.logging.UserEventDispatcher
;
import
com.android.launcher3.mdm.DisableCompat
;
import
com.android.launcher3.mdm.DpmOwnerHelper
;
import
com.android.launcher3.mdm.DpmOwnerHelper
;
import
com.android.launcher3.mdm.MdmUtils
;
import
com.android.launcher3.mdm.MdmUtils
;
import
com.android.launcher3.model.ModelWriter
;
import
com.android.launcher3.model.ModelWriter
;
...
@@ -127,15 +122,12 @@ import com.android.launcher3.notification.NotificationListener;
...
@@ -127,15 +122,12 @@ import com.android.launcher3.notification.NotificationListener;
import
com.android.launcher3.pageindicators.PageIndicator
;
import
com.android.launcher3.pageindicators.PageIndicator
;
import
com.android.launcher3.popup.PopupContainerWithArrow
;
import
com.android.launcher3.popup.PopupContainerWithArrow
;
import
com.android.launcher3.popup.PopupDataProvider
;
import
com.android.launcher3.popup.PopupDataProvider
;
import
com.android.launcher3.settings.AppChooseActivity
;
import
com.android.launcher3.settings.AppInstallReceiver
;
import
com.android.launcher3.settings.AppInstallReceiver
;
import
com.android.launcher3.settings.ErrorTimeHelper
;
import
com.android.launcher3.settings.ErrorTimeHelper
;
import
com.android.launcher3.settings.String2ListHelper
;
import
com.android.launcher3.settings.String2ListHelper
;
import
com.android.launcher3.settings.VerifyPwdProtectionActivity
;
import
com.android.launcher3.settings.wifi.NetworkConnectChangedReceiver
;
import
com.android.launcher3.settings.wifi.NetworkConnectChangedReceiver
;
import
com.android.launcher3.settings.wifi.WifiInfoBean
;
import
com.android.launcher3.settings.wifi.WifiInfoBean
;
import
com.android.launcher3.settings.wifi.WifiManagerUtils
;
import
com.android.launcher3.settings.wifi.WifiManagerUtils
;
import
com.android.launcher3.settings.wifi.WifiScanService
;
import
com.android.launcher3.shortcuts.DeepShortcutManager
;
import
com.android.launcher3.shortcuts.DeepShortcutManager
;
import
com.android.launcher3.shortcuts.ShortcutKey
;
import
com.android.launcher3.shortcuts.ShortcutKey
;
import
com.android.launcher3.userevent.nano.LauncherLogProto
;
import
com.android.launcher3.userevent.nano.LauncherLogProto
;
...
@@ -161,18 +153,18 @@ import com.google.gson.Gson;
...
@@ -161,18 +153,18 @@ import com.google.gson.Gson;
import
com.secspace.lib.common.dialog.SwitcherDialog
;
import
com.secspace.lib.common.dialog.SwitcherDialog
;
import
com.secspace.lib.common.env.Packages
;
import
com.secspace.lib.common.env.Packages
;
import
com.secspace.lib.common.event.ChangeWallPaperEvent
;
import
com.secspace.lib.common.event.ChangeWallPaperEvent
;
import
com.secspace.lib.common.event.InitEvent
;
import
com.secspace.lib.common.event.RefreshWorkSpaceEvent
;
import
com.secspace.lib.common.event.RefreshWorkSpaceEvent
;
import
com.secspace.lib.common.function.WorkManager
;
import
com.secspace.lib.common.utils.ActivityHelper
;
import
com.secspace.lib.common.utils.ActivityHelper
;
import
com.secspace.lib.common.utils.DeviceUtil
;
import
com.secspace.lib.common.utils.DeviceUtil
;
import
com.secspace.lib.common.utils.DpmHelper
;
import
com.secspace.lib.common.utils.DpmHelper
;
import
com.secspace.lib.common.utils.FileUtil
;
import
com.secspace.lib.common.utils.FileUtil
;
import
com.secspace.lib.common.utils.ImeiCheckUtils
;
import
com.secspace.lib.common.utils.ImeiCheckUtils
;
import
com.secspace.lib.common.utils.ImeiUtil
;
import
com.secspace.lib.common.utils.InputUtil
;
import
com.secspace.lib.common.utils.InputUtil
;
import
com.secspace.lib.common.utils.IntentUtil
;
import
com.secspace.lib.common.utils.IntentUtil
;
import
com.secspace.lib.common.utils.Prefs
;
import
com.secspace.lib.common.utils.Prefs
;
import
com.secspace.lib.common.utils.ToastUtil
;
import
com.secspace.lib.common.utils.ToastUtil
;
import
com.secspace.mdmengine.api.manager.IDeviceApplicationManager
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
com.skr.activation.api.ActivationApi
;
import
com.skr.activation.api.ActivationApi
;
import
com.skr.activation.network.linstener.CheckLocalActiveStatusListener
;
import
com.skr.activation.network.linstener.CheckLocalActiveStatusListener
;
...
@@ -191,9 +183,6 @@ import java.util.HashSet;
...
@@ -191,9 +183,6 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
static
com
.
android
.
launcher3
.
settings
.
Contants
.
FROM_WHERE
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
;
/**
/**
* Default launcher application.
* Default launcher application.
*/
*/
...
@@ -414,7 +403,6 @@ public class Launcher extends BaseActivity
...
@@ -414,7 +403,6 @@ public class Launcher extends BaseActivity
private
RotationPrefChangeHandler
mRotationPrefChangeHandler
;
private
RotationPrefChangeHandler
mRotationPrefChangeHandler
;
private
String
mWallpaperPath
;
private
String
mWallpaperPath
;
ComponentName
componentName8
=
new
ComponentName
(
"com.huawei.android.hwouc"
,
"com.huawei.android.hwouc.ui.activities.MainEntranceActivity"
);
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -432,11 +420,15 @@ public class Launcher extends BaseActivity
...
@@ -432,11 +420,15 @@ public class Launcher extends BaseActivity
.
penaltyDeath
()
.
penaltyDeath
()
.
build
());
.
build
());
}
}
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
)){
EventBus
.
getDefault
().
register
(
this
);
}
if
(
Prefs
.
isFirstInit
(
this
))
{
if
(
Prefs
.
isFirstInit
(
this
))
{
String
pgks
=
getPackageName
();
String
pgks
=
getPackageName
();
String
systemPkgs
=
""
;
String
systemPkgs
=
""
;
Prefs
.
setUserShowAppPkgs
(
this
,
pgks
);
Prefs
.
setUserShowAppPkgs
(
this
,
pgks
);
Prefs
.
setSystemShowAppPkgs
(
this
,
systemPkgs
);
Prefs
.
setSystemShowAppPkgs
(
this
,
systemPkgs
);
Prefs
.
setIsFirstInit
(
this
,
false
);
}
}
mWallpaperPath
=
getFilesDir
().
getAbsolutePath
()
+
File
.
separator
+
WALLPAPER_NAME
;
mWallpaperPath
=
getFilesDir
().
getAbsolutePath
()
+
File
.
separator
+
WALLPAPER_NAME
;
Log
.
i
(
TAG
,
"onCreate: "
);
Log
.
i
(
TAG
,
"onCreate: "
);
...
@@ -449,7 +441,7 @@ public class Launcher extends BaseActivity
...
@@ -449,7 +441,7 @@ public class Launcher extends BaseActivity
}
}
mWifiManager
=
(
WifiManager
)
getApplicationContext
().
getSystemService
(
Context
.
WIFI_SERVICE
);
mWifiManager
=
(
WifiManager
)
getApplicationContext
().
getSystemService
(
Context
.
WIFI_SERVICE
);
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
ImeiCheckUtils
.
getInstance
(
this
).
initImeiList
();
//
ImeiCheckUtils.getInstance(this).initImeiList();
LauncherAppState
app
=
LauncherAppState
.
getInstance
(
this
);
LauncherAppState
app
=
LauncherAppState
.
getInstance
(
this
);
// Load configuration-specific DeviceProfile
// Load configuration-specific DeviceProfile
...
@@ -546,22 +538,20 @@ public class Launcher extends BaseActivity
...
@@ -546,22 +538,20 @@ public class Launcher extends BaseActivity
mLauncherCallbacks
.
onCreate
(
savedInstanceState
);
mLauncherCallbacks
.
onCreate
(
savedInstanceState
);
}
}
mHandler
=
new
Handler
();
mHandler
=
new
Handler
();
EventBus
.
getDefault
().
register
(
this
);
if
(
mWallpaperPath
!=
null
)
{
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
mLauncherView
.
setBackground
(
new
BitmapDrawable
(
bitmap
));
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
}
Log
.
e
(
"TAG1"
,
"onCreate: "
+
getIntent
().
getAction
());
// Bitmap bitmap = BitmapFactory.decodeFile(mWallpaperPath);
Drawable
drawable
=
getDrawable
(
R
.
drawable
.
bg
);
mLauncherView
.
setBackground
(
drawable
);
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
.
setBackground
(
drawable
);
if
(
ACTION_CHANGE_WALLPAPER
.
equals
(
getIntent
().
getAction
()))
{
if
(
ACTION_CHANGE_WALLPAPER
.
equals
(
getIntent
().
getAction
()))
{
Uri
selectedImage
=
getIntent
().
getParcelableExtra
(
"uri"
);
Uri
selectedImage
=
getIntent
().
getParcelableExtra
(
"uri"
);
String
path
=
FileUtil
.
getPath
(
this
,
selectedImage
);
String
path
=
FileUtil
.
getPath
(
this
,
selectedImage
);
FileUtil
.
copyFile
(
this
,
path
,
WALLPAPER_NAME
);
FileUtil
.
copyFile
(
path
,
WALLPAPER_NAME
);
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
}
}
registerNetworkReceiver
();
registerNetworkReceiver
();
...
@@ -1213,7 +1203,6 @@ public class Launcher extends BaseActivity
...
@@ -1213,7 +1203,6 @@ public class Launcher extends BaseActivity
if
(
mLauncherCallbacks
!=
null
)
{
if
(
mLauncherCallbacks
!=
null
)
{
mLauncherCallbacks
.
onResume
();
mLauncherCallbacks
.
onResume
();
}
}
// activationNext();
ActivationApi
.
getInstance
().
isActiveFromLocalAndNet
(
getPackageName
(),
new
CheckLocalActiveStatusListener
()
{
ActivationApi
.
getInstance
().
isActiveFromLocalAndNet
(
getPackageName
(),
new
CheckLocalActiveStatusListener
()
{
@Override
@Override
public
void
hasActivated
()
{
public
void
hasActivated
()
{
...
@@ -1235,60 +1224,33 @@ public class Launcher extends BaseActivity
...
@@ -1235,60 +1224,33 @@ public class Launcher extends BaseActivity
}
}
private
void
activationNext
()
{
private
void
activationNext
()
{
if
(!
DpmHelper
.
getInstance
(
this
).
isMiddlewareInstalled
())
{
DpmHelper
.
getInstance
(
this
).
installMiddleWare
();
// if (!DpmHelper.getInstance(this).isMiddlewareInstalled()) {
return
;
// DpmHelper.getInstance(this).installMiddleWare();
}
// return;
DpmHelper
.
getInstance
(
this
).
initMiddleWare
();
// }
if
(!
DpmHelper
.
getInstance
(
this
).
isMiddlewareDPMActived
())
{
// DpmHelper.getInstance(this).initMiddleWare();
DpmHelper
.
getInstance
(
this
).
toActivateMiddlewareDpm
();
// if (!DpmHelper.getInstance(this).isMiddlewareDPMActived()) {
}
// DpmHelper.getInstance(this).toActivateMiddlewareDpm();
// }
String
pwd
=
Prefs
.
getLoginPwd
(
this
);
String
pwd
=
Prefs
.
getLoginPwd
(
this
);
if
(
TextUtils
.
isEmpty
(
pwd
))
{
if
(
TextUtils
.
isEmpty
(
pwd
))
{
Intent
intent
=
new
Intent
(
this
,
PwdPinSetPwdActivity
.
class
);
Intent
intent
=
new
Intent
(
this
,
PwdPinSetPwdActivity
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
return
;
return
;
}
}
MdmFactoryManager
mdmFactoryManager
=
DpmHelper
.
getInstance
(
this
).
getmMdmFactoryManager
();
mdmFactoryManager
.
getDeviceSettingsManager
().
setRestoreFactoryDisabled
(
true
);
mdmFactoryManager
.
getDeviceApplicationManager
().
addDisabledDeactivateMdmPackages
(
getPersistentList
());
mdmFactoryManager
.
getDeviceApplicationManager
().
addDisallowedUninstallPackages
(
getPersistentList
());
mdmFactoryManager
.
getDeviceRestrictionManager
().
setDeviceOwnerApp
(
"DeviceOwner"
);
mdmFactoryManager
.
getDeviceApplicationManager
().
addPersistentApp
(
getPersistentList
());
ArrayList
<
String
>
arrayList
=
new
ArrayList
<>();
arrayList
.
add
(
this
.
getPackageName
());
mdmFactoryManager
.
getDeviceSettingsManager
().
setSuperWhiteListForHwSystemManger
(
arrayList
);
mdmFactoryManager
.
getDeviceRestrictionManager
().
turnOnGPS
(
true
);
mdmFactoryManager
.
getDeviceSettingsManager
().
setSystemUpdateDisabled
(
true
);
DisableCompat
.
disableComponent
(
this
,
componentName8
);
//检查中间件是否是deviceOwner
checkDeviceOwner
();
//检查是否是第一次初始化
isFirstInit
();
isCoverInstall
();
startWifiScanService
();
setAutoStartLauncher
();
MdmFactoryManager
.
getInstance
().
getDeviceApplicationManager
().
setApplicationEnabledSetting
(
"com.huawei.powergenie"
,
PackageManager
.
COMPONENT_ENABLED_STATE_DISABLED
,
1
);
// MdmFactoryManager.getInstance().getDeviceApplicationManager().setApplicationEnabledSetting("com.huawei.powergenie",PackageManager.COMPONENT_ENABLED_STATE_ENABLED,1);
//重新loading一下应用 为了过滤应用
Log
.
i
(
TAG
,
"launcher onresume: "
);
LauncherAppState
app
=
LauncherAppState
.
getInstanceNoCreate
();
LauncherAppState
app
=
LauncherAppState
.
getInstanceNoCreate
();
if
(
app
!=
null
)
{
if
(
app
!=
null
)
{
app
.
getModel
().
forceReload
();
app
.
getModel
().
forceReload
();
}
}
}
WorkManager
.
INSTANCE
.
enter
(
this
);
private
void
isCoverInstall
()
{
// //检查中间件是否是deviceOwner
if
(
Prefs
.
isCoverSecondInstall
(
this
))
{
// checkDeviceOwner();
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setAdbDisabled
(
false
);
// MdmFactoryManager.getInstance().getDeviceApplicationManager().setApplicationEnabledSetting("com.huawei.powergenie", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 1);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setUSBOtgDisabled
(
false
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setUSBDataDisabled
(
false
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setExternalStorageDisabled
(
false
);
initDefaultPkgsList
();
Prefs
.
setCoverSecondInstall
(
this
,
false
);
}
}
}
private
void
initWifiList
()
{
private
void
initWifiList
()
{
List
<
WifiInfoBean
>
wifiInfoBeans
=
new
ArrayList
<>();
List
<
WifiInfoBean
>
wifiInfoBeans
=
new
ArrayList
<>();
WifiInfoBean
wifiInfoBean
=
new
WifiInfoBean
();
WifiInfoBean
wifiInfoBean
=
new
WifiInfoBean
();
...
@@ -1337,83 +1299,9 @@ public class Launcher extends BaseActivity
...
@@ -1337,83 +1299,9 @@ public class Launcher extends BaseActivity
return
false
;
return
false
;
}
}
public
void
clearProcesses
()
{
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
,
sticky
=
true
)
IDeviceApplicationManager
dam
=
MdmFactoryManager
.
getInstance
().
getDeviceApplicationManager
();
private
void
isFirstInit
(
InitEvent
initEvent
)
{
//clear task
Log
.
e
(
"TAG"
,
"post: isFirstInit"
);
List
<
ActivityManager
.
RunningTaskInfo
>
runningTasks
=
dam
.
getRunningTasks
(
1000
);
if
(
runningTasks
!=
null
)
{
for
(
ActivityManager
.
RunningTaskInfo
task
:
runningTasks
)
{
String
pkg
=
task
.
baseActivity
.
getPackageName
();
if
(
pkg
.
equals
(
this
.
getPackageName
())
||
pkg
.
equals
(
PACKAGENAME_MIDDLEWARE
)
||
pkg
.
equals
(
"com.android.systemui"
))
{
continue
;
}
dam
.
removeTask
(
task
.
id
);
Log
.
d
(
TAG
,
"remove task "
+
task
.
baseActivity
.
getPackageName
());
}
}
//clear processes
List
<
ActivityManager
.
RunningAppProcessInfo
>
runningAppProcesses
=
dam
.
getRunningAppProcesses
();
List
<
String
>
packages
=
getAllPackages
(
PackageManager
.
MATCH_UNINSTALLED_PACKAGES
);
if
(
runningAppProcesses
!=
null
)
{
for
(
ActivityManager
.
RunningAppProcessInfo
processInfo
:
runningAppProcesses
)
{
String
processName
=
processInfo
.
processName
;
if
(!
packages
.
contains
(
processName
))
{
continue
;
}
String
packageName
=
processName
;
if
(
packageName
.
equals
(
PACKAGENAME_MIDDLEWARE
)
||
this
.
getPackageName
().
equals
(
packageName
)
||
packageName
.
equals
(
"com.huawei.powergenie"
))
{
continue
;
}
dam
.
killApplicationProcess
(
packageName
);
dam
.
forceStopPackage
(
packageName
);
Log
.
d
(
TAG
,
"kill "
+
packageName
);
}
}
}
public
List
<
String
>
getAllPackages
(
int
flags
)
{
List
<
PackageInfo
>
packageInfos
=
getAllPackageInfo
(
flags
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
packageInfos
.
size
();
i
++)
{
list
.
add
(
packageInfos
.
get
(
i
).
packageName
);
}
return
list
;
}
public
List
<
PackageInfo
>
getAllPackageInfo
(
int
flags
)
{
List
<
PackageInfo
>
mInstalledPackageInfoList
=
getPackageManager
().
getInstalledPackages
(
flags
);
return
mInstalledPackageInfoList
;
}
private
void
killBackgroundApplication
()
{
final
PackageManager
packageManager
=
this
.
getPackageManager
();
final
Intent
mainIntent
=
new
Intent
(
Intent
.
ACTION_MAIN
,
null
);
mainIntent
.
addCategory
(
Intent
.
CATEGORY_LAUNCHER
);
final
List
<
ResolveInfo
>
apps
=
packageManager
.
queryIntentActivities
(
mainIntent
,
0
);
for
(
int
i
=
0
;
i
<
apps
.
size
();
i
++)
{
String
name
=
apps
.
get
(
i
).
activityInfo
.
packageName
;
Log
.
i
(
TAG
,
"killBackgroundApplication: "
+
name
);
if
(
name
.
contains
(
this
.
getPackageName
())
||
name
.
equals
(
PACKAGENAME_MIDDLEWARE
))
{
continue
;
}
MdmFactoryManager
.
getInstance
().
getDeviceApplicationManager
().
forceStopPackage
(
name
);
}
}
private
void
setAutoStartLauncher
()
{
if
(
Prefs
.
isAutoStartSelf
(
this
))
{
MdmUtils
.
setDefaultLauncher
(
this
);
}
else
{
MdmUtils
.
clearDefaultLauncher
(
this
);
}
}
private
void
isFirstInit
()
{
if
(
Prefs
.
isFirstInit
(
this
))
{
if
(
Prefs
.
isFirstInit
(
this
))
{
showPwdDialog
(
getString
(
R
.
string
.
launcher_setting_tip
),
getString
(
R
.
string
.
ok
),
null
,
new
DialogInterface
.
OnClickListener
()
{
showPwdDialog
(
getString
(
R
.
string
.
launcher_setting_tip
),
getString
(
R
.
string
.
ok
),
null
,
new
DialogInterface
.
OnClickListener
()
{
@Override
@Override
...
@@ -1425,18 +1313,7 @@ public class Launcher extends BaseActivity
...
@@ -1425,18 +1313,7 @@ public class Launcher extends BaseActivity
dialog
.
dismiss
();
dialog
.
dismiss
();
}
}
},
null
);
},
null
);
new
Thread
()
{
@Override
public
void
run
()
{
super
.
run
();
clearProcesses
();
killBackgroundApplication
();
initDefaultPkgsList
();
}
}.
start
();
Prefs
.
setIsFirstInit
(
Launcher
.
this
,
false
);
Prefs
.
setIsFirstInit
(
Launcher
.
this
,
false
);
// initWifiList();
}
}
}
}
...
@@ -1452,11 +1329,6 @@ public class Launcher extends BaseActivity
...
@@ -1452,11 +1329,6 @@ public class Launcher extends BaseActivity
}
}
private
void
initDefaultPkgsList
()
{
// DpmHelper.getInstance(this).preinstallApp("MCS_SVN_1515.apk");
// DpmHelper.getInstance(this).preinstallApp("NumasPad_v1.8.6.apk");
}
private
boolean
checkDeviceOwner
()
{
private
boolean
checkDeviceOwner
()
{
boolean
middlewareDeviceOwner
=
DpmHelper
.
getInstance
(
this
).
isMiddlewareDeviceOwner
();
boolean
middlewareDeviceOwner
=
DpmHelper
.
getInstance
(
this
).
isMiddlewareDeviceOwner
();
if
(!
middlewareDeviceOwner
)
{
if
(!
middlewareDeviceOwner
)
{
...
@@ -1467,7 +1339,7 @@ public class Launcher extends BaseActivity
...
@@ -1467,7 +1339,7 @@ public class Launcher extends BaseActivity
checkDeviceOwner
();
checkDeviceOwner
();
}
}
},
6000
);
},
6000
);
}
else
{
}
else
{
MdmFactoryManager
.
getInstance
().
getGooglePolicyManager
().
setOrganizationName
(
"个人"
);
MdmFactoryManager
.
getInstance
().
getGooglePolicyManager
().
setOrganizationName
(
"个人"
);
}
}
return
middlewareDeviceOwner
;
return
middlewareDeviceOwner
;
...
@@ -1538,24 +1410,12 @@ public class Launcher extends BaseActivity
...
@@ -1538,24 +1410,12 @@ public class Launcher extends BaseActivity
public
void
changeWalPaper
(
ChangeWallPaperEvent
changeWallPaperEvent
)
{
public
void
changeWalPaper
(
ChangeWallPaperEvent
changeWallPaperEvent
)
{
Uri
selectedImage
=
changeWallPaperEvent
.
getUri
();
Uri
selectedImage
=
changeWallPaperEvent
.
getUri
();
String
path
=
FileUtil
.
getPath
(
this
,
selectedImage
);
String
path
=
FileUtil
.
getPath
(
this
,
selectedImage
);
FileUtil
.
copyFile
(
this
,
path
,
WALLPAPER_NAME
);
FileUtil
.
copyFile
(
path
,
WALLPAPER_NAME
);
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
mWallpaperPath
);
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
View
launcher
=
findViewById
(
R
.
id
.
launcher
);
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
launcher
.
setBackground
(
new
BitmapDrawable
(
getResources
(),
bitmap
));
}
}
private
List
<
String
>
getPersistentList
()
{
List
<
String
>
list
=
null
;
if
(
list
==
null
)
{
list
=
new
ArrayList
<>();
}
if
(
list
.
size
()
>
0
)
{
list
.
clear
();
}
list
.
add
(
getPackageName
());
list
.
add
(
PACKAGENAME_MIDDLEWARE
);
return
list
;
}
@Override
@Override
protected
void
onPause
()
{
protected
void
onPause
()
{
...
@@ -2353,14 +2213,6 @@ public class Launcher extends BaseActivity
...
@@ -2353,14 +2213,6 @@ public class Launcher extends BaseActivity
// });
// });
MdmUtils
.
setDefaultLauncher
(
Launcher
.
this
);
MdmUtils
.
setDefaultLauncher
(
Launcher
.
this
);
new
Thread
()
{
@Override
public
void
run
()
{
super
.
run
();
clearProcesses
();
killBackgroundApplication
();
}
}.
start
();
}
}
}
}
...
...
Launcher3/src/com/android/launcher3/mdm/MdmUtils.java
View file @
b907eb49
...
@@ -10,8 +10,10 @@ import com.secspace.lib.common.utils.Prefs;
...
@@ -10,8 +10,10 @@ import com.secspace.lib.common.utils.Prefs;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
android
.
launcher3
.
mdm
.
Component
.
huaweiLuancher
;
import
static
com
.
android
.
launcher3
.
mdm
.
Component
.
huaweiLuancher
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgHuaWei
.
PACKAGENAME_HW_LAUNCHER
;
public
class
MdmUtils
{
public
class
MdmUtils
{
/**
/**
...
@@ -40,6 +42,16 @@ public class MdmUtils {
...
@@ -40,6 +42,16 @@ public class MdmUtils {
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setStatusBarExpandPanelDisabled
(
false
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setStatusBarExpandPanelDisabled
(
false
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setTaskButtonDisabled
(
false
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setTaskButtonDisabled
(
false
);
Prefs
.
setAutoStartSelf
(
context
,
false
);
Prefs
.
setAutoStartSelf
(
context
,
false
);
List
<
String
>
launchers
=
Prefs
.
getHideLauncherPackages
(
context
);
if
(
launchers
==
null
)
{
launchers
=
new
ArrayList
<>();
}
if
(!
launchers
.
contains
(
PACKAGENAME_HW_LAUNCHER
))
{
launchers
.
add
(
PACKAGENAME_HW_LAUNCHER
);
}
for
(
String
launcher
:
launchers
)
{
DisableCompat
.
enableApplication
(
context
,
launcher
);
}
DisableCompat
.
enableComponent
(
context
,
huaweiLuancher
);
DisableCompat
.
enableComponent
(
context
,
huaweiLuancher
);
}
}
...
...
Launcher3/src/com/android/launcher3/settings/SettingActivity.java
deleted
100644 → 0
View file @
02fd4a46
package
com
.
android
.
launcher3
.
settings
;
import
android.app.AlertDialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
com.android.launcher3.BuildConfig
;
import
com.android.launcher3.Launcher
;
import
com.android.launcher3.R
;
import
com.android.launcher3.mdm.MdmUtils
;
import
com.android.launcher3.settings.wifi.WifiWhiteListActivity
;
import
com.secspace.lib.common.dialog.SwitcherDialog
;
import
com.secspace.lib.common.event.ChangeWallPaperEvent
;
import
com.secspace.lib.common.update.CheckUpdateCore
;
import
com.secspace.lib.common.utils.ActivityHelper
;
import
com.secspace.lib.common.utils.Prefs
;
import
com.secspace.lib.common.utils.ToastUtil
;
import
com.secspace.lib.common.utils.UninstallUtil
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
org.greenrobot.eventbus.EventBus
;
import
static
com
.
android
.
launcher3
.
settings
.
Contants
.
FROM_WHERE
;
import
static
com
.
android
.
launcher3
.
settings
.
Contants
.
IS_SHOW_ORIGINAL_PWD
;
public
class
SettingActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
private
static
final
int
REQUEST_PICK_WALLPAPER
=
10
;
private
static
final
String
ACTION_CHANGE_WALLPAPER
=
"action_change_wallpaper"
;
private
Button
mBtnVsrsion
;
private
Button
mBtnChangeWallPaper
;
private
Button
mBtnChangePwd
;
private
Button
mBtnsetPwdCar
;
private
Button
mBtnAllowNewApp
;
private
Button
mBtnInvisibleMenu
;
private
Button
mBtnAtuoStart
;
private
Button
mWifiWhiteList
;
private
Button
mBtnDisableManager
;
private
Button
mBtnUpdate
;
private
Button
mBtnUninstall
;
//允许添加先安装应用
public
static
final
int
ALLOW_NEW_APP
=
0
;
//允许本身自启
public
static
final
int
AUTO_START_SELF
=
1
;
private
Context
mContext
;
private
TextView
mTvTitle
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_setting
);
mContext
=
this
;
initView
();
initListener
();
initData
();
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
setBtnBackground
();
}
private
void
setBtnBackground
()
{
if
(
Prefs
.
isAllowNewApp
(
this
))
{
mBtnAllowNewApp
.
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
btn_background
));
}
else
{
mBtnAllowNewApp
.
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
notification_color_beneath
));
}
if
(
Prefs
.
isAutoStartSelf
(
this
))
{
mBtnAtuoStart
.
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
btn_background
));
}
else
{
mBtnAtuoStart
.
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
notification_color_beneath
));
}
}
private
void
initListener
()
{
mBtnAllowNewApp
.
setOnClickListener
(
this
);
mBtnChangePwd
.
setOnClickListener
(
this
);
mBtnsetPwdCar
.
setOnClickListener
(
this
);
mBtnAtuoStart
.
setOnClickListener
(
this
);
mBtnChangeWallPaper
.
setOnClickListener
(
this
);
mWifiWhiteList
.
setOnClickListener
(
this
);
mBtnDisableManager
.
setOnClickListener
(
this
);
mBtnUpdate
.
setOnClickListener
(
this
);
mBtnUninstall
.
setOnClickListener
(
this
);
}
private
void
initView
()
{
mBtnVsrsion
=
findViewById
(
R
.
id
.
btn_version
);
mBtnChangeWallPaper
=
findViewById
(
R
.
id
.
btn_change_wallpaper
);
mBtnChangePwd
=
findViewById
(
R
.
id
.
btn_change_pwd
);
mBtnsetPwdCar
=
findViewById
(
R
.
id
.
btn_set_pwdcar
);
mBtnAllowNewApp
=
findViewById
(
R
.
id
.
btn_allow_new_app
);
mBtnInvisibleMenu
=
findViewById
(
R
.
id
.
btn_invisible_menu
);
mBtnAtuoStart
=
findViewById
(
R
.
id
.
btn_auto_start
);
mWifiWhiteList
=
findViewById
(
R
.
id
.
btn_wifi_whitelist
);
mBtnDisableManager
=
findViewById
(
R
.
id
.
btn_manager_disable
);
mBtnUpdate
=
findViewById
(
R
.
id
.
btn_update
);
mBtnUninstall
=
findViewById
(
R
.
id
.
btn_uninstall
);
findViewById
(
R
.
id
.
tv_back
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
finish
();
}
});
mTvTitle
=
findViewById
(
R
.
id
.
tv_title
);
mTvTitle
.
setText
(
"设置"
);
}
private
void
initData
()
{
mBtnVsrsion
.
setText
(
"V"
+
BuildConfig
.
VERSION_NAME
);
}
private
void
showPwdDialog
(
final
String
tip
,
final
int
type
,
String
text
)
{
AlertDialog
alertDialog
;
TextView
textView
=
new
TextView
(
this
);
View
view
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_ll
,
null
);
textView
.
setText
(
text
);
final
LinearLayout
ll
=
view
.
findViewById
(
R
.
id
.
item_ll
);
ll
.
addView
(
textView
);
alertDialog
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
getString
(
R
.
string
.
tip
))
.
setCancelable
(
false
)
.
setView
(
view
)
.
setNegativeButton
(
R
.
string
.
work_cancel
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
}
})
.
setPositiveButton
(
tip
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
switch
(
type
)
{
case
ALLOW_NEW_APP:
if
(
tip
.
equals
(
getString
(
R
.
string
.
open
)))
{
Prefs
.
setAllowNewApp
(
mContext
,
true
);
}
else
{
Prefs
.
setAllowNewApp
(
mContext
,
false
);
}
break
;
case
AUTO_START_SELF:
if
(
tip
.
equals
(
getString
(
R
.
string
.
open
)))
{
Prefs
.
setAutoStartSelf
(
mContext
,
true
);
MdmUtils
.
setDefaultLauncher
(
mContext
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setStatusBarExpandPanelDisabled
(
true
);
}
else
{
Prefs
.
setAutoStartSelf
(
mContext
,
false
);
MdmUtils
.
clearDefaultLauncher
(
mContext
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setStatusBarExpandPanelDisabled
(
false
);
}
break
;
}
setBtnBackground
();
dialog
.
dismiss
();
}
})
.
create
();
if
(!
alertDialog
.
isShowing
())
{
alertDialog
.
show
();
}
}
private
void
showTipDialog
(
String
text
)
{
AlertDialog
alertDialog
;
TextView
textView
=
new
TextView
(
this
);
View
view
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_ll
,
null
);
textView
.
setText
(
text
);
final
LinearLayout
ll
=
view
.
findViewById
(
R
.
id
.
item_ll
);
ll
.
addView
(
textView
);
alertDialog
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
getString
(
R
.
string
.
tip
))
.
setCancelable
(
false
)
.
setView
(
view
)
.
setNegativeButton
(
R
.
string
.
work_cancel
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
}
})
.
create
();
if
(!
alertDialog
.
isShowing
())
{
alertDialog
.
show
();
}
}
@Override
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
case
R
.
id
.
btn_change_pwd
:
Intent
intent1
=
new
Intent
(
this
,
ChangePwdActivity
.
class
);
intent1
.
putExtra
(
IS_SHOW_ORIGINAL_PWD
,
true
);
startActivity
(
intent1
);
break
;
case
R
.
id
.
btn_set_pwdcar
:
Intent
intent2
=
new
Intent
(
this
,
VerifyPwdProtectionActivity
.
class
);
intent2
.
putExtra
(
FROM_WHERE
,
SettingActivity
.
class
.
getSimpleName
());
startActivity
(
intent2
);
break
;
case
R
.
id
.
btn_auto_start
:
boolean
autoStartSelf
=
Prefs
.
isAutoStartSelf
(
this
);
if
(!
autoStartSelf
)
{
showPwdDialog
(
getString
(
R
.
string
.
open
),
AUTO_START_SELF
,
getString
(
R
.
string
.
open_start_tip
));
}
else
{
showPwdDialog
(
getString
(
R
.
string
.
close
),
AUTO_START_SELF
,
getString
(
R
.
string
.
open_start_tip
));
}
break
;
case
R
.
id
.
btn_allow_new_app
:
boolean
allowNewApp
=
Prefs
.
isAllowNewApp
(
this
);
if
(!
allowNewApp
)
{
showPwdDialog
(
getString
(
R
.
string
.
open
),
ALLOW_NEW_APP
,
getString
(
R
.
string
.
open_new_app_tip
));
}
else
{
showPwdDialog
(
getString
(
R
.
string
.
close
),
ALLOW_NEW_APP
,
getString
(
R
.
string
.
open_new_app_tip
));
}
break
;
case
R
.
id
.
btn_wifi_whitelist
:
startActivity
(
new
Intent
(
this
,
WifiWhiteListActivity
.
class
));
break
;
case
R
.
id
.
btn_change_wallpaper
:
Intent
intent
=
new
Intent
(
Intent
.
ACTION_PICK
,
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
startActivityForResult
(
intent
,
REQUEST_PICK_WALLPAPER
);
break
;
case
R
.
id
.
btn_manager_disable
:
startActivity
(
new
Intent
(
this
,
ManagerDisableActivity
.
class
));
break
;
case
R
.
id
.
btn_update
:
CheckUpdateCore
.
get
().
enableUpdate
();
ToastUtil
.
showLong
(
mContext
,
"正在检测更新,请稍后"
);
break
;
case
R
.
id
.
btn_uninstall
:
uninstall
();
break
;
}
}
private
void
uninstall
(){
SwitcherDialog
.
getInstance
(
mContext
).
show
(
"正在卸载中,请稍后"
,
"unInstall"
);
UninstallUtil
.
INSTANCE
.
removeForbidden
(
mContext
);
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
2000
);
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
SwitcherDialog
.
getInstance
(
mContext
).
dismiss
(
"unInstall"
);
UninstallUtil
.
INSTANCE
.
uninstallService
(
mContext
);
}
});
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}).
start
();
}
@Override
protected
void
onActivityResult
(
final
int
requestCode
,
final
int
resultCode
,
final
Intent
data
)
{
if
(
requestCode
==
REQUEST_PICK_WALLPAPER
)
{
if
(
resultCode
==
RESULT_OK
)
{
Log
.
e
(
"WWWW"
,
"AAAAA"
);
Uri
selectedImage
=
data
.
getData
();
EventBus
.
getDefault
().
postSticky
(
new
ChangeWallPaperEvent
(
selectedImage
));
ToastUtil
.
showShort
(
this
,
"壁纸修改成功"
);
}
}
}
}
Launcher3/src/com/android/launcher3/settings/SettingActivity.kt
0 → 100644
View file @
b907eb49
package
com.android.launcher3.settings
import
android.app.Activity
import
android.app.AlertDialog
import
android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.provider.MediaStore
import
android.support.v7.app.AppCompatActivity
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.View
import
android.widget.LinearLayout
import
android.widget.TextView
import
com.android.launcher3.BuildConfig
import
com.android.launcher3.R
import
com.android.launcher3.mdm.DisableCompat
import
com.android.launcher3.mdm.MdmUtils
import
com.android.launcher3.settings.wifi.WifiWhiteListActivity
import
com.secspace.lib.common.dialog.SwitcherDialog
import
com.secspace.lib.common.event.ChangeWallPaperEvent
import
com.secspace.lib.common.update.CheckUpdateCore
import
com.secspace.lib.common.utils.PkgManager
import
com.secspace.lib.common.utils.Prefs
import
com.secspace.lib.common.utils.ToastUtil
import
com.secspace.lib.common.utils.UninstallUtil.removeForbidden
import
com.secspace.lib.common.utils.UninstallUtil.uninstallService
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
import
kotlinx.android.synthetic.main.activity_setting.*
import
kotlinx.android.synthetic.main.toolbar.*
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
org.greenrobot.eventbus.EventBus
class
SettingActivity
:
AppCompatActivity
(),
View
.
OnClickListener
{
private
var
mContext
:
Context
?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_setting
)
mContext
=
this
initView
()
}
override
fun
onResume
()
{
super
.
onResume
()
setBtnBackground
()
}
private
fun
setBtnBackground
()
{
if
(
Prefs
.
isAllowNewApp
(
this
))
{
btn_allow_new_app
.
setBackgroundColor
(
resources
.
getColor
(
R
.
color
.
btn_background
))
}
else
{
btn_allow_new_app
.
setBackgroundColor
(
resources
.
getColor
(
R
.
color
.
notification_color_beneath
))
}
if
(
Prefs
.
isAutoStartSelf
(
this
))
{
btn_auto_start
.
setBackgroundColor
(
resources
.
getColor
(
R
.
color
.
btn_background
))
}
else
{
btn_auto_start
.
setBackgroundColor
(
resources
.
getColor
(
R
.
color
.
notification_color_beneath
))
}
}
private
fun
initView
()
{
btn_allow_new_app
.
setOnClickListener
(
this
)
btn_change_pwd
.
setOnClickListener
(
this
)
btn_set_pwdcar
.
setOnClickListener
(
this
)
btn_auto_start
.
setOnClickListener
(
this
)
btn_change_wallpaper
.
setOnClickListener
(
this
)
btn_wifi_whitelist
.
setOnClickListener
(
this
)
btn_manager_disable
.
setOnClickListener
(
this
)
btn_update
.
setOnClickListener
(
this
)
btn_uninstall
.
setOnClickListener
(
this
)
btn_reinforce
.
setOnClickListener
(
this
)
tv_back
.
setOnClickListener
(
this
)
btn_version
.
text
=
String
.
format
(
getString
(
R
.
string
.
edu_version
),
BuildConfig
.
VERSION_NAME
)
tv_title
.
text
=
"设置"
}
private
fun
showPwdDialog
(
tip
:
String
,
type
:
Int
,
text
:
String
)
{
val
alertDialog
:
AlertDialog
val
textView
=
TextView
(
this
)
val
view
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_ll
,
null
)
textView
.
text
=
text
val
ll
=
view
.
findViewById
<
LinearLayout
>(
R
.
id
.
item_ll
)
ll
.
addView
(
textView
)
alertDialog
=
AlertDialog
.
Builder
(
this
)
.
setTitle
(
getString
(
R
.
string
.
tip
))
.
setCancelable
(
false
)
.
setView
(
view
)
.
setNegativeButton
(
R
.
string
.
work_cancel
)
{
dialog
,
which
->
dialog
.
dismiss
()
}
.
setPositiveButton
(
tip
)
{
dialog
,
_
->
when
(
type
)
{
ALLOW_NEW_APP
->
if
(
tip
==
getString
(
R
.
string
.
open
))
{
Prefs
.
setAllowNewApp
(
mContext
,
true
)
}
else
{
Prefs
.
setAllowNewApp
(
mContext
,
false
)
}
AUTO_START_SELF
->
if
(
tip
==
getString
(
R
.
string
.
open
))
{
Prefs
.
setAutoStartSelf
(
mContext
,
true
)
MdmUtils
.
setDefaultLauncher
(
mContext
)
MdmFactoryManager
.
getInstance
().
deviceRestrictionManager
.
isStatusBarExpandPanelDisabled
=
true
}
else
{
Prefs
.
setAutoStartSelf
(
mContext
,
false
)
MdmUtils
.
clearDefaultLauncher
(
mContext
)
MdmFactoryManager
.
getInstance
().
deviceRestrictionManager
.
isStatusBarExpandPanelDisabled
=
false
}
}
setBtnBackground
()
dialog
.
dismiss
()
}
.
create
()
if
(!
alertDialog
.
isShowing
)
{
alertDialog
.
show
()
}
}
private
fun
showTipDialog
(
text
:
String
)
{
val
alertDialog
:
AlertDialog
val
textView
=
TextView
(
this
)
val
view
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_ll
,
null
)
textView
.
text
=
text
val
ll
=
view
.
findViewById
<
LinearLayout
>(
R
.
id
.
item_ll
)
ll
.
addView
(
textView
)
alertDialog
=
AlertDialog
.
Builder
(
this
)
.
setTitle
(
getString
(
R
.
string
.
tip
))
.
setCancelable
(
false
)
.
setView
(
view
)
.
setNegativeButton
(
R
.
string
.
work_cancel
)
{
dialog
,
_
->
dialog
.
dismiss
()
}
.
create
()
if
(!
alertDialog
.
isShowing
)
{
alertDialog
.
show
()
}
}
override
fun
onClick
(
v
:
View
)
{
when
(
v
.
id
)
{
R
.
id
.
btn_change_pwd
->
{
val
intent1
=
Intent
(
this
,
ChangePwdActivity
::
class
.
java
)
intent1
.
putExtra
(
Contants
.
IS_SHOW_ORIGINAL_PWD
,
true
)
startActivity
(
intent1
)
}
R
.
id
.
btn_set_pwdcar
->
{
val
intent2
=
Intent
(
this
,
VerifyPwdProtectionActivity
::
class
.
java
)
intent2
.
putExtra
(
Contants
.
FROM_WHERE
,
SettingActivity
::
class
.
java
.
simpleName
)
startActivity
(
intent2
)
}
R
.
id
.
btn_auto_start
->
{
val
autoStartSelf
=
Prefs
.
isAutoStartSelf
(
this
)
if
(!
autoStartSelf
)
{
showPwdDialog
(
getString
(
R
.
string
.
open
),
AUTO_START_SELF
,
getString
(
R
.
string
.
open_start_tip
))
}
else
{
showPwdDialog
(
getString
(
R
.
string
.
close
),
AUTO_START_SELF
,
getString
(
R
.
string
.
open_start_tip
))
}
}
R
.
id
.
btn_allow_new_app
->
{
val
allowNewApp
=
Prefs
.
isAllowNewApp
(
this
)
if
(!
allowNewApp
)
{
showPwdDialog
(
getString
(
R
.
string
.
open
),
ALLOW_NEW_APP
,
getString
(
R
.
string
.
open_new_app_tip
))
}
else
{
showPwdDialog
(
getString
(
R
.
string
.
close
),
ALLOW_NEW_APP
,
getString
(
R
.
string
.
open_new_app_tip
))
}
}
R
.
id
.
btn_wifi_whitelist
->
startActivity
(
Intent
(
this
,
WifiWhiteListActivity
::
class
.
java
))
R
.
id
.
btn_change_wallpaper
->
{
val
intent
=
Intent
(
Intent
.
ACTION_PICK
,
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
)
startActivityForResult
(
intent
,
REQUEST_PICK_WALLPAPER
)
}
R
.
id
.
btn_manager_disable
->
startActivity
(
Intent
(
this
,
ManagerDisableActivity
::
class
.
java
))
R
.
id
.
btn_update
->
{
CheckUpdateCore
.
get
().
enableUpdate
()
ToastUtil
.
showLong
(
mContext
,
R
.
string
.
edu_check_update
)
}
R
.
id
.
btn_uninstall
->
showTipDialog
({
uninstall
()
},
getString
(
R
.
string
.
edu_uninstall_tip
))
R
.
id
.
btn_reinforce
->
showTipDialog
({
reinforce
()
},
getString
(
R
.
string
.
edu_reinforce
))
R
.
id
.
tv_back
->
finish
()
}
}
private
fun
reinforce
()
{
val
packages
:
MutableList
<
String
>
=
PkgManager
.
getInstance
(
mContext
).
queryLauncherPackages
()
packages
.
remove
(
mContext
?.
packageName
)
if
(
packages
.
isNotEmpty
()){
Prefs
.
setHideLauncherPackages
(
mContext
,
packages
)
}
for
(
packageName
in
packages
)
{
DisableCompat
.
disableApplication
(
mContext
,
packageName
)
}
}
private
fun
uninstall
()
{
GlobalScope
.
launch
(
Dispatchers
.
Main
)
{
SwitcherDialog
.
getInstance
(
mContext
).
show
(
getString
(
R
.
string
.
edu_uninstall
),
"unInstall"
)
removeForbidden
(
mContext
)
delay
(
1000
)
uninstallService
(
mContext
)
delay
(
800
)
SwitcherDialog
.
getInstance
(
mContext
).
dismiss
(
"unInstall"
)
}
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
if
(
requestCode
==
REQUEST_PICK_WALLPAPER
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
Log
.
e
(
"WWWW"
,
"AAAAA"
)
val
selectedImage
=
data
!!
.
data
EventBus
.
getDefault
().
postSticky
(
ChangeWallPaperEvent
(
selectedImage
))
ToastUtil
.
showShort
(
this
,
"壁纸修改成功"
)
}
}
}
private
inline
fun
showTipDialog
(
crossinline
block
:
()
->
Unit
,
text
:
String
)
{
val
alertDialog
:
AlertDialog
val
textView
=
TextView
(
this
)
val
view
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_ll
,
null
)
textView
.
text
=
text
val
ll
=
view
.
findViewById
<
LinearLayout
>(
R
.
id
.
item_ll
)
ll
.
addView
(
textView
)
alertDialog
=
AlertDialog
.
Builder
(
this
)
.
setTitle
(
getString
(
R
.
string
.
tip
))
.
setCancelable
(
false
)
.
setView
(
view
)
.
setNegativeButton
(
R
.
string
.
work_cancel
)
{
dialog
,
_
->
dialog
.
dismiss
()
}
.
setPositiveButton
(
R
.
string
.
work_sure
)
{
dialog
,
_
->
run
{
dialog
.
dismiss
()
block
()
}
}
.
create
()
if
(!
alertDialog
.
isShowing
)
{
alertDialog
.
show
()
}
}
companion
object
{
private
const
val
REQUEST_PICK_WALLPAPER
=
10
private
const
val
ACTION_CHANGE_WALLPAPER
=
"action_change_wallpaper"
//允许添加先安装应用
const
val
ALLOW_NEW_APP
=
0
//允许本身自启
const
val
AUTO_START_SELF
=
1
}
}
\ No newline at end of file
assetsprovider/src/main/assets/MCS_SVN_1515.apk
deleted
100644 → 0
View file @
02fd4a46
File deleted
assetsprovider/src/main/assets/Mdm_Service.apk
View file @
b907eb49
No preview for this file type
assetsprovider/src/main/assets/NumasPad_v1.8.6.apk
deleted
100644 → 0
View file @
02fd4a46
File deleted
assetsprovider/src/main/assets/toolV4.apk
deleted
100644 → 0
View file @
02fd4a46
File deleted
gradle.properties
View file @
b907eb49
...
@@ -30,4 +30,4 @@ versionIntCode=2020031702
...
@@ -30,4 +30,4 @@ versionIntCode=2020031702
versionNameMajor
=
1
versionNameMajor
=
1
versionNameMinor
=
0
versionNameMinor
=
0
versionNamePatch
=
0
versionNamePatch
=
1
\ No newline at end of file
\ No newline at end of file
lib_common/build.gradle
View file @
b907eb49
...
@@ -83,7 +83,7 @@ dependencies {
...
@@ -83,7 +83,7 @@ dependencies {
api
'pub.devrel:easypermissions:1.1.3'
api
'pub.devrel:easypermissions:1.1.3'
api
'com.jakewharton:butterknife:8.7.0'
api
'com.jakewharton:butterknife:8.7.0'
api
'com.google.code.gson:gson:2.7'
api
'com.google.code.gson:gson:2.7'
api
'org.greenrobot:eventbus:3.
0.0
'
api
'org.greenrobot:eventbus:3.
1.1
'
String
HwSdk
=
'2.5.2.300'
String
HwSdk
=
'2.5.2.300'
api
'com.huawei.android.hms:base:'
+
HwSdk
api
'com.huawei.android.hms:base:'
+
HwSdk
api
'com.huawei.android.hms:push:'
+
HwSdk
api
'com.huawei.android.hms:push:'
+
HwSdk
...
@@ -122,4 +122,7 @@ dependencies {
...
@@ -122,4 +122,7 @@ dependencies {
// Downloader
// Downloader
implementation
'com.tk.lib:downloader:1.0.6'
implementation
'com.tk.lib:downloader:1.0.6'
implementation
'com.tk.lib:dialog:1.0.2'
implementation
'com.tk.lib:dialog:1.0.2'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
}
}
\ No newline at end of file
lib_common/src/main/AndroidManifest.xml
View file @
b907eb49
...
@@ -6,9 +6,12 @@
...
@@ -6,9 +6,12 @@
android:label=
"@string/common_sec_permission_default"
android:label=
"@string/common_sec_permission_default"
android:protectionLevel=
"signature"
></permission>
android:protectionLevel=
"signature"
></permission>
<uses-permission
android:name=
"android.permission.GET_ACCOUNTS"
android:maxSdkVersion=
"22"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"secspace.permission.sec.Default"
></uses-permission>
<uses-permission
android:name=
"secspace.permission.sec.Default"
></uses-permission>
<uses-permission
android:name=
"middleware.permission.MDM"
/>
<application>
<application>
<activity
<activity
android:name=
".tips.PermissionTipActivity"
android:name=
".tips.PermissionTipActivity"
...
...
lib_common/src/main/java/com/secspace/lib/common/event/InitEvent.java
0 → 100644
View file @
b907eb49
package
com
.
secspace
.
lib
.
common
.
event
;
/**
* 初始化
*
* @author kaku
* @date 2017/9/1
*/
public
class
InitEvent
{
public
InitEvent
()
{
}
}
lib_common/src/main/java/com/secspace/lib/common/function/DialogManager.java
0 → 100644
View file @
b907eb49
package
com
.
secspace
.
lib
.
common
.
function
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.res.Resources
;
import
com.secspace.lib.common.R
;
import
com.secspace.lib.common.dialog.DotRotateDialog
;
import
com.secspace.lib.common.dialog.OptimizeDialog
;
import
com.secspace.lib.common.dialog.SecSpaceUpdateDialog
;
import
com.secspace.lib.common.dialog.SimpleDialog
;
import
com.secspace.lib.common.dialog.SwitcherDialog
;
import
com.secspace.lib.common.env.BlackandWhiteList
;
import
com.secspace.lib.common.event.ExitEvent
;
import
com.secspace.lib.common.event.ResetPwdEvent
;
import
com.secspace.lib.common.utils.DpmHelper
;
import
com.secspace.lib.common.utils.PkgManager
;
import
com.secspace.lib.common.utils.Prefs
;
import
com.secspace.lib.common.utils.ToastUtil
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
org.greenrobot.eventbus.EventBus
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
CompSecSpace
.
CLASSNAME_DPM_ADMIN
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
;
/**
* Created by cyw_m on 2018/4/6.
*/
@SuppressLint
(
"StaticFieldLeak"
)
public
class
DialogManager
{
private
static
DialogManager
mInstance
=
null
;
private
SimpleDialog
mSimpleDialog
;
private
DotRotateDialog
mDotRotateDialog
;
private
OptimizeDialog
mOptimizeDialog
;
private
SecSpaceUpdateDialog
mPresetAppUpdateDialog
;
private
DialogManager
()
{
}
public
static
DialogManager
getInstance
()
{
if
(
mInstance
==
null
)
{
synchronized
(
DialogManager
.
class
)
{
if
(
mInstance
==
null
)
{
mInstance
=
new
DialogManager
();
}
}
}
return
mInstance
;
}
/**
* 安装中间件弹窗
*/
public
void
showInstallMiddleWare
(
Activity
activity
)
{
final
Context
context
=
activity
.
getApplication
();
mSimpleDialog
=
new
SimpleDialog
(
activity
).
show
(
context
.
getResources
().
getString
(
R
.
string
.
common_remind
)
,
context
.
getResources
().
getString
(
R
.
string
.
common_need_install_middleware
)
,
false
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
WorkManager
.
INSTANCE
.
installMiddleWare
(
context
);
dialog
.
dismiss
();
}
}
,
null
);
}
public
void
showMiddleWareDeviceOwnerConfirmDialog
(
Activity
activity
)
{
if
(
DpmOwnerHelper
.
INSTANCE
.
isSettingDeviceOwner
())
{
return
;
}
final
Context
context
=
activity
.
getApplicationContext
();
dismissSimpleDialog
();
mSimpleDialog
=
new
SimpleDialog
(
activity
).
show
(
activity
.
getResources
().
getString
(
R
.
string
.
common_remind
)
,
activity
.
getResources
().
getString
(
R
.
string
.
work_confirm_device_owner
)
,
false
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
DpmOwnerHelper
.
INSTANCE
.
disableAccountsAndRemoveProfileUsers
(
context
);
SwitcherDialog
.
getInstance
(
context
).
show
(
context
.
getString
(
R
.
string
.
work_del_account
),
"Clear Account"
);
dialog
.
dismiss
();
}
}
,
null
);
}
public
void
showRemoveUserConfirmDialog
(
Activity
activity
)
{
mSimpleDialog
=
new
SimpleDialog
(
activity
).
show
(
activity
.
getResources
().
getString
(
R
.
string
.
common_remind
)
,
activity
.
getResources
().
getString
(
R
.
string
.
work_remove_user_confirm_device_owner
)
,
false
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
DpmOwnerHelper
.
INSTANCE
.
removeOtherUsers
();
}
}
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
EventBus
.
getDefault
().
post
(
new
ExitEvent
());
}
}
);
}
/**
* 关闭普通dialog
*/
public
void
dismissSimpleDialog
()
{
if
(
mSimpleDialog
!=
null
)
{
mSimpleDialog
.
dismiss
();
}
}
}
lib_common/src/main/java/com/secspace/lib/common/function/DpmOwnerHelper.kt
0 → 100644
View file @
b907eb49
package
com.secspace.lib.common.function
import
android.accounts.AccountManager
import
android.content.Context
import
android.content.pm.PackageManager
import
android.os.Environment
import
android.os.Handler
import
com.secspace.lib.common.utils.DisableCompat
import
com.secspace.lib.common.utils.IntentUtil
import
com.secspace.log.Log
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
import
java.io.File
import
java.io.FileReader
import
java.io.FileWriter
/**
* Created by lichuanzhi@tiankuan.net on 2019/3/29
*/
object
DpmOwnerHelper
{
private
const
val
TAG
=
"DpmOwnerHelper"
private
const
val
DISABLED_ACCOUNT_APP_FILE
=
"disableAccountApps.txt"
var
isSettingDeviceOwner
=
false
;
private
val
mHandler
=
Handler
()
/**
* 禁用账户并且移除掉所有其他用户(华为账号,隐私空间,工作空间等)
*/
fun
disableAccountsAndRemoveProfileUsers
(
context
:
Context
)
{
if
(
isSettingDeviceOwner
)
{
return
}
isSettingDeviceOwner
=
true
try
{
val
accountManager
=
context
.
getSystemService
(
Context
.
ACCOUNT_SERVICE
)
as
AccountManager
val
disabledApps
=
ArrayList
<
String
>()
val
map
=
HashMap
<
String
,
String
>()
accountManager
.
authenticatorTypes
.
forEach
{
map
[
it
.
type
]
=
it
.
packageName
Log
.
d
(
TAG
,
"authenticatorTypes:${it.type}, ${it.packageName}"
)
}
accountManager
.
accounts
.
forEach
{
try
{
Log
.
d
(
TAG
,
"accounts:${map.keys}, ${it.type}"
)
if
(
map
.
keys
.
contains
(
it
.
type
)){
map
[
it
.
type
]
?.
let
{
pkg
->
disabledApps
.
add
(
pkg
)
DisableCompat
.
disableApplication
(
context
,
pkg
)
}
}
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
}
if
(
disabledApps
.
size
>
0
)
{
writeDisabledApps
(
context
,
disabledApps
)
}
//MdmFactoryManager.getInstance().deviceUserManager.isAddUserDisabled = true
val
users
=
MdmFactoryManager
.
getInstance
().
deviceUserManager
.
systemUserList
users
?.
forEach
{
if
(!
it
.
isPrimary
)
{
// 移除所有其他用户
MdmFactoryManager
.
getInstance
().
deviceUserManager
.
removeUser
(
it
.
id
)
}
}
mHandler
.
postDelayed
({
IntentUtil
.
activateMdmServiceDeviceOwner
(
context
)
isSettingDeviceOwner
=
false
},
8
*
1000
)
mHandler
.
postDelayed
({
recoverAccounts
(
context
)
},
10
*
1000
)
}
catch
(
e
:
Exception
)
{
Log
.
e
(
TAG
,
Log
.
getStackTraceString
(
e
))
isSettingDeviceOwner
=
false
}
}
/**
* 恢复禁用的账户
*/
fun
recoverAccounts
(
context
:
Context
)
{
try
{
val
disabledApps
=
readDisabledApps
(
context
)
disabledApps
?.
map
{
if
(
it
.
trim
().
isNotEmpty
())
{
DisableCompat
.
enableApplication
(
context
,
it
.
trim
())
}
}
}
catch
(
e
:
java
.
lang
.
Exception
)
{
e
.
printStackTrace
()
}
}
private
fun
writeDisabledApps
(
context
:
Context
,
disabledApps
:
List
<
String
>)
{
val
dir
=
File
(
Environment
.
getExternalStorageDirectory
().
absolutePath
+
File
.
separator
+
"."
+
context
.
packageName
)
if
(!
dir
.
exists
())
{
dir
.
mkdirs
()
}
val
writer
=
FileWriter
(
File
(
dir
,
DISABLED_ACCOUNT_APP_FILE
),
false
)
writer
.
write
(
disabledApps
.
joinToString
())
writer
.
close
()
}
private
fun
readDisabledApps
(
context
:
Context
):
List
<
String
>?
{
val
dir
=
File
(
Environment
.
getExternalStorageDirectory
().
absolutePath
+
File
.
separator
+
"."
+
context
.
packageName
)
if
(!
dir
.
exists
())
{
return
null
}
val
file
=
File
(
dir
,
DISABLED_ACCOUNT_APP_FILE
)
if
(!
file
.
exists
())
{
return
null
}
return
FileReader
(
file
).
readText
().
split
(
","
)
}
fun
removeOtherUsers
(){
val
users
=
MdmFactoryManager
.
getInstance
().
deviceUserManager
.
systemUserList
users
?.
forEach
{
if
(!
it
.
isPrimary
)
{
// 移除所有其他用户
MdmFactoryManager
.
getInstance
().
deviceUserManager
.
removeUser
(
it
.
id
)
}
}
}
}
\ No newline at end of file
lib_common/src/main/java/com/secspace/lib/common/function/SwitchInMdm.kt
0 → 100644
View file @
b907eb49
package
com.secspace.lib.common.function
import
android.content.Context
import
android.content.Intent
import
android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.util.Log
import
com.secspace.lib.common.env.Packages.PkgSecSpace
import
com.secspace.lib.common.event.InitEvent
import
com.secspace.lib.common.utils.DisableCompat
import
com.secspace.lib.common.utils.DpmHelper
import
com.secspace.lib.common.utils.MdmUtils
import
com.secspace.lib.common.utils.Package.ComponentNames.COMPONENT_UPDATE_SYSTEM
import
com.secspace.lib.common.utils.Package.ComponentNames.EnterprisePrivacySettingsActivity
import
com.secspace.lib.common.utils.Prefs
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
import
org.greenrobot.eventbus.EventBus
import
java.util.*
object
SwitchInMdm
{
private
var
context
:
Context
?
=
null
private
val
TAG
=
"SwitchInMdm"
fun
init
(
context
:
Context
){
this
.
context
=
context
val
mdmFactoryManager
=
DpmHelper
.
getInstance
(
context
).
getmMdmFactoryManager
()
mdmFactoryManager
.
deviceSettingsManager
.
isRestoreFactoryDisabled
=
true
mdmFactoryManager
.
deviceApplicationManager
.
addDisabledDeactivateMdmPackages
(
getPersistentList
(
context
))
mdmFactoryManager
.
deviceApplicationManager
.
addDisallowedUninstallPackages
(
getPersistentList
(
context
))
mdmFactoryManager
.
deviceRestrictionManager
.
setDeviceOwnerApp
(
"DeviceOwner"
)
mdmFactoryManager
.
deviceApplicationManager
.
addPersistentApp
(
getPersistentList
(
context
))
val
arrayList
=
ArrayList
<
String
>()
arrayList
.
add
(
context
.
packageName
)
mdmFactoryManager
.
deviceSettingsManager
.
superWhiteListForHwSystemManger
=
arrayList
mdmFactoryManager
.
deviceRestrictionManager
.
turnOnGPS
(
true
)
mdmFactoryManager
.
deviceSettingsManager
.
isSystemUpdateDisabled
=
true
MdmFactoryManager
.
getInstance
().
deviceApplicationManager
.
setApplicationEnabledSetting
(
"com.huawei.powergenie"
,
PackageManager
.
COMPONENT_ENABLED_STATE_DISABLED
,
1
)
DisableCompat
.
disableComponent
(
context
,
COMPONENT_UPDATE_SYSTEM
)
DisableCompat
.
disableComponent
(
context
,
EnterprisePrivacySettingsActivity
)
clearProcesses
()
killBackgroundApplication
()
isCoverInstall
()
MdmUtils
.
setDefaultLauncher
(
context
)
EventBus
.
getDefault
().
postSticky
(
InitEvent
())
Log
.
e
(
"TAG"
,
"post: InitEvent"
)
}
private
fun
isCoverInstall
()
{
if
(
Prefs
.
isCoverSecondInstall
(
context
))
{
MdmFactoryManager
.
getInstance
().
deviceRestrictionManager
.
isAdbDisabled
=
false
MdmFactoryManager
.
getInstance
().
deviceRestrictionManager
.
isUSBOtgDisabled
=
false
MdmFactoryManager
.
getInstance
().
deviceRestrictionManager
.
isUSBDataDisabled
=
false
MdmFactoryManager
.
getInstance
().
deviceRestrictionManager
.
isExternalStorageDisabled
=
false
Prefs
.
setCoverSecondInstall
(
context
,
false
)
}
}
private
fun
getPersistentList
(
context
:
Context
):
List
<
String
?>?
{
var
list
:
MutableList
<
String
?>?
=
null
if
(
list
==
null
)
{
list
=
ArrayList
()
}
if
(
list
.
size
>
0
)
{
list
.
clear
()
}
list
.
add
(
context
.
packageName
)
list
.
add
(
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
)
return
list
}
private
fun
clearProcesses
()
{
val
dam
=
MdmFactoryManager
.
getInstance
().
deviceApplicationManager
//clear task
val
runningTasks
=
dam
.
getRunningTasks
(
1000
)
if
(
runningTasks
!=
null
)
{
for
(
task
in
runningTasks
)
{
val
pkg
=
task
.
baseActivity
.
packageName
if
(
pkg
==
context
?.
packageName
||
pkg
==
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
||
pkg
==
"com.android.systemui"
)
{
continue
}
dam
.
removeTask
(
task
.
id
)
Log
.
d
(
TAG
,
"remove task "
+
task
.
baseActivity
.
packageName
)
}
}
//clear processes
val
runningAppProcesses
=
dam
.
runningAppProcesses
val
packages
=
getAllPackages
(
PackageManager
.
MATCH_UNINSTALLED_PACKAGES
)
if
(
runningAppProcesses
!=
null
)
{
for
(
processInfo
in
runningAppProcesses
)
{
val
processName
=
processInfo
.
processName
if
(!
packages
.
contains
(
processName
))
{
continue
}
if
(
processName
==
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
||
context
?.
packageName
==
processName
||
processName
==
"com.huawei.powergenie"
)
{
continue
}
dam
.
killApplicationProcess
(
processName
)
dam
.
forceStopPackage
(
processName
)
Log
.
d
(
TAG
,
"kill $processName"
)
}
}
}
private
fun
getAllPackages
(
flags
:
Int
):
List
<
String
>
{
val
packageInfos
=
getAllPackageInfo
(
flags
)
val
list
:
MutableList
<
String
>
=
ArrayList
()
for
(
i
in
packageInfos
.
indices
)
{
list
.
add
(
packageInfos
[
i
].
packageName
)
}
return
list
}
private
fun
getAllPackageInfo
(
flags
:
Int
):
List
<
PackageInfo
>
{
return
context
!!
.
packageManager
.
getInstalledPackages
(
flags
)
}
private
fun
killBackgroundApplication
()
{
val
packageManager
:
PackageManager
?
=
context
?.
packageManager
val
mainIntent
=
Intent
(
Intent
.
ACTION_MAIN
,
null
)
mainIntent
.
addCategory
(
Intent
.
CATEGORY_LAUNCHER
)
val
apps
=
packageManager
?.
queryIntentActivities
(
mainIntent
,
0
)
for
(
i
in
apps
?.
indices
!!
)
{
val
name
=
apps
[
i
].
activityInfo
.
packageName
Log
.
i
(
TAG
,
"killBackgroundApplication: $name"
)
if
(
context
?.
packageName
?.
let
{
name
.
contains
(
it
)
}
!!
||
name
==
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
)
{
continue
}
MdmFactoryManager
.
getInstance
().
deviceApplicationManager
.
forceStopPackage
(
name
)
}
}
}
\ No newline at end of file
lib_common/src/main/java/com/secspace/lib/common/function/WorkManager.kt
0 → 100644
View file @
b907eb49
package
com.secspace.lib.common.function
import
android.annotation.TargetApi
import
android.app.Activity
import
android.content.Context
import
android.content.pm.PackageManager
import
android.os.Build
import
android.os.Handler
import
android.os.Looper
import
android.os.SystemClock
import
com.secspace.lib.common.env.Packages
import
com.secspace.lib.common.env.SEnvironment
import
com.secspace.lib.common.function.SwitchInMdm.init
import
com.secspace.lib.common.utils.*
import
com.secspace.log.Log
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.launch
import
java.io.File
object
WorkManager
{
private
val
TAG
=
"SecSpaceWorkManager"
private
lateinit
var
mContext
:
Context
private
val
mHandler
:
Handler
=
Handler
(
Looper
.
getMainLooper
(),
Handler
.
Callback
{
true
})
private
var
mEnterTime
:
Long
=
0
private
var
isFrstCheckDeviceOwner
=
true
var
isChecksCompleted
=
false
fun
enter
(
launcher
:
Activity
?)
{
mContext
=
launcher
!!
.
applicationContext
val
isMdmInitialized
=
Prefs
.
isMdmInitializedWhenEnter
(
mContext
)
if
(
isChecksCompleted
&&
isMdmInitialized
)
{
Log
.
i
(
TAG
,
"isMdmInitialized: $isMdmInitialized, isChecksCompleted:$isChecksCompleted"
)
return
}
mEnterTime
=
SystemClock
.
uptimeMillis
()
//检查中间件是否是最新的
if
(!
DpmHelper
.
getInstance
(
mContext
).
isMiddlewareLatest
)
{
DialogManager
.
getInstance
().
showInstallMiddleWare
(
launcher
)
return
}
DpmHelper
.
getInstance
(
mContext
).
initMiddleWare
()
//检查中间件是否激活
if
(!
DpmHelper
.
getInstance
(
mContext
).
isMiddlewareDPMActived
)
{
MdmFactoryManager
.
getInstance
().
deviceSettingsManager
.
setSilentActiveAdmin
(
DpmHelper
.
getInstance
(
mContext
).
middleWareAdmin
)
Log
.
i
(
TAG
,
"silent active middleware"
)
}
//安装耗时,检查是否都是最新的
if
(!
DpmHelper
.
getInstance
(
mContext
).
isMiddlewareLatest
)
{
Log
.
i
(
TAG
,
"will install delay"
)
mHandler
.
postDelayed
(
{
enter
(
launcher
)
},
2000
)
return
}
//检查中间件二是否激活DeviceOwner
if
(!
DpmHelper
.
getInstance
(
mContext
).
isMiddlewareDeviceOwner
)
{
if
(
isFrstCheckDeviceOwner
)
{
isFrstCheckDeviceOwner
=
false
MdmFactoryManager
.
getInstance
().
deviceRestrictionManager
.
setDeviceOwnerApp
(
Packages
.
PkgSecSpace
.
PACKAGENAME_MIDDLEWARE
)
mHandler
.
postDelayed
(
{
enter
(
launcher
)
},
1500
)
return
}
else
{
DialogManager
.
getInstance
().
showMiddleWareDeviceOwnerConfirmDialog
(
launcher
)
return
}
}
else
{
MdmFactoryManager
.
getInstance
().
googlePolicyManager
.
organizationName
=
"个人"
}
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
init
(
launcher
)
checkLocalUpdateFile
()
//检查本地更新文件
}
isChecksCompleted
=
true
Prefs
.
setMdmInitializedWhenEnter
(
mContext
,
true
)
}
private
fun
hasPermissions
(
permissions
:
Array
<
String
>,
packageName
:
String
):
Boolean
{
if
(
Build
.
VERSION
.
SDK_INT
<
23
)
{
return
true
}
else
{
val
length
=
permissions
.
size
for
(
i
in
0
until
length
)
{
val
permission
=
permissions
[
i
]
if
(
mContext
.
packageManager
.
checkPermission
(
permission
,
packageName
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
return
false
}
}
return
true
}
}
/**
* 检查本地是否有更新文件,有且版本号高则更新
*/
private
fun
checkLocalUpdateFile
()
{
Log
.
d
(
TAG
,
"check local update file"
)
val
dir
=
File
(
mContext
.
getExternalFilesDir
(
""
),
"Download"
)
if
(!
dir
.
exists
())
{
Log
.
i
(
TAG
,
"Download dir is not exist."
)
return
}
val
files
=
dir
.
listFiles
()
if
(
files
==
null
||
files
.
size
==
0
)
{
Log
.
i
(
TAG
,
"No file"
)
return
}
var
updateFile
:
File
?
=
null
val
currentVCode
=
PkgManager
.
getInstance
(
mContext
).
getVersionCodeFromPackage
(
mContext
.
packageName
)
var
newVCode
=
-
1
for
(
file
:
File
in
files
)
{
val
fileCode
=
PkgManager
.
getInstance
(
mContext
).
getStorageApkVersionCode
(
file
.
absolutePath
)
if
(
newVCode
<
fileCode
)
{
newVCode
=
fileCode
updateFile
=
file
}
}
if
(
updateFile
==
null
)
{
Log
.
i
(
TAG
,
"No update file"
)
return
}
Log
.
i
(
TAG
,
String
.
format
(
"new version(%d),old version(%d)"
,
newVCode
,
currentVCode
))
if
(
newVCode
<=
currentVCode
)
{
Log
.
i
(
TAG
,
"No Update."
)
return
}
Log
.
i
(
TAG
,
"Will install update File: "
+
updateFile
.
absolutePath
)
ToastUtil
.
showShort
(
mContext
,
"更新中..."
)
install
(
updateFile
.
absolutePath
)
}
@TargetApi
(
Build
.
VERSION_CODES
.
LOLLIPOP
)
fun
exit
(
launcher
:
Activity
?)
{
}
private
fun
pathFromAssets
(
name
:
String
):
String
{
return
mContext
.
externalCacheDir
.
absolutePath
+
File
.
separator
+
name
}
private
fun
install
(
path
:
String
)
{
PkgManager
.
getInstance
(
mContext
).
installByInstaller
(
path
)
}
/**
* 安装中间件
*/
fun
installMiddleWare
(
context
:
Context
)
{
val
path
=
pathFromAssets
(
SEnvironment
.
getMiddleWareNameForAssets
())
FileUtil
.
copyFileFromAssets
(
context
,
SEnvironment
.
getMiddleWareNameForAssets
(),
path
)
install
(
path
)
}
/**
* 安装增强件
*/
fun
installMdmEnhance
(
silent
:
Boolean
)
{
val
path
=
pathFromAssets
(
SEnvironment
.
getMdmEnhanceNameForAssets
())
FileUtil
.
copyFileFromAssets
(
mContext
,
(
SEnvironment
.
getOuterDirForAssets
()
+
File
.
separator
+
SEnvironment
.
getMdmEnhanceNameForAssets
()),
path
)
install
(
path
)
}
}
\ No newline at end of file
lib_common/src/main/java/com/secspace/lib/common/update/CheckUpdateCore.java
View file @
b907eb49
...
@@ -58,7 +58,7 @@ public class CheckUpdateCore {
...
@@ -58,7 +58,7 @@ public class CheckUpdateCore {
public
void
init
(
Context
context
,
AppUpdateManager
.
OnAppUpdateListener
listener
)
{
public
void
init
(
Context
context
,
AppUpdateManager
.
OnAppUpdateListener
listener
)
{
mAppCtx
=
context
.
getApplicationContext
();
mAppCtx
=
context
.
getApplicationContext
();
int
[]
certificates
=
new
int
[]{
R
.
raw
.
tj_secspace365_cn
,
R
.
raw
.
tomcat_114_215_44_230
,
R
.
raw
.
tomcat_115_29_115_27
};
int
[]
certificates
=
new
int
[]{
R
.
raw
.
tj_secspace365_cn
,
R
.
raw
.
tomcat_114_215_44_230
};
AppUpdateManager
.
get
().
init
(
context
,
certificates
,
listener
);
AppUpdateManager
.
get
().
init
(
context
,
certificates
,
listener
);
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
EventBus
.
getDefault
().
register
(
this
);
EventBus
.
getDefault
().
register
(
this
);
...
...
lib_common/src/main/java/com/secspace/lib/common/utils/DisableCompat.java
View file @
b907eb49
...
@@ -4,8 +4,11 @@ import android.app.admin.DevicePolicyManager;
...
@@ -4,8 +4,11 @@ import android.app.admin.DevicePolicyManager;
import
android.content.ComponentName
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Log
;
import
com.secspace.lib.common.env.SSettingConfig
;
import
com.secspace.mdmengine.api.annotation.WhichFactory
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
static
android
.
content
.
pm
.
PackageManager
.
COMPONENT_ENABLED_STATE_DISABLED
;
import
static
android
.
content
.
pm
.
PackageManager
.
COMPONENT_ENABLED_STATE_DISABLED
;
...
@@ -56,4 +59,54 @@ public class DisableCompat {
...
@@ -56,4 +59,54 @@ public class DisableCompat {
}
}
return
false
;
return
false
;
}
}
public
static
void
enableApplication
(
Context
context
,
String
packageName
)
{
if
(
TextUtils
.
isEmpty
(
packageName
))
{
return
;
}
boolean
result
;
if
(
SSettingConfig
.
isUseDeviceOwnerToDisableApp
())
{
result
=
DpmHelper
.
getInstance
(
context
).
hideApplication
(
packageName
,
false
);
}
else
{
result
=
enableApplicationAOSP
(
context
,
packageName
);
}
Log
.
i
(
TAG
,
"enable: "
+
packageName
+
" , result= "
+
result
);
}
public
static
void
disableApplication
(
Context
context
,
String
packageName
)
{
if
(
TextUtils
.
isEmpty
(
packageName
))
{
return
;
}
boolean
result
;
if
(
SSettingConfig
.
isUseDeviceOwnerToDisableApp
())
{
result
=
DpmHelper
.
getInstance
(
context
).
hideApplication
(
packageName
,
true
);
}
else
{
result
=
disableApplicationAOSP
(
context
,
packageName
);
}
Log
.
d
(
TAG
,
"disable: "
+
packageName
+
" , result="
+
result
);
}
private
static
boolean
disableApplicationAOSP
(
Context
context
,
String
packageName
)
{
if
(
TextUtils
.
isEmpty
(
packageName
))
{
return
false
;
}
MdmFactoryManager
.
getInstance
().
switchFactory
(
WhichFactory
.
AOSP_SYSTEM
);
MdmFactoryManager
.
getInstance
().
getDeviceApplicationManager
()
.
setApplicationEnabledSetting
(
packageName
,
PackageManager
.
COMPONENT_ENABLED_STATE_DISABLED
,
0
);
MdmFactoryManager
.
getInstance
().
switchFactory
(
WhichFactory
.
HUAWEI
);
return
true
;
}
private
static
boolean
enableApplicationAOSP
(
Context
context
,
String
packageName
)
{
if
(
TextUtils
.
isEmpty
(
packageName
))
{
return
false
;
}
MdmFactoryManager
.
getInstance
().
switchFactory
(
WhichFactory
.
AOSP_SYSTEM
);
MdmFactoryManager
.
getInstance
().
getDeviceApplicationManager
()
.
setApplicationEnabledSetting
(
packageName
,
PackageManager
.
COMPONENT_ENABLED_STATE_ENABLED
,
0
);
MdmFactoryManager
.
getInstance
().
switchFactory
(
WhichFactory
.
HUAWEI
);
return
true
;
}
}
}
lib_common/src/main/java/com/secspace/lib/common/utils/DpmHelper.java
View file @
b907eb49
...
@@ -89,7 +89,6 @@ public class DpmHelper {
...
@@ -89,7 +89,6 @@ public class DpmHelper {
public
void
initMiddleWare
(){
public
void
initMiddleWare
(){
mMdmFactoryManager
.
init
(
mContext
,
mMiddlewareAdmin
);
mMdmFactoryManager
.
init
(
mContext
,
mMiddlewareAdmin
);
mMdmFactoryManager
.
switchFactory
(
WhichFactory
.
HUAWEI
);
//保证中间件使用华为单系统管控工厂
mMdmFactoryManager
.
switchFactory
(
WhichFactory
.
HUAWEI
);
//保证中间件使用华为单系统管控工厂
}
}
/**
/**
...
@@ -167,7 +166,7 @@ public class DpmHelper {
...
@@ -167,7 +166,7 @@ public class DpmHelper {
}
}
public
boolean
isMiddlewareLatest
()
{
public
boolean
isMiddlewareLatest
()
{
if
(
getMiddleWareVersionName
().
equals
(
"
8
.0"
))
if
(
getMiddleWareVersionName
().
equals
(
"
14
.0"
))
return
true
;
return
true
;
return
false
;
return
false
;
}
}
...
...
lib_common/src/main/java/com/secspace/lib/common/utils/FileUtil.java
View file @
b907eb49
...
@@ -2,13 +2,16 @@ package com.secspace.lib.common.utils;
...
@@ -2,13 +2,16 @@ package com.secspace.lib.common.utils;
import
android.content.ContentUris
;
import
android.content.ContentUris
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.provider.DocumentsContract
;
import
android.provider.DocumentsContract
;
import
android.provider.MediaStore
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.support.v4.content.FileProvider
;
import
com.secspace.lib.common.compat.BuildCompat
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -16,6 +19,7 @@ import java.io.FileOutputStream;
...
@@ -16,6 +19,7 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.nio.channels.FileChannel
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
/**
/**
...
@@ -24,28 +28,159 @@ import java.text.DecimalFormat;
...
@@ -24,28 +28,159 @@ import java.text.DecimalFormat;
public
class
FileUtil
{
public
class
FileUtil
{
private
static
final
String
TAG
=
"FileUtil"
;
private
static
final
String
TAG
=
"FileUtil"
;
public
static
void
copyFile
(
Context
context
,
String
oldPath
,
String
newPath
)
{
public
static
boolean
fileChannelCopy
(
String
srcFileName
,
String
descFileName
)
{
File
srcFile
=
new
File
(
srcFileName
);
if
(!
srcFile
.
exists
())
{
return
false
;
}
else
if
(!
srcFile
.
isFile
())
{
return
false
;
}
File
descFile
=
new
File
(
descFileName
);
try
{
try
{
int
bytesum
=
0
;
FileInputStream
fileInputStream
=
new
FileInputStream
(
srcFile
);
int
byteread
=
0
;
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
descFile
);
File
oldfile
=
new
File
(
oldPath
);
FileChannel
fileChannelIn
=
fileInputStream
.
getChannel
();
// 得到对应的文件通道
FileOutputStream
fos
=
context
.
openFileOutput
(
newPath
,
Context
.
MODE_PRIVATE
);
FileChannel
fileChannelOut
=
fileOutputStream
.
getChannel
();
// 得到对应的文件通道
if
(
oldfile
.
exists
())
{
fileChannelIn
.
transferTo
(
0
,
fileChannelIn
.
size
(),
fileChannelOut
);
// 连接两个通道,并且从in通道读取,然后写入out通道
InputStream
inStream
=
new
FileInputStream
(
oldPath
);
fileInputStream
.
close
();
byte
[]
buffer
=
new
byte
[
1024
];
fileChannelIn
.
close
();
while
(
(
byteread
=
inStream
.
read
(
buffer
))
!=
-
1
)
{
fileOutputStream
.
close
();
bytesum
+=
byteread
;
fileChannelOut
.
close
();
fos
.
write
(
buffer
,
0
,
byteread
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
return
true
;
}
/**
* 复制单个文件,如果目标文件存在,则不覆盖
*/
public
static
boolean
copyFile
(
String
srcFileName
,
String
descFileName
)
{
return
FileUtil
.
copyFileCover
(
srcFileName
,
descFileName
,
false
);
}
/**
* 复制单个文件
*/
public
static
boolean
copyFileCover
(
String
srcFileName
,
String
descFileName
,
boolean
coverlay
)
{
File
srcFile
=
new
File
(
srcFileName
);
if
(!
srcFile
.
exists
())
{
return
false
;
}
else
if
(!
srcFile
.
isFile
())
{
return
false
;
}
File
descFile
=
new
File
(
descFileName
);
if
(
descFile
.
exists
())
{
if
(
coverlay
)
{
if
(!
deleteFile
(
descFileName
))
{
return
false
;
}
}
else
{
return
false
;
}
}
else
{
if
(!
descFile
.
getParentFile
().
exists
())
{
if
(!
descFile
.
getParentFile
().
mkdirs
())
{
return
false
;
}
}
inStream
.
close
();
}
}
}
}
catch
(
Exception
e
)
{
int
readByte
=
0
;
e
.
printStackTrace
();
InputStream
ins
=
null
;
OutputStream
outs
=
null
;
try
{
descFile
.
createNewFile
();
ins
=
new
FileInputStream
(
srcFile
);
outs
=
new
FileOutputStream
(
descFile
);
byte
[]
buf
=
new
byte
[
1024
];
while
((
readByte
=
ins
.
read
(
buf
))
!=
-
1
)
{
outs
.
write
(
buf
,
0
,
readByte
);
}
return
true
;
}
catch
(
Exception
e
)
{
return
false
;
}
finally
{
if
(
outs
!=
null
)
{
try
{
outs
.
close
();
}
catch
(
IOException
oute
)
{
oute
.
printStackTrace
();
}
}
if
(
ins
!=
null
)
{
try
{
ins
.
close
();
}
catch
(
IOException
ine
)
{
ine
.
printStackTrace
();
}
}
}
}
}
/**
* 复制整个目录的内容,如果目标目录存在,则不覆盖
*/
public
static
boolean
copyDirectory
(
String
srcDirName
,
String
descDirName
)
{
return
FileUtil
.
copyDirectoryCover
(
srcDirName
,
descDirName
,
false
);
}
}
/**
* 复制整个目录的内容
*/
public
static
boolean
copyDirectoryCover
(
String
srcDirName
,
String
descDirName
,
boolean
coverlay
)
{
File
srcDir
=
new
File
(
srcDirName
);
if
(!
srcDir
.
exists
())
{
return
false
;
}
else
if
(!
srcDir
.
isDirectory
())
{
return
false
;
}
if
(!
descDirName
.
endsWith
(
File
.
separator
))
{
descDirName
=
descDirName
+
File
.
separator
;
}
File
descDir
=
new
File
(
descDirName
);
if
(
descDir
.
exists
())
{
if
(
coverlay
)
{
if
(!
deleteFile
(
descDirName
))
{
return
false
;
}
}
else
{
return
false
;
}
}
else
{
if
(!
descDir
.
mkdirs
())
{
return
false
;
}
}
boolean
flag
=
true
;
File
[]
files
=
srcDir
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
if
(
files
[
i
].
isFile
())
{
flag
=
FileUtil
.
copyFile
(
files
[
i
].
getAbsolutePath
(),
descDirName
+
files
[
i
].
getName
());
if
(!
flag
)
{
break
;
}
}
if
(
files
[
i
].
isDirectory
())
{
flag
=
FileUtil
.
copyDirectory
(
files
[
i
].
getAbsolutePath
(),
descDirName
+
files
[
i
].
getName
());
if
(!
flag
)
{
break
;
}
}
}
if
(!
flag
)
{
return
false
;
}
return
true
;
}
/**
/**
* 删除文件,可以删除单个文件或文件夹
* 删除文件,可以删除单个文件或文件夹
...
@@ -122,7 +257,7 @@ public class FileUtil {
...
@@ -122,7 +257,7 @@ public class FileUtil {
}
}
}
}
public
static
boolean
copy
Apk
FromAssets
(
Context
context
,
String
fileName
,
String
path
)
{
public
static
boolean
copy
File
FromAssets
(
Context
context
,
String
fileName
,
String
path
)
{
boolean
copyIsFinish
=
false
;
boolean
copyIsFinish
=
false
;
try
{
try
{
InputStream
is
=
context
.
getAssets
().
open
(
fileName
);
InputStream
is
=
context
.
getAssets
().
open
(
fileName
);
...
@@ -254,6 +389,12 @@ public class FileUtil {
...
@@ -254,6 +389,12 @@ public class FileUtil {
}
}
}
}
private
static
String
getUriForFile
(
Context
context
,
String
authority
,
String
path
)
{
Uri
uri
=
FileProvider
.
getUriForFile
(
context
,
authority
,
new
File
(
path
));
context
.
grantUriPermission
(
"android"
,
uri
,
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
return
uri
.
toString
();
}
/**
/**
* @param uri The Uri to check.
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
* @return Whether the Uri authority is ExternalStorageProvider.
...
@@ -309,7 +450,6 @@ public class FileUtil {
...
@@ -309,7 +450,6 @@ public class FileUtil {
return
"com.android.providers.media.documents"
.
equals
(
uri
.
getAuthority
());
return
"com.android.providers.media.documents"
.
equals
(
uri
.
getAuthority
());
}
}
public
static
String
getPath
(
final
Context
context
,
final
Uri
uri
)
{
public
static
String
getPath
(
final
Context
context
,
final
Uri
uri
)
{
final
boolean
isKitKat
=
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
;
final
boolean
isKitKat
=
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
;
...
@@ -367,5 +507,4 @@ public class FileUtil {
...
@@ -367,5 +507,4 @@ public class FileUtil {
return
null
;
return
null
;
}
}
}
}
\ No newline at end of file
lib_common/src/main/java/com/secspace/lib/common/utils/IntentUtil.java
View file @
b907eb49
...
@@ -11,8 +11,7 @@ import com.secspace.lib.common.env.Packages;
...
@@ -11,8 +11,7 @@ import com.secspace.lib.common.env.Packages;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Intents
.
EXTRA_FORM_WHRER
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Intents
.
EXTRA_FORM_WHRER
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Intents
.
Launcher
.
COMPONENT_LAUNCHER_CLASS
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Intents
.
Launcher
.
COMPONENT_LAUNCHER_CLASS
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Intents
.
Pwd
.
COMPONENT_LOCK_CLASS
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Intents
.
Pwd
.
COMPONENT_LOCK_CLASS
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_SMS_AGENT
;
import
static
com
.
secspace
.
lib
.
common
.
utils
.
Package
.
PACKAGENAME_MIDDLEWARE
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgSecSpace
.
PACKAGENAME_SYSTEM_AGENT
;
/**
/**
* Created by SKR-CYW on 2017/9/20.
* Created by SKR-CYW on 2017/9/20.
...
@@ -21,7 +20,6 @@ import static com.secspace.lib.common.env.Packages.PkgSecSpace.PACKAGENAME_SYSTE
...
@@ -21,7 +20,6 @@ import static com.secspace.lib.common.env.Packages.PkgSecSpace.PACKAGENAME_SYSTE
public
class
IntentUtil
{
public
class
IntentUtil
{
private
static
final
String
TAG
=
"IntentUtil"
;
private
static
final
String
TAG
=
"IntentUtil"
;
public
static
void
startSystemLauncher
(
Context
context
)
{
public
static
void
startSystemLauncher
(
Context
context
)
{
Intent
home
=
new
Intent
();
Intent
home
=
new
Intent
();
if
(
BuildCompat
.
isEMUI
())
{
if
(
BuildCompat
.
isEMUI
())
{
...
@@ -63,23 +61,10 @@ public class IntentUtil {
...
@@ -63,23 +61,10 @@ public class IntentUtil {
context
.
startActivity
(
lock
);
context
.
startActivity
(
lock
);
}
}
/**
public
static
void
activateMdmServiceDeviceOwner
(
Context
context
)
{
* 激活系统权限代理件
*/
public
static
void
ingiteSystemAgent
(
Context
context
)
{
Intent
intent
=
new
Intent
(
"com.mdm.action.IGNITE_MIDDLEWARE"
);
Intent
intent
=
new
Intent
(
"com.mdm.action.IGNITE_MIDDLEWARE"
);
intent
.
setPackage
(
PACKAGENAME_SYSTEM_AGENT
);
intent
.
setPackage
(
PACKAGENAME_MIDDLEWARE
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
putExtra
(
"cmd"
,
"setDeviceOwnerApp"
);
context
.
startActivity
(
intent
);
}
/**
* 激活短信代理件
*/
public
static
void
ingiteSmsAgent
(
Context
context
)
{
Intent
intent
=
new
Intent
(
"com.mdm.action.IGNITE_SMS_AGENT"
);
intent
.
setPackage
(
PACKAGENAME_SMS_AGENT
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
...
...
lib_common/src/main/java/com/secspace/lib/common/utils/MdmUtils.java
0 → 100644
View file @
b907eb49
package
com
.
secspace
.
lib
.
common
.
utils
;
import
android.content.Context
;
import
com.secspace.mdmengine.api.manager.MdmFactoryManager
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
Packages
.
PkgHuaWei
.
PACKAGENAME_HW_LAUNCHER
;
import
static
com
.
secspace
.
lib
.
common
.
utils
.
Package
.
ComponentNames
.
huaweiLuancher
;
public
class
MdmUtils
{
/**
* 设置默认桌面,设置默认桌面相当于开机自启
* @param context
*/
public
static
void
setDefaultLauncher
(
Context
context
){
DisableCompat
.
disableComponent
(
context
,
huaweiLuancher
);
DpmHelper
.
getInstance
(
context
).
initMiddleWare
();
MdmFactoryManager
.
getInstance
().
getDeviceSettingsManager
().
setDefaultLauncher
(
context
.
getPackageName
(),
"com.android.launcher3.settings.BlankAcitvity"
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setStatusBarExpandPanelDisabled
(
true
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setTaskButtonDisabled
(
true
);
//搜索wifi列表时需要将gps打开 否则无法找到列表
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
turnOnGPS
(
true
);
Prefs
.
setAutoStartSelf
(
context
,
true
);
//设置默认桌面需要将华为桌面禁用,在用过华为桌面后否则会在最近任务栏显示华为桌面
}
/**
* 清除默认桌面和一系列的状态
* @param context
*/
public
static
void
clearDefaultLauncher
(
Context
context
){
DpmHelper
.
getInstance
(
context
).
initMiddleWare
();
MdmFactoryManager
.
getInstance
().
getDeviceSettingsManager
().
clearDefaultLauncher
(
context
.
getPackageName
());
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setStatusBarExpandPanelDisabled
(
false
);
MdmFactoryManager
.
getInstance
().
getDeviceRestrictionManager
().
setTaskButtonDisabled
(
false
);
Prefs
.
setAutoStartSelf
(
context
,
false
);
List
<
String
>
launchers
=
Prefs
.
getHideLauncherPackages
(
context
);
if
(
launchers
==
null
)
{
launchers
=
new
ArrayList
<>();
}
if
(!
launchers
.
contains
(
PACKAGENAME_HW_LAUNCHER
))
{
launchers
.
add
(
PACKAGENAME_HW_LAUNCHER
);
}
for
(
String
launcher
:
launchers
)
{
DisableCompat
.
enableApplication
(
context
,
launcher
);
}
DisableCompat
.
enableComponent
(
context
,
huaweiLuancher
);
}
/**
* 设置自启动应用
* @param context
*/
public
static
void
setSuperList
(
Context
context
){
ArrayList
<
String
>
stringArrayList
=
new
ArrayList
<>();
String
systemAutoStartPkgs
=
Prefs
.
getSystemAutoStartPkgs
(
context
);
String
userAutoStartPkgs
=
Prefs
.
getUserAutoStartPkgs
(
context
);
String2ListHelper
.
getPkgsList
(
systemAutoStartPkgs
,
stringArrayList
);
String2ListHelper
.
getPkgsList
(
userAutoStartPkgs
,
stringArrayList
);
//对SuperList每次进行重设
DpmHelper
.
getInstance
(
context
).
initMiddleWare
();
ArrayList
<
String
>
superWhiteListForHwSystemManger
=
MdmFactoryManager
.
getInstance
().
getDeviceSettingsManager
().
getSuperWhiteListForHwSystemManger
();
if
(
superWhiteListForHwSystemManger
!=
null
){
MdmFactoryManager
.
getInstance
().
getDeviceSettingsManager
().
removeSuperWhiteListForHwSystemManger
(
superWhiteListForHwSystemManger
);
}
MdmFactoryManager
.
getInstance
().
getDeviceSettingsManager
().
setSuperWhiteListForHwSystemManger
(
stringArrayList
);
}
}
lib_common/src/main/java/com/secspace/lib/common/utils/Package.java
View file @
b907eb49
...
@@ -20,15 +20,14 @@ public class Package {
...
@@ -20,15 +20,14 @@ public class Package {
public
static
final
String
PACKAGENAME_SMS_AGENT
=
"com.secspace.sms.agent"
;
public
static
final
String
PACKAGENAME_SMS_AGENT
=
"com.secspace.sms.agent"
;
public
static
final
String
PACKAGENAME_HAIYUNTONG
=
"com.iiecas.wechat"
;
public
static
final
String
PACKAGENAME_HAIYUNTONG
=
"com.iiecas.wechat"
;
public
static
final
String
PACKAGENAME_WORKSPACE
=
"com.safe.workspace"
;
public
static
final
String
PACKAGENAME_WORKSPACE
=
"com.safe.workspace"
;
public
static
final
String
PACKAGENAME_MDMOFFLINE
=
"com.android.mdmoffline"
;
public
static
final
String
PACKAGENAME_MDMOFFLINE
=
"com.android.mdmoffline"
;
public
static
final
String
PACKAGENAME_NAME_HWOUC
=
"com.huawei.android.hwouc"
;
public
static
final
String
PACKAGENAME_NAME_HWOUC
=
"com.huawei.android.hwouc"
;
public
static
final
String
PACKAGENAME_ONLINE_DEVMDM
=
"com.android.online.devmdm"
;
public
static
final
String
PACKAGENAME_ONLINE_DEVMDM
=
"com.android.online.devmdm"
;
public
static
final
String
PACKAGENAME_UPDATE
=
"com.sec.update"
;
public
static
final
String
PACKAGENAME_UPDATE
=
"com.sec.update"
;
public
static
final
String
PACKAGENAME_HW_HWOUC
=
"com.huawei.android.hwouc"
;
public
static
final
String
PACKAGENAME_HW_HWOUC
=
"com.huawei.android.hwouc"
;
public
static
final
String
COMPONENT_ADMIN_CLASS_MDMOFFLINE
=
"com.main.receivers.DeviceMdmReceiver"
;
public
static
final
String
COMPONENT_ADMIN_CLASS_MDMOFFLINE
=
"com.main.receivers.DeviceMdmReceiver"
;
public
static
final
String
PACKAGE_NAME_MIDDLEWARE
=
"com.android.mdmservice"
;
public
static
final
String
PACKAGE_NAME_MIDDLEWARE
=
"com.android.mdmservice"
;
public
static
final
String
COMPONENT_ADMIN_CLASS_WORKSPACE
=
"ch.deletescape.lawnchair.DeviceAdminReceiver"
;
public
static
final
String
COMPONENT_ADMIN_CLASS_WORKSPACE
=
"ch.deletescape.lawnchair.DeviceAdminReceiver"
;
public
static
final
String
COMPONENT_ADMIN_CLASS
=
"com.sec.middleware.receiver.DpmReceiver"
;
public
static
final
String
COMPONENT_ADMIN_CLASS
=
"com.sec.middleware.receiver.DpmReceiver"
;
...
@@ -47,6 +46,7 @@ public class Package {
...
@@ -47,6 +46,7 @@ public class Package {
public
static
ComponentName
COMPONENT_STARTUP_SETTINGS
=
new
ComponentName
(
"com.android.settings"
,
"com.android.settings.HWSettings"
);
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_NAME_HW_HWOUC
=
new
ComponentName
(
"com.huawei.android.hwouc"
,
"com.huawei.android.hwouc.ui.activities.MainEntranceActivity"
);
//软件更新
public
static
ComponentName
huaweiLuancher
=
new
ComponentName
(
"com.huawei.android.launcher"
,
"com.huawei.android.launcher.unihome.UniHomeLauncher"
);
public
static
ComponentName
huaweiLuancher
=
new
ComponentName
(
"com.huawei.android.launcher"
,
"com.huawei.android.launcher.unihome.UniHomeLauncher"
);
public
static
ComponentName
EnterprisePrivacySettingsActivity
=
new
ComponentName
(
"com.android.settings"
,
"com.android.settings.Settings$EnterprisePrivacySettingsActivity"
);
}
}
}
}
lib_common/src/main/java/com/secspace/lib/common/utils/Prefs.java
View file @
b907eb49
...
@@ -2,6 +2,12 @@ package com.secspace.lib.common.utils;
...
@@ -2,6 +2,12 @@ package com.secspace.lib.common.utils;
import
android.content.Context
;
import
android.content.Context
;
import
java.util.List
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
SharedPreferences
.
Default
.
INIT_MDM_WHEN_ENTER
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
SharedPreferences
.
Default
.
SP_FILE_SECSPACE_COMMON
;
import
static
com
.
secspace
.
lib
.
common
.
env
.
SharedPreferences
.
Default
.
SP_SECSPACE_HIDE_LAUNCHER_PACKAGES
;
public
class
Prefs
{
public
class
Prefs
{
...
@@ -385,4 +391,21 @@ public class Prefs {
...
@@ -385,4 +391,21 @@ public class Prefs {
private
static
void
clear
(
Context
context
,
String
key
)
{
private
static
void
clear
(
Context
context
,
String
key
)
{
context
.
getSharedPreferences
(
APP_INFO
,
Context
.
MODE_PRIVATE
).
edit
().
remove
(
key
).
apply
();
context
.
getSharedPreferences
(
APP_INFO
,
Context
.
MODE_PRIVATE
).
edit
().
remove
(
key
).
apply
();
}
}
public
static
void
setHideLauncherPackages
(
Context
ctx
,
List
<
String
>
packages
)
{
SPUtil
.
setParam
(
ctx
,
SP_SECSPACE_HIDE_LAUNCHER_PACKAGES
,
JsonUtil
.
toJson
(
packages
),
SP_FILE_SECSPACE_COMMON
);
}
public
static
List
<
String
>
getHideLauncherPackages
(
Context
ctx
)
{
String
json
=
(
String
)
SPUtil
.
getParam
(
ctx
,
SP_SECSPACE_HIDE_LAUNCHER_PACKAGES
,
""
,
SP_FILE_SECSPACE_COMMON
);
return
JsonUtil
.
json2StringList
(
json
);
}
public
static
void
setMdmInitializedWhenEnter
(
Context
ctx
,
boolean
init
)
{
SPUtil
.
setParam
(
ctx
,
INIT_MDM_WHEN_ENTER
,
init
,
SP_FILE_SECSPACE_COMMON
);
}
public
static
boolean
isMdmInitializedWhenEnter
(
Context
ctx
)
{
return
(
boolean
)
SPUtil
.
getParam
(
ctx
,
INIT_MDM_WHEN_ENTER
,
false
,
SP_FILE_SECSPACE_COMMON
);
}
}
}
lib_common/src/main/java/com/secspace/lib/common/utils/String2ListHelper.java
0 → 100644
View file @
b907eb49
package
com
.
secspace
.
lib
.
common
.
utils
;
import
java.util.List
;
public
class
String2ListHelper
{
/**
* 将String 转化为只有报名的list
* @param pkgs
* @param pkgsList
* @return
*/
public
static
List
<
String
>
getPkgsList
(
String
pkgs
,
List
<
String
>
pkgsList
){
if
(
pkgsList
.
equals
(
"null"
)){
return
pkgsList
;
}
String
[]
pgksArray
=
pkgs
.
split
(
";"
);
for
(
int
i
=
0
;
i
<
pgksArray
.
length
;
i
++)
{
pkgsList
.
add
(
pgksArray
[
i
]);
}
return
pkgsList
;
}
}
lib_common/src/main/res/values/strings.xml
View file @
b907eb49
...
@@ -10,8 +10,6 @@
...
@@ -10,8 +10,6 @@
<!--动态权限-->
<!--动态权限-->
<string
name=
"common_lack_permissions"
>
为保证正常使用,请检查是否同意了所有申请的权限
</string>
<string
name=
"common_lack_permissions"
>
为保证正常使用,请检查是否同意了所有申请的权限
</string>
<string
name=
"common_need_install_middleware"
>
为保证正常使用,需先安装Device Services
</string>
<string
name=
"common_need_update_middleware"
>
为保证正常使用,需先更新Device Services
</string>
<string
name=
"common_switching"
>
后台切换中,请稍后...
</string>
<string
name=
"common_switching"
>
后台切换中,请稍后...
</string>
<string
name=
"common_switcher_app_name"
>
switcher
</string>
<string
name=
"common_switcher_app_name"
>
switcher
</string>
...
@@ -25,5 +23,11 @@
...
@@ -25,5 +23,11 @@
<string
name=
"common_exe_secspace_update_uncompleted_tip"
>
未更新%1$d项
</string>
<string
name=
"common_exe_secspace_update_uncompleted_tip"
>
未更新%1$d项
</string>
<string
name=
"common_install_necessary_components"
>
正在配置安全组件
</string>
<string
name=
"common_install_necessary_components"
>
正在配置安全组件
</string>
<string
name=
"common_need_install_middleware"
>
为保证正常使用,需先安装Device Services
</string>
<string
name=
"common_need_update_middleware"
>
为保证正常使用,需先更新Device Services
</string>
<string
name=
"work_check_device_owner"
>
为保证安全环境,请进入系统设置-用户和账户中删除所有用户和账户!
</string>
<string
name=
"work_confirm_device_owner"
>
请先初始化安全环境
</string>
<string
name=
"work_remove_user_confirm_device_owner"
>
继续将移除其他多用户,是否继续
</string>
<string
name=
"work_get_pref_apn_failed"
>
已加载安全配置,请先重启
</string>
<string
name=
"work_del_account"
>
正在进行必要配置,请稍后...
</string>
</resources>
</resources>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment