@bubblewrap/core 1.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/README.md +63 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +56 -0
- package/dist/lib/BufferedLog.d.ts +20 -0
- package/dist/lib/BufferedLog.js +83 -0
- package/dist/lib/Config.d.ts +9 -0
- package/dist/lib/Config.js +50 -0
- package/dist/lib/DigitalAssetLinks.d.ts +3 -0
- package/dist/lib/DigitalAssetLinks.js +37 -0
- package/dist/lib/FetchUtils.d.ts +17 -0
- package/dist/lib/FetchUtils.js +79 -0
- package/dist/lib/GooglePlay.d.ts +41 -0
- package/dist/lib/GooglePlay.js +92 -0
- package/dist/lib/GradleWrapper.d.ts +31 -0
- package/dist/lib/GradleWrapper.js +62 -0
- package/dist/lib/ImageHelper.d.ts +37 -0
- package/dist/lib/ImageHelper.js +112 -0
- package/dist/lib/Log.d.ts +88 -0
- package/dist/lib/Log.js +114 -0
- package/dist/lib/Result.d.ts +46 -0
- package/dist/lib/Result.js +97 -0
- package/dist/lib/ShortcutInfo.d.ts +32 -0
- package/dist/lib/ShortcutInfo.js +84 -0
- package/dist/lib/TwaGenerator.d.ts +39 -0
- package/dist/lib/TwaGenerator.js +362 -0
- package/dist/lib/TwaManifest.d.ts +234 -0
- package/dist/lib/TwaManifest.js +384 -0
- package/dist/lib/androidSdk/AndroidSdkTools.d.ts +87 -0
- package/dist/lib/androidSdk/AndroidSdkTools.js +226 -0
- package/dist/lib/errors/ValidatePathError.d.ts +9 -0
- package/dist/lib/errors/ValidatePathError.js +16 -0
- package/dist/lib/features/AppsFlyerFeature.d.ts +8 -0
- package/dist/lib/features/AppsFlyerFeature.js +70 -0
- package/dist/lib/features/EmptyFeature.d.ts +28 -0
- package/dist/lib/features/EmptyFeature.js +44 -0
- package/dist/lib/features/Feature.d.ts +120 -0
- package/dist/lib/features/Feature.js +17 -0
- package/dist/lib/features/FeatureManager.d.ts +36 -0
- package/dist/lib/features/FeatureManager.js +137 -0
- package/dist/lib/features/FirstRunFlagFeature.d.ts +8 -0
- package/dist/lib/features/FirstRunFlagFeature.js +43 -0
- package/dist/lib/features/LocationDelegationFeature.d.ts +7 -0
- package/dist/lib/features/LocationDelegationFeature.js +32 -0
- package/dist/lib/features/PlayBillingFeature.d.ts +7 -0
- package/dist/lib/features/PlayBillingFeature.js +53 -0
- package/dist/lib/jdk/JarSigner.d.ts +13 -0
- package/dist/lib/jdk/JarSigner.js +55 -0
- package/dist/lib/jdk/JdkHelper.d.ts +55 -0
- package/dist/lib/jdk/JdkHelper.js +127 -0
- package/dist/lib/jdk/KeyTool.d.ts +57 -0
- package/dist/lib/jdk/KeyTool.js +136 -0
- package/dist/lib/mock/MockLog.d.ts +37 -0
- package/dist/lib/mock/MockLog.js +70 -0
- package/dist/lib/types/WebManifest.d.ts +44 -0
- package/dist/lib/types/WebManifest.js +17 -0
- package/dist/lib/util.d.ts +82 -0
- package/dist/lib/util.js +279 -0
- package/dist/lib/wrappers/svg2img.d.ts +14 -0
- package/dist/lib/wrappers/svg2img.js +39 -0
- package/package.json +58 -0
- package/template_project/app/.gitignore +1 -0
- package/template_project/app/build.gradle +211 -0
- package/template_project/app/src/main/AndroidManifest.xml +204 -0
- package/template_project/app/src/main/java/Application.java +35 -0
- package/template_project/app/src/main/java/DelegationService.java +18 -0
- package/template_project/app/src/main/java/LauncherActivity.java +62 -0
- package/template_project/app/src/main/res/drawable-anydpi/shortcut_legacy_background.xml +25 -0
- package/template_project/app/src/main/res/drawable-anydpi/shortcut_monochrome.xml +27 -0
- package/template_project/app/src/main/res/drawable-anydpi-v26/shortcut_maskable.xml +32 -0
- package/template_project/app/src/main/res/drawable-anydpi-v26/shortcut_monochrome.xml +26 -0
- package/template_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +33 -0
- package/template_project/app/src/main/res/values/colors.xml +18 -0
- package/template_project/app/src/main/res/values/strings.xml +50 -0
- package/template_project/app/src/main/res/xml/filepaths.xml +18 -0
- package/template_project/app/src/main/res/xml/shortcuts.xml +16 -0
- package/template_project/build.gradle +42 -0
- package/template_project/enable-debug.sh +27 -0
- package/template_project/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template_project/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/template_project/gradle.properties +14 -0
- package/template_project/gradlew +188 -0
- package/template_project/gradlew.bat +100 -0
- package/template_project/settings.gradle +1 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Config } from '../Config';
|
|
3
|
+
import { JdkHelper } from '../jdk/JdkHelper';
|
|
4
|
+
import { Log } from '../../lib/Log';
|
|
5
|
+
import { Result } from '../../lib/Result';
|
|
6
|
+
import { ValidatePathError } from '../errors/ValidatePathError';
|
|
7
|
+
export declare const BUILD_TOOLS_VERSION = "30.0.3";
|
|
8
|
+
/**
|
|
9
|
+
* Wraps functionality of the Android SDK Tools and allows them to be invoked programatically.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AndroidSdkTools {
|
|
12
|
+
readonly log: Log;
|
|
13
|
+
private process;
|
|
14
|
+
private config;
|
|
15
|
+
private jdkHelper;
|
|
16
|
+
private pathJoin;
|
|
17
|
+
static create(process: NodeJS.Process, config: Config, jdkHelper: JdkHelper, log?: Log): Promise<AndroidSdkTools>;
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new instance of AndroidSdkTools.
|
|
20
|
+
*
|
|
21
|
+
* @param {NodeJS.Process} process information from the OS process
|
|
22
|
+
* @param {Config} config the bubblewrap general configuration
|
|
23
|
+
* @param {jdkHelper} jdkHelper the JDK information to be used by the Android SDK
|
|
24
|
+
*/
|
|
25
|
+
constructor(process: NodeJS.Process, config: Config, jdkHelper: JdkHelper, log?: Log);
|
|
26
|
+
/**
|
|
27
|
+
* Installs the build tools into the the Android SDK. Equivalent to running
|
|
28
|
+
*
|
|
29
|
+
* `tools/bin/sdkmanager --install "build-tools;29.0.2"`
|
|
30
|
+
*/
|
|
31
|
+
installBuildTools(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Verifies if the build-tools are installed on the Android SDK.
|
|
34
|
+
*/
|
|
35
|
+
checkBuildTools(): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the path to the Android SDK.
|
|
38
|
+
* @returns {string} the path to the Android SDK.
|
|
39
|
+
*/
|
|
40
|
+
getAndroidHome(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a Node Process with the correct ANDROID_HOME information
|
|
43
|
+
* @returns {NodeJS.ProcessEnv} the env with ANDROID_HOME set
|
|
44
|
+
*/
|
|
45
|
+
getEnv(): NodeJS.ProcessEnv;
|
|
46
|
+
/**
|
|
47
|
+
* Invokes the zipalign tool from the Android SDK with the following flags:
|
|
48
|
+
* -f : overwrite existing outfile.zip.
|
|
49
|
+
* -v : verbose output.
|
|
50
|
+
* -p 4 : align all libraries to the 32-bit page boundary.
|
|
51
|
+
* More information on zipalign can be found here:
|
|
52
|
+
* https://developer.android.com/studio/command-line/zipalign
|
|
53
|
+
* @param {string} input path to the input file.
|
|
54
|
+
* @param {string} output path to the output file.
|
|
55
|
+
*/
|
|
56
|
+
zipalign(input: string, output: string): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Invokes the zipalign tool from the Android SDK with the following flags:
|
|
59
|
+
* -c : confirm the alignment of the given file.
|
|
60
|
+
* -v : verbose output.
|
|
61
|
+
* -p 4 : align all libraries to the 32-bit page boundary.
|
|
62
|
+
* More information on zipalign can be found here:
|
|
63
|
+
* https://developer.android.com/studio/command-line/zipalign
|
|
64
|
+
* @param {string} input path to the input file.
|
|
65
|
+
*/
|
|
66
|
+
zipalignOnlyVerification(input: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Signs an Android APK, with they keystore
|
|
69
|
+
* @param {string} keystore path to the keystore
|
|
70
|
+
* @param {string} ksPass keystore password
|
|
71
|
+
* @param {string} alias key alias
|
|
72
|
+
* @param {string} keyPass key password
|
|
73
|
+
* @param {string} input path to the input APK file
|
|
74
|
+
* @param {string} output path where the signed APK will be generated
|
|
75
|
+
*/
|
|
76
|
+
apksigner(keystore: string, ksPass: string, alias: string, keyPass: string, input: string, output: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Installs an APK on an a device connected to the computer.
|
|
79
|
+
* @param apkFilePath the path to the APK to be installed
|
|
80
|
+
*/
|
|
81
|
+
install(apkFilePath: string, passthroughArgs?: string[]): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if `sdkPath` is valid.
|
|
84
|
+
* @param {string} sdkPath the path to the sdk.
|
|
85
|
+
*/
|
|
86
|
+
static validatePath(sdkPath: string): Promise<Result<string, ValidatePathError>>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2019 Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AndroidSdkTools = exports.BUILD_TOOLS_VERSION = void 0;
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const util = require("../util");
|
|
22
|
+
const Log_1 = require("../../lib/Log");
|
|
23
|
+
const Result_1 = require("../../lib/Result");
|
|
24
|
+
const ValidatePathError_1 = require("../errors/ValidatePathError");
|
|
25
|
+
exports.BUILD_TOOLS_VERSION = '30.0.3';
|
|
26
|
+
/**
|
|
27
|
+
* Wraps functionality of the Android SDK Tools and allows them to be invoked programatically.
|
|
28
|
+
*/
|
|
29
|
+
class AndroidSdkTools {
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a new instance of AndroidSdkTools.
|
|
32
|
+
*
|
|
33
|
+
* @param {NodeJS.Process} process information from the OS process
|
|
34
|
+
* @param {Config} config the bubblewrap general configuration
|
|
35
|
+
* @param {jdkHelper} jdkHelper the JDK information to be used by the Android SDK
|
|
36
|
+
*/
|
|
37
|
+
constructor(process, config, jdkHelper, log = new Log_1.ConsoleLog('AndroidSdkTools')) {
|
|
38
|
+
this.log = log;
|
|
39
|
+
this.process = process;
|
|
40
|
+
this.config = config;
|
|
41
|
+
this.jdkHelper = jdkHelper;
|
|
42
|
+
if (this.process.platform === 'win32') {
|
|
43
|
+
this.pathJoin = path.win32.join;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.pathJoin = path.posix.join;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
static async create(process, config, jdkHelper, log = new Log_1.ConsoleLog('AndroidSdkTools')) {
|
|
50
|
+
// unwrap will throw an error in case that the the path is valid and else will do nothing.
|
|
51
|
+
(await AndroidSdkTools.validatePath(config.androidSdkPath)).unwrap();
|
|
52
|
+
try {
|
|
53
|
+
return new AndroidSdkTools(process, config, jdkHelper, log);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Installs the build tools into the the Android SDK. Equivalent to running
|
|
61
|
+
*
|
|
62
|
+
* `tools/bin/sdkmanager --install "build-tools;29.0.2"`
|
|
63
|
+
*/
|
|
64
|
+
async installBuildTools() {
|
|
65
|
+
const env = this.getEnv();
|
|
66
|
+
// The escape char allows us to pass a directory with spaces as sdk_root. On Windows,
|
|
67
|
+
// those are not properly handled by the Android SDK, so we try running without wrapping the
|
|
68
|
+
// value.
|
|
69
|
+
// TODO(andreban): Check for spaces in the path and throw an Error if one is found.
|
|
70
|
+
let sdkRootEscapeChar = '"';
|
|
71
|
+
let sdkManagerPath = this.pathJoin(this.getAndroidHome(), '/tools/bin/sdkmanager');
|
|
72
|
+
if (this.process.platform === 'win32') {
|
|
73
|
+
sdkRootEscapeChar = '';
|
|
74
|
+
sdkManagerPath += '.bat';
|
|
75
|
+
}
|
|
76
|
+
if (!fs.existsSync(sdkManagerPath)) {
|
|
77
|
+
// Android SDK version `6858069` and above doesn't have a `tools` folder anymore.
|
|
78
|
+
sdkManagerPath = this.pathJoin(this.getAndroidHome(), '/bin/sdkmanager');
|
|
79
|
+
if (this.process.platform === 'win32') {
|
|
80
|
+
sdkManagerPath += '.bat';
|
|
81
|
+
}
|
|
82
|
+
if (!fs.existsSync(sdkManagerPath)) {
|
|
83
|
+
throw new Error(`Could not find sdkmanager at: ${sdkManagerPath}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
this.log.info('Installing Build Tools');
|
|
87
|
+
await util.execInteractive(sdkManagerPath, ['--install',
|
|
88
|
+
`"build-tools;${exports.BUILD_TOOLS_VERSION}"`,
|
|
89
|
+
// setting ANDROID_HOME via this.getEnv() should be enough, but version 6200805 of the
|
|
90
|
+
// the Android Command Line tools don't work properly if sdk_root is not set.
|
|
91
|
+
`--sdk_root=${sdkRootEscapeChar}${this.getAndroidHome()}${sdkRootEscapeChar}`], env);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Verifies if the build-tools are installed on the Android SDK.
|
|
95
|
+
*/
|
|
96
|
+
async checkBuildTools() {
|
|
97
|
+
const buildToolsPath = this.pathJoin(this.getAndroidHome(), '/build-tools/', exports.BUILD_TOOLS_VERSION);
|
|
98
|
+
return fs.existsSync(buildToolsPath);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns the path to the Android SDK.
|
|
102
|
+
* @returns {string} the path to the Android SDK.
|
|
103
|
+
*/
|
|
104
|
+
getAndroidHome() {
|
|
105
|
+
return this.pathJoin(this.config.androidSdkPath, '/');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates a Node Process with the correct ANDROID_HOME information
|
|
109
|
+
* @returns {NodeJS.ProcessEnv} the env with ANDROID_HOME set
|
|
110
|
+
*/
|
|
111
|
+
getEnv() {
|
|
112
|
+
const env = this.jdkHelper.getEnv();
|
|
113
|
+
env['ANDROID_HOME'] = this.getAndroidHome();
|
|
114
|
+
return env;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Invokes the zipalign tool from the Android SDK with the following flags:
|
|
118
|
+
* -f : overwrite existing outfile.zip.
|
|
119
|
+
* -v : verbose output.
|
|
120
|
+
* -p 4 : align all libraries to the 32-bit page boundary.
|
|
121
|
+
* More information on zipalign can be found here:
|
|
122
|
+
* https://developer.android.com/studio/command-line/zipalign
|
|
123
|
+
* @param {string} input path to the input file.
|
|
124
|
+
* @param {string} output path to the output file.
|
|
125
|
+
*/
|
|
126
|
+
async zipalign(input, output) {
|
|
127
|
+
const env = this.getEnv();
|
|
128
|
+
const zipalignCmd = [
|
|
129
|
+
`"${this.pathJoin(this.getAndroidHome(), `/build-tools/${exports.BUILD_TOOLS_VERSION}/zipalign`)}"`,
|
|
130
|
+
'-v -f -p 4',
|
|
131
|
+
input,
|
|
132
|
+
output,
|
|
133
|
+
];
|
|
134
|
+
await util.execute(zipalignCmd, env);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Invokes the zipalign tool from the Android SDK with the following flags:
|
|
138
|
+
* -c : confirm the alignment of the given file.
|
|
139
|
+
* -v : verbose output.
|
|
140
|
+
* -p 4 : align all libraries to the 32-bit page boundary.
|
|
141
|
+
* More information on zipalign can be found here:
|
|
142
|
+
* https://developer.android.com/studio/command-line/zipalign
|
|
143
|
+
* @param {string} input path to the input file.
|
|
144
|
+
*/
|
|
145
|
+
async zipalignOnlyVerification(input) {
|
|
146
|
+
const env = this.getEnv();
|
|
147
|
+
const zipalignCmd = [
|
|
148
|
+
`"${this.pathJoin(this.getAndroidHome(), `/build-tools/${exports.BUILD_TOOLS_VERSION}/zipalign`)}"`,
|
|
149
|
+
'-v -c -p 4',
|
|
150
|
+
input,
|
|
151
|
+
];
|
|
152
|
+
await util.execute(zipalignCmd, env);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Signs an Android APK, with they keystore
|
|
156
|
+
* @param {string} keystore path to the keystore
|
|
157
|
+
* @param {string} ksPass keystore password
|
|
158
|
+
* @param {string} alias key alias
|
|
159
|
+
* @param {string} keyPass key password
|
|
160
|
+
* @param {string} input path to the input APK file
|
|
161
|
+
* @param {string} output path where the signed APK will be generated
|
|
162
|
+
*/
|
|
163
|
+
async apksigner(keystore, ksPass, alias, keyPass, input, output) {
|
|
164
|
+
const env = this.getEnv();
|
|
165
|
+
const apkSignerParams = [
|
|
166
|
+
'sign',
|
|
167
|
+
'--ks', keystore,
|
|
168
|
+
'--ks-key-alias', alias,
|
|
169
|
+
'--ks-pass', `pass:${ksPass}`,
|
|
170
|
+
'--key-pass', `pass:${keyPass}`,
|
|
171
|
+
'--out', output,
|
|
172
|
+
input,
|
|
173
|
+
];
|
|
174
|
+
// This is a workaround for https://issuetracker.google.com/issues/150888434, where
|
|
175
|
+
// find_java.bat is unable to find the java command on Windows.
|
|
176
|
+
// We run apksigner.jar directly instead of invoking the bat.
|
|
177
|
+
if (this.process.platform === 'win32') {
|
|
178
|
+
const javaCmd = [
|
|
179
|
+
'-Xmx1024M',
|
|
180
|
+
'-Xss1m',
|
|
181
|
+
'-jar',
|
|
182
|
+
this.pathJoin(this.getAndroidHome(), `/build-tools/${exports.BUILD_TOOLS_VERSION}/lib/apksigner.jar`),
|
|
183
|
+
];
|
|
184
|
+
javaCmd.push(...apkSignerParams);
|
|
185
|
+
await this.jdkHelper.runJava(javaCmd);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const apksignerCmd = this.pathJoin(this.getAndroidHome(), `/build-tools/${exports.BUILD_TOOLS_VERSION}/apksigner`);
|
|
189
|
+
await util.executeFile(apksignerCmd, apkSignerParams, env);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Installs an APK on an a device connected to the computer.
|
|
193
|
+
* @param apkFilePath the path to the APK to be installed
|
|
194
|
+
*/
|
|
195
|
+
async install(apkFilePath, passthroughArgs = []) {
|
|
196
|
+
if (!fs.existsSync(apkFilePath)) {
|
|
197
|
+
throw new Error(`Could not find APK file at ${apkFilePath}`);
|
|
198
|
+
}
|
|
199
|
+
const env = this.getEnv();
|
|
200
|
+
const installCmd = [
|
|
201
|
+
`"${this.pathJoin(this.getAndroidHome(), '/platform-tools/adb')}"`,
|
|
202
|
+
'install',
|
|
203
|
+
'-r',
|
|
204
|
+
...passthroughArgs,
|
|
205
|
+
apkFilePath,
|
|
206
|
+
];
|
|
207
|
+
await util.execute(installCmd, env, this.log);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Checks if `sdkPath` is valid.
|
|
211
|
+
* @param {string} sdkPath the path to the sdk.
|
|
212
|
+
*/
|
|
213
|
+
static async validatePath(sdkPath) {
|
|
214
|
+
const toolsPath = path.join(sdkPath, 'tools');
|
|
215
|
+
const binPath = path.join(sdkPath, 'bin');
|
|
216
|
+
// Checks if the path provided is valid. Older versions of the the Android SDK add the
|
|
217
|
+
// initial files inside the `tools` folder. Version `6858069` and above add it directly
|
|
218
|
+
// to the `bin` folder.
|
|
219
|
+
if (!fs.existsSync(sdkPath) || (!fs.existsSync(toolsPath)) && !fs.existsSync(binPath)) {
|
|
220
|
+
return Result_1.Result.error(new ValidatePathError_1.ValidatePathError('The provided androidSdk isn\'t correct.', 'PathIsNotCorrect'));
|
|
221
|
+
}
|
|
222
|
+
;
|
|
223
|
+
return Result_1.Result.ok(sdkPath);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.AndroidSdkTools = AndroidSdkTools;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare type ErrorCode = 'PathIsNotCorrect' | 'PathIsNotSupported';
|
|
2
|
+
/**
|
|
3
|
+
* Extends Error type to have an error code in addition to the Error's message.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ValidatePathError extends Error {
|
|
6
|
+
private errorCode;
|
|
7
|
+
constructor(message: string, errorCode: ErrorCode);
|
|
8
|
+
getErrorCode(): ErrorCode;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidatePathError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Extends Error type to have an error code in addition to the Error's message.
|
|
6
|
+
*/
|
|
7
|
+
class ValidatePathError extends Error {
|
|
8
|
+
constructor(message, errorCode) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.errorCode = errorCode;
|
|
11
|
+
}
|
|
12
|
+
getErrorCode() {
|
|
13
|
+
return this.errorCode;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.ValidatePathError = ValidatePathError;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AppsFlyerFeature = void 0;
|
|
19
|
+
const EmptyFeature_1 = require("./EmptyFeature");
|
|
20
|
+
class AppsFlyerFeature extends EmptyFeature_1.EmptyFeature {
|
|
21
|
+
constructor(config) {
|
|
22
|
+
super('appsFlyer');
|
|
23
|
+
// Setup build.gradle.
|
|
24
|
+
this.buildGradle.repositories.push('mavenCentral()');
|
|
25
|
+
this.buildGradle.dependencies.push('com.appsflyer:af-android-sdk:5.4.0');
|
|
26
|
+
// Setup the Android Manifest.
|
|
27
|
+
this.androidManifest.permissions.push('android.permission.INTERNET', 'android.permission.ACCESS_NETWORK_STATE', 'android.permission.ACCESS_WIFI_STATE',
|
|
28
|
+
// TODO(andreban): this may be optional. Check and remove if that's confirmed.
|
|
29
|
+
'android.permission.READ_PHONE_STATE');
|
|
30
|
+
this.androidManifest.components.push(`<receiver
|
|
31
|
+
android:name="com.appsflyer.SingleInstallBroadcastReceiver"
|
|
32
|
+
android:exported="true">
|
|
33
|
+
<intent-filter>
|
|
34
|
+
<action android:name="com.android.vending.INSTALL_REFERRER" />
|
|
35
|
+
</intent-filter>
|
|
36
|
+
</receiver>`);
|
|
37
|
+
// Setup the Application class.
|
|
38
|
+
this.applicationClass.imports.push('java.util.Map', 'com.appsflyer.AppsFlyerLib', 'com.appsflyer.AppsFlyerConversionListener');
|
|
39
|
+
this.applicationClass.variables.push(`private static final String AF_DEV_KEY = "${config.appsFlyerId}";`);
|
|
40
|
+
this.applicationClass.onCreate =
|
|
41
|
+
`AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() {
|
|
42
|
+
@Override
|
|
43
|
+
public void onConversionDataSuccess(Map<String, Object> conversionData) {
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
public void onConversionDataFail(String errorMessage) {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Override
|
|
51
|
+
public void onAppOpenAttribution(Map<String, String> attributionData) {
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Override
|
|
55
|
+
public void onAttributionFailure(String errorMessage) {
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionListener, this);
|
|
59
|
+
AppsFlyerLib.getInstance().startTracking(this);`;
|
|
60
|
+
// Setup the LauncherActivity.
|
|
61
|
+
this.launcherActivity.imports.push('com.appsflyer.AppsFlyerLib');
|
|
62
|
+
this.launcherActivity.launchUrl =
|
|
63
|
+
`String appsFlyerId = AppsFlyerLib.getInstance().getAppsFlyerUID(this);
|
|
64
|
+
uri = uri
|
|
65
|
+
.buildUpon()
|
|
66
|
+
.appendQueryParameter("appsflyer_id", appsFlyerId)
|
|
67
|
+
.build();`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.AppsFlyerFeature = AppsFlyerFeature;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Feature } from './Feature';
|
|
2
|
+
export declare class EmptyFeature implements Feature {
|
|
3
|
+
name: string;
|
|
4
|
+
buildGradle: {
|
|
5
|
+
repositories: string[];
|
|
6
|
+
dependencies: string[];
|
|
7
|
+
};
|
|
8
|
+
androidManifest: {
|
|
9
|
+
permissions: string[];
|
|
10
|
+
components: string[];
|
|
11
|
+
};
|
|
12
|
+
applicationClass: {
|
|
13
|
+
imports: string[];
|
|
14
|
+
variables: string[];
|
|
15
|
+
onCreate?: string;
|
|
16
|
+
};
|
|
17
|
+
launcherActivity: {
|
|
18
|
+
imports: string[];
|
|
19
|
+
variables: string[];
|
|
20
|
+
methods: string[];
|
|
21
|
+
launchUrl?: string;
|
|
22
|
+
};
|
|
23
|
+
delegationService: {
|
|
24
|
+
imports: string[];
|
|
25
|
+
onCreate?: string;
|
|
26
|
+
};
|
|
27
|
+
constructor(name: string);
|
|
28
|
+
}
|