File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
packages/rtn-web-browser/android/src/main/kotlin/com/amazonaws/amplify/rtnwebbrowser Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ package com.amazonaws.amplify.rtnwebbrowser
5+
6+ import com.facebook.react.bridge.Promise
7+ import com.facebook.react.bridge.ReactApplicationContext
8+ import com.facebook.react.bridge.ReactContextBaseJavaModule
9+ import com.facebook.react.bridge.ReactMethod
10+
11+ class ChromeOSModule (reactContext : ReactApplicationContext ) : ReactContextBaseJavaModule(reactContext) {
12+
13+ override fun getName () = " ChromeOS"
14+
15+ @ReactMethod
16+ fun isChromeOS (promise : Promise ) {
17+ try {
18+ val isChromeOS = detectChromeOS()
19+ promise.resolve(isChromeOS)
20+ } catch (e: Exception ) {
21+ promise.reject(" CHROMEOS_DETECTION_ERROR" , " Failed to detect ChromeOS" , e)
22+ }
23+ }
24+
25+ private fun detectChromeOS (): Boolean {
26+ return try {
27+ // Check for Android Runtime for Chrome (ARC) system feature
28+ val packageManager = reactApplicationContext.packageManager
29+
30+ packageManager.hasSystemFeature(" org.chromium.arc.device_management" ) ||
31+ packageManager.hasSystemFeature(" org.chromium.arc" )
32+ } catch (e: Exception ) {
33+ // If we can't check system features, return false
34+ false
35+ }
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -18,5 +18,8 @@ class WebBrowserPackage : ReactPackage {
1818
1919 override fun createNativeModules (
2020 reactContext : ReactApplicationContext
21- ): MutableList <NativeModule > = listOf (WebBrowserModule (reactContext)).toMutableList()
21+ ): MutableList <NativeModule > = listOf (
22+ WebBrowserModule (reactContext),
23+ ChromeOSModule (reactContext)
24+ ).toMutableList()
2225}
You can’t perform that action at this time.
0 commit comments