Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Kits Telephony

ASecurity

HarmonyOS TelephonyKit 电话能力集使用规范。包含电话拨打、短信发送、SIM卡管理、网络状态监听等功能。Use when: (1) 拨打电话,(2) 发送短信,(3) 读取SIM卡信息,(4) 监听通话状态。Triggers: 电话、拨打、短信、SMS、SIM卡、通话、telephony、call、sms、sim、@ohos.telephony。

2 stars
0 votes
0 copies
0 views
Added 9/22/2026
developmenttypescriptapi

Works with

cliapi

Security Analysis

A100/100

Scanned 9/22/2026

Install to Claude Code

$npx -y skills add IsKenKenYa/skills --skill kits_telephony --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kits Telephony?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Kits Telephony
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/iskenkenya-kits-telephony/badge)](https://www.skillsdirectory.com/skills/iskenkenya-kits-telephony)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: kits_telephony
description: "HarmonyOS TelephonyKit 电话能力集使用规范。包含电话拨打、短信发送、SIM卡管理、网络状态监听等功能。Use when: (1) 拨打电话,(2) 发送短信,(3) 读取SIM卡信息,(4) 监听通话状态。Triggers: 电话、拨打、短信、SMS、SIM卡、通话、telephony、call、sms、sim、@ohos.telephony。"
user-invocable: false
metadata:
  internal: true
---

# TelephonyKit 电话能力集 (kits_telephony)

本 skill 覆盖 HarmonyOS **TelephonyKit** 电话能力集的使用规范。

## 能力列表

| 模块 | 导入方式 | 用途 |
|------|----------|------|
| call | @ohos.telephony.call | 电话拨打 |
| sms | @ohos.telephony.sms | 短信发送 |
| sim | @ohos.telephony.sim | SIM卡信息 |
| radio | @ohos.telephony.radio | 无线通信状态 |
| observer | @ohos.telephony.observer | 状态监听 |
| data | @ohos.telephony.data | 数据业务 |
| vcard | @ohos.telephony.vcard | 名片解析 |

## 快速索引

### 拨打电话

```typescript
import call from '@ohos.telephony.call';

// 拨打电话(需要系统权限或用户确认)
await call.dial('13800138000');

// 带参数拨打
await call.dial('13800138000', {
  accountId: 0,  // SIM卡槽ID
  videoState: 0  // 0-语音, 1-视频
});

// 判断是否支持通话
let isSupported = call.hasVoiceCapability();
console.log('Voice capability: ' + isSupported);

// 监听通话状态
call.on('callStateChange', (data: call.CallStateChange) => {
  console.log(`Call state: ${data.state}, Number: ${data.accountId}`);
  // CallState: CALL_STATE_UNKNOWN(0), CALL_STATE_IDLE(1), CALL_STATE_RINGING(2), CALL_STATE_OFFHOOK(3)
});
```

### 发送短信

```typescript
import sms from '@ohos.telephony.sms';

// 发送短信
let options: sms.SendMessageOptions = {
  slotId: 0,                    // SIM卡槽ID
  destinationHost: '13800138000',
  content: 'Hello from HarmonyOS',
  deliveryCallback: (err, data) => {
    if (err) {
      console.error('SMS delivery failed: ' + err.message);
    } else {
      console.log('SMS delivered successfully');
    }
  },
  sendCallback: (err, data) => {
    if (err) {
      console.error('SMS send failed: ' + err.message);
    } else {
      console.log('SMS sent successfully');
    }
  }
};

await sms.sendMessage(options);

// 发送长短信(自动分片)
let longMessage = '这是一段很长的短信内容...'.repeat(100);
await sms.sendMessage({
  slotId: 0,
  destinationHost: '13800138000',
  content: longMessage
});

// 创建短信消息
let message: sms.ShortMessage = {
  hasReplyPath: false,
  isReplaceMessage: false,
  messageClass: sms.ShortMessageClass.CLASS_UNKNOWN,
  protocolId: 0,
  status: 0,
  visibleMessageBody: '短信内容',
  visibleRawAddress: '13800138000'
};
```

### SIM卡信息

```typescript
import sim from '@ohos.telephony.sim';

// 检查SIM卡状态
let hasSim = sim.hasSimCard(0);  // 0-SIM1, 1-SIM2
console.log('Has SIM: ' + hasSim);

// 获取SIM卡状态
let simState = sim.getSimState(0);
// SimState: SIM_STATE_UNKNOWN(0), SIM_STATE_ABSENT(1), SIM_STATE_PRESENT(2), SIM_STATE_LOCKED(3)

// 获取SIM卡运营商
let operatorName = sim.getSimOperatorName(0);
console.log('Operator: ' + operatorName);

// 获取SIM卡号码
let phoneNumber = sim.getSimTelephoneNumber(0);
console.log('Phone number: ' + phoneNumber);

// 获取SIM卡SPN
let spn = sim.getSimSpn(0);
console.log('SPN: ' + spn);

// 获取SIM卡ICC ID
let iccId = sim.getSimIccId(0);
console.log('ICC ID: ' + iccId);

// 获取ISO国家代码
let isoCode = sim.getIsoCountryCodeForSim(0);
console.log('ISO: ' + isoCode);
```

### 网络状态监听

```typescript
import observer from '@ohos.telephony.observer';

// 监听网络状态变化
observer.on('networkStateChange', (data: observer.NetworkState) => {
  console.log(`Network state: ${data.regState}`);
  console.log(`Signal strength: ${data.signalStrength}`);
  console.log(`Data connection: ${data.dataConnectionState}`);
});

// 监听信号强度变化
observer.on('signalInfoChange', (data: observer.SignalInformation[]) => {
  for (let info of data) {
    console.log(`Signal type: ${info.signalType}, Level: ${info.signalLevel}`);
  }
});

// 监听SIM卡状态变化
observer.on('simStateChange', (data: observer.SimStateInfo) => {
  console.log(`SIM state changed: ${data.simState}`);
});

// 监听通话状态变化
observer.on('callStateChange', (data: observer.CallStateInfo) => {
  console.log(`Call state: ${data.callState}`);
  // CallState: CALL_STATUS_UNKNOWN(0), CALL_STATUS_IDLE(1), CALL_STATUS_RINGING(2), CALL_STATUS_OFFHOOK(3)
});
```

### 数据业务

```typescript
import data from '@ohos.telephony.data';

// 检查数据业务是否启用
let isDataEnabled = data.isCellularDataEnabled();
console.log('Cellular data enabled: ' + isDataEnabled);

// 检查数据漫游是否启用
let isRoaming = data.isCellularDataRoamingEnabled(0);
console.log('Data roaming: ' + isRoaming);

// 获取默认数据SIM卡
let defaultSlot = data.getDefaultCellularDataSlotId();
console.log('Default data slot: ' + defaultSlot);

// 监听数据连接状态
data.on('cellularDataChange', (dataInfo: data.CellularDataState) => {
  console.log('Cellular data state: ' + dataInfo);
});
```

### 名片(vCard)解析

```typescript
import vcard from '@ohos.telephony.vcard';

// 解析vCard字符串
let vcardString = `BEGIN:VCARD
VERSION:3.0
FN:张三
TEL:13800138000
EMAIL:test@example.com
END:VCARD`;

let result = await vcard.parseVCard(vcardString);
console.log('Name: ' + result.fullName);
console.log('Phone: ' + result.phoneNumbers);
```

## 使用示例

### 一键拨号

```typescript
import call from '@ohos.telephony.call';

@Entry
@Component
struct CallPage {
  @State phoneNumber: string = '';

  async makeCall(): Promise<void> {
    try {
      // 检查是否支持通话
      if (!call.hasVoiceCapability()) {
        promptAction.showToast({ message: '设备不支持通话功能' });
        return;
      }

      // 拨打电话
      await call.dial(this.phoneNumber);
    } catch (error) {
      console.error('Call failed: ' + error.message);
    }
  }

  build() {
    Column({ space: 20 }) {
      TextInput({ placeholder: '输入电话号码', text: this.phoneNumber })
        .type(InputType.PhoneNumber)
        .width('80%')
        .onChange((value) => { this.phoneNumber = value; })

      Button('拨打')
        .width('80%')
        .onClick(() => this.makeCall())
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.Center)
  }
}
```

### 短信发送

```typescript
import sms from '@ohos.telephony.sms';

@Entry
@Component
struct SmsPage {
  @State phoneNumbers: string = '';
  @State message: string = '';
  @State sendStatus: string = '';

  async sendSms(): Promise<void> {
    let numbers = this.phoneNumbers.split(',').map(s => s.trim());

    for (let number of numbers) {
      try {
        await sms.sendMessage({
          slotId: 0,
          destinationHost: number,
          content: this.message,
          sendCallback: (err, data) => {
            if (err) {
              this.sendStatus = `发送失败: ${number}`;
            } else {
              this.statusText = `发送成功: ${number}`;
            }
          }
        });
      } catch (error) {
        console.error('Send SMS failed: ' + error.message);
      }
    }
  }

  build() {
    Column({ space: 20 }) {
      TextInput({ placeholder: '收件人(多个用逗号分隔)', text: this.phoneNumbers })
        .width('90%')

      TextArea({ placeholder: '短信内容', text: this.message })
        .width('90%')
        .height(150)
        .onChange((value) => { this.message = value; })

      Text(this.sendStatus)
        .fontColor('#666')

      Button('发送短信')
        .width('90%')
        .onClick(() => this.sendSms())
    }
    .width('100%')
    .height('100%')
    .padding(20)
  }
}
```

### SIM卡信息展示

```typescript
import sim from '@ohos.telephony.sim';
import observer from '@ohos.telephony.observer';

@Entry
@Component
struct SimInfoPage {
  @State sim1Info: string = '读取中...';
  @State sim2Info: string = '读取中...';

  aboutToAppear(): void {
    this.loadSimInfo(0);
    this.loadSimInfo(1);
  }

  async loadSimInfo(slotId: number): Promise<void> {
    try {
      if (!sim.hasSimCard(slotId)) {
        if (slotId === 0) this.sim1Info = '未插入SIM卡';
        else this.sim2Info = '未插入SIM卡';
        return;
      }

      let operator = sim.getSimOperatorName(slotId);
      let state = sim.getSimState(slotId);
      let iso = sim.getIsoCountryCodeForSim(slotId);

      let info = `运营商: ${operator}\n状态: ${state}\n国家: ${iso}`;

      if (slotId === 0) this.sim1Info = info;
      else this.sim2Info = info;
    } catch (error) {
      console.error('Load SIM info failed: ' + error.message);
    }
  }

  build() {
    Column({ space: 20 }) {
      Text('SIM卡信息')
        .fontSize(24)
        .fontWeight(FontWeight.Bold)

      Row({ space: 20 }) {
        Column() {
          Text('SIM卡 1')
            .fontWeight(FontWeight.Bold)
          Text(this.sim1Info)
            .fontSize(12)
        }
        .layoutWeight(1)
        .padding(10)
        .border({ width: 1, color: '#ddd', radius: 8 })

        Column() {
          Text('SIM卡 2')
            .fontWeight(FontWeight.Bold)
          Text(this.sim2Info)
            .fontSize(12)
        }
        .layoutWeight(1)
        .padding(10)
        .border({ width: 1, color: '#ddd', radius: 8 })
      }
    }
    .width('100%')
    .padding(20)
  }
}
```

### 通话状态监听

```typescript
import call from '@ohos.telephony.call';

@Entry
@Component
struct CallMonitorPage {
  @State callState: string = '空闲';
  @State callHistory: string[] = [];
  private callStateCallback = (data: call.CallStateChange) => {
    this.updateCallState(data);
  };

  aboutToAppear(): void {
    call.on('callStateChange', this.callStateCallback);
  }

  aboutToDisappear(): void {
    call.off('callStateChange', this.callStateCallback);
  }

  private updateCallState(data: call.CallStateChange): void {
    switch (data.state) {
      case call.CallState.CALL_STATE_IDLE:
        this.callState = '空闲';
        break;
      case call.CallState.CALL_STATE_RINGING:
        this.callState = `来电响铃: ${data.accountId}`;
        this.callHistory.push(`来电: ${new Date().toLocaleString()}`);
        break;
      case call.CallState.CALL_STATE_OFFHOOK:
        this.callState = '通话中';
        break;
      default:
        this.callState = '未知状态';
    }
  }

  build() {
    Column({ space: 20 }) {
      Text('通话状态: ' + this.callState)
        .fontSize(20)

      Text('通话记录')
        .fontSize(16)

      List() {
        ForEach(this.callHistory, (item: string, index: number) => {
          ListItem() {
            Text(item)
          }
        })
      }
      .layoutWeight(1)
      .width('100%')
    }
    .width('100%')
    .padding(20)
  }
}
```

## 权限配置

```json
{
  "module": {
    "requestPermissions": [
      { "name": "ohos.permission.MAKE_CALL" },
      { "name": "ohos.permission.SEND_MESSAGES" },
      { "name": "ohos.permission.RECEIVE_SMS" },
      { "name": "ohos.permission.READ_CONTACTS" },
      { "name": "ohos.permission.GET_NETWORK_INFO" }
    ]
  }
}
```

## CallState 枚举

```typescript
enum CallState {
  CALL_STATE_UNKNOWN = 0,   // 未知
  CALL_STATE_IDLE = 1,      // 空闲
  CALL_STATE_RINGING = 2,   // 来电响铃
  CALL_STATE_OFFHOOK = 3    // 通话中
}
```

## SimState 枚举

```typescript
enum SimState {
  SIM_STATE_UNKNOWN = 0,    // 未知
  SIM_STATE_ABSENT = 1,     // 无SIM卡
  SIM_STATE_PRESENT = 2,    // SIM卡正常
  SIM_STATE_LOCKED = 3      // SIM卡锁定
}
```

## 最佳实践

1. **拨打电话前检查权限**:
```typescript
// 先请求权限
let permission = await requestPermissions(['ohos.permission.MAKE_CALL']);
if (permission) {
  await call.dial(phoneNumber);
}
```

2. **短信发送失败处理**:
```typescript
await sms.sendMessage({
  slotId: 0,
  destinationHost: phoneNumber,
  content: message,
  sendCallback: (err, data) => {
    if (err) {
      // 重试或记录失败
      console.error('Send failed, will retry...');
    }
  }
});
```

3. **双卡槽处理**:
```typescript
// 获取默认SIM卡槽
let defaultSlot = data.getDefaultCellularDataSlotId();
// 或让用户选择
```

## 注意事项

1. 拨打电话和发送短信需要用户授权
2. 部分API需要系统应用权限
3. 双卡设备需要指定slotId
4. 监听器要及时取消注册避免内存泄漏

Attribution

IsKenKenYaIsKenKenYa
View sourceMore from IsKenKenYa →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284072 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →