installStream
Install a single APK from a ReadableStream
.
It will use streaming install if the device supports it. The APK file will be uploaded, parsed, and installed at the same time.
If the device does not support streaming install, it will first use AdbSync.prototype.write
to upload the APK file to a temp folder on the device, then use install
method to install it.
export interface PackageManagerInstallOptions {
/**
* `-R`
*/
skipExisting: boolean;
/**
* `-i`
*/
installerPackageName: string;
/**
* `-t`
*/
allowTest: boolean;
/**
* `-f`
*/
internalStorage: boolean;
/**
* `-d`
*/
requestDowngrade: boolean;
/**
* `-g`
*/
grantRuntimePermissions: boolean;
/**
* `--restrict-permissions`
*/
restrictPermissions: boolean;
/**
* `--dont-kill`
*/
doNotKill: boolean;
/**
* `--originating-uri`
*/
originatingUri: string;
/**
* `--referrer`
*/
refererUri: string;
/**
* `-p`
*/
inheritFrom: string;
/**
* `--pkg`
*/
packageName: string;
/**
* `--abi`
*/
abi: string;
/**
* `--ephemeral`/`--instant`/`--instantapp`
*/
instantApp: boolean;
/**
* `--full`
*/
full: boolean;
/**
* `--preload`
*/
preload: boolean;
/**
* `--user`
*/
user: SingleUserOrAll;
/**
* `--install-location`
*/
installLocation: PackageManagerInstallLocation;
/**
* `--install-reason`
*/
installReason: PackageManagerInstallReason;
/**
* `--force-uuid`
*/
forceUuid: string;
/**
* `--apex`
*/
apex: boolean;
/**
* `--force-non-staged`
*/
forceNonStaged: boolean;
/**
* `--staged`
*/
staged: boolean;
/**
* `--force-queryable`
*/
forceQueryable: boolean;
/**
* `--enable-rollback`
*/
enableRollback: boolean;
/**
* `--staged-ready-timeout`
*/
stagedReadyTimeout: number;
/**
* `--skip-verification`
*/
skipVerification: boolean;
/**
* `--bypass-low-target-sdk-block`
*/
bypassLowTargetSdkBlock: boolean;
}
declare class PackageManager {
installStream(
size: number,
stream: ReadableStream<Uint8Array>,
options?: Partial<PackageManagerInstallOptions>
): Promise<void>;
}
Usage
- JavaScript
- TypeScript
import { PackageManager } from "@yume-chan/android-bin";
const pm = new PackageManager(adb);
await pm.installStream(file.size, file.stream());
import type { Adb } from "@yume-chan/adb";
import { PackageManager } from "@yume-chan/android-bin";
declare const adb: Adb;
const pm = new PackageManager(adb);
declare const file: File;
await pm.installStream(file.size, file.stream());
Equivalent ADB Command
adb install /path/to/app.apk