diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/IWindow.aidl | 5 | ||||
| -rw-r--r-- | core/java/android/view/IWindowManager.aidl | 5 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 103 | ||||
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 18 | ||||
| -rw-r--r-- | core/java/android/view/ViewRoot.java | 35 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 43 | ||||
| -rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 6 |
7 files changed, 201 insertions, 14 deletions
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl index 85a8c1aea369..0e482d6046ab 100644 --- a/core/java/android/view/IWindow.aidl +++ b/core/java/android/view/IWindow.aidl @@ -70,4 +70,9 @@ oneway interface IWindow { * Drag/drop events */ void dispatchDragEvent(in DragEvent event); + + /** + * System chrome visibility changes + */ + void dispatchSystemUiVisibilityChanged(int visibility); } diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 8bdc1f807bda..51653df16d1c 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -187,4 +187,9 @@ interface IWindowManager * Create a screenshot of the applications currently displayed. */ Bitmap screenshotApplications(IBinder appToken, int maxWidth, int maxHeight); + + /** + * Called by the status bar to notify Views of changes to System UI visiblity. + */ + void statusBarVisibilityChanged(int visibility); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 469bbaaf8d07..6d5fd2c3e853 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -48,6 +48,7 @@ import android.os.Message; import android.os.Parcel; import android.os.Parcelable; import android.os.RemoteException; +import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; import android.util.AttributeSet; @@ -1697,6 +1698,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility public static final int OVER_SCROLL_NEVER = 2; /** + * View has requested the status bar to be visible (the default). + * + * @see setSystemUiVisibility + */ + public static final int STATUS_BAR_VISIBLE = 0; + + /** + * View has requested the status bar to be visible (the default). + * + * @see setSystemUiVisibility + */ + public static final int STATUS_BAR_HIDDEN = 0x00000001; + + /** * Controls the over-scroll mode for this view. * See {@link #overScrollBy(int, int, int, int, int, int, int, int, boolean)}, * {@link #OVER_SCROLL_ALWAYS}, {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}, @@ -1735,6 +1750,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility int mPrivateFlags; /** + * This view's request for the visibility of the status bar. + * @hide + */ + int mSystemUiVisibility; + + /** * Count of how many windows this view has been attached to. */ int mWindowAttachCount; @@ -2037,6 +2058,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility private OnDragListener mOnDragListener; + private OnSystemUiVisibilityChangeListener mOnSystemUiVisibilityChangeListener; + /** * The application environment this view lives in. * This field should be made private, so it is hidden from the SDK. @@ -4706,17 +4729,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } void performCollectViewAttributes(int visibility) { - //noinspection PointlessBitwiseExpression - if (((visibility | mViewFlags) & (VISIBILITY_MASK | KEEP_SCREEN_ON)) - == (VISIBLE | KEEP_SCREEN_ON)) { - mAttachInfo.mKeepScreenOn = true; + if ((visibility & VISIBILITY_MASK) == VISIBLE) { + if ((mViewFlags & KEEP_SCREEN_ON) == KEEP_SCREEN_ON) { + mAttachInfo.mKeepScreenOn = true; + } + mAttachInfo.mSystemUiVisibility |= mSystemUiVisibility; + if (mOnSystemUiVisibilityChangeListener != null) { + mAttachInfo.mHasSystemUiListeners = true; + } } } void needGlobalAttributesUpdate(boolean force) { - AttachInfo ai = mAttachInfo; + final AttachInfo ai = mAttachInfo; if (ai != null) { - if (ai.mKeepScreenOn || force) { + if (force || ai.mKeepScreenOn || (ai.mSystemUiVisibility != 0) + || ai.mHasSystemUiListeners) { ai.mRecomputeGlobalAttributes = true; } } @@ -5301,7 +5329,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } if ((changed & KEEP_SCREEN_ON) != 0) { - if (mParent != null) { + if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) { mParent.recomputeViewAttributes(this); } } @@ -10618,6 +10646,40 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } /** + * Request that the visibility of the status bar be changed. + */ + public void setSystemUiVisibility(int visibility) { + if (visibility != mSystemUiVisibility) { + mSystemUiVisibility = visibility; + if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) { + mParent.recomputeViewAttributes(this); + } + } + } + + /** + * Returns the status bar visibility that this view has requested. + */ + public int getSystemUiVisibility(int visibility) { + return mSystemUiVisibility; + } + + public void setOnSystemUiVisibilityChangeListener(OnSystemUiVisibilityChangeListener l) { + mOnSystemUiVisibilityChangeListener = l; + if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) { + mParent.recomputeViewAttributes(this); + } + } + + /** + */ + public void dispatchSystemUiVisibilityChanged(int visibility) { + if (mOnSystemUiVisibilityChangeListener != null) { + mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange(visibility); + } + } + + /** * !!! TODO: real docs * * The base class implementation makes the shadow the same size and appearance @@ -11307,6 +11369,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo); } + /** + * Interface definition for a callback to be invoked when the status bar changes + * visibility. + * + * @see #setOnSystemUiVisibilityChangeListener + */ + public interface OnSystemUiVisibilityChangeListener { + /** + * Called when the status bar changes visibility because of a call to + * {@link #setSystemUiVisibility}. + * + * @param visibility {@link #STATUS_BAR_VISIBLE} or {@link #STATUS_BAR_HIDDEN}. + */ + public void onSystemUiVisibilityChange(int visibility); + } + private final class UnsetPressedState implements Runnable { public void run() { setPressed(false); @@ -11525,6 +11603,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility boolean mKeepScreenOn; /** + * Bitwise-or of all of the values that views have passed to setSystemUiVisibility(). + */ + int mSystemUiVisibility; + + /** + * True if a view in this hierarchy has an OnSystemUiVisibilityChangeListener + * attached. + */ + boolean mHasSystemUiListeners; + + /** * Set if the visibility of any views has changed. */ boolean mViewVisibilityChanged; diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 115431e2fac6..d6c8ad655afe 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -860,8 +860,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * {@inheritDoc} */ public void recomputeViewAttributes(View child) { - ViewParent parent = mParent; - if (parent != null) parent.recomputeViewAttributes(this); + if (mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) { + ViewParent parent = mParent; + if (parent != null) parent.recomputeViewAttributes(this); + } } @Override @@ -1070,6 +1072,18 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return child.mCanAcceptDrop; } + @Override + public void dispatchSystemUiVisibilityChanged(int visible) { + super.dispatchSystemUiVisibilityChanged(visible); + + final int count = mChildrenCount; + final View[] children = mChildren; + for (int i=0; i <count; i++) { + final View child = children[i]; + child.dispatchSystemUiVisibilityChanged(visible); + } + } + /** * {@inheritDoc} */ diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 8a9b78be4ddd..d9321416ab97 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -718,6 +718,7 @@ public final class ViewRoot extends Handler implements ViewParent, attachInfo.mWindowVisibility = viewVisibility; attachInfo.mRecomputeGlobalAttributes = false; attachInfo.mKeepScreenOn = false; + attachInfo.mSystemUiVisibility = 0; viewVisibilityChanged = false; mLastConfiguration.setTo(host.getResources().getConfiguration()); host.dispatchAttachedToWindow(attachInfo, 0); @@ -891,14 +892,17 @@ public final class ViewRoot extends Handler implements ViewParent, } if (attachInfo.mRecomputeGlobalAttributes) { - //Log.i(TAG, "Computing screen on!"); + //Log.i(TAG, "Computing view hierarchy attributes!"); attachInfo.mRecomputeGlobalAttributes = false; - boolean oldVal = attachInfo.mKeepScreenOn; + boolean oldScreenOn = attachInfo.mKeepScreenOn; + int oldVis = attachInfo.mSystemUiVisibility; attachInfo.mKeepScreenOn = false; + attachInfo.mSystemUiVisibility = 0; + attachInfo.mHasSystemUiListeners = false; host.dispatchCollectViewAttributes(0); - if (attachInfo.mKeepScreenOn != oldVal) { + if (attachInfo.mKeepScreenOn != oldScreenOn || + attachInfo.mSystemUiVisibility != oldVis) { params = lp; - //Log.i(TAG, "Keep screen on changed: " + attachInfo.mKeepScreenOn); } } @@ -980,6 +984,8 @@ public final class ViewRoot extends Handler implements ViewParent, if (attachInfo.mKeepScreenOn) { params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; } + params.systemUiVisibility = attachInfo.mSystemUiVisibility; + params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners; } if (DEBUG_LAYOUT) { Log.i(TAG, "host=w:" + host.getMeasuredWidth() + ", h:" + @@ -1895,6 +1901,7 @@ public final class ViewRoot extends Handler implements ViewParent, public final static int CLOSE_SYSTEM_DIALOGS = 1014; public final static int DISPATCH_DRAG_EVENT = 1015; public final static int DISPATCH_DRAG_LOCATION_EVENT = 1016; + public final static int DISPATCH_SYSTEM_UI_VISIBILITY = 1017; @Override public void handleMessage(Message msg) { @@ -2057,6 +2064,9 @@ public final class ViewRoot extends Handler implements ViewParent, event.mLocalState = mLocalDragState; // only present when this app called startDrag() handleDragEvent(event); } break; + case DISPATCH_SYSTEM_UI_VISIBILITY: { + handleDispatchSystemUiVisibilityChanged(msg.arg1); + } break; } } @@ -2826,6 +2836,11 @@ public final class ViewRoot extends Handler implements ViewParent, event.recycle(); } + public void handleDispatchSystemUiVisibilityChanged(int visibility) { + if (mView == null) return; + mView.dispatchSystemUiVisibilityChanged(visibility); + } + public void getLastTouchPoint(Point outLocation) { outLocation.x = (int) mLastTouchPoint.x; outLocation.y = (int) mLastTouchPoint.y; @@ -3141,6 +3156,10 @@ public final class ViewRoot extends Handler implements ViewParent, sendMessage(msg); } + public void dispatchSystemUiVisibilityChanged(int visibility) { + sendMessage(obtainMessage(DISPATCH_SYSTEM_UI_VISIBILITY, visibility, 0)); + } + /** * The window is getting focus so if there is anything focused/selected * send an {@link AccessibilityEvent} to announce that. @@ -3359,6 +3378,14 @@ public final class ViewRoot extends Handler implements ViewParent, viewRoot.dispatchDragEvent(event); } } + + @Override + public void dispatchSystemUiVisibilityChanged(int visibility) { + final ViewRoot viewRoot = mViewRoot.get(); + if (viewRoot != null) { + viewRoot.dispatchSystemUiVisibilityChanged(visibility); + } + } } /** diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 8eb42690229c..491a79f1557d 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -950,7 +950,22 @@ public interface WindowManager extends ViewManager { * will be used. */ public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; - + + /** + * Control the visibility of the status bar. + * @hide + */ + public int systemUiVisibility; + + /** + * Get callbacks about the system ui visibility changing. + * + * TODO: Maybe there should be a bitfield of optional callbacks that we need. + * + * @hide + */ + public boolean hasSystemUiListeners; + public LayoutParams() { super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); type = TYPE_APPLICATION; @@ -1030,6 +1045,8 @@ public interface WindowManager extends ViewManager { out.writeString(packageName); TextUtils.writeToParcel(mTitle, out, parcelableFlags); out.writeInt(screenOrientation); + out.writeInt(systemUiVisibility); + out.writeInt(hasSystemUiListeners ? 1 : 0); } public static final Parcelable.Creator<LayoutParams> CREATOR @@ -1065,6 +1082,8 @@ public interface WindowManager extends ViewManager { packageName = in.readString(); mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); screenOrientation = in.readInt(); + systemUiVisibility = in.readInt(); + hasSystemUiListeners = in.readInt() != 0; } @SuppressWarnings({"PointlessBitwiseExpression"}) @@ -1082,6 +1101,10 @@ public interface WindowManager extends ViewManager { public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; /** {@hide} */ public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12; + /** {@hide} */ + public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13; + /** {@hide} */ + public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14; // internal buffer to backup/restore parameters under compatibility mode. private int[] mCompatibilityParamsBackup = null; @@ -1189,6 +1212,16 @@ public interface WindowManager extends ViewManager { changes |= SCREEN_ORIENTATION_CHANGED; } + if (systemUiVisibility != o.systemUiVisibility) { + systemUiVisibility = o.systemUiVisibility; + changes |= SYSTEM_UI_VISIBILITY_CHANGED; + } + + if (hasSystemUiListeners != o.hasSystemUiListeners) { + hasSystemUiListeners = o.hasSystemUiListeners; + changes |= SYSTEM_UI_LISTENER_CHANGED; + } + return changes; } @@ -1261,6 +1294,14 @@ public interface WindowManager extends ViewManager { if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) { sb.append(" compatible=true"); } + if (systemUiVisibility != 0) { + sb.append(" sysui=0x"); + sb.append(Integer.toHexString(systemUiVisibility)); + } + if (hasSystemUiListeners) { + sb.append(" sysuil="); + sb.append(hasSystemUiListeners); + } sb.append('}'); return sb.toString(); } diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index e8d67da1af77..ad069029eabe 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -695,6 +695,12 @@ public interface WindowManagerPolicy { * immediately. */ public boolean allowAppAnimationsLw(); + + + /** + * A new window has been focused. + */ + public void focusChanged(WindowState lastFocus, WindowState newFocus); /** * Called after the screen turns off. |
