@react-native-ohos/react-native-system-setting 1.7.7-rc.1 → 1.7.7-rc.3
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/API.md +57 -57
- package/CHANGELOG.md +206 -0
- package/COMMITTERS.md +7 -0
- package/LICENSE +21 -21
- package/LICENSE.md +21 -21
- package/OAT.xml +81 -0
- package/RCTSystemSetting.podspec +20 -20
- package/README.OpenSource +10 -10
- package/README.md +15 -15
- package/SystemSetting.d.ts +81 -81
- package/SystemSetting.js +347 -347
- package/Utils.js +11 -11
- package/harmony/react_native_system_setting/Index.ets +28 -27
- package/harmony/react_native_system_setting/build-profile.json5 +31 -31
- package/harmony/react_native_system_setting/hvigorfile.ts +6 -6
- package/harmony/react_native_system_setting/obfuscation-rules.txt +17 -17
- package/harmony/react_native_system_setting/oh-package.json5 +10 -10
- package/harmony/react_native_system_setting/src/main/cpp/CMakeLists.txt +5 -3
- package/harmony/react_native_system_setting/src/main/cpp/SystemSettingPackage.h +36 -0
- package/harmony/react_native_system_setting/src/main/cpp/{RNSystemSettingPackage.h → generated/RNOH/generated/BaseReactNativeSystemSettingPackage.h} +65 -76
- package/harmony/react_native_system_setting/src/main/cpp/{ReactNativeSystemSetting.cpp → generated/RNOH/generated/turbo_modules/ReactNativeSystemSetting.cpp} +47 -54
- package/harmony/react_native_system_setting/src/main/cpp/{ReactNativeSystemSetting.h → generated/RNOH/generated/turbo_modules/ReactNativeSystemSetting.h} +16 -21
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/ComponentDescriptors.h +22 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/EventEmitters.cpp +18 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/EventEmitters.h +19 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/Props.cpp +21 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/Props.h +20 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/ShadowNodes.cpp +19 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/ShadowNodes.h +25 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/States.cpp +18 -0
- package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/States.h +23 -0
- package/harmony/react_native_system_setting/src/main/ets/Logger.ts +63 -63
- package/harmony/react_native_system_setting/src/main/ets/{RNSystemSettingPackage.ts → RNSystemSettingPackage.ets} +52 -51
- package/harmony/react_native_system_setting/src/main/ets/RNSystemSettingTurboModule.ts +346 -361
- package/harmony/react_native_system_setting/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/react_native_system_setting/src/main/ets/generated/index.ets +5 -8
- package/harmony/react_native_system_setting/src/main/ets/generated/ts.ts +6 -9
- package/harmony/react_native_system_setting/src/main/ets/generated/turboModules/ReactNativeSystemSetting.ts +78 -86
- package/harmony/react_native_system_setting/src/main/ets/generated/turboModules/ts.ts +5 -8
- package/harmony/react_native_system_setting/src/main/module.json5 +9 -9
- package/harmony/react_native_system_setting/src/main/resources/base/element/string.json +8 -8
- package/harmony/react_native_system_setting/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/react_native_system_setting/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/react_native_system_setting/src/mock/mock-config.json5 +2 -0
- package/harmony/react_native_system_setting/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/harmony/react_native_system_setting/src/ohosTest/ets/test/List.test.ets +5 -0
- package/harmony/react_native_system_setting/src/ohosTest/ets/testability/TestAbility.ets +47 -0
- package/harmony/react_native_system_setting/src/ohosTest/ets/testability/pages/Index.ets +17 -0
- package/harmony/react_native_system_setting/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +90 -0
- package/harmony/react_native_system_setting/src/ohosTest/module.json5 +36 -0
- package/harmony/react_native_system_setting/src/ohosTest/resources/base/element/color.json +8 -0
- package/harmony/react_native_system_setting/src/ohosTest/resources/base/element/string.json +16 -0
- package/harmony/react_native_system_setting/src/ohosTest/resources/base/media/icon.png +0 -0
- package/harmony/react_native_system_setting/src/ohosTest/resources/base/profile/test_pages.json +5 -0
- package/harmony/react_native_system_setting/src/test/List.test.ets +5 -0
- package/harmony/react_native_system_setting/src/test/LocalUnit.test.ets +33 -0
- package/harmony/react_native_system_setting/{ts.ts → ts.ets} +24 -24
- package/harmony/react_native_system_setting.har +0 -0
- package/iOS.md +101 -0
- package/package.json +48 -46
- package/src/ReactRNSystemSetting.ts +108 -112
- package/harmony/react_native_system_setting/BuildProfile.ets +0 -6
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
25
|
export * from './src/main/ets/RNSystemSettingPackage'
|
|
Binary file
|
package/iOS.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# iOS
|
|
2
|
+
|
|
3
|
+
Some functions are diabled by default:
|
|
4
|
+
|
|
5
|
+
* `switchWifi()`
|
|
6
|
+
* `switchBluetooth()`
|
|
7
|
+
* `switchLocation()`
|
|
8
|
+
* `switchAirplane()`
|
|
9
|
+
* `isBluetoothEnabled()`
|
|
10
|
+
* `addBluetoothListener()`
|
|
11
|
+
|
|
12
|
+
When you call these functions, you'll just get some warning log.
|
|
13
|
+
|
|
14
|
+
You can enable it by add a preprocessor macros.
|
|
15
|
+
|
|
16
|
+
## Private API
|
|
17
|
+
|
|
18
|
+
There are some functions which start with `switch`:
|
|
19
|
+
|
|
20
|
+
* `switchWifi()`
|
|
21
|
+
* `switchBluetooth()`
|
|
22
|
+
* `switchLocation()`
|
|
23
|
+
* `switchAirplane()`
|
|
24
|
+
|
|
25
|
+
I implement them by using non-public APIs, which is not permitted on the App Store, see [this issue](https://github.com/c19354837/react-native-system-setting/issues/28).
|
|
26
|
+
|
|
27
|
+
**These functions are disabled by default. You must not call them If your app need submit to App Store. As an alternative, you can show a tip to tell the user how to change the system setting.**
|
|
28
|
+
|
|
29
|
+
Only when you'll distribute the app outside App Store, you can enable them by add a preprocessor macros `PRIVATE_API`.
|
|
30
|
+
|
|
31
|
+
**WARNING: If you enable it and submit app to App Store, you'll definitely get a rejection from apple. In the worst case, your account will be ban!**
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
> You should add `PRIVATE_API` in both `Debug` and `Release`
|
|
36
|
+
|
|
37
|
+
## Bluetooth
|
|
38
|
+
|
|
39
|
+
There are some bluetooth-function:
|
|
40
|
+
|
|
41
|
+
* `isBluetoothEnabled()`
|
|
42
|
+
* `addBluetoothListener()`
|
|
43
|
+
|
|
44
|
+
You can enable them in a few steps:
|
|
45
|
+
|
|
46
|
+
First, add preprocessor macros `BLUETOOTH`, either
|
|
47
|
+
1) Manually, or
|
|
48
|
+
2) Using `post_install` hook in Podfile (for React-Native >=0.60 with autolinking)
|
|
49
|
+
|
|
50
|
+
### Manually adding a preprocessor macro:
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
> You should add `BLUETOOTH` in both `Debug` and `Release`
|
|
55
|
+
|
|
56
|
+
### Automatically adding a preprocessor macro via Podfile
|
|
57
|
+
Add `post_install` hook in `Podfile`:
|
|
58
|
+
```ruby
|
|
59
|
+
post_install do |installer|
|
|
60
|
+
flipper_post_install(installer)
|
|
61
|
+
|
|
62
|
+
## ADD THE FOLLOWING:
|
|
63
|
+
|
|
64
|
+
# Enables bluetooth functionality of react-native-system-setting
|
|
65
|
+
installer.pods_project.targets.each do |target|
|
|
66
|
+
if target.name == "RCTSystemSetting"
|
|
67
|
+
target.build_configurations.each do |config|
|
|
68
|
+
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
|
|
69
|
+
if !config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'].include? 'BLUETOOTH'
|
|
70
|
+
puts 'Adding BLUETOOTH in GCC_PREPROCESSOR_DEFINITIONS of Pod RCTSystemSetting...'
|
|
71
|
+
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'BLUETOOTH'
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Then open `Info.plist` as source code.
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
Finally, add `NSBluetoothPeripheralUsageDescription` in `Info.plist`, see [Info.plist - example](https://github.com/c19354837/react-native-system-setting/blob/master/examples/SystemSettingExample/ios/SystemSettingExample/Info.plist#L55-L56)
|
|
84
|
+
|
|
85
|
+
```xml
|
|
86
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
87
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
88
|
+
<plist version="1.0">
|
|
89
|
+
<dict>
|
|
90
|
+
|
|
91
|
+
...
|
|
92
|
+
|
|
93
|
+
<key>NSBluetoothPeripheralUsageDescription</key>
|
|
94
|
+
<string>Explain the reasons for accessing...</string>
|
|
95
|
+
|
|
96
|
+
</dict>
|
|
97
|
+
</plist>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
> You can change the `string` as you need
|
|
101
|
+
|
package/package.json
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@react-native-ohos/react-native-system-setting",
|
|
3
|
-
"version": "1.7.7-rc.
|
|
4
|
-
"description": "provide some system setting APIs. Volume, brightness, wifi, location, bluetooth, airplane...",
|
|
5
|
-
"main": "SystemSetting.js",
|
|
6
|
-
"types": "SystemSetting.d.ts",
|
|
7
|
-
"homepage": "https://
|
|
8
|
-
"bugs": {
|
|
9
|
-
"url": "https://
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-system-setting",
|
|
3
|
+
"version": "1.7.7-rc.3",
|
|
4
|
+
"description": "provide some system setting APIs. Volume, brightness, wifi, location, bluetooth, airplane...",
|
|
5
|
+
"main": "SystemSetting.js",
|
|
6
|
+
"types": "SystemSetting.d.ts",
|
|
7
|
+
"homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-system-setting",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-system-setting/issues"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-system-setting --cpp-output-path ./harmony/react_native_system_setting/src/main/cpp/generated --ets-output-path ./harmony/react_native_system_setting/src/main/ets/generated --turbo-modules-spec-paths ./src --arkts-components-spec-paths ./src"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"react-native",
|
|
17
|
+
"system",
|
|
18
|
+
"setting",
|
|
19
|
+
"volume",
|
|
20
|
+
"wifi",
|
|
21
|
+
"brightness",
|
|
22
|
+
"location",
|
|
23
|
+
"bluetooth",
|
|
24
|
+
"airplane"
|
|
25
|
+
],
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "Ninty",
|
|
28
|
+
"email": "c19354837@hotmail.com",
|
|
29
|
+
"url": "https://github.com/c19354837"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-system-setting.git"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"registry": "https://registry.npmjs.org/",
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"harmony": {
|
|
41
|
+
"alias": "react-native-system-setting",
|
|
42
|
+
"autolinking": {
|
|
43
|
+
"etsPackageClassName": "SystemSettingPackage",
|
|
44
|
+
"cppPackageClassName": "SystemSettingPackage",
|
|
45
|
+
"cmakeLibraryTargetName": "rnoh_system_setting",
|
|
46
|
+
"ohPackageName": "@react-native-ohos/react-native-system-setting"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
47
49
|
}
|
|
@@ -1,113 +1,109 @@
|
|
|
1
|
-
import type { TurboModule } from 'react-native';
|
|
2
|
-
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export interface Spec extends TurboModule {
|
|
5
|
-
getBrightness: () => Promise<number>;
|
|
6
|
-
|
|
7
|
-
setBrightness: (val: number) => Promise<boolean>;
|
|
8
|
-
|
|
9
|
-
setBrightnessForce: (val: number) => Promise<boolean>;
|
|
10
|
-
|
|
11
|
-
getAppBrightness: () => Promise<number>;
|
|
12
|
-
|
|
13
|
-
setAppBrightness: (val: number) => Promise<boolean>;
|
|
14
|
-
|
|
15
|
-
grantWriteSettingPremission: () => void;
|
|
16
|
-
|
|
17
|
-
getScreenMode: () => Promise<number>;
|
|
18
|
-
|
|
19
|
-
setScreenMode: (val: number) => Promise<boolean>;
|
|
20
|
-
|
|
21
|
-
saveBrightness: () => Promise<void>;
|
|
22
|
-
|
|
23
|
-
restoreBrightness: () => number;
|
|
24
|
-
|
|
25
|
-
getVolume: (type?: VolumeType) => Promise<number>;
|
|
26
|
-
|
|
27
|
-
setVolume: (value: number, config?: VolumeConfig | VolumeType) => void;
|
|
28
|
-
|
|
29
|
-
addVolumeListener: () => void;
|
|
30
|
-
|
|
31
|
-
removeVolumeListener: (listener?: EmitterSubscription) => void;
|
|
32
|
-
|
|
33
|
-
isWifiEnabled: () => Promise<boolean>;
|
|
34
|
-
|
|
35
|
-
switchWifiSilence: (onComplete?: CompleteFunc) => void;
|
|
36
|
-
|
|
37
|
-
switchWifi: (onComplete?: CompleteFunc) => void;
|
|
38
|
-
|
|
39
|
-
isLocationEnabled: () => Promise<boolean>;
|
|
40
|
-
|
|
41
|
-
getLocationMode: () => Promise<number>;
|
|
42
|
-
|
|
43
|
-
switchLocation: (onComplete?: CompleteFunc) => void;
|
|
44
|
-
|
|
45
|
-
isBluetoothEnabled: () => Promise<boolean>;
|
|
46
|
-
|
|
47
|
-
switchBluetooth: (onComplete?: CompleteFunc) => void;
|
|
48
|
-
|
|
49
|
-
switchBluetoothSilence: (onComplete?: CompleteFunc) => void;
|
|
50
|
-
|
|
51
|
-
isAirplaneEnabled: () => Promise<boolean>;
|
|
52
|
-
|
|
53
|
-
switchAirplane: (onComplete?: CompleteFunc) => void;
|
|
54
|
-
|
|
55
|
-
openAppSystemSettings: () => void;
|
|
56
|
-
|
|
57
|
-
addBluetoothListener: () => void;
|
|
58
|
-
|
|
59
|
-
addWifiListener: (
|
|
60
|
-
callback: (wifiEnabled: boolean) => void
|
|
61
|
-
) => Promise<EmitterSubscription | null>;
|
|
62
|
-
|
|
63
|
-
addLocationListener: (
|
|
64
|
-
callback: (locationEnabled: boolean) => void
|
|
65
|
-
) => Promise<EmitterSubscription | null>;
|
|
66
|
-
|
|
67
|
-
addLocationModeListener: (
|
|
68
|
-
callback: (locationMode: number) => void
|
|
69
|
-
) => Promise<EmitterSubscription | null>;
|
|
70
|
-
|
|
71
|
-
addAirplaneListener: (
|
|
72
|
-
callback: (airplaneModeEnabled: boolean) => void
|
|
73
|
-
) => Promise<EmitterSubscription | null>;
|
|
74
|
-
|
|
75
|
-
removeListener: (type: string) => void;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
| "
|
|
91
|
-
| "
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
alarm?: number;
|
|
110
|
-
notification?: number;
|
|
111
|
-
}
|
|
112
|
-
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
getBrightness: () => Promise<number>;
|
|
6
|
+
|
|
7
|
+
setBrightness: (val: number) => Promise<boolean>;
|
|
8
|
+
|
|
9
|
+
setBrightnessForce: (val: number) => Promise<boolean>;
|
|
10
|
+
|
|
11
|
+
getAppBrightness: () => Promise<number>;
|
|
12
|
+
|
|
13
|
+
setAppBrightness: (val: number) => Promise<boolean>;
|
|
14
|
+
|
|
15
|
+
grantWriteSettingPremission: () => void;
|
|
16
|
+
|
|
17
|
+
getScreenMode: () => Promise<number>;
|
|
18
|
+
|
|
19
|
+
setScreenMode: (val: number) => Promise<boolean>;
|
|
20
|
+
|
|
21
|
+
saveBrightness: () => Promise<void>;
|
|
22
|
+
|
|
23
|
+
restoreBrightness: () => number;
|
|
24
|
+
|
|
25
|
+
getVolume: (type?: VolumeType) => Promise<number>;
|
|
26
|
+
|
|
27
|
+
setVolume: (value: number, config?: VolumeConfig | VolumeType) => void;
|
|
28
|
+
|
|
29
|
+
addVolumeListener: () => void;
|
|
30
|
+
|
|
31
|
+
removeVolumeListener: (listener?: EmitterSubscription) => void;
|
|
32
|
+
|
|
33
|
+
isWifiEnabled: () => Promise<boolean>;
|
|
34
|
+
|
|
35
|
+
switchWifiSilence: (onComplete?: CompleteFunc) => void;
|
|
36
|
+
|
|
37
|
+
switchWifi: (onComplete?: CompleteFunc) => void;
|
|
38
|
+
|
|
39
|
+
isLocationEnabled: () => Promise<boolean>;
|
|
40
|
+
|
|
41
|
+
getLocationMode: () => Promise<number>;
|
|
42
|
+
|
|
43
|
+
switchLocation: (onComplete?: CompleteFunc) => void;
|
|
44
|
+
|
|
45
|
+
isBluetoothEnabled: () => Promise<boolean>;
|
|
46
|
+
|
|
47
|
+
switchBluetooth: (onComplete?: CompleteFunc) => void;
|
|
48
|
+
|
|
49
|
+
switchBluetoothSilence: (onComplete?: CompleteFunc) => void;
|
|
50
|
+
|
|
51
|
+
isAirplaneEnabled: () => Promise<boolean>;
|
|
52
|
+
|
|
53
|
+
switchAirplane: (onComplete?: CompleteFunc) => void;
|
|
54
|
+
|
|
55
|
+
openAppSystemSettings: () => void;
|
|
56
|
+
|
|
57
|
+
addBluetoothListener: () => void;
|
|
58
|
+
|
|
59
|
+
addWifiListener: (
|
|
60
|
+
callback: (wifiEnabled: boolean) => void
|
|
61
|
+
) => Promise<EmitterSubscription | null>;
|
|
62
|
+
|
|
63
|
+
addLocationListener: (
|
|
64
|
+
callback: (locationEnabled: boolean) => void
|
|
65
|
+
) => Promise<EmitterSubscription | null>;
|
|
66
|
+
|
|
67
|
+
addLocationModeListener: (
|
|
68
|
+
callback: (locationMode: number) => void
|
|
69
|
+
) => Promise<EmitterSubscription | null>;
|
|
70
|
+
|
|
71
|
+
addAirplaneListener: (
|
|
72
|
+
callback: (airplaneModeEnabled: boolean) => void
|
|
73
|
+
) => Promise<EmitterSubscription | null>;
|
|
74
|
+
|
|
75
|
+
removeListener: (type: string) => void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
type EmitterSubscription = {
|
|
79
|
+
remove: unknown;
|
|
80
|
+
type: 'bluetooth' | 'wifi' | 'location' | 'locationMode' | 'airplane'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type CompleteFunc = () => void
|
|
84
|
+
|
|
85
|
+
type VolumeType =
|
|
86
|
+
| "call"
|
|
87
|
+
| "system"
|
|
88
|
+
| "ring"
|
|
89
|
+
| "music"
|
|
90
|
+
| "alarm"
|
|
91
|
+
| "notification";
|
|
92
|
+
|
|
93
|
+
type VolumeConfig = {
|
|
94
|
+
type?: VolumeType;
|
|
95
|
+
playSound?: boolean;
|
|
96
|
+
showUI?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type VolumeData = {
|
|
100
|
+
value: number;
|
|
101
|
+
call?: number;
|
|
102
|
+
system?: number;
|
|
103
|
+
ring?: number;
|
|
104
|
+
music?: number;
|
|
105
|
+
alarm?: number;
|
|
106
|
+
notification?: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
113
109
|
export default TurboModuleRegistry.get<Spec>('ReactNativeSystemSetting') as Spec | null;
|