summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ActivityThread.java4
-rw-r--r--core/java/android/content/res/Configuration.java40
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java3
-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
6 files changed, 79 insertions, 30 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 35d1948..1c980e3 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3913,6 +3913,8 @@ public final class ActivityThread {
mResConfiguration = new Configuration();
}
if (!mResConfiguration.isOtherSeqNewer(config)) {
+ if (DEBUG_CONFIGURATION) Log.v(TAG, "Skipping new config: curSeq="
+ + mResConfiguration.seq + ", newSeq=" + config.seq);
return;
}
mResConfiguration.updateFrom(config);
@@ -3936,6 +3938,8 @@ public final class ActivityThread {
WeakReference<Resources> v = it.next();
Resources r = v.get();
if (r != null) {
+ if (DEBUG_CONFIGURATION) Log.v(TAG, "Changing resources "
+ + r + " config to: " + config);
r.updateConfiguration(config, dm);
//Log.i(TAG, "Updated app resources " + v.getKey()
// + " " + r + ": " + r.getConfiguration());
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 6598264..1a0c867 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -219,6 +219,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
* Makes a deep copy suitable for modification.
*/
public Configuration(Configuration o) {
+ setTo(o);
+ }
+
+ public void setTo(Configuration o) {
fontScale = o.fontScale;
mcc = o.mcc;
mnc = o.mnc;
@@ -237,7 +241,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
uiMode = o.uiMode;
seq = o.seq;
}
-
+
public String toString() {
StringBuilder sb = new StringBuilder(128);
sb.append("{ scale=");
@@ -552,21 +556,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
dest.writeInt(seq);
}
- public static final Parcelable.Creator<Configuration> CREATOR
- = new Parcelable.Creator<Configuration>() {
- public Configuration createFromParcel(Parcel source) {
- return new Configuration(source);
- }
-
- public Configuration[] newArray(int size) {
- return new Configuration[size];
- }
- };
-
- /**
- * Construct this Configuration object, reading from the Parcel.
- */
- private Configuration(Parcel source) {
+ public void readFromParcel(Parcel source) {
fontScale = source.readFloat();
mcc = source.readInt();
mnc = source.readInt();
@@ -586,6 +576,24 @@ public final class Configuration implements Parcelable, Comparable<Configuration
uiMode = source.readInt();
seq = source.readInt();
}
+
+ public static final Parcelable.Creator<Configuration> CREATOR
+ = new Parcelable.Creator<Configuration>() {
+ public Configuration createFromParcel(Parcel source) {
+ return new Configuration(source);
+ }
+
+ public Configuration[] newArray(int size) {
+ return new Configuration[size];
+ }
+ };
+
+ /**
+ * Construct this Configuration object, reading from the Parcel.
+ */
+ private Configuration(Parcel source) {
+ readFromParcel(source);
+ }
public int compareTo(Configuration that) {
int n;
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 444135a..f47a8d0 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -141,6 +141,7 @@ public abstract class WallpaperService extends Service {
final Rect mVisibleInsets = new Rect();
final Rect mWinFrame = new Rect();
final Rect mContentInsets = new Rect();
+ final Configuration mConfiguration = new Configuration();
final WindowManager.LayoutParams mLayout
= new WindowManager.LayoutParams();
@@ -494,7 +495,7 @@ public abstract class WallpaperService extends Service {
final int relayoutResult = mSession.relayout(
mWindow, mLayout, mWidth, mHeight,
View.VISIBLE, false, mWinFrame, mContentInsets,
- mVisibleInsets, mSurfaceHolder.mSurface);
+ mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface);
if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
+ ", frame=" + mWinFrame);
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();
}