定制adb 命令需求
2021-11-01 本文已影响0人
gale_小米
1)根据gmsxxx.jar 包获取执行 得到 需求执行adb 命令“cmd package query-activities --components” 时要过滤掉指定的应用
1.定位adb 命令执行文件(PackageManagerShellCommand.java);
java.lang.IllegalArgumentException: No intent supplied
at android.content.Intent.parseCommandArgs(Intent.java:7441)
at com.android.server.pm.PackageManagerShellCommand.parseIntentAndUser(PackageManagerShellCommand.java:878)
at com.android.server.pm.PackageManagerShellCommand.runQueryIntentActivities(PackageManagerShellCommand.java:960)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:163)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21972)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4860)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4035)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
2.根据具体需求进行配置
Index: PackageManagerShellCommand.java
===================================================================
--- PackageManagerShellCommand.java (revision 11487)
+++ PackageManagerShellCommand.java (working copy)
@@ -904,7 +904,11 @@
if (brief || components) {
final ComponentName comp;
if (ri.activityInfo != null) {
- comp = new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
+ if(ri.activityInfo.name.contains("xxx")){
+ return;
+ }else{
+ comp = new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
+ }
} else if (ri.serviceInfo != null) {
comp = new ComponentName(ri.serviceInfo.packageName, ri.serviceInfo.name);
} else if (ri.providerInfo != null) {