|
|
AIWROKÈí¼þƽ̨É豸ÐÅÏ¢È«Ãæ¼ì²â¹¤¾ßÀý×Ó
- /**
- * AIWROKƽ̨É豸ÐÅÏ¢È«Ãæ¼ì²â¹¤¾ß
- * //🍎½»Á÷QQȺ711841924Ⱥһ£¬Æ»¹ûÄÚ²âȺ£¬528816639
- * ±¾¹¤¾ßÖ¼ÔÚÈ«Ãæ¼ì²âºÍչʾAndroidÉ豸µÄ¸÷ÏîÓ²¼þºÍÈí¼þÐÅÏ¢
- * °üÀ¨É豸»ù±¾ÐÅÏ¢¡¢ÆÁÄ»²ÎÊý¡¢µç³Ø×´Ì¬¡¢´æ´¢¿Õ¼ä¡¢ÄÚ´æÊ¹ÓÃÇé¿ö¡¢ÍøÂç״̬µÈ
- * ²ÉÓÃÁ˶à²ãÈÝ´í»úÖÆºÍÓѺõĿÉÊÓ»¯Õ¹Ê¾·½Ê½
- * ÊÊÓÃÓÚAIWROK×Ô¶¯»¯Æ½Ì¨»·¾³
- */
- // °²È«µ÷Óú¯Êý£¬·ÀÖ¹·½·¨²»´æÔÚʱ±¨´í
- function safeCall(methodName, caller, defaultValue) {
- try {
- if (typeof caller[methodName] === 'function') {
- var result = caller[methodName]();
- return result !== undefined && result !== null ? result : (defaultValue || "δ֪");
- } else {
- return defaultValue || "·½·¨²»¿ÉÓÃ";
- }
- } catch (e) {
- return defaultValue || "µ÷Óóö´í: " + e.message;
- }
- }
- // ¸ü°²È«µÄµ÷Óú¯Êý£¬Ö§³Ö´«²Î
- function safeCallWithArgs(methodName, caller, args, defaultValue) {
- try {
- if (typeof caller[methodName] === 'function') {
- var result = caller[methodName](args);
- return result !== undefined && result !== null ? result : (defaultValue || "δ֪");
- } else {
- return defaultValue || "·½·¨²»¿ÉÓÃ";
- }
- } catch (e) {
- return defaultValue || "µ÷Óóö´í: " + e.message;
- }
- }
- // ¸ñʽ»¯´æ´¢¿Õ¼ä´óС
- function formatStorageSize(bytes) {
- if (bytes <= 0) return "0 B";
-
- var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
- var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
- var size = Math.round(bytes / Math.pow(1024, i) * 100) / 100;
- return size + ' ' + sizes[i];
- }
- // »ñÈ¡É豸»ù±¾ÐÅÏ¢
- function getDeviceInfo() {
- printl("========== É豸»ù±¾ÐÅÏ¢ ==========");
-
- var info = {
- "Éè±¸Æ·ÅÆ": safeCall("getBrand", device),
- "É豸ÐͺÅ": safeCall("getModel", device),
- "ϵͳ°æ±¾": safeCall("getVersion", device),
- "É豸ID": safeCall("getDeviceID", device),
- "É豸ÕûÊýID": safeCall("getDeviceIntID", device),
- "IMEI": safeCall("getIMEI", device),
- "OAID": safeCall("getOAID", device),
- "IPµØÖ·": safeCall("getIP", device)
- };
-
- for (var key in info) {
- printl(key + ": " + info[key]);
- }
-
- return info;
- }
- // »ñÈ¡ÆÁÄ»ÐÅÏ¢
- function getScreenInfo() {
- printl("\n========== ÆÁÄ»ÐÅÏ¢ ==========");
-
- var width = 0, height = 0;
-
- // ³¢ÊÔʹÓÃscreen¶ÔÏó»ñÈ¡ÆÁÄ»ÐÅÏ¢
- if (typeof screen !== 'undefined') {
- if (typeof screen.getScreenWidth === 'function') {
- try {
- width = screen.getScreenWidth();
- } catch (e) {
- printl("ͨ¹ýscreen»ñÈ¡¿í¶Èʧ°Ü: " + e.message);
- }
- }
-
- if (typeof screen.getScreenHeight === 'function') {
- try {
- height = screen.getScreenHeight();
- } catch (e) {
- printl("ͨ¹ýscreen»ñÈ¡¸ß¶Èʧ°Ü: " + e.message);
- }
- }
- }
-
- // Èç¹ûscreen¶ÔÏ󲻿ÉÓûò»ñȡʧ°Ü£¬³¢ÊÔdevice¶ÔÏó
- if ((!width || !height) && typeof device !== 'undefined') {
- if (typeof device.getScreenWidth === 'function') {
- try {
- width = device.getScreenWidth();
- } catch (e) {
- printl("ͨ¹ýdevice»ñÈ¡¿í¶Èʧ°Ü: " + e.message);
- }
- }
-
- if (typeof device.getScreenHeight === 'function') {
- try {
- height = device.getScreenHeight();
- } catch (e) {
- printl("ͨ¹ýdevice»ñÈ¡¸ß¶Èʧ°Ü: " + e.message);
- }
- }
- }
-
- // Èç¹ûÈÔȻûÓлñÈ¡µ½£¬Ôò³¢ÊÔʹÓÃĬÈÏÖµ
- if (!width && typeof device !== 'undefined' && typeof device.width === 'number') {
- width = device.width;
- }
-
- if (!height && typeof device !== 'undefined' && typeof device.height === 'number') {
- height = device.height;
- }
-
- if (width && height) {
- printl("ÆÁÄ»·Ö±æÂÊ: " + width + " ¡Á " + height);
- printl("ÆÁÄ»ÃܶÈ: " + width + " ¡Á " + height + " ÏñËØ");
- } else {
- printl("ÆÁÄ»·Ö±æÂÊ: ÎÞ·¨»ñÈ¡");
- }
-
- return { width: width, height: height };
- }
- // »ñÈ¡µç³ØÐÅÏ¢
- function getBatteryInfo() {
- printl("\n========== µç³ØÐÅÏ¢ ==========");
-
- var level = "δ֪";
- var status = "δ֪";
-
- if (typeof device !== 'undefined') {
- // ³¢ÊÔ¶àÖÖ·½Ê½»ñÈ¡µç³ØÐÅÏ¢
- if (typeof device.getBatteryLevel === 'function') {
- try {
- level = device.getBatteryLevel();
- if (level === null || level === undefined) {
- level = "δ֪";
- }
- } catch (e) {
- printl("»ñÈ¡µç³ØµçÁ¿Ê§°Ü: " + e.message);
- }
- }
-
- // ×¢Ò⣺device.getBatteryStatus ·½·¨²»´æÔÚ£¬Òò´ËÒÆ³ýÏà¹Ø´úÂë
- }
-
- // ¸ñʽ»¯µç³ØÐÅÏ¢ÏÔʾ
- if (level !== "δ֪" && !isNaN(level)) {
- printl("µç³ØµçÁ¿: " + level + "%");
-
- // ¸ù¾ÝµçÁ¿ÏÔʾ״̬ͼ±ê
- var batteryIcon = "🔋";
- if (level > 80) batteryIcon = "🔋";
- else if (level > 50) batteryIcon = "🔋";
- else if (level > 20) batteryIcon = "🔋";
- else batteryIcon = "🪫";
-
- printl("µçÁ¿×´Ì¬: " + batteryIcon + " " + level + "%");
- } else {
- printl("µç³ØµçÁ¿: " + level);
- }
-
- // ÒÆ³ý¶Ô²»´æÔÚ·½·¨µÄµ÷ÓÃ
- // printl("µç³Ø×´Ì¬: " + status);
-
- return { level: level };
- }
- // »ñÈ¡´æ´¢ÐÅÏ¢
- function getStorageInfo() {
- printl("\n========== ´æ´¢ÐÅÏ¢ ==========");
-
- // ³¢ÊÔ¶àÖÖ·½Ê½»ñÈ¡´æ´¢ÐÅÏ¢
- if (typeof file !== 'undefined') {
- var totalSpace = -1;
- var freeSpace = -1;
-
- // ³¢ÊÔ»ñÈ¡×ܿռä
- if (typeof file.getTotalSpace === 'function') {
- try {
- totalSpace = file.getTotalSpace("/sdcard/");
- if (totalSpace <= 0) {
- // ³¢ÊÔÆäËû·¾¶
- totalSpace = file.getTotalSpace("/");
- }
- } catch (e) {
- printl("»ñÈ¡×Ü´æ´¢¿Õ¼äʧ°Ü: " + e.message);
- }
- }
-
- // ³¢ÊÔ»ñÈ¡¿ÉÓÿռä
- if (typeof file.getFreeSpace === 'function') {
- try {
- freeSpace = file.getFreeSpace("/sdcard/");
- if (freeSpace <= 0) {
- // ³¢ÊÔÆäËû·¾¶
- freeSpace = file.getFreeSpace("/");
- }
- } catch (e) {
- printl("»ñÈ¡¿ÉÓô洢¿Õ¼äʧ°Ü: " + e.message);
- }
- }
-
- // Èç¹ûͨ¹ýfile¶ÔÏóµÄ·½·¨»ñÈ¡³É¹¦
- if (totalSpace > 0 && freeSpace >= 0) {
- var usedSpace = totalSpace - freeSpace;
- var usedPercentage = ((usedSpace / totalSpace) * 100).toFixed(1);
- printl("×Ü´æ´¢¿Õ¼ä: " + formatStorageSize(totalSpace));
- printl("ÒÑʹÓÿռä: " + formatStorageSize(usedSpace) + " (" + usedPercentage + "%)");
- printl("¿ÉÓÿռä: " + formatStorageSize(freeSpace));
-
- // ÏÔʾ´æ´¢Ê¹ÓÃÇé¿öµÄ½ø¶ÈÌõ
- var progressBarLength = 20;
- var filledLength = Math.round((usedSpace / totalSpace) * progressBarLength);
- var bar = "[" + Array(filledLength + 1).join("¨€") + Array(progressBarLength - filledLength + 1).join("░") + "]";
- printl("ʹÓÃÇé¿ö: " + bar);
- return;
- }
- }
-
- // ³¢ÊÔͨ¹ýdevice¶ÔÏó»ñÈ¡´æ´¢ÐÅÏ¢£¨Ö»³¢ÊÔȷʵ´æÔڵķ½·¨£©
- if (typeof device !== 'undefined') {
- try {
- // ¼ì²éÊÇ·ñÓлñÈ¡´æ´¢ÐÅÏ¢µÄ·½·¨£¨²»µ÷Óò»´æÔڵķ½·¨£©
- var deviceMethods = [];
- for (var prop in device) {
- if (typeof device[prop] === 'function' && prop.indexOf('Storage') !== -1) {
- deviceMethods.push(prop);
- }
- }
-
- if (deviceMethods.length > 0) {
- printl("É豸´æ´¢Ïà¹Ø·½·¨: " + deviceMethods.join(', '));
- }
- } catch (e) {
- // ºöÂÔ´íÎó
- }
- }
-
- // ³¢ÊÔͨ¹ý»·¾³±äÁ¿»ñÈ¡´æ´¢ÐÅÏ¢
- try {
- if (typeof java !== 'undefined' && java.lang && java.lang.System) {
- var system = java.lang.System;
- if (system) {
- var properties = system.getProperties();
- if (properties) {
- var fileSeparator = properties.get("file.separator") || "/";
- var sdcardPath = "/sdcard";
-
- // ³¢ÊÔʹÓÃJava FileÀà»ñÈ¡´æ´¢ÐÅÏ¢
- if (java.io && java.io.File) {
- var File = java.io.File;
- var sdcardFile = new File(sdcardPath);
- if (sdcardFile.exists()) {
- totalSpace = sdcardFile.getTotalSpace();
- freeSpace = sdcardFile.getFreeSpace();
-
- if (totalSpace > 0 && freeSpace >= 0) {
- var usedSpace = totalSpace - freeSpace;
- var usedPercentage = ((usedSpace / totalSpace) * 100).toFixed(1);
- printl("×Ü´æ´¢¿Õ¼ä: " + formatStorageSize(totalSpace));
- printl("ÒÑʹÓÿռä: " + formatStorageSize(usedSpace) + " (" + usedPercentage + "%)");
- printl("¿ÉÓÿռä: " + formatStorageSize(freeSpace));
-
- // ÏÔʾ´æ´¢Ê¹ÓÃÇé¿öµÄ½ø¶ÈÌõ
- var progressBarLength = 20;
- var filledLength = Math.round((usedSpace / totalSpace) * progressBarLength);
- var bar = "[" + Array(filledLength + 1).join("¨€") + Array(progressBarLength - filledLength + 1).join("░") + "]";
- printl("ʹÓÃÇé¿ö: " + bar);
- return;
- }
- }
- }
- }
- }
- }
- } catch (e) {
- printl("ͨ¹ýJava API»ñÈ¡´æ´¢ÐÅϢʧ°Ü: " + e.message);
- }
-
- printl("´æ´¢ÐÅÏ¢: ÎÞ·¨»ñÈ¡");
- }
- // »ñÈ¡ÄÚ´æÐÅÏ¢
- function getMemoryInfo() {
- printl("\n========== ÄÚ´æÐÅÏ¢ ==========");
-
- if (typeof app !== 'undefined') {
- // ³¢ÊÔʹÓÃapp.getMemoryPercent()»ñÈ¡ÄÚ´æÊ¹ÓðٷֱÈ
- if (typeof app.getMemoryPercent === 'function') {
- try {
- var memoryPercent = app.getMemoryPercent();
- if (memoryPercent !== null && memoryPercent !== undefined) {
- printl("ÄÚ´æÊ¹ÓÃÂÊ: " + memoryPercent + "%");
-
- // ¸ù¾ÝÄÚ´æÊ¹ÓÃÂÊÏÔʾ״̬ͼ±ê
- var memoryIcon = "🧠";
- if (memoryPercent > 80) memoryIcon = "⚠️";
- else if (memoryPercent > 60) memoryIcon = "MemoryWarning";
- printl("ÄÚ´æ×´Ì¬: " + memoryIcon + " " + memoryPercent + "%");
- return;
- }
- } catch (e) {
- printl("»ñÈ¡ÄÚ´æÊ¹ÓÃÂÊʧ°Ü: " + e.message);
- }
- }
-
- // ³¢ÊÔʹÓÃapp.getMemory()»ñÈ¡ÄÚ´æÐÅÏ¢
- if (typeof app.getMemory === 'function') {
- try {
- var memory = app.getMemory();
- // getMemory·µ»ØµÄÊÇJSON×Ö·û´®£¬ÐèÒª½âÎö
- if (typeof memory === 'string' && memory.length > 0) {
- var memoryObj = JSON.parse(memory);
- if (memoryObj && memoryObj.used) {
- printl("µ±Ç°Ó¦ÓÃÄÚ´æÕ¼ÓÃ: " + formatStorageSize(memoryObj.used));
- if (memoryObj.total) {
- printl("Ó¦ÓÃÄÚ´æ×ÜÁ¿: " + formatStorageSize(memoryObj.total));
- }
- return;
- }
- } else if (typeof memory === 'number' && memory > 0) {
- // Èç¹ûÖ±½Ó·µ»ØÊý×Ö
- printl("µ±Ç°Ó¦ÓÃÄÚ´æÕ¼ÓÃ: " + formatStorageSize(memory));
- return;
- }
- } catch (e) {
- printl("½âÎöÄÚ´æÐÅϢʧ°Ü: " + e.message);
- }
- }
- }
-
- printl("ÄÚ´æÐÅÏ¢: ÎÞ·¨»ñÈ¡");
- }
- // »ñÈ¡ÍøÂçÐÅÏ¢
- function getNetworkInfo() {
- printl("\n========== ÍøÂçÐÅÏ¢ ==========");
-
- var hasNetworkInfo = false;
-
- // WiFiÐÅÏ¢£¨¸ü°²È«µÄ¼ì²é·½Ê½£©
- if (typeof wifi !== 'undefined') {
- if (typeof wifi.isWifiEnabled === 'function') {
- try {
- var isWifiEnabled = wifi.isWifiEnabled();
- printl("WiFi״̬: " + (isWifiEnabled ? "ÒÑÆôÓÃ" : "ÒѽûÓÃ"));
- hasNetworkInfo = true;
-
- if (isWifiEnabled && typeof wifi.getSSID === 'function') {
- var ssid = wifi.getSSID();
- if (ssid) {
- printl("WiFiÃû³Æ: " + ssid);
- }
- }
- } catch (e) {
- printl("»ñÈ¡WiFiÐÅϢʧ°Ü: " + e.message);
- }
- } else {
- // ¼ì²éwifi¶ÔÏóÓÐÄÄЩ¿ÉÓ÷½·¨
- var wifiMethods = [];
- for (var prop in wifi) {
- if (typeof wifi[prop] === 'function') {
- wifiMethods.push(prop);
- }
- }
-
- if (wifiMethods.length > 0) {
- printl("WiFi¿ÉÓ÷½·¨: " + wifiMethods.join(', '));
- hasNetworkInfo = true;
- } else {
- printl("WiFi¹¦ÄÜ: ²»¿ÉÓÃ");
- }
- }
- } else {
- printl("WiFiÄ£¿é: δÕÒµ½");
- }
-
- // ³¢ÊÔͨ¹ýHTTPÇëÇó¼ì²éÍøÂçÁ¬½Ó
- if (typeof okHttp !== 'undefined') {
- try {
- printl("ÕýÔÚ²âÊÔÍøÂçÁ¬½Ó...");
- var http = new okHttp();
- var response = http.get("http://www.baidu.com");
-
- if (response && response.length > 0) {
- printl("ÍøÂçÁ¬½Ó: ¿É·ÃÎʰٶÈ");
- hasNetworkInfo = true;
- } else {
- printl("ÍøÂçÁ¬½Ó: ÎÞ·¨·ÃÎÊ°Ù¶È (¿ÕÏìÓ¦)");
- }
- } catch (e) {
- printl("ÍøÂçÁ¬½Ó²âÊÔʧ°Ü: " + e.message);
- // ¼´Ê¹²âÊÔʧ°Ü£¬Ò²±ê¼ÇΪÓÐÍøÂçÐÅÏ¢
- hasNetworkInfo = true;
- }
- } else {
- printl("HTTP¿Í»§¶Ë: δÕÒµ½");
- }
-
- // ³¢ÊÔ»ñÈ¡Éè±¸ÍøÂçÐÅÏ¢
- if (typeof device !== 'undefined') {
- // ¼ì²éÊÇ·ñÓлñÈ¡IPµÄ·½·¨
- if (typeof device.getIP === 'function') {
- try {
- var ip = device.getIP();
- if (ip && ip !== "unknown") {
- printl("É豸IP: " + ip);
- hasNetworkInfo = true;
- }
- } catch (e) {
- printl("»ñÈ¡É豸IPʧ°Ü: " + e.message);
- }
- } else {
- // ¼ì²édevice¶ÔÏóÓÐÄÄÐ©ÍøÂçÏà¹Ø·½·¨
- var networkMethods = [];
- for (var prop in device) {
- if (typeof device[prop] === 'function' && (prop.indexOf('Network') !== -1 || prop.indexOf('IP') !== -1)) {
- networkMethods.push(prop);
- }
- }
-
- if (networkMethods.length > 0) {
- printl("Éè±¸ÍøÂçÏà¹Ø·½·¨: " + networkMethods.join(', '));
- hasNetworkInfo = true;
- }
- }
- }
-
- if (!hasNetworkInfo) {
- printl("ÍøÂçÐÅÏ¢: ÎÞ·¨»ñÈ¡");
- }
- }
- // »ñÈ¡µ±Ç°ÔËÐеÄÓ¦ÓÃÐÅÏ¢
- function getRunningAppInfo() {
- printl("\n========== Ó¦ÓÃÐÅÏ¢ ==========");
-
- if (typeof app !== 'undefined') {
- var packageName = "δ֪";
-
- // ³¢ÊÔ¶àÖÖ·½Ê½»ñÈ¡°üÃû
- if (typeof app.getTopPackName === 'function') {
- try {
- packageName = app.getTopPackName();
- } catch (e) {
- printl("ͨ¹ýgetTopPackName»ñÈ¡°üÃûʧ°Ü: " + e.message);
- }
- }
-
- if ((packageName === "δ֪" || !packageName) && typeof app.getCurrentPackage === 'function') {
- try {
- packageName = app.getCurrentPackage();
- } catch (e) {
- printl("ͨ¹ýgetCurrentPackage»ñÈ¡°üÃûʧ°Ü: " + e.message);
- }
- }
-
- printl("µ±Ç°Ó¦ÓðüÃû: " + (packageName || "δ֪"));
-
- if (packageName && packageName !== "δ֪" && typeof app.getAppName === 'function') {
- try {
- var appName = app.getAppName(packageName);
- if (appName) {
- printl("µ±Ç°Ó¦ÓÃÃû³Æ: " + appName);
- }
- } catch (e) {
- printl("»ñȡӦÓÃÃû³ÆÊ§°Ü: " + e.message);
- }
- }
- return;
- }
-
- printl("Ó¦ÓÃÐÅÏ¢: app¶ÔÏ󲻿ÉÓÃ");
- }
- // Éú³ÉÉ豸ÐÅÏ¢±¨¸æ
- function generateDeviceInfoReport() {
- printl("==============================================");
- printl(" AIWROK É豸ÐÅÏ¢±¨¸æ");
- printl("==============================================");
- printl("±¨¸æÉú³Éʱ¼ä: " + new Date().toLocaleString());
- printl("");
-
- // »ñÈ¡¸÷ÀàÐÅÏ¢
- getDeviceInfo();
- getScreenInfo();
- getBatteryInfo();
- getStorageInfo();
- getMemoryInfo();
- getNetworkInfo();
- getRunningAppInfo();
-
- printl("\n==============================================");
- printl(" ±¨¸æ½áÊø");
- printl("==============================================");
- }
- // Ö÷º¯Êý
- function main() {
- printl("AIWROKʵÓÃÉ豸ÐÅϢʾÀý¿ªÊ¼Ö´ÐÐ...");
- generateDeviceInfoReport();
- printl("\nÉ豸ÐÅÏ¢»ñÈ¡Íê³É¡£");
- }
- // Ö´ÐÐÖ÷º¯Êý
- main();
¸´ÖÆ´úÂë
|
|