Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app_current()方法在android13以上版本的适配问题 #952

Open
Zeros2619 opened this issue Apr 7, 2024 · 1 comment
Open

app_current()方法在android13以上版本的适配问题 #952

Zeros2619 opened this issue Apr 7, 2024 · 1 comment

Comments

@Zeros2619
Copy link
Contributor

只在android13和android14中进行了测试,app_current()目前提供的三条指令测试结果如下

adb shell dumpsys window windows
返回结果的格式可能已经修改了,找不到mCurrentFocus=Window关键字了,Window #\d+ Window可能适用
相关格式如下

    ....
  Window #25 Window{c838dbe u0 tv.danmaku.bili/tv.danmaku.bili.MainActivityV2}:
    mDisplayId=0 rootTaskId=57 mSession=Session{8e5857d 8821:u0a10178} mClient=android.os.BinderProxy@1c9fc79
    mOwnerUid=10178 showForAllUsers=false package=tv.danmaku.bili appop=NONE
    mAttrs={(0,0)(fillxfill) sim={adjust=nothing forwardNavigation} ty=BASE_APPLICATION wanim=0x10302fd
      fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS
      pfl=NO_MOVE_ANIMATION FORCE_DRAW_STATUS_BAR_BACKGROUND USE_BLAST FIT_INSETS_CONTROLLED
      vsysui=LAYOUT_STABLE LAYOUT_FULLSCREEN LIGHT_STATUS_BAR LIGHT_NAVIGATION_BAR
      apr=LIGHT_STATUS_BARS LIGHT_NAVIGATION_BARS
      bhv=DEFAULT
      fitSides=}
    Requested w=1440 h=3200 mLayoutSeq=471
    mBaseLayer=21000 mSubLayer=0    mToken=ActivityRecord{d9b8281 u0 tv.danmaku.bili/.MainActivityV2} t57}
    mActivityRecord=ActivityRecord{d9b8281 u0 tv.danmaku.bili/.MainActivityV2} t57}
    mAppDied=false    drawnStateEvaluated=true    mightAffectAllDrawn=true
    mViewVisibility=0x8 mHaveFrame=true mObscured=false
    mGivenContentInsets=[0,0][0,0] mGivenVisibleInsets=[0,0][0,0]
    ....

adb shell dumpsys activity activities
返回结果的格式可能已经修改了,找不到mResumedActivity: ActivityRecord关键字了,mLastPausedActivity: ActivityRecord可能适用
相关格式如下

    ....
  * Task{4949d17 #68 type=standard A=10187:com.ss.android.article.lite U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}
    mLastPausedActivity: ActivityRecord{1de5aed u0 com.ss.android.article.lite/.activity.SplashActivity} t68}
    mLastNonFullscreenBounds=Rect(386, 932 - 1055, 2372)
    isSleeping=false
    * Hist  #0: ActivityRecord{1de5aed u0 com.ss.android.article.lite/.activity.SplashActivity} t68}
      packageName=com.ss.android.article.lite processName=com.ss.android.article.lite
      launchedFromUid=10148 launchedFromPackage=com.skyui.launcher launchedFromFeature=null userId=0
      app=ProcessRecord{61522ff 12268:com.ss.android.article.lite/u0a187}
      Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.ss.android.article.lite/.activity.SplashActivity bnds=[728,1350][1043,1710] }
      rootOfTask=true task=Task{4949d17 #68 type=standard A=10187:com.ss.android.article.lite}
      taskAffinity=10187:com.ss.android.article.lite
      mActivityComponent=com.ss.android.article.lite/.activity.SplashActivity
      baseDir=/data/app/~~2lWWkwjGqfrOXGlF4jyHAA==/com.ss.android.article.lite-vNQX-8D8RhknWjdu_Kmx6Q==/base.apk
      dataDir=/data/user/0/com.ss.android.article.lite
    ....

adb shell dumpsys activity top
在android13中正常, 在android14中如果后台存在较多应用,将会出现*** SERVICE 'activity' DUMP TIMEOUT (10000ms) EXPIRED ***
,超时的原因导致最终找到的ACTIVITY也不是当前前台的应用

adb shell dumpsys window 是否可以加上去,提高适配性

android13
adb shell dumpsys window | findstr mCurrentFocus
  mCurrentFocus=Window{4397ca7 u0 com.ss.android.article.lite/com.ss.android.article.lite.activity.SplashActivity}

android14
adb shell dumpsys window | findstr mCurrentFocus
  mCurrentFocus=null
  mCurrentFocus=Window{30d1a54 u0 com.android.settings/com.android.settings.Settings}
  • 手机型号
    android13, android14
  • uiautomator2的版本号(pip show uiautomator2)
    3.0.5
@codeskyblue
Copy link
Member

可以pr提到 adbutils中的shell.py里面

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants