Commit 02fd4a46 by Baoxy

build: 根据需求完成功能

parent e3ffd199
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -43,7 +43,6 @@
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
<uses-permission android:name="android.permission.BIND_APPWIDGET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
......@@ -58,12 +57,12 @@
android:fullBackupContent="@xml/backupscheme"
android:fullBackupOnly="true"
android:hardwareAccelerated="true"
android:icon="@drawable/launcher_self"
android:icon="@drawable/launcher_in"
android:label="@string/derived_app_name"
android:largeHeap="@bool/config_largeHeap"
android:resizeableActivity="false"
android:restoreAnyVersion="true"
android:roundIcon="@drawable/launcher_self"
android:roundIcon="@drawable/launcher_in"
android:supportsRtl="true">
<!-- Intent received used to install shortcuts from other applications -->
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.android.launcher3"
android:sharedUserId="com.secspace.runtime">
......@@ -34,18 +35,29 @@
<uses-permission android:name="com.android.launcher3.permission.WRITE_SETTINGS" />
<application
android:name=".App"
android:backupAgent=".LauncherBackupAgent"
android:fullBackupContent="@xml/backupscheme"
android:fullBackupOnly="true"
android:hardwareAccelerated="true"
android:icon="@drawable/launcher_self"
android:icon="@drawable/launcher_in"
android:label="@string/derived_app_name"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"
android:supportsRtl="true"
tools:replace="android:label"
android:theme="@style/LauncherTheme">
<activity android:name=".settings.ManagerDisableActivity"></activity>
<activity
android:name=".SwitchOutActivity"
android:excludeFromRecents="true"
android:icon="@drawable/launcher_out">
<intent-filter>
<action android:name="android.intent.action.switch" />
<category android:name="android.intent.action.out" />
</intent-filter>
</activity>
<receiver
android:name=".settings.BootReceiver"
android:enabled="true"
......@@ -94,6 +106,13 @@
<action android:name="android.start_launcher" />
</intent-filter>
</activity> <!-- The settings activity. When extending keep the intent filter present -->
<activity
android:name=".function.pwd.PwdPinSetPwdActivity"
android:autoRemoveFromRecents="true"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat" />
<activity
android:name=".SettingsActivity"
android:autoRemoveFromRecents="true"
......
......@@ -5,13 +5,15 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.6'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
......@@ -61,7 +63,7 @@ android {
productFlavors {
aosp {
applicationId 'com.secspace.mobilemanager'
applicationId 'com.eduspace.mobilemanager'
testApplicationId 'com.android.launcher3.tests'
}
}
......@@ -87,7 +89,6 @@ android {
lintOptions {
abortOnError false
}
}
repositories {
......@@ -97,23 +98,25 @@ repositories {
}
final String SUPPORT_LIBS_VERSION = '28.0.0'
final String kotlin_version = '1.3.61'
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
compile "com.android.support:support-v4:${SUPPORT_LIBS_VERSION}"
compile "com.android.support:recyclerview-v7:${SUPPORT_LIBS_VERSION}"
compile "com.android.support:palette-v7:${SUPPORT_LIBS_VERSION}"
implementation "com.android.support:support-v4:${SUPPORT_LIBS_VERSION}"
implementation "com.android.support:recyclerview-v7:${SUPPORT_LIBS_VERSION}"
implementation "com.android.support:palette-v7:${SUPPORT_LIBS_VERSION}"
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
testCompile 'junit:junit:4.12'
androidTestCompile "org.mockito:mockito-core:1.+"
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile "com.android.support:support-annotations:${SUPPORT_LIBS_VERSION}"
compile project(path: ':lib_common')
implementation 'com.secspace:provider_mdm_engine:1.0.0.40'
implementation 'com.skr:activation:1.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation "org.mockito:mockito-core:1.10.19"
androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestImplementation "com.android.support:support-annotations:${SUPPORT_LIBS_VERSION}"
implementation 'com.secspace:provider_mdm_engine:1.1.0.60'
implementation 'io.reactivex.rxjava2:rxjava:2.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
......@@ -123,8 +126,10 @@ dependencies {
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.skr.library:DialogAct:1.0.0'
implementation 'pub.devrel:easypermissions:1.1.3'
implementation project(path: ':assetsprovider')
api project(path: ':assetsprovider')
api project(path: ':lib_common')
implementation files('libs/activation.aar')
implementation files('libs/update-excludePush-release.aar')
}
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:drawable="@drawable/small_eyes" /><!--选中时效果-->
<item android:state_checked="false"
android:drawable="@drawable/show_pwd" /><!--未选中时效果-->
</selector>
\ 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="@color/colorLine" />
<corners android:radius="5dp" />
<solid android:color="@android:color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#ffffff"/>
<corners
android:radius="3dip"
/>
<stroke
android:width="1dp"
android:color="#a0a0a0"/>
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorLine">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="5dp" />
<stroke android:color="@color/colorLine" />
</shape>
</item>
</ripple>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#fff">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/colorPrimary"></solid>
<corners android:radius="4dp"></corners>
</shape>
</item>
</ripple>
\ No newline at end of file
......@@ -35,6 +35,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:visibility="gone"
android:text="自启动"
android:textSize="13dp"/>
......@@ -43,7 +44,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="50dp"
android:text="桌面"
android:text="桌面显示"
android:textSize="13dp"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
......@@ -83,6 +84,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:visibility="gone"
android:text="自启动"
android:textSize="13dp"/>
......@@ -91,7 +93,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="50dp"
android:text="桌面"
android:text="桌面显示"
android:textSize="13dp"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
......
......@@ -73,6 +73,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:visibility="gone"
android:text="通过密保修改"
android:textColor="#000"
android:textSize="18dp" />
......
<?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:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:text="设置混合密码"
android:textColor="#fff"
android:textSize="16dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="80dp"
android:src="@drawable/launcher_in" />
<TextView
android:id="@+id/tv_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="密码至少6位字符组成"
android:textColor="@color/spring_loaded_panel_color"
android:textSize="12dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#ffffff"
android:orientation="horizontal">
<EditText
android:id="@+id/edit_pwd"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="@null"
android:hint="请输入密码"
android:inputType="textPassword"
android:maxLength="16"
android:maxLines="1"
android:padding="12dp"
android:textColorHint="#c2c2c2"
android:textColor="#c2c2c2"
android:textSize="16dp" />
<CheckBox
android:id="@+id/cb_show_pwd"
android:layout_width="40dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:button="@drawable/cb_selector"
android:checked="true" />
</LinearLayout>
<Button
android:id="@+id/btn_sure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginTop="50dp"
android:layout_marginRight="60dp"
android:background="@drawable/ripple_blue_bg"
android:text="确定"
android:textColor="#c2c2c2" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.android.launcher3.settings.SettingActivity">
<include layout="@layout/toolbar"/>
<include layout="@layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:text="学习空间"
android:textColor="#000"
android:text="移动终端管控软件-M3QC"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:visibility="gone" />
<Button
android:id="@+id/btn_version"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="移动管家"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:text="学习空间"
android:textColor="#000" />
<Button
android:id="@+id/btn_change_wallpaper"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="壁纸修改"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:textColor="#000"
android:visibility="gone" />
<Button
android:id="@+id/btn_wifi_whitelist"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="wifi白名单"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:textColor="#000"
android:visibility="gone" />
<Button
android:id="@+id/btn_manager_disable"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="功能管控"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:textColor="#000" />
<Button
android:id="@+id/btn_change_pwd"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="修改密码"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:textColor="#000" />
<Button
android:id="@+id/btn_set_pwdcar"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="密保设置"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:textColor="#000"
android:visibility="gone" />
<Button
android:id="@+id/btn_allow_new_app"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="允许新应用添加"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:textColor="#000" />
<Button
android:visibility="gone"
android:id="@+id/btn_invisible_menu"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="桌面不显示菜单按钮"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:textColor="#000"
android:visibility="gone" />
<Button
android:id="@+id/btn_auto_start"
android:layout_marginTop="10dp"
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:text="移动管家开机自启动"
android:visibility="gone" />
<Button
android:id="@+id/btn_update"
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" />
<Button
android:id="@+id/btn_uninstall"
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" />
</LinearLayout>
</ScrollView>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/icon"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
tools:src="@mipmap/ic_launcher_home" />
<ImageView
android:id="@+id/icon"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
tools:src="@mipmap/ic_launcher_home" />
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/icon"
android:textColor="@color/material_black"
android:textSize="16sp"
tools:text="安全域" />
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/icon"
android:textColor="@color/material_black"
android:textSize="16sp"
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_toLeftOf="@+id/id_cb_autostart"
android:layout_marginEnd="16dp" />
<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_centerInParent="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
<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" />
</LinearLayout>
\ No newline at end of file
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_marginTop="15dp"
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="蓝牙传输"
android:textColor="#fff"
android:textSize="18dp" />
<ImageView
android:layout_marginTop="15dp"
android:scaleType="centerInside"
android:id="@+id/toolbar_right_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:src="@mipmap/setting" />
<ImageView
android:layout_marginTop="15dp"
android:layout_marginLeft="5dp"
android:scaleType="centerInside"
android:id="@+id/toolbar_left_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:src="@mipmap/back" />
<TextView
android:layout_marginTop="15dp"
android:id="@+id/toolbar_right_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:src="@mipmap/setting"
android:textColor="#fff"
android:textSize="15dp"
android:visibility="gone" />
<EditText
android:id="@+id/edit_search"
android:hint="搜索"
android:textColorHint="#acacac"
android:paddingLeft="6dp"
android:textSize="12dp"
android:textColor="#acacac"
android:layout_marginTop="18dp"
android:background="@drawable/edit_box_view_file"
android:layout_below="@id/toolbar_title"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="27dp" />
</RelativeLayout>
\ No newline at end of file
......@@ -19,7 +19,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
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="work_folder_name" msgid="3753320833950115786">"Work"</string>
<string name="activity_not_found" msgid="8071924732094499514">"未安装该应用。"</string>
......
......@@ -51,4 +51,6 @@
<color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
<color name="btn_background">#A6D2F5</color> <!-- Gray 300 -->
<color name="alpha_70_black">#B3000000</color>
<color name="colorLine">#dedede</color>
</resources>
......@@ -305,7 +305,7 @@
<string name="work_open">open</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">打开</string>
<string name="close">关闭</string>
......@@ -313,9 +313,9 @@
<string name="tip">提示</string>
<string name="launcher_setting_tip">安装完成,可长按桌面进行桌面配置</string>
<string name="ok">好的</string>
<string name="delete_account_tip">请先去“设置--账户” 中的所有账户和华为账户先删除,在启动移动管家</string>
<string name="delete_account_tip">请先去“设置--账户” 中的所有账户和华为账户先删除,在启动学习空间</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="work_sure">sure</string>
</resources>
......@@ -138,5 +138,4 @@
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
......@@ -17,15 +17,15 @@
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3">
<!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
<!-- Dialer, Messaging, [All Apps], Browser, Camera -->
<!--<resolve-->
<!--launcher:container="-101"-->
<!--launcher:screen="0"-->
<!--launcher:x="0"-->
<!--launcher:y="0" >-->
<!--<favorite launcher:uri="#Intent;action=android.intent.action.DIAL;end" />-->
<!--<favorite launcher:uri="tel:123" />-->
<!--<favorite launcher:uri="#Intent;action=android.intent.action.CALL_BUTTON;end" />-->
<!--</resolve>-->
<resolve
launcher:container="-101"
launcher:screen="0"
launcher:x="0"
launcher:y="0" >
<favorite
launcher:className="com.android.launcher3.SwitchOutActivity"
launcher:packageName="com.eduspace.mobilemanager"/>
</resolve>
<!--<resolve-->
<!--launcher:container="-101"-->
......
......@@ -17,17 +17,15 @@
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3">
<!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
<!-- Messaging, Email, Browser, [All Apps], Music, Gallery, Camera -->
<!--<resolve-->
<!--launcher:container="-101"-->
<!--launcher:screen="0"-->
<!--launcher:x="0"-->
<!--launcher:y="0" >-->
<!--<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MESSAGING;end" />-->
<!--<favorite launcher:uri="sms:" />-->
<!--<favorite launcher:uri="smsto:" />-->
<!--<favorite launcher:uri="mms:" />-->
<!--<favorite launcher:uri="mmsto:" />-->
<!--</resolve>-->
<resolve
launcher:container="-101"
launcher:screen="0"
launcher:x="0"
launcher:y="0" >
<favorite
launcher:className="com.android.launcher3.SwitchOutActivity"
launcher:packageName="com.eduspace.mobilemanager"/>
</resolve>
<!--<resolve-->
<!--launcher:container="-101"-->
......
......@@ -20,6 +20,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.pm.LauncherActivityInfo;
import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.util.FlagOp;
......@@ -101,7 +102,7 @@ public class AllAppsList {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
final List<LauncherActivityInfo> matches = launcherApps.getActivityList(packageName,
user);
Log.e("TAG1", "addPackage: " + matches.size() );
for (LauncherActivityInfo info : matches) {
add(new AppInfo(context, info, user), info);
}
......
package com.android.launcher3;
import android.app.Application;
import android.content.Context;
import com.secspace.lib.common.update.CheckUpdateCore;
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 {
private Context mApp;
@Override
public void onCreate() {
super.onCreate();
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) {
if (isManual) {
PkgManager.getInstance(mApp).installByInstaller(path);
}
}
});
}
}
......@@ -19,6 +19,8 @@ package com.android.launcher3;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.logging.UserEventDispatcher;
......@@ -27,6 +29,7 @@ public abstract class BaseActivity extends Activity {
protected DeviceProfile mDeviceProfile;
protected UserEventDispatcher mUserEventDispatcher;
protected Context mAppContext;
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
......@@ -54,4 +57,10 @@ public abstract class BaseActivity extends Activity {
}
return ((BaseActivity) ((ContextWrapper) context).getBaseContext());
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
mAppContext = getApplicationContext();
super.onCreate(savedInstanceState);
}
}
......@@ -63,12 +63,14 @@ import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.support.annotation.Nullable;
import android.text.InputType;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.TextKeyListener;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.KeyboardShortcutGroup;
......@@ -85,6 +87,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.OvershootInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
......@@ -109,6 +112,7 @@ import com.android.launcher3.dragndrop.PinItemDragListener;
import com.android.launcher3.dynamicui.ExtractedColors;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.function.pwd.PwdPinSetPwdActivity;
import com.android.launcher3.keyboard.CustomActionsPopup;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.logging.FileLog;
......@@ -123,9 +127,11 @@ import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.settings.AppChooseActivity;
import com.android.launcher3.settings.AppInstallReceiver;
import com.android.launcher3.settings.ErrorTimeHelper;
import com.android.launcher3.settings.String2ListHelper;
import com.android.launcher3.settings.VerifyPwdProtectionActivity;
import com.android.launcher3.settings.wifi.NetworkConnectChangedReceiver;
import com.android.launcher3.settings.wifi.WifiInfoBean;
import com.android.launcher3.settings.wifi.WifiManagerUtils;
......@@ -152,6 +158,8 @@ import com.android.launcher3.widget.WidgetAddFlowHandler;
import com.android.launcher3.widget.WidgetHostViewLoader;
import com.android.launcher3.widget.WidgetsContainerView;
import com.google.gson.Gson;
import com.secspace.lib.common.dialog.SwitcherDialog;
import com.secspace.lib.common.env.Packages;
import com.secspace.lib.common.event.ChangeWallPaperEvent;
import com.secspace.lib.common.event.RefreshWorkSpaceEvent;
import com.secspace.lib.common.utils.ActivityHelper;
......@@ -159,12 +167,15 @@ import com.secspace.lib.common.utils.DeviceUtil;
import com.secspace.lib.common.utils.DpmHelper;
import com.secspace.lib.common.utils.FileUtil;
import com.secspace.lib.common.utils.ImeiCheckUtils;
import com.secspace.lib.common.utils.ImeiUtil;
import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.IntentUtil;
import com.secspace.lib.common.utils.Prefs;
import com.secspace.lib.common.utils.ToastUtil;
import com.secspace.mdmengine.api.manager.IDeviceApplicationManager;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import com.skr.activation.api.ActivationApi;
import com.skr.activation.network.linstener.CheckActiveStatusListener;
import com.skr.activation.network.linstener.CheckLocalActiveStatusListener;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
......@@ -180,6 +191,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static com.android.launcher3.settings.Contants.FROM_WHERE;
import static com.secspace.lib.common.env.Packages.PkgSecSpace.PACKAGENAME_MIDDLEWARE;
/**
......@@ -247,8 +259,10 @@ public class Launcher extends BaseActivity
/**
* The different states that Launcher can be in.
*/
enum State {NONE, WORKSPACE, WORKSPACE_SPRING_LOADED, APPS, APPS_SPRING_LOADED,
WIDGETS, WIDGETS_SPRING_LOADED}
enum State {
NONE, WORKSPACE, WORKSPACE_SPRING_LOADED, APPS, APPS_SPRING_LOADED,
WIDGETS, WIDGETS_SPRING_LOADED
}
@Thunk
State mState = State.WORKSPACE;
......@@ -419,10 +433,10 @@ public class Launcher extends BaseActivity
.build());
}
if (Prefs.isFirstInit(this)) {
String pgks = "cc.ewell.mcs;com.lianfan.numasshell;";
String systemPkgs = "com.example.android.notepad;com.huawei.vassistant;com.android.deskclock;com.android.gallery3d;com.android.calendar;com.android.calculator2;com.microsoft.office.powerpoint;com.huawei.camera;com.android.contacts;com.android.soundrecorder;com.microsoft.office.excel;com.android.mediacenter;com.huawei.himovie;com.microsoft.office.word";
String pgks = getPackageName();
String systemPkgs = "";
Prefs.setUserShowAppPkgs(this, pgks);
Prefs.setSystemShowAppPkgs(this,systemPkgs);
Prefs.setSystemShowAppPkgs(this, systemPkgs);
}
mWallpaperPath = getFilesDir().getAbsolutePath() + File.separator + WALLPAPER_NAME;
Log.i(TAG, "onCreate: ");
......@@ -434,7 +448,6 @@ public class Launcher extends BaseActivity
mLauncherCallbacks.preOnCreate();
}
mWifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
super.onCreate(savedInstanceState);
ImeiCheckUtils.getInstance(this).initImeiList();
LauncherAppState app = LauncherAppState.getInstance(this);
......@@ -535,7 +548,6 @@ public class Launcher extends BaseActivity
mHandler = new Handler();
EventBus.getDefault().register(this);
ActivationApi.getInstance().init(getApplicationContext(), null);
if (mWallpaperPath != null) {
Bitmap bitmap = BitmapFactory.decodeFile(mWallpaperPath);
mLauncherView.setBackground(new BitmapDrawable(bitmap));
......@@ -553,7 +565,7 @@ public class Launcher extends BaseActivity
launcher.setBackground(new BitmapDrawable(getResources(), bitmap));
}
registerNetworkReceiver();
if (DpmHelper.getInstance(this).isMiddlewareInstalled()&&DpmHelper.getInstance(this).isMiddlewareDPMActived()){
if (DpmHelper.getInstance(this).isMiddlewareInstalled() && DpmHelper.getInstance(this).isMiddlewareDPMActived()) {
tipSetAuto();
}
}
......@@ -570,11 +582,11 @@ public class Launcher extends BaseActivity
intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
intentFilter.addDataScheme("package");
registerReceiver(mAppInstallReceiver, intentFilter);
IntentFilter intentFilter1=new IntentFilter();
IntentFilter intentFilter1 = new IntentFilter();
intentFilter1.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter1.addAction(Intent.ACTION_SCREEN_ON);
intentFilter1.addAction(Intent.ACTION_USER_PRESENT);
registerReceiver(mNetworkConnectChangedReceiver,intentFilter1);
registerReceiver(mNetworkConnectChangedReceiver, intentFilter1);
}
private void unregisterNetworkReceiver() {
......@@ -1201,20 +1213,28 @@ public class Launcher extends BaseActivity
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onResume();
}
if (!checkImei()) {
showPwdDialog(getString(R.string.not_user_prmission), getString(R.string.work_sure), null, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mTipDialog = null;
dialog.dismiss();
finish();
}
}, null);
return;
}
// if (!activeByCode(this)) {
// return;
// }
// activationNext();
ActivationApi.getInstance().isActiveFromLocalAndNet(getPackageName(), new CheckLocalActiveStatusListener() {
@Override
public void hasActivated() {
activationNext();
}
@Override
public void needActivate() {
ActivationApi.getInstance().setUseNormalDialog(true);
ActivationApi.getInstance().startActivateActivity(Launcher.this, getPackageName(), false);
finish();
}
@Override
public void onError() {
activationNext();
}
});
}
private void activationNext() {
if (!DpmHelper.getInstance(this).isMiddlewareInstalled()) {
DpmHelper.getInstance(this).installMiddleWare();
return;
......@@ -1223,13 +1243,19 @@ public class Launcher extends BaseActivity
if (!DpmHelper.getInstance(this).isMiddlewareDPMActived()) {
DpmHelper.getInstance(this).toActivateMiddlewareDpm();
}
String pwd = Prefs.getLoginPwd(this);
if (TextUtils.isEmpty(pwd)) {
Intent intent = new Intent(this, PwdPinSetPwdActivity.class);
startActivity(intent);
return;
}
MdmFactoryManager mdmFactoryManager = DpmHelper.getInstance(this).getmMdmFactoryManager();
mdmFactoryManager.getDeviceSettingsManager().setRestoreFactoryDisabled(true);
mdmFactoryManager.getDeviceApplicationManager().addDisabledDeactivateMdmPackages(getPersistentList());
mdmFactoryManager.getDeviceApplicationManager().addDisallowedUninstallPackages(getPersistentList());
mdmFactoryManager.getDeviceRestrictionManager().setDeviceOwnerApp("DeviceOwner");
mdmFactoryManager.getDeviceApplicationManager().addPersistentApp(getPersistentList());
ArrayList<String> arrayList=new ArrayList<>();
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(this.getPackageName());
mdmFactoryManager.getDeviceSettingsManager().setSuperWhiteListForHwSystemManger(arrayList);
mdmFactoryManager.getDeviceRestrictionManager().turnOnGPS(true);
......@@ -1242,7 +1268,7 @@ public class Launcher extends BaseActivity
isCoverInstall();
startWifiScanService();
setAutoStartLauncher();
MdmFactoryManager.getInstance().getDeviceApplicationManager().setApplicationEnabledSetting("com.huawei.powergenie",PackageManager.COMPONENT_ENABLED_STATE_DISABLED,1);
MdmFactoryManager.getInstance().getDeviceApplicationManager().setApplicationEnabledSetting("com.huawei.powergenie", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 1);
// MdmFactoryManager.getInstance().getDeviceApplicationManager().setApplicationEnabledSetting("com.huawei.powergenie",PackageManager.COMPONENT_ENABLED_STATE_ENABLED,1);
//重新loading一下应用 为了过滤应用
Log.i(TAG, "launcher onresume: ");
......@@ -1254,12 +1280,12 @@ public class Launcher extends BaseActivity
private void isCoverInstall() {
if (Prefs.isCoverSecondInstall(this)) {
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setAdbDisabled(true);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setUSBOtgDisabled(true);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setUSBDataDisabled(true);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setExternalStorageDisabled(true);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setAdbDisabled(false);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setUSBOtgDisabled(false);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setUSBDataDisabled(false);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setExternalStorageDisabled(false);
initDefaultPkgsList();
Prefs.setCoverSecondInstall(this,false);
Prefs.setCoverSecondInstall(this, false);
}
}
......@@ -1375,7 +1401,6 @@ public class Launcher extends BaseActivity
continue;
}
MdmFactoryManager.getInstance().getDeviceApplicationManager().forceStopPackage(name);
}
}
......@@ -1411,7 +1436,7 @@ public class Launcher extends BaseActivity
}.start();
Prefs.setIsFirstInit(Launcher.this, false);
initWifiList();
// initWifiList();
}
}
......@@ -1428,8 +1453,8 @@ public class Launcher extends BaseActivity
}
private void initDefaultPkgsList() {
DpmHelper.getInstance(this).preinstallApp("MCS_SVN_1515.apk");
DpmHelper.getInstance(this).preinstallApp("NumasPad_v1.8.6.apk");
// DpmHelper.getInstance(this).preinstallApp("MCS_SVN_1515.apk");
// DpmHelper.getInstance(this).preinstallApp("NumasPad_v1.8.6.apk");
}
private boolean checkDeviceOwner() {
......@@ -1442,6 +1467,8 @@ public class Launcher extends BaseActivity
checkDeviceOwner();
}
}, 6000);
}else{
MdmFactoryManager.getInstance().getGooglePolicyManager().setOrganizationName("个人");
}
return middlewareDeviceOwner;
}
......@@ -1493,7 +1520,7 @@ public class Launcher extends BaseActivity
}
private void startWifiScanService() {
startService(new Intent(this, WifiScanService.class));
// startService(new Intent(this, WifiScanService.class));
}
//重新loading一下应用 为了过滤应用
......@@ -2302,29 +2329,38 @@ public class Launcher extends BaseActivity
private void tipSetAuto() {
if (!Prefs.isAutoStartSelf(this)) {
Log.i(TAG, "onNewIntent: isAutoStartSelf");
showPwdDialog(getString(R.string.set_auto_start_tip), getString(R.string.work_sure), getString(R.string.work_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mTipDialog = null;
dialog.dismiss();
MdmUtils.setDefaultLauncher(Launcher.this);
new Thread() {
@Override
public void run() {
super.run();
clearProcesses();
killBackgroundApplication();
}
}.start();
}
}, new DialogInterface.OnClickListener() {
// showPwdDialog(getString(R.string.set_auto_start_tip), getString(R.string.work_sure), getString(R.string.work_cancel), new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// mTipDialog = null;
// dialog.dismiss();
// MdmUtils.setDefaultLauncher(Launcher.this);
// new Thread() {
// @Override
// public void run() {
// super.run();
// clearProcesses();
// killBackgroundApplication();
// }
// }.start();
// }
// }, new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// mTipDialog = null;
// dialog.dismiss();
// }
// });
MdmUtils.setDefaultLauncher(Launcher.this);
new Thread() {
@Override
public void onClick(DialogInterface dialog, int which) {
mTipDialog = null;
dialog.dismiss();
public void run() {
super.run();
clearProcesses();
killBackgroundApplication();
}
});
}.start();
}
}
......@@ -3071,7 +3107,7 @@ public class Launcher extends BaseActivity
*/
public void onClickSettingsButton(View v) {
if (!ErrorTimeHelper.getInstance(this).canShowDialog()) {
ToastUtil.showShort(this, "请在" + ErrorTimeHelper.getInstance(this).getCountDownTime() + "秒后试");
ToastUtil.showShort(this, "请在" + ErrorTimeHelper.getInstance(this).getCountDownTime() + "秒后试");
return;
}
Intent intent = new Intent()
......@@ -3245,6 +3281,11 @@ public class Launcher extends BaseActivity
intent.setSourceBounds(getViewBounds(v));
}
try {
ComponentName componentName = intent.getComponent();
if (componentName != null && componentName.getClassName().equals(Packages.ClassName.EXIT_CLASSNAME)) {
showPwdDialog();
return true;
}
if (Utilities.ATLEAST_MARSHMALLOW
&& (item instanceof ShortcutInfo)
&& (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
......@@ -3267,6 +3308,84 @@ public class Launcher extends BaseActivity
return false;
}
AlertDialog mPwdDialog;
private void showPwdDialog() {
if (mPwdDialog == null) {
final EditText editText = new EditText(this);
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
View view = LayoutInflater.from(this).inflate(R.layout.item_ll, null);
LinearLayout ll = view.findViewById(R.id.item_ll);
ll.addView(editText);
mPwdDialog = new AlertDialog.Builder(this)
.setTitle("请输入密码")
.setCancelable(false)
.setView(view)
.setNegativeButton(R.string.work_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
})
.setPositiveButton(R.string.work_sure, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
InputUtil.closeSoftInput(getApplicationContext(), editText);
boolean canInputPwd = ErrorTimeHelper.getInstance(mAppContext).canInputPwd();
if (canInputPwd) {
if (TextUtils.equals(editText.getText().toString(), Prefs.getLoginPwd(mAppContext))) {
exit();
editText.setText("");
} else if (TextUtils.equals(editText.getText().toString(), "un00000101")) {
Prefs.setOpenSilenceInstallTool(mAppContext, true);
DpmHelper.getInstance(mAppContext).preinstallApp("toolV4.apk");
finish();
} else {
ToastUtil.showLong(mAppContext, "密码错误!");
finish();
}
} else {
ToastUtil.showShort(mAppContext, "请在" + ErrorTimeHelper.getInstance(mAppContext).getCountDownTime() + "秒后重试");
finish();
}
}
})
.create();
}
if (!mPwdDialog.isShowing()) {
mPwdDialog.show();
}
}
private void exit() {
SwitcherDialog.getInstance(mAppContext).show(null, "Exit");
new Thread(new Runnable() {
@Override
public void run() {
Prefs.setAutoStartSelf(mAppContext, false);
MdmUtils.clearDefaultLauncher(mAppContext);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setStatusBarExpandPanelDisabled(false);
try {
Thread.sleep(1000);
runOnUiThread(new Runnable() {
@Override
public void run() {
SwitcherDialog.getInstance(mAppContext).dismiss("Exit");
IntentUtil.startSystemLauncher(mAppContext);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
mLastDispatchTouchEventX = ev.getX();
......@@ -4682,42 +4801,4 @@ public class Launcher extends BaseActivity
}
}
}
private boolean activeByCode(final Context context) {
boolean isActivate = ActivationApi.getInstance().isActiveFromLocal(this.getPackageName());
if (!isActivate) {
ActivationApi.getInstance().startActivateActivity(this, this.getPackageName(), false);
} else {
ActivationApi.getInstance().checkActivateCodeStatus(this.getPackageName(), new CheckActiveStatusListener() {
@Override
public void activedFailed() {
if (!DpmHelper.getInstance(context).isMiddlewareInstalled() && DpmHelper.getInstance(context).isMiddlewareDPMActived()) {
MdmUtils.clearDefaultLauncher(context);
}
Launcher.this.finish();
}
@Override
public void trialCodeWillPastDue() {
}
@Override
public void hasActived() {
}
@Override
public void serverError() {
}
@Override
public void onError(Throwable throwable) {
}
});
}
return isActivate;
}
}
......@@ -80,6 +80,7 @@ import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Provider;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.ViewOnDrawExecutor;
import com.secspace.lib.common.env.Packages;
import java.io.FileDescriptor;
import java.io.PrintWriter;
......@@ -111,25 +112,37 @@ public class LauncherModel extends BroadcastReceiver
private static final int ITEMS_CHUNK = 6; // batch size for the workspace icons
private static final long INVALID_SCREEN_ID = -1L;
@Thunk final LauncherAppState mApp;
@Thunk final Object mLock = new Object();
@Thunk DeferredHandler mHandler = new DeferredHandler();
@Thunk LoaderTask mLoaderTask;
@Thunk boolean mIsLoaderTaskRunning;
@Thunk boolean mHasLoaderCompletedOnce;
@Thunk boolean mIsManagedHeuristicAppsUpdated;
@Thunk
final LauncherAppState mApp;
@Thunk
final Object mLock = new Object();
@Thunk
DeferredHandler mHandler = new DeferredHandler();
@Thunk
LoaderTask mLoaderTask;
@Thunk
boolean mIsLoaderTaskRunning;
@Thunk
boolean mHasLoaderCompletedOnce;
@Thunk
boolean mIsManagedHeuristicAppsUpdated;
@Thunk
static final HandlerThread sWorkerThread = new HandlerThread("launcher-loader");
@Thunk static final HandlerThread sWorkerThread = new HandlerThread("launcher-loader");
static {
sWorkerThread.start();
}
@Thunk static final Handler sWorker = new Handler(sWorkerThread.getLooper());
@Thunk
static final Handler sWorker = new Handler(sWorkerThread.getLooper());
// Indicates whether the current model data is valid or not.
// We start off with everything not loaded. After that, we assume that
// our monitoring of the package manager provides all updates and we never
// need to do a requery. This is only ever touched from the loader thread.
private boolean mModelLoaded;
public boolean isModelLoaded() {
synchronized (mLock) {
return mModelLoaded && mLoaderTask == null;
......@@ -142,7 +155,8 @@ public class LauncherModel extends BroadcastReceiver
*/
static final ArrayList<Runnable> mBindCompleteRunnables = new ArrayList<Runnable>();
@Thunk WeakReference<Callbacks> mCallbacks;
@Thunk
WeakReference<Callbacks> mCallbacks;
// < only access in worker thread >
private final AllAppsList mBgAllAppsList;
......@@ -179,33 +193,54 @@ public class LauncherModel extends BroadcastReceiver
public interface Callbacks {
public boolean setLoadOnResume();
public int getCurrentWorkspaceScreen();
public void clearPendingBinds();
public void startBinding();
public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end,
boolean forceAnimateIcons);
public void bindScreens(ArrayList<Long> orderedScreenIds);
public void finishFirstPageBind(ViewOnDrawExecutor executor);
public void finishBindingItems();
public void bindAppWidget(LauncherAppWidgetInfo info);
public void bindAllApplications(ArrayList<AppInfo> apps);
public void bindAppsAdded(ArrayList<Long> newScreens,
ArrayList<ItemInfo> addNotAnimated,
ArrayList<ItemInfo> addAnimated,
ArrayList<AppInfo> addedApps);
public void bindAppsUpdated(ArrayList<AppInfo> apps);
public void bindShortcutsChanged(ArrayList<ShortcutInfo> updated,
ArrayList<ShortcutInfo> removed, UserHandle user);
public void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets);
public void bindRestoreItemsChange(HashSet<ItemInfo> updates);
public void bindWorkspaceComponentsRemoved(
HashSet<String> packageNames, HashSet<ComponentName> components,
UserHandle user);
public void bindAppInfosRemoved(ArrayList<AppInfo> appInfos);
public void notifyWidgetProvidersChanged();
public void bindAllWidgets(MultiHashMap<PackageItemInfo, WidgetItem> widgets);
public void onPageBoundSynchronously(int page);
public void executeOnNextDraw(ViewOnDrawExecutor executor);
public void bindDeepShortcutMap(MultiHashMap<ComponentKey, String> deepShortcutMap);
}
......@@ -220,8 +255,10 @@ public class LauncherModel extends BroadcastReceiver
mUserManager = UserManagerCompat.getInstance(context);
}
/** Runs the specified runnable immediately if called from the main thread, otherwise it is
* posted on the main thread handler. */
/**
* Runs the specified runnable immediately if called from the main thread, otherwise it is
* posted on the main thread handler.
*/
private void runOnMainThread(Runnable r) {
if (sWorkerThread.getThreadId() == Process.myTid()) {
// If we are on the worker thread, post onto the main handler
......@@ -231,8 +268,10 @@ public class LauncherModel extends BroadcastReceiver
}
}
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is
* posted on the worker thread handler. */
/**
* Runs the specified runnable immediately if called from the worker thread, otherwise it is
* posted on the worker thread handler.
*/
private static void runOnWorkerThread(Runnable r) {
if (sWorkerThread.getThreadId() == Process.myTid()) {
r.run();
......@@ -409,14 +448,14 @@ public class LauncherModel extends BroadcastReceiver
@Override
public void onPackagesAvailable(String[] packageNames, UserHandle user,
boolean replacing) {
boolean replacing) {
enqueueModelUpdateTask(
new PackageUpdatedTask(PackageUpdatedTask.OP_UPDATE, user, packageNames));
}
@Override
public void onPackagesUnavailable(String[] packageNames, UserHandle user,
boolean replacing) {
boolean replacing) {
if (!replacing) {
enqueueModelUpdateTask(new PackageUpdatedTask(
PackageUpdatedTask.OP_UNAVAILABLE, user, packageNames));
......@@ -437,12 +476,12 @@ public class LauncherModel extends BroadcastReceiver
@Override
public void onShortcutsChanged(String packageName, List<ShortcutInfoCompat> shortcuts,
UserHandle user) {
UserHandle user) {
enqueueModelUpdateTask(new ShortcutsChangedTask(packageName, shortcuts, user, true));
}
public void updatePinnedShortcuts(String packageName, List<ShortcutInfoCompat> shortcuts,
UserHandle user) {
UserHandle user) {
enqueueModelUpdateTask(new ShortcutsChangedTask(packageName, shortcuts, user, false));
}
......@@ -534,6 +573,7 @@ public class LauncherModel extends BroadcastReceiver
/**
* Starts the loader. Tries to bind {@params synchronousBindPage} synchronously if possible.
*
* @return true if the page could be bound synchronously.
*/
public boolean startLoader(int synchronousBindPage) {
......@@ -588,18 +628,20 @@ public class LauncherModel extends BroadcastReceiver
/**
* Runnable for the thread that loads the contents of the launcher:
* - workspace icons
* - widgets
* - all apps icons
* - deep shortcuts within apps
* - workspace icons
* - widgets
* - all apps icons
* - deep shortcuts within apps
*/
private class LoaderTask implements Runnable {
private Context mContext;
private int mPageToBindFirst;
@Thunk boolean mIsLoadingAndBindingWorkspace;
@Thunk
boolean mIsLoadingAndBindingWorkspace;
private boolean mStopped;
@Thunk boolean mLoadAndBindStepFinished;
@Thunk
boolean mLoadAndBindStepFinished;
LoaderTask(Context context, int pageToBindFirst) {
mContext = context;
......@@ -614,16 +656,16 @@ public class LauncherModel extends BroadcastReceiver
final long workspaceWaitTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
mHandler.postIdle(new Runnable() {
public void run() {
synchronized (LoaderTask.this) {
mLoadAndBindStepFinished = true;
if (DEBUG_LOADERS) {
Log.d(TAG, "done with previous binding step");
}
LoaderTask.this.notify();
public void run() {
synchronized (LoaderTask.this) {
mLoadAndBindStepFinished = true;
if (DEBUG_LOADERS) {
Log.d(TAG, "done with previous binding step");
}
LoaderTask.this.notify();
}
});
}
});
while (!mStopped && !mLoadAndBindStepFinished) {
try {
......@@ -636,7 +678,7 @@ public class LauncherModel extends BroadcastReceiver
}
if (DEBUG_LOADERS) {
Log.d(TAG, "waited "
+ (SystemClock.uptimeMillis()-workspaceWaitTime)
+ (SystemClock.uptimeMillis() - workspaceWaitTime)
+ "ms for previous step to finish binding");
}
}
......@@ -748,7 +790,7 @@ public class LauncherModel extends BroadcastReceiver
mHasLoaderCompletedOnce = true;
}
} catch (CancellationException e) {
// Loader stopped, ignore
// Loader stopped, ignore
} finally {
// Clear out this reference, otherwise we end up holding it until all of the
// callback runnables are done.
......@@ -910,329 +952,329 @@ public class LauncherModel extends BroadcastReceiver
boolean allowMissingTarget = false;
switch (c.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
intent = c.parseIntent();
if (intent == null) {
c.markDeleted("Invalid or null intent");
continue;
}
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
intent = c.parseIntent();
if (intent == null) {
c.markDeleted("Invalid or null intent");
continue;
}
int disabledState = quietMode.get(c.serialNumber) ?
ShortcutInfo.FLAG_DISABLED_QUIET_USER : 0;
ComponentName cn = intent.getComponent();
targetPkg = cn == null ? intent.getPackage() : cn.getPackageName();
int disabledState = quietMode.get(c.serialNumber) ?
ShortcutInfo.FLAG_DISABLED_QUIET_USER : 0;
ComponentName cn = intent.getComponent();
targetPkg = cn == null ? intent.getPackage() : cn.getPackageName();
if (!Process.myUserHandle().equals(c.user)) {
if (c.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
c.markDeleted("Legacy shortcuts are only allowed for default user");
continue;
} else if (c.restoreFlag != 0) {
// Don't restore items for other profiles.
c.markDeleted("Restore from managed profile not supported");
if (!Process.myUserHandle().equals(c.user)) {
if (c.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
c.markDeleted("Legacy shortcuts are only allowed for default user");
continue;
} else if (c.restoreFlag != 0) {
// Don't restore items for other profiles.
c.markDeleted("Restore from managed profile not supported");
continue;
}
}
if (TextUtils.isEmpty(targetPkg) &&
c.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
c.markDeleted("Only legacy shortcuts can have null package");
continue;
}
}
if (TextUtils.isEmpty(targetPkg) &&
c.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
c.markDeleted("Only legacy shortcuts can have null package");
continue;
}
// If there is no target package, its an implicit intent
// (legacy shortcut) which is always valid
boolean validTarget = TextUtils.isEmpty(targetPkg) ||
launcherApps.isPackageEnabledForProfile(targetPkg, c.user);
// If there is no target package, its an implicit intent
// (legacy shortcut) which is always valid
boolean validTarget = TextUtils.isEmpty(targetPkg) ||
launcherApps.isPackageEnabledForProfile(targetPkg, c.user);
if (cn != null && validTarget) {
// If the apk is present and the shortcut points to a specific
// component.
if (cn != null && validTarget) {
// If the apk is present and the shortcut points to a specific
// component.
// If the component is already present
if (launcherApps.isActivityEnabledForProfile(cn, c.user)) {
// no special handling necessary for this item
c.markRestored();
} else {
if (c.hasRestoreFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
// We allow auto install apps to have their intent
// updated after an install.
intent = pmHelper.getAppLaunchIntent(targetPkg, c.user);
if (intent != null) {
c.restoreFlag = 0;
c.updater().put(
LauncherSettings.Favorites.INTENT,
intent.toUri(0)).commit();
cn = intent.getComponent();
// If the component is already present
if (launcherApps.isActivityEnabledForProfile(cn, c.user)) {
// no special handling necessary for this item
c.markRestored();
} else {
if (c.hasRestoreFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
// We allow auto install apps to have their intent
// updated after an install.
intent = pmHelper.getAppLaunchIntent(targetPkg, c.user);
if (intent != null) {
c.restoreFlag = 0;
c.updater().put(
LauncherSettings.Favorites.INTENT,
intent.toUri(0)).commit();
cn = intent.getComponent();
} else {
c.markDeleted("Unable to find a launch target");
continue;
}
} else {
c.markDeleted("Unable to find a launch target");
// The app is installed but the component is no
// longer available.
c.markDeleted("Invalid component removed: " + cn);
continue;
}
} else {
// The app is installed but the component is no
// longer available.
c.markDeleted("Invalid component removed: " + cn);
continue;
}
}
}
// else if cn == null => can't infer much, leave it
// else if !validPkg => could be restored icon or missing sd-card
if (!TextUtils.isEmpty(targetPkg) && !validTarget) {
// Points to a valid app (superset of cn != null) but the apk
// is not available.
if (c.restoreFlag != 0) {
// Package is not yet available but might be
// installed later.
FileLog.d(TAG, "package not yet restored: " + targetPkg);
if (c.hasRestoreFlag(ShortcutInfo.FLAG_RESTORE_STARTED)) {
// Restore has started once.
} else if (installingPkgs.containsKey(targetPkg)) {
// App restore has started. Update the flag
c.restoreFlag |= ShortcutInfo.FLAG_RESTORE_STARTED;
c.updater().commit();
// else if cn == null => can't infer much, leave it
// else if !validPkg => could be restored icon or missing sd-card
if (!TextUtils.isEmpty(targetPkg) && !validTarget) {
// Points to a valid app (superset of cn != null) but the apk
// is not available.
if (c.restoreFlag != 0) {
// Package is not yet available but might be
// installed later.
FileLog.d(TAG, "package not yet restored: " + targetPkg);
if (c.hasRestoreFlag(ShortcutInfo.FLAG_RESTORE_STARTED)) {
// Restore has started once.
} else if (installingPkgs.containsKey(targetPkg)) {
// App restore has started. Update the flag
c.restoreFlag |= ShortcutInfo.FLAG_RESTORE_STARTED;
c.updater().commit();
} else {
c.markDeleted("Unrestored app removed: " + targetPkg);
continue;
}
} else if (pmHelper.isAppOnSdcard(targetPkg, c.user)) {
// Package is present but not available.
disabledState |= ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE;
// Add the icon on the workspace anyway.
allowMissingTarget = true;
} else if (!isSdCardReady) {
// SdCard is not ready yet. Package might get available,
// once it is ready.
Log.d(TAG, "Missing pkg, will check later: " + targetPkg);
pendingPackages.addToList(c.user, targetPkg);
// Add the icon on the workspace anyway.
allowMissingTarget = true;
} else {
c.markDeleted("Unrestored app removed: " + targetPkg);
// Do not wait for external media load anymore.
c.markDeleted("Invalid package removed: " + targetPkg);
continue;
}
} else if (pmHelper.isAppOnSdcard(targetPkg, c.user)) {
// Package is present but not available.
disabledState |= ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE;
// Add the icon on the workspace anyway.
allowMissingTarget = true;
} else if (!isSdCardReady) {
// SdCard is not ready yet. Package might get available,
// once it is ready.
Log.d(TAG, "Missing pkg, will check later: " + targetPkg);
pendingPackages.addToList(c.user, targetPkg);
// Add the icon on the workspace anyway.
allowMissingTarget = true;
} else {
// Do not wait for external media load anymore.
c.markDeleted("Invalid package removed: " + targetPkg);
continue;
}
}
if (validTarget) {
// The shortcut points to a valid target (either no target
// or something which is ready to be used)
c.markRestored();
}
if (validTarget) {
// The shortcut points to a valid target (either no target
// or something which is ready to be used)
c.markRestored();
}
boolean useLowResIcon = !c.isOnWorkspaceOrHotseat() &&
c.getInt(rankIndex) >= FolderIcon.NUM_ITEMS_IN_PREVIEW;
if (c.restoreFlag != 0) {
// Already verified above that user is same as default user
info = c.getRestoredItemInfo(intent);
} else if (c.itemType ==
LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
info = c.getAppShortcutInfo(
intent, allowMissingTarget, useLowResIcon);
} else if (c.itemType ==
LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
ShortcutKey key = ShortcutKey.fromIntent(intent, c.user);
if (unlockedUsers.get(c.serialNumber)) {
ShortcutInfoCompat pinnedShortcut =
shortcutKeyToPinnedShortcuts.get(key);
if (pinnedShortcut == null) {
// The shortcut is no longer valid.
c.markDeleted("Pinned shortcut not found");
continue;
}
info = new ShortcutInfo(pinnedShortcut, context);
info.iconBitmap = LauncherIcons
.createShortcutIcon(pinnedShortcut, context);
if (pmHelper.isAppSuspended(
pinnedShortcut.getPackage(), info.user)) {
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
boolean useLowResIcon = !c.isOnWorkspaceOrHotseat() &&
c.getInt(rankIndex) >= FolderIcon.NUM_ITEMS_IN_PREVIEW;
if (c.restoreFlag != 0) {
// Already verified above that user is same as default user
info = c.getRestoredItemInfo(intent);
} else if (c.itemType ==
LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
info = c.getAppShortcutInfo(
intent, allowMissingTarget, useLowResIcon);
} else if (c.itemType ==
LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
ShortcutKey key = ShortcutKey.fromIntent(intent, c.user);
if (unlockedUsers.get(c.serialNumber)) {
ShortcutInfoCompat pinnedShortcut =
shortcutKeyToPinnedShortcuts.get(key);
if (pinnedShortcut == null) {
// The shortcut is no longer valid.
c.markDeleted("Pinned shortcut not found");
continue;
}
info = new ShortcutInfo(pinnedShortcut, context);
info.iconBitmap = LauncherIcons
.createShortcutIcon(pinnedShortcut, context);
if (pmHelper.isAppSuspended(
pinnedShortcut.getPackage(), info.user)) {
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
}
intent = info.intent;
} else {
// Create a shortcut info in disabled mode for now.
info = c.loadSimpleShortcut();
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_LOCKED_USER;
}
intent = info.intent;
} else {
// Create a shortcut info in disabled mode for now.
} else { // item type == ITEM_TYPE_SHORTCUT
info = c.loadSimpleShortcut();
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_LOCKED_USER;
}
} else { // item type == ITEM_TYPE_SHORTCUT
info = c.loadSimpleShortcut();
// Shortcuts are only available on the primary profile
if (!TextUtils.isEmpty(targetPkg)
&& pmHelper.isAppSuspended(targetPkg, c.user)) {
disabledState |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
}
// Shortcuts are only available on the primary profile
if (!TextUtils.isEmpty(targetPkg)
&& pmHelper.isAppSuspended(targetPkg, c.user)) {
disabledState |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
}
// App shortcuts that used to be automatically added to Launcher
// didn't always have the correct intent flags set, so do that
// here
if (intent.getAction() != null &&
intent.getCategories() != null &&
intent.getAction().equals(Intent.ACTION_MAIN) &&
intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
// App shortcuts that used to be automatically added to Launcher
// didn't always have the correct intent flags set, so do that
// here
if (intent.getAction() != null &&
intent.getCategories() != null &&
intent.getAction().equals(Intent.ACTION_MAIN) &&
intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
}
}
if (info != null) {
c.applyCommonProperties(info);
if (info != null) {
c.applyCommonProperties(info);
info.intent = intent;
info.rank = c.getInt(rankIndex);
info.spanX = 1;
info.spanY = 1;
info.isDisabled |= disabledState;
if (isSafeMode && !Utilities.isSystemApp(context, intent)) {
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SAFEMODE;
}
info.intent = intent;
info.rank = c.getInt(rankIndex);
info.spanX = 1;
info.spanY = 1;
info.isDisabled |= disabledState;
if (isSafeMode && !Utilities.isSystemApp(context, intent)) {
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SAFEMODE;
}
if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
Integer progress = installingPkgs.get(targetPkg);
if (progress != null) {
info.setInstallProgress(progress);
} else {
info.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;
if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
Integer progress = installingPkgs.get(targetPkg);
if (progress != null) {
info.setInstallProgress(progress);
} else {
info.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;
}
}
}
c.checkAndAddItem(info, sBgDataModel);
} else {
throw new RuntimeException("Unexpected null ShortcutInfo");
}
break;
c.checkAndAddItem(info, sBgDataModel);
} else {
throw new RuntimeException("Unexpected null ShortcutInfo");
}
break;
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
FolderInfo folderInfo = sBgDataModel.findOrMakeFolder(c.id);
c.applyCommonProperties(folderInfo);
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
FolderInfo folderInfo = sBgDataModel.findOrMakeFolder(c.id);
c.applyCommonProperties(folderInfo);
// Do not trim the folder label, as is was set by the user.
folderInfo.title = c.getString(c.titleIndex);
folderInfo.spanX = 1;
folderInfo.spanY = 1;
folderInfo.options = c.getInt(optionsIndex);
// Do not trim the folder label, as is was set by the user.
folderInfo.title = c.getString(c.titleIndex);
folderInfo.spanX = 1;
folderInfo.spanY = 1;
folderInfo.options = c.getInt(optionsIndex);
// no special handling required for restored folders
c.markRestored();
// no special handling required for restored folders
c.markRestored();
c.checkAndAddItem(folderInfo, sBgDataModel);
break;
c.checkAndAddItem(folderInfo, sBgDataModel);
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
// Read all Launcher-specific widget details
boolean customWidget = c.itemType ==
LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
// Read all Launcher-specific widget details
boolean customWidget = c.itemType ==
LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
int appWidgetId = c.getInt(appWidgetIdIndex);
String savedProvider = c.getString(appWidgetProviderIndex);
int appWidgetId = c.getInt(appWidgetIdIndex);
String savedProvider = c.getString(appWidgetProviderIndex);
final ComponentName component =
ComponentName.unflattenFromString(savedProvider);
final ComponentName component =
ComponentName.unflattenFromString(savedProvider);
final boolean isIdValid = !c.hasRestoreFlag(
LauncherAppWidgetInfo.FLAG_ID_NOT_VALID);
final boolean wasProviderReady = !c.hasRestoreFlag(
LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY);
final boolean isIdValid = !c.hasRestoreFlag(
LauncherAppWidgetInfo.FLAG_ID_NOT_VALID);
final boolean wasProviderReady = !c.hasRestoreFlag(
LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY);
if (widgetProvidersMap == null) {
widgetProvidersMap = AppWidgetManagerCompat
.getInstance(mContext).getAllProvidersMap();
}
final AppWidgetProviderInfo provider = widgetProvidersMap.get(
new ComponentKey(
ComponentName.unflattenFromString(savedProvider),
c.user));
final boolean isProviderReady = isValidProvider(provider);
if (!isSafeMode && !customWidget &&
wasProviderReady && !isProviderReady) {
c.markDeleted(
"Deleting widget that isn't installed anymore: "
+ provider);
} else {
if (isProviderReady) {
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,
provider.provider);
// The provider is available. So the widget is either
// available or not available. We do not need to track
// any future restore updates.
int status = c.restoreFlag &
~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
if (!wasProviderReady) {
// If provider was not previously ready, update the
// status and UI flag.
// Id would be valid only if the widget restore broadcast was received.
if (isIdValid) {
status |= LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
} else {
status &= ~LauncherAppWidgetInfo
.FLAG_PROVIDER_NOT_READY;
if (widgetProvidersMap == null) {
widgetProvidersMap = AppWidgetManagerCompat
.getInstance(mContext).getAllProvidersMap();
}
final AppWidgetProviderInfo provider = widgetProvidersMap.get(
new ComponentKey(
ComponentName.unflattenFromString(savedProvider),
c.user));
final boolean isProviderReady = isValidProvider(provider);
if (!isSafeMode && !customWidget &&
wasProviderReady && !isProviderReady) {
c.markDeleted(
"Deleting widget that isn't installed anymore: "
+ provider);
} else {
if (isProviderReady) {
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,
provider.provider);
// The provider is available. So the widget is either
// available or not available. We do not need to track
// any future restore updates.
int status = c.restoreFlag &
~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
if (!wasProviderReady) {
// If provider was not previously ready, update the
// status and UI flag.
// Id would be valid only if the widget restore broadcast was received.
if (isIdValid) {
status |= LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
} else {
status &= ~LauncherAppWidgetInfo
.FLAG_PROVIDER_NOT_READY;
}
}
appWidgetInfo.restoreStatus = status;
} else {
Log.v(TAG, "Widget restore pending id=" + c.id
+ " appWidgetId=" + appWidgetId
+ " status =" + c.restoreFlag);
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,
component);
appWidgetInfo.restoreStatus = c.restoreFlag;
Integer installProgress = installingPkgs.get(component.getPackageName());
if (c.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_RESTORE_STARTED)) {
// Restore has started once.
} else if (installProgress != null) {
// App restore has started. Update the flag
appWidgetInfo.restoreStatus |=
LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
} else if (!isSafeMode) {
c.markDeleted("Unrestored widget removed: " + component);
continue;
}
appWidgetInfo.installProgress =
installProgress == null ? 0 : installProgress;
}
appWidgetInfo.restoreStatus = status;
} else {
Log.v(TAG, "Widget restore pending id=" + c.id
+ " appWidgetId=" + appWidgetId
+ " status =" + c.restoreFlag);
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,
component);
appWidgetInfo.restoreStatus = c.restoreFlag;
Integer installProgress = installingPkgs.get(component.getPackageName());
if (c.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_RESTORE_STARTED)) {
// Restore has started once.
} else if (installProgress != null) {
// App restore has started. Update the flag
appWidgetInfo.restoreStatus |=
LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
} else if (!isSafeMode) {
c.markDeleted("Unrestored widget removed: " + component);
continue;
if (appWidgetInfo.hasRestoreFlag(
LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG)) {
appWidgetInfo.bindOptions = c.parseIntent();
}
appWidgetInfo.installProgress =
installProgress == null ? 0 : installProgress;
}
if (appWidgetInfo.hasRestoreFlag(
LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG)) {
appWidgetInfo.bindOptions = c.parseIntent();
}
c.applyCommonProperties(appWidgetInfo);
appWidgetInfo.spanX = c.getInt(spanXIndex);
appWidgetInfo.spanY = c.getInt(spanYIndex);
appWidgetInfo.user = c.user;
c.applyCommonProperties(appWidgetInfo);
appWidgetInfo.spanX = c.getInt(spanXIndex);
appWidgetInfo.spanY = c.getInt(spanYIndex);
appWidgetInfo.user = c.user;
if (!c.isOnWorkspaceOrHotseat()) {
c.markDeleted("Widget found where container != " +
"CONTAINER_DESKTOP nor CONTAINER_HOTSEAT - ignoring!");
continue;
}
if (!c.isOnWorkspaceOrHotseat()) {
c.markDeleted("Widget found where container != " +
"CONTAINER_DESKTOP nor CONTAINER_HOTSEAT - ignoring!");
continue;
}
if (!customWidget) {
String providerName =
appWidgetInfo.providerName.flattenToString();
if (!providerName.equals(savedProvider) ||
(appWidgetInfo.restoreStatus != c.restoreFlag)) {
c.updater()
.put(LauncherSettings.Favorites.APPWIDGET_PROVIDER,
providerName)
.put(LauncherSettings.Favorites.RESTORED,
appWidgetInfo.restoreStatus)
.commit();
if (!customWidget) {
String providerName =
appWidgetInfo.providerName.flattenToString();
if (!providerName.equals(savedProvider) ||
(appWidgetInfo.restoreStatus != c.restoreFlag)) {
c.updater()
.put(LauncherSettings.Favorites.APPWIDGET_PROVIDER,
providerName)
.put(LauncherSettings.Favorites.RESTORED,
appWidgetInfo.restoreStatus)
.commit();
}
}
c.checkAndAddItem(appWidgetInfo, sBgDataModel);
}
c.checkAndAddItem(appWidgetInfo, sBgDataModel);
}
break;
break;
}
} catch (Exception e) {
Log.e(TAG, "Desktop items loading interrupted", e);
......@@ -1287,7 +1329,7 @@ public class LauncherModel extends BroadcastReceiver
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
mIconCache.getTitleAndIcon(info, false);
}
pos ++;
pos++;
if (pos >= FolderIcon.NUM_ITEMS_IN_PREVIEW) {
break;
}
......@@ -1306,7 +1348,7 @@ public class LauncherModel extends BroadcastReceiver
// Remove any empty screens
ArrayList<Long> unusedScreens = new ArrayList<>(sBgDataModel.workspaceScreens);
for (ItemInfo item: sBgDataModel.itemsIdMap) {
for (ItemInfo item : sBgDataModel.itemsIdMap) {
long screenId = item.screenId;
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
unusedScreens.contains(screenId)) {
......@@ -1325,12 +1367,14 @@ public class LauncherModel extends BroadcastReceiver
}
}
/** Filters the set of items who are directly or indirectly (via another container) on the
* specified screen. */
/**
* Filters the set of items who are directly or indirectly (via another container) on the
* specified screen.
*/
private void filterCurrentWorkspaceItems(long currentScreenId,
ArrayList<ItemInfo> allWorkspaceItems,
ArrayList<ItemInfo> currentScreenItems,
ArrayList<ItemInfo> otherScreenItems) {
ArrayList<ItemInfo> allWorkspaceItems,
ArrayList<ItemInfo> currentScreenItems,
ArrayList<ItemInfo> otherScreenItems) {
// Purge any null ItemInfos
Iterator<ItemInfo> iter = allWorkspaceItems.iterator();
while (iter.hasNext()) {
......@@ -1372,11 +1416,13 @@ public class LauncherModel extends BroadcastReceiver
}
}
/** Filters the set of widgets which are on the specified screen. */
/**
* Filters the set of widgets which are on the specified screen.
*/
private void filterCurrentAppWidgets(long currentScreenId,
ArrayList<LauncherAppWidgetInfo> appWidgets,
ArrayList<LauncherAppWidgetInfo> currentScreenWidgets,
ArrayList<LauncherAppWidgetInfo> otherScreenWidgets) {
ArrayList<LauncherAppWidgetInfo> appWidgets,
ArrayList<LauncherAppWidgetInfo> currentScreenWidgets,
ArrayList<LauncherAppWidgetInfo> otherScreenWidgets) {
for (LauncherAppWidgetInfo widget : appWidgets) {
if (widget == null) continue;
......@@ -1389,8 +1435,10 @@ public class LauncherModel extends BroadcastReceiver
}
}
/** Sorts the set of items by hotseat, workspace (spatially from top to bottom, left to
* right) */
/**
* Sorts the set of items by hotseat, workspace (spatially from top to bottom, left to
* right)
*/
private void sortWorkspaceItemsSpatially(ArrayList<ItemInfo> workspaceItems) {
final InvariantDeviceProfile profile = mApp.getInvariantDeviceProfile();
final int screenCols = profile.numColumns;
......@@ -1428,7 +1476,7 @@ public class LauncherModel extends BroadcastReceiver
}
private void bindWorkspaceScreens(final Callbacks oldCallbacks,
final ArrayList<Long> orderedScreens) {
final ArrayList<Long> orderedScreens) {
final Runnable r = new Runnable() {
@Override
public void run() {
......@@ -1442,21 +1490,21 @@ public class LauncherModel extends BroadcastReceiver
}
private void bindWorkspaceItems(final Callbacks oldCallbacks,
final ArrayList<ItemInfo> workspaceItems,
final ArrayList<LauncherAppWidgetInfo> appWidgets,
final Executor executor) {
final ArrayList<ItemInfo> workspaceItems,
final ArrayList<LauncherAppWidgetInfo> appWidgets,
final Executor executor) {
// Bind the workspace items
int N = workspaceItems.size();
for (int i = 0; i < N; i += ITEMS_CHUNK) {
final int start = i;
final int chunkSize = (i+ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N-i);
final int chunkSize = (i + ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N - i);
final Runnable r = new Runnable() {
@Override
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.bindItems(workspaceItems, start, start+chunkSize,
callbacks.bindItems(workspaceItems, start, start + chunkSize,
false);
}
}
......@@ -1596,7 +1644,7 @@ public class LauncherModel extends BroadcastReceiver
// If we're profiling, ensure this is the last thing in the queue.
if (DEBUG_LOADERS) {
Log.d(TAG, "bound workspace in "
+ (SystemClock.uptimeMillis()-t) + "ms");
+ (SystemClock.uptimeMillis() - t) + "ms");
}
}
......@@ -1652,8 +1700,7 @@ public class LauncherModel extends BroadcastReceiver
}
// shallow copy
@SuppressWarnings("unchecked")
final ArrayList<AppInfo> list
@SuppressWarnings("unchecked") final ArrayList<AppInfo> list
= (ArrayList<AppInfo>) mBgAllAppsList.data.clone();
Runnable r = new Runnable() {
public void run() {
......@@ -1672,7 +1719,7 @@ public class LauncherModel extends BroadcastReceiver
}
private void scheduleManagedHeuristicRunnable(final ManagedProfileHeuristic heuristic,
final UserHandle user, final List<LauncherActivityInfo> apps) {
final UserHandle user, final List<LauncherActivityInfo> apps) {
if (heuristic != null) {
// Assume the app lists now is updated.
mIsManagedHeuristicAppsUpdated = false;
......@@ -1732,8 +1779,8 @@ public class LauncherModel extends BroadcastReceiver
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
if (DEBUG_LOADERS) {
Log.d(TAG, "getActivityList took "
+ (SystemClock.uptimeMillis()-qiaTime) + "ms for user " + user);
if(apps != null) {
+ (SystemClock.uptimeMillis() - qiaTime) + "ms for user " + user);
if (apps != null) {
Log.d(TAG, "getActivityList got " + apps.size() + " apps for user " + user);
} else {
Log.d(TAG, "getActivityList got apps = null ");
......@@ -1749,6 +1796,11 @@ public class LauncherModel extends BroadcastReceiver
for (int i = 0; i < apps.size(); i++) {
LauncherActivityInfo app = apps.get(i);
// This builds the icon bitmaps.
// 不显示本应用
if (app.getComponentName() != null
&& TextUtils.equals(mContext.getPackageName(), app.getComponentName().getPackageName())) {
continue;
}
mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);
}
final ManagedProfileHeuristic heuristic = ManagedProfileHeuristic.get(mContext, user);
......@@ -1820,20 +1872,20 @@ public class LauncherModel extends BroadcastReceiver
final Context context = mApp.getContext();
ArrayList<ItemInfo> tmpInfos;
ArrayList<ItemInfo> added = new ArrayList<ItemInfo>();
Log.e(TAG, mBgAllAppsList.data.size()+"");
Log.e(TAG, mBgAllAppsList.data.size() + "");
synchronized (sBgDataModel) {
for (AppInfo app : mBgAllAppsList.data) {
//tmpInfos = getItemInfoForComponentName(app.componentName, app.user);
//if (tmpInfos.isEmpty()) {
// We are missing an application icon, so add this to the workspace
if(app.itemType!=LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
added.add(app);
}
// This is a rare event, so lets log it
// We are missing an application icon, so add this to the workspace
if (app.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
added.add(app);
}
// This is a rare event, so lets log it
// Log.e(TAG, "Missing Application on load: " + app);
// }
// }
}
Log.i(TAG, "added size : "+added.size());
Log.i(TAG, "added size : " + added.size());
if (!added.isEmpty()) {
addAndBindAddedWorkspaceItems(added);
}
......@@ -1974,7 +2026,7 @@ public class LauncherModel extends BroadcastReceiver
}
public void refreshAndBindWidgetsAndShortcuts(final Callbacks callbacks,
final boolean bindFirst, @Nullable final PackageUserKey packageUser) {
final boolean bindFirst, @Nullable final PackageUserKey packageUser) {
runOnWorkerThread(new Runnable() {
@Override
public void run() {
......@@ -2020,7 +2072,8 @@ public class LauncherModel extends BroadcastReceiver
}
}
@Thunk class DeferredMainThreadExecutor implements Executor {
@Thunk
class DeferredMainThreadExecutor implements Executor {
@Override
public void execute(Runnable command) {
......@@ -2068,9 +2121,10 @@ public class LauncherModel extends BroadcastReceiver
return new ArrayList<ItemInfo>(filtered);
}
@Thunk ArrayList<ItemInfo> getItemInfoForComponentName(final ComponentName cname,
final UserHandle user) {
ItemInfoFilter filter = new ItemInfoFilter() {
@Thunk
ArrayList<ItemInfo> getItemInfoForComponentName(final ComponentName cname,
final UserHandle user) {
ItemInfoFilter filter = new ItemInfoFilter() {
@Override
public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {
if (info.user == null) {
......
......@@ -43,36 +43,34 @@ public class ManagerAuthActivity extends BaseActivity {
showPwdDialog();
}
private void showPwdDialog() {
if (mPwdDialog == null) {
final EditText editText = new EditText(this);
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
TextView textView = new TextView(this);
textView.setText("验证密保");
textView.setTextColor(getColor(R.color.activation_black));
textView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
textView.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
textView.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
textView.setPadding(15, 15, 15, 15);
// TextView textView = new TextView(this);
// textView.setText("验证密保");
// textView.setTextColor(getColor(R.color.activation_black));
// textView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
// textView.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
// textView.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
// textView.setPadding(15, 15, 15, 15);
View view = LayoutInflater.from(mAppContext).inflate(R.layout.item_ll, null);
LinearLayout ll = view.findViewById(R.id.item_ll);
ll.addView(editText);
ll.addView(textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ManagerAuthActivity.this, VerifyPwdProtectionActivity.class);
intent.putExtra(FROM_WHERE, ManagerAuthActivity.class.getSimpleName());
startActivity(intent);
if (mPwdDialog != null && mPwdDialog.isShowing()) {
InputUtil.closeSoftInput(getApplicationContext(), editText);
mPwdDialog.dismiss();
finish();
}
}
});
// ll.addView(textView);
// textView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(ManagerAuthActivity.this, VerifyPwdProtectionActivity.class);
// intent.putExtra(FROM_WHERE, ManagerAuthActivity.class.getSimpleName());
// startActivity(intent);
// if (mPwdDialog != null && mPwdDialog.isShowing()) {
// InputUtil.closeSoftInput(getApplicationContext(), editText);
// mPwdDialog.dismiss();
// finish();
// }
// }
// });
mPwdDialog = new AlertDialog.Builder(this)
.setTitle("请输入密码")
.setCancelable(false)
......@@ -114,7 +112,7 @@ public class ManagerAuthActivity extends BaseActivity {
finish();
}
}else {
ToastUtil.showShort(mAppContext,"请在"+ ErrorTimeHelper.getInstance(mAppContext).getCountDownTime()+"秒后试");
ToastUtil.showShort(mAppContext,"请在"+ ErrorTimeHelper.getInstance(mAppContext).getCountDownTime()+"秒后试");
finish();
}
......
package com.android.launcher3;
import android.support.v7.app.AppCompatActivity;
public class SwitchOutActivity extends AppCompatActivity {
}
package com.android.launcher3.function.pwd;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.secspace.lib.common.utils.Prefs;
import com.secspace.lib.common.utils.ToastUtil;
import org.greenrobot.eventbus.EventBus;
import java.util.regex.Pattern;
/**
* @author huangzhencheng
*/
public class PwdPinSetPwdActivity extends AppCompatActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static final String TAG = PwdPinSetPwdActivity.class.getSimpleName();
/**
* 字符密码正则
*/
private Pattern datePatt = Pattern.compile("^(?![0-9]+$)(?![a-zA-Z]+$)(?!([^(0-9a-zA-Z)]|[\\(\\)])+$)([^(0-9a-zA-Z)]|[\\(\\)]|[a-zA-Z]|[0-9]){8,16}$");
/**
* 数字密码正则
*/
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
/**
* 密码最大程度
*/
public static final int PWD_MAX_LENGTH = 16;
/**
* 密码短程度
*/
public static final int PWD_TINY_LENGTH = 6;
EditText mEditPwd;
CheckBox mCbShowPwd;
Button mBtSure;
TextView mTvtip;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pwd_pin_set);
initView();
initToolbar();
}
private void initView() {
mEditPwd = findViewById(R.id.edit_pwd);
mCbShowPwd = findViewById(R.id.cb_show_pwd);
mBtSure = findViewById(R.id.btn_sure);
mTvtip = findViewById(R.id.tv_tip);
mBtSure.setOnClickListener(this);
mCbShowPwd.setOnCheckedChangeListener(this);
}
private void initToolbar() {
// setSupportActionBar(mToolbar);
// mEditSearch.setVisibility(View.GONE);
// mToolbarTitle.setText("设置混合密码");
// mTvtip.setText("密码必须为数字、字母或常用符号的8-16位组合");
// mEditPwd.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
//
// mToolbarLeftImg.setImageResource(R.mipmap.back);
// mToolbarRightImg.setVisibility(View.GONE);
// mToolbarRightText.setVisibility(View.GONE);
// mToolbarLeftImg.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// finish();
// }
// });
// mBtSure.setOnClickListener(this);
// mCbShowPwd.setOnClickListener(this);
// mCbShowPwd.setOnCheckedChangeListener(this);
}
private void startLauncher() {
Intent intent = new Intent();
intent.setAction("android.start_launcher");
intent.setPackage(this.getPackageName());
intent.setClass(this, Launcher.class);
startActivity(intent);
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_sure:
String pwd = String.valueOf(mEditPwd.getText());
if (TextUtils.isEmpty(pwd)) {
ToastUtil.showShort(this, "密码不能为空");
return;
}
if (pwd.length() < PWD_TINY_LENGTH) {
ToastUtil.showShort(this, "密码至少为6位");
return;
}
// if (pwd.length() > PWD_MAX_LENGTH) {
// ToastUtil.showShort(this, "密码不能超过16位");
// return;
// }
Log.i(TAG, "matches: " + datePatt.matcher(pwd).matches());
// if (!datePatt.matcher(pwd).matches()) {
// ToastUtil.showShort(this, "新密码必须为数字、字母或常用符号的8-16位组合");
// return;
// }
Prefs.setLoginPwd(this, pwd);
startLauncher();
break;
default:
break;
}
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Log.i(TAG, "onCheckedChanged: TYPE_TEXT_VARIATION_PASSWORD");
mEditPwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else {
mEditPwd.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
}
}
}
......@@ -110,7 +110,7 @@ public class ChangePwdActivity extends AppCompatActivity implements View.OnClick
String originalPwd = mEditOriginalPwd.getText().toString();
String confirmNewPwd = mEditConfirmNewPwd.getText().toString();
if (!ErrorTimeHelper.getInstance(this).canShowDialog()) {
ToastUtil.showShort(this,"请在"+ ErrorTimeHelper.getInstance(this).getCountDownTime()+"秒后试");
ToastUtil.showShort(this,"请在"+ ErrorTimeHelper.getInstance(this).getCountDownTime()+"秒后试");
return;
}
......
......@@ -19,10 +19,13 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.mdm.MdmUtils;
import com.android.launcher3.settings.wifi.WifiWhiteListActivity;
import com.secspace.lib.common.dialog.SwitcherDialog;
import com.secspace.lib.common.event.ChangeWallPaperEvent;
import com.secspace.lib.common.update.CheckUpdateCore;
import com.secspace.lib.common.utils.ActivityHelper;
import com.secspace.lib.common.utils.Prefs;
import com.secspace.lib.common.utils.ToastUtil;
import com.secspace.lib.common.utils.UninstallUtil;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import org.greenrobot.eventbus.EventBus;
......@@ -42,6 +45,8 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
private Button mBtnAtuoStart;
private Button mWifiWhiteList;
private Button mBtnDisableManager;
private Button mBtnUpdate;
private Button mBtnUninstall;
//允许添加先安装应用
public static final int ALLOW_NEW_APP = 0;
//允许本身自启
......@@ -86,7 +91,8 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
mBtnChangeWallPaper.setOnClickListener(this);
mWifiWhiteList.setOnClickListener(this);
mBtnDisableManager.setOnClickListener(this);
mBtnUpdate.setOnClickListener(this);
mBtnUninstall.setOnClickListener(this);
}
private void initView() {
......@@ -98,14 +104,16 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
mBtnInvisibleMenu = findViewById(R.id.btn_invisible_menu);
mBtnAtuoStart = findViewById(R.id.btn_auto_start);
mWifiWhiteList = findViewById(R.id.btn_wifi_whitelist);
mBtnDisableManager=findViewById(R.id.btn_manager_disable);
mBtnDisableManager = findViewById(R.id.btn_manager_disable);
mBtnUpdate = findViewById(R.id.btn_update);
mBtnUninstall = findViewById(R.id.btn_uninstall);
findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
mTvTitle=findViewById(R.id.tv_title);
mTvTitle = findViewById(R.id.tv_title);
mTvTitle.setText("设置");
}
......@@ -195,12 +203,12 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
switch (v.getId()) {
case R.id.btn_change_pwd:
Intent intent1 = new Intent(this, ChangePwdActivity.class);
intent1.putExtra(IS_SHOW_ORIGINAL_PWD,true);
intent1.putExtra(IS_SHOW_ORIGINAL_PWD, true);
startActivity(intent1);
break;
case R.id.btn_set_pwdcar:
Intent intent2 = new Intent(this, VerifyPwdProtectionActivity.class);
intent2.putExtra(FROM_WHERE,SettingActivity.class.getSimpleName());
intent2.putExtra(FROM_WHERE, SettingActivity.class.getSimpleName());
startActivity(intent2);
break;
case R.id.btn_auto_start:
......@@ -227,12 +235,41 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
startActivityForResult(intent, REQUEST_PICK_WALLPAPER);
break;
case R.id.btn_manager_disable:
startActivity(new Intent(this,ManagerDisableActivity.class));
startActivity(new Intent(this, ManagerDisableActivity.class));
break;
case R.id.btn_update:
CheckUpdateCore.get().enableUpdate();
ToastUtil.showLong(mContext, "正在检测更新,请稍后");
break;
case R.id.btn_uninstall:
uninstall();
break;
}
}
private void uninstall(){
SwitcherDialog.getInstance(mContext).show("正在卸载中,请稍后", "unInstall");
UninstallUtil.INSTANCE.removeForbidden(mContext);
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);
runOnUiThread(new Runnable() {
@Override
public void run() {
SwitcherDialog.getInstance(mContext).dismiss("unInstall");
UninstallUtil.INSTANCE.uninstallService(mContext);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
}
@Override
protected void onActivityResult(
final int requestCode, final int resultCode, final Intent data) {
......@@ -241,7 +278,7 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
Log.e("WWWW", "AAAAA");
Uri selectedImage = data.getData();
EventBus.getDefault().postSticky(new ChangeWallPaperEvent(selectedImage));
ToastUtil.showShort(this,"壁纸修改成功");
ToastUtil.showShort(this, "壁纸修改成功");
}
}
}
......
......@@ -69,7 +69,7 @@ public class VerifyPwdProtectionActivity extends AppCompatActivity implements Vi
String answer1 = mEditAnswer1.getText().toString();
String answer2 = mEditAnswer2.getText().toString();
if (!ErrorTimeHelper.getInstance(this).canShowDialog()){
ToastUtil.showShort(this,"请在"+ ErrorTimeHelper.getInstance(this).getCountDownTime()+"秒后试");
ToastUtil.showShort(this,"请在"+ ErrorTimeHelper.getInstance(this).getCountDownTime()+"秒后试");
return;
}
if (TextUtils.isEmpty(answer1) || TextUtils.isEmpty(answer2)) {
......
......@@ -75,7 +75,7 @@ public class WifiScanService extends Service {
}
if (!Prefs.isAutoStartSelf(mContext)){
// writeLog(timeStamp2Date(System.currentTimeMillis())+"\r\n");
mContext.startService(new Intent(mContext,WifiScanService.class));
// mContext.startService(new Intent(mContext,WifiScanService.class));
}
sendEmptyMessageDelayed(1, 8000);
}
......@@ -100,9 +100,9 @@ public class WifiScanService extends Service {
Intent nfIntent = new Intent(this, Launcher.class);
builder.setContentIntent(PendingIntent.
getActivity(this, 0, nfIntent, 0)) // 设置PendingIntent
.setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.launcher_self)) // 设置下拉列表中的图标(大图标)
.setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.launcher_in)) // 设置下拉列表中的图标(大图标)
.setContentTitle("移动终端软件正在运行") // 设置下拉列表里的标题
.setSmallIcon(R.drawable.launcher_self) // 设置状态栏内的小图标
.setSmallIcon(R.drawable.launcher_in) // 设置状态栏内的小图标
.setContentText("移动终端软件正在运行")// 设置上下文内容
.setDefaults(NotificationCompat.FLAG_ONLY_ALERT_ONCE);
notification = builder.build(); // 获取构建好的Notification;
......
......@@ -47,6 +47,10 @@ android {
signingConfig signingConfigs.debug
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
......@@ -57,6 +61,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile project(path: ':lib_common')
api project(path: ':lib_common')
implementation 'com.secspace:provider_mdm_engine:1.0.0.40'
}
......@@ -16,7 +16,7 @@
<Button
android:onClick="uninstall_mobile_steward"
android:text="卸载移动管家"
android:text="卸载学习空间"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
......
......@@ -21,6 +21,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
......
......@@ -8,11 +8,10 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
......
......@@ -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/
#32位有符号数2147483647(10)
versionIntCode=2019083001
versionIntCode=2020031702
versionNameMajor=1
versionNameMinor=0
versionNamePatch=1
\ No newline at end of file
versionNamePatch=0
\ No newline at end of file
#Wed Aug 07 11:15:53 CST 2019
#Mon Mar 16 14:03:33 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
......@@ -18,6 +20,18 @@ android {
arguments = [AROUTER_MODULE_NAME: project.getName(), AROUTER_GENERATE_DOC: "enable"]
}
}
// 更新标准版自测
buildConfigField "String", "UPDATE_SERVER", "\"https://tj.secspace365.cn/SKRAC/\""
//buildConfigField "String", "UPDATE_SERVER", "\"https://114.215.44.230/SKRAC/\""
// 1- 独立 2- 售后
buildConfigField "int", "UPDATE_PLATFORM", "2"
// 公司编号
buildConfigField "String", "COMPANY_ID", "\"1\""
// 更新名称
buildConfigField "String", "UPDATE_FLAG", "\"eduspace_demo\""
// 是否自动更新
buildConfigField "boolean", "AUTO_UPDATE", "true"
}
lintOptions {
......@@ -84,9 +98,9 @@ dependencies {
// sqlcipher
api 'net.zetetic:android-database-sqlcipher:3.5.9@aar'
api 'com.alibaba:arouter-api:1.4.1'
api 'com.liulishuo.okdownload:okdownload:1.0.5-SNAPSHOT'
api 'com.liulishuo.okdownload:sqlite:1.0.5-SNAPSHOT'
api 'com.liulishuo.okdownload:okhttp:1.0.5-SNAPSHOT'
api 'com.liulishuo.okdownload:okdownload:1.0.5'
api 'com.liulishuo.okdownload:sqlite:1.0.5'
api 'com.liulishuo.okdownload:okhttp:1.0.5'
debugApi 'com.github.markzhai:blockcanary-android:1.5.0'
releaseApi 'com.github.markzhai:blockcanary-no-op:1.5.0'
api 'com.skr:cryptology:1.0.0.9'
......@@ -98,6 +112,14 @@ dependencies {
annotationProcessor 'com.alibaba:arouter-compiler:1.2.2'
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
api 'com.tk.lib:log:1.0.3'
implementation 'com.secspace:provider_mdm_engine:1.0.0.32'
implementation 'com.secspace:provider_mdm_engine:1.1.0.60'
implementation files('libs/jxl.jar')
implementation files('libs/activation.aar')
implementation files('libs/update-excludePush-release.aar')
// Room
implementation 'com.tk.lib:room:1.0.2'
// Downloader
implementation 'com.tk.lib:downloader:1.0.6'
implementation 'com.tk.lib:dialog:1.0.2'
}
\ No newline at end of file
......@@ -5,6 +5,8 @@
android:name="secspace.permission.sec.Default"
android:label="@string/common_sec_permission_default"
android:protectionLevel="signature"></permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="secspace.permission.sec.Default"></uses-permission>
<application>
......
......@@ -208,4 +208,8 @@ public class Packages {
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";
}
}
package com.secspace.lib.common.update;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import com.alibaba.android.arouter.launcher.ARouter;
import com.secspace.lib.common.BuildConfig;
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.OnPushTokenUpdateEvent;
import com.secspace.lib.common.utils.DeviceUtil;
import com.secspace.lib.common.utils.ImeiUtil;
import com.secspace.lib.common.utils.VUidUtil;
import com.secspace.log.Log;
import com.skr.update.AppUpdateManager;
import com.skr.update.annotation.ApkPlatform;
import com.skr.update.annotation.AppInstallPolicy;
import com.skr.update.annotation.CheckType;
import com.skr.update.db.DbRepo;
import com.skr.update.db.entity.AppUpdateInfo;
import com.skr.update.listener.OnCheckUpdateListener;
import com.skr.update.option.PlatformUpdateOption;
import com.skr.update.option.PushOption;
import com.skr.update.option.SalesPlatformUpdateOption;
import com.skr.update.option.SinglePlatformUpdateOption;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import static com.secspace.lib.common.env.Intents.Launcher.ACTION_HAS_UPDATE;
import static com.secspace.lib.common.env.Intents.Launcher.ACTION_NO_UPDATE;
/**
* Launcher
*
* @author lichuanzhi@tiankuan.net
*/
@SuppressLint("StaticFieldLeak")
public class CheckUpdateCore {
private static final CheckUpdateCore INST = new CheckUpdateCore();
private static final String TAG = "CheckUpdateCore";
private Context mAppCtx;
private CheckUpdateCore() {
}
public static CheckUpdateCore get() {
return INST;
}
public void init(Context context, AppUpdateManager.OnAppUpdateListener listener) {
mAppCtx = context.getApplicationContext();
int[] certificates = new int[]{R.raw.tj_secspace365_cn, R.raw.tomcat_114_215_44_230, R.raw.tomcat_115_29_115_27};
AppUpdateManager.get().init(context, certificates, listener);
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
}
/**
* push token
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onToken(OnPushTokenUpdateEvent e) {
PushOption option = AppUpdateManager.get().getPushOption();
if(option!=null){
AppUpdateManager.get().uploadPushToken(e.token);
}
}
/**
* push message
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPushMessage(OnPushMessageEvent e) {
AppUpdateManager.get().onReceivePush(e.message);
}
/**
* 启用更新
*/
public void enableUpdate() {
Log.i(TAG, "enableUpdate");
if (BuildConfig.AUTO_UPDATE) {
enableAutoUpdate();
} else {
checkUpdate(false);
}
}
/**
* 打开自动更新
*/
private void enableAutoUpdate() {
int platform = BuildConfig.UPDATE_PLATFORM;
String imei = ImeiUtil.INSTANCE.imei(mAppCtx);
if (TextUtils.isEmpty(imei)) {
return;
}
PlatformUpdateOption option;
if (platform == ApkPlatform.SALES) {
option = new SalesPlatformUpdateOption.Builder()
.imei(imei)
.server(BuildConfig.UPDATE_SERVER)
.name(BuildConfig.UPDATE_FLAG)
.companyId(BuildConfig.COMPANY_ID)
.showDownloadDialog(false)
.showDownloadNotification(false)
.appInstallPolicy(AppInstallPolicy.SILENT_INSTALL)
.build();
} else {
option = new SinglePlatformUpdateOption.Builder()
.imei(imei)
.server(BuildConfig.UPDATE_SERVER)
.showDownloadDialog(false)
.showDownloadNotification(false)
.appInstallPolicy(AppInstallPolicy.SILENT_INSTALL)
.build();
}
AppUpdateManager.get().startAutoUpdate(option);
PushOption pushOption = new PushOption.Builder()
.imei(imei)
.platform(platform)
.server(BuildConfig.UPDATE_SERVER)
.build();
AppUpdateManager.get().enablePush(pushOption);
}
/**
* 检查更新
*/
public void checkUpdate(boolean isManual) {
String imei = DeviceUtil.getIMEI(mAppCtx);
SalesPlatformUpdateOption option = new SalesPlatformUpdateOption.Builder()
.imei(imei)
.server(BuildConfig.UPDATE_SERVER)
.name(BuildConfig.UPDATE_FLAG)
.companyId(BuildConfig.COMPANY_ID)
.showDownloadDialog(false)
.showDownloadNotification(true)
.appInstallPolicy(AppInstallPolicy.SILENT_INSTALL)
.build();
AppUpdateManager.get().checkUpdate(option, isManual, new OnCheckUpdateListener() {
@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;
}
});
}
/**
* 是否有检查更新
*/
public boolean hasManualUpdate() {
int versionCode = 0;
try {
PackageInfo pi = mAppCtx.getPackageManager().getPackageInfo(mAppCtx.getPackageName(), 0);
if (pi != null) {
versionCode = pi.versionCode;
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
AppUpdateInfo info = DbRepo.get().queryUncompletedAppUpdateByCheckType(CheckType.MANUAL);
return info != null && info.getVersionCode() > versionCode;
}
}
package com.secspace.lib.common.utils;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
public class DisableCompat {
private static final String TAG = "DisableCompat";
public static final String PACKAGENAME_WORKSPACE = "com.safe.workspace";
public static final String CCOMPONENT_WORKSPACE_ADMIN_CLASS = "ch.deletescape.lawnchair.DeviceAdminReceiver";
public static void disableComponent(Context context, ComponentName componentName) {
try {
PackageManager packageManager = context.getPackageManager();
packageManager.setComponentEnabledSetting(componentName, COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} catch (Exception e) {
Log.e(TAG, "disableComponent Error: " + e.toString());
}
}
public static void enableComponent(Context context, ComponentName componentName) {
try {
Log.i(TAG, "DisableCompat-enableComponent: " + componentName.toShortString());
PackageManager packageManager = context.getPackageManager();
packageManager.setComponentEnabledSetting(componentName, COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
} catch (Exception e) {
Log.e(TAG, "enableComponent Error: " + e.toString());
}
}
/**
* 启用应用
*/
public static boolean enablePackage(Context context, String packageName, boolean enable) {
Log.d(TAG, "enable package " + packageName + ", enable " + enable);
try {
DevicePolicyManager manager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (manager != null) {
ComponentName componentName = new ComponentName(PACKAGENAME_WORKSPACE, CCOMPONENT_WORKSPACE_ADMIN_CLASS);
boolean isHidden = manager.isApplicationHidden(componentName, packageName);
if (enable && !isHidden || !enable && isHidden) {
Log.d(TAG, "enable = " + enable + ",isHidden ? " + isHidden);
return false;
}
return manager.setApplicationHidden(componentName, packageName, !enable);
}
} catch (Exception e) {
Log.e(TAG, "enable package " + packageName + " failed, e = " + Log.getStackTraceString(e));
}
return false;
}
}
package com.secspace.lib.common.utils
import android.app.Activity
import android.content.Context
import android.os.Environment
import android.telephony.TelephonyManager
import android.util.Log
import java.io.*
import java.lang.Exception
import java.util.*
object ImeiUtil {
private val TEMP_DIR = Environment.getExternalStorageDirectory().toString() + "/.uuid"
private const val TEMP_FILE_NAME = ".system_file"
private const val TAG = "ImeiUtil"
fun imei(context: Context?): String{
var imei = ""
val tm: TelephonyManager = context?.getSystemService(Activity.TELEPHONY_SERVICE) as TelephonyManager
imei = try {
tm.getDeviceId()
}catch (e: Exception){
Log.e(TAG, "No imei was obtained")
uuid()
}
Log.e(TAG, "imei is $imei")
return imei
}
private fun uuid(): String {
val deviceUuid = UUID.randomUUID()
var uuid = deviceUuid.toString().replace("-", "")
uuid = uuid.substring(uuid.length - 15)
val applicationFileDir = File(TEMP_DIR)
if (!applicationFileDir.exists()) {
if (!applicationFileDir.mkdirs()) {
Log.e(TAG, "Folder creation failed: ${applicationFileDir.path}")
}
}
val file = File(applicationFileDir, TEMP_FILE_NAME)
if (!file.exists()) {
if (file.createNewFile()) {
val fileWriter = FileWriter(file, false)
fileWriter.use {
fileWriter.write(uuid)
}
} else {
Log.e(TAG, "createNewFile failed")
}
} else {
uuid = file.readText()
Log.i(TAG, "uuid $uuid")
}
return uuid
}
}
\ No newline at end of file
package com.secspace.lib.common.utils;
import android.content.ComponentName;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cyw_m on 2018/3/27.
*/
public class Package {
public static final String PACKAGENAME_SECCONFIG = "com.secspace.config";
public static final String PACKAGENAME_MIDDLEWARE = "com.android.mdmservice";
public static final String PACKAGENAME_MDMENHANCE = "com.android.mdmenhance";
public static final String PACKAGENAME_SECSPACE = "com.android.secspace";
public static final String PACKAGENAME_SECSPACE2 = "com.android.secspace.two";
public static final String PACKAGENAME_AGENT = "com.secspace.system.agent";
public static final String PACKAGENAME_SMS_AGENT = "com.secspace.sms.agent";
public static final String PACKAGENAME_HAIYUNTONG = "com.iiecas.wechat";
public static final String PACKAGENAME_WORKSPACE = "com.safe.workspace";
public static final String PACKAGENAME_MDMOFFLINE= "com.android.mdmoffline";
public static final String PACKAGENAME_NAME_HWOUC = "com.huawei.android.hwouc";
public static final String PACKAGENAME_ONLINE_DEVMDM = "com.android.online.devmdm";
public static final String PACKAGENAME_UPDATE = "com.sec.update";
public static final String PACKAGENAME_HW_HWOUC = "com.huawei.android.hwouc";
public static final String COMPONENT_ADMIN_CLASS_MDMOFFLINE= "com.main.receivers.DeviceMdmReceiver";
public static final String PACKAGE_NAME_MIDDLEWARE = "com.android.mdmservice";
public static final String COMPONENT_ADMIN_CLASS_WORKSPACE = "ch.deletescape.lawnchair.DeviceAdminReceiver";
public static final String COMPONENT_ADMIN_CLASS = "com.sec.middleware.receiver.DpmReceiver";
public static final List LIST_PACKAGES_MIDDLEWARE = new ArrayList() {
{
add(PACKAGENAME_MIDDLEWARE);
}
};
public static class ComponentNames {
public static ComponentName COMPONENT_STARTUP_APP_CONTROL = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity");
public static ComponentName COMPONENT_STARTUP_IGNORE_POWER = new ComponentName("com.android.settings", "com.android.settings.Settings$HighPowerApplicationsActivity");
public static ComponentName COMPONENT_UPDATE_SYSTEM = new ComponentName("com.huawei.android.hwouc", "com.huawei.android.hwouc.ui.activities.MainEntranceActivity");
public static ComponentName COMPONENT_STARTUP_SETTINGS = new ComponentName("com.android.settings", "com.android.settings.HWSettings");
public static ComponentName COMPONENT_NAME_HW_HWOUC = new ComponentName("com.huawei.android.hwouc", "com.huawei.android.hwouc.ui.activities.MainEntranceActivity");//软件更新
public static ComponentName huaweiLuancher = new ComponentName("com.huawei.android.launcher", "com.huawei.android.launcher.unihome.UniHomeLauncher");
}
}
package com.secspace.lib.common.utils;
import android.app.ActivityManager;
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.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.support.v4.content.FileProvider;
import android.util.Log;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by SKR-CYW on 2016/10/15.
*/
public class PkgManagerHelper {
private static final String TAG = "PkgManagerHelper";
private static PkgManagerHelper mInstance = null;
private Context mContext;
private PackageManager mPackageManager;
private PkgManagerHelper(Context context) {
this.mContext = context;
mPackageManager = mContext.getPackageManager();
}
public static PkgManagerHelper getInstance(Context context) {
if (mInstance == null) {
mInstance = new PkgManagerHelper(context);
}
return mInstance;
}
public List<PackageInfo> getAllPackageInfo() {
List<PackageInfo> mInstalledPackageInfoList = mPackageManager.getInstalledPackages(0);
return mInstalledPackageInfoList;
}
public PackageInfo getPackageInfo(String packageName) {
PackageInfo packageInfo = null;
try {
packageInfo = mPackageManager.getPackageInfo(packageName, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return packageInfo;
}
public List<String> getAllPackageName() {
List<PackageInfo> allPackageInfo = getAllPackageInfo();
List<String> mInstalledPackageNameList = new ArrayList<String>();
for (int i = 0; i < allPackageInfo.size(); i++) {
mInstalledPackageNameList.add(allPackageInfo.get(i).packageName);
}
return mInstalledPackageNameList;
}
/**
* 获取本地文件apk的versionname
*
* @param apkPath
* @return
*/
public String getStorageApkVersionName(String apkPath) {
PackageInfo info = mPackageManager.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES);
if (info != null) {
ApplicationInfo appInfo = info.applicationInfo;
appInfo.sourceDir = apkPath;
appInfo.publicSourceDir = apkPath;
return info.versionName;
}
return "0";
}
/**
* 获取本地文件apk的包名
*
* @param apkPath
* @return
*/
public String getStorageApkPackgeName(String apkPath) {
PackageInfo info = mPackageManager.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES);
String packageName = null;
if (info != null) {
ApplicationInfo appInfo = info.applicationInfo;
packageName = appInfo.packageName;
}
return packageName;
}
/**
* 获取本地文件apk icon
*
* @param apkPath
* @return
*/
public Drawable getStorageApkIcon(String apkPath) {
PackageInfo info = mPackageManager.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES);
if (info != null) {
ApplicationInfo appInfo = info.applicationInfo;
appInfo.sourceDir = apkPath;
appInfo.publicSourceDir = apkPath;
try {
return appInfo.loadIcon(mPackageManager);
} catch (OutOfMemoryError e) {
Log.e("ApkIconLoader", e.toString());
}
}
return null;
}
/**
* 获取本地文件apk 名称
*
* @param apkPath
* @return
*/
public String getStorageApkName(String apkPath) {
PackageInfo info = mPackageManager.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES);
String label = null;
if (info != null) {
ApplicationInfo appInfo = info.applicationInfo;
appInfo.sourceDir = apkPath;
appInfo.publicSourceDir = apkPath;
label = appInfo.loadLabel(mPackageManager).toString();
}
return label;
}
/**
* 安装apk 系统方法
* android.permission.INSTALL_PACKAGES(system权限)
*
* @param apkPath
*/
public void silentInstallCommon(String apkPath) {
try {
mPackageManager
.getClass().getMethod("installPackage", Uri.class, Class.forName("android.content.pm.IPackageInstallObserver"), int.class, String.class)
.invoke(mContext.getPackageManager(), Uri.fromFile(new File(apkPath)), null,
mContext.getPackageManager().getClass().getField("INSTALL_REPLACE_EXISTING").get(null), null);
Log.i(TAG, "install apk success");
} catch (Exception e) {
Log.i(TAG, "install apk", e);
}
}
/**
* android.permission.DELETE_PACKAGES(system权限)
*
* @param packageName
*/
public void silentUninstallCommon(String packageName) {
try {
mPackageManager
.getClass().getMethod("deletePackage", String.class, Class.forName("android.content.pm.IPackageDeleteObserver"),
int.class).invoke(mContext.getPackageManager(), packageName, null, 0);
Log.i(TAG, "delete apk success");
} catch (Exception e) {
Log.i(TAG, "delete apk", e);
}
}
/**
* 系统安装器卸载apk
*
* @param packageName
*/
public void uninstallByInstaller(String packageName) {
Uri packageURI = Uri.parse("package:" + packageName);
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(uninstallIntent);
}
/**
* 判断本地文件中的apk是否已安装
*
* @param packagename
* @param apkPath
* @return
*/
public boolean isStorageApkInstalled(String packagename, String apkPath) {
try {
// PackageInfo localPackageInfo = localPackageManager.getPackageInfo(packagename, PackageManager.GET_UNINSTALLED_PACKAGES);
PackageInfo localPackageInfo = mPackageManager.getPackageInfo(packagename, 0);
//apk文件的版本与安装的版本相同才认为是安装了
if (getStorageApkVersionName(apkPath).equals(localPackageInfo.versionName)) {
return true;
}
} catch (PackageManager.NameNotFoundException localNameNotFoundException) {
return false;
}
return false;
}
/**
* 正常调用系统packageinstall.apk安装
* action 为:android.intent.action.INSTALL_PACKAGE
*
* @param path
* @return
*/
public void installByInstaller(String path) {
File apkFile = new File(path);
Intent intent = new Intent(Intent.ACTION_VIEW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri contentUri = FileProvider.getUriForFile(mContext, mContext.getPackageName() + ".fileProvider", apkFile);
intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
} else {
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
mContext.startActivity(intent);
}
/**
* 判断应用是否安装
*
* @param packageName
* @return
*/
public boolean isInstalled(String packageName, String version) {
if (getAllPackageName().contains(packageName)) {
// try {
// PackageInfo applicationInfo = mPackageManager.getPackageInfo(packageName, 0);
// if (version.equals(applicationInfo.versionName)) {
// return true;
// }
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// return false;
// }
return true;
}
return false;
}
public boolean isInstalled(String packageName) {
try {
PackageInfo applicationInfo = mPackageManager.getPackageInfo(packageName, 0);
if (applicationInfo == null) {
return false;
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return false;
}
return true;
}
/**
* 获取所有的第三方应用
*
* @return
*/
public List<PackageInfo> getAllThirdAppPackageInfo() {
List<PackageInfo> allThirdApps = new ArrayList<PackageInfo>();
for (PackageInfo info : getAllPackageInfo()) {
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
allThirdApps.add(info);
}
}
return allThirdApps;
}
/**
* 获取所有的第三方应用
*
* @return
*/
public List<String> getAllThirdAppPackageName() {
List<String> packages = new ArrayList<String>();
for (PackageInfo info : getAllPackageInfo()) {
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
packages.add(info.packageName);
}
}
return packages;
}
public String getVersionNameFromPackage(String packageName) {
try {
PackageInfo packageInfo = mPackageManager.getPackageInfo(packageName, 0);
return packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "";
}
public int getVersionCodeFromPackage(String packageName) {
try {
PackageInfo packageInfo = mPackageManager.getPackageInfo(packageName, 0);
return packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return 0;
}
public String getAppNameFromPackage(String packageName) {
try {
PackageInfo packageInfo = mPackageManager.getPackageInfo(packageName, 0);
if (packageInfo == null)
return "UnKnow";
if (packageInfo.applicationInfo == null)
return "UnKnow";
return (String) packageInfo.applicationInfo.loadLabel(mPackageManager);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "UnKnow";
}
public Intent getLauncherIntent(String packageName) {
//<category android:name="com.skr.security" /> skr版
Intent intent = null;
intent = mPackageManager.getLaunchIntentForPackage(packageName);
if (intent == null) {
intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory("com.skr.security");
// intent.addCategory("com.singuloid.secphone");
}
return intent;
}
/**
* 解析某些文件夹下的apk
*
* @param paths
* @return
*/
public List<PackageInfo> findAndParseAPKs(List<String> paths) {
List<PackageInfo> packageList = new ArrayList<>();
if (paths == null)
return packageList;
for (String path : paths) {
File[] dirFiles = new File(path).listFiles();
if (dirFiles == null)
continue;
for (File f : dirFiles) {
if (!f.getName().toLowerCase().endsWith(".apk"))
continue;
PackageInfo pkgInfo = null;
try {
pkgInfo = mPackageManager.getPackageArchiveInfo(f.getAbsolutePath(), 0);
pkgInfo.applicationInfo.sourceDir = f.getAbsolutePath();
pkgInfo.applicationInfo.publicSourceDir = f.getAbsolutePath();
} catch (Exception e) {
e.printStackTrace();
// Ignore
}
if (pkgInfo != null)
packageList.add(pkgInfo);
}
}
return packageList;
}
/**
* 判断是否是system级别的app
*
* @param packageName
* @return
*/
public boolean isSystemApp(String packageName) {
try {
PackageInfo packageInfo = mPackageManager.getPackageInfo(packageName, 0);
return (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return false;
}
private static final String BOOT_START_PERMISSION = "android.permission.RECEIVE_BOOT_COMPLETED";
/**
*    * 获取Android开机启动列表
*/
public List<Map<String, Object>> getAutoLauncherApps() {
PackageManager pm = mContext.getPackageManager();
List<ApplicationInfo> appInfo = pm.getInstalledApplications(0);
Iterator<ApplicationInfo> appInfoIterator = appInfo.iterator();
List<Map<String, Object>> appList = new ArrayList<Map<String, Object>>(appInfo.size());
while (appInfoIterator.hasNext()) {
ApplicationInfo app = appInfoIterator.next();
int flag = pm.checkPermission(
BOOT_START_PERMISSION, app.packageName);
if (flag == PackageManager.PERMISSION_GRANTED) {
Map<String, Object> appMap = new HashMap<String, Object>();
String label = pm.getApplicationLabel(app).toString();
Drawable icon = pm.getApplicationIcon(app);
String packageName = app.packageName;
appMap.put("label", label);
appMap.put("icon", icon);
appMap.put("desc", packageName);
appList.add(appMap);
}
}
return appList;
}
public boolean isAppInstalled(String packagename) {
PackageInfo packageInfo;
try {
packageInfo = mContext.getPackageManager().getPackageInfo(packagename, 0);
} catch (PackageManager.NameNotFoundException e) {
packageInfo = null;
Log.d(TAG, "isAppInstalled: " + e.toString());
}
if (packageInfo == null) {
return false;
} else {
return true;
}
}
/**
* <permission android:name="android.permission.FORCE_STOP_PACKAGES"  
*  android:permissionGroup="android.permission-group.SYSTEM_TOOLS"  
*  android:protectionLevel="signature"  
*  android:label="@string/permlab_forceStopPackages"  
*  android:description="@string/permdesc_forceStopPackages"/>  
*
* @param packageName
*/
public void foceStopApp(String packageName) {
try {
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
Method method = Class.forName("android.app.ActivityManager").getMethod("forceStopPackage", String.class);
method.invoke(activityManager, packageName);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
......@@ -13,6 +13,7 @@ public class Prefs {
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 IN_SPACE="in_space";
public static final String ALLOW_NEW_APP="allow_new_app";
public static final String WIFI_WHITE_LIST="wifi_white_list";
public static final String IS_FIRST_INIT="is_first_init";
......@@ -167,7 +168,7 @@ public class Prefs {
* @param context
*/
public static String getLoginPwd(Context context){
return getString(context,LOGIN_PWD,"15841584");
return getString(context,LOGIN_PWD,"");
}
/**
......@@ -284,7 +285,22 @@ public class Prefs {
return getString(context, USER_SHOW_APP_PKGS, "null");
}
/**
* 获取当前状态
* @param context
* @return
*/
public static boolean isInSpace(Context context){
return getBoolean(context,IN_SPACE,true);
}
/**
* 当前状态
* @param context
*/
public static void setInSpace(Context context,boolean isInSpace){
putBoolean(context,IN_SPACE,isInSpace);
}
/**
......
package com.secspace.lib.common.utils
import android.content.ComponentName
import android.content.Context
import com.secspace.lib.common.env.Packages.PkgSecSpace.PACKAGENAME_MDMENHANCE
import com.secspace.lib.common.env.Packages.PkgSecSpace.PACKAGENAME_MIDDLEWARE
import com.secspace.lib.common.utils.Package.COMPONENT_ADMIN_CLASS
import com.secspace.lib.common.utils.Package.ComponentNames.COMPONENT_NAME_HW_HWOUC
import com.secspace.lib.common.utils.Package.ComponentNames.huaweiLuancher
import com.secspace.lib.common.utils.Package.PACKAGENAME_HW_HWOUC
import com.secspace.mdmengine.api.annotation.WhichFactory
import com.secspace.mdmengine.api.manager.MdmFactoryManager
object UninstallUtil{
fun removeForbidden(context: Context?) {
DisableCompat.enableComponent(context, huaweiLuancher)
DisableCompat.enablePackage(context, PACKAGENAME_HW_HWOUC, true)
MdmFactoryManager.getInstance().switchFactory(WhichFactory.HUAWEI)
DisableCompat.enableComponent(context, COMPONENT_NAME_HW_HWOUC)
MdmFactoryManager.getInstance().deviceSettingsManager.isSystemUpdateDisabled = false
MdmFactoryManager.getInstance().deviceSettingsManager.isRestoreFactoryDisabled = false
MdmFactoryManager.getInstance().deviceRestrictionManager.isStatusBarExpandPanelDisabled = false
MdmFactoryManager.getInstance().googlePolicyManager?.setStatusBarDisabled(false)
MdmFactoryManager.getInstance().googlePolicyManager?.screenCaptureDisabled = false
MdmFactoryManager.getInstance().deviceSettingsManager.clearDefaultLauncher(context?.packageName)
MdmFactoryManager.getInstance().deviceRestrictionManager.clearDeviceOwnerApp()
val disabledDeactivateMdmPackageList = MdmFactoryManager.getInstance().deviceApplicationManager.disabledDeactivateMdmPackageList
if (disabledDeactivateMdmPackageList != null && disabledDeactivateMdmPackageList.size > 0) {
MdmFactoryManager.getInstance().deviceApplicationManager.removeDisabledDeactivateMdmPackages(disabledDeactivateMdmPackageList)
}
val disallowedUninstallPackageList = MdmFactoryManager.getInstance().deviceApplicationManager.disallowedUninstallPackageList
if (disallowedUninstallPackageList != null && disallowedUninstallPackageList.size > 0) {
MdmFactoryManager.getInstance().deviceApplicationManager.removeDisallowedUninstallPackages(disallowedUninstallPackageList)
}
// 取消激活
MdmFactoryManager.getInstance().deviceSettingsManager.removeActiveAdmin(ComponentName(PACKAGENAME_MIDDLEWARE, COMPONENT_ADMIN_CLASS))
MdmFactoryManager.getInstance().deviceSettingsManager.removeActiveAdmin(ComponentName(PACKAGENAME_MDMENHANCE, COMPONENT_ADMIN_CLASS))
MdmFactoryManager.getInstance().deviceRestrictionManager.clearDeviceOwnerApp()
DisableCompat.enablePackage(context, PACKAGENAME_HW_HWOUC, true)
DisableCompat.enableComponent(context, huaweiLuancher)
}
fun uninstallService(context: Context?) {
if (PkgManagerHelper.getInstance(context).isAppInstalled(context?.packageName)) {
PkgManagerHelper.getInstance(context).uninstallByInstaller(context?.packageName)
}
if (PkgManagerHelper.getInstance(context).isAppInstalled(PACKAGENAME_MIDDLEWARE)) {
PkgManagerHelper.getInstance(context).uninstallByInstaller(PACKAGENAME_MIDDLEWARE)
}
}
}
\ No newline at end of file
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