Commit 88524018 by huangzhencheng

fix:修改了大部分的bug

parent 93a4dece
......@@ -9,6 +9,7 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/Launcher3" />
<option value="$PROJECT_DIR$/imeiprovider" />
<option value="$PROJECT_DIR$/lib_common" />
</set>
</option>
......
......@@ -44,17 +44,21 @@
<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"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<application
android:backupAgent="com.android.launcher3.LauncherBackupAgent"
android:fullBackupContent="@xml/backupscheme"
android:fullBackupOnly="true"
android:resizeableActivity="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher_home"
android:icon="@drawable/launcher_self"
android:roundIcon="@drawable/launcher_self"
android:label="@string/derived_app_name"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"
......@@ -107,6 +111,8 @@
android:name="com.android.launcher3.dragndrop.AddItemActivity"
android:autoRemoveFromRecents="true"
android:excludeFromRecents="true"
android:resizeableActivity="false"
android:label="@string/action_add_to_workspace"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert">
<intent-filter>
......@@ -117,19 +123,42 @@
<activity
android:name=".settings.AppChooseActivity"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:theme="@style/AppTheme" />
<activity
android:resizeableActivity="false"
android:name=".settings.SettingActivity"
android:launchMode="singleTask"
android:excludeFromRecents="true"
android:theme="@style/AppTheme" />
<activity
android:resizeableActivity="false"
android:name=".settings.wifi.WifiWhiteListActivity"
android:excludeFromRecents="true"
android:theme="@style/AppTheme" />
<service android:name=".settings.wifi.WifiScanService"
<activity
android:resizeableActivity="false"
android:name=".settings.ChangePwdActivity"
android:excludeFromRecents="true"
android:theme="@style/AppTheme" />
<activity
android:resizeableActivity="false"
android:name=".settings.VerifyPwdProtectionActivity"
android:excludeFromRecents="true"
android:theme="@style/AppTheme" />
<activity
android:resizeableActivity="false"
android:name=".settings.ProtectionPwdActivity"
android:excludeFromRecents="true"
android:theme="@style/AppTheme" />
<service
android:name=".settings.wifi.WifiScanService"
android:enabled="true"
android:exported="true"/>
android:exported="true" />
<!--
Should point to the content provider which can be used to dump Launcher3 compatible
......
......@@ -38,16 +38,25 @@
android:fullBackupContent="@xml/backupscheme"
android:fullBackupOnly="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher_home"
android:icon="@drawable/launcher_self"
android:label="@string/derived_app_name"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"
android:supportsRtl="true"
android:theme="@style/LauncherTheme">
<receiver
android:name=".settings.AppInstallReceiver"
android:enabled="true"
android:exported="true"></receiver>
<activity android:name=".settings.ProtectionPwdActivity" />
<activity android:name=".settings.VerifyPwdProtectionActivity" />
<activity android:name=".settings.ChangePwdActivity" />
<service
android:name=".settings.wifi.WifiScanService"
android:enabled="true"
android:exported="true"></service>
android:exported="true" />
<activity android:name=".settings.wifi.WifiWhiteListActivity" />
<activity android:name=".settings.SettingActivity" />
......@@ -61,10 +70,10 @@
android:clearTaskOnLaunch="true"
android:configChanges="keyboard|keyboardHidden|navigation"
android:enabled="true"
android:resizeableActivity="false"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:resumeWhilePausing="true"
android:screenOrientation="nosensor"
android:screenOrientation="sensor"
android:stateNotNeeded="true"
android:taskAffinity=""
android:windowSoftInputMode="adjustPan|stateUnchanged">
......
......@@ -112,7 +112,7 @@ dependencies {
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.32'
implementation 'com.secspace:provider_mdm_engine:1.0.0.40'
implementation 'com.skr:activation:1.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.0'
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="20dp" />
<solid android:color="@color/alpha_70_black" />
</shape>
\ No newline at end of file
......@@ -6,34 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".settings.AppChooseActivity">
<RelativeLayout
android:id="@+id/manager_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000"
android:padding="15dp"
android:layout_alignParentLeft="true"
android:id="@+id/tv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="返回"
android:textSize="18dp" />
<TextView
android:textColor="#000"
android:padding="15dp"
android:layout_alignParentRight="true"
android:id="@+id/tv_setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="20dp"
android:text="设置"
android:textSize="18dp" />
</RelativeLayout>
<include layout="@layout/toolbar"/>
<LinearLayout
android:id="@+id/system_app"
......
<?xml version="1.0" encoding="utf-8"?>
<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.ChangePwdActivity">
<include layout="@layout/toolbar"/>
<TextView
android:id="@+id/tv_original_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:text="原密码"
android:textColor="#000"
android:textSize="18dp" />
<EditText
android:id="@+id/edit_original_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:hint="请输入旧密码"
android:inputType="textPassword" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:text="新密码"
android:textColor="#000"
android:textSize="18dp" />
<EditText
android:id="@+id/edit_new_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:hint="请输入新密码"
android:inputType="textPassword" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:text="确认新密码"
android:textColor="#000"
android:textSize="18dp" />
<EditText
android:id="@+id/edit_confirm_new_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:hint="确认新密码"
android:inputType="textPassword" />
<TextView
android:id="@+id/tv_confir_pwd_protection"
android:layout_gravity="right"
android:layout_marginRight="15dp"
android:gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:text="通过密保修改"
android:textColor="#000"
android:textSize="18dp" />
<Button
android:id="@+id/btn_sure"
android:textSize="18dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:layout_marginRight="15dp"
android:text="@string/work_sure" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<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.ProtectionPwdActivity">
<include layout="@layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
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_marginLeft="10dp"
android:layout_marginTop="15dp"
android:text="设置密保问题1"
android:textColor="#000" />
<EditText
android:id="@+id/edit_question_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:hint="请输入密保问题1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:text="设置密保答案1"
android:textColor="#000" />
<EditText
android:id="@+id/edit_answer_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:hint="请输入密保答案1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:text="设置密保问题2"
android:textColor="#000" />
<EditText
android:id="@+id/edit_question_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:hint="请输入密保问题2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:text="设置密保答案2"
android:textColor="#000" />
<EditText
android:id="@+id/edit_answer_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:hint="请输入密保答案2" />
<Button
android:id="@+id/btn_sure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
android:text="@string/work_sure" />
</LinearLayout>
</ScrollView>
</LinearLayout>
......@@ -7,20 +7,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.android.launcher3.settings.SettingActivity">
<RelativeLayout
android:id="@+id/manager_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000"
android:padding="15dp"
android:layout_alignParentLeft="true"
android:id="@+id/tv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="返回"
android:textSize="18dp" />
</RelativeLayout>
<include layout="@layout/toolbar"/>
<ScrollView
android:layout_width="match_parent"
......@@ -34,7 +21,7 @@
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textColor="#000"
android:text="移动管家"
android:text="移动终端管控软件-M3QC"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
......
<?xml version="1.0" encoding="utf-8"?>
<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.VerifyPwdProtectionActivity">
<include layout="@layout/toolbar"/>
<TextView
android:id="@+id/tv_question_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:text="密保1:今天你吃饭了吗"
android:textColor="#000"
android:textSize="18dp" />
<EditText
android:id="@+id/edit_answer_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:hint="请输答案:" />
<TextView
android:id="@+id/tv_question_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:text="密保2: 我还是不吃饭了吧"
android:textColor="#000"
android:textSize="18dp" />
<EditText
android:id="@+id/edit_answer_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:hint="请输答案:" />
<Button
android:id="@+id/btn_sure"
android:textSize="18dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:layout_marginRight="15dp"
android:text="@string/work_sure" />
</LinearLayout>
......@@ -41,6 +41,7 @@
</FrameLayout>
<FrameLayout
android:visibility="gone"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
......@@ -48,6 +49,7 @@
<!-- App Info -->
<com.android.launcher3.InfoDropTarget
android:visibility="gone"
launcher:hideParentOnDisable="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
......@@ -59,6 +61,7 @@
</FrameLayout>
<FrameLayout
android:visibility="gone"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
......@@ -71,6 +74,7 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:visibility="gone"
android:id="@+id/uninstall_target_text"
style="@style/DropTargetButton"
android:text="@string/uninstall_drop_target_label" />
......
......@@ -14,17 +14,18 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher3.DropTargetBar
xmlns:android="http://schemas.android.com/apk/res/android"
<com.android.launcher3.DropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dynamic_grid_drop_target_size"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_gravity="left"
android:focusable="false"
android:paddingTop="@dimen/vert_drop_target_vertical_gap" >
android:paddingTop="@dimen/vert_drop_target_vertical_gap">
<!-- Delete target -->
<com.android.launcher3.DeleteDropTarget
launcher:hideParentOnDisable="true"
android:layout_width="match_parent"
android:layout_height="@dimen/dynamic_grid_drop_target_size"
android:gravity="center"
......@@ -35,11 +36,13 @@
<!-- Uninstall target -->
<com.android.launcher3.UninstallDropTarget
launcher:hideParentOnDisable="true"
android:layout_width="match_parent"
android:layout_height="@dimen/dynamic_grid_drop_target_size"
android:gravity="center"
android:paddingLeft="@dimen/vert_drop_target_horizontal_gap"
android:paddingRight="@dimen/vert_drop_target_horizontal_gap"
android:visibility="gone"
android:id="@+id/uninstall_target_text"
android:textColor="@android:color/white"
android:layout_marginTop="@dimen/vert_drop_target_vertical_gap"/>
......@@ -51,6 +54,8 @@
<!-- App Info -->
<com.android.launcher3.InfoDropTarget
launcher:hideParentOnDisable="true"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="@dimen/dynamic_grid_drop_target_size"
android:gravity="center"
......
<?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="wrap_content">
<RelativeLayout
android:id="@+id/rl_layout"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
......@@ -46,5 +48,11 @@
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<View
android:layout_marginTop="5dp"
android:background="@color/notification_color_beneath"
android:layout_below="@id/rl_layout"
android:layout_width="match_parent"
android:layout_height="1dp"/>
</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:id="@+id/manager_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:padding="15dp"
android:text="返回"
android:textColor="#000"
android:textSize="18dp" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="15dp"
android:textColor="#000"
android:textSize="18dp" />
<TextView
android:id="@+id/tv_setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="20dp"
android:padding="15dp"
android:text="设置"
android:textColor="#000"
android:textSize="18dp"
android:visibility="gone" />
</RelativeLayout>
......@@ -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">"Launcher3"</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>
......
......@@ -50,4 +50,5 @@
<color name="legacy_icon_background">#FFFFFF</color>
<color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
<color name="btn_background">#A6D2F5</color> <!-- Gray 300 -->
<color name="alpha_70_black">#B3000000</color>
</resources>
......@@ -305,4 +305,16 @@
<string name="work_open">open</string>
<string name="work_sure">sure</string>
<string name="work_back">back</string>
<string name="open_start_tip">开启后[移动管家]固定在前台不可退出,关闭可长按home退出到普通桌面</string>
<string name="open_new_app_tip">打开后新安装应用自动在桌面显示</string>
<string name="open">打开</string>
<string name="close">关闭</string>
<string name="developing">开发中</string>
<string name="tip">提示</string>
<string name="launcher_setting_tip">安装完成,可长按桌面进行桌面配置</string>
<string name="ok">好的</string>
<string name="delete_account_tip">请先去“设置--账户” 中的所有账户和华为账户先删除,在启动移动管家</string>
<string name="go_delete">去删除</string>
<string name="set_auto_start_tip">是否将移动管家设为自启状态</string>
<string name="not_user_prmission">当前设备无权限使用,请联系管理员</string>
</resources>
......@@ -87,7 +87,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
private static void addToInstallQueue(
SharedPreferences sharedPrefs, PendingInstallShortcutInfo info) {
synchronized(sLock) {
synchronized (sLock) {
String encoded = info.encodeToString();
if (encoded != null) {
Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
......@@ -99,12 +99,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
}
public static void removeFromInstallQueue(Context context, HashSet<String> packageNames,
UserHandle user) {
UserHandle user) {
if (packageNames.isEmpty()) {
return;
}
SharedPreferences sp = Utilities.getPrefs(context);
synchronized(sLock) {
synchronized (sLock) {
Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null);
if (DBG) {
Log.d(TAG, "APPS_PENDING_INSTALL: " + strings
......@@ -134,7 +134,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
private static ArrayList<PendingInstallShortcutInfo> getAndClearInstallQueue(Context context) {
SharedPreferences sharedPrefs = Utilities.getPrefs(context);
synchronized(sLock) {
synchronized (sLock) {
ArrayList<PendingInstallShortcutInfo> infos = new ArrayList<>();
Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
if (DBG) Log.d(TAG, "Getting and clearing APPS_PENDING_INSTALL: " + strings);
......@@ -160,9 +160,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) {
return;
}
if (!Prefs.isAllowNewApp(context)){
return;
}
PendingInstallShortcutInfo info = createPendingInfo(context, data);
if (info != null) {
if (!info.isLauncherActivity()) {
......@@ -174,15 +172,9 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return;
}
}
String packageName = info.getItemInfo().getIntent().getComponent().getPackageName();
String userShowAppPkgs = Prefs.getUserShowAppPkgs(context);
if (userShowAppPkgs.equals("null")){
userShowAppPkgs=packageName;
}else {
userShowAppPkgs.concat(";"+packageName);
}
Prefs.setUserShowAppPkgs(context,userShowAppPkgs);
queuePendingShortcutInfo(info, context);
}
}
......@@ -269,6 +261,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
static void enableInstallQueue() {
mUseInstallQueue = true;
}
static void disableAndFlushInstallQueue(Context context) {
mUseInstallQueue = false;
flushInstallQueue(context);
......@@ -286,7 +279,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
* Ensures that we have a valid, non-null name. If the provided name is null, we will return
* the application name instead.
*/
@Thunk static CharSequence ensureValidName(Context context, Intent intent, CharSequence name) {
@Thunk
static CharSequence ensureValidName(Context context, Intent intent, CharSequence name) {
if (name == null) {
try {
PackageManager pm = context.getPackageManager();
......@@ -384,12 +378,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
// If it a launcher target, we only need component name, and user to
// recreate this.
return new JSONStringer()
.object()
.key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
.key(APP_SHORTCUT_TYPE_KEY).value(true)
.key(USER_HANDLE_KEY).value(UserManagerCompat.getInstance(mContext)
.getSerialNumberForUser(user))
.endObject().toString();
.object()
.key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
.key(APP_SHORTCUT_TYPE_KEY).value(true)
.key(USER_HANDLE_KEY).value(UserManagerCompat.getInstance(mContext)
.getSerialNumberForUser(user))
.endObject().toString();
} else if (shortcutInfo != null) {
// If it a launcher target, we only need component name, and user to
// recreate this.
......@@ -426,13 +420,13 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
String name = ensureValidName(mContext, launchIntent, label).toString();
Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
Intent.ShortcutIconResource iconResource =
data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
// Only encode the parameters which are supported by the API.
JSONStringer json = new JSONStringer()
.object()
.key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
.key(NAME_KEY).value(name);
.object()
.key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
.key(NAME_KEY).value(name);
if (icon != null) {
byte[] iconByteArray = Utilities.flattenBitmap(icon);
json = json.key(ICON_KEY).value(
......@@ -547,7 +541,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
data.putExtra(Intent.EXTRA_SHORTCUT_ICON, b);
} else if (iconResourceName != null && !iconResourceName.isEmpty()) {
Intent.ShortcutIconResource iconResource =
new Intent.ShortcutIconResource();
new Intent.ShortcutIconResource();
iconResource.resourceName = iconResourceName;
iconResource.packageName = iconResourcePackageName;
data.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
......@@ -579,6 +573,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
/**
* Tries to create a new PendingInstallShortcutInfo which represents the same target,
* but is an app target and not a shortcut.
*
* @return the newly created info or the original one.
*/
private static PendingInstallShortcutInfo convertToLauncherActivityIfPossible(
......
package com.android.launcher3;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.text.InputType;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.launcher3.settings.AppChooseActivity;
import com.android.launcher3.settings.Prefs;
import com.android.launcher3.settings.VerifyPwdProtectionActivity;
import com.secspace.lib.common.utils.DpmHelper;
import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.Prefs;
import com.secspace.lib.common.utils.SdUtil;
import com.secspace.lib.common.utils.ToastUtil;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import java.io.File;
import static com.android.launcher3.settings.Contants.FROM_WHERE;
public class ManagerAuthActivity extends BaseActivity {
protected Context mAppContext;
AlertDialog mPwdDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -36,14 +43,37 @@ public class ManagerAuthActivity extends BaseActivity {
showPwdDialog();
}
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);
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();
}
}
});
mPwdDialog = new AlertDialog.Builder(this)
.setTitle("请输入密码")
.setCancelable(false)
......@@ -59,16 +89,27 @@ public class ManagerAuthActivity extends BaseActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
InputUtil.closeSoftInput(getApplicationContext(), editText);
if (TextUtils.equals("123", "123")) {
if (TextUtils.equals(editText.getText().toString(), Prefs.getLoginPwd(mAppContext))) {
ToastUtil.showLong(mAppContext, "密码正确!");
finish();
Intent intent = new Intent();
intent.setClass(mAppContext, AppChooseActivity.class);
startActivity(intent);
} else if (TextUtils.equals(editText.getText().toString(), "un00000101")) {
Prefs.setOpenSilenceInstallTool(mAppContext,true);
String secondaryStoragePath = SdUtil.getSecondaryStoragePath(mAppContext);
String filePath= secondaryStoragePath + File.separator + "tool.apk";
File file=new File(filePath);
if (file!=null&&file.exists()){
MdmFactoryManager.getInstance().getDeviceApplicationManager().installPackage(filePath);
}else {
ToastUtil.showLong(mAppContext, "请确认文件存在或者已插入SD卡!");
}
// DpmHelper.getInstance(mAppContext).installTool();
finish();
} else {
ToastUtil.showLong(mAppContext, "密码错误!");
finish();
}
}
})
......
......@@ -30,6 +30,7 @@ import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import com.android.launcher3.compat.ShortcutConfigActivityInfo.ShortcutConfigActivityInfoVL;
......@@ -60,15 +61,15 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
//wangx 只显示需要的应用,这里使用包名过滤一下,再返回. 可以参考下面内容
List<LauncherActivityInfo> activityList = mLauncherApps.getActivityList(packageName, user);
List<LauncherActivityInfo> newActivityList = new ArrayList<>();
List<String> pkgsList=new ArrayList<>();
List<String> pkgsList = new ArrayList<>();
String systemShowAppPkgs = Prefs.getSystemShowAppPkgs(mContext);
String userShowAppPkgs = Prefs.getUserShowAppPkgs(mContext);
if (systemShowAppPkgs.equals("null")&&userShowAppPkgs.equals("null")){
packageName="";
}else {
String2ListHelper.getPkgsList(systemShowAppPkgs,pkgsList);
String2ListHelper.getPkgsList(userShowAppPkgs,pkgsList);
if (systemShowAppPkgs.equals("null") && userShowAppPkgs.equals("null")) {
packageName = "";
} else {
String2ListHelper.getPkgsList(systemShowAppPkgs, pkgsList);
String2ListHelper.getPkgsList(userShowAppPkgs, pkgsList);
}
for (int i = 0; i < activityList.size(); i++) {
for (String pkg : pkgsList) {
......@@ -77,7 +78,8 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
}
}
}
Log.i("LauncherAppsCompatVL", "packageName: "+packageName);
Log.i("LauncherAppsCompatVL", "packageName: " + packageName);
Log.i("LauncherAppsCompatVL", "newActivityList size : " + newActivityList.size());
return newActivityList;
//
......@@ -117,7 +119,7 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
// e.printStackTrace();
// }
// return null;
}
}
@Override
......@@ -127,7 +129,7 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
@Override
public void startActivityForProfile(ComponentName component, UserHandle user,
Rect sourceBounds, Bundle opts) {
Rect sourceBounds, Bundle opts) {
mLauncherApps.startMainActivity(component, user, sourceBounds, opts);
}
......@@ -161,7 +163,7 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
@Override
public void showAppDetailsForProfile(ComponentName component, UserHandle user,
Rect sourceBounds, Bundle opts) {
Rect sourceBounds, Bundle opts) {
mLauncherApps.startAppDetailsActivity(component, user, sourceBounds, opts);
}
......@@ -219,7 +221,7 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
}
public void onPackagesUnavailable(String[] packageNames, UserHandle user,
boolean replacing) {
boolean replacing) {
mCallback.onPackagesUnavailable(packageNames, user, replacing);
}
......@@ -229,13 +231,12 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
}
public void onPackagesUnsuspended(String[] packageNames, UserHandle user) {
mCallback.onPackagesUnsuspended(packageNames, user);
}
public void onShortcutsChanged(String packageName, List<ShortcutInfo> shortcuts,
UserHandle user) {
UserHandle user) {
List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcuts.size());
for (ShortcutInfo shortcutInfo : shortcuts) {
shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo));
......
......@@ -3,8 +3,14 @@ package com.android.launcher3.mdm;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import com.secspace.lib.common.env.SSettingConfig;
import com.secspace.lib.common.utils.DpmHelper;
import com.secspace.mdmengine.api.annotation.WhichFactory;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED;
......@@ -14,6 +20,71 @@ import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
public class DisableCompat {
private static final String TAG = "DisableCompat";
public static boolean isApplicationEnable(Context context, String packageName) {
try {
PackageManager pm = context.getPackageManager();
int mode = pm.getApplicationEnabledSetting(packageName);
return mode == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT || mode == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
} catch (Exception e) {
Log.e(TAG, "isApplicationEnable Exception: " + e.toString());
e.printStackTrace();
}
return true;
}
public static void enableApplication(Context context, String packageName) {
if (TextUtils.isEmpty(packageName)) {
return;
}
boolean result;
if (SSettingConfig.isUseDeviceOwnerToDisableApp()) {
result = DpmHelper.getInstance(context).hideApplication(packageName, false);
} else {
result = enableApplicationAOSP(context, packageName);
}
Log.i(TAG, "enable: " + packageName + " , result= " + result);
}
public static void disableApplication(Context context, String packageName) {
if (TextUtils.isEmpty(packageName)) {
return;
}
boolean result;
if (SSettingConfig.isUseDeviceOwnerToDisableApp()) {
result = DpmHelper.getInstance(context).hideApplication(packageName, true);
} else {
result = disableApplicationAOSP(context, packageName);
}
Log.d(TAG, "disable: " + packageName + " , result=" + result);
}
private static boolean disableApplicationAOSP(Context context, String packageName) {
if (TextUtils.isEmpty(packageName)) {
return false;
}
MdmFactoryManager.getInstance().switchFactory(WhichFactory.AOSP_SYSTEM);
MdmFactoryManager.getInstance().getDeviceApplicationManager()
.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
MdmFactoryManager.getInstance().switchFactory(WhichFactory.HUAWEI);
return true;
}
private static boolean enableApplicationAOSP(Context context, String packageName) {
if (TextUtils.isEmpty(packageName)) {
return false;
}
MdmFactoryManager.getInstance().switchFactory(WhichFactory.AOSP_SYSTEM);
MdmFactoryManager.getInstance().getDeviceApplicationManager()
.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
MdmFactoryManager.getInstance().switchFactory(WhichFactory.HUAWEI);
return true;
}
public static void disableComponent(Context context, ComponentName componentName) {
try {
......
package com.android.launcher3.mdm;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.support.annotation.StringDef;
import android.text.TextUtils;
import android.util.Log;
import com.secspace.lib.common.env.Packages;
import com.secspace.lib.common.utils.DpmHelper;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/**
* Created by lichuanzhi@tiankuan.net on 2019/3/29
*/
public class DpmOwnerHelper {
private static final String TAG = "DpmOwnerHelper";
private static boolean isSettingDeviceOwner = false;
private static List<String> disabledApps = new ArrayList<>();
/**
* 禁用账户并且移除掉所有其他用户(华为账号,隐私空间,工作空间等)
*/
public static void disableAccountsAndRemoveProfileUsers(final Context context) {
Log.i(TAG, "disableAccountsAndRemoveProfileUsers: 移除用户是否正在设置=" + isSettingDeviceOwner);
if (isSettingDeviceOwner) {
return;
}
isSettingDeviceOwner = true;
try {
AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
disabledApps.clear();
//此方法必须在主线程中调用
AuthenticatorDescription[] authenticatorTypes = accountManager.getAuthenticatorTypes();
if (authenticatorTypes != null && authenticatorTypes.length > 0) {
for (AuthenticatorDescription authenticatorDescription : authenticatorTypes) {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo(authenticatorDescription.packageName, 0);
// 如果安装,则禁用
DisableCompat.disableApplication(context, authenticatorDescription.packageName);
disabledApps.add(pi.packageName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
}
MdmFactoryManager.getInstance().getDeviceUserManager().setAddUserDisabled(true);
List<UserInfo> users = MdmFactoryManager.getInstance().getDeviceUserManager().getSystemUserList();
if (users != null && users.size() > 0) {
for (UserInfo userInfo : users) {
if (!userInfo.isPrimary()) {
// 移除所有其他用户
MdmFactoryManager.getInstance().getDeviceUserManager().removeUser(userInfo.id);
}
}
}
Disposable subscribe = Observable.just(context).observeOn(Schedulers.newThread())
.subscribe(new Consumer<Context>() {
@Override
public void accept(Context context) throws Exception {
setDeviceowner(context);
}
});
} catch (Exception e) {
Log.i(TAG, "disableAccountsAndRemoveProfileUsers: " + e.getMessage());
e.printStackTrace();
isSettingDeviceOwner = false;
}
}
private static int COUNT = 0;
private static void setDeviceowner(Context context) throws InterruptedException {
COUNT++;
if (COUNT < 4) {
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setDeviceOwnerApp(Packages.PkgSecSpace.PACKAGENAME_MIDDLEWARE);
if (!DpmHelper.getInstance(context).isMiddlewareDeviceOwner()) {
Log.i(TAG, "disableAccountsAndRemoveProfileUsers: 设置失败!");
Thread.sleep(3000);
setDeviceowner(context);
} else {
recoverAccounts(context);
isSettingDeviceOwner = false;
COUNT = 0;
Log.i(TAG, "disableAccountsAndRemoveProfileUsers: 设置成功!");
}
} else {
Log.i(TAG, "disableAccountsAndRemoveProfileUsers: 到达尝试次数!");
recoverAccounts(context);
isSettingDeviceOwner = false;
COUNT = 0;
}
}
/**
* 恢复禁用的账户
*/
private static void recoverAccounts(Context context) {
MdmFactoryManager.getInstance().getDeviceUserManager().setAddUserDisabled(false);
if (disabledApps != null && disabledApps.size() > 0) {
for (String disableApp : disabledApps) {
if (!TextUtils.isEmpty(disableApp)) {
DisableCompat.enableApplication(context, disableApp.trim());
}
}
//清空文件
disabledApps.clear();
}
}
}
......@@ -19,15 +19,23 @@ public class MdmUtils {
public static void setDefaultLauncher(Context context){
DisableCompat.disableComponent(context,huaweiLuancher);
MdmFactoryManager.getInstance().getDeviceSettingsManager().setDefaultLauncher(context.getPackageName(), Launcher.class.getName());
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setStatusBarExpandPanelDisabled(true);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setTaskButtonDisabled(true);
//搜索wifi列表时需要将gps打开 否则无法找到列表
MdmFactoryManager.getInstance().getDeviceRestrictionManager().turnOnGPS(true);
Prefs.setAutoStartSelf(context,true);
//设置默认桌面需要将华为桌面禁用,在用过华为桌面后否则会在最近任务栏显示华为桌面
}
/**
* 设置默认桌面,设置默认桌面相当于开机自启
* 清除默认桌面和一系列的状态
* @param context
*/
public static void clearDefaultLauncher(Context context){
MdmFactoryManager.getInstance().getDeviceSettingsManager().clearDefaultLauncher(context.getPackageName());
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setStatusBarExpandPanelDisabled(false);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setTaskButtonDisabled(false);
Prefs.setAutoStartSelf(context,false);
DisableCompat.enableComponent(context,huaweiLuancher);
}
......
......@@ -13,6 +13,7 @@ import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.android.launcher3.Launcher;
......@@ -54,7 +55,9 @@ public class AppChooseActivity extends AppCompatActivity implements LoaderManage
finish();
}
});
findViewById(R.id.tv_setting).setOnClickListener(new View.OnClickListener() {
TextView tvSetting = findViewById(R.id.tv_setting);
tvSetting.setVisibility(View.VISIBLE);
tvSetting .setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(AppChooseActivity.this,SettingActivity.class));
......@@ -118,10 +121,17 @@ public class AppChooseActivity extends AppCompatActivity implements LoaderManage
mApps = appModels;
for(AppModel appModel : mApps)
{
if((appModel.getAppInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0)
if((appModel.getAppInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0){
mSystemApps.add(appModel);
else
mUserApps.add(appModel);
} else{
if (!appModel.getApplicationPackageName().equals(this.getPackageName())){
mUserApps.add(appModel);
}
}
}
mAppInfoAdapterUserApp.readResult(getApplicationContext());
mAppInfoAdapterSystemApp.readResult(getApplicationContext());
......
package com.android.launcher3.settings;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.secspace.lib.common.event.RefreshWorkSpaceEvent;
import org.greenrobot.eventbus.EventBus;
public class AppInstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
PackageManager manager = context.getPackageManager();
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
String packageName = intent.getData().getSchemeSpecificPart();
if (!TextUtils.isEmpty(packageName)){
Log.i("AppInstallReceiver", "onReceive: "+packageName);
if (!TextUtils.isEmpty(packageName) && !TextUtils.equals(packageName, context.getPackageName())) {
if (Prefs.isAllowNewApp(context)) {
String userShowAppPkgs = Prefs.getUserShowAppPkgs(context);
if (userShowAppPkgs.equals("null")) {
userShowAppPkgs = packageName;
} else {
if (!userShowAppPkgs.contains(packageName)) {
userShowAppPkgs = userShowAppPkgs.concat(";" + packageName);
}
}
Prefs.setUserShowAppPkgs(context, userShowAppPkgs);
EventBus.getDefault().post(new RefreshWorkSpaceEvent());
}
if (Prefs.isOpenSilenceInstallTool(context)) {
if (packageName.equals("com.sec.uninstall")) {
String userShowAppPkgs = Prefs.getUserShowAppPkgs(context);
if (userShowAppPkgs.equals("null")) {
userShowAppPkgs = packageName;
} else {
if (!userShowAppPkgs.contains(packageName)) {
userShowAppPkgs = userShowAppPkgs.concat(";" + packageName);
}
}
Prefs.setUserShowAppPkgs(context, userShowAppPkgs);
Prefs.setOpenSilenceInstallTool(context,false);
}
}
EventBus.getDefault().post(new RefreshWorkSpaceEvent());
}
}
}
}
}
package com.android.launcher3.settings;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.ManagerAuthActivity;
import com.android.launcher3.R;
import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.ToastUtil;
import static com.android.launcher3.settings.Contants.FROM_WHERE;
import static com.android.launcher3.settings.Contants.IS_SHOW_ORIGINAL_PWD;
public class ChangePwdActivity extends AppCompatActivity implements View.OnClickListener {
private EditText mEditOriginalPwd;
private EditText mEditNewPwd;
private TextView mTvOriginalPwd;
private Button mBtnSure;
private boolean isShowOriginalPwd;
private Intent mIntent;
private TextView mTvTitle;
private EditText mEditConfirmNewPwd;
private TextView mTvConfirmPwdProtection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_pwd);
initView();
initListener();
initData();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.i("ChangePwdActivity", "onNewIntent: "+intent);
controlView(intent);
}
private void initData() {
controlView(getIntent());
}
private void controlView(Intent intent) {
if (intent!=null){
mIntent = intent;
isShowOriginalPwd = mIntent.getBooleanExtra(IS_SHOW_ORIGINAL_PWD, false);
if (!isShowOriginalPwd) {
mTvOriginalPwd.setVisibility(View.GONE);
mEditOriginalPwd.setVisibility(View.GONE);
mTvConfirmPwdProtection.setVisibility(View.GONE);
} else {
mTvOriginalPwd.setVisibility(View.VISIBLE);
mEditOriginalPwd.setVisibility(View.VISIBLE);
mTvConfirmPwdProtection.setVisibility(View.VISIBLE);
}
}
}
private void initListener() {
mBtnSure.setOnClickListener(this);
}
private void initView() {
mEditOriginalPwd = findViewById(R.id.edit_original_pwd);
mEditNewPwd = findViewById(R.id.edit_new_pwd);
mEditConfirmNewPwd=findViewById(R.id.edit_confirm_new_pwd);
mTvOriginalPwd = findViewById(R.id.tv_original_pwd);
mBtnSure = findViewById(R.id.btn_sure);
mTvTitle=findViewById(R.id.tv_title);
mTvConfirmPwdProtection=findViewById(R.id.tv_confir_pwd_protection);
mTvTitle.setText("修改密码");
findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
mTvConfirmPwdProtection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//这里因为是和ManagerAuthActivity 跳转一样 验证的字符串 所以依旧使用这个ManagerAuthActivity
Intent intent = new Intent(ChangePwdActivity.this, VerifyPwdProtectionActivity.class);
intent.putExtra(FROM_WHERE, ManagerAuthActivity.class.getSimpleName());
startActivity(intent);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onClick(View v) {
String newPwd = mEditNewPwd.getText().toString();
String originalPwd = mEditOriginalPwd.getText().toString();
String confirmNewPwd = mEditConfirmNewPwd.getText().toString();
if (TextUtils.isEmpty(newPwd)) {
ToastUtil.showShort(this, "新密码不能为空");
return;
}
if (TextUtils.isEmpty(confirmNewPwd)) {
ToastUtil.showShort(this, "验证新密码不能为空");
return;
}
if (isShowOriginalPwd){
if (TextUtils.isEmpty(originalPwd)) {
ToastUtil.showShort(this, "原密码不能为空");
return;
}
if (TextUtils.equals(newPwd, originalPwd)) {
ToastUtil.showShort(this, "新密码和原密码不能一致");
return;
}
if (!TextUtils.equals(originalPwd, Prefs.getLoginPwd(this))) {
ToastUtil.showShort(this, "密码错误,请重新输入密码");
return;
}
}
if (!TextUtils.equals(newPwd,confirmNewPwd)){
ToastUtil.showShort(this, "两次输入密码不一致,请重新输入");
return;
}
startActivity(new Intent(this,SettingActivity.class));
Prefs.setLoginPwd(this, newPwd);
finish();
}
}
package com.android.launcher3.settings;
public class Contants {
public static final String FROM_WHERE ="from_here";
public static final String IS_SHOW_ORIGINAL_PWD="is_show_original_pwd";
}
package com.android.launcher3.settings;
import android.content.Context;
public class ErrorTimeHelper {
private static ErrorTimeHelper instance;
private Context mContext;
private int mCount = 0;
public void setCount(int count) {
this.mCount = count;
if (mCount == 5) {
setLockTime(System.currentTimeMillis());
}
}
private ErrorTimeHelper(Context context) {
mContext = context;
}
public static ErrorTimeHelper getInstance(Context context) {
if (instance == null) {
synchronized (ErrorTimeHelper.class) {
if (instance == null) {
instance = new ErrorTimeHelper(context);
}
}
}
return instance;
}
public void setLockTime(long lockTime) {
Prefs.setLockTime(mContext, lockTime);
}
public long getLockTime() {
return Prefs.getLockTime(mContext);
}
public boolean canShowDialog(){
long lockTime = getLockTime();
long nowTime = System.currentTimeMillis();
int maxTime = 10 * 60 * 1000;
if (nowTime - lockTime > maxTime) {
if (mCount ==5){
mCount =0;
}
return true;
}
return false;
}
public boolean canInputPwd() {
if (mCount<5){
setCount(++mCount);
}
long lockTime = getLockTime();
long nowTime = System.currentTimeMillis();
int maxTime = 10 * 60 * 1000;
if (nowTime - lockTime > maxTime) {
if (mCount ==5){
mCount =0;
}
return true;
}
return false;
}
// public long getCountDownTime(){
// long lockTime = getLockTime();
// long nowTime = System.currentTimeMillis();
// int maxTime = 10 * 60 * 1000;
// long alreadyLockTime = nowTime - lockTime;
// }
}
......@@ -15,6 +15,168 @@ public class Prefs {
public static final String AUTO_START_SELF="auto_start_self";
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";
public static final String LOGIN_PWD="login_pwd";
public static final String PWD_PROTECTION_ANSWER_1="pwd_protection_answer_1";
public static final String PWD_PROTECTION_ANSWER_2="pwd_protection_answer_2";
public static final String PWD_PROTECTION_QUESTION_1 = "pwd_protection_question_1";
public static final String PWD_PROTECTION_QUESTION_2 = "pwd_protection_question_2";
public static final String OPEN_SILENCE_INSTALL_TOOL = "open_silence_install_tool";
public static final String IMEI_CAN_USE = "imei_can_sue";
public static final String LOCK_TIME = "lock_time";
public static void setLockTime(Context context,long time){
putLong(context,LOCK_TIME,time);
}
public static long getLockTime(Context context){
return getLong(context,LOCK_TIME,0L);
}
/**
* 设置imei是否可用
* @param context
* @param imeiCanUse
*/
public static void setImeiCanUse(Context context,boolean imeiCanUse){
putBoolean(context,IMEI_CAN_USE,imeiCanUse);
}
/**
* 获取imei是否可用
* @param context
* @return
*/
public static boolean isImeiCanUse(Context context){
return getBoolean(context,IMEI_CAN_USE,false);
}
/**
* 设置是否打开静默安装卸载工具
* @param context
* @param isOpen
*/
public static void setOpenSilenceInstallTool(Context context,boolean isOpen){
putBoolean(context,OPEN_SILENCE_INSTALL_TOOL,isOpen);
}
/**
* 获取是否打开静默安装卸载工具
* @param context
* @return
*/
public static boolean isOpenSilenceInstallTool(Context context){
return getBoolean(context,OPEN_SILENCE_INSTALL_TOOL,false);
}
/**
* 设置密保一问题
* @param context
* @param question1
*/
public static void setPwdProtectionQuestion1(Context context,String question1){
putString(context,PWD_PROTECTION_QUESTION_1,question1);
}
/**
* 获取密保1问题
* @param context
* @return
*/
public static String getPwdProtectionQuestion1(Context context){
return getString(context,PWD_PROTECTION_QUESTION_1,"厂商提供的初始演示激活码是多少?");
}
/**
* 设置密保2问题
* @param context
* @param question2
*/
public static void setPwdProtectionQuestion2(Context context,String question2){
putString(context,PWD_PROTECTION_QUESTION_2,question2);
}
/**
* 获取密保2问题
* @param context
* @return
*/
public static String getPwdProtectionQuestion2(Context context){
return getString(context,PWD_PROTECTION_QUESTION_2,"厂商所处城区是在哪里?");
}
/**
* 设置密保一答案
* @param context
* @param answer1
*/
public static void setPwdProtectionAnswer1(Context context,String answer1){
putString(context,PWD_PROTECTION_ANSWER_1,answer1);
}
/**
* 获取密保1答案
* @param context
* @return
*/
public static String getPwdProtectionAnswer1(Context context){
return getString(context,PWD_PROTECTION_ANSWER_1,"1908129SH9");
}
/**
* 获取密保2答案
* @param context
* @return
*/
public static String getPwdProtectionAnswer2(Context context){
return getString(context,PWD_PROTECTION_ANSWER_2,"天津市南开区");
}
/**
* 设置密保一答案
* @param context
* @param answer2
*/
public static void setPwdProtectionAnswer2(Context context,String answer2){
putString(context,PWD_PROTECTION_ANSWER_2,answer2);
}
/**
* 获取密码
* @param context
*/
public static String getLoginPwd(Context context){
return getString(context,LOGIN_PWD,"181917!yh");
}
/**
* 设置密码
* @param context
* @param pwd
*/
public static void setLoginPwd(Context context,String pwd){
putString(context,LOGIN_PWD,pwd);
}
/**
* 设置是否首次进入
* @param context
* @param isFirstInit
*/
public static void setIsFirstInit(Context context,boolean isFirstInit){
putBoolean(context,IS_FIRST_INIT,isFirstInit);
}
/**
*获取是否首次进入
* @param context
*/
public static boolean isFirstInit(Context context){
return getBoolean(context,IS_FIRST_INIT,true);
}
/**
* 设置wifi白名单列表
......
package com.android.launcher3.settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.android.launcher3.R;
import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.ToastUtil;
public class ProtectionPwdActivity extends AppCompatActivity implements View.OnClickListener {
EditText mEditQuestion1;
EditText mEditQuestion2;
EditText mEditAnswer1;
EditText mEditAnswer2;
Button mBtnSure;
TextView mTvTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_protection_pwd);
initView();
}
private void initView() {
mEditAnswer1=findViewById(R.id.edit_answer_1);
mEditAnswer2=findViewById(R.id.edit_answer_2);
mEditQuestion1=findViewById(R.id.edit_question_1);
mEditQuestion2=findViewById(R.id.edit_question_2);
mTvTitle=findViewById(R.id.tv_title);
mBtnSure=findViewById(R.id.btn_sure);
findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
mTvTitle.setText("设置密保问题");
mBtnSure.setOnClickListener(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onClick(View v) {
String question1 = mEditQuestion1.getText().toString();
String question2 = mEditQuestion2.getText().toString();
String answer1 = mEditAnswer1.getText().toString();
String answer2 = mEditAnswer2.getText().toString();
if (TextUtils.isEmpty(question1)||TextUtils.isEmpty(question2)||TextUtils.isEmpty(answer1)||TextUtils.isEmpty(answer2)){
ToastUtil.showShort(this,"不能存在问题或者答案为空的情况,请重新检查输入");
return;
}
Prefs.setPwdProtectionAnswer1(this,answer1);
Prefs.setPwdProtectionQuestion1(this,question1);
Prefs.setPwdProtectionAnswer2(this,answer2);
Prefs.setPwdProtectionQuestion2(this,question2);
finish();
}
}
......@@ -21,6 +21,9 @@ import com.android.launcher3.mdm.MdmUtils;
import com.android.launcher3.settings.wifi.WifiWhiteListActivity;
import com.secspace.mdmengine.api.manager.MdmFactoryManager;
import static com.android.launcher3.settings.Contants.FROM_WHERE;
import static com.android.launcher3.settings.Contants.IS_SHOW_ORIGINAL_PWD;
public class SettingActivity extends AppCompatActivity implements View.OnClickListener {
private static final int REQUEST_PICK_WALLPAPER = 10;
private static final String ACTION_CHANGE_WALLPAPER = "action_change_wallpaper";
......@@ -37,6 +40,7 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
//允许本身自启
public static final int AUTO_START_SELF = 1;
private Context mContext;
private TextView mTvTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -54,7 +58,7 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
setBtnBackground();
}
private void setBtnBackground(){
private void setBtnBackground() {
if (Prefs.isAllowNewApp(this)) {
mBtnAllowNewApp.setBackgroundColor(getResources().getColor(R.color.btn_background));
} else {
......@@ -91,10 +95,12 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
finish();
}
});
mTvTitle=findViewById(R.id.tv_title);
mTvTitle.setText("设置");
}
private void initData() {
mBtnVsrsion.setText("版本:" + BuildConfig.VERSION_NAME);
mBtnVsrsion.setText("V" + BuildConfig.VERSION_NAME);
}
......@@ -106,7 +112,7 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
final LinearLayout ll = view.findViewById(R.id.item_ll);
ll.addView(textView);
alertDialog = new AlertDialog.Builder(this)
.setTitle("提示")
.setTitle(getString(R.string.tip))
.setCancelable(false)
.setView(view)
.setNegativeButton(R.string.work_cancel, new DialogInterface.OnClickListener() {
......@@ -120,14 +126,14 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
public void onClick(DialogInterface dialog, int which) {
switch (type) {
case ALLOW_NEW_APP:
if (tip.equals("打开")) {
if (tip.equals(getString(R.string.open))) {
Prefs.setAllowNewApp(mContext, true);
} else {
Prefs.setAllowNewApp(mContext, false);
}
break;
case AUTO_START_SELF:
if (tip.equals("打开")) {
if (tip.equals(getString(R.string.open))) {
Prefs.setAutoStartSelf(mContext, true);
MdmUtils.setDefaultLauncher(mContext);
MdmFactoryManager.getInstance().getDeviceRestrictionManager().setStatusBarExpandPanelDisabled(true);
......@@ -158,7 +164,7 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
final LinearLayout ll = view.findViewById(R.id.item_ll);
ll.addView(textView);
alertDialog = new AlertDialog.Builder(this)
.setTitle("提示")
.setTitle(getString(R.string.tip))
.setCancelable(false)
.setView(view)
.setNegativeButton(R.string.work_cancel, new DialogInterface.OnClickListener() {
......@@ -178,26 +184,29 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_change_pwd:
showTipDialog("开发中");
Intent intent1 = new Intent(this, ChangePwdActivity.class);
intent1.putExtra(IS_SHOW_ORIGINAL_PWD,true);
startActivity(intent1);
break;
case R.id.btn_set_pwdcar:
showTipDialog("开发中");
Intent intent2 = new Intent(this, VerifyPwdProtectionActivity.class);
intent2.putExtra(FROM_WHERE,SettingActivity.class.getSimpleName());
startActivity(intent2);
break;
case R.id.btn_auto_start:
boolean autoStartSelf = Prefs.isAutoStartSelf(this);
if (!autoStartSelf) {
showPwdDialog("打开", AUTO_START_SELF, "开启后[移动管家]固定在前台不可退出,关闭可退出到普通桌面");
showPwdDialog(getString(R.string.open), AUTO_START_SELF, getString(R.string.open_start_tip));
} else {
showPwdDialog("关闭", AUTO_START_SELF, "开启后[移动管家]固定在前台不可退出,关闭可退出到普通桌面");
showPwdDialog(getString(R.string.close), AUTO_START_SELF, getString(R.string.open_start_tip));
}
break;
case R.id.btn_allow_new_app:
boolean allowNewApp = Prefs.isAllowNewApp(this);
if (!allowNewApp) {
showPwdDialog("打开", ALLOW_NEW_APP, "打开后新安装应用自动在桌面显示");
showPwdDialog(getString(R.string.open), ALLOW_NEW_APP, getString(R.string.open_new_app_tip));
} else {
showPwdDialog("关闭", ALLOW_NEW_APP, "打开后新安装应用自动在桌面显示");
showPwdDialog(getString(R.string.close), ALLOW_NEW_APP, getString(R.string.open_new_app_tip));
}
break;
case R.id.btn_wifi_whitelist:
......
package com.android.launcher3.settings;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.android.launcher3.R;
import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.ToastUtil;
import static com.android.launcher3.settings.Contants.FROM_WHERE;
import static com.android.launcher3.settings.Contants.IS_SHOW_ORIGINAL_PWD;
public class VerifyPwdProtectionActivity extends AppCompatActivity implements View.OnClickListener {
TextView mTvQuestion1;
TextView mTvQuestion2;
EditText mEditAnswer1;
EditText mEditAnswer2;
Button mBtnSure;
private Intent mIntent;
private TextView mTvTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_verify_pwdprotection);
initView();
initData();
}
private void initData() {
mTvQuestion1.setText("密保1: " + Prefs.getPwdProtectionQuestion1(this));
mTvQuestion2.setText("密保2: " + Prefs.getPwdProtectionQuestion2(this));
mIntent = getIntent();
}
private void initView() {
mTvQuestion1 = findViewById(R.id.tv_question_1);
mTvQuestion2 = findViewById(R.id.tv_question_2);
mEditAnswer1 = findViewById(R.id.edit_answer_1);
mEditAnswer2 = findViewById(R.id.edit_answer_2);
mBtnSure = findViewById(R.id.btn_sure);
findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InputUtil.closeSoftInput(getApplicationContext(), mEditAnswer1);
finish();
}
});
mBtnSure.setOnClickListener(this);
mTvTitle = findViewById(R.id.tv_title);
mTvTitle.setText("验证密保");
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onClick(View v) {
String answer1 = mEditAnswer1.getText().toString();
String answer2 = mEditAnswer2.getText().toString();
if (TextUtils.isEmpty(answer1) || TextUtils.isEmpty(answer2)) {
ToastUtil.showShort(this, "密保问题不能为空");
return;
}
if (!TextUtils.equals(answer1, Prefs.getPwdProtectionAnswer1(this)) && !TextUtils.equals(answer2, Prefs.getPwdProtectionAnswer2(this))) {
ToastUtil.showShort(this, "密保问题错误");
return;
}
String fromWhere = mIntent.getStringExtra(FROM_WHERE);
Intent intent;
if (!TextUtils.isEmpty(fromWhere) && TextUtils.equals(fromWhere, SettingActivity.class.getSimpleName())) {
intent = new Intent(this, ProtectionPwdActivity.class);
} else {
intent = new Intent(this, ChangePwdActivity.class);
intent.putExtra(IS_SHOW_ORIGINAL_PWD, false);
}
startActivity(intent);
finish();
}
}
......@@ -15,6 +15,7 @@ import android.util.Log;
import android.widget.Toast;
import com.android.launcher3.settings.Prefs;
import com.google.gson.Gson;
import java.util.ArrayList;
......@@ -31,7 +32,7 @@ public class NetworkConnectChangedReceiver extends BroadcastReceiver {
private WifiManager mWifiManager;
private List<String> mWifiMacs = new ArrayList<>();
private List<WifiInfoBean> mWifiMacs = new ArrayList<>();
public NetworkConnectChangedReceiver(Context context) {
mContext = context;
......@@ -50,35 +51,13 @@ public class NetworkConnectChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i(TAG, "NetworkConnectChangedReceiver-onReceive: " + action);
if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
String bssid = intent.getStringExtra(WifiManager.EXTRA_BSSID);
String ssid;
if (null != parcelableExtra) {
NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
NetworkInfo.State state = networkInfo.getState();
Log.e(TAG, "NetworkConnectChangedReceiver-onReceive: state=" + state + "\nbssid=" + bssid);
if (state == NetworkInfo.State.CONNECTING) {
WifiManager wifiManager = getWifiManager();
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (TextUtils.isEmpty(bssid)) {
bssid = wifiInfo.getBSSID();
}
if (wifiInfo != null && !TextUtils.isEmpty(bssid)) {
bssid = bssid.toUpperCase();
int networkId = wifiInfo.getNetworkId();
Log.e(TAG, "NetworkConnectChangedReceiver-onReceive: networkId=" + networkId + " =bssid=" + bssid);
Log.e(TAG, "NetworkConnectChangedReceiver-onReceive contains:" + getmWifiMacs(context).contains(bssid));
//检测bssid是否是否是禁用的。(数据库检测)
if (getmWifiMacs(context).size() > 0 && !(getmWifiMacs(context).contains(bssid))) {
Toast.makeText(context, "此wifi不允许连接", Toast.LENGTH_LONG).show();
boolean removeNetwork = WifiManagerUtils.getInstance(context).removeNetwork(networkId);
Log.i(TAG, "removeNetwork: "+removeNetwork);
}
}
}
if (state == NetworkInfo.State.CONNECTED) {
WifiManager wifiManager = getWifiManager();
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
......@@ -88,14 +67,36 @@ public class NetworkConnectChangedReceiver extends BroadcastReceiver {
if (wifiInfo != null && !TextUtils.isEmpty(bssid)) {
bssid = bssid.toUpperCase();
ssid = wifiInfo.getSSID();
if (TextUtils.isEmpty(ssid)) {
ssid="";
}
ssid = ssid.replace("\"", "");
int networkId = wifiInfo.getNetworkId();
Log.e(TAG, "NetworkConnectChangedReceiver-onReceive: networkId=" + networkId + " =bssid=" + bssid);
//检测bssid是否是否是禁用的。(数据库检测)
if (getmWifiMacs(context).size() > 0 && !(getmWifiMacs(context).contains(bssid))) {
Toast.makeText(context, "此wifi不允许连接", Toast.LENGTH_LONG).show();
boolean removeNetwork = WifiManagerUtils.getInstance(context).removeNetwork(networkId);
Log.i(TAG, "removeNetwork: "+removeNetwork);
if (getmWifiMacs(context).size() > 0) {
boolean isRemove = true;
for (int i = 0; i < mWifiMacs.size(); i++) {
if (TextUtils.isEmpty(mWifiMacs.get(i).getMac())) {
Log.i(TAG, "wifiInfoBean ssid: "+mWifiMacs.get(i).getSsid());
Log.i(TAG, "wifiInfo ssid: "+ssid);
if (mWifiMacs.get(i).getSsid().equals(ssid)) {
Log.i(TAG, "isRemove: "+isRemove);
isRemove = false;
break;
}
} else {
if (mWifiMacs.get(i).getSsid().equals(ssid) && mWifiMacs.get(i).getMac().equals(bssid)) {
isRemove = false;
break;
}
}
}
if (isRemove) {
boolean removeNetwork = WifiManagerUtils.getInstance(context).removeNetwork(networkId);
Log.i(TAG, "removeNetwork: " + removeNetwork);
}
}
}
}
......@@ -103,14 +104,12 @@ public class NetworkConnectChangedReceiver extends BroadcastReceiver {
}
}
private List<String> getmWifiMacs(Context context){
mWifiMacs.clear();
List<WifiInfoBean> wifiInfoBeans = Gson2ListHelper.stringWifiWhite2List(context);
for (int i = 0; i < wifiInfoBeans.size(); i++) {
mWifiMacs.add(wifiInfoBeans.get(i).getMac());
private List<WifiInfoBean> getmWifiMacs(Context context) {
synchronized (String.class){
mWifiMacs.clear();
List<WifiInfoBean> wifiInfoBeans = Gson2ListHelper.stringWifiWhite2List(context);
mWifiMacs.addAll(wifiInfoBeans);
return mWifiMacs;
}
Log.i(TAG, "getmWifiMacs: "+mWifiMacs.toString());
mWifiMacs.add("00:00:00:00:00:00");
return mWifiMacs;
}
}
......@@ -69,7 +69,7 @@ public class WifiAutoConnectManager {
config.allowedPairwiseCiphers.clear();
config.allowedProtocols.clear();
config.SSID = "\"" + SSID + "\"";
config.BSSID="\""+bssid+"\"";
// config.BSSID="\""+bssid+"\"";
// nopass
if (Type == WifiCipherType.WIFICIPHER_NOPASS) {
// config.wepKeys[0] = "";
......
......@@ -69,15 +69,36 @@ public class WifiManagerUtils {
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null) {
String bssid = wifiInfo.getBSSID();
String ssid=wifiInfo.getSSID();
if (wifiInfo != null && !TextUtils.isEmpty(bssid)) {
bssid = bssid.toUpperCase();
if (TextUtils.isEmpty(ssid)){
ssid="";
}
ssid=ssid.replace("\"","");
int networkId = wifiInfo.getNetworkId();
Log.e(TAG, "NetworkConnectChangedReceiver-onReceive: networkId=" + networkId + " =bssid=" + bssid);
//检测bssid是否是否是禁用的。(数据库检测)
if (getWifiMacs(mContext).size() > 0 && !(getWifiMacs(mContext).contains(bssid))) {
Toast.makeText(mContext, "此wifi不允许连接", Toast.LENGTH_LONG).show();
boolean removeNetwork = WifiManagerUtils.getInstance(mContext).removeNetwork(networkId);
Log.i(TAG, "removeNetwork: " + removeNetwork);
List<WifiInfoBean> wifiMacs = getWifiMacs(mContext);
if (wifiMacs.size()>0) {
boolean isRemove = true;
for (int i = 0; i < wifiMacs.size(); i++) {
if (TextUtils.isEmpty(wifiMacs.get(i).getMac())) {
if (wifiMacs.get(i).getSsid().equals(ssid)) {
isRemove = false;
break;
}
} else {
if (wifiMacs.get(i).getSsid().equals(ssid) && wifiMacs.get(i).getMac().equals(bssid)) {
isRemove = false;
break;
}
}
}
if (isRemove) {
boolean removeNetwork = WifiManagerUtils.getInstance(mContext).removeNetwork(networkId);
Log.i(TAG, "removeNetwork: " + removeNetwork);
}
}
}
}
......@@ -106,11 +127,13 @@ public class WifiManagerUtils {
return false;
}
private List<String> getWifiMacs(Context context){
List<String> mWifiMacs=new ArrayList<>();
private List<WifiInfoBean> getWifiMacs(Context context){
List<WifiInfoBean> mWifiMacs=new ArrayList<>();
List<WifiInfoBean> wifiInfoBeans = Gson2ListHelper.stringWifiWhite2List(context);
for (int i = 0; i < wifiInfoBeans.size(); i++) {
mWifiMacs.add(wifiInfoBeans.get(i).getMac());
if (wifiInfoBeans!=null&&wifiInfoBeans.size()>0){
for (int i = 0; i < wifiInfoBeans.size(); i++) {
mWifiMacs.add(wifiInfoBeans.get(i));
}
}
return mWifiMacs;
}
......
......@@ -11,6 +11,8 @@ import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import com.android.launcher3.settings.Prefs;
import java.util.List;
public class WifiScanService extends Service {
......@@ -20,14 +22,19 @@ public class WifiScanService extends Service {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (WifiManagerUtils.getInstance(mContext).isEnabled()) {
Log.i("WifiScanService", "handleMessage: ");
if (WifiManagerUtils.getInstance(mContext).isEnabled()&& Prefs.isAutoStartSelf(mContext)) {
Log.i("WifiScanService", "isAutoStartSelf: ");
List<ScanResult> wifiList = getWifiList();
List<WifiInfoBean> wifiInfoBean = getWifiInfoBean();
Log.i("WifiScanService", "isAutoStartSelf: "+wifiList.size());
boolean isBreak=false;
for (int i = 0; i < wifiList.size(); i++) {
for (int j = 0; j < wifiInfoBean.size(); j++) {
Log.i("WifiScanService", "wifiList.get(i).SSID: "+wifiList.get(i).SSID);
if (wifiList.get(i).SSID.equals(wifiInfoBean.get(j).getSsid())){
if(!WifiManagerUtils.getInstance(mContext).isConnectedWifi()){
Log.i("WifiScanService", "wifiInfoBean.get(j).getSsid(): "+wifiInfoBean.get(j).getSsid());
mWifiAutoConnectManager.connect(wifiInfoBean.get(j).getSsid(),wifiInfoBean.get(j).getPwd(),WifiAutoConnectManager.WifiCipherType.WIFICIPHER_WPA,wifiInfoBean.get(j).getMac());
isBreak=true;
break;
......@@ -49,6 +56,7 @@ public class WifiScanService extends Service {
mWifiAutoConnectManager=new WifiAutoConnectManager(WifiManagerUtils.getInstance(this).getWifiManager());
mContext = this;
mHandler.sendEmptyMessage(1);
Log.i("WifiScanService", "onCreate: ");
}
private List<ScanResult> getWifiList() {
......
......@@ -118,6 +118,13 @@ public class WifiWhiteListActivity extends AppCompatActivity implements View.OnC
showPwdDialog(this);
break;
case R.id.tv_delete:
if (mWifiWhiteListAdapter.ismIsShowCb()){
mWifiWhiteListAdapter.setIsShowCb(false);
}else {
mWifiWhiteListAdapter.setIsShowCb(true);
mWifiWhiteListAdapter.notifyDataSetChanged();
return;
}
List<WifiInfoBean> deletePosition = mWifiWhiteListAdapter.getDeletePosition();
for (int i = 0; i < deletePosition.size(); i++) {
if (mWifiInfoList.contains(deletePosition.get(i))) {
......@@ -129,6 +136,7 @@ public class WifiWhiteListActivity extends AppCompatActivity implements View.OnC
Log.i(TAG, "onClick: "+list2Json);
Prefs.setWifiWhiteList(this,list2Json);
WifiManagerUtils.getInstance(this).isIllegalWifi();
mWifiWhiteListAdapter.clearDeletePosition();
mWifiWhiteListAdapter.notifyDataSetChanged();
break;
}
......@@ -146,8 +154,11 @@ public class WifiWhiteListActivity extends AppCompatActivity implements View.OnC
}
private void setWifiState(boolean state) {
boolean b = mWifiManager.setWifiEnabled(state);
Log.i(TAG, "setWifiState: "+b);
if (mWifiManager.isWifiEnabled()!=state){
boolean b = mWifiManager.setWifiEnabled(state);
Log.i(TAG, "setWifiState: "+b);
}
}
private List<WifiInfoBean> loadWifiListData() {
......@@ -167,8 +178,8 @@ public class WifiWhiteListActivity extends AppCompatActivity implements View.OnC
editPwd.setHint("请输入密码");
View view = LayoutInflater.from(this).inflate(R.layout.item_ll, null);
final LinearLayout ll = view.findViewById(R.id.item_ll);
ll.addView(editMac);
ll.addView(editSsid);
ll.addView(editMac);
ll.addView(editPwd);
alertDialog = new AlertDialog.Builder(this)
.setTitle("添加新的wifi管控")
......@@ -185,15 +196,14 @@ public class WifiWhiteListActivity extends AppCompatActivity implements View.OnC
public void onClick(DialogInterface dialog, int which) {
String mac = editMac.getText().toString();
String ssid = editSsid.getText().toString();
if (TextUtils.isEmpty(mac) || TextUtils.isEmpty(ssid)) {
if (TextUtils.isEmpty(ssid)) {
ToastUtil.showShort(WifiWhiteListActivity.this, "输入不能为空请重新输入");
return;
}
for (int i = 0; i < mWifiInfoList.size(); i++) {
String mac1 = mWifiInfoList.get(i).getMac();
String ssid1 = mWifiInfoList.get(i).getSsid();
if (TextUtils.equals(mac, mac1) || TextUtils.equals(ssid, ssid1)) {
ToastUtil.showShort(WifiWhiteListActivity.this, "输入不能为空请重新输入");
if ( TextUtils.equals(ssid, ssid1)) {
ToastUtil.showShort(WifiWhiteListActivity.this, "不能重复输入,请重新输入");
return;
}
}
......
package com.android.launcher3.settings.wifi;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.launcher3.R;
......@@ -13,6 +15,7 @@ import java.util.List;
public class WifiWhiteListAdapter extends BaseRecyclerViewAdapter<WifiInfoBean> {
private List<WifiInfoBean> mDeletePosition= new ArrayList<>();
private boolean mIsShowCb=false;
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
super.onBindViewHolder(holder, position);
......@@ -20,6 +23,11 @@ public class WifiWhiteListAdapter extends BaseRecyclerViewAdapter<WifiInfoBean>
TextView tvMac=myViewHolder.get(R.id.tv_mac);
TextView tvSsid=myViewHolder.get(R.id.tv_ssid);
CheckBox checkBox=myViewHolder.get(R.id.cb_delete);
if (mIsShowCb){
checkBox.setVisibility(View.VISIBLE);
}else {
checkBox.setVisibility(View.INVISIBLE);
}
tvMac.setText(mList.get(position).getMac());
tvSsid.setText(mList.get(position).getSsid());
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
......@@ -45,4 +53,16 @@ public class WifiWhiteListAdapter extends BaseRecyclerViewAdapter<WifiInfoBean>
public List<WifiInfoBean> getDeletePosition(){
return mDeletePosition;
}
public void clearDeletePosition(){
mDeletePosition.clear();
}
public void setIsShowCb(boolean isShowCb){
mIsShowCb=isShowCb;
notifyDataSetChanged();
}
public boolean ismIsShowCb(){
return mIsShowCb;
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "com.sec.imeiprovider"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
storeFile file("..\\doc\\skr.keystore")//签名文件路径
storePassword "123456"
keyAlias "skr.keystore"
keyPassword "123456" //签名密码
v1SigningEnabled true
v2SigningEnabled false
println("====== signingConfigs.debug ======")
}
release {
storeFile file("..\\doc\\skr.keystore")//签名文件路径
storePassword "123456"
keyAlias "skr.keystore"
keyPassword "123456"
v1SigningEnabled true
v2SigningEnabled false
println("====== signingConfigs.release ======")
}
}
buildTypes {
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
signingConfig signingConfigs.debug
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
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'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.sec.imeiprovider;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.sec.imeiprovider", appContext.getPackageName());
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sec.imeiprovider"
android:sharedUserId="com.secspace.runtime">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" />
</manifest>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
<resources>
<string name="app_name">ImeiProvider</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
package com.sec.imeiprovider;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
......@@ -70,11 +70,9 @@ dependencies {
api 'com.jakewharton:butterknife:8.7.0'
api 'com.google.code.gson:gson:2.7'
api 'org.greenrobot:eventbus:3.0.0'
String HwSdk = '2.5.2.300'
api 'com.huawei.android.hms:base:' + HwSdk
api 'com.huawei.android.hms:push:' + HwSdk
api 'com.squareup.okhttp3:okhttp:3.9.1'
api 'com.squareup.okhttp3:logging-interceptor:3.9.1'
api 'io.reactivex.rxjava2:rxjava:2.0.0'
......@@ -95,12 +93,11 @@ dependencies {
api('android.arch.persistence.room:runtime:1.1.1') {
// exclude group: 'android.arch.core'
}
//annotationProcessor
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
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 files('libs/jxl.jar')
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ public class SSettingConfig {
/**
* 是否使用Device Owner
*/
private static final boolean USE_DEVICE_OWNER = true;
private static final boolean USE_DEVICE_OWNER = false;
/**
* 是否使用Device Owner禁用应用,前提是USE_DEVICE_OWNER必须先打开
......
......@@ -268,7 +268,7 @@ public class DpmHelper {
}
public void installMiddleWare() {
String appStoreFilePath = Environment.getExternalStorageDirectory() + File.separator + MDM_FILE_NAME;
String appStoreFilePath = mContext.getExternalCacheDir() + File.separator + MDM_FILE_NAME;
File file = new File(appStoreFilePath);
if (file.exists()) {
file.delete();
......@@ -277,6 +277,17 @@ public class DpmHelper {
installByInstaller(appStoreFilePath);
}
public void preinstallApp(String apkName){
String appStoreFilePath = mContext.getExternalCacheDir().getPath() + File.separator + apkName;
Log.i(TAG, "installTool: "+appStoreFilePath);
File file = new File(appStoreFilePath);
if (file.exists()) {
file.delete();
}
copyApkFromAssets(mContext, apkName, appStoreFilePath);
MdmFactoryManager.getInstance().getDeviceApplicationManager().installPackage(appStoreFilePath);
}
/**
* 安装中间件
*
......
package com.secspace.lib.common.utils;
import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class ImeiCheckUtils {
private static ImeiCheckUtils instance;
private Context mContext;
private List<String> mImeiList;
private ImeiCheckUtils(Context context) {
mContext = context;
}
public static ImeiCheckUtils getInstance(Context context) {
if (instance == null) {
synchronized (ImeiCheckUtils.class) {
if (instance == null) {
instance = new ImeiCheckUtils(context);
}
}
}
return instance;
}
public void initImeiList() {
if (mImeiList == null) {
mImeiList = new ArrayList<>();
}
mImeiList.clear();
mImeiList.add("864592035232660");
mImeiList.add("864592035232561");
mImeiList.add("864592035232553");
mImeiList.add("864592035266098");
mImeiList.add("864592035266114");
mImeiList.add("864592035265934");
mImeiList.add("864592035266171");
mImeiList.add("864592035266213");
mImeiList.add("864592035266254");
mImeiList.add("864592035266247");
mImeiList.add("864592035266239");
mImeiList.add("864592035266130");
mImeiList.add("864592035266064");
mImeiList.add("864592035267815");
mImeiList.add("864592035225862");
mImeiList.add("864592035226084");
mImeiList.add("864592035226118");
mImeiList.add("864592035226142");
mImeiList.add("864592035226134");
mImeiList.add("864592035226241");
mImeiList.add("864592035224477");
mImeiList.add("864592035224550");
mImeiList.add("864592035224543");
mImeiList.add("864592035224568");
mImeiList.add("864592035224592");
mImeiList.add("864592035224626");
mImeiList.add("864592035224659");
mImeiList.add("864592035224709");
mImeiList.add("864592035224923");
mImeiList.add("864592035224782");
mImeiList.add("864592035224865");
mImeiList.add("864592035224899");
mImeiList.add("864592035224840");
mImeiList.add("864592035224808");
mImeiList.add("864592035224741");
mImeiList.add("864592035224683");
mImeiList.add("864592035348250");
mImeiList.add("864592035348284");
mImeiList.add("864592035348219");
mImeiList.add("864592035348110");
mImeiList.add("864592035348177");
mImeiList.add("864592035348185");
mImeiList.add("864592035348136");
mImeiList.add("864592035348144");
mImeiList.add("864592035348235");
mImeiList.add("864592035348268");
mImeiList.add("864592035348276");
mImeiList.add("864592035347773");
mImeiList.add("864592035348326");
mImeiList.add("864592035348300");
mImeiList.add("864592035348375");
mImeiList.add("864592035348128");
mImeiList.add("864592035349027");
mImeiList.add("864592035348995");
mImeiList.add("864592035349001");
mImeiList.add("864592035349019");
mImeiList.add("864592035348987");
mImeiList.add("864592035348599");
mImeiList.add("864592035348979");
mImeiList.add("864592035348912");
mImeiList.add("864592035349035");
mImeiList.add("864592035349092");
mImeiList.add("864592035349100");
mImeiList.add("864592035349126");
mImeiList.add("864592035349118");
mImeiList.add("864592035349076");
mImeiList.add("864592035349084");
mImeiList.add("864592035349068");
mImeiList.add("864592035348839");
mImeiList.add("864592035348847");
mImeiList.add("864592035348821");
mImeiList.add("864592035348813");
mImeiList.add("864592035348805");
mImeiList.add("864592035348771");
mImeiList.add("864592035348763");
mImeiList.add("864592035348789");
mImeiList.add("864592035348953");
mImeiList.add("864592035348946");
mImeiList.add("864592035348938");
mImeiList.add("864592035348854");
mImeiList.add("864592035348904");
mImeiList.add("864592035348888");
mImeiList.add("864592035348870");
mImeiList.add("864592035348862");
mImeiList.add("864592035341446");
mImeiList.add("864592035342824");
mImeiList.add("864592035342881");
mImeiList.add("864592035342675");
mImeiList.add("864592035342980");
mImeiList.add("864592035342931");
mImeiList.add("864592035342972");
mImeiList.add("864592035341008");
mImeiList.add("864592035340240");
mImeiList.add("864592035342501");
mImeiList.add("864592035340703");
mImeiList.add("864592035342485");
mImeiList.add("864592035343046");
mImeiList.add("864592035343020");
mImeiList.add("864592035341982");
mImeiList.add("864592035343061");
mImeiList.add("864592035349514");
mImeiList.add("864592035349365");
mImeiList.add("864592035349563");
mImeiList.add("864592035009605");
mImeiList.add("864592035349464");
mImeiList.add("864592035349357");
mImeiList.add("864592035349431");
mImeiList.add("864592035349555");
mImeiList.add("864592035232710");
mImeiList.add("864592035266163");
mImeiList.add("864592035226076");
mImeiList.add("864592035225664");
mImeiList.add("864592034450248");
mImeiList.add("863736032749579");
InputStream is = null;
try {
Context context1 = mContext.createPackageContext("com.sec.imeiprovider",
Context.CONTEXT_IGNORE_SECURITY);
is = context1.getAssets().open("imeiProvider.xls");
Workbook book = Workbook.getWorkbook(is);
book.getNumberOfSheets();
// 获得第一个工作表对象
Sheet sheet = book.getSheet(0);
int Rows = sheet.getRows();
for (int i = 0; i < Rows; ++i) {
String content = (sheet.getCell(0, i)).getContents();
mImeiList.add(content);
}
} catch (IOException e) {
e.printStackTrace();
} catch (BiffException e) {
e.printStackTrace();
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
public List<String> getmImeiList() {
if (mImeiList == null) mImeiList = new ArrayList<>();
Log.i("ImeiCheckUtils", "getmImeiList: "+mImeiList.size());
return mImeiList;
}
}
include ':Launcher3', ':lib_common'
include ':Launcher3', ':lib_common', ':imeiprovider'
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