From 5fd2169eabd77e6bfafaf456e58051a3bafb2bca Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 7 Jun 2011 14:09:47 -0700 Subject: Work on issue #4518815: Compatibility mode introduces compatibility regression... ...for Market App iRunner There were a lot of serious issues with how we updated (or often didn't update) the display and resource state when switching compatibility mode in conjunction with restarting and updating application components. This addresses everything I could find. Unfortunately it does *not* fix this particular app. I am starting to think this is just an issue in the app. This change does fix a number of other problems I could repro, such as switching the compatibility mode of an IME. Also a few changes here and there to get rid of $#*&^!! debug logs. Change-Id: Ib15572eac9ec93b4b9966ddcbbc830ce9dec1317 --- cmds/installd/commands.c | 12 +-- core/java/android/app/ActivityThread.java | 98 +++++++++++++++------- core/java/android/app/Application.java | 4 +- core/java/android/app/ContextImpl.java | 12 ++- core/java/android/app/LoadedApk.java | 11 +-- .../android/content/res/CompatibilityInfo.java | 3 + core/java/android/content/res/Configuration.java | 35 ++++++-- core/java/android/content/res/Resources.java | 34 +++++--- core/java/android/text/TextLine.java | 1 - .../java/android/view/CompatibilityInfoHolder.java | 45 ++++++++++ core/java/android/view/Display.java | 38 ++++++--- core/java/android/view/ViewRoot.java | 41 ++++++++- core/java/android/view/Window.java | 9 +- core/java/android/view/WindowManagerImpl.java | 65 +++++++++----- libs/utils/StreamingZipInflater.cpp | 10 +-- .../internal/policy/impl/PhoneWindowManager.java | 9 +- services/java/com/android/server/WifiService.java | 2 +- .../java/com/android/server/wm/BlackFrame.java | 7 ++ .../java/com/android/server/wm/DimAnimator.java | 5 +- .../java/com/android/server/wm/DimSurface.java | 5 +- .../android/server/wm/ScreenRotationAnimation.java | 7 ++ .../android/server/wm/WindowManagerService.java | 43 +++++++++- .../java/com/android/server/wm/WindowState.java | 41 +++++---- 23 files changed, 404 insertions(+), 133 deletions(-) create mode 100644 core/java/android/view/CompatibilityInfoHolder.java diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index 4d49c30..ada712d 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -213,7 +213,7 @@ int move_dex(const char *src, const char *dst) if (create_cache_path(src_dex, src)) return -1; if (create_cache_path(dst_dex, dst)) return -1; - LOGI("move %s -> %s\n", src_dex, dst_dex); + LOGV("move %s -> %s\n", src_dex, dst_dex); if (rename(src_dex, dst_dex) < 0) { LOGE("Couldn't move %s: %s\n", src_dex, strerror(errno)); return -1; @@ -229,7 +229,7 @@ int rm_dex(const char *path) if (!is_valid_apk_path(path)) return -1; if (create_cache_path(dex_path, path)) return -1; - LOGI("unlink %s\n", dex_path); + LOGV("unlink %s\n", dex_path); if (unlink(dex_path) < 0) { LOGE("Couldn't unlink %s: %s\n", dex_path, strerror(errno)); return -1; @@ -428,7 +428,7 @@ static int wait_dexopt(pid_t pid, const char* apk_path) } if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { - LOGD("DexInv: --- END '%s' (success) ---\n", apk_path); + LOGV("DexInv: --- END '%s' (success) ---\n", apk_path); return 0; } else { LOGW("DexInv: --- END '%s' --- status=0x%04x, process failed\n", @@ -495,7 +495,7 @@ int dexopt(const char *apk_path, uid_t uid, int is_public) goto fail; } - LOGD("DexInv: --- BEGIN '%s' ---\n", apk_path); + LOGV("DexInv: --- BEGIN '%s' ---\n", apk_path); pid_t pid; pid = fork(); @@ -563,7 +563,7 @@ void mkinnerdirs(char* path, int basepos, mode_t mode, int uid, int gid, if (path[basepos] == '/') { path[basepos] = 0; if (lstat(path, statbuf) < 0) { - LOGI("Making directory: %s\n", path); + LOGV("Making directory: %s\n", path); if (mkdir(path, mode) == 0) { chown(path, uid, gid); } else { @@ -595,7 +595,7 @@ int movefileordir(char* srcpath, char* dstpath, int dstbasepos, if ((statbuf->st_mode&S_IFDIR) == 0) { mkinnerdirs(dstpath, dstbasepos, S_IRWXU|S_IRWXG|S_IXOTH, dstuid, dstgid, statbuf); - LOGI("Renaming %s to %s (uid %d)\n", srcpath, dstpath, dstuid); + LOGV("Renaming %s to %s (uid %d)\n", srcpath, dstpath, dstuid); if (rename(srcpath, dstpath) >= 0) { if (chown(dstpath, dstuid, dstgid) < 0) { LOGE("cannot chown %s: %s\n", dstpath, strerror(errno)); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index a61147a..6c63c2a 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -155,7 +155,9 @@ public final class ActivityThread { = new HashMap(); AppBindData mBoundApplication; Configuration mConfiguration; + Configuration mCompatConfiguration; Configuration mResConfiguration; + CompatibilityInfo mResCompatibilityInfo; Application mInitialApplication; final ArrayList mAllApplications = new ArrayList(); @@ -181,8 +183,8 @@ public final class ActivityThread { = new HashMap>(); final HashMap> mResourcePackages = new HashMap>(); - Display mDisplay = null; - DisplayMetrics mDisplayMetrics = null; + final HashMap mDisplayMetrics + = new HashMap(); final HashMap > mActiveResources = new HashMap >(); final ArrayList mRelaunchingActivities @@ -1267,20 +1269,45 @@ public final class ActivityThread { return sPackageManager; } - DisplayMetrics getDisplayMetricsLocked(boolean forceUpdate) { - if (mDisplayMetrics != null && !forceUpdate) { - return mDisplayMetrics; + DisplayMetrics getDisplayMetricsLocked(CompatibilityInfo ci, boolean forceUpdate) { + DisplayMetrics dm = mDisplayMetrics.get(ci); + if (dm != null && !forceUpdate) { + return dm; } - if (mDisplay == null) { - WindowManager wm = WindowManagerImpl.getDefault(); - mDisplay = wm.getDefaultDisplay(); + if (dm == null) { + dm = new DisplayMetrics(); + mDisplayMetrics.put(ci, dm); } - DisplayMetrics metrics = mDisplayMetrics = new DisplayMetrics(); - mDisplay.getMetrics(metrics); + Display d = WindowManagerImpl.getDefault(ci).getDefaultDisplay(); + d.getMetrics(dm); //Slog.i("foo", "New metrics: w=" + metrics.widthPixels + " h=" // + metrics.heightPixels + " den=" + metrics.density // + " xdpi=" + metrics.xdpi + " ydpi=" + metrics.ydpi); - return metrics; + return dm; + } + + static Configuration applyConfigCompat(Configuration config, CompatibilityInfo compat) { + if (config == null) { + return null; + } + if (compat != null && !compat.supportsScreen()) { + config = new Configuration(config); + compat.applyToConfiguration(config); + } + return config; + } + + private final Configuration mMainThreadConfig = new Configuration(); + Configuration applyConfigCompatMainThread(Configuration config, CompatibilityInfo compat) { + if (config == null) { + return null; + } + if (compat != null && !compat.supportsScreen()) { + mMainThreadConfig.setTo(config); + config = mMainThreadConfig; + compat.applyToConfiguration(config); + } + return config; } /** @@ -1322,7 +1349,7 @@ public final class ActivityThread { } //Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics); - DisplayMetrics metrics = getDisplayMetricsLocked(false); + DisplayMetrics metrics = getDisplayMetricsLocked(compInfo, false); r = new Resources(assets, metrics, getConfiguration(), compInfo); if (false) { Slog.i(TAG, "Created app resources " + resDir + " " + r + ": " @@ -1350,7 +1377,7 @@ public final class ActivityThread { * Creates the top level resources for the given package. */ Resources getTopLevelResources(String resDir, LoadedApk pkgInfo) { - return getTopLevelResources(resDir, pkgInfo.mCompatibilityInfo); + return getTopLevelResources(resDir, pkgInfo.mCompatibilityInfo.get()); } final Handler getHandler() { @@ -1517,7 +1544,8 @@ public final class ActivityThread { CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO); context.init(info, null, this); context.getResources().updateConfiguration( - getConfiguration(), getDisplayMetricsLocked(false)); + getConfiguration(), getDisplayMetricsLocked( + CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, false)); mSystemContext = context; //Slog.i(TAG, "Created system resources " + context.getResources() // + ": " + context.getResources().getConfiguration()); @@ -1730,7 +1758,7 @@ public final class ActivityThread { appContext.init(r.packageInfo, r.token, this); appContext.setOuterContext(activity); CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager()); - Configuration config = new Configuration(mConfiguration); + Configuration config = new Configuration(mCompatConfiguration); if (DEBUG_CONFIGURATION) Slog.v(TAG, "Launching activity " + r.activityInfo.name + " with config " + config); activity.attach(appContext, this, getInstrumentation(), r.token, @@ -2763,13 +2791,14 @@ public final class ActivityThread { private void handleUpdatePackageCompatibilityInfo(UpdateCompatibilityData data) { LoadedApk apk = peekPackageInfo(data.pkg, false); if (apk != null) { - apk.mCompatibilityInfo = data.info; + apk.mCompatibilityInfo.set(data.info); } apk = peekPackageInfo(data.pkg, true); if (apk != null) { - apk.mCompatibilityInfo = data.info; + apk.mCompatibilityInfo.set(data.info); } handleConfigurationChanged(mConfiguration, data.info); + WindowManagerImpl.getDefault().reportNewConfiguration(mConfiguration); } private final void deliverResults(ActivityClientRecord r, List results) { @@ -3192,20 +3221,22 @@ public final class ActivityThread { ActivityClientRecord ar = it.next(); Activity a = ar.activity; if (a != null) { + Configuration thisConfig = applyConfigCompatMainThread(newConfig, + ar.packageInfo.mCompatibilityInfo.getIfNeeded()); if (!ar.activity.mFinished && (allActivities || (a != null && !ar.paused))) { // If the activity is currently resumed, its configuration // needs to change right now. callbacks.add(a); - } else if (newConfig != null) { + } else if (thisConfig != null) { // Otherwise, we will tell it about the change // the next time it is resumed or shown. Note that // the activity manager may, before then, decide the // activity needs to be destroyed to handle its new // configuration. if (DEBUG_CONFIGURATION) Slog.v(TAG, "Setting activity " - + ar.activityInfo.name + " newConfig=" + newConfig); - ar.newConfig = newConfig; + + ar.activityInfo.name + " newConfig=" + thisConfig); + ar.newConfig = thisConfig; } } } @@ -3252,7 +3283,6 @@ public final class ActivityThread { // onConfigurationChanged int diff = activity.mCurrentConfig.diff(config); if (diff != 0) { - // If this activity doesn't handle any of the config changes // then don't bother calling onConfigurationChanged as we're // going to destroy it. @@ -3296,7 +3326,15 @@ public final class ActivityThread { return false; } int changes = mResConfiguration.updateFrom(config); - DisplayMetrics dm = getDisplayMetricsLocked(true); + DisplayMetrics dm = getDisplayMetricsLocked(compat, true); + + if (compat != null && (mResCompatibilityInfo == null || + !mResCompatibilityInfo.equals(compat))) { + mResCompatibilityInfo = compat; + changes |= ActivityInfo.CONFIG_SCREEN_LAYOUT + | ActivityInfo.CONFIG_SCREEN_SIZE + | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE; + } // set it for java, this also affects newly created Resources if (config.locale != null) { @@ -3358,13 +3396,14 @@ public final class ActivityThread { return; } mConfiguration.updateFrom(config); - if (compat != null) { - // Can't do this here, because it causes us to report the - // comatible config back to the am as the current config - // of the activity, and much unhappiness results. - //compat.applyToConfiguration(mConfiguration); + if (mCompatConfiguration == null) { + mCompatConfiguration = new Configuration(); + } + mCompatConfiguration.setTo(mConfiguration); + if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) { + mResCompatibilityInfo.applyToConfiguration(mCompatConfiguration); + config = mCompatConfiguration; } - callbacks = collectComponentCallbacksLocked(false, config); } @@ -3385,7 +3424,7 @@ public final class ActivityThread { if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: " + r.activityInfo.name); - performConfigurationChanged(r.activity, mConfiguration); + performConfigurationChanged(r.activity, mCompatConfiguration); } final void handleProfilerControl(boolean start, ProfilerControlData pcd) { @@ -3480,6 +3519,7 @@ public final class ActivityThread { private final void handleBindApplication(AppBindData data) { mBoundApplication = data; mConfiguration = new Configuration(data.config); + mCompatConfiguration = new Configuration(data.config); // send up app name; do this *before* waiting for debugger Process.setArgV0(data.processName); diff --git a/core/java/android/app/Application.java b/core/java/android/app/Application.java index b9ac848..10cc9f8 100644 --- a/core/java/android/app/Application.java +++ b/core/java/android/app/Application.java @@ -37,6 +37,8 @@ import android.content.res.Configuration; * when first constructing the singleton.

*/ public class Application extends ContextWrapper implements ComponentCallbacks { + /** @hide */ + public LoadedApk mLoadedApk; public Application() { super(null); @@ -75,6 +77,6 @@ public class Application extends ContextWrapper implements ComponentCallbacks { */ /* package */ final void attach(Context context) { attachBaseContext(context); + mLoadedApk = ContextImpl.getImpl(context).mPackageInfo; } - } diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 73170bb..20dc792 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -425,11 +425,19 @@ class ContextImpl extends Context { registerService(WINDOW_SERVICE, new ServiceFetcher() { public Object getService(ContextImpl ctx) { - CompatibilityInfo ci = ctx.mResources.getCompatibilityInfo(); - return WindowManagerImpl.getDefault(ci); + return WindowManagerImpl.getDefault(ctx.mPackageInfo.mCompatibilityInfo); }}); } + static ContextImpl getImpl(Context context) { + Context nextContext; + while ((context instanceof ContextWrapper) && + (nextContext=((ContextWrapper)context).getBaseContext()) != null) { + context = nextContext; + } + return (ContextImpl)context; + } + // The system service cache for the system services that are // cached per-ContextImpl. Package-scoped to avoid accessor // methods. diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 6287d33..2549c84 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -38,6 +38,7 @@ import android.os.RemoteException; import android.os.StrictMode; import android.util.AndroidRuntimeException; import android.util.Slog; +import android.view.CompatibilityInfoHolder; import java.io.File; import java.io.IOException; @@ -64,7 +65,7 @@ final class ServiceConnectionLeaked extends AndroidRuntimeException { * Local state maintained about a currently loaded .apk. * @hide */ -final class LoadedApk { +public final class LoadedApk { private final ActivityThread mActivityThread; private final ApplicationInfo mApplicationInfo; @@ -78,10 +79,10 @@ final class LoadedApk { private final ClassLoader mBaseClassLoader; private final boolean mSecurityViolation; private final boolean mIncludeCode; + public final CompatibilityInfoHolder mCompatibilityInfo = new CompatibilityInfoHolder(); Resources mResources; private ClassLoader mClassLoader; private Application mApplication; - CompatibilityInfo mCompatibilityInfo; private final HashMap> mReceivers = new HashMap>(); @@ -121,7 +122,7 @@ final class LoadedApk { mBaseClassLoader = baseLoader; mSecurityViolation = securityViolation; mIncludeCode = includeCode; - mCompatibilityInfo = compatInfo; + mCompatibilityInfo.set(compatInfo); if (mAppDir == null) { if (ActivityThread.mSystemContext == null) { @@ -129,7 +130,7 @@ final class LoadedApk { ContextImpl.createSystemContext(mainThread); ActivityThread.mSystemContext.getResources().updateConfiguration( mainThread.getConfiguration(), - mainThread.getDisplayMetricsLocked(false), + mainThread.getDisplayMetricsLocked(compatInfo, false), compatInfo); //Slog.i(TAG, "Created system resources " // + mSystemContext.getResources() + ": " @@ -157,7 +158,7 @@ final class LoadedApk { mIncludeCode = true; mClassLoader = systemContext.getClassLoader(); mResources = systemContext.getResources(); - mCompatibilityInfo = compatInfo; + mCompatibilityInfo.set(compatInfo); } public String getPackageName() { diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index b686e54..acf2f2f 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -456,6 +456,9 @@ public class CompatibilityInfo implements Parcelable { inoutConfig.screenLayout = (inoutConfig.screenLayout&~Configuration.SCREENLAYOUT_SIZE_MASK) | Configuration.SCREENLAYOUT_SIZE_NORMAL; + inoutConfig.screenWidthDp = inoutConfig.compatScreenWidthDp; + inoutConfig.screenHeightDp = inoutConfig.compatScreenHeightDp; + inoutConfig.smallestScreenWidthDp = inoutConfig.compatSmallestScreenWidthDp; } } diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java index 6409aac..e2c6483 100644 --- a/core/java/android/content/res/Configuration.java +++ b/core/java/android/content/res/Configuration.java @@ -269,6 +269,13 @@ public final class Configuration implements Parcelable, Comparable=0; i--) { sConfigCallbacks.get(i).onConfigurationChanged(config); @@ -1995,6 +2019,7 @@ public final class ViewRoot extends Handler implements ViewParent, public final static int DISPATCH_DRAG_LOCATION_EVENT = 1016; public final static int DISPATCH_SYSTEM_UI_VISIBILITY = 1017; public final static int DISPATCH_GENERIC_MOTION = 1018; + public final static int UPDATE_CONFIGURATION = 1019; @Override public void handleMessage(Message msg) { @@ -2178,6 +2203,13 @@ public final class ViewRoot extends Handler implements ViewParent, case DISPATCH_SYSTEM_UI_VISIBILITY: { handleDispatchSystemUiVisibilityChanged(msg.arg1); } break; + case UPDATE_CONFIGURATION: { + Configuration config = (Configuration)msg.obj; + if (config.isOtherSeqNewer(mLastConfiguration)) { + config = mLastConfiguration; + } + updateConfiguration(config, false); + } break; } } @@ -3205,6 +3237,11 @@ public final class ViewRoot extends Handler implements ViewParent, } } + public void requestUpdateConfiguration(Configuration config) { + Message msg = obtainMessage(UPDATE_CONFIGURATION, config); + sendMessage(msg); + } + private void destroyHardwareRenderer() { if (mAttachInfo.mHardwareRenderer != null) { mAttachInfo.mHardwareRenderer.destroy(true); diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 5236a9e..e07085c 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -16,6 +16,7 @@ package android.view; +import android.app.Application; import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; @@ -25,6 +26,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; +import android.util.Slog; import android.view.accessibility.AccessibilityEvent; /** @@ -463,11 +465,16 @@ public abstract class Window { mWindowManager = new LocalWindowManager(wm, hardwareAccelerated); } + static CompatibilityInfoHolder getCompatInfo(Context context) { + Application app = (Application)context.getApplicationContext(); + return app != null ? app.mLoadedApk.mCompatibilityInfo : new CompatibilityInfoHolder(); + } + private class LocalWindowManager extends WindowManagerImpl.CompatModeWrapper { private final boolean mHardwareAccelerated; LocalWindowManager(WindowManager wm, boolean hardwareAccelerated) { - super(wm, mContext.getResources().getCompatibilityInfo()); + super(wm, getCompatInfo(mContext)); mHardwareAccelerated = hardwareAccelerated; } diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index 9cae75c..a853c15 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -19,11 +19,13 @@ package android.view; import java.util.HashMap; import android.content.res.CompatibilityInfo; +import android.content.res.Configuration; import android.graphics.PixelFormat; import android.os.IBinder; import android.util.AndroidRuntimeException; import android.util.Config; import android.util.Log; +import android.util.Slog; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; @@ -88,29 +90,32 @@ public class WindowManagerImpl implements WindowManager { = new HashMap(); static class CompatModeWrapper implements WindowManager { - private final WindowManager mWindowManager; + private final WindowManagerImpl mWindowManager; private final Display mDefaultDisplay; + private final CompatibilityInfoHolder mCompatibilityInfo; - CompatModeWrapper(WindowManager wm, CompatibilityInfo ci) { - mWindowManager = wm; + CompatModeWrapper(WindowManager wm, CompatibilityInfoHolder ci) { + mWindowManager = wm instanceof CompatModeWrapper + ? ((CompatModeWrapper)wm).mWindowManager : (WindowManagerImpl)wm; // Use the original display if there is no compatibility mode // to apply, or the underlying window manager is already a // compatibility mode wrapper. (We assume that if it is a // wrapper, it is applying the same compatibility mode.) - if (ci == null || wm instanceof CompatModeWrapper - || (!ci.isScalingRequired() && ci.supportsScreen())) { + if (ci == null) { mDefaultDisplay = mWindowManager.getDefaultDisplay(); } else { //mDefaultDisplay = mWindowManager.getDefaultDisplay(); mDefaultDisplay = Display.createCompatibleDisplay( mWindowManager.getDefaultDisplay().getDisplayId(), ci); } + + mCompatibilityInfo = ci; } @Override public void addView(View view, android.view.ViewGroup.LayoutParams params) { - mWindowManager.addView(view, params); + mWindowManager.addView(view, params, mCompatibilityInfo); } @Override @@ -146,8 +151,9 @@ public class WindowManagerImpl implements WindowManager { } public static WindowManager getDefault(CompatibilityInfo compatInfo) { - if (compatInfo == null || (!compatInfo.isScalingRequired() - && compatInfo.supportsScreen())) { + CompatibilityInfoHolder cih = new CompatibilityInfoHolder(); + cih.set(compatInfo); + if (cih.getIfNeeded() == null) { return sWindowManager; } @@ -159,35 +165,40 @@ public class WindowManagerImpl implements WindowManager { // having to make wrappers. WindowManager wm = sCompatWindowManagers.get(compatInfo); if (wm == null) { - wm = new CompatModeWrapper(sWindowManager, compatInfo); + wm = new CompatModeWrapper(sWindowManager, cih); sCompatWindowManagers.put(compatInfo, wm); } return wm; } } + + public static WindowManager getDefault(CompatibilityInfoHolder compatInfo) { + return new CompatModeWrapper(sWindowManager, compatInfo); + } public boolean isHardwareAccelerated() { return false; } - public void addView(View view) - { + public void addView(View view) { addView(view, new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_APPLICATION, 0, PixelFormat.OPAQUE)); } - public void addView(View view, ViewGroup.LayoutParams params) - { - addView(view, params, false); + public void addView(View view, ViewGroup.LayoutParams params) { + addView(view, params, null, false); } - public void addViewNesting(View view, ViewGroup.LayoutParams params) - { - addView(view, params, false); + public void addView(View view, ViewGroup.LayoutParams params, CompatibilityInfoHolder cih) { + addView(view, params, cih, false); } - private void addView(View view, ViewGroup.LayoutParams params, boolean nest) - { + public void addViewNesting(View view, ViewGroup.LayoutParams params) { + addView(view, params, null, false); + } + + private void addView(View view, ViewGroup.LayoutParams params, + CompatibilityInfoHolder cih, boolean nest) { if (Config.LOGV) Log.v("WindowManager", "addView view=" + view); if (!(params instanceof WindowManager.LayoutParams)) { @@ -237,6 +248,11 @@ public class WindowManagerImpl implements WindowManager { root = new ViewRoot(view.getContext()); root.mAddNesting = 1; + if (cih == null) { + root.mCompatibilityInfo = new CompatibilityInfoHolder(); + } else { + root.mCompatibilityInfo = cih; + } view.setLayoutParams(wparams); @@ -402,6 +418,17 @@ public class WindowManagerImpl implements WindowManager { } } + public void reportNewConfiguration(Configuration config) { + synchronized (this) { + int count = mViews.length; + config = new Configuration(config); + for (int i=0; i @@ -77,7 +77,7 @@ StreamingZipInflater::~StreamingZipInflater() { } void StreamingZipInflater::initInflateState() { - LOGD("Initializing inflate state"); + LOGV("Initializing inflate state"); memset(&mInflateState, 0, sizeof(mInflateState)); mInflateState.zalloc = Z_NULL; @@ -152,13 +152,13 @@ ssize_t StreamingZipInflater::read(void* outBuf, size_t count) { mInflateState.avail_out = mOutBufSize; /* - LOGD("Inflating to outbuf: avail_in=%u avail_out=%u next_in=%p next_out=%p", + LOGV("Inflating to outbuf: avail_in=%u avail_out=%u next_in=%p next_out=%p", mInflateState.avail_in, mInflateState.avail_out, mInflateState.next_in, mInflateState.next_out); */ int result = Z_OK; if (mStreamNeedsInit) { - LOGD("Initializing zlib to inflate"); + LOGV("Initializing zlib to inflate"); result = inflateInit2(&mInflateState, -MAX_WBITS); mStreamNeedsInit = false; } @@ -192,7 +192,7 @@ int StreamingZipInflater::readNextChunk() { size_t toRead = min_of(mInBufSize, mInTotalSize - mInNextChunkOffset); if (toRead > 0) { ssize_t didRead = ::read(mFd, mInBuf, toRead); - //LOGD("Reading input chunk, size %08x didread %08x", toRead, didRead); + //LOGV("Reading input chunk, size %08x didread %08x", toRead, didRead); if (didRead < 0) { // TODO: error LOGE("Error reading asset data"); diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 8d8ff96..13205e8 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -860,7 +860,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; lp.format = PixelFormat.TRANSLUCENT; lp.setTitle("PointerLocation"); - WindowManagerImpl wm = (WindowManagerImpl) + WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); wm.addView(addView, lp); @@ -883,7 +883,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mPointerLocationInputChannel = null; } - WindowManagerImpl wm = (WindowManagerImpl) + WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); wm.removeView(removeView); } @@ -1174,8 +1174,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { com.android.internal.R.styleable.Window_windowAnimationStyle, 0); params.setTitle("Starting " + packageName); - WindowManagerImpl wm = (WindowManagerImpl) - context.getSystemService(Context.WINDOW_SERVICE); + WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); View view = win.getDecorView(); if (win.isFloating()) { @@ -1220,7 +1219,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { TAG, "Removing starting window for " + appToken + ": " + window); if (window != null) { - WindowManagerImpl wm = (WindowManagerImpl) mContext.getSystemService(Context.WINDOW_SERVICE); + WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); wm.removeView(window); } } diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 6acc32f..6e88490 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -84,7 +84,7 @@ import com.android.internal.R; public class WifiService extends IWifiManager.Stub { private static final String TAG = "WifiService"; - private static final boolean DBG = true; + private static final boolean DBG = false; private final WifiStateMachine mWifiStateMachine; diff --git a/services/java/com/android/server/wm/BlackFrame.java b/services/java/com/android/server/wm/BlackFrame.java index f9f5758..d8fd7fe 100644 --- a/services/java/com/android/server/wm/BlackFrame.java +++ b/services/java/com/android/server/wm/BlackFrame.java @@ -38,6 +38,9 @@ public class BlackFrame { top = t; surface = new Surface(session, 0, "BlackSurface", -1, w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM); + if (WindowManagerService.SHOW_TRANSACTIONS || + WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG, + " BLACK " + surface + ": CREATE layer=" + layer); surface.setAlpha(1.0f); surface.setLayer(layer); } @@ -104,6 +107,10 @@ public class BlackFrame { if (mBlackSurfaces != null) { for (int i=0; i>> OPEN TRANSACTION createSurfaceLocked"); WindowManagerService.logSurface(this, "CREATE pos=(" + mFrame.left + "," + mFrame.top + ") (" + @@ -677,7 +682,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { mSurfaceShown = false; mSurface.hide(); if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_DITHER) != 0) { - if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "DITHER", null); + if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "DITHER", null); mSurface.setFlags(Surface.SURFACE_DITHER, Surface.SURFACE_DITHER); } @@ -688,7 +693,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { mLastHidden = true; } finally { Surface.closeTransaction(); - if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "<<< CLOSE TRANSACTION createSurfaceLocked"); + if (SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "<<< CLOSE TRANSACTION createSurfaceLocked"); } if (WindowManagerService.localLOGV) Slog.v( WindowManagerService.TAG, "Created surface " + this); @@ -725,7 +730,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { } try { - if (WindowManagerService.DEBUG_VISIBILITY) { + if (DEBUG_VISIBILITY) { RuntimeException e = null; if (!WindowManagerService.HIDE_STACK_CRAWLS) { e = new RuntimeException(); @@ -734,13 +739,13 @@ final class WindowState implements WindowManagerPolicy.WindowState { Slog.w(WindowManagerService.TAG, "Window " + this + " destroying surface " + mSurface + ", session " + mSession, e); } - if (WindowManagerService.SHOW_TRANSACTIONS) { + if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { RuntimeException e = null; if (!WindowManagerService.HIDE_STACK_CRAWLS) { e = new RuntimeException(); e.fillInStackTrace(); } - if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "DESTROY", e); + WindowManagerService.logSurface(this, "DESTROY", e); } mSurface.destroy(); } catch (RuntimeException e) { @@ -756,7 +761,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { boolean finishDrawingLocked() { if (mDrawPending) { - if (WindowManagerService.SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v( + if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v( WindowManagerService.TAG, "finishDrawingLocked: " + mSurface); mCommitDrawPending = true; mDrawPending = false; @@ -783,7 +788,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { // This must be called while inside a transaction. boolean performShowLocked() { - if (WindowManagerService.DEBUG_VISIBILITY) { + if (DEBUG_VISIBILITY) { RuntimeException e = null; if (!WindowManagerService.HIDE_STACK_CRAWLS) { e = new RuntimeException(); @@ -794,9 +799,9 @@ final class WindowState implements WindowManagerPolicy.WindowState { + " starting=" + (mAttrs.type == TYPE_APPLICATION_STARTING), e); } if (mReadyToShow && isReadyForDisplay()) { - if (WindowManagerService.SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) WindowManagerService.logSurface(this, + if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) WindowManagerService.logSurface(this, "SHOW (performShowLocked)", null); - if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Showing " + this + if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Showing " + this + " during animation: policyVis=" + mPolicyVisibility + " attHidden=" + mAttachedHidden + " tok.hiddenRequested=" @@ -958,7 +963,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { mHasTransformation = false; mHasLocalTransformation = false; if (mPolicyVisibility != mPolicyVisibilityAfterAnim) { - if (WindowManagerService.DEBUG_VISIBILITY) { + if (DEBUG_VISIBILITY) { Slog.v(WindowManagerService.TAG, "Policy visibility changing after anim in " + this + ": " + mPolicyVisibilityAfterAnim); } @@ -1020,7 +1025,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (mSurface != null) { mService.mDestroySurface.add(this); mDestroying = true; - if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "HIDE (finishExit)", null); + if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(this, "HIDE (finishExit)", null); mSurfaceShown = false; try { mSurface.hide(); @@ -1414,9 +1419,9 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (mPolicyVisibility && mPolicyVisibilityAfterAnim) { return false; } - if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility true: " + this); + if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility true: " + this); if (doAnimation) { - if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "doAnimation: mPolicyVisibility=" + if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "doAnimation: mPolicyVisibility=" + mPolicyVisibility + " mAnimation=" + mAnimation); if (mService.mDisplayFrozen || !mService.mPolicy.isScreenOn()) { doAnimation = false; @@ -1462,7 +1467,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (doAnimation) { mPolicyVisibilityAfterAnim = false; } else { - if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility false: " + this); + if (DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "Policy visibility false: " + this); mPolicyVisibilityAfterAnim = false; mPolicyVisibility = false; // Window is no longer visible -- make sure if we were waiting -- cgit v1.1