Skip to content

Commit

Permalink
Identify DecorViews on Android 6.0
Browse files Browse the repository at this point in the history
The DecorView class package has been changed into com.android.internal.policy.PhoneWindow$DecorView, so check for that as well.
  • Loading branch information
hypest committed Oct 13, 2015
1 parent ae788f8 commit deb22de
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
Expand Up @@ -133,14 +133,9 @@ public final View getRecentDecorView(View[] views) {

for (int j = 0; j < views.length; j++) {
view = views[j];
if (view != null){
String nameOfClass = view.getClass().getName();
if(nameOfClass.equals("com.android.internal.policy.impl.PhoneWindow$DecorView") || nameOfClass
.equals("com.android.internal.policy.impl.MultiPhoneWindow$MultiPhoneDecorView") ||
nameOfClass.equals("com.android.internal.policy.PhoneWindow$DecorView")) {
decorViews[i] = view;
i++;
}
if (isDecorView(view)){
decorViews[i] = view;
i++;
}
}
return getRecentContainer(decorViews);
Expand Down Expand Up @@ -186,8 +181,7 @@ private final View[] getNonDecorViews(View[] views) {

for (int j = 0; j < views.length; j++) {
view = views[j];
if (view != null && !(view.getClass().getName()
.equals("com.android.internal.policy.impl.PhoneWindow$DecorView"))) {
if (!isDecorView(view)) {
decorViews[i] = view;
i++;
}
Expand All @@ -196,6 +190,21 @@ private final View[] getNonDecorViews(View[] views) {
return decorViews;
}

/**
* Returns whether a view is a DecorView
* @param view
* @return true if view is a DecorView, false otherwise
*/
private boolean isDecorView(View view) {
if (view == null) {
return false;
}

final String nameOfClass = view.getClass().getName();
return (nameOfClass.equals("com.android.internal.policy.impl.PhoneWindow$DecorView") ||
nameOfClass.equals("com.android.internal.policy.impl.MultiPhoneWindow$MultiPhoneDecorView") ||
nameOfClass.equals("com.android.internal.policy.PhoneWindow$DecorView"));
}


/**
Expand Down Expand Up @@ -595,4 +604,4 @@ private void setWindowManagerString(){
}


}
}

0 comments on commit deb22de

Please sign in to comment.