Skip to content

Commit db7f7f4

Browse files
committed
fix: updated bundletool.jar to support 16 KB page size. remove vendor adb
1 parent ad7e6ab commit db7f7f4

12 files changed

Lines changed: 10819 additions & 12393 deletions

File tree

lib/common/resources/platform-tools/android/darwin/NOTICE.txt

Lines changed: 0 additions & 3407 deletions
This file was deleted.
-1.85 MB
Binary file not shown.

lib/common/resources/platform-tools/android/linux/NOTICE.txt

Lines changed: 0 additions & 4451 deletions
This file was deleted.
-2.05 MB
Binary file not shown.
-95.5 KB
Binary file not shown.
-61.5 KB
Binary file not shown.

lib/common/resources/platform-tools/android/win32/NOTICE.txt

Lines changed: 0 additions & 4451 deletions
This file was deleted.
-1.35 MB
Binary file not shown.
-312 KB
Binary file not shown.

lib/config.ts

Lines changed: 6 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import * as path from "path";
2-
import * as shelljs from "shelljs";
3-
import * as os from "os";
41
import * as _ from "lodash";
2+
import * as path from "path";
3+
import { IFileSystem } from "./common/declarations";
4+
import { IInjector } from "./common/definitions/yok";
5+
import { injector } from "./common/yok";
56
import {
7+
IAndroidToolsInfo,
68
IConfiguration,
79
IStaticConfig,
8-
IAndroidToolsInfo,
910
} from "./declarations";
10-
import { IFileSystem, IChildProcess, IHostInfo } from "./common/declarations";
11-
import { IInjector } from "./common/definitions/yok";
12-
import { injector } from "./common/yok";
1311

1412
export class Configuration implements IConfiguration {
1513
// User specific config
@@ -77,9 +75,7 @@ export class StaticConfig implements IStaticConfig {
7775
if (!this._adbFilePath) {
7876
const androidToolsInfo: IAndroidToolsInfo =
7977
this.$injector.resolve("androidToolsInfo");
80-
this._adbFilePath =
81-
(await androidToolsInfo.getPathToAdbFromAndroidHome()) ||
82-
(await this.getAdbFilePathCore());
78+
this._adbFilePath = await androidToolsInfo.getPathToAdbFromAndroidHome();
8379
}
8480

8581
return this._adbFilePath;
@@ -110,79 +106,5 @@ export class StaticConfig implements IStaticConfig {
110106
public get HTML_COMMON_HELPERS_DIR(): string {
111107
return path.join(__dirname, "common", "docs", "helpers");
112108
}
113-
114-
private async getAdbFilePathCore(): Promise<string> {
115-
const $childProcess: IChildProcess =
116-
this.$injector.resolve("$childProcess");
117-
118-
try {
119-
// Do NOT use the adb wrapper because it will end blow up with Segmentation fault because the wrapper uses this method!!!
120-
const proc = await $childProcess.spawnFromEvent(
121-
"adb",
122-
["version"],
123-
"exit",
124-
undefined,
125-
{ throwError: false }
126-
);
127-
128-
if (proc.stderr) {
129-
return await this.spawnPrivateAdb();
130-
}
131-
} catch (e) {
132-
if (e.code === "ENOENT") {
133-
return await this.spawnPrivateAdb();
134-
}
135-
}
136-
137-
return "adb";
138-
}
139-
140-
/*
141-
Problem:
142-
1. Adb forks itself as a server which keeps running until adb kill-server is invoked or crashes
143-
2. On Windows running processes lock their image files due to memory mapping. Locked files prevent their parent directories from deletion and cannot be overwritten.
144-
3. Update and uninstall scenarios are broken
145-
Solution:
146-
- Copy adb and associated files into a temporary directory. Let this copy of adb run persistently
147-
- On Posix OSes, immediately delete the file to not take file space
148-
- Tie common lib version to updates of adb, so that when we integrate a newer adb we can use it
149-
- Adb is named differently on OSes and may have additional files. The code is hairy to accommodate these differences
150-
*/
151-
private async spawnPrivateAdb(): Promise<string> {
152-
const $fs: IFileSystem = this.$injector.resolve("$fs"),
153-
$childProcess: IChildProcess = this.$injector.resolve("$childProcess"),
154-
$hostInfo: IHostInfo = this.$injector.resolve("$hostInfo");
155-
156-
// prepare the directory to host our copy of adb
157-
const defaultAdbDirPath = path.join(
158-
__dirname,
159-
"common",
160-
"resources",
161-
"platform-tools",
162-
"android",
163-
process.platform
164-
);
165-
const pathToPackageJson = path.join(__dirname, "..", "package.json");
166-
const nsCliVersion = require(pathToPackageJson).version;
167-
const tmpDir = path.join(os.tmpdir(), `nativescript-cli-${nsCliVersion}`);
168-
$fs.createDirectory(tmpDir);
169-
170-
// copy the adb and associated files
171-
const targetAdb = path.join(tmpDir, "adb");
172-
173-
// In case directory is missing or it's empty, copy the new adb
174-
if (!$fs.exists(tmpDir) || !$fs.readDirectory(tmpDir).length) {
175-
shelljs.cp(path.join(defaultAdbDirPath, "*"), tmpDir); // deliberately ignore copy errors
176-
// adb loses its executable bit when packed inside electron asar file. Manually fix the issue
177-
if (!$hostInfo.isWindows) {
178-
shelljs.chmod("+x", targetAdb);
179-
}
180-
}
181-
182-
// let adb start its global server
183-
await $childProcess.spawnFromEvent(targetAdb, ["start-server"], "exit");
184-
185-
return targetAdb;
186-
}
187109
}
188110
injector.register("staticConfig", StaticConfig);

0 commit comments

Comments
 (0)