latyas
import subprocess
import datetime,time
import platform

adb = r\'c:\adb\adb.exe\'
sqlite_exe = \'su -c \\'sqlite3 /data/data/com.android.providers.telephony/databases/mmssms.db \"%s\"\\'\'
    
current_time = int(subprocess.check_output([adb,\'shell\',\'date +%s\']))*1000
last_updated = str(current_time)



while True:
    print \'last_updated:\' + time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(int(last_updated)/1000))
    sql = sqlite_exe % (\'SELECT address, date, body, type FROM sms WHERE date > \' + last_updated + \' order by date desc\')
    sms_dump = subprocess.check_output([adb,\'shell\',sql])

    for i,line in enumerate(sms_dump.split(\'\n\')):
        part = line.split(\'|\')
        if len(part) > 3 and part[3].strip() == \'1\':
            #SMS
            if platform.system() == \'Windows\':
                print str(i) + \'th: \' + \'Sender:\' + part[0] + \',time:\' + time.strftime("%Y-%m-%dT %H:%M:%S",time.localtime(int(part[1])/1000)) + \',Body:\' + part[2].decode(\'utf8\').encode(\'gbk\') + \',type:\' + part[3]
            else:
                print str(i) + \'th: \' + \'Sender:\' + part[0] + \',time:\' + time.strftime("%Y-%m-%dT %H:%M:%S",time.localtime(int(part[1])/1000)) + \',Body:\' + part[2] + \',type:\' + part[3]

            if i == 0:
                last_updated = part[1]

    time.sleep(10)

 平台:python 2.7

分类:

技术点:

相关文章:

  • 2021-11-17
  • 2021-09-06
  • 2021-08-26
  • 2021-06-19
  • 2021-12-28
  • 2022-02-10
  • 2021-10-12
  • 2021-09-03
猜你喜欢
  • 2022-12-23
  • 2021-12-03
  • 2021-04-06
  • 2021-12-22
  • 2021-11-18
  • 2022-03-02
  • 2021-12-13
相关资源
相似解决方案