Skip to content

Commit e8a45ee

Browse files
committed
Missing const, eslint
1 parent 238a7ba commit e8a45ee

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

packages/react-native-executorch/android/src/main/cpp/ETInstallerModule.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
#include <rnexecutorch/RnExecutorchInstaller.h>
44

5+
#include "EmulatorDetection.h"
6+
57
#include <jni.h>
68
#include <jsi/jsi.h>
7-
#include <sys/system_properties.h>
89

910
namespace rnexecutorch {
1011
JavaVM *java_machine;
@@ -65,18 +66,10 @@ void ETInstallerModule::injectJSIBindings() {
6566
return std::vector<std::byte>(dataBytePtr, dataBytePtr + size);
6667
};
6768

68-
auto isEmulator = []() {
69-
char fingerprint[PROP_VALUE_MAX] = {0};
70-
char hardware[PROP_VALUE_MAX] = {0};
71-
__system_property_get("ro.build.fingerprint", fingerprint);
72-
__system_property_get("ro.hardware", hardware);
73-
std::string fp(fingerprint);
74-
std::string hw(hardware);
75-
return fp.find("generic") == 0 || hw == "goldfish" || hw == "ranchu";
76-
}();
69+
auto _isEmulator = isEmulator();
7770

7871
RnExecutorchInstaller::injectJSIBindings(jsiRuntime_, jsCallInvoker_,
79-
fetchDataByUrl, isEmulator);
72+
fetchDataByUrl, _isEmulator);
8073
}
8174
} // namespace rnexecutorch
8275

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include <sys/system_properties.h>
4+
#include <string>
5+
6+
namespace rnexecutorch {
7+
8+
inline bool isEmulator() {
9+
auto readProp = [](const char *key) -> std::string {
10+
const prop_info *pi = __system_property_find(key);
11+
if (!pi) return "";
12+
std::string result;
13+
__system_property_read_callback(
14+
pi,
15+
[](void *cookie, const char *, const char *value, uint32_t) {
16+
*static_cast<std::string *>(cookie) = value;
17+
},
18+
&result);
19+
return result;
20+
};
21+
22+
std::string fp = readProp("ro.build.fingerprint");
23+
std::string hw = readProp("ro.hardware");
24+
return fp.find("generic") == 0 || hw == "goldfish" || hw == "ranchu";
25+
}
26+
27+
} // namespace rnexecutorch
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export const DOWNLOAD_EVENT_ENDPOINT =
22
'https://ai.swmansion.com/telemetry/downloads/api/downloads';
3+
4+
// eslint-disable-next-line @typescript-eslint/no-var-requires
5+
export const LIB_VERSION: string = require('../../package.json').version;

packages/react-native-executorch/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ declare global {
105105
symbols: string,
106106
independentCharacters?: boolean
107107
) => Promise<any>;
108+
// eslint-disable-next-line camelcase
108109
var __rne_isEmulator: () => boolean;
109110
}
110111
// eslint-disable no-var
@@ -126,6 +127,7 @@ if (
126127
global.loadTextToSpeechKokoro == null ||
127128
global.loadOCR == null ||
128129
global.loadVerticalOCR == null ||
130+
// eslint-disable-next-line camelcase
129131
global.__rne_isEmulator == null
130132
) {
131133
if (!ETInstallerNativeModule) {

packages/react-native-executorch/src/utils/ResourceFetcherUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { ResourceSource } from '..';
22
import { getModelNameForUrl } from '../constants/modelUrls';
3-
import { DOWNLOAD_EVENT_ENDPOINT } from '../constants/resourceFetcher';
3+
import {
4+
DOWNLOAD_EVENT_ENDPOINT,
5+
LIB_VERSION,
6+
} from '../constants/resourceFetcher';
47

58
/**
69
* Http status codes
@@ -207,7 +210,6 @@ export namespace ResourceFetcherUtils {
207210
}
208211

209212
export function isEmulator(): boolean {
210-
// eslint-disable-next-line camelcase
211213
return !!(global as any).__rne_isEmulator;
212214
}
213215

0 commit comments

Comments
 (0)