summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ContextImpl.java6
-rw-r--r--core/java/android/app/MediaRouteActionProvider.java15
-rw-r--r--core/java/android/app/MediaRouteButton.java17
-rw-r--r--core/java/android/content/Context.java13
-rw-r--r--core/java/android/text/Layout.java1
-rw-r--r--core/java/android/text/style/StyleSpan.java1
-rw-r--r--core/java/android/text/style/TextAppearanceSpan.java1
-rw-r--r--core/java/android/text/style/TypefaceSpan.java1
-rw-r--r--core/java/android/view/Choreographer.java33
-rw-r--r--core/java/android/view/ViewRootImpl.java25
-rw-r--r--core/java/android/widget/Switch.java4
-rw-r--r--core/java/android/widget/TextView.java4
12 files changed, 96 insertions, 25 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 4c35a8c..b902550 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -55,6 +55,7 @@ import android.location.ICountryDetector;
import android.location.ILocationManager;
import android.location.LocationManager;
import android.media.AudioManager;
+import android.media.MediaRouter;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.INetworkPolicyManager;
@@ -288,6 +289,11 @@ class ContextImpl extends Context {
return new AudioManager(ctx);
}});
+ registerService(MEDIA_ROUTER_SERVICE, new ServiceFetcher() {
+ public Object createService(ContextImpl ctx) {
+ return new MediaRouter(ctx);
+ }});
+
registerService(CLIPBOARD_SERVICE, new ServiceFetcher() {
public Object createService(ContextImpl ctx) {
return new ClipboardManager(ctx.getOuterContext(),
diff --git a/core/java/android/app/MediaRouteActionProvider.java b/core/java/android/app/MediaRouteActionProvider.java
index 301b125..5fe08ec 100644
--- a/core/java/android/app/MediaRouteActionProvider.java
+++ b/core/java/android/app/MediaRouteActionProvider.java
@@ -33,11 +33,12 @@ public class MediaRouteActionProvider extends ActionProvider {
private MediaRouteButton mView;
private int mRouteTypes;
private final RouterCallback mRouterCallback = new RouterCallback();
+ private View.OnClickListener mExtendedSettingsListener;
public MediaRouteActionProvider(Context context) {
super(context);
mContext = context;
- mRouter = MediaRouter.forApplication(context);
+ mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
// Start with live audio by default.
// TODO Update this when new route types are added; segment by API level
@@ -76,6 +77,7 @@ public class MediaRouteActionProvider extends ActionProvider {
mView = new MediaRouteButton(mContext);
mMenuItem.setVisible(mRouter.getRouteCount() > 1);
mView.setRouteTypes(mRouteTypes);
+ mView.setExtendedSettingsClickListener(mExtendedSettingsListener);
return mView;
}
@@ -85,14 +87,21 @@ public class MediaRouteActionProvider extends ActionProvider {
return true;
}
+ public void setExtendedSettingsClickListener(View.OnClickListener listener) {
+ mExtendedSettingsListener = listener;
+ if (mView != null) {
+ mView.setExtendedSettingsClickListener(listener);
+ }
+ }
+
private class RouterCallback extends MediaRouter.SimpleCallback {
@Override
- public void onRouteAdded(int type, RouteInfo info) {
+ public void onRouteAdded(MediaRouter router, RouteInfo info) {
mMenuItem.setVisible(mRouter.getRouteCount() > 1);
}
@Override
- public void onRouteRemoved(int type, RouteInfo info) {
+ public void onRouteRemoved(MediaRouter router, RouteInfo info) {
mMenuItem.setVisible(mRouter.getRouteCount() > 1);
}
}
diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java
index 3aabd5d..385241c 100644
--- a/core/java/android/app/MediaRouteButton.java
+++ b/core/java/android/app/MediaRouteButton.java
@@ -43,6 +43,8 @@ public class MediaRouteButton extends View {
private int mMinWidth;
private int mMinHeight;
+ private OnClickListener mExtendedSettingsClickListener;
+
private static final int[] ACTIVATED_STATE_SET = {
R.attr.state_activated
};
@@ -58,7 +60,7 @@ public class MediaRouteButton extends View {
public MediaRouteButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- mRouter = MediaRouter.forApplication(context);
+ mRouter = (MediaRouter)context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
TypedArray a = context.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.MediaRouteButton, defStyleAttr, 0);
@@ -260,24 +262,29 @@ public class MediaRouteButton extends View {
mRemoteIndicator.draw(canvas);
}
+ public void setExtendedSettingsClickListener(OnClickListener listener) {
+ // TODO: if dialog is already open, propagate so that it updates live.
+ mExtendedSettingsClickListener = listener;
+ }
+
private class MediaRouteCallback extends MediaRouter.SimpleCallback {
@Override
- public void onRouteSelected(int type, RouteInfo info) {
+ public void onRouteSelected(MediaRouter router, int type, RouteInfo info) {
updateRemoteIndicator();
}
@Override
- public void onRouteUnselected(int type, RouteInfo info) {
+ public void onRouteUnselected(MediaRouter router, int type, RouteInfo info) {
updateRemoteIndicator();
}
@Override
- public void onRouteAdded(int type, RouteInfo info) {
+ public void onRouteAdded(MediaRouter router, RouteInfo info) {
updateRouteCount();
}
@Override
- public void onRouteRemoved(int type, RouteInfo info) {
+ public void onRouteRemoved(MediaRouter router, RouteInfo info) {
updateRouteCount();
}
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 4c169d3..7588cda 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -1528,6 +1528,8 @@ public abstract class Context {
* @see android.net.wifi.WifiManager
* @see #AUDIO_SERVICE
* @see android.media.AudioManager
+ * @see #MEDIA_ROUTER_SERVICE
+ * @see android.media.MediaRouter
* @see #TELEPHONY_SERVICE
* @see android.telephony.TelephonyManager
* @see #INPUT_METHOD_SERVICE
@@ -1778,7 +1780,6 @@ public abstract class Context {
*/
public static final String NSD_SERVICE = "servicediscovery";
-
/**
* Use with {@link #getSystemService} to retrieve a
* {@link android.media.AudioManager} for handling management of volume,
@@ -1791,6 +1792,16 @@ public abstract class Context {
/**
* Use with {@link #getSystemService} to retrieve a
+ * {@link android.media.MediaRouter} for controlling and managing
+ * routing of media.
+ *
+ * @see #getSystemService
+ * @see android.media.MediaRouter
+ */
+ public static final String MEDIA_ROUTER_SERVICE = "media_router";
+
+ /**
+ * Use with {@link #getSystemService} to retrieve a
* {@link android.telephony.TelephonyManager} for handling management the
* telephony features of the device.
*
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index c453a5d..12f16fd 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -456,6 +456,7 @@ public abstract class Layout {
final int top = Math.max(dtop, 0);
final int bottom = Math.min(getLineTop(getLineCount()), dbottom);
+ if (top >= bottom) return TextUtils.packRangeInLong(0, -1);
return TextUtils.packRangeInLong(getLineForVertical(top), getLineForVertical(bottom));
}
diff --git a/core/java/android/text/style/StyleSpan.java b/core/java/android/text/style/StyleSpan.java
index deed737..8e6147c 100644
--- a/core/java/android/text/style/StyleSpan.java
+++ b/core/java/android/text/style/StyleSpan.java
@@ -98,7 +98,6 @@ public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {
}
int fake = want & ~tf.getStyle();
- fake |= tf.getStyle() & Typeface.BOLD;
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
diff --git a/core/java/android/text/style/TextAppearanceSpan.java b/core/java/android/text/style/TextAppearanceSpan.java
index abd02cf..ecbf4bc 100644
--- a/core/java/android/text/style/TextAppearanceSpan.java
+++ b/core/java/android/text/style/TextAppearanceSpan.java
@@ -235,7 +235,6 @@ public class TextAppearanceSpan extends MetricAffectingSpan implements Parcelabl
}
int fake = style & ~tf.getStyle();
- fake |= tf.getStyle() & Typeface.BOLD;
if ((fake & Typeface.BOLD) != 0) {
ds.setFakeBoldText(true);
diff --git a/core/java/android/text/style/TypefaceSpan.java b/core/java/android/text/style/TypefaceSpan.java
index 3d74ed0..f194060 100644
--- a/core/java/android/text/style/TypefaceSpan.java
+++ b/core/java/android/text/style/TypefaceSpan.java
@@ -82,7 +82,6 @@ public class TypefaceSpan extends MetricAffectingSpan implements ParcelableSpan
Typeface tf = Typeface.create(family, oldStyle);
int fake = oldStyle & ~tf.getStyle();
- fake |= tf.getStyle() & Typeface.BOLD;
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java
index aaa081c..78dc86f 100644
--- a/core/java/android/view/Choreographer.java
+++ b/core/java/android/view/Choreographer.java
@@ -103,6 +103,11 @@ public final class Choreographer {
private static final boolean USE_FRAME_TIME = SystemProperties.getBoolean(
"debug.choreographer.frametime", true);
+ // Set a limit to warn about skipped frames.
+ // Skipped frames imply jank.
+ private static final int SKIPPED_FRAME_WARNING_LIMIT = SystemProperties.getInt(
+ "debug.choreographer.skipwarning", 30);
+
private static final long NANOS_PER_MS = 1000000;
private static final int MSG_DO_FRAME = 0;
@@ -486,13 +491,18 @@ public final class Choreographer {
startNanos = System.nanoTime();
final long jitterNanos = startNanos - frameTimeNanos;
if (jitterNanos >= mFrameIntervalNanos) {
+ final long skippedFrames = jitterNanos / mFrameIntervalNanos;
+ if (skippedFrames >= SKIPPED_FRAME_WARNING_LIMIT) {
+ Log.i(TAG, "Skipped " + skippedFrames + " frames! "
+ + "The application may be doing too much work on its main thread.");
+ }
final long lastFrameOffset = jitterNanos % mFrameIntervalNanos;
if (DEBUG) {
Log.d(TAG, "Missed vsync by " + (jitterNanos * 0.000001f) + " ms "
+ "which is more than the frame interval of "
+ (mFrameIntervalNanos * 0.000001f) + " ms! "
- + "Setting frame time to " + (lastFrameOffset * 0.000001f)
- + " ms in the past.");
+ + "Skipping " + skippedFrames + " frames and setting frame "
+ + "time to " + (lastFrameOffset * 0.000001f) + " ms in the past.");
}
frameTimeNanos = startNanos - lastFrameOffset;
}
@@ -500,7 +510,7 @@ public final class Choreographer {
if (frameTimeNanos < mLastFrameTimeNanos) {
if (DEBUG) {
Log.d(TAG, "Frame time appears to be going backwards. May be due to a "
- + "previously skipped frame. Waiting for next vsync");
+ + "previously skipped frame. Waiting for next vsync.");
}
scheduleVsyncLocked();
return;
@@ -658,6 +668,7 @@ public final class Choreographer {
private final class FrameDisplayEventReceiver extends DisplayEventReceiver
implements Runnable {
+ private boolean mHavePendingVsync;
private long mTimestampNanos;
private int mFrame;
@@ -672,6 +683,21 @@ public final class Choreographer {
// the message queue. If there are no messages in the queue with timestamps
// earlier than the frame time, then the vsync event will be processed immediately.
// Otherwise, messages that predate the vsync event will be handled first.
+ long now = System.nanoTime();
+ if (timestampNanos > now) {
+ Log.w(TAG, "Frame time is " + ((timestampNanos - now) * 0.000001f)
+ + " ms in the future! Check that graphics HAL is generating vsync "
+ + "timestamps using the correct timebase.");
+ timestampNanos = now;
+ }
+
+ if (mHavePendingVsync) {
+ Log.w(TAG, "Already have a pending vsync event. There should only be "
+ + "one at a time.");
+ } else {
+ mHavePendingVsync = true;
+ }
+
mTimestampNanos = timestampNanos;
mFrame = frame;
Message msg = Message.obtain(mHandler, this);
@@ -681,6 +707,7 @@ public final class Choreographer {
@Override
public void run() {
+ mHavePendingVsync = false;
doFrame(mTimestampNanos, mFrame);
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7eeb6d0..cdc51d1 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -229,6 +229,7 @@ public final class ViewRootImpl implements ViewParent,
boolean mWindowsAnimating;
boolean mIsDrawing;
int mLastSystemUiVisibility;
+ int mClientWindowLayoutFlags;
// Pool of queued input events.
private static final int MAX_QUEUED_INPUT_EVENT_POOL_SIZE = 10;
@@ -485,6 +486,8 @@ public final class ViewRootImpl implements ViewParent,
mFallbackEventHandler.setView(view);
mWindowAttributes.copyFrom(attrs);
attrs = mWindowAttributes;
+ // Keep track of the actual window flags supplied by the client.
+ mClientWindowLayoutFlags = attrs.flags;
setAccessibilityFocusedHost(null);
@@ -760,6 +763,8 @@ public final class ViewRootImpl implements ViewParent,
void setLayoutParams(WindowManager.LayoutParams attrs, boolean newView) {
synchronized (this) {
int oldSoftInputMode = mWindowAttributes.softInputMode;
+ // Keep track of the actual window flags supplied by the client.
+ mClientWindowLayoutFlags = attrs.flags;
// preserve compatible window flag if exists.
int compatibleWindowFlag =
mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
@@ -768,7 +773,9 @@ public final class ViewRootImpl implements ViewParent,
attrs.subtreeSystemUiVisibility = mWindowAttributes.subtreeSystemUiVisibility;
mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
mWindowAttributes.flags |= compatibleWindowFlag;
-
+
+ applyKeepScreenOnFlag(mWindowAttributes);
+
if (newView) {
mSoftInputMode = attrs.softInputMode;
requestLayout();
@@ -1000,6 +1007,18 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ private void applyKeepScreenOnFlag(WindowManager.LayoutParams params) {
+ // Update window's global keep screen on flag: if a view has requested
+ // that the screen be kept on, then it is always set; otherwise, it is
+ // set to whatever the client last requested for the global state.
+ if (mAttachInfo.mKeepScreenOn) {
+ params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ } else {
+ params.flags = (params.flags&~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ | (mClientWindowLayoutFlags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
+ }
+
private boolean collectViewAttributes() {
final View.AttachInfo attachInfo = mAttachInfo;
if (attachInfo.mRecomputeGlobalAttributes) {
@@ -1017,9 +1036,7 @@ public final class ViewRootImpl implements ViewParent,
|| attachInfo.mSystemUiVisibility != oldVis
|| attachInfo.mHasSystemUiListeners != oldHasSystemUiListeners) {
WindowManager.LayoutParams params = mWindowAttributes;
- if (attachInfo.mKeepScreenOn) {
- params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
- }
+ applyKeepScreenOnFlag(params);
params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
mView.dispatchWindowSystemUiVisiblityChanged(attachInfo.mSystemUiVisibility);
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index 39bc7c2..471f259 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -259,12 +259,10 @@ public class Switch extends CompoundButton {
// now compute what (if any) algorithmic styling is needed
int typefaceStyle = tf != null ? tf.getStyle() : 0;
int need = style & ~typefaceStyle;
- need |= typefaceStyle & Typeface.BOLD;
mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0);
mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
} else {
- int typefaceStyle = tf != null ? tf.getStyle() : 0;
- mTextPaint.setFakeBoldText((typefaceStyle & Typeface.BOLD) != 0);
+ mTextPaint.setFakeBoldText(false);
mTextPaint.setTextSkewX(0);
setSwitchTypeface(tf);
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 464a527..01617da 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -1237,12 +1237,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// now compute what (if any) algorithmic styling is needed
int typefaceStyle = tf != null ? tf.getStyle() : 0;
int need = style & ~typefaceStyle;
- need |= typefaceStyle & Typeface.BOLD; // keep bold in
mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0);
mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
} else {
- int typefaceStyle = tf != null ? tf.getStyle() : 0;
- mTextPaint.setFakeBoldText((typefaceStyle & Typeface.BOLD) != 0);
+ mTextPaint.setFakeBoldText(false);
mTextPaint.setTextSkewX(0);
setTypeface(tf);
}