summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/IWindowSession.aidl7
-rw-r--r--core/java/android/view/SurfaceView.java6
-rw-r--r--core/java/android/view/ViewRoot.java49
3 files changed, 49 insertions, 13 deletions
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index b6b009b..01f07d6 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -17,6 +17,7 @@
package android.view;
+import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Bundle;
@@ -63,6 +64,9 @@ interface IWindowSession {
* contents to make sure the user can see it. This is different than
* <var>outContentInsets</var> in that these insets change transiently,
* so complex relayout of the window should not happen based on them.
+ * @param outConfiguration New configuration of window, if it is now
+ * becoming visible and the global configuration has changed since it
+ * was last displayed.
* @param outSurface Object in which is placed the new display surface.
*
* @return int Result flags: {@link WindowManagerImpl#RELAYOUT_SHOW_FOCUS},
@@ -71,7 +75,8 @@ interface IWindowSession {
int relayout(IWindow window, in WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewVisibility,
boolean insetsPending, out Rect outFrame, out Rect outContentInsets,
- out Rect outVisibleInsets, out Surface outSurface);
+ out Rect outVisibleInsets, out Configuration outConfig,
+ out Surface outSurface);
/**
* Give the window manager a hint of the part of the window that is
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 0722699..d8010bc 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -39,7 +39,6 @@ import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.concurrent.locks.ReentrantLock;
-import java.lang.ref.WeakReference;
/**
* Provides a dedicated drawing surface embedded inside of a view hierarchy.
@@ -102,7 +101,8 @@ public class SurfaceView extends View {
final Rect mVisibleInsets = new Rect();
final Rect mWinFrame = new Rect();
final Rect mContentInsets = new Rect();
-
+ final Configuration mConfiguration = new Configuration();
+
static final int KEEP_SCREEN_ON_MSG = 1;
static final int GET_NEW_SURFACE_MSG = 2;
@@ -428,7 +428,7 @@ public class SurfaceView extends View {
final int relayoutResult = mSession.relayout(
mWindow, mLayout, mWidth, mHeight,
visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets,
- mVisibleInsets, mSurface);
+ mVisibleInsets, mConfiguration, mSurface);
if (localLOGV) Log.i(TAG, "New surface: " + mSurface
+ ", vis=" + visible + ", frame=" + mWinFrame);
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 484922d..c87ffee 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -80,6 +80,7 @@ public final class ViewRoot extends Handler implements ViewParent,
private static final boolean DEBUG_ORIENTATION = false || LOCAL_LOGV;
private static final boolean DEBUG_TRACKBALL = false || LOCAL_LOGV;
private static final boolean DEBUG_IMF = false || LOCAL_LOGV;
+ private static final boolean DEBUG_CONFIGURATION = false || LOCAL_LOGV;
private static final boolean WATCH_POINTER = false;
private static final boolean MEASURE_LATENCY = false;
@@ -176,6 +177,9 @@ public final class ViewRoot extends Handler implements ViewParent,
final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
= new ViewTreeObserver.InternalInsetsInfo();
+ final Configuration mLastConfiguration = new Configuration();
+ final Configuration mPendingConfiguration = new Configuration();
+
class ResizedInfo {
Rect coveredInsets;
Rect visibleInsets;
@@ -719,6 +723,7 @@ public final class ViewRoot extends Handler implements ViewParent,
attachInfo.mRecomputeGlobalAttributes = false;
attachInfo.mKeepScreenOn = false;
viewVisibilityChanged = false;
+ mLastConfiguration.setTo(host.getResources().getConfiguration());
host.dispatchAttachedToWindow(attachInfo, 0);
//Log.i(TAG, "Screen on initialized: " + attachInfo.mKeepScreenOn);
@@ -904,6 +909,13 @@ public final class ViewRoot extends Handler implements ViewParent,
+ " visible=" + mPendingVisibleInsets.toShortString()
+ " surface=" + mSurface);
+ if (mPendingConfiguration.seq != 0) {
+ if (DEBUG_CONFIGURATION) Log.v(TAG, "Visible with new config: "
+ + mPendingConfiguration);
+ updateConfiguration(mPendingConfiguration, !mFirst);
+ mPendingConfiguration.seq = 0;
+ }
+
contentInsetsChanged = !mPendingContentInsets.equals(
mAttachInfo.mContentInsets);
visibleInsetsChanged = !mPendingVisibleInsets.equals(
@@ -1627,6 +1639,30 @@ public final class ViewRoot extends Handler implements ViewParent,
}
}
+ void updateConfiguration(Configuration config, boolean force) {
+ if (DEBUG_CONFIGURATION) Log.v(TAG,
+ "Applying new config to window "
+ + mWindowAttributes.getTitle()
+ + ": " + config);
+ synchronized (sConfigCallbacks) {
+ for (int i=sConfigCallbacks.size()-1; i>=0; i--) {
+ sConfigCallbacks.get(i).onConfigurationChanged(config);
+ }
+ }
+ if (mView != null) {
+ // At this point the resources have been updated to
+ // have the most recent config, whatever that is. Use
+ // the on in them which may be newer.
+ if (mView != null) {
+ config = mView.getResources().getConfiguration();
+ }
+ if (force || mLastConfiguration.diff(config) != 0) {
+ mLastConfiguration.setTo(config);
+ mView.dispatchConfigurationChanged(config);
+ }
+ }
+ }
+
/**
* Return true if child is an ancestor of parent, (or equal to the parent).
*/
@@ -1815,14 +1851,7 @@ public final class ViewRoot extends Handler implements ViewParent,
if (mAdded) {
Configuration config = ((ResizedInfo)msg.obj).newConfig;
if (config != null) {
- synchronized (sConfigCallbacks) {
- for (int i=sConfigCallbacks.size()-1; i>=0; i--) {
- sConfigCallbacks.get(i).onConfigurationChanged(config);
- }
- }
- if (mView != null) {
- mView.dispatchConfigurationChanged(config);
- }
+ updateConfiguration(config, false);
}
mWinFrame.left = 0;
mWinFrame.right = msg.arg1;
@@ -2500,12 +2529,14 @@ public final class ViewRoot extends Handler implements ViewParent,
if (params != null) {
if (DBG) Log.d(TAG, "WindowLayout in layoutWindow:" + params);
}
+ mPendingConfiguration.seq = 0;
int relayoutResult = sWindowSession.relayout(
mWindow, params,
(int) (mView.mMeasuredWidth * appScale + 0.5f),
(int) (mView.mMeasuredHeight * appScale + 0.5f),
viewVisibility, insetsPending, mWinFrame,
- mPendingContentInsets, mPendingVisibleInsets, mSurface);
+ mPendingContentInsets, mPendingVisibleInsets,
+ mPendingConfiguration, mSurface);
if (restore) {
params.restore();
}