[置顶] Firefox OS 学习——manifest.webapp结构分析

时间:2023-03-08 16:53:35

Firefox OS 学习——Gaia 编译分析  这篇文章多次提到manifest.webapp文件,对于做过android app 开发的人来说,都很熟悉Android.mk 和Manifest.xml文件。在Firefox OS中,manifest.webapp的作用是综合了android 中的Android.mk 和Manifest.xml的作用。下面就具体说说manifest.webapp的结构及其内容。

manifest.webapp采用的是json的数据格式(键值对的形式),它描述了app 的name,icon,loacl,premissions等相关的信息。先看一个相对完整的manifest.webapp的格式及其内容:

{
"name": "MozillaBall",
"description": "Exciting Open Web development action!",
"launch_path": "/",
"version": "1.0",
"type": "privileged",
"icons": {
"16": "/img/icon_16.png",
"48": "/img/icon_48.png",
"128": "/img/icon_128.png"
},
"developer": {
"name": "Mozilla",
"url": "https://mozilla.org/en-US"
},
"installs_allowed_from": [
"https://marketplace.mozilla.org"
"https://marketplace.example.org"
],
"appcache_path": "/cache.manifest",
"locales": [
"es": {
"description": "¡Acción abierta emocionante del desarrollo del Web!",
"developer": {
"url": "https://mozilla.org/es-ES"
}
}
"it": {
"description": "Azione aperta emozionante di sviluppo di fotoricettore!",
"developer": {
"url": "http://it.mozillalabs.com/"
}
}
],
"default_locale": "en",
"screen_size": {
"min_width": "600",
"min_height": "300"
},
"required_features": [
"touch", "geolocation", "webgl"
],
"orientation": "landscape",
"permissions": {
"contacts": {
"description": "Required for autocompletion in the share screen",
"access": "read"
}
},
"fullscreen": "true",
"activities": {
"share": {
"filters": {
"type": ["image/png", "image/gif"]
}
"href": "/share.html",
"disposition": "window"
}
}
}

属性

上述code清单中的各种属性,用法,含义,下面做详细介绍。这些属性必须包含String,其实它的属性大致可以分为两类:强制属性,可选属性。

1.强制属性

name:默认locale下,web app的名称,显示在设备中app的名称,最大支持128字符

description:默认locale下,web app的简短描述(查询了一些资料,没发现它的功能)最大支持1024字符

default_locale:设置默认的locale,确定name,description的语言环境。

2.可选属性

launch_path:指定web app被打开时,首先加载的东西,一般都是"/index.html".如果值缺省了(即"/"),将加载域名的东西。

version:web app的版本号,

type:确定这个app 和manifest如何被runtime解析,还有所使用的安全机制。它的值只能是下面三个中一个:

* web:正常的web app可以单独存在,在应用商店可以下载安装,并且会列举有限的权限。type 不指定时,默认是web。

* privileged:就像android Ios 一样单独存在的app,会在本地安装一个文件包。它需要通过应用商店的审核。

* certified:不用于第三发app中,属于系统级别的东西,例如系统设置,拨号器,电源管理等。类似android:sharedUserId 作用把。

icons:app icon,支持 16 x 16, 32 x 32, 48 x 48, 64 x 64, 128 x 128 and 256 x 256

developer:开发者相关的信息,包括开发者名称,及其URL。

installs_allowed_from:指定app可以从那些应用商店安装,"*"可以从任何地方安装," "无法从任何网站商店安装。

appcache_path:

待续