KaiOS — 一个基于Mozilla的Boot to Gecko(B2G)Web技术的按键手机操作系统。应用程序开发使用HTML5、CSS和JavaScript进行,无需学习原生语言。KaiOS在具有256–512 MB RAM的设备上运行,并支持4G VoLTE、GPS、蓝牙。根据KaiOS Technologies数据,2025年全球有超过2亿活跃设备。
要点
KaiOS — 由KaiOS Technologies公司开发的按键手机移动操作系统。该系统基于Mozilla的开源项目Boot to Gecko(B2G),该项目最初是作为超低价设备的Web版Android替代品而创建的。首个商业版本于2017年在印度的Reliance JioPhone手机上发布。
根据Counterpoint Research(2025年第二季度)的数据,KaiOS占据全球移动操作系统市场的2.8%,落后于Android(72%)和iOS(27%),但领先于其他平台。在印度,得益于JioPhone计划,KaiOS的份额达到14%。KaiOS设备的平均价格为20-30美元,这使得该系统对新兴市场至关重要。
KaiOS的关键特点——所有应用都是Web应用。开发者使用HTML5、CSS和JavaScript编写代码,将其打包成带清单的ZIP存档并发布到KaiStore。该系统不支持安装原生APK文件——仅支持符合W3C Widget规范的Open Web Apps。
KaiOS 2.5(2018年)— 基于Gecko 48内核的首个稳定版本,安装在JioPhone 1上。KaiOS 2.5.3(2021年)— 支持Google Assistant、Google Maps Go、YouTube Go。KaiOS 3.0(2022年)— Gecko 84,性能提升,WebGL 2.0,CSS Grid。KaiOS 3.1(2024年)— 针对256 MB RAM优化,新的Web API Audio Channel,改进的TLS 1.3安全性。
| KaiOS版本 | 年份 | Gecko | 关键变化 |
|---|---|---|---|
| 2.5 | 2018 | 48 | 首个稳定版本,JioPhone 1 |
| 2.5.3 | 2021 | 48 | Google Apps、助手、安全性改进 |
| 3.0 | 2022 | 84 | ES2020、WebGL 2.0、CSS Grid、JS性能提升 |
| 3.1 | 2024 | 84 | 256 MB RAM、TLS 1.3、Audio Channel API |
KaiOS架构由三个关键层组成:Linux内核(Gonk)、Web引擎Gecko和用户界面Gaia。Gonk — 硬件相关层,包括驱动程序、HAL(硬件抽象层)、RIL(无线电接口层)调制解调器栈和传感器支持。从Android开源项目(AOSP)中采用了引导加载程序、驱动程序和部分库。
Gonk为Gecko提供硬件访问:相机、蓝牙、Wi-Fi、GPS、音频、振动、传感器。与Android应用为Dalvik/ART编写不同,在KaiOS中应用通过Gecko转换为Gonk IPC的Web API访问硬件。无线电接口(RIL)提供4G VoLTE、SMS、USSD和SIM卡管理。
Gecko在KaiOS中不仅仅是浏览器引擎,而是完整的应用程序运行时环境。所有HTML5应用都在Gecko Process Manager内部运行,它将每个应用隔离在单独的进程中。Gecko实现了W3C Widget Packaging规范和Mozilla的硬件访问扩展。Gecko版本决定了开发者可以使用哪些Web API。
Gaia — 操作系统本身的Web界面:锁屏、主屏幕(启动器)、通知面板、拨号屏幕、联系人、SMS客户端。所有系统应用都是相同的Open Web Apps。开发者可以通过在清单中注册相应的activity handler来替换标准相机或键盘为自己的应用。
// 检查KaiOS版本和API可用性
function checkKaiOSVersion() {
const ua = navigator.userAgent;
let version = 'unknown';
if (ua.includes('KAIOS/2.5')) {
version = '2.5';
} else if (ua.includes('KAIOS/3')) {
version = '3.0';
}
const features = {
geolocation: 'geolocation' in navigator,
vibration: 'vibrate' in navigator,
mozMobileConnection: 'mozMobileConnection' in navigator,
mozTelephony: 'mozTelephony' in navigator,
mozSms: 'mozSms' in navigator,
bluetooth: 'bluetooth' in navigator
};
return { version, features };
}
// 检查Google Apps是否存在(仅KaiOS 2.5.3+)
const systemInfo = checkKaiOSVersion();
console.log('KaiOS version:', systemInfo.version);
console.log('Available APIs:', JSON.stringify(systemInfo.features, null, 2));
// 使用带可用性检查的振动
function triggerHapticFeedback() {
if (navigator.vibrate) {
navigator.vibrate([200, 100, 200]); // 振动、暂停、振动
}
}checkKaiOSVersion函数读取User Agent以确定KaiOS版本并检查关键Web API的可用性。在2.5版本中,mozMobileConnection、mozTelephony、mozSms可用——它们在普通浏览器中不存在且是KaiOS独有的。triggerHapticFeedback函数使用Vibration API并保持向后兼容。
KaiOS应用 — 一个包含HTML文件、CSS、JavaScript、图像和清单的ZIP存档(格式.zip,而非.apk)。最小应用的结构包括manifest.webapp(应用描述)、index.html(入口点)、style.css和icon.png(90×90像素方形图标)。清单符合W3C Manifest for Web Apps规范。
manifest.webapp文件 — KaiOS应用的主配置文件。必填字段:name(名称)、description(最多140个字符的描述)、launch_path(指向index.html的路径)、icons(30×30、60×60、90×90、120×120像素的图标)。type字段:'certified'(系统应用)、'privileged'(访问Web API)、'web'(无特殊权限)。Privileged应用的权限在permissions数组中指定。
// manifest.webapp — KaiOS应用配置
{
"name": "手电筒",
"description": "打开和关闭相机闪光灯",
"launch_path": "/index.html",
"icons": {
"30": "/icons/icon-30.png",
"60": "/icons/icon-60.png",
"90": "/icons/icon-90.png",
"120": "/icons/icon-120.png"
},
"type": "privileged",
"permissions": {
"camera": {
"description": "需要打开闪光灯"
}
},
"default_locale": "ru",
"orientation": "portrait-primary",
"fullscreen": true
}清单指出应用类型为privileged — 这通过permissions提供对camera API的访问。图标尺寸严格为30×30、60×60、90×90和120×120像素。orientation字段限制竖屏方向——在按键手机中通常没有用于旋转屏幕的加速度计。fullscreen: true隐藏状态栏。
KaiOS中的HTML5页面使用标准标签,同时考虑有限的屏幕(通常为240×320像素)。viewport元标签是必须的:<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">。KaiOS不支持触摸事件(按键手机没有触摸屏),所有导航都通过按键进行:ArrowUp、ArrowDown用于移动,Enter用于选择,Back用于返回。
// index.html — 适用于KaiOS的简单手电筒应用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1">
<title>手电筒</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="app">
<div id="status" class="status-off">已关闭</div>
<div id="hint">按 Enter 键开启</div>
</div>
<script>
const statusEl = document.getElementById('status');
const hintEl = document.getElementById('hint');
let isFlashOn = false;
let camera = null;
async function initCamera() {
try {
camera = navigator.mozCameras.getListOfCameras()[0];
const cameraControl = await
navigator.mozCameras.getCamera(camera, { mode: 'picture' });
return cameraControl;
} catch (e) {
showError('相机不可用:' + e.message);
}
}
async function toggleFlash() {
const cam = await initCamera();
if (!cam) return;
isFlashOn = !isFlashOn;
try {
await cam.setConfiguration({
mode: 'picture',
flashMode: isFlashOn ? 'on' : 'off'
});
statusEl.textContent = isFlashOn ? '已开启' : '已关闭';
statusEl.className = isFlashOn ? 'status-on' : 'status-off';
} catch (e) {
showError('错误:' + e.message);
}
}
// 处理硬件Enter按键
document.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
toggleFlash();
}
});
initCamera();
</script>
</body>
</html>手电筒应用使用MozCamera API控制相机闪光灯。用户按下硬件Enter键——触发keydown处理程序,在on和off之间切换flashMode。状态通过具有status-on/status-off类的文本块显示以进行视觉指示。MozCamera API仅对清单中具有camera权限的privileged应用可用。
KaiOS Web API — 一组JavaScript接口,提供对电话硬件功能的访问。大多数API是Mozilla专有扩展(带有moz前缀)且在普通浏览器中不可用。要使用API,应用在清单中必须具有privileged或certified类型。
MozMobileConnection — 网络信息:运营商、信号强度、网络类型(4G/3G/2G)、IMEI、漫游状态。MozTelephony — 通话管理:拨号、接听、结束、会议、通话状态。MozSms — 发送和接收SMS、MMS,管理SIM卡上的消息。MozContacts — 读取和写入电话簿。MozBluetooth — 蓝牙管理:发现设备、配对、文件传输。Push API — 从服务器接收推送通知。
// 通过KaiOS Web API处理联系人和通话
const TelephonyManager = {
// 拨打电话号码
async makeCall(phoneNumber) {
if (!navigator.mozTelephony) {
throw new Error('Telephony API 不可用');
}
const call = navigator.mozTelephony.dial(phoneNumber);
call.onconnected = () => console.log('通话已建立');
call.ondisconnected = () => console.log('通话已结束');
return call;
},
// 从电话簿获取联系人列表
async getContacts() {
const cursor = navigator.mozContacts.getAll({
sortBy: 'familyName',
sortOrder: 'ascending'
});
const contacts = [];
return new Promise((resolve, reject) => {
cursor.onsuccess = function() {
if (this.result) {
contacts.push(this.result);
this.continue();
} else {
resolve(contacts);
}
};
cursor.onerror = function() {
reject(this.error);
};
});
},
// 发送短信
async sendSms(phoneNumber, message) {
if (!navigator.mozSms) {
throw new Error('SMS API 不可用');
}
const request = navigator.mozSms.send(phoneNumber, message);
return new Promise((resolve, reject) => {
request.onsuccess = () => resolve(request.result);
request.onerror = () => reject(request.error);
});
}
};
// 使用示例
TelephonyManager.getContacts()
.then(contacts => console.log('找到联系人:', contacts.length))
.catch(err => console.error(err));TelephonyManager对象结合了三个关键的KaiOS API:用于通话的mozTelephony、用于电话簿的mozContacts和用于消息的mozSms。带游标的getAll() — 异步读取大量数据的模式(典型用于超过1000条记录的联系人)。所有API返回带有onsuccess和onerror处理程序的DOMRequest。
KaiOS Web API存在限制:通话和SMS API仅在电话上可用(不在平板电脑上),相机——仅在物理相机存在时,蓝牙——有限的HSP/HFP配置文件。Push API需要Google Firebase(FCM)服务器或自有服务器的支持。地理位置API根据硬件支持使用A-GPS或Cell ID。
| API | 应用类型 | 可用性 | KaiOS版本 |
|---|---|---|---|
| MozMobileConnection | privileged | 所有电话 | 2.5+ |
| MozTelephony | privileged | 仅电话 | 2.5+ |
| MozSms | privileged | 仅电话 | 2.5+ |
| MozContacts | privileged | 所有电话 | 2.5+ |
| MozBluetooth | certified | 带蓝牙模块 | 2.5+ |
| Geolocation API | web | 带GPS/Cell ID | 2.5+ |
| Push API | privileged | 带互联网 | 3.0+ |
| WebGL 2.0 | web | 带GPU加速 | 3.0+ |
KaiOS用户界面面向T9键盘和硬件按键控制。标准屏幕分辨率——大多数按键手机为240×320像素(QVGA)。没有触摸屏意味着所有导航都通过keydown/keyup事件进行:ArrowUp、ArrowDown、ArrowLeft、ArrowRight、Enter、Back(或Escape)。
KaiOS不以常规方式支持CSS :focus——焦点通过tabindex和JavaScript进行管理。开发者必须手动跟踪当前选定的元素并在按键时移动焦点。建议在列表元素上使用data-index以简化导航。选定的元素通常通过.selected类以对比色的background-color CSS属性高亮显示。
// 适用于KaiOS的列表焦点导航
class ListNavigation {
constructor(containerSelector) {
this.container = document.querySelector(containerSelector);
this.items = this.container.querySelectorAll('[data-index]');
this.currentIndex = 0;
this.init();
}
init() {
this.updateFocus();
document.addEventListener('keydown', (e) => {
switch (e.key) {
case 'ArrowUp':
e.preventDefault();
this.moveFocus(-1);
break;
case 'ArrowDown':
e.preventDefault();
this.moveFocus(1);
break;
case 'Enter':
e.preventDefault();
this.selectItem();
break;
case 'Backspace':
case 'Escape':
e.preventDefault();
this.goBack();
break;
}
});
}
moveFocus(direction) {
this.items[this.currentIndex].classList.remove('selected');
this.currentIndex = (this.currentIndex + direction + this.items.length) % this.items.length;
this.updateFocus();
}
updateFocus() {
const el = this.items[this.currentIndex];
el.classList.add('selected');
el.scrollIntoView({ block: 'nearest' });
}
selectItem() {
const el = this.items[this.currentIndex];
const event = new CustomEvent('itemselected', {
detail: { index: this.currentIndex, element: el }
});
this.container.dispatchEvent(event);
}
goBack() {
history.back();
}
}
// 初始化菜单列表导航
const nav = new ListNavigation('#menu-list');
nav.container.addEventListener('itemselected', (e) => {
console.log('选中的元素:', e.detail.index);
});ListNavigation类为KaiOS实现了完整的焦点导航。ArrowUp/ArrowDown在具有data-index的元素上循环移动焦点。Enter触发自定义事件itemselected。Backspace/Escape返回上一个屏幕。scrollIntoView带block: nearest在元素超出可见区域时自动滚动屏幕。
KaiOS 2.5支持CSS 2.1 + 部分CSS3(border-radius、box-shadow、gradients)。Flexbox在KaiOS 2.5中部分支持,在KaiOS 3.0中完全支持,包括CSS Grid。为了兼容性,建议使用固定宽度的float布局。默认字体——TizenSans或面向亚洲市场的Noto Sans CJK。文本大小——主要内容14-16像素,标题18-20像素。
KaiStore — KaiOS的官方应用商店,预装在所有设备上。开发者在KaiOS开发者门户(developer.kaiostech.com)注册,上传签名的ZIP包并填写描述。审核检查安全性、稳定性和内容策略合规性。平均审核时间——3-5个工作日。
KaiOS要求通过KaiOS Certificate对应用进行数字签名。开发者使用kaios-sign工具生成密钥对(私钥+公钥),将公钥发送到KaiOS开发者门户并获取证书。签名的.zip文件在META-INF文件夹中包含签名。没有签名,应用只能在开发设备上安装。
KaiStore支持免费应用、通过KaiOS Ads SDK的广告以及通过运营商计费(Direct Carrier Billing)的应用内购买。KaiStore佣金——收入的30%。替代渠道——通过OEM制造商(Jio、Nokia、Alcatel、Doro)预装。预装需要与设备制造商直接签订合同。
| 阶段 | 操作 | 时间 |
|---|---|---|
| 注册 | 在KaiOS开发者门户创建账户 | 1天 |
| 签名 | 生成密钥,获取证书 | 1-2天 |
| 构建 | 用清单和签名打包.zip | 1小时 |
| 上传 | 上传包,填写描述 | 1天 |
| 审核 | 检查安全性和质量 | 3-5天 |
| 发布 | 在KaiStore向所有区域发布 | 1天 |
KaiStore在某些国家不支持付费应用(仅通过运营商计费支付)。应用大小限制为10 MB以通过2G/3G网络下载。应用不得使用超过50 MB的RAM。未经清单明确说明禁止访问mozMobileConnection API。违反策略会导致开发者账户被封锁。
常见问题
KaiOS — 基于Mozilla Gecko Web引擎的按键手机操作系统。在256-512 MB RAM的设备上运行,支持4G VoLTE、GPS和蓝牙。应用程序使用HTML5、CSS和JavaScript编写。根据Counterpoint Research,KaiOS已安装在超过2亿台设备上。
唯一的开发技术栈——HTML5、CSS和JavaScript。KaiOS不支持C++或Java等原生语言。所有应用都是符合W3C规范的Open Web Apps。访问硬件功能使用带moz前缀的Mozilla Web API。应用打包为带manifest.webapp的ZIP存档。
官方商店——KaiStore,在KaiOS开发者门户注册。应用使用开发者证书签名并以.zip格式上传。审核需要3-5天。替代渠道——通过与OEM制造商的合同在新设备上预装。KaiStore佣金——30%。
KaiOS使用Gecko Web引擎运行HTML5应用,需要256-512 MB RAM。Android Go在Dalvik/ART上运行原生APK,需要1-2 GB RAM。KaiOS运行在价格不超过30美元的按键手机上,Android Go运行在50美元起的廉价智能手机上。KaiOS功耗更低,续航更长。
主要API:MozMobileConnection(网络)、MozTelephony(通话)、MozSms(短信)、MozContacts(联系人)、MozBluetooth(蓝牙)、Geolocation API、Vibration API、Push API、Notification API。访问camera API需要privileged应用类型。Push API从KaiOS 3.0起可用。
总结
我们将开发一款交钥匙移动应用程序
IT Sectr自2017年以来为初创企业和企业打造iOS和Android应用程序。我们将为您提供咨询并提出最佳解决方案。