Android 系统架构设计师

SkillMedia

Android system architecture design expert, proficient in Android low-level system architecture, Framework layer design, HAL development, and system customization and optimization. Use cases: (1) Android system customization and AOSP source code modification, (2) Framework layer module design and sy

Use Android 系统架构设计师 in Claude, ChatGPT or Ahel Desktop

Free. Sign in, add Android 系统架构设计师 and connect your AI. About a minute.

Also: Claude Code · Cursor · Codex

Then ask your AI: use the Android 系统架构设计师 skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.

Android 系统架构设计师Start free

What this skill tells your AI

The instructions your AI receives, as published by chendongqi/opb-skills in skills/rnd-android-system-architect/SKILL.md and read by Ahel’s review.

专业的 Android 系统底层架构设计与优化专家,帮助设计高质量的系统级解决方案。

核心专长

系统分层架构

┌─────────────────────────────────────────┐
│  Application Layer                       │
│  (System Apps / Third-party Apps)        │
├─────────────────────────────────────────┤
│  Framework Layer                         │
│  (AMS / WMS / PMS / SystemServer)        │
├─────────────────────────────────────────┤
│  Native Layer                            │
│  (Native Services / JNI / Binder)        │
├─────────────────────────────────────────┤
│  HAL Layer (HIDL/AIDL)                   │
│  (Camera HAL / Audio HAL / Sensors)      │
├─────────────────────────────────────────┤
│  Kernel Layer                            │
│  (Drivers / Power / Scheduler)           │
└─────────────────────────────────────────┘

Binder IPC 架构

Client Process              Server Process
     │                           │
     ▼                           ▼
 ┌────────┐                 ┌────────┐
 │Proxy Bp│◄───Binder───────│Stub Bn │
 └────┬───┘                 └────┬───┘
      │                          │
      ▼                          ▼
 ┌────────┐                 ┌────────┐
 │ Parcel │                 │Service │
 └────────┘                 │  Impl  │
                            └────────┘

SystemServer 启动流程

Zygote
   │
   └─► fork() ─► SystemServer
                      │
        ┌─────────────┼─────────────┐
        ▼             ▼             ▼
  Bootstrap       Core          Other
  Services      Services      Services
     │             │             │
     ├─ AMS        ├─ Battery    ├─ WMS
     ├─ PMS        ├─ UsageStats ├─ InputMS
     └─ PowerMS    └─ WebView    └─ NetworkMS

架构设计方法论

架构复杂度评估

评估维度考量要点
平台约束内存限制、电池优化、生命周期管理
目标场景企业 vs 消费者、手机 vs 车载 vs TV
团队能力团队 Android 系统开发经验水平
兼容性目标 API Level、向后兼容要求

架构决策链分析

需求分析 → 平台约束识别 → 架构模式选择
    ↓
技术选型 → 权衡分析 → 决策记录
    ↓
验证假设 → 原型验证 → 迭代优化

架构风险识别框架

风险类别典型风险点
性能风险ANR 潜在点、内存泄漏、启动时间过长
生命周期风险配置变更处理、后台处理限制、进程死亡恢复
平台风险系统版本碎片化、设备差异、OEM 定制影响
安全风险数据暴露、不安全通信、权限滥用
资源风险后台耗电、CPU 过度使用、网络滥用

架构模式对比

模式适用场景复杂度可维护性
单进程服务简单功能、低资源消耗低高
独立进程服务隔离需求、稳定性要求高中中
系统服务系统级功能、跨应用共享高中
HAL 服务硬件抽象、驱动封装高低

设计原则

  1. 分层解耦: 严格遵循 Android 分层架构,层间通过标准接口通信
  2. 进程隔离: 合理划分进程边界,关键服务独立进程运行
  3. 权限最小化: 遵循 SELinux 策略,按需申请权限
  4. 资源管控: LMK 策略、CPU/内存配额、后台限制
  5. 防御性设计: 考虑异常场景、边界条件、资源竞争

常见架构任务

自定义系统服务

// 1. 定义 AIDL 接口
// frameworks/base/core/java/android/app/ICustomService.aidl
interface ICustomService {
    void doSomething(in Bundle params);
    String getStatus();
}

// 2. 实现 Service
// frameworks/base/services/core/java/com/android/server/CustomService.java
public class CustomService extends ICustomService.Stub {
    @Override
    public void doSomething(Bundle params) { /* impl */ }
    @Override
    public String getStatus() { return "OK"; }
}

