mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
OHOS: Use native API to get most of the information needed for starting servoshell. (#37392)
Uses the native ohos-api crates to get the required information for starting servoshell. This increases the minimum API version requirement to API-14. Testing: Tested on device. --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Co-authored-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
This commit is contained in:
parent
7a801f0ef5
commit
099fd10317
6 changed files with 95 additions and 47 deletions
|
@ -15,35 +15,10 @@ interface ServoXComponentInterface {
|
|||
|
||||
interface InitOpts {
|
||||
url: string;
|
||||
deviceType: string,
|
||||
osFullName: string,
|
||||
resourceDir: string,
|
||||
cacheDir: string,
|
||||
displayDensity: number,
|
||||
commandlineArgs: string,
|
||||
}
|
||||
|
||||
function get_density(): number {
|
||||
try {
|
||||
let displayClass = display.getDefaultDisplaySync();
|
||||
console.info('Test densityDPI:' + JSON.stringify(displayClass.densityDPI));
|
||||
return displayClass.densityDPI / 160;
|
||||
} catch (exception) {
|
||||
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
function get_device_type(): string {
|
||||
let device_type: string = deviceInfo.deviceType;
|
||||
if (device_type == "") {
|
||||
console.error("deviceInfo.deviceType is empty string!")
|
||||
} else {
|
||||
console.info("Device type is " + device_type)
|
||||
}
|
||||
return device_type;
|
||||
}
|
||||
|
||||
function prompt_toast(msg: string) {
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
|
@ -114,16 +89,10 @@ struct Index {
|
|||
.onLoad((xComponentContext) => {
|
||||
this.xComponentContext = xComponentContext as ServoXComponentInterface;
|
||||
let resource_dir: string = this.context.resourceDir;
|
||||
let cache_dir: string = this.context.cacheDir;
|
||||
console.debug("resourceDir: ", resource_dir);
|
||||
console.debug("cacheDir: ", cache_dir);
|
||||
let init_options: InitOpts = {
|
||||
url: this.urlToLoad,
|
||||
deviceType: get_device_type(),
|
||||
osFullName: deviceInfo.osFullName,
|
||||
displayDensity: get_density(),
|
||||
resourceDir: resource_dir,
|
||||
cacheDir: cache_dir,
|
||||
commandlineArgs: this.CommandlineArgs
|
||||
}
|
||||
this.xComponentContext.initServo(init_options)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue