获取 APP 列表 ( 包名 ) @param type pm list packages 命令后的附加选项片段,可为空;例如 -3、-s @return 对应选项的应用包名列表
(final String type)
| 84 | * @return 对应选项的应用包名列表 |
| 85 | */ |
| 86 | public static List<String> getAppList(final String type) { |
| 87 | // adb shell pm list packages [options] |
| 88 | String typeStr = TextUtils.isEmpty(type) ? "" : " " + type; |
| 89 | // 执行 shell |
| 90 | ShellUtils.CommandResult result = ShellUtils.execCmd( |
| 91 | "pm list packages" + typeStr, false |
| 92 | ); |
| 93 | if (result.isSuccessWithSuccessOutput()) { |
| 94 | try { |
| 95 | String[] arrays = result.successMsg.split(DevFinal.SYMBOL.NEW_LINE); |
| 96 | return Arrays.asList(arrays); |
| 97 | } catch (Exception e) { |
| 98 | LogPrintUtils.eTag(TAG, e, "getAppList type: %s", typeStr); |
| 99 | } |
| 100 | } |
| 101 | return null; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * 获取 APP 安装列表 ( 包名 ) |
no test coverage detected