ADB 双开差别
>>> jiance(sjh) ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities) Display #0 (activities from top to bottom): Stack #190: type=standard mode=fullscreen isSleeping=false mBounds=Rect(0, 0 - 0, 0) Task id #99900039 mBounds=Rect(0, 0 - 0, 0) mMinWidth=-1 mMinHeight=-1 mLastNonFullscreenBounds=null * TaskRecord{81da309 #99900039 A=com.kuaishou.nebula U=999 StackId=190 sz=1} userId=999 effectiveUid=u999a399 mCallingUid=u0a20 mUserSetupComplete=true mCallingPackage=com.miui.home affinity=com.kuaishou.nebula intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.kuaishou.nebula/com.yxcorp.gifshow.HomeActivity} kuaishou.nebula 已经运行 >>> jiance(sjh) ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities) Display #0 (activities from top to bottom): Stack #191: type=standard mode=fullscreen isSleeping=false mBounds=Rect(0, 0 - 0, 0) Task id #37598 mBounds=Rect(0, 0 - 0, 0) mMinWidth=-1 mMinHeight=-1 mLastNonFullscreenBounds=null * TaskRecord{fac89b6 #37598 A=com.kuaishou.nebula U=0 StackId=191 sz=1} userId=0 effectiveUid=u0a399 mCallingUid=u0a20 mUserSetupComplete=true mCallingPackage=com.miui.home affinity=com.kuaishou.nebula intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.kuaishou.nebula/com.yxcorp.gifshow.HomeActivity} kuaishou.nebula 已经运行
def jiance(sjh): aakk="adb -s {0} shell dumpsys activity activities".format(sjh) aak="adb -s {0} shell am start -n com.kuaishou.nebula/com.yxcorp.gifshow.HomeActivity".format(sjh) zh=[] lx=[] ap=0 p = subprocess.Popen(aakk, shell=True, stdout=subprocess.PIPE) out, err = p.communicate() time.sleep(4) #print(out.splitlines()[24:27]) for line in out.splitlines(): aa=line.decode("utf-8") print(aa) try: ab=re.findall('cmp=com.(.*?)/',aa) #al=ab[0]+'.HomeActivity' if len(ab)>0: break pass except: continue for ii in ab: print(ii) try: aa=ab[0] except: ap=1 if ap==0: if aa=="kuaishou.nebula": print("已经运行") pass else: process = subprocess.Popen(aak,shell=True) time.sleep(2) print("已经重新打开了") else: print("没有得到ab")