Browse Source

1.添加防火墙调用方法。

2025_1_17_tb223fc
wangwanlei 2 months ago
parent
commit
6ed86942f6

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

178
          * false:关闭蓝牙
178
          * false:关闭蓝牙
179
          */
179
          */
180
         fun enableBluetooth(enableFlag: Boolean) {
180
         fun enableBluetooth(enableFlag: Boolean) {
181
+            if (enableFlag&&ModelNameUtils.IS_LianxTB223FC()) {
182
+                //223FC需要处理蓝牙分享才能打开开关
183
+                disableBluetoothShare(!enableFlag)
184
+            }
181
             if (ModelNameUtils.IS_LianxX505f()) {
185
             if (ModelNameUtils.IS_LianxX505f()) {
182
                 csdkManager?.enableBluetooth_v3(enableFlag)
186
                 csdkManager?.enableBluetooth_v3(enableFlag)
183
             } else if (ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()) {
187
             } else if (ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()) {
287
          */
291
          */
288
         fun setCustomOTG(enableFlag: Boolean) {
292
         fun setCustomOTG(enableFlag: Boolean) {
289
             if (ModelNameUtils.IS_LianxX505f() || ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()) {
293
             if (ModelNameUtils.IS_LianxX505f() || ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()) {
290
-                csdkManager?.customOTG = enableFlag
294
+                //csdkManager?.customOTG = enableFlag
291
             }
295
             }
292
         }
296
         }
293
 
297
 
647
                 list.addAll(urlWhiteListRead)
651
                 list.addAll(urlWhiteListRead)
648
                 list.add(Const.BASEURL)
652
                 list.add(Const.BASEURL)
649
                 list.addAll(Const.whiteList)
653
                 list.addAll(Const.whiteList)
650
-                csdkManager?.urlWhiteListWrite(list)
651
-                csdkManager?.urlBlackListWrite(arrayListOf("*"))
654
+                if (ModelNameUtils.IS_LianxTB223FC()){
655
+                    AfwUtils.addUrLWhiteList(list)
656
+                    AfwUtils.addUrLBlackList(arrayListOf("*"))
657
+                }else{
658
+                    csdkManager?.urlWhiteListWrite(list)
659
+                    csdkManager?.urlBlackListWrite(arrayListOf("*"))
660
+                }
652
             }
661
             }
653
         }
662
         }
654
 
663
 
