Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 0f29501c authored by Simon Chan's avatar Simon Chan
Browse files

feat(bin): add `PackageManager.prototype.getPackages` method

parent 5a1f4176
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
---
"@yume-chan/android-bin": minor
---

Add `PackageManager.prototype.getPackages` method to get apk paths
+16 −0
Original line number Diff line number Diff line
@@ -475,6 +475,22 @@ export class PackageManager extends AdbCommandBase {
        }
    }

    async getPackages(packageName: string): Promise<string[]> {
        const args = ["pm", "-p", packageName];

        const process = await this.#cmdOrSubprocess(args);
        const result: string[] = [];
        for await (const line of process.stdout
            .pipeThrough(new TextDecoderStream())
            .pipeThrough(new SplitStringStream("\n"))) {
            if (line.startsWith("package:")) {
                result.push(line.substring("package:".length));
            }
        }

        return result;
    }

    async uninstall(
        packageName: string,
        options?: Partial<PackageManagerUninstallOptions>,