MCPcopy
hub / github.com/ys1231/MoveCertificate / getInstallCertResults

Function getInstallCertResults

webdev/src/cert-service.ts:222–258  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220 * 4. 逐个识别证书名称,并判断是否已成功安装到系统目录
221 */
222export async function getInstallCertResults(): Promise<CertEntry[]> {
223 try {
224 // 1. 获取当前 Android 系统版本号
225 const { errno, stdout } = await exec('getprop ro.build.version.release') as ExecResult;
226 const systemVersion = Number(stdout);
227 if (isNaN(systemVersion)) {
228 toast(t('getVersionFailed'));
229 return [];
230 }
231
232 // 2. 列出用户安装的证书(/data/misc/user/0/cacerts-added/)
233 const userCerts = await getFileList(CERT_USER_SYSTEM);
234
235 // 3. 列出系统证书目录
236 const systemCertPath = systemVersion >= 14 ? CERT_HIGH_SYSTEM : CERT_LOW_SYSTEM;
237 const systemCerts = await getFileList(systemCertPath);
238
239 if (!userCerts.length && !systemCerts.length) {
240 toast(t('noCertFound'));
241 return [];
242 }
243
244 // 4. 逐个识别证书名称并判断状态
245 const results: CertEntry[] = [];
246 for (const item of userCerts) {
247 const name = await getCertName(CERT_USER_SYSTEM + item);
248 const status = systemCerts.includes(item) ? 'success' : 'failed';
249 results.push({ status, name: `${item}: ${name}` });
250 }
251
252 return results;
253 } catch (e) {
254 console.error('获取证书列表失败:', e);
255 toast(t('getCertListFailed'));
256 return [];
257 }
258}
259
260// ==================== 模式配置 ====================
261

Callers 1

loadCertsTabFunction · 0.85

Calls 3

tFunction · 0.85
getFileListFunction · 0.85
getCertNameFunction · 0.85

Tested by

no test coverage detected