diff options
Diffstat (limited to 'core/java')
19 files changed, 293 insertions, 147 deletions
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java index c858e3c..b644dd1 100644 --- a/core/java/android/accessibilityservice/AccessibilityService.java +++ b/core/java/android/accessibilityservice/AccessibilityService.java @@ -244,64 +244,54 @@ public abstract class AccessibilityService extends Service { public static final int GESTURE_SWIPE_DOWN_AND_UP = 8; /** - * The user has performed a clockwise circle gesture on the touch screen. - */ - public static final int GESTURE_CLOCKWISE_CIRCLE = 9; - - /** - * The user has performed a counter clockwise circle gesture on the touch screen. - */ - public static final int GESTURE_COUNTER_CLOCKWISE_CIRCLE = 10; - - /** * The user has performed a left and up gesture on the touch screen. */ - public static final int GESTURE_SWIPE_LEFT_AND_UP = 11; + public static final int GESTURE_SWIPE_LEFT_AND_UP = 9; /** * The user has performed a left and down gesture on the touch screen. */ - public static final int GESTURE_SWIPE_LEFT_AND_DOWN = 12; + public static final int GESTURE_SWIPE_LEFT_AND_DOWN = 10; /** * The user has performed a right and up gesture on the touch screen. */ - public static final int GESTURE_SWIPE_RIGHT_AND_UP = 13; + public static final int GESTURE_SWIPE_RIGHT_AND_UP = 11; /** * The user has performed a right and down gesture on the touch screen. */ - public static final int GESTURE_SWIPE_RIGHT_AND_DOWN = 14; + public static final int GESTURE_SWIPE_RIGHT_AND_DOWN = 12; /** * The user has performed an up and left gesture on the touch screen. */ - public static final int GESTURE_SWIPE_UP_AND_LEFT = 15; + public static final int GESTURE_SWIPE_UP_AND_LEFT = 13; /** * The user has performed an up and right gesture on the touch screen. */ - public static final int GESTURE_SWIPE_UP_AND_RIGHT = 16; + public static final int GESTURE_SWIPE_UP_AND_RIGHT = 14; /** * The user has performed an down and left gesture on the touch screen. */ - public static final int GESTURE_SWIPE_DOWN_AND_LEFT = 17; + public static final int GESTURE_SWIPE_DOWN_AND_LEFT = 15; /** * The user has performed an down and right gesture on the touch screen. */ - public static final int GESTURE_SWIPE_DOWN_AND_RIGHT = 18; + public static final int GESTURE_SWIPE_DOWN_AND_RIGHT = 16; /** * The user has performed a two finger tap gesture on the touch screen. */ - public static final int GESTURE_TWO_FINGER_TAP = 19; + public static final int GESTURE_TWO_FINGER_TAP = 17; /** * The user has performed a two finger long press gesture on the touch screen. */ - public static final int GESTURE_TWO_FINGER_LONG_PRESS = 20; + public static final int GESTURE_TWO_FINGER_LONG_PRESS = 18; /** * The {@link Intent} that must be declared as handled by the service. diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 3ae286f..8d6a496 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -2742,6 +2742,10 @@ public class Activity extends ContextThemeWrapper * may choose to override this method to construct the desired task stack in a different * way.</p> * + * <p>This method will be invoked by the default implementation of {@link #onNavigateUp()} + * if {@link #shouldUpRecreateTask(Intent)} returns true when supplied with the intent + * returned by {@link #getParentActivityIntent()}.</p> + * * <p>Applications that wish to supply extra Intent parameters to the parent stack defined * by the manifest should override {@link #onPrepareNavigateUpTaskStack(TaskStackBuilder)}.</p> * diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 1a46430..b55ee26 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -3843,7 +3843,7 @@ public final class ActivityThread { windowManager.endTrimMemory(); } - private void setupGraphicsSupport(LoadedApk info) { + private void setupGraphicsSupport(LoadedApk info, File cacheDir) { if (Process.isIsolated()) { // Isolated processes aren't going to do UI. return; @@ -3855,11 +3855,8 @@ public final class ActivityThread { // If there are several packages in this application we won't // initialize the graphics disk caches if (packages != null && packages.length == 1) { - ContextImpl appContext = new ContextImpl(); - appContext.init(info, null, this); - - HardwareRenderer.setupDiskCache(appContext.getCacheDir()); - RenderScript.setupDiskCache(appContext.getCacheDir()); + HardwareRenderer.setupDiskCache(cacheDir); + RenderScript.setupDiskCache(cacheDir); } } catch (RemoteException e) { // Ignore @@ -3925,8 +3922,15 @@ public final class ActivityThread { data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo); - setupGraphicsSupport(data.info); - + final ContextImpl appContext = new ContextImpl(); + appContext.init(data.info, null, this); + final File cacheDir = appContext.getCacheDir(); + + // Provide a usable directory for temporary files + System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath()); + + setupGraphicsSupport(data.info, cacheDir); + /** * For system applications on userdebug/eng builds, log stack * traces of disk and network access to dropbox for analysis. @@ -4003,8 +4007,6 @@ public final class ActivityThread { } if (data.instrumentationName != null) { - ContextImpl appContext = new ContextImpl(); - appContext.init(data.info, null, this); InstrumentationInfo ii = null; try { ii = appContext.getPackageManager(). diff --git a/core/java/android/app/DatePickerDialog.java b/core/java/android/app/DatePickerDialog.java index c62e5cf..3f0b4d4 100644 --- a/core/java/android/app/DatePickerDialog.java +++ b/core/java/android/app/DatePickerDialog.java @@ -16,17 +16,20 @@ package android.app; -import com.android.internal.R; - import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; +import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.widget.DatePicker; import android.widget.DatePicker.OnDateChangedListener; +import com.android.internal.R; + +import java.util.Calendar; + /** * A simple dialog containing an {@link android.widget.DatePicker}. * @@ -42,6 +45,9 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, private final DatePicker mDatePicker; private final OnDateSetListener mCallBack; + private final Calendar mCalendar; + + private boolean mTitleNeedsUpdate = true; /** * The callback used to indicate the user is done filling in the date. @@ -91,10 +97,11 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, mCallBack = callBack; + mCalendar = Calendar.getInstance(); + Context themeContext = getContext(); setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_done), this); setIcon(0); - setTitle(R.string.date_picker_dialog_title); LayoutInflater inflater = (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -102,6 +109,7 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, setView(view); mDatePicker = (DatePicker) view.findViewById(R.id.datePicker); mDatePicker.init(year, monthOfYear, dayOfMonth, this); + updateTitle(year, monthOfYear, dayOfMonth); } public void onClick(DialogInterface dialog, int which) { @@ -110,7 +118,8 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, public void onDateChanged(DatePicker view, int year, int month, int day) { - mDatePicker.init(year, month, day, null); + mDatePicker.init(year, month, day, this); + updateTitle(year, month, day); } /** @@ -147,6 +156,28 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, super.onStop(); } + private void updateTitle(int year, int month, int day) { + if (!mDatePicker.getCalendarViewShown()) { + mCalendar.set(Calendar.YEAR, year); + mCalendar.set(Calendar.MONTH, month); + mCalendar.set(Calendar.DAY_OF_MONTH, day); + String title = DateUtils.formatDateTime(mContext, + mCalendar.getTimeInMillis(), + DateUtils.FORMAT_SHOW_DATE + | DateUtils.FORMAT_SHOW_WEEKDAY + | DateUtils.FORMAT_SHOW_YEAR + | DateUtils.FORMAT_ABBREV_MONTH + | DateUtils.FORMAT_ABBREV_WEEKDAY); + setTitle(title); + mTitleNeedsUpdate = true; + } else { + if (mTitleNeedsUpdate) { + mTitleNeedsUpdate = false; + setTitle(R.string.date_picker_dialog_title); + } + } + } + @Override public Bundle onSaveInstanceState() { Bundle state = super.onSaveInstanceState(); diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index 0713127..93f732c 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -1155,7 +1155,7 @@ public class DownloadManager { validateArgumentIsNonEmpty("description", description); validateArgumentIsNonEmpty("path", path); validateArgumentIsNonEmpty("mimeType", mimeType); - if (length <= 0) { + if (length < 0) { throw new IllegalArgumentException(" invalid value for param: totalBytes"); } diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 69689c9..8f4efab 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -888,7 +888,7 @@ public class Notification implements Parcelable * .setContentText(subject) * .setSmallIcon(R.drawable.new_mail) * .setLargeIcon(aBitmap) - * .getNotification(); + * .build(); * </pre> */ public static class Builder { @@ -925,6 +925,7 @@ public class Notification implements Parcelable private int mPriority; private ArrayList<Action> mActions = new ArrayList<Action>(3); private boolean mUseChronometer; + private Style mStyle; /** * Constructs a new Builder with the defaults: @@ -1305,7 +1306,7 @@ public class Notification implements Parcelable * Add metadata to this notification. * * A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's - * current contents are copied into the Notification each time {@link #getNotification()} is + * current contents are copied into the Notification each time {@link #build()} is * called. * * @see Notification#extras @@ -1329,6 +1330,19 @@ public class Notification implements Parcelable return this; } + /** + * Add a rich notification style to be applied at build time. + * + * @param style Object responsible for modifying the notification style. + */ + public Builder setStyle(Style style) { + if (mStyle != style) { + mStyle = style; + mStyle.setBuilder(this); + } + return this; + } + private void setFlag(int mask, boolean value) { if (value) { mFlags |= mask; @@ -1464,10 +1478,9 @@ public class Notification implements Parcelable } /** - * Combine all of the options that have been set and return a new {@link Notification} - * object. + * Apply the unstyled operations and return a new {@link Notification} object. */ - public Notification getNotification() { + private Notification buildUnstyled() { Notification n = new Notification(); n.when = mWhen; n.icon = mSmallIcon; @@ -1509,6 +1522,49 @@ public class Notification implements Parcelable } return n; } + + /** + * @deprecated Use {@link #build()} instead. + */ + @Deprecated + public Notification getNotification() { + return build(); + } + + /** + * Combine all of the options that have been set and return a new {@link Notification} + * object. + */ + public Notification build() { + if (mStyle != null) { + return mStyle.build(); + } else { + return buildUnstyled(); + } + } + } + + + /** + * An object that can apply a rich notification style to a {@link Notification.Builder} + * object. + */ + public static class Style { + protected Builder mBuilder; + + public void setBuilder(Builder builder) { + if (mBuilder != builder) { + mBuilder = builder; + mBuilder.setStyle(this); + } + } + + public Notification build() { + if (mBuilder == null) { + throw new IllegalArgumentException("Style requires a valid Builder object"); + } + return mBuilder.buildUnstyled(); + } } /** @@ -1528,12 +1584,14 @@ public class Notification implements Parcelable * * @see Notification#bigContentView */ - public static class BigPictureStyle { - private Builder mBuilder; + public static class BigPictureStyle extends Style { private Bitmap mPicture; + public BigPictureStyle() { + } + public BigPictureStyle(Builder builder) { - mBuilder = builder; + setBuilder(builder); } public BigPictureStyle bigPicture(Bitmap b) { @@ -1549,8 +1607,12 @@ public class Notification implements Parcelable return contentView; } + @Override public Notification build() { - Notification wip = mBuilder.getNotification(); + if (mBuilder == null) { + throw new IllegalArgumentException("Style requires a valid Builder object"); + } + Notification wip = mBuilder.buildUnstyled(); wip.bigContentView = makeBigContentView(); return wip; } @@ -1573,12 +1635,14 @@ public class Notification implements Parcelable * * @see Notification#bigContentView */ - public static class BigTextStyle { - private Builder mBuilder; + public static class BigTextStyle extends Style { private CharSequence mBigText; + public BigTextStyle() { + } + public BigTextStyle(Builder builder) { - mBuilder = builder; + setBuilder(builder); } public BigTextStyle bigText(CharSequence cs) { @@ -1587,17 +1651,21 @@ public class Notification implements Parcelable } private RemoteViews makeBigContentView() { - RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(R.layout.notification_template_big_text); - + int bigTextId = R.layout.notification_template_big_text; + RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(bigTextId); contentView.setTextViewText(R.id.big_text, mBigText); contentView.setViewVisibility(R.id.big_text, View.VISIBLE); - contentView.setTextViewText(R.id.text, ""); // XXX: what do do with this spot? + contentView.setViewVisibility(R.id.text2, View.GONE); return contentView; } + @Override public Notification build() { - Notification wip = mBuilder.getNotification(); + if (mBuilder == null) { + throw new IllegalArgumentException("Style requires a valid Builder object"); + } + Notification wip = mBuilder.buildUnstyled(); wip.bigContentView = makeBigContentView(); return wip; } @@ -1608,7 +1676,7 @@ public class Notification implements Parcelable * * This class is a "rebuilder": It consumes a Builder object and modifies its behavior, like so: * <pre class="prettyprint"> - * Notification noti = new Notification.DigestStyle( + * Notification noti = new Notification.InboxStyle( * new Notification.Builder() * .setContentTitle("New mail from " + sender.toString()) * .setContentText(subject) @@ -1621,12 +1689,14 @@ public class Notification implements Parcelable * * @see Notification#bigContentView */ - public static class InboxStyle { - private Builder mBuilder; + public static class InboxStyle extends Style { private ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>(5); + public InboxStyle() { + } + public InboxStyle(Builder builder) { - mBuilder = builder; + setBuilder(builder); } public InboxStyle addLine(CharSequence cs) { @@ -1652,8 +1722,12 @@ public class Notification implements Parcelable return contentView; } + @Override public Notification build() { - Notification wip = mBuilder.getNotification(); + if (mBuilder == null) { + throw new IllegalArgumentException("Style requires a valid Builder object"); + } + Notification wip = mBuilder.buildUnstyled(); wip.bigContentView = makeBigContentView(); return wip; } diff --git a/core/java/android/server/BluetoothAdapterStateMachine.java b/core/java/android/server/BluetoothAdapterStateMachine.java index 7711caa..f543de9 100644 --- a/core/java/android/server/BluetoothAdapterStateMachine.java +++ b/core/java/android/server/BluetoothAdapterStateMachine.java @@ -441,9 +441,10 @@ final class BluetoothAdapterStateMachine extends StateMachine { if (mPublicState == BluetoothAdapter.STATE_TURNING_OFF) { transitionTo(mHotOff); finishSwitchingOff(); - if (!mContext.getResources().getBoolean - (com.android.internal.R.bool.config_bluetooth_adapter_quick_switch)) { - deferMessage(obtainMessage(TURN_COLD)); + deferMessage(obtainMessage(TURN_COLD)); + if (mContext.getResources().getBoolean + (com.android.internal.R.bool.config_bluetooth_adapter_quick_switch)) { + deferMessage(obtainMessage(TURN_HOT)); } } } else { @@ -612,9 +613,10 @@ final class BluetoothAdapterStateMachine extends StateMachine { removeMessages(POWER_DOWN_TIMEOUT); if (!((Boolean) message.obj)) { transitionTo(mHotOff); - if (!mContext.getResources().getBoolean + deferMessage(obtainMessage(TURN_COLD)); + if (mContext.getResources().getBoolean (com.android.internal.R.bool.config_bluetooth_adapter_quick_switch)) { - deferMessage(obtainMessage(TURN_COLD)); + deferMessage(obtainMessage(TURN_HOT)); } } else { if (!isTurningOn) { diff --git a/core/java/android/text/TextDirectionHeuristic.java b/core/java/android/text/TextDirectionHeuristic.java index 0bf64e4..513e11c 100644 --- a/core/java/android/text/TextDirectionHeuristic.java +++ b/core/java/android/text/TextDirectionHeuristic.java @@ -22,5 +22,5 @@ package android.text; * @hide */ public interface TextDirectionHeuristic { - /** @hide */ boolean isRtl(char[] text, int start, int count); + boolean isRtl(char[] text, int start, int count); } diff --git a/core/java/android/text/TextDirectionHeuristics.java b/core/java/android/text/TextDirectionHeuristics.java index 6ca6161..bbaa173 100644 --- a/core/java/android/text/TextDirectionHeuristics.java +++ b/core/java/android/text/TextDirectionHeuristics.java @@ -22,6 +22,8 @@ import android.view.View; /** * Some objects that implement TextDirectionHeuristic. + * + * @hide */ public class TextDirectionHeuristics { diff --git a/core/java/android/view/ActionMode.java b/core/java/android/view/ActionMode.java index 0ba5fdb..a359952 100644 --- a/core/java/android/view/ActionMode.java +++ b/core/java/android/view/ActionMode.java @@ -30,6 +30,7 @@ package android.view; */ public abstract class ActionMode { private Object mTag; + private boolean mTitleOptionalHint; /** * Set a tag object associated with this ActionMode. @@ -119,6 +120,18 @@ public abstract class ActionMode { * @param titleOptional true if the title only presents optional information. */ public void setTitleOptionalHint(boolean titleOptional) { + mTitleOptionalHint = titleOptional; + } + + /** + * @return true if this action mode has been given a hint to consider the + * title/subtitle display to be optional. + * + * @see #setTitleOptionalHint(boolean) + * @see #isTitleOptional() + */ + public boolean getTitleOptionalHint() { + return mTitleOptionalHint; } /** diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 092bcbd..2f67481 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5423,6 +5423,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * app should not need to concern itself with saving and restoring, but that * the framework should take special note to preserve when possible. * + * <p>A view with transient state cannot be trivially rebound from an external + * data source, such as an adapter binding item views in a list. This may be + * because the view is performing an animation, tracking user selection + * of content, or similar.</p> + * * @return true if the view has transient state */ @ViewDebug.ExportedProperty(category = "layout") @@ -5436,6 +5441,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * so every call to setHasTransientState(true) should be paired with a later call * to setHasTransientState(false). * + * <p>A view with transient state cannot be trivially rebound from an external + * data source, such as an adapter binding item views in a list. This may be + * because the view is performing an animation, tracking user selection + * of content, or similar.</p> + * * @param hasTransientState true if this view has transient state */ public void setHasTransientState(boolean hasTransientState) { diff --git a/core/java/android/view/accessibility/AccessibilityRecord.java b/core/java/android/view/accessibility/AccessibilityRecord.java index 78a7d46..5c60a12 100644 --- a/core/java/android/view/accessibility/AccessibilityRecord.java +++ b/core/java/android/view/accessibility/AccessibilityRecord.java @@ -135,7 +135,12 @@ public class AccessibilityRecord { */ public void setSource(View root, int virtualDescendantId) { enforceNotSealed(); - final boolean important = (root != null) ? root.isImportantForAccessibility() : true; + final boolean important; + if (virtualDescendantId == UNDEFINED) { + important = (root != null) ? root.isImportantForAccessibility() : true; + } else { + important = true; + } setBooleanProperty(PROPERTY_IMPORTANT_FOR_ACCESSIBILITY, important); mSourceWindowId = (root != null) ? root.getAccessibilityWindowId() : UNDEFINED; final int rootViewId = (root != null) ? root.getAccessibilityViewId() : UNDEFINED; diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java index 30229f1..f0a9cc2 100644 --- a/core/java/android/webkit/WebViewClassic.java +++ b/core/java/android/webkit/WebViewClassic.java @@ -102,6 +102,7 @@ import android.webkit.WebView.PictureListener; import android.webkit.WebViewCore.DrawData; import android.webkit.WebViewCore.EventHub; import android.webkit.WebViewCore.TextFieldInitData; +import android.webkit.WebViewCore.TextSelectionData; import android.webkit.WebViewCore.TouchHighlightData; import android.webkit.WebViewCore.WebKitHitTest; import android.widget.AbsoluteLayout; @@ -984,7 +985,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc static final int REQUEST_KEYBOARD = 118; static final int SHOW_FULLSCREEN = 120; static final int HIDE_FULLSCREEN = 121; - static final int REPLACE_BASE_CONTENT = 123; static final int UPDATE_MATCH_COUNT = 126; static final int CENTER_FIT_RECT = 127; static final int SET_SCROLLBAR_MODES = 129; @@ -1316,6 +1316,12 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc case WebViewInputDispatcher.EVENT_TYPE_TOUCH: onHandleUiTouchEvent(event); break; + case WebViewInputDispatcher.EVENT_TYPE_CLICK: + if (mFocusedNode != null && mFocusedNode.mIntentUrl != null) { + mWebView.playSoundEffect(SoundEffectConstants.CLICK); + overrideLoading(mFocusedNode.mIntentUrl); + } + break; } } @@ -2018,6 +2024,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } private void destroyImpl() { + int drawGLFunction = nativeGetDrawGLFunction(mNativeClass); + ViewRootImpl viewRoot = mWebView.getViewRootImpl(); + Log.d(LOGTAG, String.format("destroyImpl, drawGLFunction %x, viewroot == null %b, isHWAccel %b", + drawGLFunction, (viewRoot == null), mWebView.isHardwareAccelerated())); + mCallbackProxy.blockMessages(); clearHelpers(); if (mListBoxDialog != null) { @@ -4207,7 +4218,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc // decide which adornments to draw int extras = DRAW_EXTRAS_NONE; - if (!mFindIsUp && mSelectingText) { + if (!mFindIsUp && mShowTextSelectionExtra) { extras = DRAW_EXTRAS_SELECTION; } @@ -4232,14 +4243,8 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc df = mScrollFilter; } canvas.setDrawFilter(df); - // XXX: Revisit splitting content. Right now it causes a - // synchronization problem with layers. - int content = nativeDraw(canvas, mVisibleContentRect, mBackgroundColor, - extras, false); + nativeDraw(canvas, mVisibleContentRect, mBackgroundColor, extras); canvas.setDrawFilter(null); - if (!mBlockWebkitViewMessages && content != 0) { - mWebViewCore.sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0); - } } canvas.restoreToCount(saveCount); @@ -4362,7 +4367,9 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } private void removeTouchHighlight() { - mWebViewCore.removeMessages(EventHub.HIT_TEST); + if (mWebViewCore != null) { + mWebViewCore.removeMessages(EventHub.HIT_TEST); + } mPrivateHandler.removeMessages(HIT_TEST_RESULT); setTouchHighlightRects(null); } @@ -4535,11 +4542,13 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc private void startSelectingText() { mSelectingText = true; + mShowTextSelectionExtra = true; mHandleAlphaAnimator.setIntValues(255); mHandleAlphaAnimator.start(); } private void endSelectingText() { mSelectingText = false; + mShowTextSelectionExtra = false; mHandleAlphaAnimator.setIntValues(0); mHandleAlphaAnimator.start(); } @@ -5312,9 +5321,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc mSelectCallback.finish(); mSelectCallback = null; } - if (!mIsCaretSelection) { - updateWebkitSelection(); - } invalidate(); // redraw without selection mAutoScrollX = 0; mAutoScrollY = 0; @@ -5434,9 +5440,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc removeAccessibilityApisFromJavaScript(); updateHwAccelerated(); + int drawGLFunction = nativeGetDrawGLFunction(mNativeClass); + ViewRootImpl viewRoot = mWebView.getViewRootImpl(); + Log.d(LOGTAG, String.format("onDetachedFromWindow, drawGLFunction %x, viewroot == null %b, isHWAccel %b", + drawGLFunction, (viewRoot == null), mWebView.isHardwareAccelerated())); if (mWebView.isHardwareAccelerated()) { - int drawGLFunction = nativeGetDrawGLFunction(mNativeClass); - ViewRootImpl viewRoot = mWebView.getViewRootImpl(); if (drawGLFunction != 0 && viewRoot != null) { viewRoot.detachFunctor(drawGLFunction); } @@ -6440,6 +6448,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc private int mTrackballXMove = 0; private int mTrackballYMove = 0; private boolean mSelectingText = false; + private boolean mShowTextSelectionExtra = false; private boolean mSelectionStarted = false; private static final int TRACKBALL_KEY_TIMEOUT = 1000; private static final int TRACKBALL_TIMEOUT = 200; @@ -7256,10 +7265,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc mZoomManager.updateDefaultZoomDensity(density); break; } - case REPLACE_BASE_CONTENT: { - nativeReplaceBaseContent(msg.arg1); - break; - } case NEW_PICTURE_MSG_ID: { // called for new content final WebViewCore.DrawData draw = (WebViewCore.DrawData) msg.obj; @@ -7594,6 +7599,8 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc case UPDATE_CONTENT_BOUNDS: mEditTextContentBounds.set((Rect) msg.obj); + nativeMapLayerRect(mNativeClass, mEditTextLayerId, + mEditTextContentBounds); break; case SCROLL_EDIT_TEXT: @@ -7620,6 +7627,26 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc public Context getContext() { return WebViewClassic.this.getContext(); } + + @Override + public boolean shouldInterceptTouchEvent(MotionEvent event) { + if (!mSelectingText) { + return false; + } + ensureSelectionHandles(); + int y = Math.round(event.getY() - getTitleHeight() + getScrollY()); + int x = Math.round(event.getX() + getScrollX()); + boolean isPressingHandle; + if (mIsCaretSelection) { + isPressingHandle = mSelectHandleCenter.getBounds() + .contains(x, y); + } else { + isPressingHandle = + mSelectHandleLeft.getBounds().contains(x, y) + || mSelectHandleRight.getBounds().contains(x, y); + } + return isPressingHandle; + } } private void setHitTestTypeFromUrl(String url) { @@ -7944,6 +7971,13 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } nativeSetTextSelection(mNativeClass, data.mSelectTextPtr); + if (data.mSelectionReason == TextSelectionData.REASON_ACCESSIBILITY_INJECTOR) { + selectionDone(); + mShowTextSelectionExtra = true; + invalidate(); + return; + } + if (data.mSelectTextPtr != 0 && (data.mStart != data.mEnd || (mFieldPointer == nodePointer && mFieldPointer != 0))) { @@ -8434,18 +8468,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } /** - * Draw the HTML page into the specified canvas. This call ignores any - * view-specific zoom, scroll offset, or other changes. It does not draw - * any view-specific chrome, such as progress or URL bars. - * - * only needs to be accessible to Browser and testing - */ - public void drawPage(Canvas canvas) { - calcOurContentVisibleRectF(mVisibleContentRect); - nativeDraw(canvas, mVisibleContentRect, 0, 0, false); - } - - /** * Enable the communication b/t the webView and VideoViewProxy * * only used by the Browser @@ -8578,14 +8600,8 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc private native void nativeDebugDump(); private native void nativeDestroy(); - /** - * Draw the picture set with a background color and extra. If - * "splitIfNeeded" is true and the return value is not 0, the return value - * MUST be passed to WebViewCore with SPLIT_PICTURE_SET message so that the - * native allocation can be freed. - */ - private native int nativeDraw(Canvas canvas, RectF visibleRect, - int color, int extra, boolean splitIfNeeded); + private native void nativeDraw(Canvas canvas, RectF visibleRect, + int color, int extra); private native void nativeDumpDisplayTree(String urlOrNull); private native boolean nativeEvaluateLayersAnimations(int nativeInstance); private native int nativeCreateDrawGLFunction(int nativeInstance, Rect rect, @@ -8599,7 +8615,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc private native boolean nativeSetBaseLayer(int nativeInstance, int layer, boolean showVisualIndicator, boolean isPictureAfterFirstLayout); private native int nativeGetBaseLayer(); - private native void nativeReplaceBaseContent(int content); private native void nativeCopyBaseContentToPicture(Picture pict); private native boolean nativeHasContent(); private native void nativeStopGL(); diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 12c9d69..661bbf8 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -143,6 +143,7 @@ public final class WebViewCore { private int mHighUsageDeltaMb; private int mChromeCanFocusDirection; + private int mTextSelectionChangeReason = TextSelectionData.REASON_UNKNOWN; // The thread name used to identify the WebCore thread and for use in // debugging other classes that require operation within the WebCore thread. @@ -610,12 +611,6 @@ public final class WebViewCore { private native boolean nativeFocusBoundsChanged(int nativeClass); - /** - * Splits slow parts of the picture set. Called from the webkit thread after - * WebView.nativeDraw() returns content to be split. - */ - private native void nativeSplitContent(int nativeClass, int content); - private native boolean nativeKey(int nativeClass, int keyCode, int unichar, int repeatCount, boolean isShift, boolean isAlt, boolean isSym, boolean isDown); @@ -867,6 +862,8 @@ public final class WebViewCore { } static class TextSelectionData { + static final int REASON_UNKNOWN = 0; + static final int REASON_ACCESSIBILITY_INJECTOR = 1; public TextSelectionData(int start, int end, int selectTextPtr) { mStart = start; mEnd = end; @@ -875,6 +872,7 @@ public final class WebViewCore { int mStart; int mEnd; int mSelectTextPtr; + int mSelectionReason = TextSelectionData.REASON_UNKNOWN; } static class TouchUpData { @@ -1018,7 +1016,7 @@ public final class WebViewCore { "WEBKIT_DRAW", // = 130; "131", // = 131; "POST_URL", // = 132; - "SPLIT_PICTURE_SET", // = 133; + "", // = 133; "CLEAR_CONTENT", // = 134; "", // = 135; "", // = 136; @@ -1094,7 +1092,6 @@ public final class WebViewCore { static final int WEBKIT_DRAW = 130; static final int POST_URL = 132; - static final int SPLIT_PICTURE_SET = 133; static final int CLEAR_CONTENT = 134; // UI nav messages @@ -1551,12 +1548,16 @@ public final class WebViewCore { break; case MODIFY_SELECTION: + mTextSelectionChangeReason + = TextSelectionData.REASON_ACCESSIBILITY_INJECTOR; String modifiedSelectionString = nativeModifySelection(mNativeClass, msg.arg1, msg.arg2); mWebViewClassic.mPrivateHandler.obtainMessage( WebViewClassic.SELECTION_STRING_CHANGED, modifiedSelectionString).sendToTarget(); + mTextSelectionChangeReason + = TextSelectionData.REASON_UNKNOWN; break; case LISTBOX_CHOICES: @@ -1611,13 +1612,6 @@ public final class WebViewCore { data.mOrigin, data.mAllow, data.mRemember); break; - case SPLIT_PICTURE_SET: - nativeSplitContent(mNativeClass, msg.arg1); - mWebViewClassic.mPrivateHandler.obtainMessage( - WebViewClassic.REPLACE_BASE_CONTENT, msg.arg1, 0); - mSplitPictureIsScheduled = false; - break; - case CLEAR_CONTENT: // Clear the view so that onDraw() will draw nothing // but white background @@ -1879,7 +1873,6 @@ public final class WebViewCore { private synchronized void removeMessages() { // reset mDrawIsScheduled flag as WEBKIT_DRAW may be removed mDrawIsScheduled = false; - mSplitPictureIsScheduled = false; if (mMessages != null) { mMessages.clear(); } else { @@ -2141,20 +2134,9 @@ public final class WebViewCore { return usedQuota; } - // called from UI thread - void splitContent(int content) { - if (!mSplitPictureIsScheduled) { - mSplitPictureIsScheduled = true; - sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0); - } - } - // Used to avoid posting more than one draw message. private boolean mDrawIsScheduled; - // Used to avoid posting more than one split picture message. - private boolean mSplitPictureIsScheduled; - // Used to suspend drawing. private boolean mDrawIsPaused; @@ -2789,13 +2771,19 @@ public final class WebViewCore { } } + private TextSelectionData createTextSelection(int start, int end, int selPtr) { + TextSelectionData data = new TextSelectionData(start, end, selPtr); + data.mSelectionReason = mTextSelectionChangeReason; + return data; + } + // called by JNI private void updateTextSelection(int pointer, int start, int end, int textGeneration, int selectionPtr) { if (mWebViewClassic != null) { Message.obtain(mWebViewClassic.mPrivateHandler, WebViewClassic.UPDATE_TEXT_SELECTION_MSG_ID, pointer, textGeneration, - new TextSelectionData(start, end, selectionPtr)).sendToTarget(); + createTextSelection(start, end, selectionPtr)).sendToTarget(); } } @@ -2829,7 +2817,7 @@ public final class WebViewCore { Message.obtain(mWebViewClassic.mPrivateHandler, WebViewClassic.UPDATE_TEXT_SELECTION_MSG_ID, initData.mFieldPointer, 0, - new TextSelectionData(start, end, selectionPtr)) + createTextSelection(start, end, selectionPtr)) .sendToTarget(); } diff --git a/core/java/android/webkit/WebViewInputDispatcher.java b/core/java/android/webkit/WebViewInputDispatcher.java index b612a3b..ef23a11 100644 --- a/core/java/android/webkit/WebViewInputDispatcher.java +++ b/core/java/android/webkit/WebViewInputDispatcher.java @@ -22,7 +22,6 @@ import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.util.Log; -import android.view.InputDevice; import android.view.MotionEvent; import android.view.ViewConfiguration; @@ -314,11 +313,13 @@ final class WebViewInputDispatcher { return false; } - if (mPostSendTouchEventsToWebKit - && mPostDoNotSendTouchEventsToWebKitUntilNextGesture - && action == MotionEvent.ACTION_DOWN) { - // Recover from a previous web kit timeout. - mPostDoNotSendTouchEventsToWebKitUntilNextGesture = false; + if (action == MotionEvent.ACTION_DOWN && mPostSendTouchEventsToWebKit) { + if (mUiCallbacks.shouldInterceptTouchEvent(eventToEnqueue)) { + mPostDoNotSendTouchEventsToWebKitUntilNextGesture = true; + } else if (mPostDoNotSendTouchEventsToWebKitUntilNextGesture) { + // Recover from a previous web kit timeout. + mPostDoNotSendTouchEventsToWebKitUntilNextGesture = false; + } } } @@ -949,6 +950,15 @@ final class WebViewInputDispatcher { * @param flags The event's dispatch flags. */ public void dispatchUiEvent(MotionEvent event, int eventType, int flags); + + /** + * Asks the UI thread whether this touch event stream should be + * intercepted based on the touch down event. + * @param event The touch down event. + * @return true if the UI stream wants the touch stream without going + * through webkit or false otherwise. + */ + public boolean shouldInterceptTouchEvent(MotionEvent event); } /* Implemented by {@link WebViewCore} to perform operations on the web kit thread. */ diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index 4d9ff0f..cb10d0a 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -658,7 +658,7 @@ public class GridLayout extends ViewGroup { private void validateLayoutParams() { final boolean horizontal = (orientation == HORIZONTAL); final Axis axis = horizontal ? horizontalAxis : verticalAxis; - final int count = max(0, axis.getCount()); // Handle negative values, including UNDEFINED + final int count = (axis.definedCount != UNDEFINED) ? axis.definedCount : 0; int major = 0; int minor = 0; diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java index ed711f3..805c0a9 100644 --- a/core/java/com/android/internal/app/ActionBarImpl.java +++ b/core/java/com/android/internal/app/ActionBarImpl.java @@ -817,6 +817,7 @@ public class ActionBarImpl extends ActionBar { @Override public void setTitleOptionalHint(boolean titleOptional) { + super.setTitleOptionalHint(titleOptional); mContextView.setTitleOptional(titleOptional); } diff --git a/core/java/com/android/internal/view/StandaloneActionMode.java b/core/java/com/android/internal/view/StandaloneActionMode.java index 4b681ec..fae7ea1 100644 --- a/core/java/com/android/internal/view/StandaloneActionMode.java +++ b/core/java/com/android/internal/view/StandaloneActionMode.java @@ -73,6 +73,7 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call @Override public void setTitleOptionalHint(boolean titleOptional) { + super.setTitleOptionalHint(titleOptional); mContextView.setTitleOptional(titleOptional); } diff --git a/core/java/com/android/server/NetworkManagementSocketTagger.java b/core/java/com/android/server/NetworkManagementSocketTagger.java index c77992d..06ef4c9 100644 --- a/core/java/com/android/server/NetworkManagementSocketTagger.java +++ b/core/java/com/android/server/NetworkManagementSocketTagger.java @@ -16,20 +16,14 @@ package com.android.server; -import android.net.NetworkStats; import android.os.SystemProperties; import android.util.Log; import android.util.Slog; import dalvik.system.SocketTagger; -import libcore.io.IoUtils; import java.io.FileDescriptor; -import java.io.FileOutputStream; -import java.io.IOException; -import java.math.BigInteger; import java.net.SocketException; -import java.nio.charset.Charsets; /** * Assigns tags to sockets for traffic stats. @@ -141,8 +135,12 @@ public final class NetworkManagementSocketTagger extends SocketTagger { * format like {@code 0x7fffffff00000000}. */ public static int kernelToTag(String string) { - // TODO: migrate to direct integer instead of odd shifting - return (int) (Long.decode(string) >> 32); + int length = string.length(); + if (length > 10) { + return Long.decode(string.substring(0, length - 8)).intValue(); + } else { + return 0; + } } private static native int native_tagSocketFd(FileDescriptor fd, int tag, int uid); |