876
             try {
885
             try {
877
                 if (ModelNameUtils.IS_LianxX505f()){
886
                 if (ModelNameUtils.IS_LianxX505f()){
878
                     csdkManager?.disallowBluetoothShare_v3(b)
887
                     csdkManager?.disallowBluetoothShare_v3(b)
879
-                }else if (ModelNameUtils.IS_LianxX6e6f()){
888
+                }else if (ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()){
880
                     csdkManager?.disallowBluetoothV3(b)
889
                     csdkManager?.disallowBluetoothV3(b)
881
                 }
890
                 }
882
             }catch (e:Exception){
891
             }catch (e:Exception){
916
             val exitControlFlag =false
925
             val exitControlFlag =false
917
             Toaster.init(this)
926
             Toaster.init(this)
918
             DialogX.init(this)
927
             DialogX.init(this)
928
+            if (ModelNameUtils.IS_LianxTB223FC()){
929
+                AfwUtils.startBindService(this)
930
+            }
919
             if (ModelNameUtils.IS_LianxX505f() || ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()) {
931
             if (ModelNameUtils.IS_LianxX505f() || ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()) {
920
                 csdkManager = CSDKManager(this)
932
                 csdkManager = CSDKManager(this)
921
                 //允许运行时权限
933
                 //允许运行时权限

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

113
 import java.util.Timer
113
 import java.util.Timer
114
 import java.util.TimerTask
114
 import java.util.TimerTask
115
 import java.util.concurrent.TimeUnit
115
 import java.util.concurrent.TimeUnit
116
+import kotlin.system.exitProcess
116
 
117
 
117
 
118
 
118
 class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), DownloadCallback {
119
 class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), DownloadCallback {
546
                 it?.let {
547
                 it?.let {
547
                     spUtils.saveJson(Const.SCHOOLSETDEVICE, it)
548
                     spUtils.saveJson(Const.SCHOOLSETDEVICE, it)
548
                     initSchoolSet(it)
549
                     initSchoolSet(it)
549
-                    mBinding.rv.visibility = View.VISIBLE
550
+                    //mBinding.rv.visibility = View.VISIBLE
550
                     updateAppRv()
551
                     updateAppRv()
551
                     if (it.fromNetWorkType == 1) {
552
                     if (it.fromNetWorkType == 1) {
552
                         if (quitFlag) {
553
                         if (quitFlag) {
635
             viewModel.autoAppData.collect {
636
             viewModel.autoAppData.collect {
636
                 lifecycleScope.launch {
637
                 lifecycleScope.launch {
637
                     withContext(Dispatchers.IO){
638
                     withContext(Dispatchers.IO){
638
-                        delay(15000)
639
+                        delay(3000)
639
                     }
640
                     }
640
-                    mBinding.flayoutRoot.visibility = View.GONE
641
+                    /*mBinding.flayoutRoot.visibility = View.GONE*/
642
+                    mBinding.userinfoLlayout.visibility=View.VISIBLE
643
+                    mBinding.rv.visibility = View.VISIBLE
641
                 }
644
                 }
642
                 it?.let {
645
                 it?.let {
643
                     if (!netAutoAppFlag || isDestroyFlag) {
646
                     if (!netAutoAppFlag || isDestroyFlag) {
931
                     StrategyUtils.clearMemory(context, data)
934
                     StrategyUtils.clearMemory(context, data)
932
                     Toaster.show(context.getString(R.string.speedend))
935
                     Toaster.show(context.getString(R.string.speedend))
933
                 }
936
                 }
937
+/*
938
+                if (ModelNameUtils.IS_LianxX505f()|| ModelNameUtils.IS_LianxX6e6f()|| ModelNameUtils.IS_LianxTB223FC()){
939
+                    ManageApplication.setPackageEnabled("com.tblenovo.launcher",true)
940
+                    //505f的桌面名称
941
+                    if (ModelNameUtils.IS_LianxTB223FC()){
942
+                        ManageApplication.setCustomLauncher("com.tblenovo.launcher","com.android.searchlauncher.SearchLauncher")
943
+                    }else{
944
+                        ManageApplication.setCustomLauncher("com.tblenovo.launcher","com.android.iotlauncher.IotLauncher")
945
+                    }
946
+                    try {
947
+                        //解除管控后,禁止切换启动器
948
+                        ManageApplication.disallowSwitchLauncher_v3(true)
949
+                        val launchIntent = Intent()
950
+                        if (ModelNameUtils.IS_LianxTB223FC()){
951
+                            launchIntent.setComponent(
952
+                                ComponentName(
953
+                                    "com.tblenovo.launcher",
954
+                                    "com.android.searchlauncher.SearchLauncher"
955
+                                )
956
+                            )
957
+                        }else{
958
+                            launchIntent.setComponent(
959
+                                ComponentName(
960
+                                    "com.tblenovo.launcher",
961
+                                    "com.android.iotlauncher.IotLauncher"
962
+                                )
963
+                            )
964
+                        }
965
+                        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
966
+                        startActivity(launchIntent)
967
+                    }catch (e:Exception){
968
+                        Toaster.showLong("失败原因"+e.toString())
969
+                    }
970
+                }
971
+*/
972
+
934
             }
973
             }
935
 
974
 
936
             override fun clearAppData(context: Context) {
975
             override fun clearAppData(context: Context) {
2096
                     AppCompatResources.getDrawable(this, R.drawable.icon_updatestrategy)!!
2135
                     AppCompatResources.getDrawable(this, R.drawable.icon_updatestrategy)!!
2097
                 )
2136
                 )
2098
             )
2137
             )
2099
-            mBinding.rv.visibility = View.VISIBLE
2138
+            //mBinding.rv.visibility = View.VISIBLE
2100
             if (adapter == null) {
2139
             if (adapter == null) {
2101
                 adapter = AppAdapter(this, dataList)
2140
                 adapter = AppAdapter(this, dataList)
2102
                 adapter?.changePwdListener = getChangeCodeListener()
2141
                 adapter?.changePwdListener = getChangeCodeListener()

+ 4
- 3
app/src/main/java/com/xhly/manageapp/utils/AfwUtils.kt View File

166
             if (iafwService != null) {
166
             if (iafwService != null) {
167
                 urlList.forEach {url->
167
                 urlList.forEach {url->
168
                     val afwRes = iafwService!!.addWhiteRule(url)
168
                     val afwRes = iafwService!!.addWhiteRule(url)
169
-                    Log.i(TAG, "setEnable=" + afwRes.operationResult)
169
+                    Log.i(TAG, "urlsetEnable=" + afwRes.operationResult+"|||"+url)
170
                 }
170
                 }
171
             } else {
171
             } else {
172
                 Log.i(TAG, "iafwService=null")
172
                 Log.i(TAG, "iafwService=null")
203
         try {
203
         try {
204
             if (iafwService != null) {
204
             if (iafwService != null) {
205
                 val afwRes = iafwService!!.clearAppRules()
205
                 val afwRes = iafwService!!.clearAppRules()
206
-                Log.i(TAG, "setEnable=" + afwRes.operationResult)
206
+                Log.i(TAG, "清除APP规则setEnable=" + afwRes.operationResult)
207
             } else {
207
             } else {
208
                 Log.i(TAG, "iafwService=null")
208
                 Log.i(TAG, "iafwService=null")
209
             }
209
             }
254
         try {
254
         try {
255
             if (iafwService != null) {
255
             if (iafwService != null) {
256
                 val afwRes = iafwService!!.setEnable(enable)
256
                 val afwRes = iafwService!!.setEnable(enable)
257
-                Log.i(TAG, "setEnable=" + afwRes.operationResult)
257
+                addUrLBlackList(arrayListOf("*"))
258
+                Log.i(TAG, "开启网络setEnable=" + afwRes.operationResult)
258
             } else {
259
             } else {
259
                 Log.i(TAG, "iafwService=null")
260
                 Log.i(TAG, "iafwService=null")
260
             }
261
             }

+ 1
- 3
app/src/main/java/com/xhly/manageapp/utils/StrategyUtils.kt View File

496
             ManageApplication.hideMenuSoftKey(true)
496
             ManageApplication.hideMenuSoftKey(true)
497
             ManageApplication.setLockScreenMode()
497
             ManageApplication.setLockScreenMode()
498
             //禁用蓝牙分享
498
             //禁用蓝牙分享
499
-            if (!ModelNameUtils.IS_LianxTB223FC()){
500
-                ManageApplication.disableBluetoothShare()
501
-            }
499
+            ManageApplication.disableBluetoothShare()
502
             //禁用Recovery模式
500
             //禁用Recovery模式
503
             ManageApplication.setCustomRecovery_v3()
501
             ManageApplication.setCustomRecovery_v3()
504
             //冻结默认启动器
502
             //冻结默认启动器

+ 3
- 0
app/src/main/res/layout/activity_main.xml View File

26
 
26
 
27
 
27
 
28
             <LinearLayout
28
             <LinearLayout
29
+                android:id="@+id/userinfo_llayout"
30
+                android:visibility="invisible"
29
                 android:layout_width="match_parent"
31
                 android:layout_width="match_parent"
30
                 android:layout_height="wrap_content"
32
                 android:layout_height="wrap_content"
31
                 android:layout_marginLeft="21dp"
33
                 android:layout_marginLeft="21dp"
180
                 android:textSize="8sp" />
182
                 android:textSize="8sp" />
181
         </LinearLayout>
183
         </LinearLayout>
182
         <LinearLayout
184
         <LinearLayout
185
+            android:visibility="gone"
183
             android:id="@+id/flayout_root"
186
             android:id="@+id/flayout_root"
184
             android:layout_width="match_parent"
187
             android:layout_width="match_parent"
185
             android:layout_height="match_parent"
188
             android:layout_height="match_parent"

Loading…
Cancel
Save