Browse Source

1.添加网络监听。

2.不再默认添加商店由网络控制。
20241218TB223FC(测试jar包)
wangwanlei 10 months ago
parent
commit
7804787162

+ 13
- 2
app/src/main/AndroidManifest.xml View File

@@ -34,10 +34,11 @@
34 34
     <!--用于申请调用A-GPS模块,卫星定位加速-->
35 35
     <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
36 36
     <!--用于获取wifi的获取权限,wifi信息会用来进行网络定位-->
37
-    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
37
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
38 38
 
39 39
     <!--护眼模式权限,只有系统app可以使用-->
40
-    <uses-permission android:name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS"
40
+    <uses-permission
41
+        android:name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS"
41 42
         tools:ignore="ProtectedPermissions" />
42 43
 
43 44
     <application
@@ -107,6 +108,16 @@
107 108
                 <action android:name="android.bluetooth.BluetoothAdapter.STATE_ON" />
108 109
             </intent-filter>
109 110
         </receiver>
111
+        <receiver
112
+            android:name="com.xhly.manageapp.broadcastreceiver.NetConnectReceiver"
113
+            android:enabled="true"
114
+            android:exported="true">
115
+            <intent-filter android:priority="1000">
116
+                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
117
+                <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
118
+                <action android:name="android.net.wifi.STATE_CHANGE" />
119
+            </intent-filter>
120
+        </receiver>
110 121
         <receiver
111 122
             android:name="com.xhly.manageapp.broadcastreceiver.SimStateReceive"
112 123
             android:enabled="true"

+ 1
- 1
app/src/main/java/com/xhly/manageapp/ManageApplication.kt View File

@@ -620,7 +620,7 @@ class ManageApplication : MultiDexApplication() {
620 620
                 addAppWhiteRule(arrayListOf(Const.CURRENTAPPPKG))
621 621
                 //允许运行时权限,禁止状态栏下拉,屏蔽底部虚拟键。
622 622
                 setRuntimePermissions(true)
623
-                disableStatusBarPanel(true)
623
+                disableStatusBarPanel(false)
624 624
                 hideHomeSoftKey(true)
625 625
                 hideMenuSoftKey(true)
626 626
                 enableAccessibility()

+ 34
- 0
app/src/main/java/com/xhly/manageapp/broadcastreceiver/NetConnectReceiver.java View File

@@ -0,0 +1,34 @@
1
+package com.xhly.manageapp.broadcastreceiver;
2
+
3
+import android.content.BroadcastReceiver;
4
+import android.content.Context;
5
+import android.content.Intent;
6
+import android.net.ConnectivityManager;
7
+import android.net.NetworkInfo;
8
+
9
+import com.xhly.corelib.Const;
10
+import com.xhly.corelib.eventbus.UIEvent;
11
+
12
+class NetConnectReceiver extends BroadcastReceiver {
13
+    @Override
14
+    public void onReceive(Context context, Intent intent) {
15
+        ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
16
+        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
17
+
18
+        if (networkInfo != null && networkInfo.isConnected()) {
19
+            // 网络连接已建立
20
+            new UIEvent(Const.STARTSOCKET).post();
21
+        } else {
22
+            // 网络连接断开
23
+
24
+        }
25
+    }
26
+/*  override fun onReceive(context: Context?, intent: Intent?) {
27
+    Log.e("qingshan", "网络状态改变")
28
+    context?.getSystemService(ConnectivityManager::class.java)?.allNetworkInfo?.filter {
29
+      it.typeName == "MOBILE" || it.typeName == "WIFI"
30
+    }?.forEach {networkInfo ->
31
+      Log.e("qingshan", "${networkInfo?.typeName}, isConnect= ${networkInfo?.isConnected}")
32
+    }
33
+  }*/
34
+}

+ 6
- 2
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

@@ -926,6 +926,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
926 926
             Const.INSTALL_FORCEAPP->{
927 927
                 ManageApplication.installPackage(uiEvent.message)
928 928
             }
929
+
930
+            Const.STARTSOCKET -> {
931
+                AppSocket.startSocket(this)
932
+            }
929 933
         }
930 934
     }
931 935
 
@@ -989,9 +993,9 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
989 993
             }
990 994
 
991 995
             //移除应用列表隐藏的应用
992
-            storeRemoveList.forEach {pkg->
996
+           /* storeRemoveList.forEach {pkg->
993 997
                 appList.removeIf { it.packageName==pkg }
994
-            }
998
+            }*/
995 999
             //移除学校控制之外预装应用
996 1000
             appList.removeAll(removeList)
997 1001
 

+ 2
- 2
app/src/main/java/com/xhly/manageapp/utils/CustomAppUtils.kt View File

@@ -11,11 +11,11 @@ import com.xhly.corelib.bean.AppInfo
11 11
 class CustomAppUtils {
12 12
     public fun getCustomAppList(context: Context): ArrayList<AppInfo> {
13 13
         val appList= arrayListOf<AppInfo>()
14
-        appList.add(getCusomAppBean(
14
+    /*    appList.add(getCusomAppBean(
15 15
             context.getString(R.string.appstore),
16 16
             Const.STOREAPPPKG,
17 17
             AppCompatResources.getDrawable(context,R.drawable.icon_store)!!
18
-        ))
18
+        ))*/
19 19
         appList.add(getCusomAppBean(
20 20
             context.getString(R.string.speed),
21 21
             Const.CUSTOMSPEEDAPP,

+ 4
- 1
corelib/src/main/java/com/xhly/corelib/Const.kt View File

@@ -65,7 +65,10 @@ object Const {
65 65
 
66 66
     //存储是否是第一次打开的key
67 67
     const val FIRSTAPPLIST = "FIRSTAPPLIST"
68
-
68
+    /**
69
+     * 启动socket
70
+     */
71
+     const val STARTSOCKET="STARTSOCKET"
69 72
     /**
70 73
      * 标记推出1登录
71 74
      */

Loading…
Cancel
Save