Browse Source

1.管理页面取消按键隐藏。

2.已安装应用的app名字优先使用商店的名字。
3.登陆时重新设置策略。
20241218TB223FC(测试jar包)
wangwanlei 8 months ago
parent
commit
690cb35d50

+ 1
- 1
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

245
         if (exitControlFlag){
245
         if (exitControlFlag){
246
             //如果解除了管控,登录成功则重新添加管控
246
             //如果解除了管控,登录成功则重新添加管控
247
             currentSpUtils.setParam(Const.EXIT_CONTROL,false)
247
             currentSpUtils.setParam(Const.EXIT_CONTROL,false)
248
-            StrategyUtils.initControlStrategy()
249
         }
248
         }
249
+        StrategyUtils.initControlStrategy()
250
         //提交登录事件
250
         //提交登录事件
251
         val data = LogdOperateBean()
251
         val data = LogdOperateBean()
252
         ManageApplication.getDeviceInfo()?.let {
252
         ManageApplication.getDeviceInfo()?.let {

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

844
     private fun updateAppInstallInfo() {
844
     private fun updateAppInstallInfo() {
845
         try {
845
         try {
846
             //获得已安装应用列表
846
             //获得已安装应用列表
847
-            val appList = AppUtils.GetAppList(this)
847
+            val appList = AppUtils.GetAllAppList(this)
848
             try {
848
             try {
849
                 //获得预装应用的包名
849
                 //获得预装应用的包名
850
                 val currentList =
850
                 val currentList =
863
                 }
863
                 }
864
                 //除了管控之类的我们的app之外的预装都不在统计范围,所以移除
864
                 //除了管控之类的我们的app之外的预装都不在统计范围,所以移除
865
                 appList.removeAll(removeList)
865
                 appList.removeAll(removeList)
866
+                //获得存储的应用商店包名
867
+                getAppStoreList()
866
             } catch (e: Exception) {
868
             } catch (e: Exception) {
867
 
869
 
868
             }
870
             }
871
+
869
             val userBean = spUtils.getFromJson(Const.USERINFO, UserBean().javaClass) as UserBean
872
             val userBean = spUtils.getFromJson(Const.USERINFO, UserBean().javaClass) as UserBean
870
             val appInstallList = arrayListOf<AppInstallBean>()
873
             val appInstallList = arrayListOf<AppInstallBean>()
871
             appList.forEach {
874
             appList.forEach {
872
                 val appInstallBean = AppInstallBean()
875
                 val appInstallBean = AppInstallBean()
873
                 appInstallBean.userid = userBean.userid
876
                 appInstallBean.userid = userBean.userid
874
-                appInstallBean.appName = it.name
877
+                val filter =
878
+                    appStroeList.filter { store -> store.appPackage.equals(it.packageName) }
879
+                if (filter.isNotEmpty()){
880
+                    appInstallBean.appName = filter[0].appName
881
+                }else{
882
+                    appInstallBean.appName = it.name
883
+                }
875
                 appInstallBean.appVersion = it.versionName
884
                 appInstallBean.appVersion = it.versionName
876
                 appInstallBean.appNum = it.versionNum
885
                 appInstallBean.appNum = it.versionNum
877
                 appInstallBean.appPackage = it.packageName
886
                 appInstallBean.appPackage = it.packageName

+ 1
- 0
app/src/main/res/layout/activity_manage.xml View File

213
                     android:layout_width="0dp"
213
                     android:layout_width="0dp"
214
                     android:layout_height="80dp"
214
                     android:layout_height="80dp"
215
                     android:layout_weight="1"
215
                     android:layout_weight="1"
216
+                    android:visibility="gone"
216
                     android:text="隐藏底部按键" />
217
                     android:text="隐藏底部按键" />
217
                 <androidx.appcompat.widget.AppCompatButton
218
                 <androidx.appcompat.widget.AppCompatButton
218
                     android:id="@+id/clear_btn"
219
                     android:id="@+id/clear_btn"

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

67
 
67
 
68
     //存储区域码,存在则在弹窗出现时显示
68
     //存储区域码,存在则在弹窗出现时显示
69
     const val REGIONCODEKEY="REGIONCODEKEY"
69
     const val REGIONCODEKEY="REGIONCODEKEY"
70
-    //接口地址
70
+    //接口地址 正式地址mc.xhkjedu.com测试地址mcapitest.xhkjedu.com
71
     const val URL1: String = "https://mcapitest.xhkjedu.com/"
71
     const val URL1: String = "https://mcapitest.xhkjedu.com/"
72
 
72
 
73
     //接口地址
73
     //接口地址

+ 46
- 0
corelib/src/main/java/com/xhly/corelib/utils/AppUtils.java View File

18
 import java.util.List;
18
 import java.util.List;
19
 
19
 
20
 public class AppUtils {
20
 public class AppUtils {
21
+    /**
22
+     * 获得不包含自己的app列表
23
+     */
21
     public static List<AppInfo> GetAppList(Context context) {
24
     public static List<AppInfo> GetAppList(Context context) {
22
         List<AppInfo> list = new ArrayList<>();
25
         List<AppInfo> list = new ArrayList<>();
23
         List<String>  pkgList=new ArrayList<>();
26
         List<String>  pkgList=new ArrayList<>();
59
         return list;
62
         return list;
60
     }
63
     }
61
 
64
 
65
+    /**
66
+     * 获得包含自己的app列表
67
+     */
68
+    public static List<AppInfo> GetAllAppList(Context context) {
69
+        List<AppInfo> list = new ArrayList<>();
70
+        List<String>  pkgList=new ArrayList<>();
71
+        PackageManager pm = context.getPackageManager();
72
+        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
73
+        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
74
+        List<ResolveInfo> activities = pm.queryIntentActivities(mainIntent, 0);
75
+        for (ResolveInfo info : activities) {
76
+            String packName = info.activityInfo.packageName;
77
+            //去重
78
+            if (pkgList.contains(packName)) {
79
+                continue;
80
+            }
81
+            AppInfo mInfo = new AppInfo();
82
+            mInfo.setIco(info.activityInfo.applicationInfo.loadIcon(pm));
83
+            mInfo.setName(info.activityInfo.applicationInfo.loadLabel(pm).toString());
84
+            mInfo.setPackageName(packName);
85
+            pkgList.add(packName);
86
+            try {
87
+                PackageInfo packageInfo = context.getPackageManager().getPackageInfo(packName, PackageManager.GET_META_DATA);
88
+                mInfo.setVersionName(packageInfo.versionName);
89
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
90
+                    mInfo.setVersionNum(packageInfo.getLongVersionCode());
91
+                }else {
92
+                    mInfo.setVersionNum(packageInfo.versionCode);
93
+                }
94
+            } catch (PackageManager.NameNotFoundException e) {
95
+                throw new RuntimeException(e);
96
+            }
97
+            // 为应用程序的启动Activity 准备Intent
98
+            Intent launchIntent = new Intent();
99
+            launchIntent.setComponent(new ComponentName(packName,
100
+                    info.activityInfo.name));
101
+            launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
102
+            mInfo.setIntent(launchIntent);
103
+            list.add(mInfo);
104
+        }
105
+        return list;
106
+    }
107
+
62
     /**
108
     /**
63
      * 判断应用是否已经安装
109
      * 判断应用是否已经安装
64
      */
110
      */

Loading…
Cancel
Save