diff options
40 files changed, 310 insertions, 196 deletions
diff --git a/api/current.xml b/api/current.xml index f417e3d89f59..86c47f589e53 100644 --- a/api/current.xml +++ b/api/current.xml @@ -260231,7 +260231,7 @@ deprecated="not deprecated" visibility="public" > -<parameter name="arg0" type="T"> +<parameter name="t" type="T"> </parameter> </method> </interface> diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 63a3ff04e88d..f05ef8c588cd 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -7580,8 +7580,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility mHardwareLayer.destroy(); mHardwareLayer = null; } - mAttachInfo.mHandler.removeMessages(AttachInfo.INVALIDATE_MSG, this); - mAttachInfo.mHandler.removeMessages(AttachInfo.INVALIDATE_RECT_MSG, this); + + if (mAttachInfo != null) { + mAttachInfo.mHandler.removeMessages(AttachInfo.INVALIDATE_MSG, this); + mAttachInfo.mHandler.removeMessages(AttachInfo.INVALIDATE_RECT_MSG, this); + } + mCurrentAnimation = null; } diff --git a/core/java/android/view/WindowOrientationListener.java b/core/java/android/view/WindowOrientationListener.java index 2a76e33f94fe..6095a64d634a 100755 --- a/core/java/android/view/WindowOrientationListener.java +++ b/core/java/android/view/WindowOrientationListener.java @@ -234,6 +234,14 @@ public abstract class WindowOrientationListener { // high time constant. private static final float MAX_DEVIATION_FROM_GRAVITY = 1.5f; + // Minimum acceleration considered, in m/s^2. Below this threshold sensor noise will have + // significant impact on the calculations and in case of the vector (0, 0, 0) there is no + // defined rotation or tilt at all. Low or zero readings can happen when space travelling + // or free falling, but more commonly when shaking or getting bad readings from the sensor. + // The accelerometer is turned off when not used and polling it too soon after it is + // turned on may result in (0, 0, 0). + private static final float MIN_ABS_ACCELERATION = 1.5f; + // Actual sampling period corresponding to SensorManager.SENSOR_DELAY_NORMAL. There's no // way to get this information from SensorManager. // Note the actual period is generally 3-30ms larger than this depending on the device, but @@ -347,6 +355,9 @@ public abstract class WindowOrientationListener { float deviation = Math.abs(magnitude - SensorManager.STANDARD_GRAVITY); handleAccelerationDistrust(deviation); + if (magnitude < MIN_ABS_ACCELERATION) { + return; // Ignore tilt and orientation when (0, 0, 0) or low reading + } // only filter tilt when we're accelerating float alpha = 1; diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java index 1b3937100456..c27082f928f9 100644 --- a/core/java/android/widget/AdapterViewAnimator.java +++ b/core/java/android/widget/AdapterViewAnimator.java @@ -787,6 +787,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter> // We do the former in case mAdapter is null, and hence setDisplayedChild won't // set mWhichChild mWhichChild = ss.whichChild; + setDisplayedChild(mWhichChild); } diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 0476d28fffdf..264af71eb438 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -194,7 +194,21 @@ public class StackView extends AdapterViewAnimator { /** * Animate the views between different relative indexes within the {@link AdapterViewAnimator} */ - void animateViewForTransition(int fromIndex, int toIndex, View view) { + void animateViewForTransition(int fromIndex, int toIndex, final View view) { + ObjectAnimator alphaOa = null; + ObjectAnimator oldAlphaOa = null; + + // If there is currently an alpha animation on this view, we need + // to know about it, and may need to cancel it so as not to interfere with + // a new alpha animation. + Object tag = view.getTag(com.android.internal.R.id.viewAlphaAnimation); + if (tag instanceof WeakReference<?>) { + Object obj = ((WeakReference<?>) tag).get(); + if (obj instanceof ObjectAnimator) { + oldAlphaOa = (ObjectAnimator) obj; + } + } + if (fromIndex == -1 && toIndex == NUM_ACTIVE_VIEWS -1) { // Fade item in if (view.getAlpha() == 1) { @@ -206,9 +220,12 @@ public class StackView extends AdapterViewAnimator { view.setTranslationY(0); view.setVisibility(VISIBLE); - ObjectAnimator fadeIn = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 1.0f); - fadeIn.setDuration(FADE_IN_ANIMATION_DURATION); - fadeIn.start(); + alphaOa = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 1.0f); + alphaOa.setDuration(FADE_IN_ANIMATION_DURATION); + if (oldAlphaOa != null) oldAlphaOa.cancel(); + alphaOa.start(); + view.setTagInternal(com.android.internal.R.id.viewAlphaAnimation, + new WeakReference<ObjectAnimator>(alphaOa)); } else if (fromIndex == 0 && toIndex == 1) { // Slide item in view.setVisibility(VISIBLE); @@ -216,39 +233,45 @@ public class StackView extends AdapterViewAnimator { int duration = Math.round(mStackSlider.getDurationForNeutralPosition(mYVelocity)); StackSlider animationSlider = new StackSlider(mStackSlider); + animationSlider.setView(view); PropertyValuesHolder slideInY = PropertyValuesHolder.ofFloat("YProgress", 0.0f); PropertyValuesHolder slideInX = PropertyValuesHolder.ofFloat("XProgress", 0.0f); - ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, + ObjectAnimator slideIn = ObjectAnimator.ofPropertyValuesHolder(animationSlider, slideInX, slideInY); - pa.setDuration(duration); - pa.setInterpolator(new LinearInterpolator()); - pa.start(); + slideIn.setDuration(duration); + slideIn.setInterpolator(new LinearInterpolator()); + slideIn.start(); } else if (fromIndex == 1 && toIndex == 0) { // Slide item out int duration = Math.round(mStackSlider.getDurationForOffscreenPosition(mYVelocity)); StackSlider animationSlider = new StackSlider(mStackSlider); + animationSlider.setView(view); PropertyValuesHolder slideOutY = PropertyValuesHolder.ofFloat("YProgress", 1.0f); PropertyValuesHolder slideOutX = PropertyValuesHolder.ofFloat("XProgress", 0.0f); - ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, + ObjectAnimator slideOut = ObjectAnimator.ofPropertyValuesHolder(animationSlider, slideOutX, slideOutY); - pa.setDuration(duration); - pa.setInterpolator(new LinearInterpolator()); - pa.start(); - } else if (fromIndex == -1 && toIndex == 0) { + slideOut.setDuration(duration); + slideOut.setInterpolator(new LinearInterpolator()); + slideOut.start(); + } else if (toIndex == 0) { // Make sure this view that is "waiting in the wings" is invisible view.setAlpha(0.0f); view.setVisibility(INVISIBLE); - LayoutParams lp = (LayoutParams) view.getLayoutParams(); - lp.setVerticalOffset(-mSlideAmount); + } else if (fromIndex == 0 && toIndex > 1) { + view.setVisibility(VISIBLE); + view.setAlpha(1.0f); } else if (fromIndex == -1) { view.setAlpha(1.0f); view.setVisibility(VISIBLE); } else if (toIndex == -1) { // Fade item out - ObjectAnimator fadeOut = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 0.0f); - fadeOut.setDuration(STACK_RELAYOUT_DURATION); - fadeOut.start(); + alphaOa = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 0.0f); + alphaOa.setDuration(STACK_RELAYOUT_DURATION); + if (oldAlphaOa != null) oldAlphaOa.cancel(); + alphaOa.start(); + view.setTagInternal(com.android.internal.R.id.viewAlphaAnimation, + new WeakReference<ObjectAnimator>(alphaOa)); } // Implement the faked perspective @@ -279,6 +302,16 @@ public class StackView extends AdapterViewAnimator { (getMeasuredWidth() * (1 - PERSPECTIVE_SHIFT_FACTOR_X) / 2.0f); final float transX = perspectiveTranslationX + scaleShiftCorrectionX; + // If this view is currently being animated for a certain position, we need to cancel + // this animation so as not to interfere with the new transformation. + Object tag = view.getTag(com.android.internal.R.id.viewAnimation); + if (tag instanceof WeakReference<?>) { + Object obj = ((WeakReference<?>) tag).get(); + if (obj instanceof ObjectAnimator) { + ((ObjectAnimator) obj).cancel(); + } + } + if (animate) { PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat("translationX", transX); PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", transY); @@ -292,14 +325,6 @@ public class StackView extends AdapterViewAnimator { new WeakReference<ObjectAnimator>(oa)); oa.start(); } else { - Object tag = view.getTag(com.android.internal.R.id.viewAnimation); - if (tag instanceof WeakReference<?>) { - Object obj = ((WeakReference<?>) tag).get(); - if (obj instanceof ObjectAnimator) { - ((ObjectAnimator) obj).cancel(); - } - } - view.setTranslationX(transX); view.setTranslationY(transY); view.setScaleX(scale); diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java index d0faea6a4cbf..830c2c1f865a 100644 --- a/core/java/com/android/internal/view/menu/MenuBuilder.java +++ b/core/java/com/android/internal/view/menu/MenuBuilder.java @@ -353,8 +353,7 @@ public class MenuBuilder implements Menu { mNonActionItems = new ArrayList<MenuItemImpl>(); mIsActionItemsStale = true; - mShortcutsVisible = - (mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); + setShortcutsVisibleInner(true); } public MenuBuilder setDefaultShowAsAction(int defaultShowAsAction) { @@ -782,14 +781,18 @@ public class MenuBuilder implements Menu { */ public void setShortcutsVisible(boolean shortcutsVisible) { if (mShortcutsVisible == shortcutsVisible) return; - - mShortcutsVisible = - (mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) - && shortcutsVisible; - + + setShortcutsVisibleInner(shortcutsVisible); refreshShortcuts(mShortcutsVisible, isQwertyMode()); } + private void setShortcutsVisibleInner(boolean shortcutsVisible) { + mShortcutsVisible = shortcutsVisible + && mResources.getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS + && mResources.getBoolean( + com.android.internal.R.bool.config_showMenuShortcutsWhenKeyboardPresent); + } + /** * @return Whether shortcuts should be visible on menus. */ diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 590baf1f4d0c..8bb05fb2ec78 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -529,4 +529,8 @@ <!-- When a database query is executed, the results retuned are paginated in pages of size (in KB) indicated by this value --> <integer name="config_cursorWindowSize">2048</integer> + + <!-- Sets whether menu shortcuts should be displayed on panel menus when + a keyboard is present. --> + <bool name="config_showMenuShortcutsWhenKeyboardPresent">false</bool> </resources> diff --git a/core/res/res/values/ids.xml b/core/res/res/values/ids.xml index 93ccd4f9b8cd..837e04f536e8 100644 --- a/core/res/res/values/ids.xml +++ b/core/res/res/values/ids.xml @@ -74,4 +74,5 @@ <item type="id" name="rowTypeId" /> <item type="id" name="up" /> <item type="id" name="viewAnimation" /> + <item type="id" name="viewAlphaAnimation" /> </resources> diff --git a/libs/ui/KeyCharacterMap.cpp b/libs/ui/KeyCharacterMap.cpp index 9bfa8f6de440..2decfe93215a 100644 --- a/libs/ui/KeyCharacterMap.cpp +++ b/libs/ui/KeyCharacterMap.cpp @@ -185,9 +185,11 @@ bool KeyCharacterMap::getFallbackAction(int32_t keyCode, int32_t metaState, const Key* key; const Behavior* behavior; if (getKeyBehavior(keyCode, metaState, &key, &behavior)) { - outFallbackAction->keyCode = behavior->fallbackKeyCode; - outFallbackAction->metaState = metaState & ~behavior->metaState; - result = true; + if (behavior->fallbackKeyCode) { + outFallbackAction->keyCode = behavior->fallbackKeyCode; + outFallbackAction->metaState = metaState & ~behavior->metaState; + result = true; + } } #if DEBUG_MAPPING LOGD("getFallbackKeyCode: keyCode=%d, metaState=0x%08x ~ Result %s, " diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java index 1f06dcc4c6f2..5e33f0535c49 100644 --- a/policy/src/com/android/internal/policy/impl/GlobalActions.java +++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java @@ -221,8 +221,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac final AlertDialog.Builder ab = new AlertDialog.Builder(mContext); ab.setAdapter(mAdapter, this) - .setInverseBackgroundForced(true) - .setTitle(R.string.global_actions); + .setInverseBackgroundForced(true); final AlertDialog dialog = ab.create(); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); @@ -249,6 +248,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } else { mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); } + mDialog.setTitle(R.string.global_actions); } diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 1fc2e6c5e4a0..d6b7366ea168 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -1624,24 +1624,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // First handle chording of panel key: if a panel key is held // but not released, try to execute a shortcut in it. if ((mPanelChordingKey > 0) && (mPanelChordingKey != keyCode)) { - // Perform the shortcut (mPreparedPanel can be null since - // global shortcuts (such as search) don't rely on a - // prepared panel or menu). - boolean handled = performPanelShortcut(mPreparedPanel, keyCode, event, - Menu.FLAG_PERFORM_NO_CLOSE); - - if (!handled) { - /* - * If not handled, then pass it to the view hierarchy - * and anyone else that may be interested. - */ - handled = dispatchKeyShortcutEvent(event); - - if (handled && mPreparedPanel != null) { - mPreparedPanel.isHandled = true; - } - } - + boolean handled = dispatchKeyShortcutEvent(event); if (handled) { return true; } @@ -1676,6 +1659,19 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { @Override public boolean dispatchKeyShortcutEvent(KeyEvent ev) { + // Perform the shortcut (mPreparedPanel can be null since + // global shortcuts (such as search) don't rely on a + // prepared panel or menu). + boolean handled = performPanelShortcut(mPreparedPanel, ev.getKeyCode(), ev, + Menu.FLAG_PERFORM_NO_CLOSE); + if (handled) { + if (mPreparedPanel != null) { + mPreparedPanel.isHandled = true; + } + return true; + } + + // Shortcut not handled by the panel. Dispatch to the view hierarchy. final Callback cb = getCallback(); return cb != null && mFeatureId < 0 ? cb.dispatchKeyShortcutEvent(ev) : super .dispatchKeyShortcutEvent(ev); diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index a6037aa131e9..2a393227745c 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -239,9 +239,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { volatile boolean mPowerKeyHandled; RecentApplicationsDialog mRecentAppsDialog; Handler mHandler; - + + private static final int LID_ABSENT = -1; + private static final int LID_CLOSED = 0; + private static final int LID_OPEN = 1; + + int mLidOpen = LID_ABSENT; + boolean mSystemReady; - boolean mLidOpen; boolean mHdmiPlugged; int mUiMode = Configuration.UI_MODE_TYPE_NORMAL; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; @@ -896,21 +901,31 @@ public class PhoneWindowManager implements WindowManagerPolicy { void readLidState() { try { int sw = mWindowManager.getSwitchState(SW_LID); - if (sw >= 0) { - mLidOpen = sw == 0; + if (sw > 0) { + mLidOpen = LID_OPEN; + } else if (sw == 0) { + mLidOpen = LID_CLOSED; + } else { + mLidOpen = LID_ABSENT; } } catch (RemoteException e) { // Ignore } } - private int determineHiddenState(boolean lidOpen, - int mode, int hiddenValue, int visibleValue) { + private int determineHiddenState(int mode, int hiddenValue, int visibleValue) { + if (KEYBOARD_ALWAYS_HIDDEN) { + return hiddenValue; + } + if (mLidOpen == LID_ABSENT) { + return visibleValue; + } + switch (mode) { case 1: - return lidOpen ? visibleValue : hiddenValue; + return mLidOpen == LID_OPEN ? visibleValue : hiddenValue; case 2: - return lidOpen ? hiddenValue : visibleValue; + return mLidOpen == LID_OPEN ? hiddenValue : visibleValue; } return visibleValue; } @@ -918,12 +933,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ public void adjustConfigurationLw(Configuration config) { readLidState(); - final boolean lidOpen = !KEYBOARD_ALWAYS_HIDDEN && mLidOpen; - mPowerManager.setKeyboardVisibility(lidOpen); - config.hardKeyboardHidden = determineHiddenState(lidOpen, + mPowerManager.setKeyboardVisibility(mLidOpen == LID_OPEN); + config.hardKeyboardHidden = determineHiddenState( mLidKeyboardAccessibility, Configuration.HARDKEYBOARDHIDDEN_YES, Configuration.HARDKEYBOARDHIDDEN_NO); - config.navigationHidden = determineHiddenState(lidOpen, + config.navigationHidden = determineHiddenState( mLidNavigationAccessibility, Configuration.NAVIGATIONHIDDEN_YES, Configuration.NAVIGATIONHIDDEN_NO); config.keyboardHidden = (config.hardKeyboardHidden @@ -1973,8 +1987,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { // lid changed state - mLidOpen = lidOpen; - boolean awakeNow = mKeyguardMediator.doLidChangeTq(mLidOpen); + mLidOpen = lidOpen ? LID_OPEN : LID_CLOSED; + boolean awakeNow = mKeyguardMediator.doLidChangeTq(lidOpen); updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE); if (awakeNow) { // If the lid is opening and we don't have to keep the @@ -1982,7 +1996,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // immediately. mKeyguardMediator.pokeWakelock(); } else if (keyguardIsShowingTq()) { - if (mLidOpen) { + if (lidOpen) { // If we are opening the lid and not hiding the // keyguard, then we need to have it turn on the // screen once it is shown. @@ -1991,7 +2005,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else { // Light up the keyboard if we are sliding up. - if (mLidOpen) { + if (lidOpen) { mPowerManager.userActivity(SystemClock.uptimeMillis(), false, LocalPowerManager.BUTTON_EVENT); } else { @@ -2473,7 +2487,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { //or case.unspecified if (mHdmiPlugged) { return Surface.ROTATION_0; - } else if (mLidOpen) { + } else if (mLidOpen == LID_OPEN) { return mLidOpenRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) { return mCarDockRotation; @@ -2550,7 +2564,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { int sState = mWindowManager.getKeycodeState(KeyEvent.KEYCODE_S); int dpadState = mWindowManager.getDPadKeycodeState(KeyEvent.KEYCODE_DPAD_CENTER); int trackballState = mWindowManager.getTrackballScancodeState(BTN_MOUSE); - mSafeMode = menuState > 0 || sState > 0 || dpadState > 0 || trackballState > 0; + int volumeDownState = mWindowManager.getKeycodeState(KeyEvent.KEYCODE_VOLUME_DOWN); + mSafeMode = menuState > 0 || sState > 0 || dpadState > 0 || trackballState > 0 + || volumeDownState > 0; performHapticFeedbackLw(null, mSafeMode ? HapticFeedbackConstants.SAFE_MODE_ENABLED : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); @@ -2639,11 +2655,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { } void updateRotation(int animFlags) { - mPowerManager.setKeyboardVisibility(mLidOpen); + mPowerManager.setKeyboardVisibility(mLidOpen == LID_OPEN); int rotation = Surface.ROTATION_0; if (mHdmiPlugged) { rotation = Surface.ROTATION_0; - } else if (mLidOpen) { + } else if (mLidOpen == LID_OPEN) { rotation = mLidOpenRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) { rotation = mCarDockRotation; diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp index 7a45de6fb35a..f6a8859a5e91 100644 --- a/services/input/InputReader.cpp +++ b/services/input/InputReader.cpp @@ -1183,10 +1183,18 @@ void CursorInputMapper::sync(nsecs_t when) { if (downChanged) { if (mAccumulator.btnMouse) { - mLocked.down = true; - mLocked.downTime = when; + if (!mLocked.down) { + mLocked.down = true; + mLocked.downTime = when; + } else { + downChanged = false; + } } else { - mLocked.down = false; + if (mLocked.down) { + mLocked.down = false; + } else { + downChanged = false; + } } } diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/InputManager.java index 6dca52348039..06595ae503cb 100644 --- a/services/java/com/android/server/InputManager.java +++ b/services/java/com/android/server/InputManager.java @@ -423,7 +423,7 @@ public class InputManager { @SuppressWarnings("unused") public void notifyConfigurationChanged(long whenNanos) { - mWindowManagerService.sendNewConfiguration(); + mWindowManagerService.mInputMonitor.notifyConfigurationChanged(); } @SuppressWarnings("unused") diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 95534e356110..6f4b4c5be403 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -481,14 +481,11 @@ class ServerThread extends Thread { // we are in safe mode. final boolean safeMode = wm.detectSafeMode(); if (safeMode) { - try { - ActivityManagerNative.getDefault().enterSafeMode(); - // Post the safe mode state in the Zygote class - Zygote.systemInSafeMode = true; - // Disable the JIT for the system_server process - VMRuntime.getRuntime().disableJitCompilation(); - } catch (RemoteException e) { - } + ActivityManagerService.self().enterSafeMode(); + // Post the safe mode state in the Zygote class + Zygote.systemInSafeMode = true; + // Disable the JIT for the system_server process + VMRuntime.getRuntime().disableJitCompilation(); } else { // Enable the JIT for the system_server process VMRuntime.getRuntime().startJitCompilation(); @@ -506,6 +503,10 @@ class ServerThread extends Thread { wm.systemReady(); + if (safeMode) { + ActivityManagerService.self().showSafeModeOverlay(); + } + // Update the configuration for this context by hand, because we're going // to start using it before the config change done in wm.systemReady() will // propagate to it. diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 8d9cb31c013b..bdc779c3e11e 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -212,6 +212,10 @@ public class WindowManagerService extends IWindowManager.Stub // Maximum number of milliseconds to wait for input event injection. // FIXME is this value reasonable? private static final int INJECTION_TIMEOUT_MILLIS = 30 * 1000; + + // Maximum number of milliseconds to wait for input devices to be enumerated before + // proceding with safe mode detection. + private static final int INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS = 1000; // Default input dispatching timeout in nanoseconds. private static final long DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS = 5000 * 1000000L; @@ -5812,6 +5816,11 @@ public class WindowManagerService extends IWindowManager.Stub // Temporary input application object to provide to the input dispatcher. private InputApplication mTempInputApplication = new InputApplication(); + // Set to true when the first input device configuration change notification + // is received to indicate that the input devices are ready. + private final Object mInputDevicesReadyMonitor = new Object(); + private boolean mInputDevicesReady; + /* Notifies the window manager about a broken input channel. * * Called by the InputManager. @@ -6007,7 +6016,32 @@ public class WindowManagerService extends IWindowManager.Stub // Also avoids keeping InputChannel objects referenced unnecessarily. mTempInputWindows.clear(); } - + + /* Notifies that the input device configuration has changed. */ + public void notifyConfigurationChanged() { + sendNewConfiguration(); + + synchronized (mInputDevicesReadyMonitor) { + if (!mInputDevicesReady) { + mInputDevicesReady = true; + mInputDevicesReadyMonitor.notifyAll(); + } + } + } + + /* Waits until the built-in input devices have been configured. */ + public boolean waitForInputDevicesReady(long timeoutMillis) { + synchronized (mInputDevicesReadyMonitor) { + if (!mInputDevicesReady) { + try { + mInputDevicesReadyMonitor.wait(timeoutMillis); + } catch (InterruptedException ex) { + } + } + return mInputDevicesReady; + } + } + /* Notifies that the lid switch changed state. */ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen); @@ -6329,6 +6363,13 @@ public class WindowManagerService extends IWindowManager.Stub } public boolean detectSafeMode() { + if (!mInputMonitor.waitForInputDevicesReady( + INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS)) { + Slog.w(TAG, "Devices still not ready after waiting " + + INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS + + " milliseconds before attempting to detect safe mode."); + } + mSafeMode = mPolicy.detectSafeMode(); return mSafeMode; } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 17ef88d96f44..dbf9a96a8739 100755 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -6075,23 +6075,25 @@ public final class ActivityManagerService extends ActivityManagerNative AppGlobals.getPackageManager().enterSafeMode(); } catch (RemoteException e) { } - - View v = LayoutInflater.from(mContext).inflate( - com.android.internal.R.layout.safe_mode, null); - WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); - lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; - lp.width = WindowManager.LayoutParams.WRAP_CONTENT; - lp.height = WindowManager.LayoutParams.WRAP_CONTENT; - lp.gravity = Gravity.BOTTOM | Gravity.LEFT; - lp.format = v.getBackground().getOpacity(); - lp.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE - | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; - ((WindowManager)mContext.getSystemService( - Context.WINDOW_SERVICE)).addView(v, lp); } } } + public final void showSafeModeOverlay() { + View v = LayoutInflater.from(mContext).inflate( + com.android.internal.R.layout.safe_mode, null); + WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); + lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; + lp.width = WindowManager.LayoutParams.WRAP_CONTENT; + lp.height = WindowManager.LayoutParams.WRAP_CONTENT; + lp.gravity = Gravity.BOTTOM | Gravity.LEFT; + lp.format = v.getBackground().getOpacity(); + lp.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE + | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; + ((WindowManager)mContext.getSystemService( + Context.WINDOW_SERVICE)).addView(v, lp); + } + public void noteWakeupAlarm(IIntentSender sender) { if (!(sender instanceof PendingIntentRecord)) { return; diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java index 9ccb3eed7892..a3466e27e597 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java @@ -75,6 +75,7 @@ public class TestShellActivity extends Activity implements LayoutTestController public void handleMessage(Message msg) { if (msg.what == MSG_TIMEOUT) { mTimedOut = true; + mWebView.stopLoading(); if (mCallback != null) mCallback.timedOut(mWebView.getUrl()); if (!mRequestedWebKitData) { diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java index 7020d9cbfcea..db3cf44d89c8 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java @@ -353,7 +353,7 @@ public class BitmapFactory { If it happened on close, bm is still valid. */ Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, - String.format("Error decoding bitmap of id 0x%x", id), e); + String.format("Error decoding bitmap of id 0x%x", id), e, null /*data*/); } finally { try { if (is != null) is.close(); @@ -454,7 +454,7 @@ public class BitmapFactory { if (is instanceof AssetManager.AssetInputStream) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Bitmap.decodeStream: " + - "InputStream is unsupported (AssetManager.AssetInputStream)"); + "InputStream is unsupported (AssetManager.AssetInputStream)", null /*data*/); return null; } else { // pass some temp storage down to the native code. 1024 is made up, diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java index 03d65b2ed969..73c5a1aceab4 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java @@ -114,7 +114,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in BitmapShader", e); + "Unable to inverse matrix in BitmapShader", e, null /*data*/); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -123,7 +123,7 @@ public class BitmapShader_Delegate extends Shader_Delegate { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in BitmapShader", e); + "Unable to inverse matrix in BitmapShader", e, null /*data*/); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java index 18bf4b58ff08..108d1838db7b 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java @@ -250,7 +250,7 @@ public final class Bitmap_Delegate { /*package*/ static boolean nativeCompress(int nativeBitmap, int format, int quality, OutputStream stream, byte[] tempStorage) { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, - "Bitmap.compress() is not supported"); + "Bitmap.compress() is not supported", null /*data*/); return true; } @@ -386,7 +386,8 @@ public final class Bitmap_Delegate { // This is only called by Bitmap.CREATOR (Parcelable.Creator<Bitmap>), which is only // used during aidl call so really this should not be called. Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, - "AIDL is not suppored, and therefore Bitmaps cannot be created from parcels."); + "AIDL is not suppored, and therefore Bitmaps cannot be created from parcels.", + null /*data*/); return null; } @@ -395,7 +396,8 @@ public final class Bitmap_Delegate { // This is only called when sending a bitmap through aidl, so really this should not // be called. Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, - "AIDL is not suppored, and therefore Bitmaps cannot be written to parcels."); + "AIDL is not suppored, and therefore Bitmaps cannot be written to parcels.", + null /*data*/); return false; } @@ -412,7 +414,7 @@ public final class Bitmap_Delegate { if (paint != null && paint.getMaskFilter() != null) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MASKFILTER, "MaskFilter not supported in Bitmap.extractAlpha", - null); + null, null /*data*/); } int alpha = paint != null ? paint.getAlpha() : 0xFF; diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java index 8bfaf4041200..5a6902c074dc 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java @@ -425,7 +425,7 @@ public final class Canvas_Delegate { assert false; Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Canvas#setMatrix(android.graphics.Matrix) only " + - "supports affine transformations.", null); + "supports affine transformations.", null, null /*data*/); } } @@ -494,7 +494,7 @@ public final class Canvas_Delegate { if (filterDelegate.isSupported() == false) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_DRAWFILTER, - filterDelegate.getSupportMessage(), null); + filterDelegate.getSupportMessage(), null, null /*data*/); } } diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java index aab310aa626e..9525dcf8e049 100644 --- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java @@ -137,7 +137,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in LinearGradient", e); + "Unable to inverse matrix in LinearGradient", e, null /*data*/); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -146,7 +146,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in LinearGradient", e); + "Unable to inverse matrix in LinearGradient", e, null /*data*/); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java index 0c934fccaa4d..2d77d40f6f54 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java @@ -615,7 +615,7 @@ public final class Matrix_Delegate { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "Matrix.setPolyToPoly is not supported.", - null); + null, null /*data*/); return false; } diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java index 049ac454c165..7a6da95dbb89 100644 --- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java @@ -74,7 +74,7 @@ public final class NinePatch_Delegate { oos = new ObjectOutputStream(baos); oos.writeObject(chunk); } catch (IOException e) { - Bridge.getLog().error(null, "Failed to serialize NinePatchChunk.", e); + Bridge.getLog().error(null, "Failed to serialize NinePatchChunk.", e, null /*data*/); return null; } finally { if (oos != null) { @@ -198,11 +198,11 @@ public final class NinePatch_Delegate { } } catch (IOException e) { Bridge.getLog().error(LayoutLog.TAG_BROKEN, - "Failed to deserialize NinePatchChunk content.", e); + "Failed to deserialize NinePatchChunk content.", e, null /*data*/); return null; } catch (ClassNotFoundException e) { Bridge.getLog().error(LayoutLog.TAG_BROKEN, - "Failed to deserialize NinePatchChunk class.", e); + "Failed to deserialize NinePatchChunk class.", e, null /*data*/); return null; } finally { if (ois != null) { diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java index 67afecae3493..87164fb42e0b 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java @@ -182,7 +182,7 @@ public class Paint_Delegate { } else { Bridge.getLog().fidelityWarning(LayoutLog.TAG_PATHEFFECT, effectDelegate.getSupportMessage(), - null); + null, null /*data*/); } } @@ -377,7 +377,7 @@ public class Paint_Delegate { int color) { // FIXME Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, - "Paint.setShadowLayer is not supported.", null); + "Paint.setShadowLayer is not supported.", null, null /*data*/); } /*package*/ static float getTextSize(Paint thisPaint) { @@ -694,7 +694,7 @@ public class Paint_Delegate { ColorFilter_Delegate filterDelegate = delegate.getColorFilter(); if (filterDelegate != null && filterDelegate.isSupported() == false) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_COLORFILTER, - filterDelegate.getSupportMessage(), null); + filterDelegate.getSupportMessage(), null, null /*data*/); } return filter; @@ -733,7 +733,7 @@ public class Paint_Delegate { MaskFilter_Delegate filterDelegate = delegate.getMaskFilter(); if (filterDelegate != null && filterDelegate.isSupported() == false) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MASKFILTER, - filterDelegate.getSupportMessage(), null); + filterDelegate.getSupportMessage(), null, null /*data*/); } return maskfilter; @@ -764,7 +764,7 @@ public class Paint_Delegate { Rasterizer_Delegate rasterizerDelegate = delegate.getRasterizer(); if (rasterizerDelegate != null && rasterizerDelegate.isSupported() == false) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_RASTERIZER, - rasterizerDelegate.getSupportMessage(), null); + rasterizerDelegate.getSupportMessage(), null, null /*data*/); } return rasterizer; diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java index 62ea62230061..a4e43c111879 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java @@ -698,7 +698,7 @@ public final class Path_Delegate { assert false; Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Path#transform() only " + - "supports affine transformations.", null); + "supports affine transformations.", null, null /*data*/); } GeneralPath newPath = new GeneralPath(); diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java index 314dcff212a9..147e1d0e7607 100644 --- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffXfermode_Delegate.java @@ -74,7 +74,7 @@ public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { } Bridge.getLog().error(LayoutLog.TAG_BROKEN, - String.format("Unknown PorterDuff.Mode: %d", mode)); + String.format("Unknown PorterDuff.Mode: %d", mode), null /*data*/); assert false; return PorterDuff.Mode.SRC_OVER; } @@ -118,7 +118,7 @@ public class PorterDuffXfermode_Delegate extends Xfermode_Delegate { Bridge.getLog().fidelityWarning(LayoutLog.TAG_BROKEN, String.format("Unsupported PorterDuff Mode: %s", mode.name()), - null); + null, null /*data*/); return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha); } diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java index 2c26175d75d9..ffdf5ddb02c9 100644 --- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java @@ -126,7 +126,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in RadialGradient", e); + "Unable to inverse matrix in RadialGradient", e, null /*data*/); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -135,7 +135,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in RadialGradient", e); + "Unable to inverse matrix in RadialGradient", e, null /*data*/); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java index f86c56cc2a2c..9b6fb82a6329 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java @@ -417,7 +417,8 @@ public class Region_Delegate { // This is only called by Region.CREATOR (Parcelable.Creator<Region>), which is only // used during aidl call so really this should not be called. Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, - "AIDL is not suppored, and therefore Regions cannot be created from parcels."); + "AIDL is not suppored, and therefore Regions cannot be created from parcels.", + null /*data*/); return 0; } @@ -426,7 +427,8 @@ public class Region_Delegate { // This is only called when sending a region through aidl, so really this should not // be called. Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, - "AIDL is not suppored, and therefore Regions cannot be written to parcels."); + "AIDL is not suppored, and therefore Regions cannot be written to parcels.", + null /*data*/); return false; } diff --git a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java index e812f7f0031e..048990a21a75 100644 --- a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java @@ -118,7 +118,7 @@ public class SweepGradient_Delegate extends Gradient_Delegate { canvasMatrix = xform.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in SweepGradient", e); + "Unable to inverse matrix in SweepGradient", e, null /*data*/); canvasMatrix = new java.awt.geom.AffineTransform(); } @@ -127,7 +127,7 @@ public class SweepGradient_Delegate extends Gradient_Delegate { localMatrix = localMatrix.createInverse(); } catch (java.awt.geom.NoninvertibleTransformException e) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_INVERSE, - "Unable to inverse matrix in SweepGradient", e); + "Unable to inverse matrix in SweepGradient", e, null /*data*/); localMatrix = new java.awt.geom.AffineTransform(); } diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java index 44275d6ab928..00a2a57951dd 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java @@ -127,13 +127,13 @@ public final class Typeface_Delegate { /*package*/ static synchronized int nativeCreateFromAsset(AssetManager mgr, String path) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, - "Typeface.createFromAsset() is not supported.", null); + "Typeface.createFromAsset() is not supported.", null /*throwable*/, null /*data*/); return 0; } /*package*/ static synchronized int nativeCreateFromFile(String path) { Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, - "Typeface.createFromFile() is not supported.", null); + "Typeface.createFromFile() is not supported.", null /*throwable*/, null /*data*/); return 0; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java index 6e9f4d5ab76e..37576b4ec9c0 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java @@ -137,17 +137,17 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge { */ private final static LayoutLog sDefaultLog = new LayoutLog() { @Override - public void error(String tag, String message) { + public void error(String tag, String message, Object data) { System.err.println(message); } @Override - public void error(String tag, String message, Throwable throwable) { + public void error(String tag, String message, Throwable throwable, Object data) { System.err.println(message); } @Override - public void warning(String tag, String message) { + public void warning(String tag, String message, Object data) { System.out.println(message); } }; @@ -207,7 +207,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge { @Override public void onInvokeV(String signature, boolean isNative, Object caller) { sDefaultLog.error(null, "Missing Stub: " + signature + - (isNative ? " (native)" : "")); + (isNative ? " (native)" : ""), null /*data*/); if (debug.equalsIgnoreCase("throw")) { // Throwing this exception doesn't seem that useful. It breaks diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index f5fc036ef773..82e217a677ab 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -343,7 +343,7 @@ public final class BridgeContext extends Activity { } else if (set != null) { // null parser is ok // really this should not be happening since its instantiated in Bridge Bridge.getLog().error(LayoutLog.TAG_BROKEN, - "Parser is not a BridgeXmlBlockParser!"); + "Parser is not a BridgeXmlBlockParser!", null /*data*/); return null; } @@ -391,7 +391,8 @@ public final class BridgeContext extends Activity { } else { Bridge.getLog().error(null, String.format( - "Failed to find style '%s' in current theme", defStyleName)); + "Failed to find style '%s' in current theme", defStyleName), + null /*data*/); } } } @@ -726,7 +727,8 @@ public final class BridgeContext extends Activity { if ("+id".equals(resType) == false && "+android:id".equals(resType) == false) { //$NON-NLS-1$ //$NON-NLS-2$ Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, "Couldn't resolve resource @" + - (frameworkOnly ? "android:" : "") + resType + "/" + resName); + (frameworkOnly ? "android:" : "") + resType + "/" + resName, + new ResourceValue(resType, resName, frameworkOnly)); } return null; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java index 61ac81bee4a6..e95d295bb608 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java @@ -180,7 +180,7 @@ public final class BridgeInflater extends LayoutInflater { return inflate(bridgeParser, root); } catch (Exception e) { Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, - "Failed to parse file " + f.getAbsolutePath(), e); + "Failed to parse file " + f.getAbsolutePath(), e, null /*data*/); return null; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java index 8446a990a9c3..23d81a2b7ba7 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java @@ -143,7 +143,8 @@ public final class BridgeResources extends Resources { try { return ResourceHelper.getColor(value.getValue()); } catch (NumberFormatException e) { - Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e); + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e, + null /*data*/); return 0; } } @@ -176,13 +177,13 @@ public final class BridgeResources extends Resources { new BridgeXmlBlockParser(parser, mContext, resValue.isFramework())); } catch (XmlPullParserException e) { Bridge.getLog().error(LayoutLog.TAG_BROKEN, - "Failed to configure parser for " + value, e); + "Failed to configure parser for " + value, e, null /*data*/); // we'll return null below. } catch (Exception e) { // this is an error and not warning since the file existence is checked before // attempting to parse it. Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, - "Failed to parse file " + value, e); + "Failed to parse file " + value, e, null /*data*/); return null; } @@ -193,7 +194,8 @@ public final class BridgeResources extends Resources { return ColorStateList.valueOf(color); } catch (NumberFormatException e) { Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, - "Failed to convert " + value + " into a ColorStateList", e); + "Failed to convert " + value + " into a ColorStateList", e, + null /*data*/); return null; } } @@ -253,7 +255,7 @@ public final class BridgeResources extends Resources { } } catch (XmlPullParserException e) { Bridge.getLog().error(LayoutLog.TAG_BROKEN, - "Failed to configure parser for " + value.getValue(), e); + "Failed to configure parser for " + value.getValue(), e, null /*data*/); // we'll return null below. } catch (FileNotFoundException e) { // this shouldn't happen since we check above. @@ -288,7 +290,7 @@ public final class BridgeResources extends Resources { } } catch (XmlPullParserException e) { Bridge.getLog().error(LayoutLog.TAG_BROKEN, - "Failed to configure parser for " + value.getValue(), e); + "Failed to configure parser for " + value.getValue(), e, null /*data*/); // we'll return null below. } catch (FileNotFoundException e) { // this shouldn't happen since we check above. diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java index 42f05e381594..84bb4d1dd304 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java @@ -207,10 +207,10 @@ public final class BridgeTypedArray extends TypedArray { if (i != null) { result |= i.intValue(); } else { - Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format( - "Unknown constant \"%s\" in attribute \"%2$s\"", - keyword, mNames[index])); + "\"%s\" in attribute \"%2$s\" is not a valid value", + keyword, mNames[index]), null /*data*/); } } return result; @@ -238,10 +238,10 @@ public final class BridgeTypedArray extends TypedArray { try { return Float.parseFloat(s); } catch (NumberFormatException e) { - Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format( - "Unable to convert \"%s\" into a float in attribute \"%2$s\"", - s, mNames[index])); + "\"%s\" in attribute \"%2$s\" cannot be converted to float.", + s, mNames[index]), null /*data*/); // we'll return the default value below. } @@ -271,7 +271,7 @@ public final class BridgeTypedArray extends TypedArray { try { return ResourceHelper.getColor(s); } catch (NumberFormatException e) { - Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e); + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e, null /*data*/); // we'll return the default value below. } @@ -315,13 +315,13 @@ public final class BridgeTypedArray extends TypedArray { return colorStateList; } catch (XmlPullParserException e) { Bridge.getLog().error(LayoutLog.TAG_BROKEN, - "Failed to configure parser for " + value, e); + "Failed to configure parser for " + value, e, null /*data*/); return null; } catch (Exception e) { // this is an error and not warning since the file existence is checked before // attempting to parse it. Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, - "Failed to parse file " + value, e); + "Failed to parse file " + value, e, null /*data*/); return null; } @@ -331,7 +331,7 @@ public final class BridgeTypedArray extends TypedArray { int color = ResourceHelper.getColor(value); return ColorStateList.valueOf(color); } catch (NumberFormatException e) { - Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e); + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e, null /*data*/); } assert false; @@ -360,10 +360,10 @@ public final class BridgeTypedArray extends TypedArray { try { return Integer.parseInt(s); } catch (NumberFormatException e) { - Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format( - "Unable to convert \"%s\" into a integer in attribute \"%2$s\"", - s, mNames[index])); + "\"%s\" in attribute \"%2$s\" cannont be converted to an integer.", + s, mNames[index]), null /*data*/); // The default value is returned below. } @@ -410,10 +410,10 @@ public final class BridgeTypedArray extends TypedArray { } // looks like we were unable to resolve the dimension value - Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format( - "Unable to resolve dimension value \"%1$s\" in attribute \"%2$s\"", - s, mNames[index])); + "\"%1$s\" in attribute \"%2$s\" is not a valid format.", + s, mNames[index]), null /*data*/); assert false; @@ -542,10 +542,10 @@ public final class BridgeTypedArray extends TypedArray { } // looks like we were unable to resolve the fraction value - Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format( - "Unable to resolve fraction value \"%1$s\" in attribute \"%2$s\"", - value, mNames[index])); + "\"%1$s\" in attribute \"%2$s\" cannont be converted to a fraction.", + value, mNames[index]), null /*data*/); assert false; @@ -656,7 +656,8 @@ public final class BridgeTypedArray extends TypedArray { Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, String.format( - "Unable to resolve id \"%1$s\" for attribute \"%2$s\"", value, mNames[index])); + "Unable to resolve id \"%1$s\" for attribute \"%2$s\"", value, mNames[index]), + resValue); assert false; @@ -685,21 +686,7 @@ public final class BridgeTypedArray extends TypedArray { return null; } - Drawable d = ResourceHelper.getDrawable(value, mContext, mResourceData[index].isFramework()); - - if (d != null) { - return d; - } - - // looks like we were unable to resolve the drawable - Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, - String.format( - "Unable to resolve drawable \"%1$s\" in attribute \"%2$s\"", stringValue, - mNames[index])); - - assert false; - - return null; + return ResourceHelper.getDrawable(value, mContext, mResourceData[index].isFramework()); } @@ -724,10 +711,10 @@ public final class BridgeTypedArray extends TypedArray { return new CharSequence[] { value }; } - Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE, + Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format( String.format("Unknown value for getTextArray(%d) => %s", //DEBUG - index, mResourceData[index].getName()))); + index, mResourceData[index].getName())), null /*data*/); return null; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java index c4ebb8a9e682..21d6b1a67505 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java @@ -730,7 +730,7 @@ public class GcSnapshot { } else { Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, shaderDelegate.getSupportMessage(), - null); + null /*throwable*/, null /*data*/); } } @@ -764,7 +764,7 @@ public class GcSnapshot { } else { Bridge.getLog().fidelityWarning(LayoutLog.TAG_XFERMODE, xfermodeDelegate.getSupportMessage(), - null); + null /*throwable*/, null /*data*/); } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index 566d4d4a87f8..2439791f0097 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -1046,7 +1046,8 @@ public class RenderSessionImpl { assert false; mParams.getLog().error(LayoutLog.TAG_RESOURCES_RESOLVE, - String.format("Unable to resolve parent style name: %s", parentName)); + String.format("Unable to resolve parent style name: %s", parentName), + null /*data*/); return null; } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java index 4e331d1f9368..475b4be25314 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java @@ -166,7 +166,7 @@ public final class ResourceHelper { } catch (IOException e) { // failed to read the file, we'll return null below. Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, - "Failed lot load " + file.getAbsolutePath(), e); + "Failed lot load " + file.getAbsolutePath(), e, null /*data*/); } } @@ -197,11 +197,12 @@ public final class ResourceHelper { } catch (Exception e) { // this is an error and not warning since the file existence is checked before // attempting to parse it. - Bridge.getLog().error(null, "Failed to parse file " + value, e); + Bridge.getLog().error(null, "Failed to parse file " + value, e, null /*data*/); } } else { Bridge.getLog().error(LayoutLog.TAG_BROKEN, - String.format("File %s does not exist (or is not a file)", stringValue)); + String.format("File %s does not exist (or is not a file)", stringValue), + null /*data*/); } return null; @@ -228,7 +229,7 @@ public final class ResourceHelper { } catch (IOException e) { // we'll return null below Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ, - "Failed lot load " + bmpFile.getAbsolutePath(), e); + "Failed lot load " + bmpFile.getAbsolutePath(), e, null /*data*/); } } else { // attempt to get a color from the value @@ -238,7 +239,8 @@ public final class ResourceHelper { } catch (NumberFormatException e) { // we'll return null below. Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, - "Failed to convert " + stringValue + " into a drawable", e); + "Failed to convert " + stringValue + " into a drawable", e, + null /*data*/); } } } |