{"id":341,"date":"2024-12-05T21:52:50","date_gmt":"2024-12-05T13:52:50","guid":{"rendered":"https:\/\/daogu.work\/?p=341"},"modified":"2024-12-06T16:50:28","modified_gmt":"2024-12-06T08:50:28","slug":"%e5%ae%89%e5%8d%93%e6%89%8b%e6%9c%ba%e5%af%bc%e5%87%ba%e7%9f%ad%e4%bf%a1%e5%b9%b6%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/daogu.work\/?p=341","title":{"rendered":"\u5b89\u5353\u624b\u673a\u5bfc\u51fa\u77ed\u4fe1\u5e76\u89e3\u6790"},"content":{"rendered":"\n<p>\u56e0\u4e3a\u5de5\u4f5c\u539f\u56e0\uff0c\u8fd9\u51e0\u5e74\u77ed\u4fe1\u91cf\u6fc0\u589e\uff0c\u77ed\u4fe1\u91cf\u5df2\u7ecf\u589e\u52a0\u523014\u4e07\u591a\u6761\u3002\u624b\u673a\u662f\u534e\u4e3a\u7684mate 40 pro\uff0c\u6ca1\u6709\u5347\u7ea7\u9e3f\u8499\uff0c\u4ecd\u7136\u662fEMUI\u7cfb\u7edf\uff0c\u6700\u540e\u4e00\u4e2a\u7248\u672c\u3002<br>\u6211\u7684\u9700\u6c42\u5f88\u7b80\u5355\uff0c\u77ed\u4fe1\u592a\u591a\u4e86\uff0c\u7cfb\u7edf\u81ea\u5e26\u7684\u77ed\u4fe1\u5e94\u7528\uff0c\u5df2\u7ecf\u4e0d\u80fd\u641c\u7d22\u4e86\uff0c\u8f93\u5165\u540e\u5c31\u641c\u7d22\u4e0d\u51fa\u6765\u4e86\u3002\u5728\u7f51\u4e0a\u627e\u4e86\u4e00\u4e9b\u65b9\u6848\uff0c\u4f7f\u7528\u534e\u4e3a\u5957\u4ef6\u6765\u770b\u770b\u3002<br>\u4f7f\u7528\u534e\u4e3a\u5957\u4ef6\uff0c\u70b9\u51fb\u5230\u901a\u8baf\u5f55\u662f\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\u7684\uff0c\u4e5f\u80fd\u5bfc\u51fa\u5185\u5bb9\uff0c\u4f46\u662f\u5f53\u70b9\u51fb\u5230\u77ed\u4fe1\u7684\u65f6\u5019\uff0c\u5c31\u5361\u6b7b\u4e86\uff0c\u4e0d\u77e5\u9053\u662f\u7a0b\u5e8f\u54ea\u91cc\u7684bug,\u6253\u534e\u4e3a\u5ba2\u670d\uff0c\u524d\u540e\u6c9f\u901a\u4e86\u4e00\u4e2a\u591a\u661f\u671f\uff0c\u4e5f\u662f\u65e0\u679c\uff0c\u540e\u6765\u5c31\u6ca1\u7ba1\u4e86\u3002<br>\u4f7f\u7528\u534e\u4e3a\u5907\u4efd\u4ea7\u751f\u7684\u6587\u4ef6\uff0c\u9700\u8981\u89e3\u5bc6\uff0c\u7136\u540e\u518d\u67e5\u627e\u77ed\u4fe1\uff0c\u4f46\u7f51\u4e0a\u627e\u5230\u7684\u89e3\u5bc6\u6e20\u9053\u4e5f\u5931\u6548\u4e86\uff0c\u65e0\u6cd5\u89e3\u5bc6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b80\u5355\u7684\u9700\u6c42<\/h2>\n\n\n\n<p>\u624b\u673a\u77ed\u4fe1\u592a\u591a\u4e86\uff0c\u65e0\u6cd5\u641c\u7d22\uff0c\u60f3\u5c06\u624b\u673a\u77ed\u4fe1\u5b58\u6863\uff0c\u5bf9\u4e8e\u5386\u53f2\u77ed\u4fe1\uff0c\u6709\u9700\u8981\u65f6\u80fd\u5feb\u901f\u641c\u7d22\u5373\u53ef\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8fd1\u671f\u7684\u65b9\u6848<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SMS Backup &amp; Restore \u5907\u4efd\u77ed\u4fe1\uff0c\u5907\u4efd\u51fa\u6765\u7684xml\u6587\u4ef6\u3002\u53bbgoogle play\u5546\u5e97\u6216\u8005apkure\u5546\u5e97\u4e0b\u8f7d\u5373\u53ef\u3002<\/li>\n\n\n\n<li>\u6587\u4ef6\u89e3\u6790\u5e76\u5bfc\u5165\u5230mongodb,\u4f7f\u7528compass\u8fdb\u884c\u67e5\u8be2\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u77ed\u4fe1\u5bfc\u51fa<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u63a8\u8350\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6253\u5f00\uff0csms backup &amp; Restore,\u4ee5\u82f1\u6587\u754c\u9762\u4e3a\u4f8b\uff0c settings &#8211; Backup location -&gt;Local backup folder \u9009\u62e9\u4e00\u4e2a\u4f60\u719f\u6089\u7684\u76ee\u5f55\uff0c\u6700\u597d\u662f\u77ed\u76ee\u5f55\uff0c\u4e0d\u7136\u540e\u9762\u4f7f\u7528adb \u7684\u65f6\u5019\uff0c\u4e0d\u597d\u62c9\u51fa\u6587\u4ef6\uff0c\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u65b9\u6cd5\u628a\u5bfc\u51fa\u7684\u6587\u4ef6\u5907\u4efd\u51fa\u6765\u3002<\/li>\n\n\n\n<li>\u8fd9\u91cc\u6211\u662f\u5c06\u6587\u4ef6\u5b58\u50a8\u5230Downloads\u76ee\u5f55\u4e2d\uff0c\u540e\u9762\u7684\u6587\u4ef6\u540d\uff0c\u4f60\u770b\u4e00\u4e0b\u586b\u5199\u5bf9\u5e94\u5907\u4efd\u51fa\u6765\u7684\u6587\u4ef6\u5373\u53ef\u3002adb\u662f\u8fde\u63a5\u4e86\u7535\u8111\uff0c\u4f60\u53ef\u4ee5\u628a\u8fd9\u4e2a\u6587\u4ef6\u590d\u5236\u5230\u6307\u5b9a\u7684\u76ee\u5f55\u3002<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>adb pull \/storage\/emulated\/0\/Download\/sms-20241204152305.xml .\/sms-backup-20241204.xml<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\u70b9\uff1a\u6ce8\u610f\u5bfc\u51fa\u8bbe\u7f6e\u7684\u65f6\u5019\uff0c\u5141\u8bb8\u8bfb\u53d6\u901a\u8baf\u5f55\uff0c\u8fd9\u6837\u4f60\u53ef\u4ee5\u770b\u5230\u6709\u4e00\u4e2a\u5b57\u6bb5\uff0ccontact_name\uff0c\u77ed\u4fe1\u7684\u6613\u8bfb\u6027\u4f1a\u597d\u5f88\u591a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u53e6\u4e00\u79cd\u5bfc\u51fa\u7684\u529e\u6cd5<\/h3>\n\n\n\n<p><strong>\u4f7f\u7528 Content Provider \u5bfc\u51fa\u77ed\u4fe1<\/strong> Android \u63d0\u4f9b\u4e86\u4e00\u79cd\u6807\u51c6\u65b9\u6cd5\uff0c\u901a\u8fc7 <code>content:\/\/<\/code> URI \u6765\u8bbf\u95ee\u77ed\u4fe1\u6570\u636e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>adb shell content query --uri content:\/\/sms &gt; sms_data.txt<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2asms_data.txt\u7684\u76ee\u5f55\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e24\u79cd\u65b9\u6cd5\u6bd4\u8f83<\/h3>\n\n\n\n<p>Content Provider\u5bfc\u51fa\uff1a\u5bfc\u51fa\u7684\u662f\u5e7f\u672c\u884c\uff0c\u6ca1\u6709\u89e3\u6790\uff0c\u4ee5=\u5206\u9694\uff0c\u5982\u679c\u6570\u636e\u4e2d\u6709=\u53f7\u4f1a\u9020\u6210\u540e\u7eed\u5206\u9694\u56f0\u96be\u3002<br>Sms Backup &amp; Restore: \u5bfc\u51fa\u7684xml\u683c\u5f0f\uff0c\u53ef\u4ee5\u76f4\u63a5\u89e3\u6790\uff0c\u65b9\u4fbf\u5bfc\u5165\u5230json\u4e2d\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u6790xml\u6570\u636e\u5e76\u5bfc\u5165\u5230mongodb\u4e2d<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u6790\u601d\u8def<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6709\u552f\u4e00\u4e3b\u952e\uff0c\u8fd9\u6837\u540e\u7eed\u518d\u5bfc\u5165\u7684\u65f6\u5019\uff0c\u56e0\u4e3a\u5907\u4efd\u90fd\u662f\u5168\u91cf\u5907\u4efd\uff0c\u540e\u7eed\u968f\u4fbf\u5bfc\u5165\uff0c\u4f46\u6709\u4e3b\u952e\u540e\uff0c\u91cd\u590d\u7684\u5c06\u6570\u636e\u5c06\u4e0d\u4f1a\u88ab\u518d\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u3002\u4f7f\u7528\u4e86address,date,type,body,sub_id\u8fdb\u884c\u7ec4\u5408\u751f\u6210md5\u7684hash\u503c\u4f5c\u4e3a\u6570\u636e\u5e93\u7684_id\u3002<\/li>\n\n\n\n<li>\u89e3\u6790\u5b57\u6bb5\u5b8c\u6210\u540e\uff0c\u5229\u7528python\u7684list\u5b8c\u6210\u63d2\u5165\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u76f8\u5173\u4ee3\u7801<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import xml.etree.ElementTree as ET  \nimport json  \nfrom pymongo import MongoClient  \nimport hashlib  \n\ndef generate_unique_id(sms):  \n    unique_string = f\"{sms&#91;'address']}_{sms&#91;'date']}_{sms&#91;'type']}_{sms.get('body', '')}_{sms.get('sub_id', '')}\"  \n    return hashlib.md5(unique_string.encode()).hexdigest()  \n\n# \u89e3\u6790 XML  \ntree = ET.parse('data\/sms-backup-20241204.xml')  \nroot = tree.getroot()  \n\nsms_list = &#91;]  \nfor sms in root.findall('sms'):  \n    sms_list.append({  \n        'address': sms.get('address'),  \n        'date': sms.get('date'),  \n        'type': sms.get('type'),  \n        'contact_name' : sms.get('contact_name'),  \n        'body': sms.get('body'),  \n         'sub_id': sms.get('sub_id'),  \n        'read': sms.get('read'),  \n        'status':sms.get('status'),  \n        'date_sent': sms.get('date_sent')  \n    })  \n\n# \u4fdd\u5b58\u4e3a JSON \u6587\u4ef6  \nwith open('data\/sms_data.json', 'w', encoding='utf-8') as f:  \n    json.dump(sms_list, f, ensure_ascii=False, indent=4)  \n\n## add primary key  \nfor sms in sms_list:  \n    sms&#91;\"_id\"] = generate_unique_id(sms)  \n\n# \u5bfc\u5165\u5230 MongoDB  \n\nUSERNAME = \"admin\"  \nPASSWORD = \"test1234\"  \nHOST = \"10.0.1.21\"  # \u6216\u8fdc\u7a0b\u670d\u52a1\u5668\u5730\u5740  \nPORT = 27017        # MongoDB \u9ed8\u8ba4\u7aef\u53e3  \nDATABASE = \"sms\"  \nCOLLECTION = \"sms_collection\"  \n# \u8fde\u63a5 MongoDB  \nclient = MongoClient(f\"mongodb:\/\/{USERNAME}:{PASSWORD}@{HOST}:{PORT}\/\")  \ndb = client&#91;DATABASE]  \ncollection = db&#91;COLLECTION]  \n\ntry:  \n    collection.insert_many(sms_list, ordered=False)  # \u8df3\u8fc7\u91cd\u590d\u8bb0\u5f55  \n    print(\"\u77ed\u4fe1\u6570\u636e\u5df2\u6210\u529f\u5bfc\u5165 MongoDB\uff01\")  \nexcept Exception as e:  \n    print(f\"\u5bfc\u5165\u65f6\u51fa\u73b0\u9519\u8bef\uff1a{e}\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">xml\u5bfc\u51fa\u7684\u5b57\u6bb5\u8bf4\u660e<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>protocol \u534f\u8bae\u7c7b\u578b\uff0c\u901a\u5e38\u4e3a 0\uff0c\u8868\u793a\u6807\u51c6 SMS \u534f\u8bae<\/li>\n\n\n\n<li>address \u77ed\u4fe1\u7684\u53d1\u9001\u65b9\u6216\u63a5\u6536\u65b9\u53f7\u7801<\/li>\n\n\n\n<li>date \u77ed\u4fe1\u53d1\u9001\u6216\u63a5\u6536\u7684\u65f6\u95f4\u6233\uff081970 \u5e74 1 \u6708 1 \u65e5\u4ee5\u6765\u7684\u6beb\u79d2\u6570\uff09<\/li>\n\n\n\n<li>type \u77ed\u4fe1\u7c7b\u578b\uff1a1 \u8868\u793a\u63a5\u6536\uff0c2 \u8868\u793a\u53d1\u9001<\/li>\n\n\n\n<li>subject \u77ed\u4fe1\u4e3b\u9898\uff0c\u901a\u5e38\u4e3a null\uff0c\u9002\u7528\u4e8e MMS \u6216\u5176\u4ed6\u591a\u5a92\u4f53\u6d88\u606f<\/li>\n\n\n\n<li>body \u77ed\u4fe1\u5185\u5bb9<\/li>\n\n\n\n<li>toa \u63a5\u6536\u65b9\u53f7\u7801\u5730\u5740\uff0c\u901a\u5e38\u4e3a null<\/li>\n\n\n\n<li>sc_toa \u77ed\u4fe1\u670d\u52a1\u4e2d\u5fc3\u5730\u5740\uff0c\u901a\u5e38\u4e3a null<\/li>\n\n\n\n<li>service_center \u77ed\u4fe1\u7684\u670d\u52a1\u4e2d\u5fc3\u4fe1\u606f\uff0c\u901a\u5e38\u4e3a null<\/li>\n\n\n\n<li>read \u77ed\u4fe1\u662f\u5426\u5df2\u8bfb\uff1a1 \u8868\u793a\u5df2\u8bfb\uff0c0 \u8868\u793a\u672a\u8bfb<\/li>\n\n\n\n<li>status \u77ed\u4fe1\u72b6\u6001\uff1a-1 \u8868\u793a\u65e0\u7279\u6b8a\u72b6\u6001\uff1b\u5176\u4ed6\u503c\u53ef\u80fd\u8868\u793a\u53d1\u9001\u5931\u8d25\u7b49\u72b6\u6001<\/li>\n\n\n\n<li>locked \u77ed\u4fe1\u662f\u5426\u88ab\u9501\u5b9a\uff1a1 \u8868\u793a\u9501\u5b9a\uff0c0 \u8868\u793a\u672a\u9501\u5b9a<\/li>\n\n\n\n<li>date_sent \u77ed\u4fe1\u7684\u5b9e\u9645\u53d1\u9001\u65f6\u95f4\uff081970 \u5e74 1 \u6708 1 \u65e5\u4ee5\u6765\u7684\u6beb\u79d2\u6570\uff09<\/li>\n\n\n\n<li>sub_id \u8ba2\u9605\u5361 ID\uff08\u53cc\u5361\u624b\u673a\u65f6\u6807\u8bb0 SIM \u5361\uff09<\/li>\n\n\n\n<li>readable_date \u4eba\u7c7b\u53ef\u8bfb\u7684\u65f6\u95f4\u683c\u5f0f\uff08\u5982 Oct 28, 2015 19:57:25\uff09<\/li>\n\n\n\n<li>contact_name \u8054\u7cfb\u4eba\u540d\u79f0\uff0c\u82e5\u672a\u77e5\u5219\u4e3a (Unknown)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u67e5\u8be2\u793a\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">mongodb\u64cd\u4f5c<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u521b\u5efa\u7d22\u5f15<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>db.sms_collection.createIndex({body: \"text\"});<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u67e5\u627e\u7279\u5b9a\u6587\u5b57<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>db.sms_collection.findOne({body: \/\u6e38\u591a\u591a\/i});<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u67e5\u8be2\u622a\u56fe<\/h4>\n\n\n\n<p>\u8fd9\u8fd8\u80fd\u67e5\u5230\u597d\u591a\u5e74\u524d\u7684\u77ed\u4fe1\uff0c15\u5e74\u7684\u3002<\/p>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/img.daogu.work\/images\/2024\/12\/06\/1af609529e756da2b1d103db721b8ce3.png\" alt=\"1af609529e756da2b1d103db721b8ce3.png\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u4e3a\u4ecb\u7ecd\u4e86\u534e\u4e3a\u5957\u4ef6\u5361\u6b7b\u540e\uff0c\u63a2\u7d22\u4e86\u4f7f\u7528SMS Backup\u8f6f\u4ef6\u5bfc\u51fa\u5de8\u91cf\u77ed\u4fe1\u5e76\u5bfc\u5165mongodb\u8fdb\u884c\u67e5\u8be2\u7684\u65b9\u6848\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[187,102,186,188],"class_list":["post-341","post","type-post","status-publish","format-standard","hentry","category-softinstall","tag-adb","tag-mongodb","tag-sms-backup","tag-188"],"_links":{"self":[{"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341"}],"version-history":[{"count":2,"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts\/341\/revisions"}],"predecessor-version":[{"id":344,"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts\/341\/revisions\/344"}],"wp:attachment":[{"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}