1/* 2* Copyright (C) 2021 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 16import {AsyncCallback} from "./basic"; 17 18/** 19 * Provides applications with APIs for obtaining SIM card status, card file information, and card specifications. 20 * SIM cards include SIM, USIM, and CSIM cards. 21 * 22 * @since 6 23 * @sysCap SystemCapability.Telephony.Telephony 24 */ 25declare namespace sim { 26 /** 27 * Obtains the default card slot for the voice service. 28 * 29 * @param callback Returns {@code 0} if card 1 is used as the default card slot for the voice service; 30 * returns {@code 1} if card 2 is used as the default card slot for the voice service; 31 * returns {@code -1} if no card is available for the voice service. 32 * @since 7 33 */ 34 function getDefaultVoiceSlotId(callback: AsyncCallback<number>): void; 35 function getDefaultVoiceSlotId(): Promise<number>; 36 37 /** 38 * Obtains the ISO country code of the SIM card in a specified slot. 39 * 40 * @param slotId Indicates the card slot index number, 41 * ranging from 0 to the maximum card slot index number supported by the device. 42 * @param callback Returns the country code defined in ISO 3166-2; returns an empty string if no SIM card is inserted. 43 */ 44 function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback<string>): void; 45 function getISOCountryCodeForSim(slotId: number): Promise<string>; 46 47 /** 48 * Obtains the home PLMN number of the SIM card in a specified slot. 49 * 50 * <p>The value is recorded in the SIM card and is irrelevant to the network 51 * with which the SIM card is currently registered. 52 * 53 * @param slotId Indicates the card slot index number, 54 * ranging from 0 to the maximum card slot index number supported by the device. 55 * @param callback Returns the PLMN number; returns an empty string if no SIM card is inserted. 56 */ 57 function getSimOperatorNumeric(slotId: number, callback: AsyncCallback<string>): void; 58 function getSimOperatorNumeric(slotId: number): Promise<string>; 59 60 /** 61 * Obtains the service provider name (SPN) of the SIM card in a specified slot. 62 * 63 * <p>The value is recorded in the EFSPN file of the SIM card and is irrelevant to the network 64 * with which the SIM card is currently registered. 65 * 66 * @param slotId Indicates the card slot index number, 67 * ranging from 0 to the maximum card slot index number supported by the device. 68 * @param callback Returns the SPN; returns an empty string if no SIM card is inserted or 69 * no EFSPN file in the SIM card. 70 */ 71 function getSimSpn(slotId: number, callback: AsyncCallback<string>): void; 72 function getSimSpn(slotId: number): Promise<string>; 73 74 /** 75 * Obtains the state of the SIM card in a specified slot. 76 * 77 * @param slotId Indicates the card slot index number, 78 * ranging from {@code 0} to the maximum card slot index number supported by the device. 79 * @param callback Returns one of the following SIM card states: 80 * <ul> 81 * <li>{@code SimState#SIM_STATE_UNKNOWN} 82 * <li>{@code SimState#SIM_STATE_NOT_PRESENT} 83 * <li>{@code SimState#SIM_STATE_LOCKED} 84 * <li>{@code SimState#SIM_STATE_NOT_READY} 85 * <li>{@code SimState#SIM_STATE_READY} 86 * <li>{@code SimState#SIM_STATE_LOADED} 87 * </ul> 88 */ 89 function getSimState(slotId: number, callback: AsyncCallback<SimState>): void; 90 function getSimState(slotId: number): Promise<SimState>; 91 92 /** 93 * Obtains the ICCID of the SIM card in a specified slot. 94 * 95 * <p>The ICCID is a unique identifier of a SIM card. It consists of 20 digits 96 * and is recorded in the EFICCID file of the SIM card. 97 * 98 * <p>Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. 99 * 100 * @param slotId Indicates the card slot index number, 101 * ranging from 0 to the maximum card slot index number supported by the device. 102 * @param callback Returns the ICCID; returns an empty string if no SIM card is inserted. 103 * @permission ohos.permission.GET_TELEPHONY_STATE 104 */ 105 function getSimIccId(slotId: number, callback: AsyncCallback<string>): void; 106 function getSimIccId(slotId: number): Promise<string>; 107 108 /** 109 * Obtains the Group Identifier Level 1 (GID1) of the SIM card in a specified slot. 110 * The GID1 is recorded in the EFGID1 file of the SIM card. 111 * 112 * <p>Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. 113 * 114 * @param slotId Indicates the card slot index number, 115 * ranging from 0 to the maximum card slot index number supported by the device. 116 * @param callback Returns the GID1; returns an empty string if no SIM card is inserted or 117 * no GID1 in the SIM card. 118 * @permission ohos.permission.GET_TELEPHONY_STATE 119 */ 120 function getSimGid1(slotId: number, callback: AsyncCallback<string>): void; 121 function getSimGid1(slotId: number): Promise<string>; 122 123 /** 124 * @permission ohos.permission.GET_TELEPHONY_STATE 125 * @systemapi Hide this for inner system use. 126 */ 127 function getIMSI(slotId: number, callback: AsyncCallback<string>): void; 128 function getIMSI(slotId: number): Promise<string>; 129 130 /** 131 * @permission ohos.permission.GET_TELEPHONY_STATE 132 * @systemapi Hide this for inner system use. 133 * @since 7 134 */ 135 function getSimAccountInfo(slotId: number, callback: AsyncCallback<IccAccountInfo>): void; 136 function getSimAccountInfo(slotId: number): Promise<IccAccountInfo>; 137 138 /** 139 * @permission ohos.permission.SET_TELEPHONY_STATE 140 * @systemapi Hide this for inner system use. 141 * @since 7 142 */ 143 function setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback<void>): void; 144 function setDefaultVoiceSlotId(slotId: number): Promise<void>; 145 146 /** 147 * @permission ohos.permission.SET_TELEPHONY_STATE 148 * @systemapi Hide this for inner system use. 149 * @since 7 150 */ 151 function unlockPin(slotId: number, pin: string, callback: AsyncCallback<LockStatusResponse>): void; 152 function unlockPin(slotId: number, pin: string): Promise<LockStatusResponse>; 153 154 /** 155 * @permission ohos.permission.SET_TELEPHONY_STATE 156 * @systemapi Hide this for inner system use. 157 * @since 7 158 */ 159 function unlockPuk(slotId: number, newPin: string, puk: string, callback: AsyncCallback<LockStatusResponse>): void; 160 function unlockPuk(slotId: number, newPin: string, puk: string): Promise<LockStatusResponse>; 161 162 /** 163 * @permission ohos.permission.SET_TELEPHONY_STATE 164 * @systemapi Hide this for inner system use. 165 * @since 7 166 */ 167 function alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback<LockStatusResponse>): void; 168 function alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResponse>; 169 170 /** 171 * @permission ohos.permission.SET_TELEPHONY_STATE 172 * @systemapi Hide this for inner system use. 173 * @since 7 174 */ 175 function setLockState(slotId: number, pin: string, enable: number, callback: AsyncCallback<LockStatusResponse>): void; 176 function setLockState(slotId: number, pin: string, enable: number): Promise<LockStatusResponse>; 177 178 /** 179 * @systemapi Hide this for inner system use. 180 * @since 7 181 */ 182 export interface IccAccountInfo { 183 slotIndex: number, /* slot id */ 184 showName: string, /* display name for card */ 185 showNumber: string, /* display number for card */ 186 } 187 188 /** 189 * @systemapi Hide this for inner system use. 190 * @since 7 191 */ 192 export interface LockStatusResponse { 193 result: number, /* Current operation result */ 194 remain?: number, /* Operations remaining */ 195 } 196 197 export enum SimState { 198 /** 199 * Indicates unknown SIM card state, that is, the accurate status cannot be obtained. 200 */ 201 SIM_STATE_UNKNOWN, 202 203 /** 204 * Indicates that the SIM card is in the <b>not present</b> state, that is, no SIM card is inserted 205 * into the card slot. 206 */ 207 SIM_STATE_NOT_PRESENT, 208 209 /** 210 * Indicates that the SIM card is in the <b>locked</b> state, that is, the SIM card is locked by the 211 * personal identification number (PIN)/PIN unblocking key (PUK) or network. 212 */ 213 SIM_STATE_LOCKED, 214 215 /** 216 * Indicates that the SIM card is in the <b>not ready</b> state, that is, the SIM card is in position 217 * but cannot work properly. 218 */ 219 SIM_STATE_NOT_READY, 220 221 /** 222 * Indicates that the SIM card is in the <b>ready</b> state, that is, the SIM card is in position and 223 * is working properly. 224 */ 225 SIM_STATE_READY, 226 227 /** 228 * Indicates that the SIM card is in the <b>loaded</b> state, that is, the SIM card is in position and 229 * is working properly. 230 */ 231 SIM_STATE_LOADED 232 } 233} 234 235export default sim;