Commit a73bfa4f by Baoxy

build: 完成需求

parent 1990a495
...@@ -63,7 +63,8 @@ ...@@ -63,7 +63,8 @@
android:resizeableActivity="false" android:resizeableActivity="false"
android:restoreAnyVersion="true" android:restoreAnyVersion="true"
android:roundIcon="@drawable/launcher_in" android:roundIcon="@drawable/launcher_in"
android:supportsRtl="true"> android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<!-- Intent received used to install shortcuts from other applications --> <!-- Intent received used to install shortcuts from other applications -->
<receiver <receiver
...@@ -121,29 +122,21 @@ ...@@ -121,29 +122,21 @@
<action android:name="android.content.pm.action.CONFIRM_PIN_APPWIDGET" /> <action android:name="android.content.pm.action.CONFIRM_PIN_APPWIDGET" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".settings.AppChooseActivity"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:theme="@style/AppTheme" />
<activity <activity android:name=".function.setting.AdminSettingActivity"
android:name=".settings.SettingActivity" android:theme="@style/SettingTheme"/>
android:excludeFromRecents="true" <activity android:name=".function.setting.SettingActivity"
android:launchMode="singleTask" android:theme="@style/SettingTheme"/>
android:resizeableActivity="false"
android:theme="@style/AppTheme" />
<activity <activity
android:name=".settings.wifi.WifiWhiteListActivity" android:name=".settings.wifi.WifiWhiteListActivity"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:resizeableActivity="false" android:resizeableActivity="false"
android:theme="@style/AppTheme" /> android:theme="@style/AppTheme" />
<activity <activity
android:name=".settings.ChangePwdActivity" android:name=".function.setting.ChangePwdActivity"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:resizeableActivity="false" android:resizeableActivity="false"
android:theme="@style/AppTheme" /> android:theme="@style/SettingTheme" />
<activity <activity
android:name=".settings.VerifyPwdProtectionActivity" android:name=".settings.VerifyPwdProtectionActivity"
android:excludeFromRecents="true" android:excludeFromRecents="true"
...@@ -179,19 +172,6 @@ ...@@ -179,19 +172,6 @@
android:name="com.android.launcher3.launcher_dump_provider" android:name="com.android.launcher3.launcher_dump_provider"
android:value="com.android.launcher3.LauncherProvider" /> android:value="com.android.launcher3.LauncherProvider" />
<activity
android:name=".settings.BlankAcitvity"
android:launchMode="singleInstance"
android:theme="@style/Theme.Transparent">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
</activity>
<receiver android:name=".settings.BootReceiver"> <receiver android:name=".settings.BootReceiver">
<intent-filter> <intent-filter>
<action android:name="middleware.intent.action.DPM_SERVICE_ON_CREATE" /> <action android:name="middleware.intent.action.DPM_SERVICE_ON_CREATE" />
......
...@@ -47,18 +47,19 @@ ...@@ -47,18 +47,19 @@
android:restoreAnyVersion="true" android:restoreAnyVersion="true"
android:supportsRtl="true" android:supportsRtl="true"
tools:replace="android:label" tools:replace="android:label"
android:theme="@style/LauncherTheme"> android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".settings.ManagerDisableActivity"></activity> <activity android:name=".settings.ManagerDisableActivity"></activity>
<activity <activity
android:name=".SwitchOutActivity" android:name=".function.shortcut.ExitShortcut"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:icon="@drawable/launcher_out"> android:icon="@drawable/launcher_out"
<intent-filter> android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<action android:name="android.intent.action.switch" /> <activity
<category android:name="android.intent.action.out" /> android:name=".function.shortcut.SettingShortcut"
</intent-filter> android:excludeFromRecents="true"
</activity> android:icon="@mipmap/ic_settings"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<receiver <receiver
android:name=".settings.BootReceiver" android:name=".settings.BootReceiver"
android:enabled="true" android:enabled="true"
...@@ -70,7 +71,8 @@ ...@@ -70,7 +71,8 @@
<activity android:name=".settings.ProtectionPwdActivity" /> <activity android:name=".settings.ProtectionPwdActivity" />
<activity android:name=".settings.VerifyPwdProtectionActivity" /> <activity android:name=".settings.VerifyPwdProtectionActivity" />
<activity android:name=".settings.ChangePwdActivity" /> <activity android:name=".function.setting.ChangePwdActivity"
android:theme="@style/SettingTheme"/>
<service <service
android:name=".settings.wifi.WifiScanService" android:name=".settings.wifi.WifiScanService"
...@@ -78,8 +80,36 @@ ...@@ -78,8 +80,36 @@
android:exported="true" /> android:exported="true" />
<activity android:name=".settings.wifi.WifiWhiteListActivity" /> <activity android:name=".settings.wifi.WifiWhiteListActivity" />
<activity android:name=".settings.SettingActivity" />
<activity android:name=".ManagerAuthActivity" /> <activity android:name=".function.setting.AdminSettingActivity"
android:theme="@style/SettingTheme"/>
<activity android:name=".function.setting.SettingActivity"
android:theme="@style/SettingTheme"/>
<activity android:name=".function.setting.SettingAboutActivity"
android:theme="@style/SettingTheme"/>
<activity android:name=".function.setting.PrivacyPolicyActivity"
android:theme="@style/SettingTheme"/>
<activity android:name=".function.setting.SettingPwdActivity"
android:theme="@style/SettingTheme"/>
<activity android:name=".function.setting.SettingBuyActivity"
android:theme="@style/SettingTheme">
</activity>
<activity android:name=".ManagerAuthActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<activity
android:name=".function.setting.AppChooseActivity"
android:excludeFromRecents="true"
android:resizeableActivity="false"
android:screenOrientation="landscape"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<!-- <!--
Main launcher activity. When extending only change the name, and keep all the Main launcher activity. When extending only change the name, and keep all the
attributes and intent filters the same attributes and intent filters the same
...@@ -96,7 +126,7 @@ ...@@ -96,7 +126,7 @@
android:stateNotNeeded="true" android:stateNotNeeded="true"
android:taskAffinity="" android:taskAffinity=""
android:windowSoftInputMode="adjustPan|stateUnchanged" android:windowSoftInputMode="adjustPan|stateUnchanged"
android:theme="@style/Theme.AppCompat.Light"> android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter> <intent-filter>
<!-- <action android:name="android.intent.action.MAIN" /> --> <!-- <action android:name="android.intent.action.MAIN" /> -->
...@@ -137,6 +167,31 @@ ...@@ -137,6 +167,31 @@
android:exported="true" android:exported="true"
android:readPermission="com.android.launcher3.permission.READ_SETTINGS" android:readPermission="com.android.launcher3.permission.READ_SETTINGS"
android:writePermission="com.android.launcher3.permission.WRITE_SETTINGS" /> android:writePermission="com.android.launcher3.permission.WRITE_SETTINGS" />
<activity
android:name=".settings.BlankActivity"
android:launchMode="singleInstance"
android:autoRemoveFromRecents="true"
android:theme="@style/TransparentTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.eduspace.mobilemanager.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/fileprovider_paths" />
</provider>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -125,14 +125,13 @@ dependencies { ...@@ -125,14 +125,13 @@ dependencies {
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
implementation 'com.google.code.gson:gson:2.7' implementation 'com.google.code.gson:gson:2.7'
implementation 'com.skr.library:DialogAct:1.0.0' implementation 'com.skr.library:DialogAct:1.0.0'
implementation 'pub.devrel:easypermissions:1.1.3' implementation 'pub.devrel:easypermissions:2.0.1'
api project(path: ':assetsprovider') api project(path: ':assetsprovider')
api project(path: ':lib_common') api project(path: ':lib_common')
implementation files('libs/activation.aar')
implementation files('libs/update-excludePush-release.aar')
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.qmuiteam:qmui:1.3.0"
} }
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1px"
android:color="#B22d80df" />
<solid android:color="#662d80df" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1px"
android:color="#fafafa" />
<corners android:radius="3dp" />
<solid android:color="#fafafa" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1px"
android:color="#B22d80df" />
<corners android:radius="3dp" />
<solid android:color="#662d80df" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/switch_button_open" android:state_checked="true" />
<item android:drawable="@mipmap/switch_button_close" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical" android:orientation="vertical"
tools:context=".settings.AppChooseActivity"> tools:context=".function.setting.AppChooseActivity">
<include layout="@layout/toolbar"/>
<LinearLayout
android:id="@+id/system_app"
android:layout_width="match_parent"
android:layout_height="240dp"
android:layout_below="@id/manager_toolbar"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/round_corner_rect"
android:elevation="4dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/tv_setting_title"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_marginLeft="12dp" android:layout_height="48dp"
android:text="系统应用" android:drawableStart="@mipmap/ic_back"
android:textSize="13dp"/> android:drawablePadding="10dp"
android:gravity="center_vertical"
android:onClick="close"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#363636"
android:textSize="16sp" />
<TextView <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_alignParentRight="true" android:orientation="horizontal">
android:layout_marginRight="8dp"
android:visibility="gone"
android:text="自启动"
android:textSize="13dp"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_alignParentRight="true" android:layout_weight="1"
android:layout_marginRight="50dp" android:gravity="center"
android:text="桌面显示" android:onClick="close"
android:textSize="13dp"/> android:paddingLeft="16dp"
</RelativeLayout> android:paddingRight="16dp"
<android.support.v7.widget.RecyclerView android:text="系统应用"
android:id="@+id/recyclerview_system" android:textColor="#363636"
android:layout_width="match_parent" android:textSize="16sp" />
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView> <TextView
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:gravity="center"
android:onClick="close"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="用户应用"
android:textColor="#363636"
android:textSize="16sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_above="@id/ll_btns"
android:id="@+id/user_app"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_below="@id/system_app" android:layout_weight="1"
android:layout_marginLeft="10dp" android:orientation="horizontal">
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/round_corner_rect"
android:elevation="4dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <android.support.v7.widget.RecyclerView
android:layout_width="wrap_content" android:id="@+id/recyclerview_system"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_marginLeft="12dp" android:layout_height="match_parent"
android:text="用户应用" android:layout_weight="1"
android:textSize="13dp"/> android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
tools:ignore="NestedWeights" />
<TextView <View
android:layout_width="wrap_content" android:layout_width="1dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_alignParentRight="true" android:background="#DDDFE1" />
android:layout_marginRight="8dp"
android:visibility="gone"
android:text="自启动"
android:textSize="13dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="50dp"
android:text="桌面显示"
android:textSize="13dp"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_user" android:id="@+id/recyclerview_user"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent"> android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
</android.support.v7.widget.RecyclerView> android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/ll_btns"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<Button <Button
android:layout_weight="1"
android:text="确定"
android:id="@+id/btn_sure" android:id="@+id/btn_sure"
android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> style="@style/Widget.AppCompat.Button.Borderless"
android:layout_height="48dp"
android:layout_margin="10dp"
android:elevation="3dp"
android:layout_weight="1"
android:background="#fafafa"
android:onClick="btnClick"
android:text="确定" />
<Button <Button
android:layout_weight="1"
android:text="取消"
android:id="@+id/btn_cancel" android:id="@+id/btn_cancel"
android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="48dp"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_weight="1"
android:background="#fafafa"
android:layout_margin="10dp"
android:elevation="3dp"
android:onClick="btnClick"
android:text="取消" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical" android:orientation="vertical"
tools:context="com.android.launcher3.settings.ChangePwdActivity"> tools:context="com.android.launcher3.function.setting.ChangePwdActivity">
<include layout="@layout/toolbar"/>
<TextView <TextView
android:id="@+id/tv_original_pwd" android:id="@+id/tv_setting_title"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_marginLeft="15dp" android:drawableStart="@mipmap/ic_back"
android:layout_marginTop="15dp" android:drawablePadding="10dp"
android:text="原密码" android:gravity="center_vertical"
android:textColor="#000" android:onClick="close"
android:textSize="18dp" /> android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/edu_item_about"
android:textColor="#363636"
android:textSize="16sp" />
<EditText <EditText
android:id="@+id/edit_original_pwd" android:id="@+id/et_old_pwd"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_marginLeft="15dp" android:background="#FFFFFF"
android:layout_marginTop="10dp"
android:hint="请输入旧密码" android:hint="请输入旧密码"
android:inputType="textPassword" /> android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#363636"
android:inputType="textPassword"
android:textColorHint="#8D8D8D"
android:textSize="16sp" />
<TextView <View
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="1dp"
android:layout_marginLeft="15dp" android:background="#DDDFE1" />
android:layout_marginTop="10dp"
android:text="新密码"
android:textColor="#000"
android:textSize="18dp" />
<EditText <EditText
android:id="@+id/edit_new_pwd" android:id="@+id/et_new_pwd"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_marginLeft="15dp" android:background="#FFFFFF"
android:layout_marginTop="10dp"
android:hint="请输入新密码" android:hint="请输入新密码"
android:inputType="textPassword" /> android:paddingLeft="16dp"
android:inputType="textPassword"
android:paddingRight="16dp"
android:textColor="#363636"
android:textColorHint="#8D8D8D"
android:textSize="16sp" />
<TextView <View
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="1dp"
android:layout_marginLeft="15dp" android:background="#DDDFE1" />
android:layout_marginTop="10dp"
android:text="确认新密码"
android:textColor="#000"
android:textSize="18dp" />
<EditText <EditText
android:id="@+id/edit_confirm_new_pwd" android:id="@+id/et_new_pwd_again"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_marginLeft="15dp" android:background="#FFFFFF"
android:layout_marginTop="10dp" android:inputType="textPassword"
android:hint="确认新密码" android:hint="请再次输入新密码"
android:inputType="textPassword" /> android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#363636"
android:textColorHint="#8D8D8D"
android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DDDFE1" />
<TextView <TextView
android:id="@+id/tv_confir_pwd_protection" android:id="@+id/tv_confir_pwd_protection"
android:layout_gravity="right" android:layout_width="match_parent"
android:layout_marginRight="15dp" android:layout_height="48dp"
android:gravity="right" android:gravity="center_vertical|end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:visibility="gone" android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="通过密保修改" android:text="通过密保修改"
android:textColor="#000" android:textColor="#363636"
android:textSize="18dp" /> android:textSize="14sp" />
<Button <Button
android:id="@+id/btn_sure" style="@style/Widget.AppCompat.Button.Borderless"
android:textSize="18dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_marginLeft="15dp" android:layout_marginTop="10dp"
android:layout_marginTop="20dp" android:layout_marginBottom="10dp"
android:layout_marginRight="15dp" android:background="@drawable/btn_select"
android:text="@string/work_sure" /> android:elevation="3dp"
android:onClick="btnClick"
android:gravity="center"
android:text="@string/common_sure"
android:textColor="#fafafa"
android:textSize="16sp" />
</LinearLayout> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:drawableStart="@mipmap/ic_back"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:onClick="close"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/edu_item_privacy"
android:textColor="#363636"
android:textSize="16sp" />
<WebView
android:id="@+id/wv_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical" android:orientation="vertical"
tools:context="com.android.launcher3.settings.SettingActivity"> tools:context="com.android.launcher3.function.setting.AdminSettingActivity">
<include layout="@layout/toolbar" /> <TextView
android:id="@+id/tv_setting_title"
android:layout_width="match_parent"
android:layout_height="48dp"
android:drawableStart="@mipmap/ic_back"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:onClick="close"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/edu_item_about"
android:textColor="#363636"
android:textSize="16sp" />
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -18,144 +30,61 @@ ...@@ -18,144 +30,61 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<Button <com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
android:layout_width="match_parent" android:id="@+id/grouplistview"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:text="学习空间"
android:textColor="#000"
android:visibility="gone" />
<Button
android:id="@+id/btn_version"
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_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: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"
android:visibility="gone" />
<Button
android:id="@+id/btn_wifi_whitelist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:text="wifi白名单"
android:textColor="#000"
android:visibility="gone" />
<Button
android:id="@+id/btn_manager_disable"
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_pwd"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:text="修改密码"
android:textColor="#000" />
<LinearLayout
<Button android:id="@+id/parent_buy"
android:id="@+id/btn_set_pwdcar"
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"
android:visibility="gone" />
<Button
android:id="@+id/btn_allow_new_app"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginLeft="20dp" android:orientation="vertical"
android:layout_marginTop="10dp" android:visibility="gone">
android:layout_marginRight="20dp"
android:text="新安装应用自动添加" <ImageView
android:textColor="#000" /> android:id="@+id/iv_image"
android:layout_width="wrap_content"
<Button android:layout_height="wrap_content"
android:id="@+id/btn_invisible_menu" android:layout_gravity="center_horizontal"
android:layout_width="match_parent" android:layout_marginTop="10dp"
android:layout_height="wrap_content" android:src="@mipmap/img" />
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp" <TextView
android:layout_marginRight="20dp" android:layout_width="match_parent"
android:text="桌面不显示菜单按钮" android:layout_height="48dp"
android:textColor="#000" android:layout_marginTop="10dp"
android:visibility="gone" /> android:gravity="center"
android:text="请扫描上方二维码购买正式激活码"
<Button android:textColor="#363636"
android:id="@+id/btn_auto_start" android:textSize="15sp" />
android:layout_width="match_parent"
android:layout_height="wrap_content" <Button
android:layout_marginLeft="20dp" android:id="@+id/btn_activation"
android:layout_marginTop="10dp" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_marginRight="20dp" android:layout_width="match_parent"
android:text="学习空间开机自启动" android:layout_height="48dp"
android:textColor="#000" android:layout_marginTop="10dp"
android:visibility="gone" /> android:layout_marginBottom="10dp"
android:layout_marginLeft="60dp"
<Button android:layout_marginRight="60dp"
android:id="@+id/btn_update" android:background="@drawable/rev_select"
android:layout_width="match_parent" android:elevation="3dp"
android:layout_height="wrap_content" android:gravity="center"
android:layout_marginLeft="20dp" android:text="输入激活码"
android:layout_marginTop="10dp" android:textSize="16sp"
android:layout_marginRight="20dp" android:textColor="#fafafa" />
android:text="检测更新"
android:textColor="#000" /> <TextView
android:layout_width="match_parent"
<Button android:layout_height="48dp"
android:id="@+id/btn_uninstall" android:gravity="center"
android:layout_width="match_parent" android:text="如有疑问或购买,请致电 400 826 5936"
android:layout_height="wrap_content" android:textColor="#363636"
android:layout_marginLeft="20dp" android:textIsSelectable="true"
android:layout_marginTop="10dp" android:textSize="15sp" />
android:layout_marginRight="20dp" </LinearLayout>
android:text="卸载"
android:textColor="#000" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="48dp"
android:id="@+id/parent"
android:padding="10dp"> android:padding="10dp">
<ImageView <ImageView
...@@ -13,32 +14,15 @@ ...@@ -13,32 +14,15 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
tools:src="@mipmap/ic_launcher_home" /> tools:src="@mipmap/ic_launcher_home" />
<TextView <CheckedTextView
android:id="@+id/name" android:id="@+id/name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="20dp" android:layout_marginStart="20dp"
android:gravity="center_vertical"
android:layout_toRightOf="@+id/icon" android:layout_toRightOf="@+id/icon"
android:textColor="@color/material_black" android:textColor="#363636"
android:textSize="16sp" android:textSize="16sp"
tools:text="安全域" /> tools:text="安全域" />
<CheckBox
android:id="@+id/id_cb_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="16dp"/>
<CheckBox
android:id="@+id/id_cb_autostart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android" <resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name" msgid="649227358658669779">"学习空间"</string> <string name="app_name" msgid="649227358658669779">"学习"</string>
<string name="folder_name" msgid="7371454440695724752"></string> <string name="folder_name" msgid="7371454440695724752"></string>
<string name="work_folder_name" msgid="3753320833950115786">"Work"</string> <string name="work_folder_name" msgid="3753320833950115786">"Work"</string>
<string name="activity_not_found" msgid="8071924732094499514">"未安装该应用。"</string> <string name="activity_not_found" msgid="8071924732094499514">"未安装该应用。"</string>
......
...@@ -53,4 +53,6 @@ ...@@ -53,4 +53,6 @@
<color name="alpha_70_black">#B3000000</color> <color name="alpha_70_black">#B3000000</color>
<color name="colorLine">#dedede</color> <color name="colorLine">#dedede</color>
<color name="colorBackground">#f6f6f6</color>
<color name="revBackground">#2d80df</color>
</resources> </resources>
...@@ -305,7 +305,7 @@ ...@@ -305,7 +305,7 @@
<string name="work_open">open</string> <string name="work_open">open</string>
<string name="work_back">back</string> <string name="work_back">back</string>
<string name="open_start_tip">开启后[学习空间]固定在前台不可退出,关闭可长按home退出到普通桌面,配置完成后请退出返回到移动终端管控软件主页</string> <string name="open_start_tip">开启后[学习]固定在前台不可退出,关闭可长按home退出到普通桌面,配置完成后请退出返回到移动终端管控软件主页</string>
<string name="open_new_app_tip">打开后新安装应用自动在桌面显示</string> <string name="open_new_app_tip">打开后新安装应用自动在桌面显示</string>
<string name="open">打开</string> <string name="open">打开</string>
<string name="close">关闭</string> <string name="close">关闭</string>
...@@ -313,15 +313,41 @@ ...@@ -313,15 +313,41 @@
<string name="tip">提示</string> <string name="tip">提示</string>
<string name="launcher_setting_tip">安装完成,可长按桌面进行桌面配置</string> <string name="launcher_setting_tip">安装完成,可长按桌面进行桌面配置</string>
<string name="ok">好的</string> <string name="ok">好的</string>
<string name="delete_account_tip">请先去“设置--账户” 中的所有账户和华为账户先删除,在启动学习空间</string> <string name="delete_account_tip">请先去“设置--账户” 中的所有账户和华为账户先删除,在启动学习</string>
<string name="go_delete">去删除</string> <string name="go_delete">去删除</string>
<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_version">%1$s</string>
<string name="edu_check_update">正在检测更新,请稍后</string> <string name="edu_check_update">正在检测更新,请稍后</string>
<string name="edu_uninstall">正在卸载中,请稍后</string> <string name="edu_uninstall">正在卸载中,请稍后</string>
<string name="edu_reinforce">因部分系统版本自身原因,从学习空间内设置回到空间主页时,可能会出现提示设置默认桌面的问题,可在此处确认进行加固处理</string> <string name="edu_reinforce">因部分系统版本自身原因,从学习帮内设置回到空间主页时,可能会出现提示设置默认桌面的问题,可在此处确认进行加固处理</string>
<string name="edu_uninstall_tip">继续操作将卸载学习空间,请确认是否继续</string> <string name="edu_uninstall_tip">继续操作将卸载学习帮,请确认是否继续</string>
<string name="edu_title_setting">设置</string>
<string name="edu_item_version">版本号</string>
<string name="edu_item_wallpaper">修改壁纸</string>
<string name="edu_item_func_mdm">功能管控</string>
<string name="edu_item_reinforce">桌面加固</string>
<string name="edu_item_icon">桌面应用</string>
<string name="edu_item_change_pwd">修改密码</string>
<string name="edu_item_pwd_cer">密保设置</string>
<string name="edu_item_update">检测更新</string>
<string name="edu_item_allow_app">新安装应用自动添加</string>
<string name="edu_item_uninstall">卸载</string>
<string name="edu_item_wlan">WLAN设置</string>
<string name="edu_item_appuse">应用使用情况</string>
<string name="edu_item_about">关于</string>
<string name="edu_item_buy">购买</string>
<string name="edu_item_pwd_manager">密码管理</string>
<string name="edu_item_privacy">隐私条款</string>
<string name="edu_item_unique">唯一标识</string>
<string name="edu_toast_wait">开发中</string>
<string name="edu_item_activation_type">激活类型</string>
<string name="edu_item_activation_code">激活码</string>
<string name="edu_item_activation_start">激活时间</string>
<string name="edu_item_activation_end">到期时间</string>
</resources> </resources>
...@@ -27,7 +27,12 @@ ...@@ -27,7 +27,12 @@
<item name="android:colorEdgeEffect">#FF757575</item> <item name="android:colorEdgeEffect">#FF757575</item>
</style> </style>
<style name="LauncherTheme" parent="@style/BaseLauncherTheme"></style> <style name="TransparentTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<!-- Theme for the widget container. Overridden on API 26. --> <!-- Theme for the widget container. Overridden on API 26. -->
<style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings"> <style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
...@@ -138,4 +143,30 @@ ...@@ -138,4 +143,30 @@
<item name="android:windowIsFloating">true</item> <item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item> <item name="android:backgroundDimEnabled">false</item>
</style> </style>
<style name="GroupListSectionView" parent="QMUI.GroupListSectionView">
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
</style>
<style name="SettingTheme" parent="QMUI.Compat.NoActionBar">
<!-- window 背景 -->
<item name="android:windowBackground">@color/colorBackground</item>
<!-- 设置项的字体大小 -->
<item name="qmui_common_list_item_title_h_text_size">14sp</item>
<!-- 设置项的右侧字体大小 -->
<item name="qmui_common_list_item_detail_h_text_size">12sp</item>
<!-- 字体颜色 -->
<item name="android:textColorPrimary">#363636</item>
<item name="android:textColorSecondary">#999</item>
<!-- 设置项的字体颜色 -->
<item name="qmui_config_color_gray_1">#363636</item>
<!-- 设置项的右侧字体颜色 -->
<item name="qmui_config_color_gray_5">#999</item>
<!-- 设置项的右侧箭头和文字间距 -->
<item name="qmui_common_list_item_accessory_margin_left">5dp</item>
<item name="QMUIGroupListSectionViewStyle">@style/GroupListSectionView</item>
<!-- 设置项右侧的开关 -->
<item name="qmui_common_list_item_switch">@drawable/switch_button</item>
</style>
</resources> </resources>
...@@ -23,10 +23,19 @@ ...@@ -23,10 +23,19 @@
launcher:x="0" launcher:x="0"
launcher:y="0" > launcher:y="0" >
<favorite <favorite
launcher:className="com.android.launcher3.SwitchOutActivity" launcher:className="com.android.launcher3.function.shortcut.ExitShortcut"
launcher:packageName="com.eduspace.mobilemanager"/> launcher:packageName="com.eduspace.mobilemanager"/>
</resolve> </resolve>
<resolve
launcher:container="-101"
launcher:screen="1"
launcher:x="1"
launcher:y="0" >
<favorite
launcher:className="com.android.launcher3.function.shortcut.SettingShortcut"
launcher:packageName="com.eduspace.mobilemanager"/>
</resolve>
<!--<resolve--> <!--<resolve-->
<!--launcher:container="-101"--> <!--launcher:container="-101"-->
<!--launcher:screen="1"--> <!--launcher:screen="1"-->
......
...@@ -23,10 +23,18 @@ ...@@ -23,10 +23,18 @@
launcher:x="0" launcher:x="0"
launcher:y="0" > launcher:y="0" >
<favorite <favorite
launcher:className="com.android.launcher3.SwitchOutActivity" launcher:className="com.android.launcher3.function.shortcut.ExitShortcut"
launcher:packageName="com.eduspace.mobilemanager"/>
</resolve>
<resolve
launcher:container="-101"
launcher:screen="1"
launcher:x="1"
launcher:y="0" >
<favorite
launcher:className="com.android.launcher3.function.shortcut.SettingShortcut"
launcher:packageName="com.eduspace.mobilemanager"/> launcher:packageName="com.eduspace.mobilemanager"/>
</resolve> </resolve>
<!--<resolve--> <!--<resolve-->
<!--launcher:container="-101"--> <!--launcher:container="-101"-->
<!--launcher:screen="1"--> <!--launcher:screen="1"-->
......
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="external_root"
path="" />
<root-path
name="root"
path="" />
<!--<files-path-->
<!--name="files"-->
<!--path="." />-->
<!--<cache-path name="private_cache" path="cache" />-->
<!--<external-files-path name="external_files" path="files" />-->
<external-cache-path
name="external_cache"
path="cache" />
</paths>
\ No newline at end of file
...@@ -20,7 +20,6 @@ import android.content.ComponentName; ...@@ -20,7 +20,6 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherActivityInfo;
import android.os.UserHandle; import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.util.FlagOp; import com.android.launcher3.util.FlagOp;
...@@ -102,7 +101,6 @@ public class AllAppsList { ...@@ -102,7 +101,6 @@ public class AllAppsList {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context); final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
final List<LauncherActivityInfo> matches = launcherApps.getActivityList(packageName, final List<LauncherActivityInfo> matches = launcherApps.getActivityList(packageName,
user); user);
Log.e("TAG1", "addPackage: " + matches.size() );
for (LauncherActivityInfo info : matches) { for (LauncherActivityInfo info : matches) {
add(new AppInfo(context, info, user), info); add(new AppInfo(context, info, user), info);
} }
......
...@@ -3,12 +3,9 @@ package com.android.launcher3; ...@@ -3,12 +3,9 @@ package com.android.launcher3;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import com.secspace.lib.common.function.ActivationHelper;
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.DpmHelper;
import com.secspace.lib.common.utils.ImeiUtil;
import com.secspace.lib.common.utils.PkgManager;
import com.skr.activation.api.ActivationApi;
import com.skr.update.AppUpdateManager;
public class App extends Application { public class App extends Application {
private Context mApp; private Context mApp;
...@@ -17,22 +14,11 @@ public class App extends Application { ...@@ -17,22 +14,11 @@ public class App extends Application {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
mApp = getApplicationContext(); mApp = getApplicationContext();
String imei = ImeiUtil.INSTANCE.imei(this);
ActivationApi.getInstance().init(this.getApplicationContext(), Launcher.class, imei, true);
CheckUpdateCore.get().init(this, new AppUpdateManager.OnAppUpdateListener() {
@Override
public boolean allowInstall(long l, String s) {
return true;
}
@Override
public void onInstall(String path, boolean isManual) {
PkgManager.getInstance(mApp).installByInstaller(path);
}
});
DpmHelper dpmHelper = DpmHelper.getInstance(mApp); DpmHelper dpmHelper = DpmHelper.getInstance(mApp);
if (dpmHelper.isMiddlewareLatest()) { if (dpmHelper.isMiddlewareLatest()) {
dpmHelper.initMiddleWare(); dpmHelper.initMiddleWare();
} }
ActivationHelper.INSTANCE.init(mApp);
CheckUpdateCore.get().init(this);
} }
} }
...@@ -19,13 +19,19 @@ package com.android.launcher3; ...@@ -19,13 +19,19 @@ package com.android.launcher3;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.ContextWrapper; import android.content.ContextWrapper;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.AccessibilityDelegate; import android.view.View.AccessibilityDelegate;
import android.view.Window;
import android.view.WindowManager;
import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.logging.UserEventDispatcher;
public abstract class BaseActivity extends Activity { public abstract class BaseActivity extends AppCompatActivity {
protected DeviceProfile mDeviceProfile; protected DeviceProfile mDeviceProfile;
protected UserEventDispatcher mUserEventDispatcher; protected UserEventDispatcher mUserEventDispatcher;
...@@ -61,6 +67,38 @@ public abstract class BaseActivity extends Activity { ...@@ -61,6 +67,38 @@ public abstract class BaseActivity extends Activity {
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
mAppContext = getApplicationContext(); mAppContext = getApplicationContext();
transparent();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
private void transparent() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色
Window window = this.getWindow();
View decorView = window.getDecorView();
//两个 flag 要结合使用,表示让应用的主体内容占用系统状态栏的空间
int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
} else {
Window window = this.getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
int flagTranslucentStatus = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
attributes.flags |= flagTranslucentStatus;
window.setAttributes(attributes);
}
}
}
protected void setAndroidNativeLightStatusBar(boolean dark) {
View decor = getWindow().getDecorView();
if (dark) {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}
} }
...@@ -10,26 +10,16 @@ import android.content.Intent; ...@@ -10,26 +10,16 @@ import android.content.Intent;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.InputType; import android.text.InputType;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.launcher3.settings.AppChooseActivity; import com.android.launcher3.function.setting.AdminSettingActivity;
import com.android.launcher3.settings.ErrorTimeHelper; import com.android.launcher3.settings.ErrorTimeHelper;
import com.android.launcher3.settings.VerifyPwdProtectionActivity;
import com.secspace.lib.common.utils.DpmHelper;
import com.secspace.lib.common.utils.InputUtil; import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.Prefs; import com.secspace.lib.common.utils.Prefs;
import com.secspace.lib.common.utils.SdUtil;
import com.secspace.lib.common.utils.ToastUtil; import com.secspace.lib.common.utils.ToastUtil;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import java.io.File;
import static com.android.launcher3.settings.Contants.FROM_WHERE;
public class ManagerAuthActivity extends BaseActivity { public class ManagerAuthActivity extends BaseActivity {
...@@ -93,7 +83,7 @@ public class ManagerAuthActivity extends BaseActivity { ...@@ -93,7 +83,7 @@ public class ManagerAuthActivity extends BaseActivity {
finish(); finish();
ErrorTimeHelper.getInstance(mAppContext).resetLockTimeAndCount(); ErrorTimeHelper.getInstance(mAppContext).resetLockTimeAndCount();
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass(mAppContext, AppChooseActivity.class); intent.setClass(mAppContext, AdminSettingActivity.class);
startActivity(intent); startActivity(intent);
} else { } else {
ToastUtil.showLong(mAppContext, "密码错误!"); ToastUtil.showLong(mAppContext, "密码错误!");
......
package com.android.launcher3;
import android.support.v7.app.AppCompatActivity;
public class SwitchOutActivity extends AppCompatActivity {
}
...@@ -33,7 +33,6 @@ import android.support.annotation.Nullable; ...@@ -33,7 +33,6 @@ import android.support.annotation.Nullable;
import android.util.Log; import android.util.Log;
import com.android.launcher3.compat.ShortcutConfigActivityInfo.ShortcutConfigActivityInfoVL; import com.android.launcher3.compat.ShortcutConfigActivityInfo.ShortcutConfigActivityInfoVL;
import com.android.launcher3.settings.String2ListHelper;
import com.android.launcher3.shortcuts.ShortcutInfoCompat; import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.PackageUserKey;
import com.secspace.lib.common.utils.Prefs; import com.secspace.lib.common.utils.Prefs;
...@@ -60,16 +59,9 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat { ...@@ -60,16 +59,9 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
//wangx 只显示需要的应用,这里使用包名过滤一下,再返回. 可以参考下面内容 //wangx 只显示需要的应用,这里使用包名过滤一下,再返回. 可以参考下面内容
List<LauncherActivityInfo> activityList = mLauncherApps.getActivityList(packageName, user); List<LauncherActivityInfo> activityList = mLauncherApps.getActivityList(packageName, user);
List<LauncherActivityInfo> newActivityList = new ArrayList<>(); List<LauncherActivityInfo> newActivityList = new ArrayList<>();
List<String> pkgsList = new ArrayList<>(); List<String> pkgsList = Prefs.getSystemShowAppPkgs(mContext);
pkgsList.addAll(Prefs.getUserShowAppPkgs(mContext));
String systemShowAppPkgs = Prefs.getSystemShowAppPkgs(mContext);
String userShowAppPkgs = Prefs.getUserShowAppPkgs(mContext);
if (systemShowAppPkgs.equals("null") && userShowAppPkgs.equals("null")) {
packageName = "";
} else {
String2ListHelper.getPkgsList(systemShowAppPkgs, pkgsList);
String2ListHelper.getPkgsList(userShowAppPkgs, pkgsList);
}
for (int i = 0; i < activityList.size(); i++) { for (int i = 0; i < activityList.size(); i++) {
for (String pkg : pkgsList) { for (String pkg : pkgsList) {
if (activityList.get(i).getApplicationInfo().packageName.equals(pkg)) { if (activityList.get(i).getApplicationInfo().packageName.equals(pkg)) {
......
...@@ -20,6 +20,7 @@ import android.widget.EditText; ...@@ -20,6 +20,7 @@ import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.Launcher; import com.android.launcher3.Launcher;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.secspace.lib.common.utils.Prefs; import com.secspace.lib.common.utils.Prefs;
...@@ -32,7 +33,7 @@ import java.util.regex.Pattern; ...@@ -32,7 +33,7 @@ import java.util.regex.Pattern;
/** /**
* @author huangzhencheng * @author huangzhencheng
*/ */
public class PwdPinSetPwdActivity extends AppCompatActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { public class PwdPinSetPwdActivity extends BaseActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static final String TAG = PwdPinSetPwdActivity.class.getSimpleName(); private static final String TAG = PwdPinSetPwdActivity.class.getSimpleName();
/** /**
* 字符密码正则 * 字符密码正则
...@@ -60,7 +61,6 @@ public class PwdPinSetPwdActivity extends AppCompatActivity implements View.OnCl ...@@ -60,7 +61,6 @@ public class PwdPinSetPwdActivity extends AppCompatActivity implements View.OnCl
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pwd_pin_set); setContentView(R.layout.activity_pwd_pin_set);
initView(); initView();
transparent();
} }
private void initView() { private void initView() {
...@@ -125,26 +125,4 @@ public class PwdPinSetPwdActivity extends AppCompatActivity implements View.OnCl ...@@ -125,26 +125,4 @@ public class PwdPinSetPwdActivity extends AppCompatActivity implements View.OnCl
mEditPwd.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); mEditPwd.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
} }
} }
protected void transparent() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色
Window window = this.getWindow();
View decorView = window.getDecorView();
//两个 flag 要结合使用,表示让应用的主体内容占用系统状态栏的空间
int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
} else {
Window window = this.getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
int flagTranslucentStatus = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
attributes.flags |= flagTranslucentStatus;
window.setAttributes(attributes);
}
}
}
} }
package com.android.launcher3.function.setting
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.GridLayout
import android.widget.LinearLayout
import android.widget.TextView
import com.android.launcher3.BaseActivity
import com.android.launcher3.R
import com.android.launcher3.mdm.DisableCompat
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
import com.secspace.lib.common.dialog.SwitcherDialog
import com.secspace.lib.common.event.ChangeWallPaperEvent
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.lib.common.utils.dp2px
import kotlinx.android.synthetic.main.activity_setting.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
class AdminSettingActivity : BaseActivity() {
private var mContext: Context? = null
private var icon: QMUICommonListItemView? = null
private var reinforce: QMUICommonListItemView? = null
private var pwdManager: QMUICommonListItemView? = null
private var allowApp: QMUICommonListItemView? = null
private var uninstall: QMUICommonListItemView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setAndroidNativeLightStatusBar(true)
setContentView(R.layout.activity_setting)
mContext = this
initView()
}
private fun initView() {
tv_setting_title.setText(R.string.edu_title_setting)
icon = grouplistview.createItemView(null,
getString(R.string.edu_item_icon),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
reinforce = grouplistview.createItemView(null,
getString(R.string.edu_item_reinforce),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
pwdManager = grouplistview.createItemView(null,
getString(R.string.edu_item_pwd_manager),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
allowApp = grouplistview.createItemView(null,
getString(R.string.edu_item_allow_app),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_SWITCH,
dp2px(48f))
uninstall = grouplistview.createItemView(null,
getString(R.string.edu_item_uninstall),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
// reinforce?.switch?.setOnCheckedChangeListener { _, isChecked ->
// Prefs.setReinforce(mContext, isChecked)
// if (isChecked) showTipDialog({ reinforce() }, { reinforce?.switch?.isChecked = false }, getString(R.string.edu_reinforce))
// }
allowApp?.switch?.setOnCheckedChangeListener { _, isChecked ->
Prefs.setAllowNewApp(mContext, isChecked)
if (isChecked) showTipDialog({ }, { allowApp?.switch?.isChecked = false }, getString(R.string.open_new_app_tip))
}
QMUIGroupListView.newSection(this)
.addItemView(icon) {startActivity(Intent(mContext, AppChooseActivity::class.java))}
.addItemView(reinforce) {ToastUtil.showShort(mContext, R.string.edu_toast_wait)}
.addItemView(allowApp) {}
.addItemView(pwdManager) { startActivity(Intent(mContext, SettingPwdActivity::class.java)) }
.addItemView(uninstall) { showTipDialog({ uninstall() }, { }, getString(R.string.edu_uninstall_tip)) }
.addTo(grouplistview)
}
fun close(view: View?) {
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) {
val selectedImage = data!!.data
EventBus.getDefault().postSticky(ChangeWallPaperEvent(selectedImage))
ToastUtil.showShort(this, "壁纸修改成功")
}
}
}
private inline fun showTipDialog(crossinline sure: () -> Unit, crossinline cancel: () -> 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()
cancel()
}
.setPositiveButton(R.string.work_sure) { dialog, _ ->
run {
dialog.dismiss()
sure()
}
}
.create()
if (!alertDialog.isShowing) {
alertDialog.show()
}
}
companion object {
private const val REQUEST_PICK_WALLPAPER = 10
}
}
\ No newline at end of file
package com.android.launcher3.function.setting
import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.ResolveInfo
import android.os.Bundle
import android.os.Handler
import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.LinearLayoutManager.HORIZONTAL
import android.support.v7.widget.LinearLayoutManager.VERTICAL
import android.util.Log
import android.view.View
import com.android.launcher3.BaseActivity
import com.android.launcher3.R
import com.android.launcher3.settings.AppChooseListAdapter
import com.android.launcher3.settings.AppChooseListAdapter.SYSTEM_APP_FLAG
import com.android.launcher3.settings.AppChooseListAdapter.USER_APP_FLAG
import com.android.launcher3.settings.AppModel
import com.android.launcher3.settings.BaseRecyclerViewAdapter
import com.secspace.lib.common.dialog.SwitcherDialog
import com.secspace.lib.common.function.SwitchInMdm
import com.secspace.lib.common.utils.IntentUtil
import com.secspace.lib.common.utils.Prefs
import kotlinx.android.synthetic.main.activity_app_manager.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class AppChooseActivity : BaseActivity() {
var mAppInfoAdapterSystemApp: AppChooseListAdapter? = null
var mAppInfoAdapterUserApp: AppChooseListAdapter? = null
private val mSystemApps: MutableList<AppModel> = ArrayList()
private val mUserApps: MutableList<AppModel> = ArrayList()
private lateinit var mContext: Context
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_app_manager)
mContext = this
setAndroidNativeLightStatusBar(true)
initView()
loadData()
}
fun initView() {
tv_setting_title.setText(R.string.edu_item_icon)
SwitcherDialog.getInstance(this).show("加载应用中", "Loading")
mAppInfoAdapterSystemApp = AppChooseListAdapter(SYSTEM_APP_FLAG)
mAppInfoAdapterSystemApp?.setItemViewId(R.layout.item_app_choose_list)
val linearLayoutManager = LinearLayoutManager(this, VERTICAL, false)
recyclerview_system.layoutManager = linearLayoutManager
recyclerview_system.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL))
recyclerview_system.adapter = mAppInfoAdapterSystemApp
mAppInfoAdapterUserApp = AppChooseListAdapter(USER_APP_FLAG)
mAppInfoAdapterUserApp?.setItemViewId(R.layout.item_app_choose_list)
val linearLayoutManagerUser = LinearLayoutManager(this, VERTICAL, false)
recyclerview_user.layoutManager = linearLayoutManagerUser
recyclerview_user.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL))
recyclerview_user.adapter = mAppInfoAdapterUserApp
mAppInfoAdapterSystemApp?.list = mSystemApps
mAppInfoAdapterUserApp?.list = mUserApps
}
private fun loadData() {
GlobalScope.launch(Dispatchers.IO) {
val resolveInfos: List<ResolveInfo> = packageManager.queryIntentActivities(Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER), 0)
val apps: MutableList<ApplicationInfo> = ArrayList()
resolveInfos.forEach {
apps.add(packageManager.getApplicationInfo(it.activityInfo.packageName, 0))
}
val items = ArrayList<AppModel>(apps.size)
apps.forEach {
val app = AppModel(mAppContext, it)
items.add(app)
}
loadFinished(items)
}
}
private suspend fun loadFinished(appModels: List<AppModel>) {
mSystemApps.clear()
mUserApps.clear()
appModels.forEach {
if (it.appInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0) {
mSystemApps.add(it)
} else {
if (it.applicationPackageName != this.packageName) {
mUserApps.add(it)
}
}
}
withContext(Dispatchers.Main) {
SwitcherDialog.getInstance(mContext).dismiss("Loading")
mAppInfoAdapterUserApp?.readResult(mAppContext)
mAppInfoAdapterSystemApp?.readResult(mAppContext)
mAppInfoAdapterSystemApp?.notifyDataSetChanged()
mAppInfoAdapterUserApp?.notifyDataSetChanged()
}
}
fun close(view: View?) {
finish()
}
fun btnClick(view: View?) {
when (view?.id) {
R.id.btn_sure -> {
mAppInfoAdapterSystemApp?.saveResult(mAppContext)
mAppInfoAdapterUserApp?.saveResult(mAppContext)
SwitchInMdm.addDisallowedRunningApp(this)
IntentUtil.startEduLauncher(this)
finish()
}
R.id.btn_cancel -> {
finish()
}
}
}
}
\ No newline at end of file
package com.android.launcher3.function.setting
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.SpannableString
import android.text.Spanned
import android.text.SpannedString
import android.text.TextUtils
import android.text.style.AbsoluteSizeSpan
import android.view.View
import android.widget.EditText
import com.android.launcher3.BaseActivity
import com.android.launcher3.ExtendedEditText
import com.android.launcher3.R
import com.android.launcher3.function.setting.AdminSettingActivity
import com.android.launcher3.settings.ErrorTimeHelper
import com.secspace.lib.common.utils.Prefs
import com.secspace.lib.common.utils.ToastUtil
import kotlinx.android.synthetic.main.activity_change_pwd.*
import kotlinx.android.synthetic.main.activity_setting.tv_setting_title
class ChangePwdActivity : BaseActivity() {
private var mContext: Context? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setAndroidNativeLightStatusBar(true)
setContentView(R.layout.activity_change_pwd)
mContext = this
initView()
}
private fun initView() {
tv_setting_title.setText(R.string.edu_item_change_pwd)
setHintSize(et_old_pwd, "请输入旧密码")
setHintSize(et_new_pwd, "请输入新密码")
setHintSize(et_new_pwd_again, "如有疑问或购买")
tv_confir_pwd_protection.setOnClickListener {
ToastUtil.showShort(this@ChangePwdActivity, R.string.edu_toast_wait)
}
}
private fun setHintSize(editText: EditText, text: String) {
val ss = SpannableString(text)
val ass = AbsoluteSizeSpan(16, false)
ss.setSpan(ass, 0, ss.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
editText.hint = SpannedString(ss)
}
fun btnClick(v: View) {
val originalPwd = et_old_pwd.text.toString()
val newPwd = et_new_pwd.text.toString()
val confirmNewPwd = et_new_pwd_again.text.toString()
if (!ErrorTimeHelper.getInstance(this).canShowDialog()) {
ToastUtil.showShort(this, "请在" + ErrorTimeHelper.getInstance(this).countDownTime + "秒后重试")
return
}
if (newPwd.isEmpty()) {
ToastUtil.showShort(this, "新密码不能为空")
return
}
if (confirmNewPwd.isEmpty()) {
ToastUtil.showShort(this, "验证新密码不能为空")
return
}
if (originalPwd.isEmpty()) {
ToastUtil.showShort(this, "原密码不能为空")
return
}
if (!TextUtils.equals(originalPwd, Prefs.getLoginPwd(this))) {
ToastUtil.showShort(this, "密码错误,请重新输入密码")
ErrorTimeHelper.getInstance(this).addErrorCount()
return
}
if (!TextUtils.equals(newPwd, confirmNewPwd)) {
ToastUtil.showShort(this, "两次输入密码不一致,请重新输入")
return
}
ToastUtil.showShort(this, "密码修改成功")
Prefs.setLoginPwd(this, newPwd)
//如果存在输错密码多次的情况下重置密码
ErrorTimeHelper.getInstance(this).resetLockTimeAndCount()
finish()
}
fun close(view: View?) {
finish()
}
}
\ No newline at end of file
package com.android.launcher3.function.setting
import android.os.Bundle
import android.view.View
import com.android.launcher3.BaseActivity
import com.android.launcher3.R
import kotlinx.android.synthetic.main.activity_privacy_policy.*
class PrivacyPolicyActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setAndroidNativeLightStatusBar(true)
setContentView(R.layout.activity_privacy_policy)
wv_content.loadUrl("file:///android_asset/html/privacy_policy.html")
}
fun close(view: View?) {
finish()
}
}
\ No newline at end of file
package com.android.launcher3.function.setting
import android.content.Context
import android.content.Intent
import android.icu.lang.UCharacter.DecompositionType
import android.os.Bundle
import android.view.View
import android.widget.GridLayout
import com.android.launcher3.BaseActivity
import com.android.launcher3.BuildConfig
import com.android.launcher3.R
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
import com.secspace.lib.common.update.CheckUpdateCore
import com.secspace.lib.common.utils.ImeiUtil
import com.secspace.lib.common.utils.dp2px
import kotlinx.android.synthetic.main.activity_setting.*
class SettingAboutActivity : BaseActivity() {
private var mContext: Context? = null
private var version: QMUICommonListItemView? = null
private var update: QMUICommonListItemView? = null
private var privacy: QMUICommonListItemView? = null
private var uniqueId: QMUICommonListItemView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setAndroidNativeLightStatusBar(true)
setContentView(R.layout.activity_setting)
mContext = this
initView()
}
private fun initView() {
tv_setting_title.setText(R.string.edu_item_about)
version = grouplistview.createItemView(null,
getString(R.string.edu_item_version),
String.format(getString(R.string.edu_version), BuildConfig.VERSION_NAME),
DecompositionType.VERTICAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
privacy = grouplistview.createItemView(null,
getString(R.string.edu_item_privacy),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
update = grouplistview.createItemView(null,
getString(R.string.edu_item_update),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
uniqueId = grouplistview.createItemView(null,
getString(R.string.edu_item_unique),
ImeiUtil.uniqueId(mContext, true),
DecompositionType.VERTICAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
QMUIGroupListView.newSection(mContext)
.addItemView(version) { }
.addItemView(uniqueId) { }
.addItemView(update) { CheckUpdateCore.get().checkUpdate(true) }
.addItemView(privacy) { startActivity(Intent(mContext, PrivacyPolicyActivity::class.java)) }
.addTo(grouplistview)
}
fun close(view: View?) {
finish()
}
}
\ No newline at end of file
package com.android.launcher3.function.setting
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.GridLayout
import android.widget.LinearLayout
import com.android.launcher3.BaseActivity
import com.android.launcher3.R
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
import com.secspace.lib.common.utils.*
import kotlinx.android.synthetic.main.activity_setting.*
class SettingActivity : BaseActivity() {
private var mContext: Context? = null
private var wlan: QMUICommonListItemView? = null
private var appUse: QMUICommonListItemView? = null
private var buy: QMUICommonListItemView? = null
private var about: QMUICommonListItemView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setAndroidNativeLightStatusBar(true)
setContentView(R.layout.activity_setting)
mContext = this
initView()
}
private fun initView() {
tv_setting_title.setText(R.string.edu_title_setting)
wlan = grouplistview.createItemView(null,
getString(R.string.edu_item_wlan),
null,
LinearLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
appUse = grouplistview.createItemView(null,
getString(R.string.edu_item_appuse),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
buy = grouplistview.createItemView(null,
getString(R.string.edu_item_buy),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
about = grouplistview.createItemView(null,
getString(R.string.edu_item_about),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
QMUIGroupListView.newSection(mContext)
.addItemView(wlan) { IntentUtil.startWifiSetting(mContext) }
.addItemView(appUse) { ToastUtil.showShort(mContext, R.string.edu_toast_wait) }
.addItemView(buy) { startActivity(Intent(mContext, SettingBuyActivity::class.java)) }
.addItemView(about) { startActivity(Intent(mContext, SettingAboutActivity::class.java)) }
.addTo(grouplistview)
}
fun close(view: View?) {
finish()
}
}
\ No newline at end of file
package com.android.launcher3.function.setting
import android.content.Context
import android.icu.lang.UCharacter
import android.os.Bundle
import android.view.View
import android.view.View.VISIBLE
import com.android.launcher3.BaseActivity
import com.android.launcher3.R
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
import com.secspace.lib.common.function.ActivationHelper
import com.secspace.lib.common.function.ActivationHelper.ActivationListener
import com.secspace.lib.common.function.DialogManager
import com.secspace.lib.common.utils.IntentUtil
import com.secspace.lib.common.utils.ToastUtil
import com.secspace.lib.common.utils.dp2px
import kotlinx.android.synthetic.main.activity_setting.*
class SettingBuyActivity : BaseActivity() {
private var activationType: QMUICommonListItemView? = null
private var code: QMUICommonListItemView? = null
private var timeStart: QMUICommonListItemView? = null
private var timeEnd: QMUICommonListItemView? = null
private lateinit var mContext: Context
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mContext = this
setAndroidNativeLightStatusBar(true)
setContentView(R.layout.activity_setting)
initView()
}
private fun initView() {
parent_buy.visibility = VISIBLE
tv_setting_title.setText(R.string.edu_item_buy)
activationType = grouplistview.createItemView(null,
getString(R.string.edu_item_activation_type),
ActivationHelper.getActivationType(mContext) ,
UCharacter.DecompositionType.VERTICAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
code = grouplistview.createItemView(null,
getString(R.string.edu_item_activation_code),
ActivationHelper.getActivationCode(mContext),
UCharacter.DecompositionType.VERTICAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
timeStart = grouplistview.createItemView(null,
getString(R.string.edu_item_activation_start),
ActivationHelper.getActivationTimeStart(mContext),
UCharacter.DecompositionType.VERTICAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
timeEnd = grouplistview.createItemView(null,
getString(R.string.edu_item_activation_end),
ActivationHelper.getActivationTimeEnd(mContext),
UCharacter.DecompositionType.VERTICAL,
QMUICommonListItemView.ACCESSORY_TYPE_NONE,
dp2px(48f))
QMUIGroupListView.newSection(mContext)
.addItemView(activationType) {}
.addItemView(code) { }
.addItemView(timeStart) {}
.addItemView(timeEnd) { }
.addTo(grouplistview)
btn_activation.setOnClickListener {
ActivationHelper.active(this, object: ActivationListener {
override fun activated() {
ToastUtil.showShort(mContext, "该设备已激活")
}
}, true)
}
}
fun close(view: View?) {
finish()
}
}
\ No newline at end of file
package com.android.launcher3.function.setting
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.GridLayout
import android.widget.LinearLayout
import android.widget.TextView
import com.android.launcher3.BaseActivity
import com.android.launcher3.R
import com.android.launcher3.mdm.DisableCompat
import com.android.launcher3.settings.Contants
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
import com.secspace.lib.common.dialog.SwitcherDialog
import com.secspace.lib.common.event.ChangeWallPaperEvent
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.lib.common.utils.dp2px
import kotlinx.android.synthetic.main.activity_setting.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
class SettingPwdActivity : BaseActivity(){
private var mContext: Context? = null
private var pwd: QMUICommonListItemView? = null
private var pwdCar: QMUICommonListItemView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setAndroidNativeLightStatusBar(true)
setContentView(R.layout.activity_setting)
mContext = this
initView()
}
private fun initView() {
tv_setting_title.setText(R.string.edu_item_pwd_manager)
pwd = grouplistview.createItemView(null,
getString(R.string.edu_item_change_pwd),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
pwdCar = grouplistview.createItemView(null,
getString(R.string.edu_item_pwd_cer),
null,
GridLayout.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
dp2px(48f))
QMUIGroupListView.newSection(this)
.addItemView(pwd) {
val intent1 = Intent(this, ChangePwdActivity::class.java)
intent1.putExtra(Contants.IS_SHOW_ORIGINAL_PWD, true)
startActivity(intent1)
}
.addItemView(pwdCar) {
ToastUtil.showShort(mContext, R.string.edu_toast_wait)
}
.addTo(grouplistview)
}
fun close(view: View?) {
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
package com.android.launcher3.function.shortcut
import android.support.v7.app.AppCompatActivity
class ExitShortcut : AppCompatActivity()
\ No newline at end of file
package com.android.launcher3.function.shortcut
import android.support.v7.app.AppCompatActivity
class SettingShortcut : AppCompatActivity()
\ No newline at end of file
package com.android.launcher3.mdm;
import android.content.Context;
import com.android.launcher3.Launcher;
import com.android.launcher3.settings.BlankAcitvity;
import com.android.launcher3.settings.String2ListHelper;
import com.secspace.lib.common.utils.DpmHelper;
import com.secspace.lib.common.utils.Prefs;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import java.util.ArrayList;
import java.util.List;
import static com.android.launcher3.mdm.Component.huaweiLuancher;
import static com.secspace.lib.common.env.Packages.PkgHuaWei.PACKAGENAME_HW_LAUNCHER;
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(), BlankAcitvity.class.getName());
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);
}
}
package com.android.launcher3.settings;
import android.app.LoaderManager;
import android.content.Intent;
import android.content.Loader;
import android.content.pm.ApplicationInfo;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.R;
import com.android.launcher3.mdm.MdmUtils;
import com.secspace.lib.common.event.RefreshWorkSpaceEvent;
import com.secspace.lib.common.utils.ActivityHelper;
import com.secspace.lib.common.utils.DpmHelper;
import com.secspace.lib.common.utils.Prefs;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
public class AppChooseActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<List<AppModel>>, BaseRecyclerViewAdapter.OnItemClickListener, View.OnClickListener {
public static final int APPS_LOADER_ID = 0;
public static final int SYSTEM_APP_FLAG = 0;
public static final int USER_APP_FLAG = 1;
RecyclerView mRecyclerViewSystemApp;
RecyclerView mRecyclerViewUserApp;
AppChooseListAdapter mAppInfoAdapterSystemApp;
AppChooseListAdapter mAppInfoAdapterUserApp;
private Handler mHandler = new Handler();
private List<AppModel> mApps = new ArrayList<>();
private List<AppModel> mSystemApps = new ArrayList<>();
private List<AppModel> mUserApps = new ArrayList<>();
private Button mBtnSure;
private Button mBtnCancel;
private String[] systemAppList = {""};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityHelper.getInstance().addActivity(this);
setContentView(R.layout.activity_app_manager);
mRecyclerViewSystemApp = findViewById(R.id.recyclerview_system);
mRecyclerViewUserApp = findViewById(R.id.recyclerview_user);
mBtnSure = findViewById(R.id.btn_sure);
mBtnCancel = findViewById(R.id.btn_cancel);
mBtnSure.setOnClickListener(this);
mBtnCancel.setOnClickListener(this);
findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
goHome();
finish();
}
});
TextView tvSetting = findViewById(R.id.tv_setting);
tvSetting.setVisibility(View.VISIBLE);
tvSetting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(AppChooseActivity.this, SettingActivity.class));
}
});
mAppInfoAdapterSystemApp = new AppChooseListAdapter(SYSTEM_APP_FLAG);
mAppInfoAdapterSystemApp.setItemViewId(R.layout.item_app_choose_list);
mAppInfoAdapterSystemApp.setOnItemClickListener(this);
mAppInfoAdapterUserApp = new AppChooseListAdapter(USER_APP_FLAG);
mAppInfoAdapterUserApp.setItemViewId(R.layout.item_app_choose_list);
mAppInfoAdapterUserApp.setOnItemClickListener(this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
mRecyclerViewSystemApp.setLayoutManager(linearLayoutManager);
mRecyclerViewSystemApp.setItemAnimator(new DefaultItemAnimator());
mRecyclerViewSystemApp.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL));
mRecyclerViewSystemApp.setAdapter(mAppInfoAdapterSystemApp);
LinearLayoutManager linearLayoutManagerUser = new LinearLayoutManager(this);
mRecyclerViewUserApp.setLayoutManager(linearLayoutManagerUser);
mRecyclerViewUserApp.setItemAnimator(new DefaultItemAnimator());
mRecyclerViewUserApp.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL));
mRecyclerViewUserApp.setAdapter(mAppInfoAdapterUserApp);
mAppInfoAdapterSystemApp.setList(mSystemApps);
mAppInfoAdapterUserApp.setList(mUserApps);
getLoaderManager().initLoader(APPS_LOADER_ID, null, this);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
getLoaderManager().restartLoader(APPS_LOADER_ID, null, this);
}
@Override
protected void onStop() {
super.onStop();
// EventBus.getDefault().postSticky(new RefreshWorkSpaceEvent());
}
@Override
public void onItemClick(View itemView, int position) {
}
@Override
public Loader<List<AppModel>> onCreateLoader(int i, Bundle bundle) {
return new AppsLoader(this);
}
@Override
public void onLoadFinished(android.content.Loader<List<AppModel>> loader, List<AppModel> appModels) {
mSystemApps.clear();
mUserApps.clear();
mApps = appModels;
Log.i("AppChooseActivity", "onLoadFinished: ");
for (AppModel appModel : mApps) {
if ((appModel.getAppInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
mSystemApps.add(appModel);
} else {
if (!appModel.getApplicationPackageName().equals(this.getPackageName())) {
mUserApps.add(appModel);
}
}
}
mAppInfoAdapterUserApp.readResult(getApplicationContext());
mAppInfoAdapterSystemApp.readResult(getApplicationContext());
mAppInfoAdapterSystemApp.notifyDataSetChanged();
mAppInfoAdapterUserApp.notifyDataSetChanged();
}
@Override
public void onLoaderReset(android.content.Loader<List<AppModel>> loader) {
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_sure:
mAppInfoAdapterSystemApp.saveResult(getApplicationContext());
mAppInfoAdapterUserApp.saveResult(getApplicationContext());
// MdmUtils.setSuperList(this);
goHome();
finish();
break;
case R.id.btn_cancel:
goHome();
finish();
break;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (!goHome()){
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
public boolean goHome() {
if (Prefs.isAutoStartSelf(this)){
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
return false;
}
return true;
}
}
package com.android.launcher3.settings; package com.android.launcher3.settings;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.graphics.DrawableFactory;
import com.secspace.lib.common.utils.Prefs; import com.secspace.lib.common.utils.Prefs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
public class AppChooseListAdapter extends BaseRecyclerViewAdapter<AppModel> { public class AppChooseListAdapter extends BaseRecyclerViewAdapter<AppModel> {
public static final String TAG = "AppChooseListAdapter";
public static final int SYSTEM_APP_FLAG = 0; public static final int SYSTEM_APP_FLAG = 0;
public static final int USER_APP_FLAG = 1; public static final int USER_APP_FLAG = 1;
private Set<String> flagShow = new HashSet(); public static final String TAG = "AppChooseListAdapter";
private Set<String> flagAutostart = new HashSet(); private List<String> flagShow = new ArrayList<>();
private int mAppTypeFlag; private int mAppTypeFlag;
private List<String> mAutoStartPkgs = new ArrayList<>();
private List<String> mShowAppPkgs = new ArrayList<>();
public AppChooseListAdapter(int flag) { public AppChooseListAdapter(int flag) {
mAppTypeFlag = flag; mAppTypeFlag = flag;
} }
@SuppressLint("ResourceAsColor")
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
super.onBindViewHolder(holder, position); super.onBindViewHolder(holder, position);
MyViewHolder mHolder = (MyViewHolder) holder; MyViewHolder mHolder = (MyViewHolder) holder;
ImageView imgIcon = mHolder.get(R.id.icon); ImageView imgIcon = mHolder.get(R.id.icon);
TextView tvName = mHolder.get(R.id.name); final CheckedTextView tvName = mHolder.get(R.id.name);
CheckBox checkBoxShow = mHolder.get(R.id.id_cb_show); final RelativeLayout parent = mHolder.get(R.id.parent);
CheckBox checkBoxAutostart = mHolder.get(R.id.id_cb_autostart);
imgIcon.setImageDrawable(mList.get(position).getIcon()); imgIcon.setImageDrawable(mList.get(position).getIcon());
tvName.setText(mList.get(position).getLabel()); tvName.setText(mList.get(position).getLabel());
final String packageName = mList.get(position).getApplicationPackageName(); final String packageName = mList.get(position).getApplicationPackageName();
if (flagShow != null && flagShow.contains(packageName)) {
checkBoxShow.setChecked(true);
} else {
checkBoxShow.setChecked(false);
}
if (flagAutostart != null && flagAutostart.contains(packageName)) { if (flagShow != null && flagShow.contains(packageName)) {
checkBoxAutostart.setChecked(true); tvName.setChecked(true);
parent.setBackgroundResource(R.drawable.rev_select);
} else { } else {
checkBoxAutostart.setChecked(false); tvName.setChecked(false);
parent.setBackgroundResource(R.drawable.rev_normal);
} }
checkBoxShow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { parent.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onClick(View v) {
if (buttonView.isPressed()) { tvName.toggle();
Log.i(TAG, "checkBoxShow mAppTypeFlag: " + mAppTypeFlag + " packageName: " + packageName); if (tvName.isChecked()) {
if (isChecked) {
flagShow.add(packageName); flagShow.add(packageName);
parent.setBackgroundResource(R.drawable.rev_select);
} else { } else {
flagShow.remove(packageName); flagShow.remove(packageName);
parent.setBackgroundResource(R.drawable.rev_normal);
} }
Log.i(TAG, " mAppTypeFlag: " + mAppTypeFlag + " flagShow: " + flagShow.toString());
}
} }
}); });
checkBoxAutostart.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isPressed()) {
Log.i(TAG, "checkBoxAutostart mAppTypeFlag: " + mAppTypeFlag + " packageName: " + packageName);
if (isChecked) {
flagAutostart.add(packageName);
} else {
flagAutostart.remove(packageName);
}
Log.i(TAG, " flagAutostart: " + mAppTypeFlag + " flagShow: " + flagAutostart.toString());
}
}
});
// for (int i = 0; i < mAutoStartPkgs.size(); i++) {
// if (packageName.equals(mAutoStartPkgs.get(i))) {
// checkBoxAutostart.setChecked(true);
// break;
// }
// }
//
// for (int i = 0; i < mShowAppPkgs.size(); i++) {
// if (packageName.equals(mShowAppPkgs.get(i))) {
// checkBoxShow.setChecked(true);
// break;
// }
// }
} }
public void saveResult(Context context) { public void saveResult(Context context) {
//使用preference 记录,这个需要实现一下
//用字串也行 用位也行
StringBuilder stringBuilderShowPkgs = new StringBuilder();
for (String name : flagShow) {
stringBuilderShowPkgs.append(name);
stringBuilderShowPkgs.append(";");
}
StringBuilder stringBuilderAutoStartPkgs = new StringBuilder();
for (String name : flagAutostart) {
stringBuilderAutoStartPkgs.append(name);
stringBuilderAutoStartPkgs.append(";");
}
if (mAppTypeFlag == SYSTEM_APP_FLAG) { if (mAppTypeFlag == SYSTEM_APP_FLAG) {
Prefs.setSystemAutoStartPkgs(context, stringBuilderAutoStartPkgs.toString()); Prefs.setSystemShowAppPkgs(context, flagShow);
Prefs.setSystemShowAppPkgs(context, stringBuilderShowPkgs.toString());
} else { } else {
Prefs.setUserShowAppPkgs(context, stringBuilderShowPkgs.toString()); Prefs.setUserShowAppPkgs(context, flagShow);
Prefs.setUserAutoStartPkgs(context, stringBuilderAutoStartPkgs.toString());
} }
Log.i(TAG, "stringBuilderShowPkgs: " + stringBuilderShowPkgs + mAppTypeFlag);
Log.i(TAG, "stringBuilderAutoStartPkgs: " + stringBuilderAutoStartPkgs + mAppTypeFlag);
} }
public void readResult(Context context) { public void readResult(Context context) {
List<String> systemAppPkgs = new ArrayList<>();
List<String> autoStartAppPkgs = new ArrayList<>();
String showAppPkgs;
String autoStartPkgs;
if (mAppTypeFlag == SYSTEM_APP_FLAG) { if (mAppTypeFlag == SYSTEM_APP_FLAG) {
showAppPkgs = Prefs.getSystemShowAppPkgs(context); flagShow = Prefs.getSystemShowAppPkgs(context);
autoStartPkgs = Prefs.getSystemAutoStartPkgs(context);
} else {
showAppPkgs = Prefs.getUserShowAppPkgs(context);
autoStartPkgs = Prefs.getUserAutoStartPkgs(context);
}
Log.i(TAG, "showAppPkgs: " + showAppPkgs + mAppTypeFlag);
Log.i(TAG, "autoStartPkgs: " + autoStartPkgs + mAppTypeFlag);
if (showAppPkgs.equals("null")) {
mShowAppPkgs = systemAppPkgs;
} else { } else {
String[] split = showAppPkgs.split(";"); flagShow = Prefs.getUserShowAppPkgs(context);
mShowAppPkgs = Arrays.asList(split);
}
if (autoStartPkgs.equals("null")) {
mAutoStartPkgs = autoStartAppPkgs;
} else {
String[] split = autoStartPkgs.split(";");
mAutoStartPkgs = Arrays.asList(split);
}
for (int i = 0; i < mShowAppPkgs.size(); i++) {
flagShow.add(mShowAppPkgs.get(i));
}
for (int i = 0; i < mAutoStartPkgs.size(); i++) {
flagAutostart.add(mAutoStartPkgs.get(i));
} }
} }
} }
...@@ -6,54 +6,33 @@ import android.content.Intent; ...@@ -6,54 +6,33 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import com.secspace.lib.common.event.RefreshWorkSpaceEvent; import com.secspace.lib.common.event.RefreshWorkSpaceEvent;
import com.secspace.lib.common.function.SwitchInMdm;
import com.secspace.lib.common.utils.Prefs; import com.secspace.lib.common.utils.Prefs;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import java.util.List;
public class AppInstallReceiver extends BroadcastReceiver { public class AppInstallReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
PackageManager manager = context.getPackageManager();
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) { if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
String packageName = intent.getData().getSchemeSpecificPart(); String packageName = intent.getData().getSchemeSpecificPart();
if (!TextUtils.isEmpty(packageName)){ if (!TextUtils.isEmpty(packageName)) {
Log.i("AppInstallReceiver", "onReceive: "+packageName);
if (!TextUtils.isEmpty(packageName) && !TextUtils.equals(packageName, context.getPackageName())) { if (!TextUtils.isEmpty(packageName) && !TextUtils.equals(packageName, context.getPackageName())) {
if (Prefs.isAllowNewApp(context)) { if (Prefs.isAllowNewApp(context)) {
String userShowAppPkgs = Prefs.getUserShowAppPkgs(context); List<String> pkgs = Prefs.getUserShowAppPkgs(context);
if (userShowAppPkgs.equals("null")) { pkgs.add(packageName);
userShowAppPkgs = packageName; Prefs.setUserShowAppPkgs(context, pkgs);
} else { SwitchInMdm.INSTANCE.addDisallowedRunningApp(context);
if (!userShowAppPkgs.contains(packageName)) {
userShowAppPkgs = userShowAppPkgs.concat(";" + packageName);
}
}
Prefs.setUserShowAppPkgs(context, userShowAppPkgs);
EventBus.getDefault().post(new RefreshWorkSpaceEvent()); EventBus.getDefault().post(new RefreshWorkSpaceEvent());
} }
if (Prefs.isOpenSilenceInstallTool(context)) {
if (packageName.equals("com.sec.uninstall")) {
String userShowAppPkgs = Prefs.getUserShowAppPkgs(context);
if (userShowAppPkgs.equals("null")) {
userShowAppPkgs = packageName;
} else {
if (!userShowAppPkgs.contains(packageName)) {
userShowAppPkgs = userShowAppPkgs.concat(";" + packageName);
}
}
Prefs.setUserShowAppPkgs(context, userShowAppPkgs);
Prefs.setOpenSilenceInstallTool(context,false);
}
}
EventBus.getDefault().post(new RefreshWorkSpaceEvent()); EventBus.getDefault().post(new RefreshWorkSpaceEvent());
} }
} }
} }
} }
} }
...@@ -3,8 +3,7 @@ package com.android.launcher3.settings; ...@@ -3,8 +3,7 @@ package com.android.launcher3.settings;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import java.io.File;
public class AppModel { public class AppModel {
...@@ -14,28 +13,24 @@ public class AppModel { ...@@ -14,28 +13,24 @@ public class AppModel {
private String mAppLabel; private String mAppLabel;
private Drawable mIcon; private Drawable mIcon;
private boolean mMounted;
private final File mApkFile;
private int mAppType = APP_TYPE_USER; private int mAppType = APP_TYPE_USER;
public static final int APP_TYPE_SYSTEM = 0; public static final int APP_TYPE_SYSTEM = 0;
public static final int APP_TYPE_USER = 1; public static final int APP_TYPE_USER = 1;
public AppModel(Context context, String label, Drawable icon,int appType) { public AppModel(Context context, String label, Drawable icon, int appType) {
this.mAppLabel = label; this.mAppLabel = label;
this.mIcon = icon; this.mIcon = icon;
this.mAppType = appType; this.mAppType = appType;
this.mContext = context; this.mContext = context;
mApkFile = null;
mInfo = null; mInfo = null;
} }
public AppModel(Context context, ApplicationInfo info) { public AppModel(Context context, ApplicationInfo info) {
mContext = context; mContext = context;
mInfo = info; mInfo = info;
mApkFile = new File(info.sourceDir); loadLabel();
loadIcon();
} }
public ApplicationInfo getAppInfo() { public ApplicationInfo getAppInfo() {
...@@ -55,46 +50,20 @@ public class AppModel { ...@@ -55,46 +50,20 @@ public class AppModel {
} }
public Drawable getIcon() { public Drawable getIcon() {
if (mIcon != null) { return mIcon;
return mIcon; }
}
private void loadIcon() {
mIcon = mContext.getPackageManager().getApplicationIcon(mInfo);
if (mIcon == null) { if (mIcon == null) {
if (mApkFile.exists()) { mIcon = mInfo.loadIcon(mContext.getPackageManager());
mIcon = mInfo.loadIcon(mContext.getPackageManager());
return mIcon;
} else {
mMounted = false;
}
} else if (!mMounted) {
// If the app wasn't mounted but is now mounted, reload its icon.
if (mApkFile != null && mApkFile.exists()) {
mMounted = true;
mIcon = mInfo.loadIcon(mContext.getPackageManager());
return mIcon;
}
} else {
return mIcon;
} }
return mContext.getResources().getDrawable(android.R.drawable.sym_def_app_icon);
} }
private void loadLabel() {
public void loadLabel(Context context) { mAppLabel = mInfo.loadLabel(mContext.getPackageManager()).toString();
if (mAppLabel != null) { if (TextUtils.isEmpty(mAppLabel)) {
return; mAppLabel = mInfo.name;
}
if (mAppLabel == null || !mMounted) {
if (!mApkFile.exists()) {
mMounted = false;
mAppLabel = mInfo.packageName;
} else {
mMounted = true;
CharSequence label = mInfo.loadLabel(context.getPackageManager());
mAppLabel = label != null ? label.toString() : mInfo.packageName;
}
} }
} }
} }
package com.android.launcher3.settings;
import android.content.AsyncTaskLoader;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class AppsLoader extends AsyncTaskLoader<List<AppModel>> {
List<AppModel> mInstalledApps;
final PackageManager mPm;
public AppsLoader(Context context) {
super(context);
mPm = context.getPackageManager();
}
@Override
public ArrayList<AppModel> loadInBackground() {
// retrieve the list of installed applications
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> resolveInfos = mPm.queryIntentActivities(mainIntent, 0);
List<ApplicationInfo> apps = new ArrayList<ApplicationInfo>();
for (ResolveInfo rInfo : resolveInfos) {
try {
apps.add(mPm.getApplicationInfo(rInfo.activityInfo.packageName, 0));
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
final Context context = getContext();
// create corresponding apps and load their labels
ArrayList<AppModel> items = new ArrayList<AppModel>(apps.size());
for (int i = 0; i < apps.size(); i++) {
AppModel app = new AppModel(context, apps.get(i));
app.loadLabel(context);
items.add(app);
}
Collections.sort(items, ALPHA_COMPARATOR);
return items;
}
@Override
public void deliverResult(List<AppModel> apps) {
if (isReset()) {
// An async query came in while the loader is stopped. We
// don't need the result.
if (apps != null) {
onReleaseResources(apps);
}
}
List<AppModel> oldApps = apps;
mInstalledApps = apps;
if (isStarted()) {
// If the Loader is currently started, we can immediately
// deliver its results.
super.deliverResult(apps);
}
// At this point we can release the resources associated with
// 'oldApps' if needed; now that the new result is delivered we
// know that it is no longer in use.
if (oldApps != null) {
onReleaseResources(oldApps);
}
}
@Override
protected void onStartLoading() {
if (mInstalledApps != null) {
// If we currently have a result available, deliver it
// immediately.
deliverResult(mInstalledApps);
}
if (takeContentChanged() || mInstalledApps == null ) {
// If the data has changed since the last time it was loaded
// or is not currently available, start a load.
forceLoad();
}
}
@Override
protected void onStopLoading() {
// Attempt to cancel the current load task if possible.
cancelLoad();
}
@Override
public void onCanceled(List<AppModel> apps) {
super.onCanceled(apps);
// At this point we can release the resources associated with 'apps'
// if needed.
onReleaseResources(apps);
}
@Override
protected void onReset() {
// Ensure the loader is stopped
onStopLoading();
// At this point we can release the resources associated with 'apps'
// if needed.
if (mInstalledApps != null) {
onReleaseResources(mInstalledApps);
mInstalledApps = null;
}
}
/**
* Helper method to do the cleanup work if needed, for example if we're
* using Cursor, then we should be closing it here
*
* @param apps
*/
protected void onReleaseResources(List<AppModel> apps) {
// do nothing
}
/**
* Perform alphabetical comparison of application entry objects.
*/
public static final Comparator<AppModel> ALPHA_COMPARATOR = new Comparator<AppModel>() {
private final Collator sCollator = Collator.getInstance();
@Override
public int compare(AppModel object1, AppModel object2) {
return sCollator.compare(object1.getLabel(), object2.getLabel());
}
};
}
...@@ -67,7 +67,7 @@ public class BaseRecyclerViewAdapter<T> extends RecyclerView.Adapter<RecyclerVie ...@@ -67,7 +67,7 @@ public class BaseRecyclerViewAdapter<T> extends RecyclerView.Adapter<RecyclerVie
case ITEM_TYPE_HEADER: case ITEM_TYPE_HEADER:
return null; return null;
case ITEM_TYPE_CONTENT: case ITEM_TYPE_CONTENT:
MyViewHolder contentHolder = new MyViewHolder(LayoutInflater.from(mContext).inflate(mItemViewId, null)); MyViewHolder contentHolder = new MyViewHolder(LayoutInflater.from(mContext).inflate(mItemViewId, parent, false));
setOnItemClickListener(contentHolder); setOnItemClickListener(contentHolder);
setOnItemLongClickListener(contentHolder); setOnItemLongClickListener(contentHolder);
return contentHolder; return contentHolder;
......
package com.android.launcher3.settings;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.android.launcher3.Launcher;
public class BlankAcitvity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void onResume() {
super.onResume();
Intent intent = new Intent();
intent.setAction("android.start_launcher");
intent.setPackage(this.getPackageName());
intent.setClass(this,Launcher.class);
startActivity(intent);
}
}
package com.android.launcher3.settings;
import android.content.Intent;
import com.secspace.lib.common.base.BaseActivity;
import com.secspace.lib.common.function.DialogManager;
import com.secspace.lib.common.utils.IntentUtil;
import com.secspace.lib.common.utils.Prefs;
public class BlankActivity extends BaseActivity {
@Override
public int getLayoutId() {
return 0;
}
@Override
public void initView() {
}
@Override
protected void onResume() {
super.onResume();
if (!Prefs.isPrivacyPolicyAccept(this)) {
DialogManager.getInstance().showPrivacyPolicyDialog(this);
return;
}
IntentUtil.startEduLauncher(this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
}
...@@ -14,7 +14,7 @@ public class BootReceiver extends BroadcastReceiver { ...@@ -14,7 +14,7 @@ public class BootReceiver extends BroadcastReceiver {
Log.i("BootReceiver", "onReceive: "+intent.getAction()); Log.i("BootReceiver", "onReceive: "+intent.getAction());
if(Prefs.isAutoStartSelf(context)){ if(Prefs.isAutoStartSelf(context)){
Intent intent1=new Intent(); Intent intent1=new Intent();
intent1.setClass(context,BlankAcitvity.class); intent1.setClass(context, BlankActivity.class);
intent1.setPackage(context.getPackageName()); intent1.setPackage(context.getPackageName());
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent1); context.startActivity(intent1);
......
package com.android.launcher3.settings;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.ManagerAuthActivity;
import com.android.launcher3.R;
import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.Prefs;
import com.secspace.lib.common.utils.ToastUtil;
import static com.android.launcher3.settings.Contants.FROM_WHERE;
import static com.android.launcher3.settings.Contants.IS_SHOW_ORIGINAL_PWD;
public class ChangePwdActivity extends AppCompatActivity implements View.OnClickListener {
private EditText mEditOriginalPwd;
private EditText mEditNewPwd;
private TextView mTvOriginalPwd;
private Button mBtnSure;
private boolean isShowOriginalPwd;
private Intent mIntent;
private TextView mTvTitle;
private EditText mEditConfirmNewPwd;
private TextView mTvConfirmPwdProtection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_pwd);
initView();
initListener();
initData();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.i("ChangePwdActivity", "onNewIntent: " + intent);
controlView(intent);
}
private void initData() {
controlView(getIntent());
}
private void controlView(Intent intent) {
if (intent != null) {
mIntent = intent;
isShowOriginalPwd = mIntent.getBooleanExtra(IS_SHOW_ORIGINAL_PWD, false);
if (!isShowOriginalPwd) {
mTvOriginalPwd.setVisibility(View.GONE);
mEditOriginalPwd.setVisibility(View.GONE);
mTvConfirmPwdProtection.setVisibility(View.GONE);
} else {
mTvOriginalPwd.setVisibility(View.VISIBLE);
mEditOriginalPwd.setVisibility(View.VISIBLE);
mTvConfirmPwdProtection.setVisibility(View.VISIBLE);
}
}
}
private void initListener() {
mBtnSure.setOnClickListener(this);
}
private void initView() {
mEditOriginalPwd = findViewById(R.id.edit_original_pwd);
mEditNewPwd = findViewById(R.id.edit_new_pwd);
mEditConfirmNewPwd = findViewById(R.id.edit_confirm_new_pwd);
mTvOriginalPwd = findViewById(R.id.tv_original_pwd);
mBtnSure = findViewById(R.id.btn_sure);
mTvTitle = findViewById(R.id.tv_title);
mTvConfirmPwdProtection = findViewById(R.id.tv_confir_pwd_protection);
mTvTitle.setText("修改密码");
findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
mTvConfirmPwdProtection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//这里因为是和ManagerAuthActivity 跳转一样 验证的字符串 所以依旧使用这个ManagerAuthActivity
Intent intent = new Intent(ChangePwdActivity.this, VerifyPwdProtectionActivity.class);
intent.putExtra(FROM_WHERE, ManagerAuthActivity.class.getSimpleName());
startActivity(intent);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onClick(View v) {
String newPwd = mEditNewPwd.getText().toString();
String originalPwd = mEditOriginalPwd.getText().toString();
String confirmNewPwd = mEditConfirmNewPwd.getText().toString();
if (!ErrorTimeHelper.getInstance(this).canShowDialog()) {
ToastUtil.showShort(this,"请在"+ ErrorTimeHelper.getInstance(this).getCountDownTime()+"秒后重试");
return;
}
if (TextUtils.isEmpty(newPwd)) {
ToastUtil.showShort(this, "新密码不能为空");
return;
}
if (TextUtils.isEmpty(confirmNewPwd)) {
ToastUtil.showShort(this, "验证新密码不能为空");
return;
}
if (isShowOriginalPwd) {
if (TextUtils.isEmpty(originalPwd)) {
ToastUtil.showShort(this, "原密码不能为空");
return;
}
if (TextUtils.equals(newPwd, originalPwd)) {
ToastUtil.showShort(this, "新密码和原密码不能一致");
return;
}
if (!TextUtils.equals(originalPwd, Prefs.getLoginPwd(this))) {
ToastUtil.showShort(this, "密码错误,请重新输入密码");
ErrorTimeHelper.getInstance(this).addErrorCount();
return;
}
}
if (!TextUtils.equals(newPwd, confirmNewPwd)) {
ToastUtil.showShort(this, "两次输入密码不一致,请重新输入");
return;
}
startActivity(new Intent(this, SettingActivity.class));
Prefs.setLoginPwd(this, newPwd);
//如果存在输错密码多次的情况下重置密码
ErrorTimeHelper.getInstance(this).resetLockTimeAndCount();
finish();
}
}
...@@ -10,6 +10,8 @@ import android.widget.EditText; ...@@ -10,6 +10,8 @@ import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.function.setting.ChangePwdActivity;
import com.android.launcher3.function.setting.AdminSettingActivity;
import com.secspace.lib.common.utils.InputUtil; import com.secspace.lib.common.utils.InputUtil;
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;
...@@ -83,7 +85,7 @@ public class VerifyPwdProtectionActivity extends AppCompatActivity implements Vi ...@@ -83,7 +85,7 @@ public class VerifyPwdProtectionActivity extends AppCompatActivity implements Vi
} }
String fromWhere = mIntent.getStringExtra(FROM_WHERE); String fromWhere = mIntent.getStringExtra(FROM_WHERE);
Intent intent; Intent intent;
if (!TextUtils.isEmpty(fromWhere) && TextUtils.equals(fromWhere, SettingActivity.class.getSimpleName())) { if (!TextUtils.isEmpty(fromWhere) && TextUtils.equals(fromWhere, AdminSettingActivity.class.getSimpleName())) {
intent = new Intent(this, ProtectionPwdActivity.class); intent = new Intent(this, ProtectionPwdActivity.class);
} else { } else {
intent = new Intent(this, ChangePwdActivity.class); intent = new Intent(this, ChangePwdActivity.class);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<Button <Button
android:onClick="uninstall_mobile_steward" android:onClick="uninstall_mobile_steward"
android:text="卸载学习空间" android:text="卸载学习"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_width="match_parent" android:layout_width="match_parent"
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
p {line-height:0px;}
</style>
</head>
<body>
<p><font color="black">本软件在使用过程中,为了更好的提供客户服务,基于技术必要性将会使用到如下的权限和功能:</font>
</p>
<h5><font color="black">功能权限</font>
</h5>
<p><font color="black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;应用运行管理</font></p>
<p></p>
<p><font color="black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下拉菜单的禁用/启用</font></p>
<h5><font color="black">非个人信息收集</font></h5>
<p></p>
<p><font color="black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;获取设备的唯一识别信息</font></p>
<p></p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>软件许可协议与免责声明</title>
</head>
<body>
<font size="2">
<p>欢迎使用学习帮。</p>
<p>本《免责声明与软件许可协议》(以下简称《协议》或协议)是您(以下也称为“用户”)与本公司之间关学习帮于用户下载、安装、使用的权利与义务的约定。</p>
<p>当您安装学习帮时,将会被提示是否同意接受本《协议》,请务必认真阅读和理解本《协议》中规定的所有权利和限制。除非您接受本《协议》所有条款,否则您无权激活及使用本产品。您一旦激活及使用本产品,将视为对本《协议》的接受,即表示您同意接受本《协议》各项条款的约束。</p>
<h3>一、软件许可协议</h3>
<h4>a) 产品安装及使用</h4>
<p>本产品仅可安装于安卓系统的终端上,暂不支持其他平台的安装及使用;</p>
<p>本产品支持短期试用,购买后可使用激活码或账户凭证进行永久激活;</p>
<h4>b) 权利声明</h4>
<p>本产品的一切知识产权,以及与本产品相关的所有信息内容,包括但不限于:文字表述及其组合、图标、图饰、图像、图表、色彩、界面设计、版面框架、有关数据、附加程序、印刷材料或电子文档等均为本公司所有,受著作权法和国际著作权条约以及其他知识产权法律法规的保护。</p>
<h4>c) 权利及限制</h4>
<h5>1. 您的权利</h5>
<p>当您通过合法渠道激活本产品时,您对本产品拥有有非独占的、不可转让的使用权;</p>
<h5>2. 权利限制</h5>
<p>● 禁止反向工程、反向编译和反向汇编:用户不得对本软件产品进行反向工程(Reverse Engineer)、反向编译(Decompile)或反向汇编(Disassemble),同时不得改动编译在程序文件内部的任何资源。</p>
<p>● 组件分割:本软件产品是作为一个单一产品而被授予许可使用,用户不得将各个部分分开用于任何目的。</p>
<p>● 保留权利:本协议未明示授权的其他一切权利仍归本公司所有,用户使用其他权利时必须获得本公司的书面同意。</p>
<h3>二、免责声明</h3>
<p>免责声明的内容条款我们保留在任何时候由我们全权处理、变更、修改或者以其他方式改变这个政策的权利</p>
<h4>a) 作为用户,您需要了解以下事实以及科学技术进步可能导致的产品更新、以及不同用户的使用习惯、行为方式都可能导致责任情形出现。本公司或者本软件对于以下情形,在本协议中并没有给出任何担保,也不承担任何责任:</h4>
<p>1. 本软件经过详细的测试,但不能保证与所有的软硬件系统完全兼容,不能保证本软件完全没有错误。如果出现不兼容及软件错误的情况,用户可登录软件官网论坛将情况报告作者,获得技术支持。如果无法解决兼容性问题,用户可以删除本软件。</p>
<p>2. 使用本软件产品风险由用户自行承担,在适用法律允许的最大范围内,对因使用或不能使用本软件所产生的损害及风险,包括但不限于直接或间接的个人损害、商业赢利的丧失、贸易中断、商业信息的丢失或任何其它经济损失,作者不承担任何责任。</p>
<p>3. 对于因终端系统或互联网网络故障、终端故障或病毒、信息损坏或丢失或其它任何不可抗力原因而产生损失,作者不承担任何责任。</p>
<p>4. 用户违反本协议规定,对作者公司造成损害的。作者有权采取包括但不限于中断使用许可、停止提供服务、限制使用、法律追究等措施。</p>
<h4>b) 本协议是用户和本公司之间关于本软件相关事项的最终的、完整的、排他的协议。</h4>
<h4>c) 如果本协议中的任何条款无论因何种原因完全或部分无效或不具有执行力,或违反任何适用的法律,则该条款被视为删除,但本协议的其余条款仍应有效并且有约束力。</h4>
<h4>d) 本公司有权随时根据有关法律、法规的变化、技术进步或者技术路线选择,以及公司经营状况和经营策略的调整等修改本协议。修改后的协议会随附于新版本软件。当发生有关争议时,以最新的协议文本为准。</h4>
<h4>e) 每部分的题目只为阅读之便,而不能应用于对条款内容的解释。</h4>
<h4>f) 本公司在法律允许的最大范围内对本协议拥有解释权与修改权。</h4>
<h4>g) 本协议适用中华人民共和国法律。</h4>
<h3>三、关于信息收集</h3>
<h4>a) 信息收集内容:</h4>
<h5>1. 我们不收集个人信息。</h5>
<p>个人信息包括您的地理位置、名字、地址、邮箱、电话及你设备上存储的信息,和您使用应用、服务或网站时用来识别您或别人的信息等。</p>
<h5>2. 在使用本产品时,我们会收集的您的一些非个人信息。</h5>
<p>非个人信息包括设备的唯一识别码(如sn码、imei)及其他相似信息。</p>
<h4>b) 收集到的信息的使用</h4>
<p>个人信息:因为我们不收集个人信息,所以我们不会以任何方式使用你的个人信息。</p>
<p>非个人信息:我们会使用非个人信息用于以下目的:</p>
<p>1. 产品的激活:本产品需要依据设备唯一识别码判断设备是否被激活,判断为激活状态才可正常使用本产品;</p>
<p>2. 在线升级:本产品进行在线升级时,需要根据设备唯一识别获取升级进度,以及进行单点升级时需要根据唯一识别信息进行推送;</p>
<h4>c) 关于收集到的信息的安全保护</h4>
<p>我们不收集个人信息,并且我们采用有效的措施来保护你的非个人信息,使这些信息不会在未经授权的情况下被访问和使用。</p>
<h3>四、用户使用须知</h3>
<h4>a) 软件功能</h4>
<p>本软件是基于Android(安卓)系统开发的一款软件,提供手机上安装的应用开启多个账户同时登录功能。</p>
<p>为提供适配的升级版本,在请求联网更新时,需要上传IMEI号,客户端版本号,以便提供相应的功能服务。这些数据是用于判断移动设备型号的信息,以及用户已经下载使用的程序等数据,不包含任何用户的隐私数据,也不用于确定任何的个人身份信息。</p>
<h4>b) 硬件需求:</h4>
<p>移动通讯终端设备(手机, 平板电脑)</p>
<h4>c) 本软件的开发与技术支持</h4>
<p>本软件由本公司公司提供开发与产品支持。</p>
<h4>d) 软件的修改和升级</h4>
<p>本公司保留随时为用户提供本软件的修改、升级版本的权利。</p>
<h4>e) 产品集成</h4>
<p>为了提供更多的功能扩展,本软件可能将相关的产品集成在用户界面,供用户使用。</p>
<h4>f) 用户权利限制</h4>
<h5>用户应在遵守法律及本协议的前提下使用本软件。用户无权实施包括但不限于下列行为:</h5>
<p>1. 不得删除或者改变本软件上的所有权利管理电子信息;</p>
<p>2. 不得故意避开或者破坏著作权人为保护本软件著作权而采取的技术措施;</p>
<p>3. 用户不得利用本软件误导、欺骗他人 ;</p>
<p>4. 违反国家规定,对计算机信息系统功能进行删除、修改、增加、干扰,造成计算机信息系统不能正常运行;</p>
<p>5. 未经允许,进入计算机信息网络或者使用计算机信息网络资源;</p>
<p>6. 未经允许,对计算机信息网络功能进行删除、修改或者增加的;</p>
<p>7. 未经允许,对计算机信息网络中存储、处理或者传输的数据和应用程序进行删除、修改或者增加;</p>
<p>8. 破坏本软件系统或网站的正常运行,故意传播计算机病毒等破坏性程序;</p>
<p>9. 其他任何危害计算机信息网络安全的行为。</p>
</font>
</body>
</html>
\ No newline at end of file
...@@ -26,8 +26,8 @@ MAVEN_URL=http://192.168.0.170:13000/nexus/content/repositories/releases/ ...@@ -26,8 +26,8 @@ MAVEN_URL=http://192.168.0.170:13000/nexus/content/repositories/releases/
MAVEN_URL_SNAPSHOT=http://192.168.0.170:13000/nexus/content/repositories/releases/ MAVEN_URL_SNAPSHOT=http://192.168.0.170:13000/nexus/content/repositories/releases/
#32位有符号数2147483647(10) #32位有符号数2147483647(10)
versionIntCode=2020031705 versionIntCode=2020032001
versionNameMajor=1 versionNameMajor=1
versionNameMinor=0 versionNameMinor=0
versionNamePatch=0 versionNamePatch=1
\ No newline at end of file \ No newline at end of file
...@@ -22,8 +22,7 @@ android { ...@@ -22,8 +22,7 @@ android {
} }
// 更新标准版自测 // 更新标准版自测
buildConfigField "String", "UPDATE_SERVER", "\"https://tj.secspace365.cn/SKRAC/\"" buildConfigField "String", "UPDATE_SERVER", "\"https://update.tiankuan.net/SKRAC/\""
//buildConfigField "String", "UPDATE_SERVER", "\"https://114.215.44.230/SKRAC/\""
// 1- 独立 2- 售后 // 1- 独立 2- 售后
buildConfigField "int", "UPDATE_PLATFORM", "2" buildConfigField "int", "UPDATE_PLATFORM", "2"
// 公司编号 // 公司编号
...@@ -75,12 +74,13 @@ dependencies { ...@@ -75,12 +74,13 @@ dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
api "com.android.support:support-annotations:$rootProject.ext.supportLibraryVersion" api "com.android.support:support-annotations:$rootProject.ext.supportLibraryVersion"
api "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion" api "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
api "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion" api "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
api "com.android.support:design:$rootProject.ext.supportLibraryVersion" api "com.android.support:design:$rootProject.ext.supportLibraryVersion"
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
api 'pub.devrel:easypermissions:1.1.3' api 'pub.devrel:easypermissions:2.0.1'
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.1.1' api 'org.greenrobot:eventbus:3.1.1'
...@@ -115,14 +115,14 @@ dependencies { ...@@ -115,14 +115,14 @@ dependencies {
implementation 'com.secspace:provider_mdm_engine:1.1.0.60' implementation 'com.secspace:provider_mdm_engine:1.1.0.60'
implementation files('libs/jxl.jar') implementation files('libs/jxl.jar')
implementation files('libs/activation.aar') implementation files('libs/activation.aar')
implementation files('libs/update-excludePush-release.aar')
// Room // Room
implementation 'com.tk.lib:room:1.0.2' implementation 'com.tk.lib:room:1.0.2'
// Downloader // Downloader
implementation 'com.tk.lib:downloader:1.0.8' implementation 'com.tk.lib:downloader:1.0.9'
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-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
implementation "com.qmuiteam:qmui:1.3.0"
implementation 'com.tk.lib:update-excludePush:1.1.0'
} }
\ No newline at end of file
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
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.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission <uses-permission
android:name="android.permission.GET_ACCOUNTS" android:name="android.permission.GET_ACCOUNTS"
android:maxSdkVersion="22" /> android:maxSdkVersion="22" />
...@@ -25,5 +29,7 @@ ...@@ -25,5 +29,7 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".AddDeviceAdminActivity" /> <activity android:name=".AddDeviceAdminActivity" />
<service android:name=".function.ExitService"/>
</application> </application>
</manifest> </manifest>
...@@ -164,12 +164,13 @@ public class Packages { ...@@ -164,12 +164,13 @@ public class Packages {
public static final ComponentName COMPONENTNAME_HW_SPLITSCREENAPPACTIVITY = new ComponentName(PACKAGENAME_HW_LAUNCHER, "com.huawei.android.launcher.splitscreen.SplitScreenAppActivity"); public static final ComponentName COMPONENTNAME_HW_SPLITSCREENAPPACTIVITY = new ComponentName(PACKAGENAME_HW_LAUNCHER, "com.huawei.android.launcher.splitscreen.SplitScreenAppActivity");
public static final ComponentName COMPONENT_NAME_HW_PASSWORD = new ComponentName(PACKAGENAME_HW_SECIME,"android.inputmethodservice.SoftInputWindow");//更改锁屏密码页面 public static final ComponentName COMPONENT_NAME_HW_PASSWORD = new ComponentName(PACKAGENAME_HW_SECIME,"android.inputmethodservice.SoftInputWindow");//更改锁屏密码页面
// 发送短信提示 // 发送短信提示
public static ComponentName COMPONENTNAME_HW_SYSTEM_MANAGER_REQUEST_AUTH = new ComponentName("com.huawei.systemmanager", "com.huawei.permission.monitor.sms.ui.RequestAuthActivity"); public static final ComponentName COMPONENTNAME_HW_SYSTEM_MANAGER_REQUEST_AUTH = new ComponentName("com.huawei.systemmanager", "com.huawei.permission.monitor.sms.ui.RequestAuthActivity");
public static ComponentName COMPONENTNAME_HW_SECURITY_MGR = new ComponentName("com.huawei.securitymgr", "com.huawei.permissionmgr.PermissionVerificationBaseActivity"); public static final ComponentName COMPONENTNAME_HW_SECURITY_MGR = new ComponentName("com.huawei.securitymgr", "com.huawei.permissionmgr.PermissionVerificationBaseActivity");
public static ComponentName COMPONENTNAME_HW_MOTION_SERVICE = new ComponentName(PACKAGENAME_HW_MOTION, "com.huawei.motionsettings.tutorial.MotionScenesSettings"); public static final ComponentName COMPONENTNAME_HW_MOTION_SERVICE = new ComponentName(PACKAGENAME_HW_MOTION, "com.huawei.motionsettings.tutorial.MotionScenesSettings");
public static ComponentName COMPONENTNAME_HW_SMARTSHOT_SERVICE = new ComponentName(PACKAGENAME_HW_SMARTSHOT,"com.qeexo.smartshot.CropActivity"); public static final ComponentName COMPONENTNAME_HW_SMARTSHOT_SERVICE = new ComponentName(PACKAGENAME_HW_SMARTSHOT,"com.qeexo.smartshot.CropActivity");
public static ComponentName COMPONENTNAME_HW_MULTISCREENSHOT_SERVICE = new ComponentName("com.huawei.HwMultiScreenShot","com.huawei.HwMultiScreenShot.MultiScreenShotService"); public static final ComponentName COMPONENTNAME_HW_MULTISCREENSHOT_SERVICE = new ComponentName("com.huawei.HwMultiScreenShot","com.huawei.HwMultiScreenShot.MultiScreenShotService");
public static final ComponentName COMPONENTNAME_HW_WIFI_SETTING = new ComponentName("com.android.settings","com.android.settings.Settings$WifiSettingsActivity");
} }
/** /**
...@@ -201,15 +202,4 @@ public class Packages { ...@@ -201,15 +202,4 @@ public class Packages {
public static final String HW_WALLET_FILE_NAME = "outer/HwWallet.apk"; public static final String HW_WALLET_FILE_NAME = "outer/HwWallet.apk";
public static final String HW_WALLET_VERSION = "9.0.1.304"; public static final String HW_WALLET_VERSION = "9.0.1.304";
} }
public static class Nfc{
public static String PACKAGE_HW_SIM = "com.huawei.sim";
public static String CLASS_HW_SIM = "com.huawei.sim.SimPresetApp";
public static String CLASS_HW_WALLET = "com.huawei.nfc.carrera.lifecycle.swipeservice.NFCOffHostApduService";
}
public static class ClassName{
public static final String EXIT_CLASSNAME = "com.android.launcher3.SwitchOutActivity";
}
} }
...@@ -74,6 +74,8 @@ public class SharedPreferences { ...@@ -74,6 +74,8 @@ public class SharedPreferences {
public static final String SWITCH_STATE = "switchState"; public static final String SWITCH_STATE = "switchState";
//进入域内时是否已经初始化管控一次 //进入域内时是否已经初始化管控一次
public static final String INIT_MDM_WHEN_ENTER = "initMdmWhenEnter"; public static final String INIT_MDM_WHEN_ENTER = "initMdmWhenEnter";
// 加固桌面开关
public static final String REINFORCE = "reinforce";
} }
//mdm 白名单相关 //mdm 白名单相关
......
package com.secspace.lib.common.function
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.os.Environment
import android.util.Log
import com.secspace.lib.common.utils.ImeiUtil.uniqueId
import com.skr.activation.api.ActivationApi
import com.skr.activation.constant.Constant
import com.skr.activation.constant.Constant.*
import com.skr.activation.network.linstener.CheckLocalActiveStatusListener
import com.skr.activation.utils.DesUtil
import com.skr.activation.utils.XmlUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.xmlpull.v1.XmlPullParserException
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.IOException
import java.net.URL
import java.net.URLConnection
import java.text.SimpleDateFormat
import java.util.*
const val PROBATION = "probation"
const val SP_TRIAL_ACTIVE_START_TIME = "trialActiveStartTime"
const val PROBATION_TIME: Long = 7 * 24 * 60 * 60 * 1000
object ActivationHelper {
private const val TAG = "ActivationHelper"
private val FILE_PATH = Environment.getExternalStorageDirectory().toString() + "/."
private const val PROBATION_FILE_NAME = "probation.xml"
private const val ACTIVATE_FILE_NAME = "activate.xml"
fun active(context: Activity, listener: ActivationListener, force: Boolean = false) {
ActivationApi.getInstance().isActiveFromLocalAndNet(context.packageName, object : CheckLocalActiveStatusListener {
override fun hasActivated() {
listener.activated()
}
override fun needActivate() {
Log.i(TAG, "needActivate")
GlobalScope.launch(Dispatchers.Main) {
if (force) {
ActivationApi.getInstance().setUseNormalDialog(true)
ActivationApi.getInstance().startActivateActivity(context, context.packageName, false)
return@launch
}
val isProbation = isProbationFromLocal(context)
if (isProbation) {
listener.activated()
} else {
DialogManager.getInstance().showBuyCodeDialog(context)
// ActivationApi.getInstance().setUseNormalDialog(true)
// ActivationApi.getInstance().startActivateActivity(context, context.packageName, false)
}
}
}
override fun onError() {}
})
}
private suspend fun getCurrentTimeByNet(): Long {
return withContext(Dispatchers.IO) {
Log.i(TAG, "getCurrentTimeByNet 1")
val url = URL("http://www.bjtime.cn")
Log.i(TAG, "getCurrentTimeByNet 2")
val uc: URLConnection = url.openConnection()
Log.i(TAG, "getCurrentTimeByNet 3")
uc.connect()
Log.i(TAG, "getCurrentTimeByNet 4")
val ld: Long = uc.date
Log.i(TAG, "getCurrentTimeByNet 5 : $ld")
val date = Date(ld)
Log.i(TAG, "getCurrentTimeByNet 6")
Log.e(TAG, "long:$ld, ${date.year}/${date.month}/${date.day} ${date.hours}:${date.minutes}:${date.seconds}")
return@withContext ld
}
}
private suspend fun isProbationFromLocal(context: Context): Boolean {
return withContext(Dispatchers.IO) {
val file = File(FILE_PATH + context.packageName, PROBATION_FILE_NAME)
if (!file.exists()) {
probation(context)
return@withContext true
}
val map: HashMap<String?, *>?
map = try {
XmlUtils.readMapXml(FileInputStream(file))
} catch (e: XmlPullParserException) {
Log.e(TAG, "ERROR: ${e.message}")
return@withContext false
} catch (e: IOException) {
Log.e(TAG, "ERROR: ${e.message}")
return@withContext false
}
if (map != null && map.containsKey(Constant.SP_TRIAL_ACTIVE_END_TIME)) {
val endTime: Long = DesUtil.decrypt(map[Constant.SP_TRIAL_ACTIVE_END_TIME].toString()).toLong()
// val currentTime = getCurrentTimeByNet()
val currentTime: Long = System.currentTimeMillis()
if (currentTime > endTime) {
return@withContext false
}
return@withContext true
}
return@withContext false
}
}
private suspend fun probation(context: Context) {
val map: MutableMap<String?, String?> = HashMap()
Log.i(TAG, "probation before")
// val currentTime = getCurrentTimeByNet()
val currentTime: Long = System.currentTimeMillis()
Log.i(TAG, "probation after")
val endTime = currentTime + PROBATION_TIME
map[Constant.SP_IS_ACTIVE] = DesUtil.encrypt(PROBATION)
map[Constant.SP_TRIAL_ACTIVE_END_TIME] = DesUtil.encrypt(endTime.toString())
map[Constant.SP_ACTIVE_CODE] = DesUtil.encrypt("无")
map[SP_TRIAL_ACTIVE_START_TIME] = DesUtil.encrypt(currentTime.toString())
try {
val fileDir = File(FILE_PATH + context.packageName)
if (!fileDir.exists()) {
fileDir.mkdirs()
}
val file = File(fileDir, PROBATION_FILE_NAME)
if (!file.exists()) {
file.createNewFile()
}
XmlUtils.writeMapXml(map, FileOutputStream(file))
} catch (e: XmlPullParserException) {
e.printStackTrace()
} catch (e: IOException) {
e.printStackTrace()
}
}
private fun getValueByXmlKey(context: Context, key: String, fileName: String): String {
val file = File(FILE_PATH + context.packageName, fileName)
if (!file.exists()) {
Log.d(TAG, "getValueByXmlKey $fileName 不存在")
return ""
}
val map: HashMap<String, *>
map = try {
XmlUtils.readMapXml(FileInputStream(file))
} catch (e: XmlPullParserException) {
Log.d(TAG, "Error ${e.message}")
return ""
} catch (e: IOException) {
Log.d(TAG, "Error ${e.message}")
return ""
}
Log.i(TAG, "getValueByXmlKey ${map.keys.toTypedArray().contentToString()}, key is $key, ${map.containsKey(key)}")
if (map != null && map.containsKey(key)) {
val result = map[key]
if (result != null) {
return DesUtil.decrypt(result.toString())
}
}
return ""
}
fun getActivationType(context: Context): String? {
val activationState = getValueByXmlKey(context, SP_IS_ACTIVE, ACTIVATE_FILE_NAME)
if (activationState.isNotEmpty()) {
return when (activationState) {
ACTIVE_TYPE_RELEASE_CODE -> "正式激活"
ACTIVE_TYPE_TRIAL_CODE -> "试用激活"
CAN_NOT_ACTIVE -> "无法激活"
else -> "激活异常"
}
}
val state = getValueByXmlKey(context, SP_IS_ACTIVE, PROBATION_FILE_NAME)
if (state == PROBATION)
return "试用期"
return "已过期"
}
fun getActivationCode(context: Context): String? {
val activationCode = getValueByXmlKey(context, SP_ACTIVE_CODE, ACTIVATE_FILE_NAME)
if (activationCode.isNotEmpty()) {
return activationCode
}
return getValueByXmlKey(context, SP_ACTIVE_CODE, PROBATION_FILE_NAME)
}
fun getActivationTimeStart(context: Context): String? {
val time = getValueByXmlKey(context, SP_TRIAL_ACTIVE_START_TIME, PROBATION_FILE_NAME)
if(time.isEmpty()) return "未获取到时间"
val longTime: Long? = time.toLong()
val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US)
return format.format(longTime?.let { Date(it) })
}
fun getActivationTimeEnd(context: Context): String? {
val activationEndTime = getValueByXmlKey(context, SP_TRIAL_ACTIVE_END_TIME, ACTIVATE_FILE_NAME)
if (activationEndTime.isNotEmpty()) {
return activationEndTime.replace(" ", " ")
}
val time = getValueByXmlKey(context, SP_TRIAL_ACTIVE_END_TIME, PROBATION_FILE_NAME)
if(time.isEmpty()) return "未获取到时间"
val longTime: Long? = time.toLong()
val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US)
return format.format(longTime?.let { Date(it) })
}
@SuppressLint("PrivateApi")
fun init(context: Context) {
val imei = uniqueId(context, false)
ActivationApi.getInstance().init(context, Class.forName("com.android.launcher3.Launcher"), imei, true)
}
interface ActivationListener {
fun activated()
}
}
\ No newline at end of file
package com.secspace.lib.common.function;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import com.secspace.lib.common.R;
import com.secspace.lib.common.utils.IntentUtil;
import com.secspace.lib.common.utils.Prefs;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class BuyCodeDialog implements DialogInterface.OnDismissListener, View.OnClickListener {
private static final String TAG = "BuyCodeDialog";
private Activity mActivity;
private Context mContext;
private android.app.AlertDialog mDialog;
private Button btnAccept;
private View layout;
public BuyCodeDialog(Activity activity) {
this.mActivity = activity;
mContext = activity.getApplicationContext();
}
public BuyCodeDialog show() {
if (mDialog == null) {
initView();
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(mActivity);
mDialog = builder.create();
mDialog.setCancelable(false);
Window window = mDialog.getWindow();
window.setBackgroundDrawableResource(R.drawable.dialog_corner_bg);
mDialog.setView(layout);
mDialog.show();
}
if (!mDialog.isShowing()) {
mDialog.show();
}
return this;
}
private void initView() {
LayoutInflater inflater = LayoutInflater.from(mActivity);
layout = inflater.inflate(R.layout.buycode_layout, null);
btnAccept = layout.findViewById(R.id.btn_accept);
btnAccept.setOnClickListener(this);
}
public void dismiss() {
if (mDialog != null && mDialog.isShowing())
mDialog.dismiss();
}
@Override
public void onDismiss(DialogInterface dialog) {
mActivity = null;
mDialog = null;
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.btn_accept) {
ActivationHelper.INSTANCE.active(mActivity, new ActivationHelper.ActivationListener() {
@Override
public void activated() {
IntentUtil.startEduLauncher(mContext);
}
}, true);
SwitchOutMdm.INSTANCE.exit(mContext);
dismiss();
}
}
}
...@@ -121,4 +121,12 @@ public class DialogManager { ...@@ -121,4 +121,12 @@ public class DialogManager {
mSimpleDialog.dismiss(); mSimpleDialog.dismiss();
} }
} }
public void showPrivacyPolicyDialog(Activity activity) {
new PrivacyPolicyDialog(activity).show();
}
public void showBuyCodeDialog(Activity activity) {
new BuyCodeDialog(activity).show();
}
} }
package com.secspace.lib.common.function
import android.app.Service
import android.content.Context
import android.content.Intent
import android.os.IBinder
import android.util.Log
import com.secspace.lib.common.dialog.SwitcherDialog
import com.secspace.lib.common.utils.IntentUtil
import com.secspace.lib.common.utils.Prefs
import kotlinx.coroutines.*
class ExitService : Service() {
private val TAG = "ExitService"
private var mAppContext: Context? = null
private var outing = false
override fun onBind(intent: Intent?): IBinder? {
return null
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.d(TAG, "exit start")
mAppContext = this
if (outing)
return super.onStartCommand(intent, flags, startId)
outing = true
SwitcherDialog.getInstance(mAppContext).show(null, "Exit")
GlobalScope.launch(Dispatchers.IO) {
Prefs.setMdmInitializedWhenEnter(mAppContext, false)
WorkManager.exit(mAppContext)
delay(1500)
withContext(Dispatchers.Main) {
IntentUtil.startSystemLauncher(mAppContext)
SwitcherDialog.getInstance(mAppContext).dismiss("Exit")
outing = false
Log.d(TAG, "exit end")
}
}
return super.onStartCommand(intent, flags, startId)
}
}
\ No newline at end of file
package com.secspace.lib.common.function;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import com.secspace.lib.common.R;
import com.secspace.lib.common.utils.IntentUtil;
import com.secspace.lib.common.utils.Prefs;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class PrivacyPolicyDialog implements DialogInterface.OnDismissListener, View.OnClickListener {
private static final String TAG = "PrivacyPolicyDialog";
private Activity mActivity;
private android.app.AlertDialog mDialog;
private TextView permissionText;
private TextView statementText;
private TextView statementText1;
private Button btnExit;
private Button btnAccept;
private View layout;
public PrivacyPolicyDialog(Activity activity) {
this.mActivity = activity;
}
public PrivacyPolicyDialog show() {
if (mDialog == null) {
initView();
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(mActivity);
mDialog = builder.create();
mDialog.setCancelable(false);
Window window = mDialog.getWindow();
window.setBackgroundDrawableResource(R.drawable.dialog_corner_bg);
String filename = "html/permission_statement.html";
String content = getStringFromHtmlFile(mActivity, filename);
permissionText.setText(Html.fromHtml(content));
btnExit.setOnClickListener(this);
btnAccept.setOnClickListener(this);
statementText.setMovementMethod(LinkMovementMethod.getInstance());
statementText1.setMovementMethod(LinkMovementMethod.getInstance());
CharSequence text = statementText.getText();
CharSequence text1 = statementText1.getText();
setText(statementText, text);
setText(statementText1, text1);
mDialog.setView(layout);
mDialog.show();
}
if (!mDialog.isShowing()) {
mDialog.show();
}
return this;
}
private void initView() {
LayoutInflater inflater = LayoutInflater.from(mActivity);
layout = inflater.inflate(R.layout.privacypolicydialog_layout, null);
permissionText = layout.findViewById(R.id.content_permissions);
statementText = layout.findViewById(R.id.read_statement);
statementText1 = layout.findViewById(R.id.read_statement1);
btnExit = layout.findViewById(R.id.btn_exit);
btnAccept = layout.findViewById(R.id.btn_accept);
}
public void setText(TextView view, CharSequence text) {
if (text instanceof Spannable) {
int end = text.length();
Spannable sp = (Spannable) text;
URLSpan[] urls = sp.getSpans(0, end, URLSpan.class);
SpannableStringBuilder style = new SpannableStringBuilder(text);
style.clearSpans();
for (URLSpan url : urls) {
MyURLSpan myURLSpan = new MyURLSpan();
style.setSpan(myURLSpan, sp.getSpanStart(url), sp.getSpanEnd(url), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
}
view.setText(style);
}
}
public void dismiss() {
if (mDialog != null && mDialog.isShowing())
mDialog.dismiss();
}
@Override
public void onDismiss(DialogInterface dialog) {
mActivity = null;
mDialog = null;
}
public static String getStringFromHtmlFile(Context context, String filePath) {
String result = "";
if (null == context || null == filePath) {
return result;
}
InputStream stream = null;
BufferedReader reader = null;
InputStreamReader streamReader = null;
try {
stream = context.getAssets().open(filePath);
streamReader = new InputStreamReader(stream, "utf-8");
reader = new BufferedReader(streamReader);
StringBuilder builder = new StringBuilder();
String line = null;
boolean readCurrentLine = true;
while ((line = reader.readLine()) != null) {
if (line.contains("<style")) {
readCurrentLine = false;
} else if (line.contains("</style")) {
readCurrentLine = true;
}
if (readCurrentLine) {
builder.append(line).append("\n");
}
}
result = builder.toString();
} catch (FileNotFoundException ex) {
Log.e(TAG, ex.getMessage());
} catch (Exception ex) {
Log.e(TAG, ex.getMessage());
} finally {
if (null != reader) {
try {
reader.close();
} catch (IOException ex) {
Log.e(TAG, ex.getMessage());
}
}
if (null != streamReader) {
try {
streamReader.close();
} catch (IOException ex) {
Log.e(TAG, ex.getMessage());
}
}
if (null != stream) {
try {
stream.close();
} catch (IOException ex) {
Log.e(TAG, ex.getMessage());
}
}
}
return result;
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.btn_exit) {
mActivity.finish();
} else if (v.getId() == R.id.btn_accept) {
Prefs.setPrivacyPolicyState(mActivity, true);
IntentUtil.startEduLauncher(mActivity);
dismiss();
mActivity.finish();
}
}
private class MyURLSpan extends ClickableSpan {
@Override
public void onClick(View view) {
view.setBackgroundColor(Color.parseColor("#00000000"));
Intent intent = null;
try {
intent = new Intent(mActivity, Class.forName("com.android.launcher3.function.setting.PrivacyPolicyActivity"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
mActivity.startActivity(intent);
}
}
}
...@@ -2,60 +2,105 @@ package com.secspace.lib.common.function ...@@ -2,60 +2,105 @@ package com.secspace.lib.common.function
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo import android.content.pm.PackageInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.util.Log import android.util.Log
import com.secspace.lib.common.env.Packages.PkgSecSpace import com.secspace.lib.common.env.Packages.PkgSecSpace
import com.secspace.lib.common.event.InitEvent import com.secspace.lib.common.utils.*
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.COMPONENT_UPDATE_SYSTEM
import com.secspace.lib.common.utils.Package.ComponentNames.EnterprisePrivacySettingsActivity import com.secspace.lib.common.utils.Package.ComponentNames.EnterprisePrivacySettingsActivity
import com.secspace.lib.common.utils.Prefs
import com.secspace.mdmengine.api.manager.MdmFactoryManager import com.secspace.mdmengine.api.manager.MdmFactoryManager
import org.greenrobot.eventbus.EventBus import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.util.* import java.util.*
object SwitchInMdm{ object SwitchInMdm {
private var context: Context? = null private var context: Context? = null
private val TAG = "SwitchInMdm" private val TAG = "SwitchInMdm"
fun init(context: Context){ fun init(context: Context) {
this.context = context this.context = context
val mdmFactoryManager = DpmHelper.getInstance(context).getmMdmFactoryManager() val mdmFactoryManager = DpmHelper.getInstance(context).getmMdmFactoryManager()
mdmFactoryManager.deviceSettingsManager.isRestoreFactoryDisabled = true
mdmFactoryManager.deviceApplicationManager.addDisabledDeactivateMdmPackages(getPersistentList(context)) mdmFactoryManager.deviceApplicationManager.addDisabledDeactivateMdmPackages(getPersistentList(context))
mdmFactoryManager.deviceApplicationManager.addDisallowedUninstallPackages(getPersistentList(context)) mdmFactoryManager.deviceApplicationManager.addDisallowedUninstallPackages(getPersistentList(context))
mdmFactoryManager.deviceRestrictionManager.setDeviceOwnerApp("DeviceOwner")
mdmFactoryManager.deviceApplicationManager.addPersistentApp(getPersistentList(context)) mdmFactoryManager.deviceApplicationManager.addPersistentApp(getPersistentList(context))
val arrayList = ArrayList<String>() val arrayList = ArrayList<String>()
arrayList.add(context.packageName) arrayList.add(context.packageName)
mdmFactoryManager.deviceSettingsManager.superWhiteListForHwSystemManger = arrayList mdmFactoryManager.deviceSettingsManager.superWhiteListForHwSystemManger = arrayList
mdmFactoryManager.deviceRestrictionManager.turnOnGPS(true) mdmFactoryManager.deviceRestrictionManager.turnOnGPS(true)
mdmFactoryManager.deviceSettingsManager.isSystemUpdateDisabled = true
MdmFactoryManager.getInstance().deviceApplicationManager.setApplicationEnabledSetting("com.huawei.powergenie", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 1) MdmFactoryManager.getInstance().deviceApplicationManager.setApplicationEnabledSetting("com.huawei.powergenie", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 1)
DisableCompat.disableComponent(context, COMPONENT_UPDATE_SYSTEM) addDisallowedRunningApp(context)
DisableCompat.disableComponent(context, EnterprisePrivacySettingsActivity)
clearProcesses() clearProcesses()
clearTasks(context)
killBackgroundApplication() killBackgroundApplication()
isCoverInstall() isCoverInstall()
MdmUtils.setDefaultLauncher(context) MdmUtils.setDefaultLauncher(context)
EventBus.getDefault().postSticky(InitEvent())
Log.e("TAG", "post: InitEvent")
} }
private fun isCoverInstall() { private fun clearTasks(context: Context) {
if (Prefs.isCoverSecondInstall(context)) { try {
MdmFactoryManager.getInstance().deviceRestrictionManager.isAdbDisabled = false val recentTasks = ReflectAmsUtil.getRecentTasks(context, 1000, 0)
MdmFactoryManager.getInstance().deviceRestrictionManager.isUSBOtgDisabled = false for (recentTask in recentTasks) {
MdmFactoryManager.getInstance().deviceRestrictionManager.isUSBDataDisabled = false val intent = recentTask.baseIntent ?: continue
MdmFactoryManager.getInstance().deviceRestrictionManager.isExternalStorageDisabled = false var packageName = intent.`package`
Prefs.setCoverSecondInstall(context, false) if (packageName == null) {
val componentName = intent.component ?: continue
packageName = componentName.packageName
}
if (packageName == context.packageName) {
continue
}
ReflectAmsUtil.removeTask(context, recentTask.affiliatedTaskId)
Log.i(TAG, String.format("clear task: pkg(%s) label(%s)"
, packageName
, if (recentTask.taskDescription == null) recentTask.description else recentTask.taskDescription.label))
}
} catch (e: Exception) {
Log.i(TAG, "clearTasks Exception: $e")
}
}
fun addDisallowedRunningApp(context: Context) {
GlobalScope.launch(Dispatchers.IO) {
val mdmFactoryManager = DpmHelper.getInstance(context).getmMdmFactoryManager()
val pkgsList = Prefs.getUserShowAppPkgs(context)
val resolveInfos: List<ResolveInfo> = context.packageManager.queryIntentActivities(Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER), 0)
val items = ArrayList<String>()
//
resolveInfos.filter {
val apiInfo = context.packageManager.getApplicationInfo(it.activityInfo.packageName, 0)
apiInfo.flags and ApplicationInfo.FLAG_SYSTEM == 0
}.forEach {
if (it.activityInfo.packageName != context.packageName)
items.add(it.activityInfo.packageName)
}
Log.e(TAG, "ALL:${items}")
items.filter {
!pkgsList.contains(it)
}.let {
Log.e(TAG, "after:${it}")
mdmFactoryManager.deviceApplicationManager.addDisallowedRunningApp(it)
}
} }
} }
private fun isCoverInstall() {
val mdmFactoryManager = MdmFactoryManager.getInstance()
mdmFactoryManager.deviceRestrictionManager.isAdbDisabled = false
mdmFactoryManager.deviceRestrictionManager.isUSBOtgDisabled = false
mdmFactoryManager.deviceRestrictionManager.isUSBDataDisabled = false
mdmFactoryManager.deviceRestrictionManager.isExternalStorageDisabled = false
mdmFactoryManager.deviceSettingsManager.isRestoreFactoryDisabled = false
mdmFactoryManager.deviceSettingsManager.isSystemUpdateDisabled = false
DisableCompat.enableComponent(context, COMPONENT_UPDATE_SYSTEM)
DisableCompat.enableComponent(context, EnterprisePrivacySettingsActivity)
}
private fun getPersistentList(context: Context): List<String?>? { private fun getPersistentList(context: Context): List<String?>? {
var list: MutableList<String?>? = null var list: MutableList<String?>? = null
if (list == null) { if (list == null) {
...@@ -124,7 +169,7 @@ object SwitchInMdm{ ...@@ -124,7 +169,7 @@ object SwitchInMdm{
for (i in apps?.indices!!) { for (i in apps?.indices!!) {
val name = apps[i].activityInfo.packageName val name = apps[i].activityInfo.packageName
Log.i(TAG, "killBackgroundApplication: $name") Log.i(TAG, "killBackgroundApplication: $name")
if (context?.packageName?.let { name.contains(it) }!! || name == PkgSecSpace.PACKAGENAME_MIDDLEWARE) { if (context?.packageName?.let { name.contains(it) }!! || name == PkgSecSpace.PACKAGENAME_MIDDLEWARE || name == context!!.packageName) {
continue continue
} }
MdmFactoryManager.getInstance().deviceApplicationManager.forceStopPackage(name) MdmFactoryManager.getInstance().deviceApplicationManager.forceStopPackage(name)
......
package com.secspace.lib.common.function
import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.util.Log
import com.secspace.lib.common.env.Packages.PkgSecSpace
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 kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.util.*
object SwitchOutMdm {
private var context: Context? = null
private val TAG = "SwitchOutMdm"
fun exit(context: Context) {
this.context = context
MdmUtils.clearDefaultLauncher(context)
recover()
removeDisallowedRunningApp(context)
clearProcesses()
killBackgroundApplication()
}
private fun removeDisallowedRunningApp(context: Context){
val mdmFactoryManager = DpmHelper.getInstance(context).getmMdmFactoryManager()
val list = mdmFactoryManager.deviceApplicationManager.disallowedRunningApp
mdmFactoryManager.deviceApplicationManager.removeDisallowedRunningApp(list)
Log.e(TAG, "remove:${list}")
}
private fun recover() {
val mdmFactoryManager = MdmFactoryManager.getInstance()
Prefs.setAutoStartSelf(context, false)
mdmFactoryManager.deviceApplicationManager.setApplicationEnabledSetting("com.huawei.powergenie", PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 1)
mdmFactoryManager.deviceRestrictionManager.isAdbDisabled = false
mdmFactoryManager.deviceRestrictionManager.isUSBOtgDisabled = false
mdmFactoryManager.deviceRestrictionManager.isUSBDataDisabled = false
mdmFactoryManager.deviceRestrictionManager.isExternalStorageDisabled = false
mdmFactoryManager.deviceRestrictionManager.isStatusBarExpandPanelDisabled = false
mdmFactoryManager.deviceSettingsManager.isRestoreFactoryDisabled = false
mdmFactoryManager.deviceSettingsManager.isSystemUpdateDisabled = false
DisableCompat.enableComponent(context, COMPONENT_UPDATE_SYSTEM)
DisableCompat.enableComponent(context, EnterprisePrivacySettingsActivity)
}
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
...@@ -54,21 +54,6 @@ object WorkManager{ ...@@ -54,21 +54,6 @@ object WorkManager{
mHandler.postDelayed( { enter(launcher) }, 2000) mHandler.postDelayed( { enter(launcher) }, 2000)
return 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) { GlobalScope.launch(Dispatchers.IO) {
init(launcher) init(launcher)
checkLocalUpdateFile() //检查本地更新文件 checkLocalUpdateFile() //检查本地更新文件
...@@ -77,6 +62,12 @@ object WorkManager{ ...@@ -77,6 +62,12 @@ object WorkManager{
Prefs.setMdmInitializedWhenEnter(mContext, true) Prefs.setMdmInitializedWhenEnter(mContext, true)
} }
fun exit(context: Context?){
GlobalScope.launch(Dispatchers.IO) {
context?.let { SwitchOutMdm.exit(it) }
}
}
private fun hasPermissions(permissions: Array<String>, packageName: String): Boolean { private fun hasPermissions(permissions: Array<String>, packageName: String): Boolean {
if (Build.VERSION.SDK_INT < 23) { if (Build.VERSION.SDK_INT < 23) {
return true return true
...@@ -131,10 +122,6 @@ object WorkManager{ ...@@ -131,10 +122,6 @@ object WorkManager{
install(updateFile.absolutePath) install(updateFile.absolutePath)
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
fun exit(launcher: Activity?) {
}
private fun pathFromAssets(name: String): String { private fun pathFromAssets(name: String): String {
return mContext.externalCacheDir.absolutePath + File.separator + name return mContext.externalCacheDir.absolutePath + File.separator + name
} }
......
...@@ -10,12 +10,10 @@ import android.text.TextUtils; ...@@ -10,12 +10,10 @@ import android.text.TextUtils;
import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.android.arouter.launcher.ARouter;
import com.secspace.lib.common.BuildConfig; import com.secspace.lib.common.BuildConfig;
import com.secspace.lib.common.R; import com.secspace.lib.common.R;
import com.secspace.lib.common.arouter.libvacentor.IVAApi;
import com.secspace.lib.common.event.OnPushMessageEvent; import com.secspace.lib.common.event.OnPushMessageEvent;
import com.secspace.lib.common.event.OnPushTokenUpdateEvent; import com.secspace.lib.common.event.OnPushTokenUpdateEvent;
import com.secspace.lib.common.utils.DeviceUtil;
import com.secspace.lib.common.utils.ImeiUtil; import com.secspace.lib.common.utils.ImeiUtil;
import com.secspace.lib.common.utils.VUidUtil; import com.secspace.lib.common.utils.PkgManager;
import com.secspace.log.Log; import com.secspace.log.Log;
import com.skr.update.AppUpdateManager; import com.skr.update.AppUpdateManager;
import com.skr.update.annotation.ApkPlatform; import com.skr.update.annotation.ApkPlatform;
...@@ -23,7 +21,6 @@ import com.skr.update.annotation.AppInstallPolicy; ...@@ -23,7 +21,6 @@ import com.skr.update.annotation.AppInstallPolicy;
import com.skr.update.annotation.CheckType; import com.skr.update.annotation.CheckType;
import com.skr.update.db.DbRepo; import com.skr.update.db.DbRepo;
import com.skr.update.db.entity.AppUpdateInfo; import com.skr.update.db.entity.AppUpdateInfo;
import com.skr.update.listener.OnCheckUpdateListener;
import com.skr.update.option.PlatformUpdateOption; import com.skr.update.option.PlatformUpdateOption;
import com.skr.update.option.PushOption; import com.skr.update.option.PushOption;
import com.skr.update.option.SalesPlatformUpdateOption; import com.skr.update.option.SalesPlatformUpdateOption;
...@@ -56,10 +53,21 @@ public class CheckUpdateCore { ...@@ -56,10 +53,21 @@ public class CheckUpdateCore {
return INST; return INST;
} }
public void init(Context context, AppUpdateManager.OnAppUpdateListener listener) { public void init(Context context) {
mAppCtx = context.getApplicationContext(); mAppCtx = context.getApplicationContext();
int[] certificates = new int[]{R.raw.tj_secspace365_cn, R.raw.tomcat_114_215_44_230}; 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, new AppUpdateManager.OnAppUpdateListener(){
@Override
public boolean allowInstall(long l, String s) {
return true;
}
@Override
public void onInstall(String path, boolean isManual) {
PkgManager.getInstance(mAppCtx).installByInstaller(path);
}
});
if (!EventBus.getDefault().isRegistered(this)) { if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
} }
...@@ -101,7 +109,7 @@ public class CheckUpdateCore { ...@@ -101,7 +109,7 @@ public class CheckUpdateCore {
*/ */
private void enableAutoUpdate() { private void enableAutoUpdate() {
int platform = BuildConfig.UPDATE_PLATFORM; int platform = BuildConfig.UPDATE_PLATFORM;
String imei = ImeiUtil.INSTANCE.imei(mAppCtx); String imei = ImeiUtil.INSTANCE.uniqueId(mAppCtx, false);
if (TextUtils.isEmpty(imei)) { if (TextUtils.isEmpty(imei)) {
return; return;
} }
...@@ -137,41 +145,18 @@ public class CheckUpdateCore { ...@@ -137,41 +145,18 @@ public class CheckUpdateCore {
/** /**
* 检查更新 * 检查更新
*/ */
public void checkUpdate(boolean isManual) { public void checkUpdate(boolean isShowToast) {
String imei = DeviceUtil.getIMEI(mAppCtx); String imei = ImeiUtil.INSTANCE.uniqueId(mAppCtx, false);
SalesPlatformUpdateOption option = new SalesPlatformUpdateOption.Builder() SalesPlatformUpdateOption option = new SalesPlatformUpdateOption.Builder()
.imei(imei) .imei(imei)
.server(BuildConfig.UPDATE_SERVER) .server(BuildConfig.UPDATE_SERVER)
.name(BuildConfig.UPDATE_FLAG) .name(BuildConfig.UPDATE_FLAG)
.companyId(BuildConfig.COMPANY_ID) .companyId(BuildConfig.COMPANY_ID)
.showDownloadDialog(false) .showDownloadDialog(true)
.showDownloadNotification(true) .showDownloadNotification(false)
.appInstallPolicy(AppInstallPolicy.SILENT_INSTALL) .appInstallPolicy(AppInstallPolicy.SILENT_INSTALL)
.build(); .build();
AppUpdateManager.get().checkUpdate(option, isManual, new OnCheckUpdateListener() { AppUpdateManager.get().checkUpdate(option, isShowToast);
@Override
public boolean onNewVersion(AppUpdateInfo appUpdateInfo) {
// 通知设置页,显示有更新红点
Intent intent = new Intent(ACTION_HAS_UPDATE);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
ARouter.getInstance().navigation(IVAApi.class).sendBroadcast(intent, VUidUtil.getVUid());
return false;
}
@Override
public boolean onNoUpdate() {
Intent intent = new Intent(ACTION_NO_UPDATE);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
ARouter.getInstance().navigation(IVAApi.class).sendBroadcast(intent, VUidUtil.getVUid());
return true;
}
@Override
public boolean onFailed() {
return false;
}
});
} }
/** /**
......
...@@ -5,52 +5,89 @@ import android.content.Context ...@@ -5,52 +5,89 @@ import android.content.Context
import android.os.Environment import android.os.Environment
import android.telephony.TelephonyManager import android.telephony.TelephonyManager
import android.util.Log import android.util.Log
import java.io.* import com.skr.activation.utils.DesUtil
import java.lang.Exception import java.io.File
import java.io.FileWriter
import java.util.* import java.util.*
object ImeiUtil { object ImeiUtil {
private val TEMP_DIR = Environment.getExternalStorageDirectory().toString() + "/.uuid" private val TEMP_DIR = Environment.getExternalStorageDirectory().toString() + "/.uuid"
private const val TEMP_FILE_NAME = ".system_file" private const val TEMP_FILE_UUID_NAME = ".system_file_uuid"
private const val TEMP_FILE_IMEI_NAME = ".system_file_imei"
private const val TAG = "ImeiUtil" private const val TAG = "ImeiUtil"
fun imei(context: Context?): String{ fun uniqueId(context: Context?, show: Boolean): String {
val imei = imei(context)
var uuid = uuid()
var uniqueId: String
if (show) {
uuid = uuid.substring(uuid.length - 15)
uniqueId = "$uuid\n$imei"
} else {
uuid = uuid.substring(uuid.length - 15)
uniqueId = "$uuid-$imei"
}
return uniqueId
}
private fun imei(context: Context?): String {
var imei = "" var imei = ""
val tm: TelephonyManager = context?.getSystemService(Activity.TELEPHONY_SERVICE) as TelephonyManager val applicationFileDir = File(TEMP_DIR)
imei = try { if (!applicationFileDir.exists()) {
tm.getDeviceId() if (!applicationFileDir.mkdirs()) {
}catch (e: Exception){ Log.e(TAG, "Folder creation failed: ${applicationFileDir.path}")
Log.e(TAG, "No imei was obtained") }
uuid() }
val file = File(applicationFileDir, TEMP_FILE_IMEI_NAME)
if (!file.exists()) {
val tm: TelephonyManager = context?.getSystemService(Activity.TELEPHONY_SERVICE) as TelephonyManager
imei = try {
tm.deviceId
} catch (e: Exception) {
Log.e(TAG, "No imei was obtained. error is ${e.message}")
"unKnown"
}
if (imei != "unKnown") {
if (file.createNewFile()) {
val fileWriter = FileWriter(file, false)
fileWriter.use {
fileWriter.write(DesUtil.encrypt(imei))
}
} else {
Log.e(TAG, "createNewFile failed")
}
}
} else {
imei = DesUtil.decrypt(file.readText())
Log.i(TAG, "imei $imei")
} }
Log.e(TAG, "imei is $imei")
return imei return imei
} }
private fun uuid(): String { private fun uuid(): String {
val deviceUuid = UUID.randomUUID() val deviceUuid = UUID.randomUUID()
var uuid = deviceUuid.toString().replace("-", "") var uuid = deviceUuid.toString().replace("-", "")
uuid = uuid.substring(uuid.length - 15)
val applicationFileDir = File(TEMP_DIR) val applicationFileDir = File(TEMP_DIR)
if (!applicationFileDir.exists()) { if (!applicationFileDir.exists()) {
if (!applicationFileDir.mkdirs()) { if (!applicationFileDir.mkdirs()) {
Log.e(TAG, "Folder creation failed: ${applicationFileDir.path}") Log.e(TAG, "Folder creation failed: ${applicationFileDir.path}")
} }
} }
val file = File(applicationFileDir, TEMP_FILE_NAME) val file = File(applicationFileDir, TEMP_FILE_UUID_NAME)
if (!file.exists()) { if (!file.exists()) {
if (file.createNewFile()) { if (file.createNewFile()) {
val fileWriter = FileWriter(file, false) val fileWriter = FileWriter(file, false)
fileWriter.use { fileWriter.use {
fileWriter.write(uuid) fileWriter.write(DesUtil.encrypt(uuid))
} }
} else { } else {
Log.e(TAG, "createNewFile failed") Log.e(TAG, "createNewFile failed")
} }
} else { } else {
uuid = file.readText() uuid = DesUtil.decrypt(file.readText())
Log.i(TAG, "uuid $uuid") Log.i(TAG, "uuid $uuid")
} }
return uuid return uuid
} }
} }
\ No newline at end of file
...@@ -3,14 +3,19 @@ package com.secspace.lib.common.utils; ...@@ -3,14 +3,19 @@ package com.secspace.lib.common.utils;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log;
import com.secspace.lib.common.base.BaseActivity; import com.secspace.lib.common.base.BaseActivity;
import com.secspace.lib.common.compat.BuildCompat; import com.secspace.lib.common.compat.BuildCompat;
import com.secspace.lib.common.env.Intents;
import com.secspace.lib.common.env.Packages; import com.secspace.lib.common.env.Packages;
import com.secspace.lib.common.function.ExitService;
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.CompHuaWei.COMPONENTNAME_HW_WIFI_SETTING;
import static com.secspace.lib.common.env.Packages.PkgSystem.PACKAGENAME_SYSTEM_SETTINGS;
import static com.secspace.lib.common.utils.Package.PACKAGENAME_MIDDLEWARE; import static com.secspace.lib.common.utils.Package.PACKAGENAME_MIDDLEWARE;
/** /**
...@@ -28,7 +33,7 @@ public class IntentUtil { ...@@ -28,7 +33,7 @@ public class IntentUtil {
home.setAction(Intent.ACTION_MAIN); home.setAction(Intent.ACTION_MAIN);
home.addCategory(Intent.CATEGORY_HOME); home.addCategory(Intent.CATEGORY_HOME);
home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(home); safeStartActivity(context, home);
} }
public static void startHomeIntent(Context context) { public static void startHomeIntent(Context context) {
...@@ -36,11 +41,14 @@ public class IntentUtil { ...@@ -36,11 +41,14 @@ public class IntentUtil {
home.setAction(Intent.ACTION_MAIN); home.setAction(Intent.ACTION_MAIN);
home.addCategory(Intent.CATEGORY_HOME); home.addCategory(Intent.CATEGORY_HOME);
home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(home); safeStartActivity(context, home);
} }
public static void startSecSpaceLauncher(Context context) { public static void startEduLauncher(Context context) {
startSecSpaceLauncher(context, true); Intent intent = new Intent();
intent.setAction("android.start_launcher");
intent.setPackage(context.getPackageName());
safeStartActivity(context, intent);
} }
public static void startSecSpaceLauncher(Context context, boolean fromManual) { public static void startSecSpaceLauncher(Context context, boolean fromManual) {
...@@ -49,16 +57,7 @@ public class IntentUtil { ...@@ -49,16 +57,7 @@ public class IntentUtil {
launcher.setComponent(new ComponentName(context.getPackageName(), COMPONENT_LAUNCHER_CLASS)); launcher.setComponent(new ComponentName(context.getPackageName(), COMPONENT_LAUNCHER_CLASS));
launcher.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launcher.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
launcher.putExtra(BaseActivity.INTENT_FROM_MANUAL, fromManual); launcher.putExtra(BaseActivity.INTENT_FROM_MANUAL, fromManual);
context.startActivity(launcher); safeStartActivity(context, launcher);
}
public static void startSecSpaceLock(Context context, String from) {
Intent lock = new Intent();
lock.setPackage(context.getPackageName());
lock.setComponent(new ComponentName(context.getPackageName(), COMPONENT_LOCK_CLASS));
lock.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
lock.putExtra(EXTRA_FORM_WHRER, from);
context.startActivity(lock);
} }
public static void activateMdmServiceDeviceOwner(Context context) { public static void activateMdmServiceDeviceOwner(Context context) {
...@@ -66,6 +65,26 @@ public class IntentUtil { ...@@ -66,6 +65,26 @@ public class IntentUtil {
intent.setPackage(PACKAGENAME_MIDDLEWARE); intent.setPackage(PACKAGENAME_MIDDLEWARE);
intent.putExtra("cmd", "setDeviceOwnerApp"); intent.putExtra("cmd", "setDeviceOwnerApp");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); safeStartActivity(context, intent);
}
public static void startExitService(Context context) {
context.startService(new Intent(context, ExitService.class));
}
public static void startWifiSetting(Context context) {
Intent launcher = new Intent();
launcher.setPackage(PACKAGENAME_SYSTEM_SETTINGS);
launcher.setComponent(COMPONENTNAME_HW_WIFI_SETTING);
launcher.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
safeStartActivity(context, launcher);
}
private static void safeStartActivity(Context context, Intent intent){
try{
context.startActivity(intent);
}catch (Exception e){
}
} }
} }
...@@ -20,11 +20,22 @@ public class MdmUtils { ...@@ -20,11 +20,22 @@ public class MdmUtils {
DpmHelper.getInstance(context).initMiddleWare(); DpmHelper.getInstance(context).initMiddleWare();
MdmFactoryManager.getInstance().getDeviceSettingsManager().setDefaultLauncher(context.getPackageName(), "com.android.launcher3.settings.BlankAcitvity"); MdmFactoryManager.getInstance().getDeviceSettingsManager().setDefaultLauncher(context.getPackageName(), "com.android.launcher3.settings.BlankAcitvity");
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setStatusBarExpandPanelDisabled(true); MdmFactoryManager.getInstance().getDeviceRestrictionManager().setStatusBarExpandPanelDisabled(true);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setTaskButtonDisabled(true); // MdmFactoryManager.getInstance().getDeviceRestrictionManager().setTaskButtonDisabled(true);
//搜索wifi列表时需要将gps打开 否则无法找到列表 //搜索wifi列表时需要将gps打开 否则无法找到列表
MdmFactoryManager.getInstance().getDeviceRestrictionManager().turnOnGPS(true); // MdmFactoryManager.getInstance().getDeviceRestrictionManager().turnOnGPS(true);
Prefs.setAutoStartSelf(context,true); Prefs.setAutoStartSelf(context,true);
//设置默认桌面需要将华为桌面禁用,在用过华为桌面后否则会在最近任务栏显示华为桌面 //设置默认桌面需要将华为桌面禁用,在用过华为桌面后否则会在最近任务栏显示华为桌面
if(!Prefs.isReinforce(context)){
return;
}
List<String> packages = PkgManager.getInstance(context).queryLauncherPackages();
packages.remove(context.getPackageName());
if (packages.size() != 0) {
Prefs.setHideLauncherPackages(context, packages);
}
for (String aPackage : packages) {
DisableCompat.disableApplication(context, aPackage);
}
} }
/** /**
...@@ -34,9 +45,8 @@ public class MdmUtils { ...@@ -34,9 +45,8 @@ public class MdmUtils {
public static void clearDefaultLauncher(Context context){ public static void clearDefaultLauncher(Context context){
DpmHelper.getInstance(context).initMiddleWare(); DpmHelper.getInstance(context).initMiddleWare();
MdmFactoryManager.getInstance().getDeviceSettingsManager().clearDefaultLauncher(context.getPackageName()); MdmFactoryManager.getInstance().getDeviceSettingsManager().clearDefaultLauncher(context.getPackageName());
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setStatusBarExpandPanelDisabled(false);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setTaskButtonDisabled(false);
Prefs.setAutoStartSelf(context,false); Prefs.setAutoStartSelf(context,false);
DisableCompat.enableComponent(context,huaweiLuancher);
List<String> launchers = Prefs.getHideLauncherPackages(context); List<String> launchers = Prefs.getHideLauncherPackages(context);
if (launchers == null) { if (launchers == null) {
launchers = new ArrayList<>(); launchers = new ArrayList<>();
...@@ -47,25 +57,6 @@ public class MdmUtils { ...@@ -47,25 +57,6 @@ public class MdmUtils {
for (String launcher : launchers) { for (String launcher : launchers) {
DisableCompat.enableApplication(context, launcher); 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);
} }
} }
...@@ -5,6 +5,7 @@ import android.content.Context; ...@@ -5,6 +5,7 @@ import android.content.Context;
import java.util.List; 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.INIT_MDM_WHEN_ENTER;
import static com.secspace.lib.common.env.SharedPreferences.Default.REINFORCE;
import static com.secspace.lib.common.env.SharedPreferences.Default.SP_FILE_SECSPACE_COMMON; 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; import static com.secspace.lib.common.env.SharedPreferences.Default.SP_SECSPACE_HIDE_LAUNCHER_PACKAGES;
...@@ -12,11 +13,8 @@ import static com.secspace.lib.common.env.SharedPreferences.Default.SP_SECSPACE_ ...@@ -12,11 +13,8 @@ import static com.secspace.lib.common.env.SharedPreferences.Default.SP_SECSPACE_
public class Prefs { public class Prefs {
private static final String APP_INFO = "app_info"; private static final String APP_INFO = "app_info";
public static final String SYSTEM_AUTO_START_PKGS = "system_auto_start_pkgs"; public static final String SHOW_SYSTEM_APP_PKGS = "show_system_app_pkgs";
public static final String SYSTEM_SHOW_APP_PKGS = "system_show_app_pkgs"; public static final String SHOW_USER_APP_PKGS = "show_user_app_pkgs";
public static final String USER_AUTO_START_PKGS = "user_auto_start_pkgs";
public static final String USER_SHOW_APP_PKGS = "user_show_app_pkgs";
public static final String AUTO_START_SELF="auto_start_self"; public static final String AUTO_START_SELF="auto_start_self";
public static final String IN_SPACE="in_space"; public static final String IN_SPACE="in_space";
...@@ -33,6 +31,7 @@ public class Prefs { ...@@ -33,6 +31,7 @@ public class Prefs {
public static final String LOCK_TIME = "lock_time"; public static final String LOCK_TIME = "lock_time";
public static final String LOCK_COUNT = "lock_count"; public static final String LOCK_COUNT = "lock_count";
public static final String COVER_SECOND_INSTALL = "cover_second_install"; public static final String COVER_SECOND_INSTALL = "cover_second_install";
public static final String SP_PRIVACYPOLICYSTATE = "privacyPolicyState";
public static void setCoverSecondInstall(Context context,boolean isCoverInstall){ public static void setCoverSecondInstall(Context context,boolean isCoverInstall){
putBoolean(context, COVER_SECOND_INSTALL,isCoverInstall); putBoolean(context, COVER_SECOND_INSTALL,isCoverInstall);
...@@ -252,45 +251,6 @@ public class Prefs { ...@@ -252,45 +251,6 @@ public class Prefs {
putBoolean(context,ALLOW_NEW_APP,isAutoStartSelf); putBoolean(context,ALLOW_NEW_APP,isAutoStartSelf);
} }
/**
* 设置用户自启动包名
*
* @param context
* @param pkgs
*/
public static void setUserAutoStartPkgs(Context context, String pkgs) {
putString(context, USER_AUTO_START_PKGS, pkgs);
}
/**
* 获取用户自启动包名
*
* @param context
*/
public static String getUserAutoStartPkgs(Context context) {
return getString(context, USER_AUTO_START_PKGS, "null");
}
/**
* 设置用户显示App包名
*
* @param context
* @param pkgs
*/
public static void setUserShowAppPkgs(Context context, String pkgs) {
putString(context, USER_SHOW_APP_PKGS, pkgs);
}
/**
* 获取用户显示App包名
*
* @param context
*/
public static String getUserShowAppPkgs(Context context) {
return getString(context, USER_SHOW_APP_PKGS, "null");
}
/** /**
* 获取当前状态 * 获取当前状态
* @param context * @param context
...@@ -308,46 +268,35 @@ public class Prefs { ...@@ -308,46 +268,35 @@ public class Prefs {
putBoolean(context,IN_SPACE,isInSpace); putBoolean(context,IN_SPACE,isInSpace);
} }
/** /**
* 设置系统自启动包名 * 设置系统显示App包名
* *
* @param context * @param context
* @param pkgs * @param pkgs
*/ */
public static void setSystemAutoStartPkgs(Context context, String pkgs) { public static void setSystemShowAppPkgs(Context context, List<String> pkgs) {
putString(context, SYSTEM_AUTO_START_PKGS, pkgs); putString(context, SHOW_SYSTEM_APP_PKGS, JsonUtil.toJson(pkgs));
} }
/** /**
* 获取系统自启动包名 * 获取系统显示App包名
* *
* @param context * @param context
*/ */
public static String getSystemAutoStartPkgs(Context context) { public static List<String> getSystemShowAppPkgs(Context context) {
return getString(context, SYSTEM_AUTO_START_PKGS, "null"); String json = getString(context, SHOW_SYSTEM_APP_PKGS, "");
return JsonUtil.json2StringList(json);
} }
/** public static void setUserShowAppPkgs(Context context, List<String> pkgs) {
* 设置系统显示App包名 putString(context, SHOW_USER_APP_PKGS, JsonUtil.toJson(pkgs));
*
* @param context
* @param pkgs
*/
public static void setSystemShowAppPkgs(Context context, String pkgs) {
putString(context, SYSTEM_SHOW_APP_PKGS, pkgs);
} }
/** public static List<String> getUserShowAppPkgs(Context context) {
* 获取系统显示App包名 String json = getString(context, SHOW_USER_APP_PKGS, "");
* return JsonUtil.json2StringList(json);
* @param context
*/
public static String getSystemShowAppPkgs(Context context) {
return getString(context, SYSTEM_SHOW_APP_PKGS, "null");
} }
private static void putString(Context context, String key, String value) { private static void putString(Context context, String key, String value) {
context.getSharedPreferences(APP_INFO, Context.MODE_PRIVATE) context.getSharedPreferences(APP_INFO, Context.MODE_PRIVATE)
.edit().putString(key, value).apply(); .edit().putString(key, value).apply();
...@@ -355,9 +304,6 @@ public class Prefs { ...@@ -355,9 +304,6 @@ public class Prefs {
private static String getString(Context context, String key, String defValue) { private static String getString(Context context, String key, String defValue) {
String value = context.getSharedPreferences(APP_INFO, Context.MODE_PRIVATE).getString(key, defValue); String value = context.getSharedPreferences(APP_INFO, Context.MODE_PRIVATE).getString(key, defValue);
// if (value != null && !TextUtils.equals(value, defValue) && !TextUtils.equals(key, SYS_MSG) && !TextUtils.equals(key, CURRENT_STRATEGY)) {
// value = KeyStoreSave.getInstance().decryptString(value, Const.KEYSTORE_ALIAS);
// }
return value; return value;
} }
...@@ -408,4 +354,20 @@ public class Prefs { ...@@ -408,4 +354,20 @@ public class Prefs {
public static boolean isMdmInitializedWhenEnter(Context ctx) { public static boolean isMdmInitializedWhenEnter(Context ctx) {
return (boolean) SPUtil.getParam(ctx, INIT_MDM_WHEN_ENTER, false, SP_FILE_SECSPACE_COMMON); return (boolean) SPUtil.getParam(ctx, INIT_MDM_WHEN_ENTER, false, SP_FILE_SECSPACE_COMMON);
} }
public static void setReinforce(Context ctx, boolean init) {
SPUtil.setParam(ctx, REINFORCE, init, SP_FILE_SECSPACE_COMMON);
}
public static boolean isReinforce(Context ctx) {
return (boolean) SPUtil.getParam(ctx, REINFORCE, false, SP_FILE_SECSPACE_COMMON);
}
public static void setPrivacyPolicyState(Context ctx, boolean isAccept) {
SPUtil.setParam(ctx, SP_PRIVACYPOLICYSTATE, isAccept, SP_FILE_SECSPACE_COMMON);
}
public static boolean isPrivacyPolicyAccept(Context ctx) {
return (boolean) SPUtil.getParam(ctx, SP_PRIVACYPOLICYSTATE, false, SP_FILE_SECSPACE_COMMON);
}
} }
package com.secspace.lib.common.utils
import android.content.res.Resources
fun dp2px(dpValue: Float): Int {
return (0.5f + dpValue * Resources.getSystem().displayMetrics.density).toInt()
}
\ No newline at end of file
...@@ -15,7 +15,6 @@ object UninstallUtil{ ...@@ -15,7 +15,6 @@ object UninstallUtil{
fun removeForbidden(context: Context?) { fun removeForbidden(context: Context?) {
DisableCompat.enableComponent(context, huaweiLuancher) DisableCompat.enableComponent(context, huaweiLuancher)
DisableCompat.enablePackage(context, PACKAGENAME_HW_HWOUC, true)
MdmFactoryManager.getInstance().switchFactory(WhichFactory.HUAWEI) MdmFactoryManager.getInstance().switchFactory(WhichFactory.HUAWEI)
DisableCompat.enableComponent(context, COMPONENT_NAME_HW_HWOUC) DisableCompat.enableComponent(context, COMPONENT_NAME_HW_HWOUC)
MdmFactoryManager.getInstance().deviceSettingsManager.isSystemUpdateDisabled = false MdmFactoryManager.getInstance().deviceSettingsManager.isSystemUpdateDisabled = false
...@@ -39,7 +38,6 @@ object UninstallUtil{ ...@@ -39,7 +38,6 @@ object UninstallUtil{
MdmFactoryManager.getInstance().deviceSettingsManager.removeActiveAdmin(ComponentName(PACKAGENAME_MDMENHANCE, COMPONENT_ADMIN_CLASS)) MdmFactoryManager.getInstance().deviceSettingsManager.removeActiveAdmin(ComponentName(PACKAGENAME_MDMENHANCE, COMPONENT_ADMIN_CLASS))
MdmFactoryManager.getInstance().deviceRestrictionManager.clearDeviceOwnerApp() MdmFactoryManager.getInstance().deviceRestrictionManager.clearDeviceOwnerApp()
DisableCompat.enablePackage(context, PACKAGENAME_HW_HWOUC, true)
DisableCompat.enableComponent(context, huaweiLuancher) DisableCompat.enableComponent(context, huaweiLuancher)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment