@amazon-devices/kepler-graphics 2.3.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/LICENSE +7 -0
- package/README.md +272 -0
- package/SystemBundles/e1224d435abddb7360ba588396252be76566b2cdc8373c285491d1711dc251d0.bundle +1742 -0
- package/SystemBundles/e1224d435abddb7360ba588396252be76566b2cdc8373c285491d1711dc251d0.bundle.map +1 -0
- package/SystemModules/amzn__kepler-graphics-2.modules.txt +7 -0
- package/SystemModules/amzn__kepler-graphics-2.private.modules.txt +11 -0
- package/SystemModules/keplerscript-system-bundle-config.json +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +34 -0
- package/dist/kepler/tm-manifest.json +1 -0
- package/dist/turbo-modules/AmazonGraphicsTurboModule.d.ts +47 -0
- package/dist/turbo-modules/AmazonGraphicsTurboModule.js +13 -0
- package/dist/turbo-modules/Display.d.ts +147 -0
- package/dist/turbo-modules/Display.js +249 -0
- package/dist/turbo-modules/DisplayController.d.ts +25 -0
- package/dist/turbo-modules/DisplayController.js +56 -0
- package/dist/turbo-modules/DisplayManager.d.ts +103 -0
- package/dist/turbo-modules/DisplayManager.js +149 -0
- package/dist/turbo-modules/__mocks__/AmazonGraphicsTurboModule.d.ts +17 -0
- package/dist/turbo-modules/__mocks__/AmazonGraphicsTurboModule.js +25 -0
- package/dist/types/GraphicsTypes.d.ts +350 -0
- package/dist/types/GraphicsTypes.js +221 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +20 -0
- package/kepler-compatibility.json +8 -0
- package/kepler-transformed-package-info.json +3 -0
- package/package.json +1 -0
- package/react-native.config.js +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
|
|
2
|
+
|
|
3
|
+
These materials are licensed as "Program Materials" under the Program Materials License Agreement (the "Agreement"). The Agreement is available at https://developer.amazon.com/support/legal/pml. See the Agreement for the specific terms and conditions of the Agreement. Capitalized terms not defined in this file have the meanings given to them in the Agreement.
|
|
4
|
+
|
|
5
|
+
If you do not agree to the above terms and conditions, you may not use any file in this package.
|
|
6
|
+
|
|
7
|
+
YOUR USE OF THE PROGRAM MATERIALS IN OR ASSOCIATED WITH THIS PACKAGE IS AT YOUR SOLE RISK. IN NO EVENT WILL AMAZON BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL, INCIDENTAL, OR PUNITIVE DAMAGES (INCLUDING FOR ANY LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, OR COMPUTER FAILURE OR MALFUNCTION) ARISING FROM OR RELATING TO SUCH PROGRAM MATERIALS, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, EVEN IF AMAZON HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS AND DISCLAIMERS APPLY EXCEPT TO THE EXTENT PROHIBITED BY APPLICABLE LAW.
|
package/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
|
|
2
|
+
# KeplerGraphics Display JS APIs
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
|
|
6
|
+
The **Kepler Graphics Turbo Module** API provides functionality for applications to query the display capabilities such as screen resolution, refresh rate, color depth/format, and HDR support for the connected display from the platform. The API also considers the device's support and returns the capabilities according to the device's limitations. This Turbo Module internally uses the display APIs from the Kepler Graphics Interface (IDL interface). Most of the APIs are 1:1 mapped against the IDL interfaces.
|
|
7
|
+
|
|
8
|
+
## Authentication
|
|
9
|
+
|
|
10
|
+
The display APIs consists of both get methods and set methods. Applications that are using the set methods via `DisplayManager` class requires
|
|
11
|
+
the security privilege **`com.amazon.graphics.privilege.display.manager`** in their Application's manifest.toml file under "[needs]" section as shown below.
|
|
12
|
+
```
|
|
13
|
+
[[needs.privilege]]
|
|
14
|
+
id = "com.amazon.graphics.privilege.display.manager"
|
|
15
|
+
```
|
|
16
|
+
Please note the get methods do not require any privilege.
|
|
17
|
+
|
|
18
|
+
## Getting Started
|
|
19
|
+
|
|
20
|
+
### Prerequisites
|
|
21
|
+
|
|
22
|
+
Kepler Applications can consume this package through the Kepler SDK.
|
|
23
|
+
|
|
24
|
+
For instructions on how to install the Kepler SDK, see [Kepler SDK Setup](https://developer.amazon.com/docs/kepler/install-kepler-sdk.html).
|
|
25
|
+
|
|
26
|
+
### Setup
|
|
27
|
+
|
|
28
|
+
The Kepler Graphics Turbo Module is provided by the `kepler-graphics` npm package. This npm package must be added to the application's `package.json` as dependency.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
"dependencies": {
|
|
32
|
+
...
|
|
33
|
+
"@amazon-devices/kepler-graphics": "^2.3.0",
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Import interfaces/types from the package
|
|
38
|
+
|
|
39
|
+
The interfaces and types should be imported from the *kepler-graphics* package
|
|
40
|
+
in a source code file as shown below:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
import {
|
|
44
|
+
Display,
|
|
45
|
+
DisplayManager,
|
|
46
|
+
DisplayController,
|
|
47
|
+
ColorDepth,
|
|
48
|
+
ColorSpace,
|
|
49
|
+
HdcpLevel,
|
|
50
|
+
HdrType,
|
|
51
|
+
LlmState,
|
|
52
|
+
HdrMode,
|
|
53
|
+
IDisplayConfig,
|
|
54
|
+
IDisplayListener,
|
|
55
|
+
IDisplayControllerListener,
|
|
56
|
+
ISubscription
|
|
57
|
+
} from '@amazon-devices/kepler-graphics';
|
|
58
|
+
```
|
|
59
|
+
Based on the consumed APIs, only the needed types in the above import listing can be retained.
|
|
60
|
+
|
|
61
|
+
## Common Use Cases
|
|
62
|
+
|
|
63
|
+
Use this package APIs to query the connected display properties and get hotplug events.
|
|
64
|
+
The following is a list of supported use cases:
|
|
65
|
+
|
|
66
|
+
1. Listening to display hotplug events.
|
|
67
|
+
2. Querying supported *Screen Resolutions (width x heigh)* and *Refresh rates* of the display.
|
|
68
|
+
3. Querying supported *HDR* types/*Transfer Functions*, maximum *HDCP level*, *Screen Density (DPI)* of the display.
|
|
69
|
+
5. Querying currently active *Screen Resolution*, *Refresh Rate*, *Color Depth*, *Color Format*, *HDR Mode*, *Low Latency Mode (ALLM)* for the display.
|
|
70
|
+
6. Listening to change events for the above mentioned display properties.
|
|
71
|
+
|
|
72
|
+
If application gets the system privilege mentioned in the **Authentication** section above, then the following set of operations are allowed.
|
|
73
|
+
|
|
74
|
+
7. Changing current *Screen Resolution* and *Refresh Rate* to one of the supported values.
|
|
75
|
+
8. Changing other display properties like *Color Depth*, *Color Format*, *HDR Mode* and *ALLM*.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
The following sections provide sample code for some of the use cases.
|
|
79
|
+
|
|
80
|
+
### 1. Check Display Status
|
|
81
|
+
To check if a display is already connected or not to the device, use the following method.
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
const displayConnected = DisplayController.isPrimaryDisplayConnected();
|
|
85
|
+
if (displayConnected) {
|
|
86
|
+
// Perform operations on the display.
|
|
87
|
+
} else {
|
|
88
|
+
// Display is not connected, Do NOT use the `Display` and `DisplayManager` methods.
|
|
89
|
+
// In this case, the hotplug event callbacks can be used to know
|
|
90
|
+
// when a new display is connected.
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 2. Display Hotplug Events
|
|
95
|
+
Get callback events when display panels are connected or disconnected. The `IDisplayControllerListener.onAddDisplay()` and `IDisplayControllerListener.onRemoveDisplay()` callback methods provide those events as shown below.
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
const displayControllerListener: IDisplayControllerListener = {
|
|
99
|
+
|
|
100
|
+
onAddDisplay: (id: Int32) => {
|
|
101
|
+
console.log("IDisplayControllerListener::onAddDisplay - ", id);
|
|
102
|
+
// Any initialization when new display is connected.
|
|
103
|
+
},
|
|
104
|
+
onRemoveDisplay: (id: Int32) => {
|
|
105
|
+
console.log("IDisplayControllerListener::onRemoveDisplay - ", id);
|
|
106
|
+
// Any cleanup required.
|
|
107
|
+
// Please note the `Display` and `DisplayManager` methods do not work
|
|
108
|
+
// when the display is disconnected.
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Register the listener callback object to receive events.
|
|
113
|
+
const subscription: ISubscription = DisplayController.addListener(displayControllerListener);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 3. Current Screen Resolution and Refresh Rate
|
|
117
|
+
|
|
118
|
+
`Display.getCurrentConfig()` returns the currently active configuration as `IDisplayConfig` object. The members of the `IDisplayConfig` object provides the screen resolution (width x height), screen density, supported refresh rates, and more. Below is the sample code.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
// Get currently active display config.
|
|
122
|
+
const displayConfig = Display.getCurrentConfig();
|
|
123
|
+
// Current width in pixels.
|
|
124
|
+
const width = displayConfig.widthInPixels;
|
|
125
|
+
// Current height in pixels.
|
|
126
|
+
const height = displayConfig.heightInPixels;
|
|
127
|
+
// Screen Density in DPI (dots-per-inch).
|
|
128
|
+
const dpi = displayConfig.screenDensityInDpi;
|
|
129
|
+
|
|
130
|
+
// Current refresh rate in milli hz (eg: 60000 = 60Hz).
|
|
131
|
+
const currentRefreshRate = Display.getCurrentRefreshRateInMillihertz();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 4. Check HDR Support
|
|
135
|
+
|
|
136
|
+
To check if HDR is supported by the display and also by the device, the following example code can be used.
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
// Checks if the display along with device supports any of the HDR formats.
|
|
140
|
+
const hdrSupport = Display.isHDRSupported();
|
|
141
|
+
|
|
142
|
+
// Get the current user selected HDR mode - possible values are in 'enum HdrMode'.
|
|
143
|
+
const hdrMode = Display.getHdrMode();
|
|
144
|
+
|
|
145
|
+
if (hdrSupport && (hdrMode !== HdrMode.DISABLED)) {
|
|
146
|
+
// HDR is supported.
|
|
147
|
+
// Now get the current configuration to check if required HDR format is supported.
|
|
148
|
+
const displayConfig = Display.getCurrentConfig();
|
|
149
|
+
for (const hdrType of displayConfig.supportedHdrType) {
|
|
150
|
+
if (hdrType === HdrType.HDR10) {
|
|
151
|
+
// HDR10 supported.
|
|
152
|
+
} else if (hdrType === HdrType.HDR10_PLUS) {
|
|
153
|
+
// HDR10+ supported.
|
|
154
|
+
} else if (hdrType === HdrType.HLG) {
|
|
155
|
+
// HLG supported.
|
|
156
|
+
} else if (hdrType == HdrType.DOLBY_VISION) {
|
|
157
|
+
// Dolby Vision supported.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
// HDR is not supported or disabled by user.
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
**NOTE:** The supported HDR types shown above is from the current active display configuration (resolution) only. Other display configuration obtained through `Display.getAllSupportedConfigs()` might list certain HDR types. Those HDR types are usable only when the current active configuration is changed to that particular display configuration through `DisplayManager.requestConfigChange()` method.
|
|
165
|
+
|
|
166
|
+
### 5. Query Other Display Properties
|
|
167
|
+
```
|
|
168
|
+
// Query the display connector name.
|
|
169
|
+
const name = Display.getName();
|
|
170
|
+
|
|
171
|
+
// Get current HDCP level - possible values are in 'enum HdcpLevel'.
|
|
172
|
+
const hdcpLevel = Display.getCurrentHdcpLevel();
|
|
173
|
+
|
|
174
|
+
// Get current color depth - possible values are in 'enum ColorDepth'.
|
|
175
|
+
const colorDepth = Display.getColorDepth();
|
|
176
|
+
|
|
177
|
+
// Get current color space - possible values are in 'enum ColorSpace'.
|
|
178
|
+
const colorSpace = Display.getColorSpace();
|
|
179
|
+
|
|
180
|
+
// Check if low latency mode is supported in the device.
|
|
181
|
+
llmSupported = Display.isLowLatencyModeSupported();
|
|
182
|
+
if (llmSupported) {
|
|
183
|
+
// Low Latency Mode is supported in the display.
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 6. Listen for Change Events
|
|
188
|
+
|
|
189
|
+
Applications can listen for changes to the display properties like screen resolution, refresh rate, color depth/space, HDCP level, HDR mode, and Low Latency Mode through the `IDisplayListener` callback interface. See the following code example:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
const displayListener: IDisplayListener = {
|
|
193
|
+
|
|
194
|
+
onConfigChange: (config: IDisplayConfig) => {
|
|
195
|
+
console.log("IDisplayListener onConfigChange == ", config);
|
|
196
|
+
},
|
|
197
|
+
onRefreshRateChange: (refreshRateInrMillihertz: Int32) => {
|
|
198
|
+
console.log("IDisplayListener onRefreshRateChange == ", refreshRateInrMillihertz);
|
|
199
|
+
},
|
|
200
|
+
onColorDepthChange: (colorDepth: ColorDepth) => {
|
|
201
|
+
Alert.alert("IDisplayListener onConfigChange == ");
|
|
202
|
+
console.log("IDisplayListener onColorDepthChange == ", colorDepth);
|
|
203
|
+
},
|
|
204
|
+
onColorSpaceChange: (colorSpace: ColorSpace) => {
|
|
205
|
+
console.log("IDisplayListener onColorSpaceChange == ", colorSpace);
|
|
206
|
+
},
|
|
207
|
+
onHdcpLevelChange: (level: HdcpLevel) => {
|
|
208
|
+
console.log("IDisplayListener onHdcpLevelChange == ", level);
|
|
209
|
+
},
|
|
210
|
+
onAutoConfigSwitchStateChange: (state: boolean) => {
|
|
211
|
+
console.log("IDisplayListener onAutoConfigSwitchStateChange == ", state);
|
|
212
|
+
},
|
|
213
|
+
onMultipleRefreshRateStateChange: (state: boolean) => {
|
|
214
|
+
console.log("IDisplayListener onMultipleRefreshRateStateChange == ", state);
|
|
215
|
+
},
|
|
216
|
+
onLowLatencyModeStateChange: (state: LlmState) => {
|
|
217
|
+
console.log("IDisplayListener onLowLatencyModeStateChange == ", state);
|
|
218
|
+
},
|
|
219
|
+
onHdrModeChange: (hdr_mode: HdrMode) => {
|
|
220
|
+
console.log("IDisplayListener onHdrModeChange == ", hdr_mode);
|
|
221
|
+
},
|
|
222
|
+
onSinkStateChange: (active: boolean) => {
|
|
223
|
+
console.log("IDisplayListener onSinkStateChange == ", active);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// Register the listener object to receive the callbacks.
|
|
228
|
+
const subscription: ISubscription = Display.addDisplayListener(displayListener);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## FAQs
|
|
232
|
+
|
|
233
|
+
#### Q1: Why display supported HDR type is not listed in the `IDisplayConfig.supportedHdrType` array?
|
|
234
|
+
In addition to the display properties, the method implementation considers the device capabilities too
|
|
235
|
+
for reporting the supported types. If the device does not support certain HDR type, for example "Dolby Vision", then the list reported by `IDisplayConfig.supportedHdrType` does not contain it.
|
|
236
|
+
|
|
237
|
+
#### Q2: How to unsubscribe for the listener callbacks?
|
|
238
|
+
The methods `Display.addDisplayListener()` and `DisplayController.addListener()` returns a `ISubscription` object.
|
|
239
|
+
This object is used to unsubscribe the listener by calling the `unsubscribe()` method. See the following code example.
|
|
240
|
+
```
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
const subscription: ISubscription = DisplayController.addListener(displayControllerListener);
|
|
243
|
+
return () => {
|
|
244
|
+
subscription.unsubscribe();
|
|
245
|
+
};
|
|
246
|
+
}, []);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Q3: Why does `supportedHdrType` return multiple duplicated values like
|
|
250
|
+
```
|
|
251
|
+
{
|
|
252
|
+
"heightInPixels": 1080,
|
|
253
|
+
"maxHdcpLevel": 7,
|
|
254
|
+
"screenDensityInDpi": 81,
|
|
255
|
+
"supportedHdrType": [
|
|
256
|
+
1,
|
|
257
|
+
1,
|
|
258
|
+
1,
|
|
259
|
+
1,
|
|
260
|
+
1
|
|
261
|
+
],
|
|
262
|
+
"supportedRefreshRatesInMillihertz": [
|
|
263
|
+
60000,
|
|
264
|
+
50000,
|
|
265
|
+
30000,
|
|
266
|
+
25000,
|
|
267
|
+
24000
|
|
268
|
+
],
|
|
269
|
+
"widthInPixels": 1920
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
HDR types are correlated with refresh rates. In this scenario, there are five different refresh rates, each with its corresponding HDR type support information. For instance, at a refresh rate of 60 millihertz (mHz), the HDR support type is 1, which corresponds to `HdrType.NONE`.
|