From ed740498cacc7977c9b310722e92b3fa53fa3584 Mon Sep 17 00:00:00 2001 From: Ficus Kirkpatrick Date: Fri, 10 Apr 2009 15:50:01 -0700 Subject: [PATCH 1/4] Add method on EncodedStringValue to transform a String[]. --- .../google/android/mms/pdu/EncodedStringValue.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/java/com/google/android/mms/pdu/EncodedStringValue.java b/core/java/com/google/android/mms/pdu/EncodedStringValue.java index 7696c5e7f3354..a27962d41e4de 100644 --- a/core/java/com/google/android/mms/pdu/EncodedStringValue.java +++ b/core/java/com/google/android/mms/pdu/EncodedStringValue.java @@ -269,4 +269,16 @@ public class EncodedStringValue implements Cloneable { return new EncodedStringValue(value.mCharacterSet, value.mData); } + + public static EncodedStringValue[] encodeStrings(String[] array) { + int count = array.length; + if (count > 0) { + EncodedStringValue[] encodedArray = new EncodedStringValue[count]; + for (int i = 0; i < count; i++) { + encodedArray[i] = new EncodedStringValue(array[i]); + } + return encodedArray; + } + return null; + } } From 9ae010a349e953a443f1cc8bc33ff1becf997a19 Mon Sep 17 00:00:00 2001 From: Feng Qian <> Date: Fri, 10 Apr 2009 18:11:32 -0700 Subject: [PATCH 2/4] AI 145796: Land the WebKit merge @r42026. Automated import of CL 145796 --- .../android/webkit/JWebCoreJavaBridge.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/core/java/android/webkit/JWebCoreJavaBridge.java b/core/java/android/webkit/JWebCoreJavaBridge.java index a0049ac982e25..361091f76d11f 100644 --- a/core/java/android/webkit/JWebCoreJavaBridge.java +++ b/core/java/android/webkit/JWebCoreJavaBridge.java @@ -34,9 +34,13 @@ final class JWebCoreJavaBridge extends Handler { // Instant timer is used to implement a timer that needs to fire almost // immediately. private boolean mHasInstantTimer; + // Reference count the pause/resume of timers private int mPauseTimerRefCount; + private boolean mTimerPaused; + private boolean mHasDeferredTimers; + /** * Construct a new JWebCoreJavaBridge to interface with * WebCore timers and cookies. @@ -50,6 +54,17 @@ final class JWebCoreJavaBridge extends Handler { nativeFinalize(); } + /** + * Call native timer callbacks. + */ + private void fireSharedTimer() { + PerfChecker checker = new PerfChecker(); + // clear the flag so that sharedTimerFired() can set a new timer + mHasInstantTimer = false; + sharedTimerFired(); + checker.responseAlert("sharedTimer"); + } + /** * handleMessage * @param msg The dispatched message. @@ -60,11 +75,11 @@ final class JWebCoreJavaBridge extends Handler { public void handleMessage(Message msg) { switch (msg.what) { case TIMER_MESSAGE: { - PerfChecker checker = new PerfChecker(); - // clear the flag so that sharedTimerFired() can set a new timer - mHasInstantTimer = false; - sharedTimerFired(); - checker.responseAlert("sharedTimer"); + if (mTimerPaused) { + mHasDeferredTimers = true; + } else { + fireSharedTimer(); + } break; } case FUNCPTR_MESSAGE: @@ -86,7 +101,8 @@ final class JWebCoreJavaBridge extends Handler { */ public void pause() { if (--mPauseTimerRefCount == 0) { - setDeferringTimers(true); + mTimerPaused = true; + mHasDeferredTimers = false; } } @@ -95,7 +111,11 @@ final class JWebCoreJavaBridge extends Handler { */ public void resume() { if (++mPauseTimerRefCount == 1) { - setDeferringTimers(false); + mTimerPaused = false; + if (mHasDeferredTimers) { + mHasDeferredTimers = false; + fireSharedTimer(); + } } } @@ -185,11 +205,11 @@ final class JWebCoreJavaBridge extends Handler { } removeMessages(TIMER_MESSAGE); mHasInstantTimer = false; + mHasDeferredTimers = false; } private native void nativeConstructor(); private native void nativeFinalize(); private native void sharedTimerFired(); - private native void setDeferringTimers(boolean defer); public native void setNetworkOnLine(boolean online); } From 3156bb00dd3ab3d6ec732bb6a64a2e84d08c34f0 Mon Sep 17 00:00:00 2001 From: Patrick Scott <> Date: Mon, 13 Apr 2009 09:57:38 -0700 Subject: [PATCH 3/4] AI 145870: Add a build property for the default alarm alert. Update the various framework classes to deal with the new property. Also update various documentation that mentions the default ringtones. Use the build property as the default alert when the user has not chosen an alert for an alarm. This is also used if the alarm alert is null when the alarm fires. BUG=1723684 Automated import of CL 145870 --- api/current.xml | 21 ++++++++++++ .../preference/RingtonePreference.java | 5 +-- .../android/preference/VolumePreference.java | 15 ++++++--- core/java/android/provider/Settings.java | 16 ++++++++++ media/java/android/media/MediaScanner.java | 12 +++++++ media/java/android/media/RingtoneManager.java | 32 +++++++++++++------ 6 files changed, 85 insertions(+), 16 deletions(-) diff --git a/api/current.xml b/api/current.xml index 3e65514af296a..df318d5764fdb 100644 --- a/api/current.xml +++ b/api/current.xml @@ -95141,6 +95141,17 @@ visibility="public" > + + + + * If the user chooses the "Default" item, the saved string will be one of - * {@link System#DEFAULT_RINGTONE_URI} or - * {@link System#DEFAULT_NOTIFICATION_URI}. If the user chooses the "Silent" + * {@link System#DEFAULT_RINGTONE_URI}, + * {@link System#DEFAULT_NOTIFICATION_URI}, or + * {@link System#DEFAULT_ALARM_ALERT_URI}. If the user chooses the "Silent" * item, the saved string will be an empty string. * * @attr ref android.R.styleable#RingtonePreference_ringtoneType diff --git a/core/java/android/preference/VolumePreference.java b/core/java/android/preference/VolumePreference.java index 20702a1de4138..abdcd931db2d9 100644 --- a/core/java/android/preference/VolumePreference.java +++ b/core/java/android/preference/VolumePreference.java @@ -22,6 +22,7 @@ import android.database.ContentObserver; import android.media.Ringtone; import android.media.RingtoneManager; import android.media.AudioManager; +import android.net.Uri; import android.os.Handler; import android.preference.PreferenceManager; import android.provider.Settings; @@ -147,10 +148,16 @@ public class VolumePreference extends SeekBarPreference implements System.getUriFor(System.VOLUME_SETTINGS[mStreamType]), false, mVolumeObserver); - mRingtone = RingtoneManager.getRingtone(mContext, - mStreamType == AudioManager.STREAM_NOTIFICATION - ? Settings.System.DEFAULT_NOTIFICATION_URI - : Settings.System.DEFAULT_RINGTONE_URI); + Uri defaultUri = null; + if (mStreamType == AudioManager.STREAM_RING) { + defaultUri = Settings.System.DEFAULT_RINGTONE_URI; + } else if (mStreamType == AudioManager.STREAM_NOTIFICATION) { + defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI; + } else { + defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI; + } + + mRingtone = RingtoneManager.getRingtone(mContext, defaultUri); mRingtone.setStreamType(mStreamType); } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 3fb46ed75a6e3..28eaced1b6e85 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -1181,6 +1181,22 @@ public final class Settings { */ public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND); + /** + * Persistent store for the system-wide default alarm alert. + * + * @see #RINGTONE + * @see #DEFAULT_ALARM_ALERT_URI + */ + public static final String ALARM_ALERT = "alarm_alert"; + + /** + * A {@link Uri} that will point to the current default alarm alert at + * any given time. + * + * @see #DEFAULT_ALARM_ALERT_URI + */ + public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT); + /** * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off */ diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index fc8476d4ae83f..cba6292175c42 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -269,10 +269,14 @@ public class MediaScanner private boolean mDefaultRingtoneSet; /** Whether the scanner has set a default sound for the notification ringtone. */ private boolean mDefaultNotificationSet; + /** Whether the scanner has set a default sound for the alarm ringtone. */ + private boolean mDefaultAlarmSet; /** The filename for the default sound for the ringer ringtone. */ private String mDefaultRingtoneFilename; /** The filename for the default sound for the notification ringtone. */ private String mDefaultNotificationFilename; + /** The filename for the default sound for the alarm ringtone. */ + private String mDefaultAlarmAlertFilename; /** * The prefix for system properties that define the default sound for * ringtones. Concatenate the name of the setting from Settings @@ -331,6 +335,8 @@ public class MediaScanner + Settings.System.RINGTONE); mDefaultNotificationFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX + Settings.System.NOTIFICATION_SOUND); + mDefaultAlarmAlertFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX + + Settings.System.ALARM_ALERT); } private MyMediaScannerClient mClient = new MyMediaScannerClient(); @@ -709,6 +715,12 @@ public class MediaScanner setSettingIfNotSet(Settings.System.RINGTONE, tableUri, rowId); mDefaultRingtoneSet = true; } + } else if (alarms && !mDefaultAlarmSet) { + if (TextUtils.isEmpty(mDefaultAlarmAlertFilename) || + doesPathHaveFilename(entry.mPath, mDefaultAlarmAlertFilename)) { + setSettingIfNotSet(Settings.System.ALARM_ALERT, tableUri, rowId); + mDefaultAlarmSet = true; + } } return result; diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java index 2f0007fadadc7..1413ca47d2822 100644 --- a/media/java/android/media/RingtoneManager.java +++ b/media/java/android/media/RingtoneManager.java @@ -122,8 +122,9 @@ public class RingtoneManager { * current ringtone, which will be used to show a checkmark next to the item * for this {@link Uri}. If showing an item for "Default" (@see * {@link #EXTRA_RINGTONE_SHOW_DEFAULT}), this can also be one of - * {@link System#DEFAULT_RINGTONE_URI} or - * {@link System#DEFAULT_NOTIFICATION_URI} to have the "Default" item + * {@link System#DEFAULT_RINGTONE_URI}, + * {@link System#DEFAULT_NOTIFICATION_URI}, or + * {@link System#DEFAULT_ALARM_ALERT_URI} to have the "Default" item * checked. * * @see #ACTION_RINGTONE_PICKER @@ -134,8 +135,9 @@ public class RingtoneManager { /** * Given to the ringtone picker as a {@link Uri}. The {@link Uri} of the * ringtone to play when the user attempts to preview the "Default" - * ringtone. This can be one of {@link System#DEFAULT_RINGTONE_URI} or - * {@link System#DEFAULT_NOTIFICATION_URI} to have the "Default" point to + * ringtone. This can be one of {@link System#DEFAULT_RINGTONE_URI}, + * {@link System#DEFAULT_NOTIFICATION_URI}, or + * {@link System#DEFAULT_ALARM_ALERT_URI} to have the "Default" point to * the current sound for the given default sound type. If you are showing a * ringtone picker for some other type of sound, you are free to provide any * {@link Uri} here. @@ -163,8 +165,9 @@ public class RingtoneManager { *

* It will be one of: *

  • the picked ringtone, - *
  • a {@link Uri} that equals {@link System#DEFAULT_RINGTONE_URI} or - * {@link System#DEFAULT_NOTIFICATION_URI} if the default was chosen, + *
  • a {@link Uri} that equals {@link System#DEFAULT_RINGTONE_URI}, + * {@link System#DEFAULT_NOTIFICATION_URI}, or + * {@link System#DEFAULT_ALARM_ALERT_URI} if the default was chosen, *
  • null if the "Silent" item was picked. * * @see #ACTION_RINGTONE_PICKER @@ -625,7 +628,8 @@ public class RingtoneManager { * * @param context A context used for querying. * @param type The type whose default sound should be returned. One of - * {@link #TYPE_RINGTONE} or {@link #TYPE_NOTIFICATION}. + * {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or + * {@link #TYPE_ALARM}. * @return A {@link Uri} pointing to the default sound for the sound type. * @see #setActualDefaultRingtoneUri(Context, int, Uri) */ @@ -641,7 +645,8 @@ public class RingtoneManager { * * @param context A context used for querying. * @param type The type whose default sound should be set. One of - * {@link #TYPE_RINGTONE} or {@link #TYPE_NOTIFICATION}. + * {@link #TYPE_RINGTONE}, {@link #TYPE_NOTIFICATION}, or + * {@link #TYPE_ALARM}. * @param ringtoneUri A {@link Uri} pointing to the default sound to set. * @see #getActualDefaultRingtoneUri(Context, int) */ @@ -656,6 +661,8 @@ public class RingtoneManager { return Settings.System.RINGTONE; } else if ((type & TYPE_NOTIFICATION) != 0) { return Settings.System.NOTIFICATION_SOUND; + } else if ((type & TYPE_ALARM) != 0) { + return Settings.System.ALARM_ALERT; } else { return null; } @@ -675,8 +682,9 @@ public class RingtoneManager { * Returns the type of a default {@link Uri}. * * @param defaultRingtoneUri The default {@link Uri}. For example, - * {@link System#DEFAULT_RINGTONE_URI} or - * {@link System#DEFAULT_NOTIFICATION_URI}. + * {@link System#DEFAULT_RINGTONE_URI}, + * {@link System#DEFAULT_NOTIFICATION_URI}, or + * {@link System#DEFAULT_ALARM_ALERT_URI}. * @return The type of the defaultRingtoneUri, or -1. */ public static int getDefaultType(Uri defaultRingtoneUri) { @@ -686,6 +694,8 @@ public class RingtoneManager { return TYPE_RINGTONE; } else if (defaultRingtoneUri.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { return TYPE_NOTIFICATION; + } else if (defaultRingtoneUri.equals(Settings.System.DEFAULT_ALARM_ALERT_URI)) { + return TYPE_ALARM; } else { return -1; } @@ -705,6 +715,8 @@ public class RingtoneManager { return Settings.System.DEFAULT_RINGTONE_URI; } else if ((type & TYPE_NOTIFICATION) != 0) { return Settings.System.DEFAULT_NOTIFICATION_URI; + } else if ((type & TYPE_ALARM) != 0) { + return Settings.System.DEFAULT_ALARM_ALERT_URI; } else { return null; } From b3230cb1e33c3de7ae7d63217617606d23943708 Mon Sep 17 00:00:00 2001 From: Grace Kloba <> Date: Mon, 13 Apr 2009 14:04:23 -0700 Subject: [PATCH 4/4] AI 145922: Fix #1640053, #1777704. When WebKit set scroll position through jni, we need to check whether there is a pending draw as the scroll position should be based on the new picture, not the current picture. BUG=1640053,1777704 Automated import of CL 145922 --- core/java/android/webkit/WebViewCore.java | 54 +++++++++++++++++------ 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 9c00e7f56ee3d..e520ba3b40fcb 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -527,7 +527,7 @@ final class WebViewCore { "DELETE_SELECTION", // = 122; "LISTBOX_CHOICES", // = 123; "SINGLE_LISTBOX_CHOICE", // = 124; - "125", + "MESSAGE_RELAY", // = 125; "SET_BACKGROUND_COLOR", // = 126; "UNBLOCK_FOCUS", // = 127; "SAVE_DOCUMENT_STATE", // = 128; @@ -573,6 +573,7 @@ final class WebViewCore { static final int DELETE_SELECTION = 122; static final int LISTBOX_CHOICES = 123; static final int SINGLE_LISTBOX_CHOICE = 124; + static final int MESSAGE_RELAY = 125; static final int SET_BACKGROUND_COLOR = 126; static final int UNBLOCK_FOCUS = 127; static final int SAVE_DOCUMENT_STATE = 128; @@ -1005,6 +1006,12 @@ final class WebViewCore { // (See public method WebView.clearView) nativeClearContent(); break; + + case MESSAGE_RELAY: + if (msg.obj instanceof Message) { + ((Message) msg.obj).sendToTarget(); + } + break; } } }; @@ -1422,9 +1429,14 @@ final class WebViewCore { return; } if (mWebView != null) { - Message.obtain(mWebView.mPrivateHandler, - WebView.SCROLL_BY_MSG_ID, dx, dy, - new Boolean(animate)).sendToTarget(); + Message msg = Message.obtain(mWebView.mPrivateHandler, + WebView.SCROLL_BY_MSG_ID, dx, dy, new Boolean(animate)); + if (mDrawIsScheduled) { + mEventHub.sendMessage(Message.obtain(null, + EventHub.MESSAGE_RELAY, msg)); + } else { + msg.sendToTarget(); + } } } @@ -1441,8 +1453,14 @@ final class WebViewCore { return; } if (mWebView != null) { - Message.obtain(mWebView.mPrivateHandler, - WebView.SCROLL_TO_MSG_ID, x, y).sendToTarget(); + Message msg = Message.obtain(mWebView.mPrivateHandler, + WebView.SCROLL_TO_MSG_ID, x, y); + if (mDrawIsScheduled) { + mEventHub.sendMessage(Message.obtain(null, + EventHub.MESSAGE_RELAY, msg)); + } else { + msg.sendToTarget(); + } } } @@ -1459,8 +1477,14 @@ final class WebViewCore { return; } if (mWebView != null) { - Message.obtain(mWebView.mPrivateHandler, - WebView.SPAWN_SCROLL_TO_MSG_ID, x, y).sendToTarget(); + Message msg = Message.obtain(mWebView.mPrivateHandler, + WebView.SPAWN_SCROLL_TO_MSG_ID, x, y); + if (mDrawIsScheduled) { + mEventHub.sendMessage(Message.obtain(null, + EventHub.MESSAGE_RELAY, msg)); + } else { + msg.sendToTarget(); + } } } @@ -1592,11 +1616,6 @@ final class WebViewCore { mViewportWidth, scaleLimit).sendToTarget(); } - // if no restored offset, move the new page to (0, 0) - Message.obtain(mWebView.mPrivateHandler, WebView.SCROLL_TO_MSG_ID, - mRestoredX, mRestoredY).sendToTarget(); - mRestoredX = mRestoredY = 0; - // force an early draw for quick feedback after the first layout if (mCurrentViewWidth != 0) { synchronized (this) { @@ -1604,10 +1623,19 @@ final class WebViewCore { mEventHub.removeMessages(EventHub.WEBKIT_DRAW); } mDrawIsScheduled = true; + // if no restored offset, move the new page to (0, 0) + mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null, + EventHub.MESSAGE_RELAY, Message.obtain( + mWebView.mPrivateHandler, + WebView.SCROLL_TO_MSG_ID, mRestoredX, + mRestoredY))); mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null, EventHub.WEBKIT_DRAW)); } } + + // reset restored offset + mRestoredX = mRestoredY = 0; } }