Adding API to access / change the task bounds
Bug: 21738328
Change-Id: I3aabcbe1dcc5caa70f66554157f41fbfacf4c50f
diff --git a/core/java/com/android/internal/widget/NonClientDecorView.java b/core/java/com/android/internal/widget/NonClientDecorView.java
index d8626cd..dd5c5d7 100644
--- a/core/java/com/android/internal/widget/NonClientDecorView.java
+++ b/core/java/com/android/internal/widget/NonClientDecorView.java
@@ -17,6 +17,7 @@
package com.android.internal.widget;
import android.content.Context;
+import android.graphics.Rect;
import android.os.RemoteException;
import android.util.AttributeSet;
import android.view.View;
@@ -243,7 +244,7 @@
* Maximize the window by moving it to the maximized workspace stack.
**/
private void maximizeWindow() {
- Window.WindowStackCallback callback = mOwner.getWindowStackCallback();
+ Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
if (callback != null) {
try {
callback.changeWindowStack(
@@ -253,4 +254,40 @@
}
}
}
+
+ /**
+ * Returns the bounds of this activity.
+ * @return Returns bounds of the activity. It will return null if either the window is
+ * fullscreen or the bounds could not be retrieved.
+ */
+ private Rect getActivityBounds() {
+ Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
+ if (callback != null) {
+ try {
+ return callback.getActivityBounds();
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Failed to get the activity bounds.");
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets the bounds of this Activity on the stack.
+ * @param newBounds The bounds of the activity. Passing null is not allowed.
+ */
+ private void setActivityBounds(Rect newBounds) {
+ if (newBounds == null) {
+ Log.e(TAG, "Failed to set null bounds to the activity.");
+ return;
+ }
+ Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
+ if (callback != null) {
+ try {
+ callback.setActivityBounds(newBounds);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Failed to set the activity bounds.");
+ }
+ }
+ }
}