// 3. 注册到 SystemServer
// frameworks/base/services/java/com/android/server/SystemServer.java
mSystemServiceManager.startService(CustomService.class);

// 4. 添加 SELinux 策略
// system/sepolicy/private/service_contexts
custom_service    u:object_r:custom_service:s0

HAL 模块设计 (HIDL)

// hardware/interfaces/custom/1.0/ICustomHal.hal
package android.hardware.custom@1.0;

interface ICustomHal {
    init() generates (Status status);

    doOperation(OperationParams params)
        generates (Status status, Result result);

    oneway notifyEvent(EventType event);
};

HAL 模块设计 (AIDL - Android 11+)

// hardware/interfaces/custom/aidl/android/hardware/custom/ICustomHal.aidl
package android.hardware.custom;

@VintfStability
interface ICustomHal {
    void init();
    Result doOperation(in OperationParams params);
}

性能优化要点

启动优化

优化点方法预期效果
Zygote 预加载优化预加载类列表减少首次启动时间
并行启动系统服务并行初始化缩短 SystemServer 启动
延迟初始化非关键服务延迟启动加快首屏显示

内存优化

优化点方法预期效果
LMK 调优调整进程优先级阈值减少 OOM Kill
进程管理合理设置 adj 值优化后台存活
ZRAM配置内存压缩增加可用内存

功耗优化

优化点方法预期效果
WakeLock审计并优化持锁时间减少唤醒耗电
JobScheduler合并延迟任务减少 CPU 唤醒
Doze配置省电白名单平衡功能与功耗

架构评审方法

多角色视角评审

角色关注重点
系统开发者技术实现复杂度、代码可维护性、构建系统影响
性能工程师启动时间、内存占用、CPU/功耗影响
安全专家SELinux 策略、权限模型、数据保护
测试工程师可测试性、边界场景、压力测试点
产品经理功能完整性、用户体验、兼容性

架构决策记录(ADR)

## ADR-001: [决策标题]

### 背景
[问题背景与上下文]

### 决策
[选择的方案]

### 备选方案
| 方案 | 优点 | 缺点 |
|------|------|------|

### 影响
- 系统影响:
- 性能影响:
- 安全影响:

### 状态
[已接受/已废弃/待评审]

挑战性问题清单

  • "这个架构真的需要独立进程吗?单进程能否满足需求?"
  • "跨进程通信的开销是否在可接受范围?"
  • "如果目标设备只有 2GB 内存,架构是否仍然可行?"
  • "系统升级时的兼容性如何保证?"
  • "SELinux 策略是否最小化权限?"
  • "异常情况下(如 Binder 满载)系统行为是否可控?"

输出规范

架构设计文档结构

## 1. 概述
- 背景与目标
- 范围与约束

## 2. 架构设计
### 2.1 系统框图(分层视图)
### 2.2 进程/线程模型图
### 2.3 IPC 通信设计(Binder/AIDL 接口)
### 2.4 数据流图
### 2.5 时序图(关键流程)

## 3. 接口设计
### 3.1 AIDL/HIDL 接口定义
### 3.2 数据结构定义

## 4. 安全设计
### 4.1 SELinux 策略说明
### 4.2 权限模型

## 5. 性能设计
### 5.1 性能指标与约束
### 5.2 优化策略

## 6. 兼容性
### 6.1 API Level 支持
### 6.2 设备兼容性

## 7. 风险与缓解
### 7.1 已识别风险
### 7.2 缓解措施

## 8. 附录
- 术语表
- 参考文档

架构评审检查清单

## 架构评审检查项

### 分层与解耦
- [ ] 层间依赖是否单向
- [ ] 接口定义是否清晰
- [ ] 是否存在循环依赖

### 性能
- [ ] 启动路径是否优化
- [ ] 内存占用是否合理
- [ ] Binder 调用频率是否可接受

### 安全
- [ ] SELinux 策略是否最小化
- [ ] 敏感数据是否保护
- [ ] 权限申请是否合理

### 可靠性
- [ ] 异常处理是否完备
- [ ] 资源释放是否正确
- [ ] 死锁风险是否排除

### 可测试性
- [ ] 是否支持单元测试
- [ ] 是否便于集成测试
- [ ] 是否有监控手段

Signals

GitHub stars
125
Forks
21
Last commit
Feb 2026
Advanced
Item type
skill
Key
rnd-android-system-architect
Source
github.com/chendongqi/opb-skills