front end:firefox os :manifest.webapp

本文详细介绍了 Firefox OS 中 manifest.webapp 文件的结构与内容。解释了强制属性如 name 和 description,以及可选属性如 icons 和 permissions 的使用方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://blog.youkuaiyun.com/nxh_love/article/details/10328849

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的格式及其内容:

  1. {  
  2.     "name": "MozillaBall",  
  3.     "description": "Exciting Open Web development action!",  
  4.     "launch_path": "/",  
  5.     "version": "1.0",  
  6.     "type": "privileged",  
  7.     "icons": {  
  8.       "16": "/img/icon_16.png",  
  9.       "48": "/img/icon_48.png",  
  10.       "128": "/img/icon_128.png"  
  11.     },  
  12.     "developer": {  
  13.       "name": "Mozilla",  
  14.       "url": "https://mozilla.org/en-US"  
  15.     },  
  16.     "installs_allowed_from": [  
  17.       "https://marketplace.mozilla.org"  
  18.       "https://marketplace.example.org"  
  19.      ],  
  20.     "appcache_path": "/cache.manifest",  
  21.     "locales": [  
  22.       "es": {  
  23.         "description": "¡Acción abierta emocionante del desarrollo del Web!",  
  24.         "developer": {  
  25.           "url": "https://mozilla.org/es-ES"  
  26.         }  
  27.       }        
  28.       "it": {  
  29.         "description": "Azione aperta emozionante di sviluppo di fotoricettore!",  
  30.         "developer": {  
  31.           "url": "http://it.mozillalabs.com/"  
  32.         }  
  33.       }  
  34.     ],  
  35.     "default_locale": "en",  
  36.     "screen_size": {  
  37.       "min_width": "600",  
  38.       "min_height": "300"  
  39.     },  
  40.     "required_features": [  
  41.       "touch", "geolocation", "webgl"  
  42.     ],  
  43.     "orientation": "landscape",  
  44.     "permissions": {  
  45.       "contacts": {  
  46.         "description": "Required for autocompletion in the share screen",  
  47.         "access": "read"  
  48.       }  
  49.     },  
  50.     "fullscreen": "true",  
  51.     "activities": {  
  52.       "share": {  
  53.         "filters": {  
  54.           "type": ["image/png", "image/gif"]  
  55.         }  
  56.         "href": "/share.html",  
  57.         "disposition": "window"  
  58.       }  
  59.     }  
  60.   }  
属性

      上述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:存放app cache manifest的绝对路径,当打开安装的web app时,cache.manifest会被解析。静态的一些资源会被存放到缓存中。

      locales:重写一些locales特定的值,适应不同的语言。locales, installs_allowed_from,  default_locale是不能被重写的。如果locales被设置了,default_locale也必须被设置。

      screen_size:包含两个属性min_width,min_height,分别设置app适应的最小宽度和高度(以像素为单位)。

      required_features:包含app 能正确运行需要的一些强制属性。具体的值尚无定论。这个在app中可能用的很少。

      orientation:锁定app的屏幕方向,和android orientation的功能一样。它的值必须是下面四个中的一个或多个:

           * portrait-primary:锁定单一portrait显示。如果设备有明显的portrait,就是显示成portrait。如果设备从landscape顺时针旋转90度,app也显示portrait。

           * landscape-primary:锁定单一landscape显示。如果设备有明显的landscape,就是显示成landscape。如果设备从portrait顺时针旋转90度,app也显示landscape。

           * portrait-secondary:锁定单一portrait显示。如果设备有明显的portrait,就是显示成portrait。如果设备从landscape逆时针旋转90度,app也显示portrait。

           * landscape-secondary:锁定单一landscape显示。如果设备有明显的landscape,就是显示成landscape。如果设备从portrait逆时针旋转90度,app也显示landscape。

           * portrait:相当于["portrait-primary", "portrait-secondary"]这种组合模式。

           * landscape:相当于["landscape-primary", "landscape-secondary"]组合模式

     permissions:描述app 所需要的权限,android开发者对着部分就很熟悉了。只是的它格式和写法不同。下面给了example:

  1. "permissions": {  
  2.   "contacts": {  
  3.     "description": "Required for autocompletion in the share screen",  
  4.     "access": "readcreate"  
  5.     },  
  6.   "alarms": {  
  7.     "description": "Required to schedule notifications"  
  8.   }  
  9. }  
      permissions详细的请参照 App_permissions

      fullscreen:设置app是否全屏,只能true 或者false。默认应该是false吧(有待验证)。

      activities:指定这个app可以支持的web activities。activities命名没有什么讲究。下面给出个例子:

  1. "activities": {  
  2.       "share": {  
  3.         "filters": {  
  4.           "type": ["image/png", "image/gif"]  
  5.         }  
  6.         "href": "/share.html",  
  7.         "disposition": "window"  
  8.       }  
  9.     }  
      关于activities中的三个属性 filters, href, disposition and returnValue请参考  Activity handler description

       redirects:针对 privileged 或 certified类型 app做第三方认证。从第三方认证后需要重定向当前app URL。但是privileged 或 certified类型 app是没有可以使用的web URL,所以它只能重定向到app 内部的URL。下面给个exanple:

  1. "redirects": [  
  2.   {"from": "http://mydomain.com/oauth2/flow.html",  
  3.     "to": "/redirects/redirect.html"},  
  4.   {"from": "http://mydomain.com/oauth2/dialogs_end.html",  
  5.     "to": "/redirects/dialogs_end.html"}  
  6. ]  

       origin:针对 privileged 或 certified类型 app的属性,功能之一就是很容易通过类似的OAuth , Persona等认证。格式是app://<UUID>.example:

  1. "origin": "app://my-app.com"  
   messages:捕获系统消息作出的反映,example:

  1. "messages": [  
  2.   { "telephony-new-call": "/dialer/index.html#keyboard-view" },  
  3.   { "bluetooth-dialer-command": "/dialer/index.html#keyboard-view" },  
  4.   { "headset-button": "/dialer/index.html#keyboard-view" },  
  5.   { "notification": "/dialer/index.html#keyboard-view" },  
  6.   { "alarm": "/facebook/fb_sync.html" }  
  7. ]  
   上面的例子中,当接受的电话打进请求消息时,会弹出keyboard-view,以便用会作出接听,挂断的操作。

   chrome在屏幕底部添加一个导航栏,对于没有返回按钮的app,可以快速增加一个导航栏。

   左边的图是导航栏隐藏的时候的图,右边是显示时候的图。


到此,manifest.webapp结构的内容基本上都涉及到了。都只是粗略的弄懂概念而已,具体的细节还要在应用中去具体甄别。

参考文章:App manifest

                    Web Application Manifest Format and Management APIs                 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值