expo-benchmark 0.1.0 → 0.3.0
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/android/app/build.gradle +182 -0
- package/android/app/debug.keystore +0 -0
- package/android/app/proguard-rules.pro +14 -0
- package/android/app/src/debug/AndroidManifest.xml +7 -0
- package/android/app/src/debugOptimized/AndroidManifest.xml +7 -0
- package/android/app/src/main/AndroidManifest.xml +31 -0
- package/android/app/src/main/java/com/duychip9901/expobenchmark/MainActivity.kt +61 -0
- package/android/app/src/main/java/com/duychip9901/expobenchmark/MainApplication.kt +56 -0
- package/android/app/src/main/res/drawable/ic_launcher_background.xml +6 -0
- package/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/android/app/src/main/res/drawable-hdpi/splashscreen_logo.png +0 -0
- package/android/app/src/main/res/drawable-mdpi/splashscreen_logo.png +0 -0
- package/android/app/src/main/res/drawable-xhdpi/splashscreen_logo.png +0 -0
- package/android/app/src/main/res/drawable-xxhdpi/splashscreen_logo.png +0 -0
- package/android/app/src/main/res/drawable-xxxhdpi/splashscreen_logo.png +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/android/app/src/main/res/values/colors.xml +5 -0
- package/android/app/src/main/res/values/strings.xml +3 -0
- package/android/app/src/main/res/values/styles.xml +11 -0
- package/android/app/src/main/res/values-night/colors.xml +1 -0
- package/android/build.gradle +4 -4
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +65 -0
- package/android/gradlew +251 -0
- package/android/gradlew.bat +94 -0
- package/android/settings.gradle +39 -0
- package/android/src/main/java/expo/modules/benchmark/ExpoBenchmarkModule.kt +75 -52
- package/app.json +5 -0
- package/package.json +6 -3
- package/android/src/main/AndroidManifest.xml +0 -2
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
apply plugin: "com.android.application"
|
|
2
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
3
|
+
apply plugin: "com.facebook.react"
|
|
4
|
+
|
|
5
|
+
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This is the configuration block to customize your React Native Android app.
|
|
9
|
+
* By default you don't need to apply any configuration, just uncomment the lines you need.
|
|
10
|
+
*/
|
|
11
|
+
react {
|
|
12
|
+
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
|
|
13
|
+
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
|
|
14
|
+
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
|
|
15
|
+
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
|
|
16
|
+
|
|
17
|
+
enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
|
|
18
|
+
// Use Expo CLI to bundle the app, this ensures the Metro config
|
|
19
|
+
// works correctly with Expo projects.
|
|
20
|
+
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
|
|
21
|
+
bundleCommand = "export:embed"
|
|
22
|
+
|
|
23
|
+
/* Folders */
|
|
24
|
+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
|
|
25
|
+
// root = file("../../")
|
|
26
|
+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
|
|
27
|
+
// reactNativeDir = file("../../node_modules/react-native")
|
|
28
|
+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
|
|
29
|
+
// codegenDir = file("../../node_modules/@react-native/codegen")
|
|
30
|
+
|
|
31
|
+
/* Variants */
|
|
32
|
+
// The list of variants to that are debuggable. For those we're going to
|
|
33
|
+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
|
|
34
|
+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
|
|
35
|
+
// debuggableVariants = ["liteDebug", "prodDebug"]
|
|
36
|
+
|
|
37
|
+
/* Bundling */
|
|
38
|
+
// A list containing the node command and its flags. Default is just 'node'.
|
|
39
|
+
// nodeExecutableAndArgs = ["node"]
|
|
40
|
+
|
|
41
|
+
//
|
|
42
|
+
// The path to the CLI configuration file. Default is empty.
|
|
43
|
+
// bundleConfig = file(../rn-cli.config.js)
|
|
44
|
+
//
|
|
45
|
+
// The name of the generated asset file containing your JS bundle
|
|
46
|
+
// bundleAssetName = "MyApplication.android.bundle"
|
|
47
|
+
//
|
|
48
|
+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
|
|
49
|
+
// entryFile = file("../js/MyApplication.android.js")
|
|
50
|
+
//
|
|
51
|
+
// A list of extra flags to pass to the 'bundle' commands.
|
|
52
|
+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
|
|
53
|
+
// extraPackagerArgs = []
|
|
54
|
+
|
|
55
|
+
/* Hermes Commands */
|
|
56
|
+
// The hermes compiler command to run. By default it is 'hermesc'
|
|
57
|
+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
|
|
58
|
+
//
|
|
59
|
+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
|
|
60
|
+
// hermesFlags = ["-O", "-output-source-map"]
|
|
61
|
+
|
|
62
|
+
/* Autolinking */
|
|
63
|
+
autolinkLibrariesWithApp()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Set this to true in release builds to optimize the app using [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization).
|
|
68
|
+
*/
|
|
69
|
+
def enableMinifyInReleaseBuilds = (findProperty('android.enableMinifyInReleaseBuilds') ?: false).toBoolean()
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The preferred build flavor of JavaScriptCore (JSC)
|
|
73
|
+
*
|
|
74
|
+
* For example, to use the international variant, you can use:
|
|
75
|
+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
|
|
76
|
+
*
|
|
77
|
+
* The international variant includes ICU i18n library and necessary data
|
|
78
|
+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
|
|
79
|
+
* give correct results when using with locales other than en-US. Note that
|
|
80
|
+
* this variant is about 6MiB larger per architecture than default.
|
|
81
|
+
*/
|
|
82
|
+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
|
|
83
|
+
|
|
84
|
+
android {
|
|
85
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
86
|
+
|
|
87
|
+
buildToolsVersion rootProject.ext.buildToolsVersion
|
|
88
|
+
compileSdk rootProject.ext.compileSdkVersion
|
|
89
|
+
|
|
90
|
+
namespace 'com.duychip9901.expobenchmark'
|
|
91
|
+
defaultConfig {
|
|
92
|
+
applicationId 'com.duychip9901.expobenchmark'
|
|
93
|
+
minSdkVersion rootProject.ext.minSdkVersion
|
|
94
|
+
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
95
|
+
versionCode 1
|
|
96
|
+
versionName "0.2.0"
|
|
97
|
+
|
|
98
|
+
buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
|
|
99
|
+
}
|
|
100
|
+
signingConfigs {
|
|
101
|
+
debug {
|
|
102
|
+
storeFile file('debug.keystore')
|
|
103
|
+
storePassword 'android'
|
|
104
|
+
keyAlias 'androiddebugkey'
|
|
105
|
+
keyPassword 'android'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
buildTypes {
|
|
109
|
+
debug {
|
|
110
|
+
signingConfig signingConfigs.debug
|
|
111
|
+
}
|
|
112
|
+
release {
|
|
113
|
+
// Caution! In production, you need to generate your own keystore file.
|
|
114
|
+
// see https://reactnative.dev/docs/signed-apk-android.
|
|
115
|
+
signingConfig signingConfigs.debug
|
|
116
|
+
def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false'
|
|
117
|
+
shrinkResources enableShrinkResources.toBoolean()
|
|
118
|
+
minifyEnabled enableMinifyInReleaseBuilds
|
|
119
|
+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
|
120
|
+
def enablePngCrunchInRelease = findProperty('android.enablePngCrunchInReleaseBuilds') ?: 'true'
|
|
121
|
+
crunchPngs enablePngCrunchInRelease.toBoolean()
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
packagingOptions {
|
|
125
|
+
jniLibs {
|
|
126
|
+
def enableLegacyPackaging = findProperty('expo.useLegacyPackaging') ?: 'false'
|
|
127
|
+
useLegacyPackaging enableLegacyPackaging.toBoolean()
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
androidResources {
|
|
131
|
+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Apply static values from `gradle.properties` to the `android.packagingOptions`
|
|
136
|
+
// Accepts values in comma delimited lists, example:
|
|
137
|
+
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
|
|
138
|
+
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
|
|
139
|
+
// Split option: 'foo,bar' -> ['foo', 'bar']
|
|
140
|
+
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
|
|
141
|
+
// Trim all elements in place.
|
|
142
|
+
for (i in 0..<options.size()) options[i] = options[i].trim();
|
|
143
|
+
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
|
|
144
|
+
options -= ""
|
|
145
|
+
|
|
146
|
+
if (options.length > 0) {
|
|
147
|
+
println "android.packagingOptions.$prop += $options ($options.length)"
|
|
148
|
+
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
|
|
149
|
+
options.each {
|
|
150
|
+
android.packagingOptions[prop] += it
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
dependencies {
|
|
156
|
+
// The version of react-native is set by the React Native Gradle Plugin
|
|
157
|
+
implementation("com.facebook.react:react-android")
|
|
158
|
+
|
|
159
|
+
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
|
|
160
|
+
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
|
|
161
|
+
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
|
|
162
|
+
|
|
163
|
+
if (isGifEnabled) {
|
|
164
|
+
// For animated gif support
|
|
165
|
+
implementation("com.facebook.fresco:animated-gif:${expoLibs.versions.fresco.get()}")
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (isWebpEnabled) {
|
|
169
|
+
// For webp support
|
|
170
|
+
implementation("com.facebook.fresco:webpsupport:${expoLibs.versions.fresco.get()}")
|
|
171
|
+
if (isWebpAnimatedEnabled) {
|
|
172
|
+
// Animated webp support
|
|
173
|
+
implementation("com.facebook.fresco:animated-webp:${expoLibs.versions.fresco.get()}")
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (hermesEnabled.toBoolean()) {
|
|
178
|
+
implementation("com.facebook.react:hermes-android")
|
|
179
|
+
} else {
|
|
180
|
+
implementation jscFlavor
|
|
181
|
+
}
|
|
182
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Add project specific ProGuard rules here.
|
|
2
|
+
# By default, the flags in this file are appended to flags specified
|
|
3
|
+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
|
|
4
|
+
# You can edit the include path and order by changing the proguardFiles
|
|
5
|
+
# directive in build.gradle.
|
|
6
|
+
#
|
|
7
|
+
# For more details, see
|
|
8
|
+
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
9
|
+
|
|
10
|
+
# react-native-reanimated
|
|
11
|
+
-keep class com.swmansion.reanimated.** { *; }
|
|
12
|
+
-keep class com.facebook.react.turbomodule.** { *; }
|
|
13
|
+
|
|
14
|
+
# Add any project specific keep options here:
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
xmlns:tools="http://schemas.android.com/tools">
|
|
3
|
+
|
|
4
|
+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
|
5
|
+
|
|
6
|
+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" tools:replace="android:usesCleartextTraffic" />
|
|
7
|
+
</manifest>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
xmlns:tools="http://schemas.android.com/tools">
|
|
3
|
+
|
|
4
|
+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
|
5
|
+
|
|
6
|
+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" tools:replace="android:usesCleartextTraffic" />
|
|
7
|
+
</manifest>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<uses-permission android:name="android.permission.INTERNET"/>
|
|
3
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
4
|
+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
|
5
|
+
<uses-permission android:name="android.permission.VIBRATE"/>
|
|
6
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
7
|
+
<queries>
|
|
8
|
+
<intent>
|
|
9
|
+
<action android:name="android.intent.action.VIEW"/>
|
|
10
|
+
<category android:name="android.intent.category.BROWSABLE"/>
|
|
11
|
+
<data android:scheme="https"/>
|
|
12
|
+
</intent>
|
|
13
|
+
</queries>
|
|
14
|
+
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true" android:enableOnBackInvokedCallback="false">
|
|
15
|
+
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
|
|
16
|
+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
|
|
17
|
+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
|
|
18
|
+
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true">
|
|
19
|
+
<intent-filter>
|
|
20
|
+
<action android:name="android.intent.action.MAIN"/>
|
|
21
|
+
<category android:name="android.intent.category.LAUNCHER"/>
|
|
22
|
+
</intent-filter>
|
|
23
|
+
<intent-filter>
|
|
24
|
+
<action android:name="android.intent.action.VIEW"/>
|
|
25
|
+
<category android:name="android.intent.category.DEFAULT"/>
|
|
26
|
+
<category android:name="android.intent.category.BROWSABLE"/>
|
|
27
|
+
<data android:scheme="exp+expo-benchmark"/>
|
|
28
|
+
</intent-filter>
|
|
29
|
+
</activity>
|
|
30
|
+
</application>
|
|
31
|
+
</manifest>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package com.duychip9901.expobenchmark
|
|
2
|
+
|
|
3
|
+
import android.os.Build
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.ReactActivity
|
|
7
|
+
import com.facebook.react.ReactActivityDelegate
|
|
8
|
+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
|
9
|
+
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
|
10
|
+
|
|
11
|
+
import expo.modules.ReactActivityDelegateWrapper
|
|
12
|
+
|
|
13
|
+
class MainActivity : ReactActivity() {
|
|
14
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
15
|
+
// Set the theme to AppTheme BEFORE onCreate to support
|
|
16
|
+
// coloring the background, status bar, and navigation bar.
|
|
17
|
+
// This is required for expo-splash-screen.
|
|
18
|
+
setTheme(R.style.AppTheme);
|
|
19
|
+
super.onCreate(null)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
24
|
+
* rendering of the component.
|
|
25
|
+
*/
|
|
26
|
+
override fun getMainComponentName(): String = "main"
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
|
|
30
|
+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
|
31
|
+
*/
|
|
32
|
+
override fun createReactActivityDelegate(): ReactActivityDelegate {
|
|
33
|
+
return ReactActivityDelegateWrapper(
|
|
34
|
+
this,
|
|
35
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
|
|
36
|
+
object : DefaultReactActivityDelegate(
|
|
37
|
+
this,
|
|
38
|
+
mainComponentName,
|
|
39
|
+
fabricEnabled
|
|
40
|
+
){})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Align the back button behavior with Android S
|
|
45
|
+
* where moving root activities to background instead of finishing activities.
|
|
46
|
+
* @see <a href="https://developer.android.com/reference/android/app/Activity#onBackPressed()">onBackPressed</a>
|
|
47
|
+
*/
|
|
48
|
+
override fun invokeDefaultOnBackPressed() {
|
|
49
|
+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
|
50
|
+
if (!moveTaskToBack(false)) {
|
|
51
|
+
// For non-root activities, use the default implementation to finish them.
|
|
52
|
+
super.invokeDefaultOnBackPressed()
|
|
53
|
+
}
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Use the default back button implementation on Android S
|
|
58
|
+
// because it's doing more than [Activity.moveTaskToBack] in fact.
|
|
59
|
+
super.invokeDefaultOnBackPressed()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package com.duychip9901.expobenchmark
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import android.content.res.Configuration
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.PackageList
|
|
7
|
+
import com.facebook.react.ReactApplication
|
|
8
|
+
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
|
|
9
|
+
import com.facebook.react.ReactNativeHost
|
|
10
|
+
import com.facebook.react.ReactPackage
|
|
11
|
+
import com.facebook.react.ReactHost
|
|
12
|
+
import com.facebook.react.common.ReleaseLevel
|
|
13
|
+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
|
|
14
|
+
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
15
|
+
|
|
16
|
+
import expo.modules.ApplicationLifecycleDispatcher
|
|
17
|
+
import expo.modules.ReactNativeHostWrapper
|
|
18
|
+
|
|
19
|
+
class MainApplication : Application(), ReactApplication {
|
|
20
|
+
|
|
21
|
+
override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper(
|
|
22
|
+
this,
|
|
23
|
+
object : DefaultReactNativeHost(this) {
|
|
24
|
+
override fun getPackages(): List<ReactPackage> =
|
|
25
|
+
PackageList(this).packages.apply {
|
|
26
|
+
// Packages that cannot be autolinked yet can be added manually here, for example:
|
|
27
|
+
// add(MyReactNativePackage())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
|
|
31
|
+
|
|
32
|
+
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
|
33
|
+
|
|
34
|
+
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
override val reactHost: ReactHost
|
|
39
|
+
get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost)
|
|
40
|
+
|
|
41
|
+
override fun onCreate() {
|
|
42
|
+
super.onCreate()
|
|
43
|
+
DefaultNewArchitectureEntryPoint.releaseLevel = try {
|
|
44
|
+
ReleaseLevel.valueOf(BuildConfig.REACT_NATIVE_RELEASE_LEVEL.uppercase())
|
|
45
|
+
} catch (e: IllegalArgumentException) {
|
|
46
|
+
ReleaseLevel.STABLE
|
|
47
|
+
}
|
|
48
|
+
loadReactNative(this)
|
|
49
|
+
ApplicationLifecycleDispatcher.onApplicationCreate(this)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override fun onConfigurationChanged(newConfig: Configuration) {
|
|
53
|
+
super.onConfigurationChanged(newConfig)
|
|
54
|
+
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Copyright (C) 2014 The Android Open Source Project
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
|
17
|
+
android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
|
|
18
|
+
android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
|
|
19
|
+
android:insetTop="@dimen/abc_edit_text_inset_top_material"
|
|
20
|
+
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
<selector>
|
|
24
|
+
<!--
|
|
25
|
+
This file is a copy of abc_edit_text_material (https://bit.ly/3k8fX7I).
|
|
26
|
+
The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
|
|
27
|
+
NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
|
|
28
|
+
|
|
29
|
+
<item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
|
|
30
|
+
|
|
31
|
+
For more info, see https://bit.ly/3CdLStv (react-native/pull/29452) and https://bit.ly/3nxOMoR.
|
|
32
|
+
-->
|
|
33
|
+
<item android:state_enabled="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
|
|
34
|
+
<item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
|
|
35
|
+
</selector>
|
|
36
|
+
|
|
37
|
+
</inset>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<resources xmlns:tools="http://schemas.android.com/tools">
|
|
2
|
+
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
|
3
|
+
<item name="android:enforceNavigationBarContrast" tools:targetApi="29">true</item>
|
|
4
|
+
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
|
|
5
|
+
<item name="colorPrimary">@color/colorPrimary</item>
|
|
6
|
+
<item name="android:statusBarColor">#ffffff</item>
|
|
7
|
+
</style>
|
|
8
|
+
<style name="Theme.App.SplashScreen" parent="AppTheme">
|
|
9
|
+
<item name="android:windowBackground">@drawable/ic_launcher_background</item>
|
|
10
|
+
</style>
|
|
11
|
+
</resources>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<resources/>
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'expo.modules.benchmark'
|
|
4
|
-
version = '0.
|
|
4
|
+
version = '0.3.0'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -35,7 +35,7 @@ android {
|
|
|
35
35
|
namespace "expo.modules.benchmark"
|
|
36
36
|
defaultConfig {
|
|
37
37
|
versionCode 1
|
|
38
|
-
versionName "0.
|
|
38
|
+
versionName "0.2.0"
|
|
39
39
|
}
|
|
40
40
|
lintOptions {
|
|
41
41
|
abortOnError false
|
|
@@ -43,6 +43,6 @@ android {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
dependencies {
|
|
46
|
-
implementation
|
|
47
|
-
implementation
|
|
46
|
+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
|
|
47
|
+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
|
|
48
48
|
}
|
|
Binary file
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Project-wide Gradle settings.
|
|
2
|
+
|
|
3
|
+
# IDE (e.g. Android Studio) users:
|
|
4
|
+
# Gradle settings configured through the IDE *will override*
|
|
5
|
+
# any settings specified in this file.
|
|
6
|
+
|
|
7
|
+
# For more details on how to configure your build environment visit
|
|
8
|
+
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
|
9
|
+
|
|
10
|
+
# Specifies the JVM arguments used for the daemon process.
|
|
11
|
+
# The setting is particularly useful for tweaking memory settings.
|
|
12
|
+
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
|
|
13
|
+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
|
|
14
|
+
|
|
15
|
+
# When configured, Gradle will run in incubating parallel mode.
|
|
16
|
+
# This option should only be used with decoupled projects. More details, visit
|
|
17
|
+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
|
18
|
+
org.gradle.parallel=true
|
|
19
|
+
|
|
20
|
+
# AndroidX package structure to make it clearer which packages are bundled with the
|
|
21
|
+
# Android operating system, and which are packaged with your app's APK
|
|
22
|
+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
|
23
|
+
android.useAndroidX=true
|
|
24
|
+
|
|
25
|
+
# Enable AAPT2 PNG crunching
|
|
26
|
+
android.enablePngCrunchInReleaseBuilds=true
|
|
27
|
+
|
|
28
|
+
# Use this property to specify which architecture you want to build.
|
|
29
|
+
# You can also override it from the CLI using
|
|
30
|
+
# ./gradlew <task> -PreactNativeArchitectures=x86_64
|
|
31
|
+
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
|
|
32
|
+
|
|
33
|
+
# Use this property to enable support to the new architecture.
|
|
34
|
+
# This will allow you to use TurboModules and the Fabric render in
|
|
35
|
+
# your application. You should enable this flag either if you want
|
|
36
|
+
# to write custom TurboModules/Fabric components OR use libraries that
|
|
37
|
+
# are providing them.
|
|
38
|
+
newArchEnabled=true
|
|
39
|
+
|
|
40
|
+
# Use this property to enable or disable the Hermes JS engine.
|
|
41
|
+
# If set to false, you will be using JSC instead.
|
|
42
|
+
hermesEnabled=true
|
|
43
|
+
|
|
44
|
+
# Use this property to enable edge-to-edge display support.
|
|
45
|
+
# This allows your app to draw behind system bars for an immersive UI.
|
|
46
|
+
# Note: Only works with ReactActivity and should not be used with custom Activity.
|
|
47
|
+
edgeToEdgeEnabled=true
|
|
48
|
+
|
|
49
|
+
# Enable GIF support in React Native images (~200 B increase)
|
|
50
|
+
expo.gif.enabled=true
|
|
51
|
+
# Enable webp support in React Native images (~85 KB increase)
|
|
52
|
+
expo.webp.enabled=true
|
|
53
|
+
# Enable animated webp support (~3.4 MB increase)
|
|
54
|
+
# Disabled by default because iOS doesn't support animated webp
|
|
55
|
+
expo.webp.animated=false
|
|
56
|
+
|
|
57
|
+
# Enable network inspector
|
|
58
|
+
EX_DEV_CLIENT_NETWORK_INSPECTOR=true
|
|
59
|
+
|
|
60
|
+
# Use legacy packaging to compress native libraries in the resulting APK.
|
|
61
|
+
expo.useLegacyPackaging=false
|
|
62
|
+
|
|
63
|
+
# Specifies whether the app is configured to use edge-to-edge via the app config or plugin
|
|
64
|
+
# WARNING: This property has been deprecated and will be removed in Expo SDK 55. Use `edgeToEdgeEnabled` or `react.edgeToEdgeEnabled` to determine whether the project is using edge-to-edge.
|
|
65
|
+
expo.edgeToEdgeEnabled=true
|
package/android/gradlew
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Copyright © 2015-2021 the original authors.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
##############################################################################
|
|
22
|
+
#
|
|
23
|
+
# Gradle start up script for POSIX generated by Gradle.
|
|
24
|
+
#
|
|
25
|
+
# Important for running:
|
|
26
|
+
#
|
|
27
|
+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
28
|
+
# noncompliant, but you have some other compliant shell such as ksh or
|
|
29
|
+
# bash, then to run this script, type that shell name before the whole
|
|
30
|
+
# command line, like:
|
|
31
|
+
#
|
|
32
|
+
# ksh Gradle
|
|
33
|
+
#
|
|
34
|
+
# Busybox and similar reduced shells will NOT work, because this script
|
|
35
|
+
# requires all of these POSIX shell features:
|
|
36
|
+
# * functions;
|
|
37
|
+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
38
|
+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
39
|
+
# * compound commands having a testable exit status, especially «case»;
|
|
40
|
+
# * various built-in commands including «command», «set», and «ulimit».
|
|
41
|
+
#
|
|
42
|
+
# Important for patching:
|
|
43
|
+
#
|
|
44
|
+
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
45
|
+
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
46
|
+
#
|
|
47
|
+
# The "traditional" practice of packing multiple parameters into a
|
|
48
|
+
# space-separated string is a well documented source of bugs and security
|
|
49
|
+
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
50
|
+
# options in "$@", and eventually passing that to Java.
|
|
51
|
+
#
|
|
52
|
+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
53
|
+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
54
|
+
# see the in-line comments for details.
|
|
55
|
+
#
|
|
56
|
+
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
57
|
+
# Darwin, MinGW, and NonStop.
|
|
58
|
+
#
|
|
59
|
+
# (3) This script is generated from the Groovy template
|
|
60
|
+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
61
|
+
# within the Gradle project.
|
|
62
|
+
#
|
|
63
|
+
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
64
|
+
#
|
|
65
|
+
##############################################################################
|
|
66
|
+
|
|
67
|
+
# Attempt to set APP_HOME
|
|
68
|
+
|
|
69
|
+
# Resolve links: $0 may be a link
|
|
70
|
+
app_path=$0
|
|
71
|
+
|
|
72
|
+
# Need this for daisy-chained symlinks.
|
|
73
|
+
while
|
|
74
|
+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
75
|
+
[ -h "$app_path" ]
|
|
76
|
+
do
|
|
77
|
+
ls=$( ls -ld "$app_path" )
|
|
78
|
+
link=${ls#*' -> '}
|
|
79
|
+
case $link in #(
|
|
80
|
+
/*) app_path=$link ;; #(
|
|
81
|
+
*) app_path=$APP_HOME$link ;;
|
|
82
|
+
esac
|
|
83
|
+
done
|
|
84
|
+
|
|
85
|
+
# This is normally unused
|
|
86
|
+
# shellcheck disable=SC2034
|
|
87
|
+
APP_BASE_NAME=${0##*/}
|
|
88
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
89
|
+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
|
90
|
+
|
|
91
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
92
|
+
MAX_FD=maximum
|
|
93
|
+
|
|
94
|
+
warn () {
|
|
95
|
+
echo "$*"
|
|
96
|
+
} >&2
|
|
97
|
+
|
|
98
|
+
die () {
|
|
99
|
+
echo
|
|
100
|
+
echo "$*"
|
|
101
|
+
echo
|
|
102
|
+
exit 1
|
|
103
|
+
} >&2
|
|
104
|
+
|
|
105
|
+
# OS specific support (must be 'true' or 'false').
|
|
106
|
+
cygwin=false
|
|
107
|
+
msys=false
|
|
108
|
+
darwin=false
|
|
109
|
+
nonstop=false
|
|
110
|
+
case "$( uname )" in #(
|
|
111
|
+
CYGWIN* ) cygwin=true ;; #(
|
|
112
|
+
Darwin* ) darwin=true ;; #(
|
|
113
|
+
MSYS* | MINGW* ) msys=true ;; #(
|
|
114
|
+
NONSTOP* ) nonstop=true ;;
|
|
115
|
+
esac
|
|
116
|
+
|
|
117
|
+
CLASSPATH="\\\"\\\""
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# Determine the Java command to use to start the JVM.
|
|
121
|
+
if [ -n "$JAVA_HOME" ] ; then
|
|
122
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
123
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
124
|
+
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
125
|
+
else
|
|
126
|
+
JAVACMD=$JAVA_HOME/bin/java
|
|
127
|
+
fi
|
|
128
|
+
if [ ! -x "$JAVACMD" ] ; then
|
|
129
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
130
|
+
|
|
131
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
132
|
+
location of your Java installation."
|
|
133
|
+
fi
|
|
134
|
+
else
|
|
135
|
+
JAVACMD=java
|
|
136
|
+
if ! command -v java >/dev/null 2>&1
|
|
137
|
+
then
|
|
138
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
139
|
+
|
|
140
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
141
|
+
location of your Java installation."
|
|
142
|
+
fi
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
# Increase the maximum file descriptors if we can.
|
|
146
|
+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
147
|
+
case $MAX_FD in #(
|
|
148
|
+
max*)
|
|
149
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
150
|
+
# shellcheck disable=SC2039,SC3045
|
|
151
|
+
MAX_FD=$( ulimit -H -n ) ||
|
|
152
|
+
warn "Could not query maximum file descriptor limit"
|
|
153
|
+
esac
|
|
154
|
+
case $MAX_FD in #(
|
|
155
|
+
'' | soft) :;; #(
|
|
156
|
+
*)
|
|
157
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
158
|
+
# shellcheck disable=SC2039,SC3045
|
|
159
|
+
ulimit -n "$MAX_FD" ||
|
|
160
|
+
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
161
|
+
esac
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Collect all arguments for the java command, stacking in reverse order:
|
|
165
|
+
# * args from the command line
|
|
166
|
+
# * the main class name
|
|
167
|
+
# * -classpath
|
|
168
|
+
# * -D...appname settings
|
|
169
|
+
# * --module-path (only if needed)
|
|
170
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
171
|
+
|
|
172
|
+
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
173
|
+
if "$cygwin" || "$msys" ; then
|
|
174
|
+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
175
|
+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
176
|
+
|
|
177
|
+
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
178
|
+
|
|
179
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
180
|
+
for arg do
|
|
181
|
+
if
|
|
182
|
+
case $arg in #(
|
|
183
|
+
-*) false ;; # don't mess with options #(
|
|
184
|
+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
185
|
+
[ -e "$t" ] ;; #(
|
|
186
|
+
*) false ;;
|
|
187
|
+
esac
|
|
188
|
+
then
|
|
189
|
+
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
190
|
+
fi
|
|
191
|
+
# Roll the args list around exactly as many times as the number of
|
|
192
|
+
# args, so each arg winds up back in the position where it started, but
|
|
193
|
+
# possibly modified.
|
|
194
|
+
#
|
|
195
|
+
# NB: a `for` loop captures its iteration list before it begins, so
|
|
196
|
+
# changing the positional parameters here affects neither the number of
|
|
197
|
+
# iterations, nor the values presented in `arg`.
|
|
198
|
+
shift # remove old arg
|
|
199
|
+
set -- "$@" "$arg" # push replacement arg
|
|
200
|
+
done
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
205
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
206
|
+
|
|
207
|
+
# Collect all arguments for the java command:
|
|
208
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
209
|
+
# and any embedded shellness will be escaped.
|
|
210
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
211
|
+
# treated as '${Hostname}' itself on the command line.
|
|
212
|
+
|
|
213
|
+
set -- \
|
|
214
|
+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
215
|
+
-classpath "$CLASSPATH" \
|
|
216
|
+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
|
217
|
+
"$@"
|
|
218
|
+
|
|
219
|
+
# Stop when "xargs" is not available.
|
|
220
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
221
|
+
then
|
|
222
|
+
die "xargs is not available"
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# Use "xargs" to parse quoted args.
|
|
226
|
+
#
|
|
227
|
+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
228
|
+
#
|
|
229
|
+
# In Bash we could simply go:
|
|
230
|
+
#
|
|
231
|
+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
232
|
+
# set -- "${ARGS[@]}" "$@"
|
|
233
|
+
#
|
|
234
|
+
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
235
|
+
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
236
|
+
# character that might be a shell metacharacter, then use eval to reverse
|
|
237
|
+
# that process (while maintaining the separation between arguments), and wrap
|
|
238
|
+
# the whole thing up as a single "set" statement.
|
|
239
|
+
#
|
|
240
|
+
# This will of course break if any of these variables contains a newline or
|
|
241
|
+
# an unmatched quote.
|
|
242
|
+
#
|
|
243
|
+
|
|
244
|
+
eval "set -- $(
|
|
245
|
+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
246
|
+
xargs -n1 |
|
|
247
|
+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
248
|
+
tr '\n' ' '
|
|
249
|
+
)" '"$@"'
|
|
250
|
+
|
|
251
|
+
exec "$JAVACMD" "$@"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@rem
|
|
2
|
+
@rem Copyright 2015 the original author or authors.
|
|
3
|
+
@rem
|
|
4
|
+
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
@rem you may not use this file except in compliance with the License.
|
|
6
|
+
@rem You may obtain a copy of the License at
|
|
7
|
+
@rem
|
|
8
|
+
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
@rem
|
|
10
|
+
@rem Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
@rem See the License for the specific language governing permissions and
|
|
14
|
+
@rem limitations under the License.
|
|
15
|
+
@rem
|
|
16
|
+
@rem SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
@rem
|
|
18
|
+
|
|
19
|
+
@if "%DEBUG%"=="" @echo off
|
|
20
|
+
@rem ##########################################################################
|
|
21
|
+
@rem
|
|
22
|
+
@rem Gradle startup script for Windows
|
|
23
|
+
@rem
|
|
24
|
+
@rem ##########################################################################
|
|
25
|
+
|
|
26
|
+
@rem Set local scope for the variables with windows NT shell
|
|
27
|
+
if "%OS%"=="Windows_NT" setlocal
|
|
28
|
+
|
|
29
|
+
set DIRNAME=%~dp0
|
|
30
|
+
if "%DIRNAME%"=="" set DIRNAME=.
|
|
31
|
+
@rem This is normally unused
|
|
32
|
+
set APP_BASE_NAME=%~n0
|
|
33
|
+
set APP_HOME=%DIRNAME%
|
|
34
|
+
|
|
35
|
+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
36
|
+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
37
|
+
|
|
38
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
39
|
+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
40
|
+
|
|
41
|
+
@rem Find java.exe
|
|
42
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
43
|
+
|
|
44
|
+
set JAVA_EXE=java.exe
|
|
45
|
+
%JAVA_EXE% -version >NUL 2>&1
|
|
46
|
+
if %ERRORLEVEL% equ 0 goto execute
|
|
47
|
+
|
|
48
|
+
echo. 1>&2
|
|
49
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
50
|
+
echo. 1>&2
|
|
51
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
52
|
+
echo location of your Java installation. 1>&2
|
|
53
|
+
|
|
54
|
+
goto fail
|
|
55
|
+
|
|
56
|
+
:findJavaFromJavaHome
|
|
57
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
|
58
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
59
|
+
|
|
60
|
+
if exist "%JAVA_EXE%" goto execute
|
|
61
|
+
|
|
62
|
+
echo. 1>&2
|
|
63
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
64
|
+
echo. 1>&2
|
|
65
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
66
|
+
echo location of your Java installation. 1>&2
|
|
67
|
+
|
|
68
|
+
goto fail
|
|
69
|
+
|
|
70
|
+
:execute
|
|
71
|
+
@rem Setup the command line
|
|
72
|
+
|
|
73
|
+
set CLASSPATH=
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@rem Execute Gradle
|
|
77
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
|
78
|
+
|
|
79
|
+
:end
|
|
80
|
+
@rem End local scope for the variables with windows NT shell
|
|
81
|
+
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
82
|
+
|
|
83
|
+
:fail
|
|
84
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
85
|
+
rem the _cmd.exe /c_ return code!
|
|
86
|
+
set EXIT_CODE=%ERRORLEVEL%
|
|
87
|
+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
88
|
+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
89
|
+
exit /b %EXIT_CODE%
|
|
90
|
+
|
|
91
|
+
:mainEnd
|
|
92
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
93
|
+
|
|
94
|
+
:omega
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
pluginManagement {
|
|
2
|
+
def reactNativeGradlePlugin = new File(
|
|
3
|
+
providers.exec {
|
|
4
|
+
workingDir(rootDir)
|
|
5
|
+
commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })")
|
|
6
|
+
}.standardOutput.asText.get().trim()
|
|
7
|
+
).getParentFile().absolutePath
|
|
8
|
+
includeBuild(reactNativeGradlePlugin)
|
|
9
|
+
|
|
10
|
+
def expoPluginsPath = new File(
|
|
11
|
+
providers.exec {
|
|
12
|
+
workingDir(rootDir)
|
|
13
|
+
commandLine("node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })")
|
|
14
|
+
}.standardOutput.asText.get().trim(),
|
|
15
|
+
"../android/expo-gradle-plugin"
|
|
16
|
+
).absolutePath
|
|
17
|
+
includeBuild(expoPluginsPath)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
plugins {
|
|
21
|
+
id("com.facebook.react.settings")
|
|
22
|
+
id("expo-autolinking-settings")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
|
|
26
|
+
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
|
|
27
|
+
ex.autolinkLibrariesFromCommand()
|
|
28
|
+
} else {
|
|
29
|
+
ex.autolinkLibrariesFromCommand(expoAutolinking.rnConfigCommand)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
expoAutolinking.useExpoModules()
|
|
33
|
+
|
|
34
|
+
rootProject.name = 'expo-benchmark'
|
|
35
|
+
|
|
36
|
+
expoAutolinking.useExpoVersionCatalog()
|
|
37
|
+
|
|
38
|
+
include ':app'
|
|
39
|
+
includeBuild(expoAutolinking.reactNativeGradlePlugin)
|
|
@@ -2,12 +2,15 @@ package expo.modules.benchmark
|
|
|
2
2
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
-
import
|
|
5
|
+
import expo.modules.kotlin.Promise
|
|
6
6
|
import java.security.MessageDigest
|
|
7
|
+
import java.util.concurrent.Executors
|
|
7
8
|
import java.util.concurrent.atomic.AtomicLong
|
|
8
9
|
import kotlin.random.Random
|
|
9
10
|
|
|
10
11
|
class ExpoBenchmarkModule : Module() {
|
|
12
|
+
private val executor = Executors.newCachedThreadPool()
|
|
13
|
+
|
|
11
14
|
override fun definition() = ModuleDefinition {
|
|
12
15
|
Name("ExpoBenchmark")
|
|
13
16
|
|
|
@@ -20,28 +23,50 @@ class ExpoBenchmarkModule : Module() {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
// Run a configurable benchmark
|
|
23
|
-
AsyncFunction("runBenchmarkAsync") { options: Map<String, Any
|
|
26
|
+
AsyncFunction("runBenchmarkAsync") { options: Map<String, Any>?, promise: Promise ->
|
|
24
27
|
val durationSeconds = (options?.get("durationSeconds") as? Number)?.toDouble() ?: 5.0
|
|
25
28
|
val threads = (options?.get("threads") as? Number)?.toInt() ?: 1
|
|
26
29
|
val actualThreads = if (threads == 0) Runtime.getRuntime().availableProcessors() else threads
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
executor.execute {
|
|
32
|
+
try {
|
|
33
|
+
val result = runBenchmark(durationSeconds, actualThreads)
|
|
34
|
+
promise.resolve(result)
|
|
35
|
+
} catch (e: Exception) {
|
|
36
|
+
promise.reject("BENCHMARK_ERROR", e.message, e)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
// Quick single-threaded benchmark
|
|
32
|
-
AsyncFunction("runQuickBenchmarkAsync") {
|
|
33
|
-
|
|
42
|
+
AsyncFunction("runQuickBenchmarkAsync") { promise: Promise ->
|
|
43
|
+
executor.execute {
|
|
44
|
+
try {
|
|
45
|
+
val result = runBenchmark(1.0, 1)
|
|
46
|
+
promise.resolve(result)
|
|
47
|
+
} catch (e: Exception) {
|
|
48
|
+
promise.reject("BENCHMARK_ERROR", e.message, e)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
// Multi-threaded benchmark using all cores
|
|
37
|
-
AsyncFunction("runMultiThreadedBenchmarkAsync") { durationSeconds: Double
|
|
54
|
+
AsyncFunction("runMultiThreadedBenchmarkAsync") { durationSeconds: Double?, promise: Promise ->
|
|
38
55
|
val duration = durationSeconds ?: 5.0
|
|
39
56
|
val threads = Runtime.getRuntime().availableProcessors()
|
|
40
|
-
|
|
57
|
+
|
|
58
|
+
executor.execute {
|
|
59
|
+
try {
|
|
60
|
+
val result = runBenchmark(duration, threads)
|
|
61
|
+
promise.resolve(result)
|
|
62
|
+
} catch (e: Exception) {
|
|
63
|
+
promise.reject("BENCHMARK_ERROR", e.message, e)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
41
66
|
}
|
|
42
67
|
}
|
|
43
68
|
|
|
44
|
-
private
|
|
69
|
+
private fun runBenchmark(durationSeconds: Double, threads: Int): Map<String, Any> {
|
|
45
70
|
val durationMs = (durationSeconds * 1000).toLong()
|
|
46
71
|
val startTime = System.currentTimeMillis()
|
|
47
72
|
val endTime = startTime + durationMs
|
|
@@ -50,58 +75,56 @@ class ExpoBenchmarkModule : Module() {
|
|
|
50
75
|
|
|
51
76
|
if (threads == 1) {
|
|
52
77
|
// Single-threaded benchmark
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
))
|
|
74
|
-
}
|
|
78
|
+
var hashCount = 0L
|
|
79
|
+
var data = ByteArray(32)
|
|
80
|
+
Random.nextBytes(data)
|
|
81
|
+
|
|
82
|
+
val digest = MessageDigest.getInstance("SHA-256")
|
|
83
|
+
|
|
84
|
+
while (System.currentTimeMillis() < endTime) {
|
|
85
|
+
data = digest.digest(data)
|
|
86
|
+
hashCount++
|
|
87
|
+
|
|
88
|
+
// Report progress every 100000 hashes
|
|
89
|
+
if (hashCount % 100000 == 0L) {
|
|
90
|
+
val elapsed = System.currentTimeMillis() - startTime
|
|
91
|
+
val currentHashrate = hashCount.toDouble() / (elapsed.toDouble() / 1000)
|
|
92
|
+
|
|
93
|
+
sendEvent("onProgress", mapOf(
|
|
94
|
+
"currentHashCount" to hashCount,
|
|
95
|
+
"elapsedMs" to elapsed,
|
|
96
|
+
"currentHashrate" to currentHashrate
|
|
97
|
+
))
|
|
75
98
|
}
|
|
76
|
-
|
|
77
|
-
hashCount
|
|
78
99
|
}
|
|
100
|
+
|
|
101
|
+
totalHashes = hashCount
|
|
79
102
|
} else {
|
|
80
103
|
// Multi-threaded benchmark
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
hashCount++
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
hashCounts[threadIndex].set(hashCount)
|
|
104
|
+
val hashCounts = Array(threads) { AtomicLong(0) }
|
|
105
|
+
val threadPool = Executors.newFixedThreadPool(threads)
|
|
106
|
+
val futures = (0 until threads).map { threadIndex ->
|
|
107
|
+
threadPool.submit {
|
|
108
|
+
var hashCount = 0L
|
|
109
|
+
var data = ByteArray(32)
|
|
110
|
+
Random.nextBytes(data)
|
|
111
|
+
|
|
112
|
+
val digest = MessageDigest.getInstance("SHA-256")
|
|
113
|
+
|
|
114
|
+
while (System.currentTimeMillis() < endTime) {
|
|
115
|
+
data = digest.digest(data)
|
|
116
|
+
hashCount++
|
|
98
117
|
}
|
|
118
|
+
|
|
119
|
+
hashCounts[threadIndex].set(hashCount)
|
|
99
120
|
}
|
|
121
|
+
}
|
|
100
122
|
|
|
101
|
-
|
|
123
|
+
// Wait for all threads to complete
|
|
124
|
+
futures.forEach { it.get() }
|
|
125
|
+
threadPool.shutdown()
|
|
102
126
|
|
|
103
|
-
|
|
104
|
-
}
|
|
127
|
+
totalHashes = hashCounts.sumOf { it.get() }
|
|
105
128
|
}
|
|
106
129
|
|
|
107
130
|
val actualEndTime = System.currentTimeMillis()
|
package/app.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-benchmark",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Benchmark module to measure SHA-256 hashrate performance on mobile devices",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
"react-native",
|
|
20
20
|
"expo",
|
|
21
21
|
"expo-benchmark",
|
|
22
|
-
"ExpoBenchmark"
|
|
22
|
+
"ExpoBenchmark",
|
|
23
|
+
"hashrate",
|
|
24
|
+
"benchmark",
|
|
25
|
+
"sha256"
|
|
23
26
|
],
|
|
24
27
|
"repository": "https://github.com/duychip0909/expo-benchmark",
|
|
25
28
|
"bugs": {
|