小米路由器dns错误如何通过智能检测得到错误信息呢?

艾媒咨询:2016年上半年中国智能路由器市场监测报告
艾媒咨询发布了《2016年上半年中国智能路由器市场监测报告》
本报告主要采用行业深度访谈、桌面研究等方法,并结合艾媒咨询自有的用户数据监测系统及北极星统计分析系统等。
通过对行业专家、相关企业与智能路由器产品用户进行深度访谈,了解相关行业主要情况,获得相应需要的数据。
对部分相关的公开信息进行筛选、对比,参照用户调研数据,最终通过桌面研究获得行业规模的数据。
政府数据与信息
行业公开信息
企业年报、季报
行业资深专家公开发表的观点
根据艾媒咨询自身数据库、北极星统计分析系统和草莓派调研社区平台(Strawberry Pie)的相关数据分析。
艾媒北极星:截止2016年6月底,北极星采用自主研发技术已经实现对6.23亿独立装机覆盖用户行为监测。
2016年上半年中国智能路由器行业发展现状
2016年上半年中国智能路由器用户行为分析
2016年上半年主流路由器厂商点评
2016H2中国智能路由器行业趋势预测
2016年上半年中国智能路由器行业发展现状
2016年上半年中国智能路由器行业发展动态
小米路由器3推出,4根外置天线增强信号
3月底,小米路由器3首发,定位于主流人群及市场,产品针对最日常的居家或工作环境,采用4天线设计,致力于为客户提供更好的信号以及稳定的性能。
魅族推出首款智能路由器,支持众多APP功能
6月13日,魅族发布魅蓝3S的同时,发布其首款智能路由器——魅族路由器急速版,满足基本的WiFi上网功能,还支持远程开关机和去除广告等众多APP功能。
360开办千人开发计划,上线智能路由开放平台
6月25日,360安全路由举行开发者见面会,宣布360智能路由开放平台上线,并启动千人开发计划,设立百万奖金招募开发者,丰富360路由的功能和应用。
2016年上半年中国家用路由器整体出货量超3千万
iiMedia Research(艾媒咨询)数据显示,2016年上半年家用路由器整体出货3197.2万,与去年基本持平,无明显增长。
市场销量方面,TPLINK系依旧遥遥领先,360则领跑智能路由器销量,占比为8.5%,份额略低于腾达,位居第三,其他智能路由厂商也已占到家用路由TOP10的半数,说明智能路由器正在扩大市场份额。
中国智能路由器销量比例逐步增长
iiMedia Research(艾媒咨询)数据显示,2016年上半年智能路由器销量占家用路由器市场整体销量比例达14.8%,相比2015年的9.9%和2014年的2%进一步上升,增长趋势明显。
360路由器销量领跑中国智能路由器市场
iiMedia Research(艾媒咨询)数据显示,2016年上半年,360排名智能路由器市场销量第一,占比为57.9%,小米、华为排名二、三位,各占23.8%、11.2%。在销量增长率方面,360路由器领跑市场,与去年同期相比销量增长率达143%,小米、华为紧跟其后。其他厂商份额止步不前甚至倒退,可见智能路由器行业洗牌已经显现。
下载地址1:※※密码3c4m(一共26页,大小1.24MB)
转载请注明来自 ,本文标题:
今日报告QQ交流群,微信公众号「报告来了」(微信号:baogaolaile)
关于微信公众号,查看最新行业报告
最热点击文章智能电视测试网络连结出现DNS配置错误怎么解决!解求_百度知道
智能电视测试网络连结出现DNS配置错误怎么解决!解求
我有更好的答案
把路由器的首选DNS改为114.114.114.114,备用的也是。路由器的WAN口连接网线,LAN口连接电视,DNS连接失败是因为自动获取、或手动配置的DNS失效了,如果您拨号里面的DNS是自动获取的话请手动配置,如果不是请更改当地能解析网页及其他应用的DNS。 如果自己解决不了的话。联系当地宽带运营商解决,运营商调试,是不需要收费的,请注意。
采纳率:92%
来自团队:
直接打电话找网络服务商。
手机可以上网,是无线wiFi
本回答被提问者采纳
为您推荐:
其他类似问题
dns的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。(呵呵.略文艺)
(呵呵.略文艺)
(月下美人)
(妙不可言 ?)
第三方登录:反馈成功啦!感谢您宝贵的意见或建议,我们火速处理!
提交失败!请稍候再试!
来自华为开发者联盟
OpenEE:HiLink Open Execution Environment,HiLink智能路由器开放平台。
OSGI:Open Service Gateway Initiative, 面向Java的动态模型系统。
Bundle:OSGI应用,格式是jar。
Plugin:HiLink路由器应用,其中包含了Bundle,格式是apk。
OpenEESDK:HiLink智能路由器开放平台对外开放SDK。
HiLink智能路由器构建了开放平台的运行环境,便于合作伙伴共同开发路由器应用。
本文档主要是针对OpenEE的应用开发活动进行相关指导说明,主要面向OpenEE应用开发人员。
(1) HiLink OpenEE开放平台简介
(2) HiLink路由器应用开发指导
(3) HiLink OpenEE开放接口说明
(4) 基础库开发说明
(5) 第三方协议转换应用开发指导
(6) 数据结构
(7) HiLink路由器应用Demo
HiLink OpenEE是华为HiLink智能路由器的开放运行平台,是基于OSGI动态化模块化系统搭建,OpenEE对外提供了路由器的基础功能开放接口,通过这些接口,第三方开发者可以方便快捷的开发智能路由器应用。
图1 OpenEE与Plugin交互图
Plugin通过OpenEE系统提供的开放能力接口与其交互。开放能力接口可分为两类:
(1) 事件通知接口
OpenEE中提供事件通知机制,开发者可以通过实现EventSubscriber接口来订阅事件,当该事件发生时,即可收到该事件的通知。同时开发者也可以通过调用EventPublisher接口,向系统中发送事件。
(2) 功能接口
功能接口是由OpenEE对外提供的、完成特定功能的接口,供开发者直接进行调用。例如获取设备信息、网络连接状态、启动Native进程等。这类接口通常以OSGi服务的方式对外进行提供,开发者通过获取相应的OSGi服务引用,即可以调用其功能接口。
OpenEE中使用事件Event来完成异步的消息通知机制。当特性类型的事件发生时,事件源会创建一个对应类型的Event类,并调用事件发送服务的接口将事件发送给系统。之后由系统依据各服务是否订阅了该类型的事件,完成事件的分发工作。
OpenEE中使用Event来实现异步事件通知机制。每个事件,通过一个Event对象进行描述。而接收事件的一方,称为事件订阅者EventSubscriber。
当该事件发生时,事件源生成一个Event事件,异步的post到系统事件总线上,之后由事件总线负责将其分发至订阅者。
OpenEE中,Event由以下四个属性进行描述:
事件类型,通常为Event实现类的类名,EventSubscriber就是使用Type来订阅事件的。
(2)Topic
事件主题,用来描述一个事件的基本含义,其格式如下:
hilink/{module}/{id}/{action}
Topic由四部分组成,各部分含义如下:
hilink:Event所属系统,本系统中固定为hilink;
module:Event所属的模块;
id:标识事件的ID,例如设备状态变化时,设备的ID;
action:Event的动作,如Added、Removed、Updated等。
(3)Payload
Event的负载,用来携带更详细的事件内容。常见用法时,将一个对象序列化之后,如使用Gson转换为JSON格式的字符串,再作为Payload发送。
(4)Source
事件源,标识产生该事件的事件源。对于有些复杂特性,可以通过Source过滤事件。对于不关心该属性的事件,通常直接设为null。
以USBAddedEvent事件为例,其属性如下:
//The USB device added event type.
public final static String TYPE = USBAddedEvent.class.getSimpleName();
Topic示例:
private static final String USB_ADDED_EVENT_TOPIC = "hilink/usb/disk/added";
private static final String USB_REMOVED_EVENT_TOPIC = "hilink/usb/disk/removed";
由于USB的事件不关心事件源,所有id都是“disk”。
EventSubscriber是OpenEE中接收事件的接口。路由器应用需要接收系统的Event事件时,需要实现该接口,并作为一个OSGI服务注册到系统中。
EventPublisher接口用于向OpenEE系统发送异步的Event事件通知。
OpenEE开放平台是遵循OSGi规范开发的,在OpenEE系统中,开放能力接口都是以服务的形式对外提供的。开发者要使用OpenEE的开放能力接口,首先需要理解什么是OSGi服务。
一个OSGi 服务就是注册到 OSGi 框架中的一个Java对象。OSGi框架会负责维护这些服务的生命周期,以及服务之间的依赖关系。注册的时候可以设置这个Service的属性。而在获取 Service的时候可以根据属性进行过滤。Bundle 可以通过 Bundle的上下文去注册Service或去查询Service。
服务的名称,可以是一个接口interface,也可以是一个类class。但是在注册服务时,服务必须可以被实例化。也就是说,如果服务名称是interface,注册时必须有对应的实现类。可以参考章节5.3。
开发者在使用服务接口时,首先需要获取到服务对象的引用,然后就可以直接调用这个服务提供的方法了。第五章开发指导章节中,会介绍如何获取服务。
OpenEE使用OSGi框架的PermissionAdmin权限管理服务,来管理各Plugin的运行管理。例如,文件的访问、包的import与export、服务的注册与获取、端口的访问等都是需要有相应的权限才能完成的。并且OpenEE在OSGi已有权限类型基础上,定义了OpenEE开放平台相关的权限类型,Plugin调用系统的开放能力接口,都需要具备相应的权限,从而保证整个OpenEE开放平台的安全性。
图2 HiLink智能路由器开放平台系统权限管理模块图
Plugin其中的jar包自身会带一份权限声明文件(local permission),存放位置为:resources/OSGI-INF/permissions.perm,该文件与全局权限配置文件policy共同限制Plugin的权限,除了PackagePermission只需在permissions.perm中声明,其他的权限必须在两者中都声明才有效。
OpenEE开放平台的权限管理主要依赖Java架构提供的安全管理器SecurityManager,以及在此基础之上由OSGI架构提供的安全管理服务PermissionAdmin,完成整理系统的安全管理。
除了支持OSGI定义的权限,还支持java原生权限以及自定义权限,OSGI与java原生的权限由系统SecurityManager的checkPermission方法去检查,自定义权限的检查类PermissionChecker封装了SecurityManager的checkPermission方法,自定义权限在每个对应的入口调用PermissionChecker进行检查。
通过eclipse导入maven工程的选项导入附件中的Demo工程,直接在其上修改开发,根据业务需求增删Demo中的相关内容。
helloworld项目结构如下:
图3 helloworld工程结构图
该目录下是项目代码路径,上述中的Activator相当于Plugin的初始化和注销类:
public class Activator
implements BundleActivator{
public void start(BundleContext context) throws Exception {
System.out.println("helloworld start.");
//TODO:做一些初始化动作
public void stop(BundleContext context) throws Exception {
System.out.println("helloworld stop.");
//TODO:做一些Plugin停止后的注销动作
在项目中,可以选择不实现Activator,在服务类的activate、deactivate方法中做初始化和注销动作也是一样的:
protected void activate() {
//TODO:做一些初始化动作
protected void deactivate() {
//TODO:做一些Plugin停止后的注销动作
在上述两者同时存在时,优先执行Activator。
此处是Plugin服务声明xml文件放置的地方,有三类服务声明:
(1) 声明引用其他的服务
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.huawei.hilink.helloworld.SystemInfoTester"&
&implementation
class="com.huawei.hilink.helloworld.SystemInfoTester" /&
&reference bind="setSystemInfo" cardinality="1..1"
interface="com.huawei.hilink.openapi.system.SystemInfo" name="SystemInfo"
policy="static" unbind="unsetSystemInfo" /&
&/scr:component&
上述是com.huawei.hilink.helloworld.SystemInfoTester这个类声明引用com.huawei.hilink.openapi.system.SystemInfo这个服务。
(2) 声明实现其他的服务接口
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.demo.Activator"&
&implementation
class="com.demo.Activator" /&
&provide interface="com.huawei.hilink.event.EventSubscriber" /&
&/service&
&/scr:component&
上述是com.demo.Activator这个类声明实现com.huawei.hilink.event.EventSubscriber这个服务接口类。
(3) 声明自己的服务
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.demo.ServicesTester"&
&implementation
class="com.demo.ServicesTester " /&
&provide interface="com.demo.ServicesTester" /&
&/service&
&/scr:component&
上述是com.demo.ServicesTester这个类将自己声明为服务,以供别人引用,& implementation/&中的类也可以是&service&&/service&中声明服务类的实现类,&service&&/service&对外提供的是接口类。
上述1、2、3中,1可以和2或3写在一个xml中。
该文件是权限声明文件,具体见5.4章节。
uiURL= http://xxxxx.html
apiLevel=1
pkgName=com.huawei.hilink.demo.helloworld
versionName=1.0.0
versionCode=1
commName=Slave.OpenEEDebug
uiURL:声明该Plugin的控制H5页面的路径,如果没有单独的控制页面,则需要填入介绍页面的地址。
由于Plugin jar包最终需要打包成apk,所以有些信息需要和android真正的apk包保持一致:
apiLevel:该字段是声明Plugin是基于OpenEESDK哪个版本的接口开发的,类似于android的API Level.
pkgName:该字段是Plugin的包名,同android的pkgName.
versionName:Plugin对外显示的版本名称,同android的versionName.
versionCode:Plugin版本号,用于版本升级比较,同android的versionCode.
commName:Plugin apk签名的证书名common name,每个合作厂商单独申请一份证书。
如果Plugin java层需要加载Plugin自带的库文件,那么需要放在该目录下,该目录又根据平台架构分为arm和mips,所以如果该Plugin在两种平台上都支持,那么arm和mips目录中需要各自放入对应平台工具链编译出的库文件。
如果Plugin需要拉起native进程,那么进程文件需要放在该目录下,arm和mips的说明同上小节。
pom.xml文件是Maven进行工作的主要配置文件。项目依赖的信息和一些基本信息都是在这个文件里面定义的。在这个文件中我们可以配置Maven项目的groupId、artifactId和version等Maven项目必须的元素;可以配置Maven项目需要使用的远程仓库;可以定义Maven项目打包的形式;可以定义Maven项目的资源依赖关系等等。
pom文件内容如下,包含四个部分:基础设置、build设置、项目信息、环境设置。
图4 pom.xml文件结构图
1) 基本设置
groupId、artifactId和version构成了Maven的坐标,指定了组件在Maven仓库中的位置。Maven中的每个组件都有一个坐标,通过这个坐标我们在自己的项目中可以设置对该组件的依赖。
groupId:项目属于哪个组,往往和项目所在公司相关,并且构建时生成的路径也是由此生成,如com.huawei.atp,则生成的相对路径为:/com/huawei/atp;
artifactId:当前Maven项目在组中唯一的ID,建议以bundle实际功能命名;
version:项目当前版本;
packaging:项目产生的构件类型,例如jar、war、ear、pom、bundle等,此处填bundle。
用于描述该bundle依赖哪些其它的bundle并自动进行下载,依赖也是通过GAV来定位的。由于是基于OSGi框架下开发,因此,每个bundle都需要依赖于org.osgi,并且指定版本为3.0.0,对应OSGi的R3版本,其他依赖包则根据相关工程而定。
pom继承与聚合
Pom的继承与聚合是多项目管理需要设置的,即上节中的&parent&和&modules&模块。在maven中使用继承时,需要设置总项目下的pom.xml文件的packaging参数为&packaging&pom&/packaging&类型,这样子项目就可以继承该pom了。
2) build设置
build设置中和我们相关的主要是plugin参数,主要的设置如下所示:
图5 Build设置图
红色部分通过maven-compiler-plugin来把.java文件编译成.class文件,可以指定jdk版本,红色部分是可选部分;蓝色部分通过maven-bundle-plugin则用于生成最终的jar包,其中包括.class文件以及MANIFEST.MF文件,如果没有指定生成目录,则默认生成在target\classes目录下。
Maven中还提供了很多其他的bundle,如maven-dependency-plugin帮助分析项目依赖,maven-javadoc-plugin生成JavaDoc文档等。具体可以参考:
3) 项目信息
这个部分主要是用于一些信息的拓展,主要是有以下一些元素:
name:项目名称;
description:项目描述信息;
url:项目所在的url;
inceptionYear:项目的开始日期;
licenses:项目使用和被使用的法律文件;
organization:项目所在组织的基本信息;
developers:项目的核心开发者信息;
contributors:项目的辅助人员信息;
4) 环境设置
pom文件的环境设置包括以下几个方面:
Issue Management:使用缺陷跟踪系统(Bugzilla,TestTrack,ClearQuest,等)信息,主要用于产生项目文档;
Continuous Integration Management:ci管理使用notfier方式来通知告知构建状态的改变;
Mailing Lists:定义了该项目需要保持联系的人员,主要是开发人员和用户的邮件列表;
SCM:主要用于对源码的管理、版本的控制,可以支持常用的SVN、CVS等;
Prerequisites:定义了maven工程正确执行的先决条件,比如要求的maven版本;
Distribution Management:主要是对生成的组件的管理和分发,可以把编译的bundle包deploy到ATP镜像仓上;
Profiles:根据相应的环境对应的改变构建时的设置,如根据jdk使用的版本从不同的仓中获取依赖包;
我们主要是要掌握pom文件中的基本设置和build设置,后面两种需要了解,关于pom更具体的信息可以查看:
完整的pom.xml示例:
&?xml version="1.0" encoding="UTF-8"?&
&project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"&
&modelVersion&4.0.0&/modelVersion&
&groupId&com.huawei.hilink&/groupId&
&artifactId&helloworld&/artifactId&
&version&1.0.0&/version&
&packaging&bundle&/packaging&
&name&helloworld&/name&
&description&helloworld for HUAWEI HiLink&/description&
&groupId&org.apache.maven.plugins&/groupId&
&artifactId&maven-compiler-plugin&/artifactId&
&configuration&
&source&1.7&/source&
&target&1.7&/target&
&optimize&true&/optimize&
&debug&false&/debug&
&/configuration&
&groupId&org.apache.felix&/groupId&
&artifactId&maven-bundle-plugin&/artifactId&
&version&2.0.1&/version&
&extensions&true&/extensions&
&configuration&
&instructions&
&bundleName&{project.name}&/bundleName&
&bundleDescription&{project.description}&/bundleDescription&
&bundleVendor&HUAWEI&/bundleVendor&
&Bundle-Activator&com.huawei.hilink.helloworld.Activator&/Bundle-Activator&
&Service-Component&OSGI-INF/xxx.xml, OSGI-INF/xxx2.xml
&/Service-Component&
&/instructions&
&/configuration&
&/plugins&
&!—下面所依赖的库版本version根据实际提供的OpenEESDK中的版本来填写--&
&dependencies&
&dependency&
&groupId&org.apache.felix&/groupId&
&artifactId&org.apache.felix.main&/artifactId&
&version&5.4.0&/version&
&/dependency&
&dependency&
&groupId&com.huawei.hilink&/groupId&
&artifactId&com.huawei.hilink.openapi&/artifactId&
&version&1.0.0&/version&
&/dependency&
&dependency&
&groupId&com.google.code.gson&/groupId&
&artifactId&gson&/artifactId&
&version&2.3.1&/version&
&/dependency&
&/dependencies&
&/project&
本章节介绍了服务的使用方法,并以EventPublisher服务为例,举例说明如何使用服务接口。
为了使用EventPublisher服务,首先需要将定义该服务的Bundle加入到依赖中来。EventPublisher服务定义在com.huawei.hilink.openapi包中,因此,在应用的pom.xml配置文件中,添加如下配置:
&dependency&
&groupId&com.huawei.hilink&/groupId&
&artifactId&com.huawei.hilink.openapi&/artifactId&
&version&1.0.0&/version&
&/dependency&
使用Declarative Services方式获取服务时,首先使用者也必须声明为服务,然后在该服务的配置文件中,声明需要引用的服务名。之后,系统会负责完成服务的依赖关系解析、启动服务等动作。
使用Declarative Services步骤如下:
(1) 编写服务实现类
示例代码:
package com.huawei.hilink.samples.
import com.huawei.hilink.event.EventP
public class ServiceTest {
private EventPublisher eventP
// ServiceTest初始化调用的第一个方法,可以在该方法中做一些初始化动作,由框架调用
protected void activate() {
// ServiceTest注销时调用的方法,可以在该方法中做一些注销动作,由框架调用
protected void deactivate() {
// 获取服务,由框架调用
protected void setEventPublisher(EventPublisher eventPublisher) {
this.eventPublisher = eventP
// 注销服务,由框架调用
protected void unsetEventPublisher(EventPublisher eventPublisher) {
this.eventPublisher =
Activate方法用于在服务启动时进行一些初始化动作,而deactivate方法用于服务退出时进行资源回收。这两个方法不是必需的,如果没有特殊的动作需要在activate于deactivate中完成,可以不实现这两个方法。
另外,activate于deactivate还支持SCR的实现方式,如果在服务中需要使用到bundle的上下文BundleContext,就需要使用这种方式。示例如下:
import org.osgi.framework.BundleC
import org.osgi.service.component.ComponentC
protected void activate(ComponentContext componentContext) {
BundleContext bundleContext = componentContext.getBundleContext();
protected void deactivate(ComponentContext componentContext) {
如果用这种方式,需要在bundle的pom.xml中添加对SCR的依赖。
&dependency&
&groupId&org.apache.felix&/groupId&
&artifactId&org.apache.felix.scr&/artifactId&
&version&1.8.2&/version&
&/dependency&
(2) 编写服务XML文件
在Plugin的resources/OSGI-INF/目录下,新建服务的XML文件;
图6 OSGI-INF路径示例图
ServiceTest.xml示例:
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true" activate="activate" deactivate="deactivate"
name="com.huawei.hilink.samples.service.ServiceTest"&
&implementation
class="com.huawei.hilink.samples.service.ServiceTest" /&
&reference bind="setEventPublisher" cardinality="1..1"
interface="com.huawei.hilink.event.EventPublisher" name="EventPublisher"
policy="dynamic" unbind="unsetEventPublisher" /&
&/scr:component&
在xml文件中,通过reference配置该服务所引用的服务。上述例子中,ServiceTest服务引用了EventPublisher服务。当EventPublisher服务启动后,OSGI系统会通过指定的bind方法,将EventPublisher服务的句柄传给ServiceTest服务。
(3) 配置OSGI-INF信息
在bundle的描述文件META-INF/MANIFEST.MF中增加component相关的header:
Service-Component: OSGI-INF/xx.xml
按照以上步骤完成后,OSGI框架会自动根据Bundle的XML配置文件,自动管理各个服务的依赖关系。该方法虽然需要修改多个地方,但是不会出错,声明方式更加规范,建议使用该方法声明。
上述3种方式都需要声明权限:
(com.huawei.hilink.event.EventPublisher " "get")
OpenEE系统用到的权限如下:下图中白色部分为osgi和openee提供的权限,灰色部分为常用的java原生权限。
PackagePermission
org.osgi.framework.PackagePermission
import,export
包权限,如:import、export的权限
ServicePermission
org.osgi.framework.ServicePermission
get,register
服务权限,如:get、register的权限
RESTPermission
com.huawei.hilink.coreapi.perm.RESTPermission
REST接口权限,使用系统提供的REST接口所需的权限
USBPermission
com.huawei.hilink.coreapi.perm. USBPermission
USB权限,访问USB存储设备的权限
SystemInfoPermission
com.huawei.hilink.coreapi.perm.SystemInfoPermission
ver,系统版本host, 网关HostInfodev,网关deviceInfocap,网关能力集wlan,网关网络信息lnhst,网关lan侧地址信息topology,网关拓扑图信息
系统信息权限,获取路由器系统信息的权限
NativePermission
com.huawei.hilink.coreapi.perm.NativePermission
usb,native进程读写usb的权限。
native进程权限,目前只有USB权限。
DevAdminByDevTypePermission
com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission
设备类型,多个以逗号隔开
get,获取control,控制observe,监听
设备管理权限,包含获取设备列表和数据,控制设备,监听设备状态、数据变化。
DevAdminBySerTypePermission
com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission
服务类型,多个以逗号隔开
get,获取control,控制observe,监听
HiLinkWiFiPermission
com.huawei.hilink.coreapi.perm.HiLinkWiFiPermission
路由器WiFi能力获取
FilePermission
java.io.FilePermission
write,read,delete
文件系统访问权限,对文件或目录的读、写、删除的操作权限
SocketPermission
java.net.SocketPermission
&ip&: &port&
accept,connect,listen,resolve
访问网络权限
PropertyPermission
java.util.PropertyPermission
write,read
获取系统属性信息,比如java.home, os.name等
RuntimePermission
java.lang.RuntimePermission
stopThread, getClassLoader,………
获取运行时权限,比如停止进程,取得Class对象的类装载器等
其他所有java权限
表1 OpenEE系统权限列表
Plugin Jar包自身会带一份权限声明文件,存放位置为:
resources/OSGI-INF/permissions.perm
Plugin需要在该文件中声明运行所需要的所有权限。如果没有声明,系统会默认Plugin不具备相应的权限,从而导致Plugin运行出错。
权限是在运行的时候去检查。声明权限的格式如下:
“Url” “Action”)
Type : 完整类名
Url: 目标路径
Action: 动作
(java.io.FilePermission "/var/run/msg.txt" "read,write")
声明对/var/run/msg.txt有读写权限
perm文件格式参考如下示例:
(org.osgi.framework.PackagePermission "*" "import")
org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.nativelauncher.NativeLauncher" "get")
(org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.system.SystemInfo" "get")
(org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.usbstorage.USBStorage" "get")
(org.osgi.framework.ServicePermission "com. huawei.hilink.demo.ServicesTester" "register")
(org.osgi.framework.ServicePermission "com.huawei.hilink.event.EventSubscriber" "register")
(java.net.SocketPermission "localhost:46740" "connect,resolve,accept,listen")
(java.lang.RuntimePermission
"stopThread ")
(java.lang.RuntimePermission
"modifyThread")
(com.huawei.hilink.coreapi.perm.USBPermission "*" "list")
(com.huawei.hilink.coreapi.perm.SystemInfoPermission "*" "wlan,dev,host")
(com.huawei.hilink.coreapi.perm.RESTPermission "/api/shp/devices" "get")
(com.huawei.hilink.coreapi.perm.RESTPermission "/api/shp/devices/-" "get")
每一行表示一个权限,不能换行。如果要注释掉某个权限,可以使用“#”或者 “//”。
Plugin安装成功之后,会在智能家居APP工具箱下的扩展工具中显示出来(如图7),点击Plugin图标,会跳到Plugin的H5页面(如图8),该页面地址即为5.2.4章节中uiURL值。
图7 扩展工具显示已安装Plugin
图8 Plugin操作H5页面
第三方Plugin的页面都是放在自己的服务器上,点击已安装Plugin图标时,智能家居APP拉起该H5页面显示,该Plugin页面分为三类:
第一类:第三方协议驱动Plugin,那么该H5页面只是一个介绍页面,对第三方接入的设备的控制是在智能家居APP首页上。
第二类:Plugin的控制端是第三方自己的APP或者终端,那么该H5页面只是一个介绍页面,第三方自己的终端可以通过长连接和Plugin通信交互,或者依赖服务器转发。
第三类:除了第一类和第二类的Plugin,那么该H5页面即为该Plugin的操作控制界面,在H5页面上的操作命令都需要依赖第三方服务器转发,通过Plugin和第三方服务器之间的长连接来向Plugin下达控制命令或者是在H5页面上显示信息,交互示意图如下图9:
图9 Plugin H5页面交互示意图
Plugin正式商用需要上传到华为应用市场,所以需要图标截图等资源
(1)图标规格:方形圆角,(32位 (216w*216h) PNG图片)
图10 Plugin图标示例图
(2)截图规格:32 bit (720w*1280h以及480*800各一份) 最大 2MB JPG图片, 截图不能包含iOS元素,通知栏去除与应用无关图标,至少3张截图。
图11 Plugin截图示例图
(3)Plugin还需要提供简介和详细介绍,简介不超过60个字,详细介绍不超过1000个字。
HiLink OpenEE对外提供的开放能力接口都定义在com.huawei.hilink.openapi包中。开发者在使用开放能力接口时,首先需要加入包的依赖。下面对OpenEE的开放能力接口进行详细介绍。
OpenEE系统提供下列事件类型:
USBAddedEvent
USBAddedEvent
USB存储设备插入
USBRemovedEvent
USBRemovedEvent
USB存储设备拔出
WANUpEvent
WANUpEvent
WANDwonEvent
WANDwonEvent
SystemRebootEvent
SystemRebootEvent
SystemRestoreEvent
SystemRestoreEvent
系统恢复出厂配置
LANUpdateEvent
LANUpdateEvent
LAN地址改变
表2 Plugin系统事件类型列表
开发者需要关心某个事件类型时,只需要实现EventSubscriber接口,并将其作为服务注册到系统中。这样在事件发生时,就可以收到相应的事件通知,Event结构体。
public class DemoServices implements EventSubscriber {
// subscribe events
private final Set&String& eventTypes = CollectionUtil
.newUnmodifiableSet(new String[] { USBAddedEvent.TYPE,
USBRemovedEvent.TYPE, WANUpEvent.TYPE, WANDownEvent.TYPE,WifiRssiEvent.TYPE});
public Set&String& getSubscribedEventTypes() {
return this.eventT
// event filter
public EventFilter getEventFilter() {
return eventF
private EventFilter eventFilter = new EventFilter() {
public boolean apply(Event event) {
//TODO:filter event
// receive subscribed events.
public void receive(Event paramEvent) {
if (paramEvent.getType().equals(USBAddedEvent.TYPE)) {
System.out.println("USB added.");
} else if (paramEvent.getType().equals(WifiRssiEvent.TYPE)) {
//get event body.
String payload = paramEvent.getPayload();
System.out.println("other event.");
声明服务:(src/main/resources/OSGI-INF/DemoServices.xml)
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.huawei.hilink.demo.DemoServices"&
&implementation
class="com.huawei.hilink.demo.DemoServices" /&
&provide interface="com.huawei.hilink.event.EventSubscriber" /&
&/service&
&/scr:component&
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
(org.osgi.framework.ServicePermission "com.huawei.hilink.event.EventSubscriber" "register")
服务名称:
com.huawei.hilink.openapi.system.SystemInfo
SystemInfo服务提供获取路由器系统信息的接口。主要接口如下:
(1) getDeviceInfo(),获取路由器设备信息。包括设备型号、名称、序列号、软件版本号。
(2) getWANInfo(),获取路由器WAN信息。如WAN口状态、接入类型、IP地址、MAC地址。
(3) getBandwidthInfo(),获取路由器带宽信息。如上行带宽、下行带宽、自动测速带宽。
(4) getWLANInfos(),获取路由器WLAN信息。包括SSID名称、类型、加密方式。
(5) getHostInfos(),获取接入路由器的设备信息。包括接入设备的状态、名称、MAC地址,以及智能家居设备信息中的房间及设备类型信息。
(6) getLANHostInfo(),获取路由器LAN侧地址信息。包括IP、掩码、MAC地址。
(7) getTopoLogyInfos(), 获取路由器连接设备的拓扑信息。
返回的系统信息结构见、、、、、、章节。
private SystemInfo systemInfoHandle =
protected void activate() {
DeviceInfo deviceInfo = systemInfoHandle.getDeviceInfo();
List&HostInfo& hostInfos = systemInfoHandle.getHostInfos();
LANHostInfo lanHost = systemInfoHandle.getLANHostInfo();
WANInfo wanInfo = systemInfoHandle.getWANInfo();
List&WLANInfo& wlanInfos = systemInfoHandle.getWLANInfos();
List&TopoLogyInfo& topoLogyInfos = systemInfoHandle.getTopoLogyInfos ();
//获取SystemInfo服务句柄
protected void setSystemInfo(SystemInfo systemInfo) {
systemInfoHandle = systemI
//注销SystemInfo服务句柄
protected void unsetSystemInfo(SystemInfo systemInfo) {
systemInfoHandle =
声明服务:(src/main/resources/OSGI-INF/SystemInfoTester.xml)
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.huawei.hilink.helloworld.SystemInfoTester"&
&implementation
class="com.huawei.hilink.helloworld.SystemInfoTester" /&
&reference bind="setSystemInfo" cardinality="1..1"
interface="com.huawei.hilink.openapi.system.SystemInfo" name="SystemInfo"
policy="dynamic" unbind="unsetSystemInfo" /&
&/scr:component&
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
(org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.system.SystemInfo" "get")
(com.huawei.hilink.coreapi.perm.SystemInfoPermission "*" "dev,host,lnhst,wlan,wan,topology")
服务名称:
com.huawei.hilink.openapi.usbstorage.USBStorage
USBStorage服务提供查询系统当前USB存储设备信息的接口。开发者通过开服务查询系统当前解决的USB存在设备信息,例如分区类型、挂载路径、总空间以及可用空间等。USBDiskVolume结构体见章节。
private USBStorage usbStorageHandle =
protected void activate() {
List&USBDiskVolume& usbDiskList = this.usbStorageHandle.getDiskVolumes();
//获取USBStorage服务句柄
protected void setUSBStorage(USBStorage usbStorage) {
this.usbStorageHandle = usbS
//注销USBStorage服务句柄
protected void unsetUSBStorage(USBStorage usbStorage) {
this.usbStorageHandle =
声明服务:(src/main/resources/OSGI-INF/USBStorageTester.xml)
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.huawei.hilink.helloworld.USBStorageTester"&
&implementation
class="com.huawei.hilink.helloworld.USBStorageTester" /&
&reference bind="setUSBStorage" cardinality="1..1"
interface="com.huawei.hilink.openapi.usbstorage.USBStorage" name="USBStorage"
policy="dynamic" unbind="unsetUSBStorage" /&
&/scr:component&
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
(org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.usbstorage.USBStorage" "get")
服务名称:
com.huawei.hilink.openapi.nativelauncher.NativeLauncher
NativeLauncher服务提供管理Plugin Native进程的接口。主要接口如下:
(1) 启动Plugin Native进程。
(2) 停止Plugin Native本地进程。
LaunchedProcess结构体见章节。
private NativeLauncher nativeLauncherHandle = ;//NativeLauncher服务句柄
private LaunchedProcess process =//启动的进程句柄
protected void activate() {
//启动方法1:参数1是进程文件名,参数2是进程传入的参数,参数3是进程退出的监听方法类
this.process = nativeLauncherHandle.launch("processname", new String[] {"args1","args2","args3"}, new NativeLauncherCallback(){
public void onLaunchEvent(int isNormalExit) {
//-1:进程退出.
//启动方法2:不需要进程退出监听
this.process = nativeLauncherHandle.launch("processname", new String[] {"args1","args2","args3"});
protected void deactivate() {
//停止进程
this.nativeLauncherHandle.stop(process);
//获取NativeLauncher服务句柄
protected void setNativeLauncher(NativeLauncher nativeLauncher) {
this.nativeLauncherHandle = nativeL
//注销NativeLauncher服务句柄
protected void unsetNativeLauncher(NativeLauncher nativeLauncher) {
this.nativeLauncherHandle =
声明服务:(src/main/resources/OSGI-INF/NativeTester.xml)
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.huawei.hilink.helloworld.NativeTester"&
&implementation
class="com.huawei.hilink.helloworld.NativeTester" /&
&reference bind="setNativeLauncher" cardinality="1..1"
interface="com.huawei.hilink.openapi.nativelauncher.NativeLauncher" name="NativeLauncher"
policy="dynamic" unbind="unsetNativeLauncher " /&
&/scr:component&
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
(org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.nativelauncher.NativeLauncher" "get")
//如果native进程想要有USB的读写权限,则需要单独声明NativePermission
(com.huawei.hilink.coreapi.perm.NativePermission "*" "usb")
服务名称:
com.huawei.hilink.openapi.plugin.PluginListener
该接口提供了三个方法,getBundleId(),unInstall()和createUIURL(String uiURL)。
getBundleId():获取Plugin的Bundle Id,用于找到对应的Plugin。
unInstall():Plugin被系统卸载之前该方法会被触发,用于Plugin在卸载之前的进行一些恢复默认等操作。
createUIURL(String uiURL):应用需要动态生成H5页面时,需要实现该方法来自定义生成Plugin的H5页面的url,返回的结果是自定义后的url,当不需要动态生成H5页面时,可以直接返回null,入参为在Plugin信息bundleInfo.properties文件中的uiURl字段的值。
实现了该接口之后,需要实现以上三个方法,getBundleId()需要使用Plugin的Activator中的BundleContext来获取,并且需要在pom.xml中声明实现了该接口服务。
public class Activator implements BundleActivator,PluginListener {
private static BundleContext contextHandle =
public void start(BundleContext context) throws Exception {
contextHandle =
public void stop(BundleContext context) throws Exception {
public long getBundleId() {
Bundle bundle = contextHandle.getBundle();
if(null == bundle){
return bundle.getBundleId();
public void unInstall() {
public String createUIURL(String uiURL) {
return uiURL+"1234";//各应用根据业务需求自定义
声明服务:(src/main/resources/OSGI-INF/Activator.xml)
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.demo.Activator"&
&implementation
class="com.demo.Activator" /&
&provide interface="com.huawei.hilink.openapi.plugin.PluginListener" /&
&/service&
&/scr:component&
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
(org.osgi.framework.ServicePermission " com.huawei.hilink.openapi.plugin.PluginListener " "register")
服务名称:
com.huawei.hilink.openapi.rest.Restful
该接口是调用restful接口,有get和post,用于获取信息或者是下发命令。获取服务句柄之后,通过request方法发送POST或者GET命令。
private Restful restfulHandle =//Restful服务句柄
protected void activate() {
String response = restfulHandle.request("GET", "/xxx1/xxx1", null);
//POST接口
String response = restfulHandle.request("POST", "/xxx2/xxx2", "{\"action\":\"create\",\
"data\":{"{\"xx\":\"xx\",\"xx\":\"xx\"}}");
protected void deactivate() {
//获取Restful服务句柄
protected void setRestful(Restful restful) {
this.restfulHandle =
//注销Restful服务句柄
protected void unsetRestful(Restful restful) {
this.restfulHandle =
声明服务:(src/main/resources/OSGI-INF/RestfulTester.xml)
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.demo.RestfulTester"&
&implementation
class="com.demo.RestfulTester" /&
&reference bind="setRestful" cardinality="1..1"
interface="com.huawei.hilink.openapi.rest.Restful" name="Restful"
policy="dynamic" unbind="unsetRestful" /&
&/scr:component&
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
(org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.rest.Restful" "get")
//声明调用的GET接口权限
(com.huawei.hilink.coreapi.perm.RESTPermission "/xxx1/xxx1" "get")
//声明调用的POST接口权限
(com.huawei.hilink.coreapi.perm.RESTPermission "/xxx2/xxx2" "post")
服务名称:
com.huawei.hilink.rest.AbstractRESTResource
该接口是提供给用户继承实现,用户通过实现该接口,可以自定义实现resful请求。
其中有两个要点:
1:注册restful模块名,也就是以什么为前缀的restful请求才能被接受处理,比如以注册模块名为test,那么只接受以/api/openee/thirdparty/包名/test为开头的restful请求(/api/openee/thirdparty这一段是所有的接口都固定)
2:注册restful接口以及处理方法,主要是在构造方法中实现buildDescriptor,参数如下:
public void buildDescriptor(String uriPattern, int httpCode, Class&?& bodyClass, String methodName);
uriPattern
Restful请求url(不包含/api/openee这一段)
请求类型,是获取数据的请求还是控制命令的请求等,可选值:HTTP_GET、HTTP_POST、HTTP_PUT、HTTP_DELETE
请求报文体的格式,会以一个类的结构来接受,GET请求此处填null。控制请求,比如请求body格式为{“args1”: “cc”, args2”: 1},那么可以定义一个类OrderTestDTO,里面有两成员String args1,Integer args2,那么此处填OrderTestDTO.class
methodName
处理该restful请求的方法名
public class RestfulResourceTester extends AbstractRESTResource {
* this function will execute first when this class load.
public void activate() {
* this function will execute last when this class unload.
public void deactivate() {
public RestfulResourceTester() {
super("test");
//用来订阅Plugin restful模块名,每个Plugin必须唯一,最好能够标识该Plugin
// 获取请求
buildDescriptor("/test/infos", HTTP_GET, null, "getTestInfos");
// 控制请求,此处请求方发过来的body是json格式,buildDescriptor会自动将该body构造成
OrderTestDTO传到orderFunction方法
buildDescriptor("/test/order ", HTTP_PUT, OrderTestDTO.class, "orderFunction");
* get all test info
* GET Path: /api/openee/thirdparty/com.xxx.xxx/test/infos
Body: null
* @return {@link RestResponse }
public Response getTestInfos () {
/* 对restful请求进行相关数据处理,返回testinfo值。
* 成功返回get的数据,此处是以TestInfo的形式返回,
* Response内部会将该结构体转化为json字符串返回请求方
return Response.ok(new TestInfo(…)).build();
//return Response.forbidden().build();请求拒绝
//return Response.badRequest().build();请求非法
* 控制请求
* Path: /api/openee/thirdparty/com.xxx.xxx/test/orger
* Body: OrderTestDTO
* @return {@link Response }
public Response orderFunction (OrderTestDTO dto) {
/*对restful请求进行相关处理,返回执行成功与否的回复*/
return Response.ok().build();//返回成功
//return Response.forbidden().build();请求拒绝
//return Response.badRequest().build();请求非法
class OrderTestDTO {
private String args1;
private Integer args2;
*默认构造函数,不要删除.
public OrderTestDTO() {
public String getArgs1 () {
return args1;
public Interger getArgs2 () {
return args2;
上述Response为请求的response响应类:
com.huawei.hilink.rest.Response
返回有以下方式
请求处理成功:Response.ok().build();请求处理成功并返回所需要的内容:Response.ok(new TestInfo(…)).build();此处TestInfo类是构造返回相应的值,会直接转成json字符串返回(同上面描述的OrderTestDTO类相反)
serverError
服务器错误,Response.serverError().build();
无内容,Response.noContent ().build();
未找到,Response.notFound ().build();
badRequest
非法请求,Response.badRequest ().build();
请求拒绝,Response.forbidden ().build();
其他失败,Response.failed().build();
使用AbstractRESTResource需要声明实现com.huawei.hilink.rest.RESTResource服务:
(src/main/resources/OSGI-INF/RestfulResourceTester.xml)
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.demo.RestfulResourceTester"&
&implementation
class="com.demo.RestfulResourceTester" /&
&provide interface="com.huawei.hilink.rest.RESTResource"/&
&/service&
&/scr:component&
需要声明服务注册权限:(src/main/resources/OSGI-INF/permissions.perm)
(org.osgi.framework.ServicePermission "com.huawei.hilink.rest.RESTResource" "register")
接口名称:
com.huawei.hilink.util.Logger
Logger接口提供日志功能。与上述其他服务类接口不同的是,Logger接口是通过工厂类提供的接口。'
* used for print log info.
private static final Logger logger = LoggerFactory
.getLogger(LoggerTester.class.getSimpleName());
private void func(String args1,Object args2) {
logger.error("xxxxxx exception {}!", new Exception(“xxxx”));
logger.error("xxxxxx exception {}!", new Throwable(“xxxx”));
logger.debug("xxx {}.", args1);
logger.warn("xxx {} xx {} xxx.", args1,args2);
logger.info("xxxxxx.");
接口名称:
com.huawei.hilink.util.LibraryUtil
该接口也是通过一般类接口来调用的,是用来获取native库文件路径,该库源文件是打包到Plugin jar包中,安装Plugin时会自动解压到Plugin运行的data/lib目录下,以便加载。
//获取库文件libsoname.so的路径
String libPath = new LibraryUtil().getLibPath("soname");
System.load(libPath); //加载
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
//声明加载动态库的权限
(java.lang.RuntimePermission "loadLibrary.*")
com.huawei.hilink.openapi.device.HiLinkDeviceMngr
该接口是以服务形式发布的,需要以服务形式调用。
声明服务:(src/main/resources/OSGI-INF/HiLinkDeviceTester.xml)
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="com.demo.HiLinkDeviceTester"&
&implementation
class="com.demo. HiLinkDeviceTester " /&
&reference bind="setHiLinkDeviceMngr" cardinality="1..1"
interface="com.huawei.hilink.openapi.device.HiLinkDeviceMngr" name=" HiLinkDeviceMngr "
policy="dynamic" unbind="unsetHiLinkDeviceMngr " /&
&/scr:component&
声明权限:(src/main/resources/OSGI-INF/permissions.perm)
//声明获取HiLinkDeviceMngr服务权限
(org.osgi.framework.ServicePermission "com.huawei.hilink.openapi.device.HiLinkDeviceMngr" "get")
Public methods
getAllDevices() 获取所有的设备列表。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission "*" "get")或者(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "*" "get")
getDevice( uid)根据HiLinkDeviceUID获取设备信息。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission "deviceType" "get")或者(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission " serviceType" "get")其中deviceType是需要获取设备的类型,即UID的第一段,serviceType是该设备所有服务类型的子集(多个以逗号隔开)
getDevicesByDevType(String deviceType)根据设备类型获取设备列表。deviceType只能传单个。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission "deviceType" "get")deviceType即为接口参数deviceType
getDevicesBySerType(String serviceType)根据服务类型获取设备列表。serviceType只能传单个。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "serviceType" "get")serviceType即为接口参数serviceType
Public methods
getDeviceData( uid)获取指定设备所有服务的数据,比如某台空调的温度,风速等。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission "deviceType " "get")或者(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "serviceType" "get")其中deviceType是需要获取设备的类型,即UID的第一段,serviceType是该设备所有服务类型的子集(多个以逗号隔开)
getDeviceDataBySerID( uid, String serviceId)根据HiLinkDeviceUID和指定服务获取设备服务数据,比如只获取某台空调的风速值。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission "deviceType" "get")或者(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission " serviceType" "get")其中deviceType是需要获取设备的类型,即UID的第一段,serviceType是该serviceId对应的serviceType
Public methods
command( uid,
cmd)对指定设备下发控制命令。返回执行后的结果,见章节错误码。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "deviceType" "control")或者(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "serviceType" "control")其中deviceType是需要控制的设备的类型,即UID的第一段,serviceType是该设备所有服务类型的子集(多个以逗号隔开)
Public methods
addDeviceListner(DeviceEventListner listner)添加所有设备的事件监听器。最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission "*" "observe")或者(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "*" "observe")
addDeviceListnerBySerTypes(String serviceType, DeviceEventListner listner)添加提供指定服务的设备事件监听器。serviceType可传多个,以逗号隔开最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "serviceType" "observe")serviceType即为接口参数serviceType
addDeviceListnerByDevTypes(String deviceType, DeviceEventListner listner)添加提供指定设备类型的设备事件监听器。deviceType可传多个,以逗号隔开最小权限声明:(com.huawei.hilink.coreapi.perm.DevAdminByDevTypePermission "deviceType" "observe")deviceType即为接口参数deviceType
removeDeviceListner(DeviceEventListner listner)删除所有设备的事件监听器。
removeDeviceListnerBySerTypes(String serviceType, DeviceEventListner listner)删除提供指定服务的设备事件监听器。serviceType可传多个,以逗号隔开
removeDeviceListnerByDevTypes(String deviceType, DeviceEventListner listner)删除提供指定设备类型的设备事件监听器。deviceType可传多个,以逗号隔开
注:上述同一类权限可以合并,比如
(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "serviceType" "observe")
(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "serviceType" "list")
(com.huawei.hilink.coreapi.perm.DevAdminBySerTypePermission "serviceType" "list,observe")
DeviceEventListner是第三方Plugin需要实现的接口
com.huawei.hilink.openapi.device.DeviceEventListner
DeviceEventListner提供了监听智能设备数据的API
Public methods
onDeviceAdded(HiLinkDevice dev)添加设备的事件通知。
onDeviceRemoved(HiLinkDeviceUID uid)删除设备的事件通知。
onDeviceOnline(HiLinkDeviceUID uid)设备上线的事件通知。
onDeviceOffline(HiLinkDeviceUID uid)设备离线的事件通知。
onDeviceData(HiLinkDeviceData data)设备数据上报的事件通知。
Plugin本身有可能会保存一些数据,该章节就是说明Plugin保存自身数据的位置与方法。
每个Plugin都有自己的数据存储目录,获取数据存储根目录方法为:
public void start(BundleContext context) throws Exception {
System.out.println("demo start.");
File dataRootFile = context.getBundle().getDataFile(".");
除了OpenEE 开发接口,Plugin还有可能需要使用一些工具类,比如json,编码格式等。如需要引用这些基础库,则在pom.xml中dependencies标签中添加dependency引用),接口的使用可网上查询使用方法。使用下述基础库接口是有可能涉及到权限的问题,可以根据telnet串口的权限异常提示打印来在permissions.perm中声明添加。
org.apache.commons.codec 编码工具包,比如base64,hex等。
&dependency&
&groupId&commons-codec&/groupId&
&artifactId&commons-codec&/artifactId&
&version&1.10&/version&
&/dependency&
org.apache.commons.io
io操作工具包。
&dependency&
&groupId&commons-io&/groupId&
&artifactId&commons-io&/artifactId&
&version&2.4&/version&
&/dependency&
org.apache.commons.lang 通用操作工具包,比如字符串操作。
&dependency&
&groupId&commons-lang&/groupId&
&artifactId&commons-lang&/artifactId&
&version&2.6&/version&
&/dependency&
com.google.gson
json操作类
&dependency&
&groupId&com.google.code.gson&/groupId&
&artifactId&gson&/artifactId&
&version&2.3.1&/version&
&/dependency&
图12 特性概述
如上图所示,华为智能路由器可以对接所有支持HiLink协议的智能家居设备,例如鸿雁排插,欧普智能情景灯。为了进一步丰富智能家居生态链,兼容更多类型的设备,我们希望华为智能路由能够与第三方协议的设备互联,并集成设备信息收集、设备状态上报、业务控制等功能。例如美的M-Smart协议的设备,也能够注册到华为HiLink云,并通过智能家居APP统一管理。
针对上面的诉求,我们开放了一套API接口,用于实现异种协议的接入。第三方开发者只需要调用并实现相关接口,即可快速集成和扩展新设备的接入。下图描述了协议转换应用在整个开放平台中的结构框图。
图13 结构框图
本章节主要描述了开发协议转换应用必须要实现的接口以及接口之间的时序关系,下图思维导图是协议开发协议转换应用的基本场景概述。
图14 整体业务逻辑
注意:协议转换应用注册新设备时,先上报设备信息,上报成功之后会收到getALL的请求,然后再上报设备的服务数据。
图15 设备注册流程图
注意:网关初次注册华为云之后不会代理下挂未注册设备到云端注册,所以会通知应用重新注册全部的在线设备。
图16 设备扫描流程图
注意:用户可能会通过智能家居APP删除注册设备,该场景下协议转换应用需要通知设备断开与路由的WiFi连接。
图17 设备删除流程图
注意:开放平台通过handleCommand方法通知协议转换应用控制设备,控制成功之后,协议转换应用需要上报新的设备状态。
图18 设备控制流程图
注意:设备的状态上报分为在线/离线状态和设备的属性状态,属性状态例如设备的软件版本号等。分别通过reportDeviceStatus和reportDeviceInfo方法实现。
设备的服务数据发生变化通过reportDeviceData方法实现。
注意:部分协议转换应用需要配合设备发现应用使用,协议转换应用安装之后需要通知到开放平台,以确保业务逻辑正常,该逻辑开发者请按需要实现。
所有的协议转换应用卸载时都需要通知到开放平台,开放平台需要删除其下挂设备。
图19 应用安装卸载流程图
com.huawei.hilink.openapi.device.HiLinkDeviceReport
该接口类包含设备发现上报、设备删除上报、设备数据上报、设备状态上报以及设备信息更新等接口。此类由华为开放平台以声明式服务的形式实现,第三方应用只需要执行引用该服务即可,以引用类名为ReportTest为例,实现步骤如下:
需要在应用包的resources目录下OSGI-INF文件夹下新增ReportTest.xml。
目录截图如下:
Xml的文件内容如下:
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="类的路径.ReportTest"&
&implementation
class="类的路径.ReportTest" /&
&reference bind="setHiLinkDeviceReport" cardinality="1..1"
interface="com.huawei.hilink.openapi.device.HiLinkDeviceReport" name=" setHiLinkDeviceReport "
policy="static" unbind=" setHiLinkDeviceReport " /&
&/scr:component&
在ReportTest.java文件中引用HiLinkDeviceReport服务,demo代码如下:
import com.huawei.hilink.openapi.device.HiLinkDeviceR
public class ReportTest {
private static HiLinkDeviceReport sysHandle =
protected void activate() {
System.out.println("activate ReportTest");
protected void deactivate() {
System.out.println("deavtivate ReportTest");
protected void setHiLinkDeviceReport(HiLinkDeviceReport deviceReport) {
sysHandle = deviceR
protected void unsetHiLinkDeviceReport(HiLinkDeviceReport deviceReport) {
sysHandle =
public static void registerDevice() {
sysHandle.reportDeviceDiscovered(arg0, arg1, arg2);
(1) 接口描述
字段/方法名
reportDeviceDiscovered
HiLinkDeviceUID,HiLinkDeviceInfo,List&HiLinkServiceInfo&
发现设备后通过该接口通知业务层。 HiLinkDeviceUID是对应设备的uid, HiLinkDeviceInfo是设备信息, List&HiLinkServiceInfo&是设备服务信息。
reportDeviceRemoved
HiLinkDeviceUID
删除设备通过该接口通知业务层。该接口需要实现设备对wifi账号密码的清除。
// device uid,三段式,设备类型:厂商:型号
final HiLinkDeviceTypeUID devTypeUID = new HiLinkDeviceTypeUID("ContactSensor:78");
final HiLinkDeviceUID devUID = new HiLinkDeviceUID(devTypeUID, "ECA81CF62");//第二个参数为设备sn号
// device info
HiLinkDeviceInfo devInfo = new HiLinkDeviceInfo();
devInfo.setSn("SN");
devInfo.setMac("Mac");
devInfo.setFwv("Fwv");
devInfo.setDevType("DevType");
devInfo.setManu("Manu");
devInfo.setHiv("Hiv");
devInfo.setModel("Model");
devInfo.setProdId("ProdId");
devInfo.setProtType(HiLinkDeviceInfoUtil.DEV_PROTTYPE_WIFI);
devInfo.setSwv("Swv");
//service info
List&HiLinkServiceInfo& serviceInfos = new ArrayList&HiLinkServiceInfo&();
serviceInfos.add(new HiLinkServiceInfo("serviceId1",
HiLinkServiceType.CO2DETECTOR));
serviceInfos.add(new HiLinkServiceInfo("serviceId2",
HiLinkServiceType.CODETECTOR));
serviceInfos.add(new HiLinkServiceInfo("serviceId3",
HiLinkServiceType.CONCENTRATION));
serviceInfos.add(new HiLinkServiceInfo("serviceId4",
HiLinkServiceType.CONNECTSTATUS));
// device discovery
DeviceReportImpl.getDevReportHandler().reportDeviceDiscovered(devUID, devInfo, serviceInfos);
(1) 接口描述
字段/方法名
reportDeviceRemoved
HiLinkDeviceUID
删除设备通过该接口通知业务层。该接口需要实现设备对wifi账号密码的清除。
// device uid,三段式,设备类型:厂商:型号
final HiLinkDeviceTypeUID devTypeUID = new HiLinkDeviceTypeUID("ContactSensor:78");
final HiLinkDeviceUID devUID = new HiLinkDeviceUID(devTypeUID, "ECA81CF62");//第二个参数为设备sn号
// device remove
DeviceReportImpl.getDevReportHandler().reportDeviceRemoved(devUID);
(1) 接口描述
字段/方法名
reportDeviceData
HiLinkDeviceData
设备数据变化后后通过该接口通知业务层。
HiLinkDeviceData deviceData = new HiLinkDeviceData(HiLinkDeviceUID devId);
//构造service数据
HiLinkServiceData serviceData = new HiLinkServiceData("serviceId");
serviceData.addCharacteristic("ggg", "hhh");
serviceData.addCharacteristic("dfff", "sss");
serviceData.addCharacteristic("ggg", "bbb");
serviceData.addCharacteristic("uuu", "kkk");
serviceData.addCharacteristic("ppp", "lll");
deviceData.add(serviceData);
//可继续构造并添加新的service数据
DeviceReportImpl.getDevReportHandler().reportDeviceData(deviceData);
(1) 接口描述
字段/方法名
reportDeviceStatus
HiLinkDeviceUID,HiLinkDeviceStatus
设备状态改变,比如上下线时通过该接口通知业务层。 HiLinkDeviceStatus 是设备状态。
//上报设备上线状态
HiLinkDeviceStatus deviceStatusInfo = new HiLinkDeviceStatus(HiLinkDeviceStatusType.ONLINE,
HiLinkDeviceStatusDetail.NONE, "thirdbundle ONLINE");
DeviceReportImpl.getDevReportHandler().reportDeviceStatus(devUID, deviceStatusInfo);
(1) 接口描述
字段/方法名
reportDeviceInfo
HiLinkDeviceUID,HiLinkDeviceInfo
设备信息更新后通过该接口通知业务层(比如对应profile版本号更新)
HiLinkDeviceInfo dev = new HiLinkDeviceInfo();
dev.setHiv("Hiv.1.0.2");
dev.setFwv("Fwv.2.1.3");
DeviceReportImpl.getDevReportHandler().reportDeviceInfo(devUID, dev);
(1) 接口描述
字段/方法名
registerHostServices
List&HiLinkServiceInfo&
应用启动之后需要调用该接口上报主路由需要扩展的服务(可选接口)
List&HiLinkServiceInfo& serviceInfos = new ArrayList&HiLinkServiceInfo&();
serviceInfos.add(new HiLinkServiceInfo("multiSocket", "multiSocket"));
DeviceReportImpl.getDevReportHandler().registerHostServices (serviceInfos);
(1) 接口描述
字段/方法名
reportHostData
List&HiLinkServiceData&
应用所支持的主设备的某个服务有事件发生时,调用该接口上报事件(可选接口)
List&HiLinkServiceData& listserviceDatas = new ArrayList&HiLinkServiceData&();
HiLinkServiceData serviceData = new HiLinkServiceData(“sid”);
serviceData.addCharacteristic("ggg", "hhh");
serviceData.addCharacteristic("dfff", "sss");
serviceData.addCharacteristic("ggg", "bbb");
listserviceDatas.add(serviceData);
DeviceReportImpl.getDevReportHandler().reportHostData (listserviceDatas);
(1) 接口描述
字段/方法名
reportNewDevice
String apkName,HiLinkDeviceInfo deviceInfo
第三方发现应用检测到新设备,需要上报待安装的协议转换应用。apkName:需安装组件的包名deviceInfo:接入设备的基本信息,其中manu,prodId,sn必须上报。(可选接口)
HiLinkDeviceInfo dev = new HiLinkDeviceInfo();
dev.setmanu("005");
dev.setProdId("setProdId ");
dev.setSn(“xxxxx”);
DeviceReportImpl.getDevReportHandler().reportNewDevice(“com.midea.msmartsdk.slk_java”,dev);
com.huawei.hilink.openapi.device.AbstractHiLinkDeviceCmdHandler
(1) 接口描述
字段/方法名
handleCommand
HiLinkDeviceUID, HiLinkDeviceCommand
HiLinkDeviceCommand
HiLinkDeviceCommand是下发的命令结构,也是回复的数据结构;回复类构造如下:action:设置为ACTION_RESPONSE,type:填充错误码字符串,如“{"errcode":0}”,其中命令执行成功返回错误码为0,执行失败返回的错误码,见错误码描述章节
deviceRemove
String ErrorCode
注销所有设备:1.清除设备的wifi接入信息;2.调用接口reportDeviceRemoved清除设备注册信息;注销成功返回“0”,注销失败返回错误码,见错误码描述章节
deviceRemove
HiLinkDeviceUID
String ErrorCode
注销某个设备:1.清除设备的wifi接入信息;2.调用接口reportDeviceRemoved清除设备注册信息;注销成功返回“0”,注销失败返回错误码,见错误码描述章节。
扫描接口,实现该接口后,还需要调用 reportDeviceDiscovered来上报发现的设备
该接口下发命令至协议转换应用,协议转换应用如果需要获取下发的控制命令,需要用声明式服务实现,以CmdTest为例,步骤如下:
需要在应用包的resources目录下OSGI-INF文件夹下新增CmdTest.xml。
目录截图如下:
Xml的文件内容如下:
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="类的路径.CmdTest"&
&implementation
class="类的路径.CmdTest" /&
&provide interface="com.huawei.hilink.openapi.device.AbstractHiLinkDeviceCmdHandler " /&
&/service&
&/scr:component&
CmdtTest.java中实现该类,demo如下:
import com.huawei.hilink.openapi.device.AbstractHiLinkDeviceCmdH
public class CmdTest implements
AbstractHiLinkDeviceCmdHandler {
protected void activate() {
System.out.println("CmdTest activate...");
protected void deactivate() {
System.out.println("CmdTest deactivate...");
* 命令处理方法
public HiLinkDeviceCommand handleCommand(HiLinkDeviceUID DevUid, HiLinkDeviceCommand cmd) {
HiLinkDeviceCommand hiLinkDeviceCommand = //声明回复command
String action = cmd.getAction();//获取命令动作
HiLinkDeviceData data =
cmd.getData();//获取数据
List&HiLinkServiceData& serviceDatas = data.getServiceDatas();
* 接收到的为下发的POST命令,对数据进行处理构造回复command,
* 接收到的为下发的GET命令,解析serviceDatas中的每个sid,获取数据后,重新构造HiLinkDeviceData
if(action.equals(HiLinkDeviceCmdUtil.ACTION_POST)){
}else if(action.equals(HiLinkDeviceCmdUtil.ACTION_GET)){
HiLinkDeviceData respData = new HiLinkDeviceData(HiLinkDeviceUID);
* 构造service数据
HiLinkServiceData serviceData = new HiLinkServiceData("serviceId");
serviceData.addCharacteristic("ggg", "hhh");
serviceData.addCharacteristic("dfff", "sss");
serviceData.addCharacteristic("ggg", "bbb");
serviceData.addCharacteristic("uuu", "kkk");
serviceData.addCharacteristic("ppp", "lll");
serviceData.addCharacteristic("errcode", "0");
respData.add(serviceData);
* 构造回复command
hiLinkDeviceCommand = new HiLinkDeviceCommand(HiLinkDeviceCmdUtil.ACTION_RESPONSE, respData);
return hiLinkDeviceC
public void startScan(){
public String deviceRemove(){
String ErrCode = "0";
return ErrC
public String getManu() {
// TODO Auto-generated method stub
String ManuCode ="03D";
return ManuC
com.huawei.hilink.openapi.plugin.PluginMonitor
该接口类用于通知路由侧某个应用安装或者卸载,第三方应用可以在应用安装卸载的方法里面调用该接口,也可以在监听该应用的其它应用里调用该接口。
(1) 接口描述
字段/方法名
pluginInstallNotify
PluginInfo pluginInfo
应用安装时调用该方法
pluginUninstallNotify
PluginInfo pluginInfo
应用卸载时调用该方法
调用该接口需要声明获取PluginMonitor服务,以PluginTest为例:
需要在应用包的resources目录下OSGI-INF文件夹下新增PluginTest.xml。
目录截图如下:
Xml的文件内容如下:
&?xml version="1.0" encoding="UTF-8"?&
&scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true"
name="类的路径.PluginTest"&
&implementation
class="类的路径.PluginTest " /&
&reference bind="setPluginMonitor " cardinality="1..1"
interface="com.huawei.hilink.openapi.plugin.PluginMonitor" name="PluginTest"
policy="static" unbind=" unsetPluginMonitor " /&
&/scr:component&
PluginTest.java中实现该类,demo如下:
Public class PluginTest(){
PluginInfo pluginInfo = new PluginInfo("pkgname", "005", "hilinkproxy");
pluginMonitorHandler.pluginInstallNotify(pluginInfo);
pluginMonitorHandler.pluginUninstallNotify(pluginInfo);
public void setPluginMonitor (PluginMonitor pluginMonitor) {
pluginMonitorHandler = pluginM
public void unsetPluginMonitor (PluginMonitor pluginMonitor) {
pluginMonitorHandler =
字段/方法名
字段/方法名
DeviceName
FriendlyName
设备友好名称
SerialNumber
单板序列号SN
SoftwareVersion
软件版本号
字段/方法名
Wan连接状态。"Connected" 或者"DisConnected"
ConnectionType
连接类型。"Static" 或者"IP_Routed"
MACAddress
WAN侧MAC地址
字段/方法名
UpBandWidth
带宽值,QoS上行流量,单位为KBps,表明上传的总的流量大小。
DownBandWidth
带宽值,QoS下行流量, 单位为KBps,表明下载的总的流量大小。
inputUpBandWidth
手动配置的带宽值。QoS上流量,单位为MBps,表明上传的总的流量大小。
inputDownBandWidth
手动配置的带宽值,QoS下行流量,单位为MBps,表明下载的总的流量大小。
UpBandWidth_test
Qos上行测速流量, 单位为MBps。
DownBandWidth_test
Qos下行测速流量,单位为MBps。
字段/方法名
FrequencyBand
当前操作的波段,必须是tr181中SupportedFrequencyBands里面支持的,如"2.4GHz"或"5GHz"。
LockStatus
Wifi锁状态,true代表不允许有新设备接入。
wifi接入数量。
BeaconType
将用于此连接的加密类型。例如:“None”“Basic”“WPA”“11i”“WPAand11i”。
字段/方法名
标示当前设备是否在线
设备的名称
MACAddress
主机的MAC地址
AccessType
连接类型,可选“LAN”,“2.4GHz”,“5GHz”
设备所在房间的ID,仅限智能家居设备
设备所在房间的Name信息,仅限智能家居设备
设备类型ID,取值参见“HiLink认证设备类型ID及名称对照表”,占三字节(取值范围"000"~"FFF"),取值为001时是无线路由器
字段/方法名
Lan测维护地址
MACAddress
Lan测维护地址对应的MAC
Lan测维护地址对应的子网掩码
字段/方法名
MACAddress
设备MAC地址
ConnectedDevices
List&TopoLogyInfo&
该设备下面接的设备TopoLogyInfo
字段/方法名
分区的文件系统类型,取值如下:"unknown","vfat","fuseblk","hfs","hfsplus","exFAT","ext2","ext3","ext4"
分区的挂载路径,如:/mnt/Sony_usb1_1
分区的总空间大小,单位:MB
分区可用空闲空间大小,单位:MB
字段/方法名
进程启动后的PID
字段/方法名
devTypeUID
HiLinkDeviceTypeUID
HiLinkDeviceTypeUID由下面字段构成:设备类型ID、厂商ID、设备型号,用冒号隔开。此处的设备类型、厂商标识、产品型号必须与HiLinkDeviceInfo中的字段保持一致
设备标识,SN号,必须与HiLinkDeviceInfo中的SN号保持一致
字段/方法名
设备厂商ID
产品ID,设备HiLink认证id,新的产品类型需要向华为申请
设备类型ID,新的设备类型需要向华为申请
description
设备简要描述
设备MAC地址,格式“AA:BB:CC:DD:EE:FF”
hardware version.硬件版本
firmware version.固件版本
HiLink协议版本
software version.软件版本
设备序列号
设备的ip地址,格式:192.168.x.xx如果是虚拟设备,上报“127.0.0.1”
协议类型: HiLinkDeviceInfoUtil.DEV_PROTTYPE_WIFI HiLinkDeviceInfoUtil.DEV_PROTTYPE_Z-WIFIHiLinkDeviceInfoUtil.DEV_PROTTYPE_ZIGBEE
字段/方法名
字段/方法名
HiLinkDeviceUID
HiLinkDeviceInfo
List&HiLinkServiceInfo&
设备服务信息
字段/方法名
HiLinkDeviceUID
serviceDatas
List&HiLinkServiceData&
字段/方法名
Map&String,Object&
服务的属性数据
字段/方法名
命令类型,HiLinkDeviceCmdUtil.ACTION_POST,HiLinkDeviceCmdUtil.ACTION_GET,HiLinkDeviceCmdUtil.ACTION_RESPONSE…
HiLinkDeviceData
具体命令内容
字段/方法名
卸载应用的包名
pluginManu
卸载应用的厂商id
pluginType
应用的类型,第三方协议转换应用填写:PluginInfo.PLUGIN_TYPE_HILINKPROXY
设备已被删除
设备请求没有响应
设备已离线
找不到设备
下面helloworld是一个最简单的HiLink路由器应用工程,demo工程包含了上述所有开放接口的使用,如果提示java版本兼容新的问题,参照5.2.7给出的pom.xml例子,在pom.xml的&plugins&标签中加上如下子标签,指定java编译版本为1.7:
&groupId&org.apache.maven.plugins&/groupId&
&artifactId&maven-compiler-plugin&/artifactId&
&configuration&
&source&1.7&/source&
&target&1.7&/target&
&optimize&true&/optimize&
&debug&false&/debug&
&/configuration&
Q1:调用提供的接口服务去获取数据或执行操作,为什么总是报空指针异常?
A:声明式服务没有配置正确是导致调用接口服务报空指针异常的主要原因,可以通过如下步骤排查:
1.检查应用中调用接口服务的类是否有对应的XML配置文件,如有请继续排查,没有请参照5.3章节进行配置;
2.确认在声明式服务配置XML配置文件中的bind和unbind对应的方法在服务类中是否有实现,如有请继续排查,如没有请在服务类中实现对应方法;
3.确认在服务类中对应的bind中的方法中实现了服务引用的赋值,如没有则请对服务引用赋值
如上步骤排查完如果问题仍然存在,请联系华为接口人协助定位。
Q2:应用安装和运行过程中在日志窗口出现权限异常的打印,如何解决?
A:在异常打印的第一行末尾会将需要的权限打印出来,请将“()”及其里面的内容拷贝然后粘贴到应用的权限配置文件permissions.perm中。
Q3:在调用自定义restful请求时,得到正确的回复,但是为何无法获取到回复中带的数据?
A:在实现自定义restful请求时,通过返回Response.ok().build(),来表明请求处理成功,如果需要返回数据,则应当将数据封装成一个JavaBean对象,通过Response.ok(Object).build()返回。}

我要回帖

更多关于 路由器管家密码错误 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信