Skip to content

Commit

Permalink
添加应用信息
Browse files Browse the repository at this point in the history
  • Loading branch information
ichtj committed Mar 28, 2024
1 parent 3df5d3b commit 808132d
Show file tree
Hide file tree
Showing 7 changed files with 1,624 additions and 1,594 deletions.
3,158 changes: 1,583 additions & 1,575 deletions app/proguardMapping.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":17,"versionName":"1.3.1","enabled":true,"outputFile":"baseiotutils_v1.3.1_2024-03-12_release.apk","fullName":"release","baseName":"release"},"path":"baseiotutils_v1.3.1_2024-03-12_release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":17,"versionName":"1.3.1","enabled":true,"outputFile":"hidTest_v1.3.1_2024-03-27_release.apk","fullName":"release","baseName":"release"},"path":"hidTest_v1.3.1_2024-03-27_release.apk","properties":{}}]
12 changes: 12 additions & 0 deletions app/src/main/java/com/ichtj/basetools/hid/HidAty.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.ichtj.basetools.hid;

import android.app.PendingIntent;
import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
Expand All @@ -8,13 +12,17 @@
import android.widget.RadioButton;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.face_chtj.base_iotutils.TranscodingUtils;
import com.face_chtj.base_iotutils.FormatViewUtils;
import com.ichtj.basetools.R;
import com.ichtj.basetools.base.BaseActivity;
import com.ichtj.basetools.util.PACKAGES;

import java.util.Arrays;
import java.util.HashMap;

@Route(path = PACKAGES.BASE + "hidTest")
public class HidAty extends BaseActivity implements CompoundButton.OnCheckedChangeListener {
private static final String TAG = HidAty.class.getSimpleName();
TextView tvResult;
Expand All @@ -37,6 +45,10 @@ public void receive(byte[] data) {
FormatViewUtils.formatData(tvResult, "HidRead>>" + TranscodingUtils.encodeHexString(data));
}
});
UsbManager manager= (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> usbDeviceHashMap=manager.getDeviceList();
Log.d(TAG, "onCreate: usbDeviceHashMap>>"+usbDeviceHashMap);
tvResult.setText(usbDeviceHashMap.toString());
}

