Merge "Check Task windowing mode when reporting display features" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
44ca54f15e
@@ -25,7 +25,10 @@ import static androidx.window.util.ExtensionHelper.transformToWindowSpaceRect;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.app.ActivityManager.AppTask;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.app.WindowConfiguration;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -180,7 +183,7 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent {
|
|||||||
if (displayId != DEFAULT_DISPLAY) {
|
if (displayId != DEFAULT_DISPLAY) {
|
||||||
Log.w(TAG, "This sample doesn't support display features on secondary displays");
|
Log.w(TAG, "This sample doesn't support display features on secondary displays");
|
||||||
return features;
|
return features;
|
||||||
} else if (activity.isInMultiWindowMode()) {
|
} else if (isTaskInMultiWindowMode(activity)) {
|
||||||
// It is recommended not to report any display features in multi-window mode, since it
|
// It is recommended not to report any display features in multi-window mode, since it
|
||||||
// won't be possible to synchronize the display feature positions with window movement.
|
// won't be possible to synchronize the display feature positions with window movement.
|
||||||
return features;
|
return features;
|
||||||
@@ -203,6 +206,32 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the task associated with the activity is in multi-window. If task info is not
|
||||||
|
* available it defaults to {@code true}.
|
||||||
|
*/
|
||||||
|
private boolean isTaskInMultiWindowMode(@NonNull Activity activity) {
|
||||||
|
final ActivityManager am = activity.getSystemService(ActivityManager.class);
|
||||||
|
if (am == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<AppTask> appTasks = am.getAppTasks();
|
||||||
|
final int taskId = activity.getTaskId();
|
||||||
|
AppTask task = null;
|
||||||
|
for (AppTask t : appTasks) {
|
||||||
|
if (t.getTaskInfo().taskId == taskId) {
|
||||||
|
task = t;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (task == null) {
|
||||||
|
// The task might be removed on the server already.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return WindowConfiguration.inMultiWindowMode(task.getTaskInfo().getWindowingMode());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link true} if a {@link Rect} has zero width and zero height,
|
* Returns {@link true} if a {@link Rect} has zero width and zero height,
|
||||||
* {@code false} otherwise.
|
* {@code false} otherwise.
|
||||||
|
|||||||
Reference in New Issue
Block a user