/*new byte[]{0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00}*/
Expand Down
Binary file added app/src/main/res/mipmap-xxhdpi/ic_hid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author chtj
* create by chtj on 2019-8-6
* desc:AppsUtils相关工具类
* --查询桌面所有应用 {@link #getAllApp(boolean)} ()}
* --查询桌面所有应用 {@link #getDeskTopAppList()}
* --获取当前应用名称 {@link #getAppName(String packageName)}
* --根据包名获取进程PID {@link #getPidByPackageName(String packagename)}
* --获取APP-VersionCode {@link #getAppVersionCode()}
Expand Down Expand Up @@ -73,28 +73,28 @@ public static String getAppPath(String pkgName) {
*/
public static List<AppEntity> getDeskTopAppList() {
try {
Context context=BaseIotUtils.getContext();
List<AppEntity> appEntityList = new ArrayList<AppEntity>();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager pm = BaseIotUtils.getContext().getPackageManager();
PackageManager pm = context.getPackageManager();
List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
for (int i = 0; i < apps.size(); i++) {
ResolveInfo info = apps.get(i);
//KLog.d("getDeskTopAppList() info >> " + info.activityInfo.toString());
String pkg = info.activityInfo.packageName;
Drawable icon = info.loadIcon(BaseIotUtils.getContext().getPackageManager());
PackageInfo packageInfo = pm.getPackageInfo(pkg, 0);
long firstInstallTime=packageInfo.firstInstallTime;
long lastUpdateTime=packageInfo.lastUpdateTime;
Drawable icon = info.loadIcon(context.getPackageManager());
ApplicationInfo ai = pm.getApplicationInfo(info.activityInfo.packageName, PackageManager.GET_ACTIVITIES);
CharSequence name = info.activityInfo.loadLabel(BaseIotUtils.getContext().getPackageManager());
boolean isSys = false;
if ((ai.flags & ai.FLAG_SYSTEM) != 0) {
isSys = true;
}
CharSequence name = info.activityInfo.loadLabel(context.getPackageManager());
boolean isSys = (ai.flags & ai.FLAG_SYSTEM) != 0;
String topApp=getTopApp();
boolean isTopApp = ai.packageName.contains(topApp);
int vCode = pm.getPackageInfo(pkg, 0).versionCode;
String vName = pm.getPackageInfo(pkg, 0).versionName;
String sourceDir = ai.sourceDir;
AppEntity entity = new AppEntity(name.toString(),pkg,vCode,vName,icon,isTopApp,isAppRunning(pkg),isSys,false,getUidByPackageName(pkg),getPidByPackageName(pkg),sourceDir,getAllProcess(pkg),getRunService(pkg));
AppEntity entity = new AppEntity(name.toString(),pkg,vCode,vName,firstInstallTime,lastUpdateTime,icon,isTopApp,isAppRunning(pkg),isSys,false,getUidByPackageName(pkg),getPidByPackageName(pkg),sourceDir,getAllProcess(pkg),getRunService(pkg));
appEntityList.add(entity);
}
return appEntityList;
Expand All @@ -108,8 +108,9 @@ public static List<AppEntity> getDeskTopAppList() {
* 查询所有应用 包含包名下app名称,图标的明细信息list
*/
public static List<AppEntity> getAllApp() {
PackageManager packageManager = BaseIotUtils.getContext().getPackageManager();
ActivityManager activityManager = (ActivityManager) BaseIotUtils.getContext().getSystemService(Context.ACTIVITY_SERVICE);
Context context=BaseIotUtils.getContext();
PackageManager packageManager = context.getPackageManager();
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<AppEntity> appList = new ArrayList<>();
List<ApplicationInfo> installedApps = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo appInfo : installedApps) {
Expand All @@ -120,14 +121,16 @@ public static List<AppEntity> getAllApp() {
String packageName = appInfo.packageName;
int versionCode = packageInfo.versionCode;
String versionName = packageInfo.versionName;
long firstInstallTime=packageInfo.firstInstallTime;
long lastUpdateTime=packageInfo.lastUpdateTime;
Drawable icon = packageManager.getApplicationIcon(appInfo);
int uid = appInfo.uid;
int pid = getPid(appInfo.packageName,activityManager);
String sourceDir = appInfo.sourceDir;
String topApp=getTopApp();
boolean isTopApp = appInfo.packageName.contains(topApp);
boolean isRunning = isAppRunning(appInfo.packageName);
AppEntity app = new AppEntity(appName, packageName, versionCode, versionName, icon, isTopApp, isRunning, isSystemApp,false, uid, pid, sourceDir,getAllProcess(appInfo.packageName), getRunService(appInfo.packageName));
AppEntity app = new AppEntity(appName, packageName, versionCode, versionName,firstInstallTime,lastUpdateTime, icon, isTopApp, isRunning, isSystemApp,false, uid, pid, sourceDir,getAllProcess(appInfo.packageName), getRunService(appInfo.packageName));
appList.add(app);
} catch (Throwable e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class AppEntity {
public String packageName;
public int versionCode;
public String versionName;
public long firstInstallTime;
public long lastUpdateTime;
public Drawable icon;
public boolean isTopApp;
public boolean isRunning;
Expand All @@ -19,11 +21,14 @@ public class AppEntity {
public String sourceDir;
public List<ProcessEntity> pkgProcess;//包名下的进程信息
public List<String> pkgService;//该应用运行的服务
public AppEntity(String appName, String packageName, int versionCode, String versionName, Drawable icon, boolean isTopApp, boolean isRunning, boolean isSystemApp, boolean isCheck, int uid, int pid, String sourceDir, List<ProcessEntity> pkgProcess, List<String> pkgService) {

public AppEntity(String appName, String packageName, int versionCode, String versionName, long firstInstallTime, long lastUpdateTime, Drawable icon, boolean isTopApp, boolean isRunning, boolean isSystemApp, boolean isCheck, int uid, int pid, String sourceDir, List<ProcessEntity> pkgProcess, List<String> pkgService) {
this.appName = appName;
this.packageName = packageName;
this.versionCode = versionCode;
this.versionName = versionName;
this.firstInstallTime = firstInstallTime;
this.lastUpdateTime = lastUpdateTime;
this.icon = icon;
this.isTopApp = isTopApp;
this.isRunning = isRunning;
Expand Down
10 changes: 6 additions & 4 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext {
//选择对应签名 "cainiao" "rockchip" "imx8" "freescale"
BUILD_SIGN="freescale"
BUILD_SIGN="rockchip"
BUILD_SIGN_PWD="android"
BUILD_SIGN_PATH="../other/facefuture.jks"
//android开发版本配置
Expand All @@ -13,22 +13,24 @@ ext {
versionName : "1.3.1",
]
//配置此项可对应生成不同的包名/应用图标 跳转不同界面
APP_CHOOSE='baseiotutils'
APP_CHOOSE='hidTest'
MY_PKG = [
baseiotutils :'com.ichtj.basetools',
socket :'com.ichtj.socket',
serialport :'com.ichtj.serialport',
reboot :'com.ichtj.reboot',
netrecord :'com.ichtj.netrecord',
netmonitor :'com.ichtj.netmonitor'
netmonitor :'com.ichtj.netmonitor',
hidTest :'com.ichtj.hid'
]
MY_ICON = [
baseiotutils :'@drawable/app_img',
socket :'@drawable/ic_socket',
serialport :'@drawable/ic_serialport',
reboot :'@mipmap/reboot',
netrecord :'@drawable/ic_net_record',
netmonitor :'@mipmap/netmonitor'
netmonitor :'@mipmap/netmonitor',
hidTest :'@mipmap/ic_hid'
]
//support配置
support = [
Expand Down

0 comments on commit 808132d

Please sign in to comment.