summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ActivityThread.java20
-rw-r--r--core/java/android/app/SearchDialog.java91
-rw-r--r--core/java/android/app/SearchManager.java22
-rw-r--r--core/java/android/backup/BackupDataInput.java20
-rw-r--r--core/java/android/backup/BackupDataInputStream.java61
-rw-r--r--core/java/android/backup/RestoreHelper.java10
-rw-r--r--core/java/android/backup/RestoreHelperDispatcher.java (renamed from core/java/android/backup/RestoreHelperDistributor.java)21
-rwxr-xr-xcore/java/android/gesture/GestureOverlayView.java2
-rwxr-xr-xcore/java/android/speech/tts/ITts.aidl2
-rwxr-xr-xcore/java/android/speech/tts/TextToSpeech.java72
-rw-r--r--core/java/com/android/internal/backup/IBackupTransport.aidl9
-rw-r--r--core/java/com/android/internal/backup/LocalTransport.java2
12 files changed, 200 insertions, 132 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 2fe6471..3676594 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3217,7 +3217,7 @@ public final class ActivityThread {
r.activity.getComponentName().getClassName());
if (!r.activity.mCalled) {
throw new SuperNotCalledException(
- "Activity " + r.intent.getComponent().toShortString()
+ "Activity " + safeToComponentShortString(r.intent)
+ " did not call through to super.onPause()");
}
} catch (SuperNotCalledException e) {
@@ -3226,7 +3226,7 @@ public final class ActivityThread {
if (!mInstrumentation.onException(r.activity, e)) {
throw new RuntimeException(
"Unable to pause activity "
- + r.intent.getComponent().toShortString()
+ + safeToComponentShortString(r.intent)
+ ": " + e.toString(), e);
}
}
@@ -3241,7 +3241,7 @@ public final class ActivityThread {
if (!mInstrumentation.onException(r.activity, e)) {
throw new RuntimeException(
"Unable to stop activity "
- + r.intent.getComponent().toShortString()
+ + safeToComponentShortString(r.intent)
+ ": " + e.toString(), e);
}
}
@@ -3266,7 +3266,7 @@ public final class ActivityThread {
if (!mInstrumentation.onException(r.activity, e)) {
throw new RuntimeException(
"Unable to retain child activities "
- + r.intent.getComponent().toShortString()
+ + safeToComponentShortString(r.intent)
+ ": " + e.toString(), e);
}
}
@@ -3277,7 +3277,7 @@ public final class ActivityThread {
r.activity.onDestroy();
if (!r.activity.mCalled) {
throw new SuperNotCalledException(
- "Activity " + r.intent.getComponent().toShortString() +
+ "Activity " + safeToComponentShortString(r.intent) +
" did not call through to super.onDestroy()");
}
if (r.window != null) {
@@ -3287,10 +3287,9 @@ public final class ActivityThread {
throw e;
} catch (Exception e) {
if (!mInstrumentation.onException(r.activity, e)) {
- ComponentName component = r.intent.getComponent();
- String name = component == null ? "[Unknown]" : component.toShortString();
throw new RuntimeException(
- "Unable to destroy activity " + name + ": " + e.toString(), e);
+ "Unable to destroy activity " + safeToComponentShortString(r.intent)
+ + ": " + e.toString(), e);
}
}
}
@@ -3299,6 +3298,11 @@ public final class ActivityThread {
return r;
}
+ private static String safeToComponentShortString(Intent intent) {
+ ComponentName component = intent.getComponent();
+ return component == null ? "[Unknown]" : component.toShortString();
+ }
+
private final void handleDestroyActivity(IBinder token, boolean finishing,
int configChanges, boolean getNonConfigInstance) {
ActivityRecord r = performDestroyActivity(token, finishing,
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 9141c4c..b6c8385 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -35,11 +35,6 @@ import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
-import android.location.Criteria;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.location.LocationProvider;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
@@ -153,15 +148,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
private final WeakHashMap<String, Drawable> mOutsideDrawablesCache =
new WeakHashMap<String, Drawable>();
- // Objects we keep around for requesting location updates when the dialog is started
- // (and canceling them when the dialog is stopped). We don't actually make use of the
- // updates ourselves here, so the LocationListener is just a dummy which doesn't do
- // anything. We only do this here so that other suggest providers which wish to provide
- // location-based suggestions are more likely to get a good fresh location.
- private LocationManager mLocationManager;
- private LocationProvider mLocationProvider;
- private LocationListener mDummyLocationListener;
-
/**
* Constructor - fires it up and makes it look like the search UI.
*
@@ -240,37 +226,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- mLocationManager =
- (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
-
- if (mLocationManager != null) {
- Criteria criteria = new Criteria();
- criteria.setAccuracy(Criteria.ACCURACY_COARSE);
-
- String providerName = mLocationManager.getBestProvider(criteria, true);
-
- if (providerName != null) {
- mLocationProvider = mLocationManager.getProvider(providerName);
- }
-
- // Just a dumb listener that doesn't do anything - requesting location updates here
- // is only intended to give location-based suggestion providers the best chance
- // of getting a good fresh location.
- mDummyLocationListener = new LocationListener() {
- public void onLocationChanged(Location location) {
- }
-
- public void onProviderDisabled(String provider) {
- }
-
- public void onProviderEnabled(String provider) {
- }
-
- public void onStatusChanged(String provider, int status, Bundle extras) {
- }
- };
- }
}
/**
@@ -423,8 +378,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
// receive broadcasts
getContext().registerReceiver(mBroadcastReceiver, mCloseDialogsFilter);
getContext().registerReceiver(mBroadcastReceiver, mPackageFilter);
-
- startLocationUpdates();
}
/**
@@ -437,8 +390,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
public void onStop() {
super.onStop();
- stopLocationUpdates();
-
// stop receiving broadcasts (throws exception if none registered)
try {
getContext().unregisterReceiver(mBroadcastReceiver);
@@ -456,26 +407,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
mUserQuery = null;
mPreviousComponents = null;
}
-
- /**
- * Asks the LocationManager for location updates so that it goes and gets a fresh location
- * if needed.
- */
- private void startLocationUpdates() {
- if (mLocationManager != null && mLocationProvider != null) {
- mLocationManager.requestLocationUpdates(mLocationProvider.getName(),
- 0, 0, mDummyLocationListener, getContext().getMainLooper());
- }
- }
-
- /**
- * Makes sure to stop listening for location updates to save battery.
- */
- private void stopLocationUpdates() {
- mLocationManager.removeUpdates(mDummyLocationListener);
- }
-
/**
* Sets the search dialog to the 'working' state, which shows a working spinner in the
* right hand size of the text field.
@@ -1168,7 +1100,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
*/
protected void launchQuerySearch(int actionKey, String actionMsg) {
String query = mSearchAutoComplete.getText().toString();
- Intent intent = createIntent(Intent.ACTION_SEARCH, null, query, null,
+ Intent intent = createIntent(Intent.ACTION_SEARCH, null, null, query, null,
actionKey, actionMsg);
launchIntent(intent);
}
@@ -1238,8 +1170,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
// logic for falling back on the searchable default
cv.put(SearchManager.SUGGEST_COLUMN_INTENT_ACTION, intent.getAction());
cv.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA, intent.getDataString());
- cv.put(SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA,
- intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
+ cv.put(SearchManager.SUGGEST_COLUMN_INTENT_COMPONENT_NAME,
+ intent.getStringExtra(SearchManager.COMPONENT_NAME_KEY));
// ensure the icons will work for global search
cv.put(SearchManager.SUGGEST_COLUMN_ICON_1,
@@ -1467,11 +1399,14 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
}
Uri dataUri = (data == null) ? null : Uri.parse(data);
- String extraData = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);
+ String componentName = getColumnString(
+ c, SearchManager.SUGGEST_COLUMN_INTENT_COMPONENT_NAME);
String query = getColumnString(c, SearchManager.SUGGEST_COLUMN_QUERY);
+ String extraData = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);
- return createIntent(action, dataUri, query, extraData, actionKey, actionMsg);
+ return createIntent(action, dataUri, extraData, query, componentName, actionKey,
+ actionMsg);
} catch (RuntimeException e ) {
int rowNum;
try { // be really paranoid now
@@ -1490,16 +1425,17 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
*
* @param action Intent action.
* @param data Intent data, or <code>null</code>.
- * @param query Intent query, or <code>null</code>.
* @param extraData Data for {@link SearchManager#EXTRA_DATA_KEY} or <code>null</code>.
+ * @param query Intent query, or <code>null</code>.
+ * @param componentName Data for {@link SearchManager#COMPONENT_NAME_KEY} or <code>null</code>.
* @param actionKey The key code of the action key that was pressed,
* or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
* @param actionMsg The message for the action key that was pressed,
* or <code>null</code> if none.
* @return The intent.
*/
- private Intent createIntent(String action, Uri data, String query, String extraData,
- int actionKey, String actionMsg) {
+ private Intent createIntent(String action, Uri data, String extraData, String query,
+ String componentName, int actionKey, String actionMsg) {
// Now build the Intent
Intent intent = new Intent(action);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -1512,6 +1448,9 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
if (extraData != null) {
intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
}
+ if (componentName != null) {
+ intent.putExtra(SearchManager.COMPONENT_NAME_KEY, componentName);
+ }
if (mAppSearchData != null) {
intent.putExtra(SearchManager.APP_DATA, mAppSearchData);
}
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 1ddd20a..eb80400 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -1165,6 +1165,14 @@ public class SearchManager
public final static String ACTION_KEY = "action_key";
/**
+ * Intent component name key: This key will be used for the extra populated by the
+ * {@link #SUGGEST_COLUMN_INTENT_COMPONENT_NAME} column.
+ *
+ * {@hide}
+ */
+ public final static String COMPONENT_NAME_KEY = "intent_component_name_key";
+
+ /**
* Intent extra data key: This key will be used for the extra populated by the
* {@link #SUGGEST_COLUMN_INTENT_EXTRA_DATA} column.
*
@@ -1364,14 +1372,24 @@ public class SearchManager
*/
public final static String SUGGEST_COLUMN_INTENT_DATA = "suggest_intent_data";
/**
+ * Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i>
+ * this element exists at the given row, this is the data that will be used when
+ * forming the suggestion's intent. If not provided, the Intent's extra data field will be null.
+ * This column allows suggestions to provide additional arbitrary data which will be included as
+ * an extra under the key EXTRA_DATA_KEY.
+ *
+ * @hide Pending API council approval.
+ */
+ public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data";
+ /**
* Column name for suggestions cursor. <i>Optional.</i> This column allows suggestions
* to provide additional arbitrary data which will be included as an extra under the key
- * {@link #EXTRA_DATA_KEY}. For use by the global search system only - if other providers
+ * {@link #COMPONENT_NAME_KEY}. For use by the global search system only - if other providers
* attempt to use this column, the value will be overwritten by global search.
*
* @hide
*/
- public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data";
+ public final static String SUGGEST_COLUMN_INTENT_COMPONENT_NAME = "suggest_intent_component";
/**
* Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i>
* this element exists at the given row, then "/" and this value will be appended to the data
diff --git a/core/java/android/backup/BackupDataInput.java b/core/java/android/backup/BackupDataInput.java
index 609dd90..69c206c 100644
--- a/core/java/android/backup/BackupDataInput.java
+++ b/core/java/android/backup/BackupDataInput.java
@@ -82,9 +82,9 @@ public class BackupDataInput {
}
}
- public int readEntityData(byte[] data, int size) throws IOException {
+ public int readEntityData(byte[] data, int offset, int size) throws IOException {
if (mHeaderReady) {
- int result = readEntityData_native(mBackupReader, data, size);
+ int result = readEntityData_native(mBackupReader, data, offset, size);
if (result >= 0) {
return result;
} else {
@@ -95,9 +95,23 @@ public class BackupDataInput {
}
}
+ public void skipEntityData() throws IOException {
+ if (mHeaderReady) {
+ int result = skipEntityData_native(mBackupReader);
+ if (result >= 0) {
+ return;
+ } else {
+ throw new IOException("result=0x" + Integer.toHexString(result));
+ }
+ } else {
+ throw new IllegalStateException("mHeaderReady=false");
+ }
+ }
+
private native static int ctor(FileDescriptor fd);
private native static void dtor(int mBackupReader);
private native int readNextHeader_native(int mBackupReader, EntityHeader entity);
- private native int readEntityData_native(int mBackupReader, byte[] data, int size);
+ private native int readEntityData_native(int mBackupReader, byte[] data, int offset, int size);
+ private native int skipEntityData_native(int mBackupReader);
}
diff --git a/core/java/android/backup/BackupDataInputStream.java b/core/java/android/backup/BackupDataInputStream.java
new file mode 100644
index 0000000..52b1675
--- /dev/null
+++ b/core/java/android/backup/BackupDataInputStream.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.backup;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/** @hide */
+public class BackupDataInputStream extends InputStream {
+
+ String key;
+ int dataSize;
+
+ BackupDataInput mData;
+ byte[] mOneByte;
+
+ BackupDataInputStream(BackupDataInput data) {
+ mData = data;
+ }
+
+ public int read() throws IOException {
+ byte[] one = mOneByte;
+ if (mOneByte == null) {
+ one = mOneByte = new byte[1];
+ }
+ mData.readEntityData(one, 0, 1);
+ return one[0];
+ }
+
+ public int read(byte[] b, int offset, int size) throws IOException {
+ return mData.readEntityData(b, offset, size);
+ }
+
+ public int read(byte[] b) throws IOException {
+ return mData.readEntityData(b, 0, b.length);
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public int size() {
+ return this.dataSize;
+ }
+}
+
+
diff --git a/core/java/android/backup/RestoreHelper.java b/core/java/android/backup/RestoreHelper.java
index ebd9906..ee8bedd 100644
--- a/core/java/android/backup/RestoreHelper.java
+++ b/core/java/android/backup/RestoreHelper.java
@@ -16,8 +16,16 @@
package android.backup;
+import java.io.InputStream;
+
/** @hide */
public interface RestoreHelper {
- public void performRestore();
+ /**
+ * Called by RestoreHelperDispatcher to dispatch one entity of data.
+ * <p class=note>
+ * Do not close the <code>data</code> stream. Do not read more than
+ * <code>dataSize</code> bytes from <code>data</code>.
+ */
+ public void performRestore(BackupDataInputStream data);
}
diff --git a/core/java/android/backup/RestoreHelperDistributor.java b/core/java/android/backup/RestoreHelperDispatcher.java
index 555ca79..cbfefdc 100644
--- a/core/java/android/backup/RestoreHelperDistributor.java
+++ b/core/java/android/backup/RestoreHelperDispatcher.java
@@ -16,13 +16,32 @@
package android.backup;
+import java.io.IOException;
import java.util.HashMap;
/** @hide */
-public class RestoreHelperDistributor {
+public class RestoreHelperDispatcher {
HashMap<String,RestoreHelper> mHelpers;
public void addHelper(String keyPrefix, RestoreHelper helper) {
mHelpers.put(keyPrefix, helper);
}
+
+ public void dispatch(BackupDataInput input) throws IOException {
+ BackupDataInputStream stream = new BackupDataInputStream(input);
+ while (input.readNextHeader()) {
+ String rawKey = input.getKey();
+ int pos = rawKey.indexOf(':');
+ if (pos > 0) {
+ String prefix = rawKey.substring(0, pos);
+ RestoreHelper helper = mHelpers.get(prefix);
+ if (helper != null) {
+ stream.dataSize = input.getDataSize();
+ stream.key = rawKey.substring(pos+1);
+ helper.performRestore(stream);
+ }
+ }
+ input.skipEntityData(); // In case they didn't consume the data.
+ }
+ }
}
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java
index 14323b8..5bfdcc4 100755
--- a/core/java/android/gesture/GestureOverlayView.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -84,7 +84,7 @@ public class GestureOverlayView extends FrameLayout {
private final Rect mInvalidRect = new Rect();
private final Path mPath = new Path();
- private boolean mGestureVisible;
+ private boolean mGestureVisible = true;
private float mX;
private float mY;
diff --git a/core/java/android/speech/tts/ITts.aidl b/core/java/android/speech/tts/ITts.aidl
index 739a8e4..02211fd 100755
--- a/core/java/android/speech/tts/ITts.aidl
+++ b/core/java/android/speech/tts/ITts.aidl
@@ -39,7 +39,7 @@ interface ITts {
void addSpeechFile(in String text, in String filename);
- void setLanguage(in String language);
+ void setLanguage(in String language, in String country, in String variant);
boolean synthesizeToFile(in String text, in String[] params, in String outputDirectory);
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java
index 2c0c09e..8f58194 100755
--- a/core/java/android/speech/tts/TextToSpeech.java
+++ b/core/java/android/speech/tts/TextToSpeech.java
@@ -22,13 +22,12 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import java.util.HashMap;
+import java.util.Locale;
/**
*
@@ -36,7 +35,7 @@ import java.util.HashMap;
*
* {@hide}
*/
-//TODO #TTS# review + complete javadoc
+//TODO #TTS# review + complete javadoc + add links to constants
public class TextToSpeech {
/**
@@ -52,9 +51,18 @@ public class TextToSpeech {
*/
public static final int TTS_ERROR_MISSING_RESOURCE = -2;
+ /**
+ * Queue mode where all entries in the playback queue (media to be played
+ * and text to be synthesized) are dropped and replaced by the new entry.
+ */
+ public static final int TTS_QUEUE_FLUSH = 0;
+ /**
+ * Queue mode where the new entry is added at the end of the playback queue.
+ */
+ public static final int TTS_QUEUE_ADD = 1;
/**
- * Called when the TTS has initialized
+ * Called when the TTS has initialized.
*
* The InitListener must implement the onInit function. onInit is passed a
* status code indicating the result of the TTS initialization.
@@ -73,9 +81,9 @@ public class TextToSpeech {
}
/**
- * Connection needed for the TTS
+ * Connection needed for the TTS.
*/
- private ServiceConnection serviceConnection;
+ private ServiceConnection mServiceConnection;
private ITts mITts = null;
private Context mContext = null;
@@ -104,8 +112,7 @@ public class TextToSpeech {
}
- public void setOnSpeechCompletedListener(
- final OnSpeechCompletedListener listener) {
+ public void setOnSpeechCompletedListener(final OnSpeechCompletedListener listener) {
synchronized(mSpeechCompListenerLock) {
mSpeechCompListener = listener;
}
@@ -126,7 +133,7 @@ public class TextToSpeech {
mStarted = false;
// Initialize the TTS, run the callback after the binding is successful
- serviceConnection = new ServiceConnection() {
+ mServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
synchronized(mStartLock) {
mITts = ITts.Stub.asInterface(service);
@@ -176,7 +183,7 @@ public class TextToSpeech {
Intent intent = new Intent("android.intent.action.USE_TTS");
intent.addCategory("android.intent.category.TTS");
- mContext.bindService(intent, serviceConnection,
+ mContext.bindService(intent, mServiceConnection,
Context.BIND_AUTO_CREATE);
// TODO handle case where the binding works (should always work) but
// the plugin fails
@@ -190,7 +197,7 @@ public class TextToSpeech {
*/
public void shutdown() {
try {
- mContext.unbindService(serviceConnection);
+ mContext.unbindService(mServiceConnection);
} catch (IllegalArgumentException e) {
// Do nothing and fail silently since an error here indicates that
// binding never succeeded in the first place.
@@ -291,8 +298,8 @@ public class TextToSpeech {
* @param text
* The string of text to be spoken.
* @param queueMode
- * The queuing strategy to use. Use 0 for no queuing, and 1 for
- * queuing.
+ * The queuing strategy to use.
+ * See TTS_QUEUE_ADD and TTS_QUEUE_FLUSH.
* @param params
* The hashmap of speech parameters to be used.
*/
@@ -329,12 +336,11 @@ public class TextToSpeech {
* @param earcon
* The earcon that should be played
* @param queueMode
- * 0 for no queue (interrupts all previous utterances), 1 for
- * queued
+ * See TTS_QUEUE_ADD and TTS_QUEUE_FLUSH.
* @param params
* The hashmap of parameters to be used.
*/
- public void playEarcon(String earcon, int queueMode,
+ public void playEarcon(String earcon, int queueMode,
HashMap<String,String> params) {
synchronized (mStartLock) {
if (!mStarted) {
@@ -358,8 +364,8 @@ public class TextToSpeech {
}
}
}
-
-
+
+
public void playSilence(long durationInMs, int queueMode) {
// TODO implement, already present in TTS service
}
@@ -429,20 +435,22 @@ public class TextToSpeech {
* Note that the speech rate is not universally supported by all engines and
* will be treated as a hint. The TTS library will try to use the specified
* speech rate, but there is no guarantee.
- *
- * Currently, this will change the speech rate for the espeak engine, but it
- * has no effect on any pre-recorded speech.
+ * This has no effect on any pre-recorded speech.
*
* @param speechRate
- * The speech rate for the TTS engine.
+ * The speech rate for the TTS engine. 1 is the normal speed,
+ * lower values slow down the speech (0.5 is half the normal speech rate),
+ * greater values accelerate it (2 is twice the normal speech rate).
*/
- public void setSpeechRate(int speechRate) {
+ public void setSpeechRate(float speechRate) {
synchronized (mStartLock) {
if (!mStarted) {
return;
}
try {
- mITts.setSpeechRate(speechRate);
+ if (speechRate > 0) {
+ mITts.setSpeechRate((int)(speechRate*100));
+ }
} catch (RemoteException e) {
// TTS died; restart it.
mStarted = false;
@@ -457,24 +465,18 @@ public class TextToSpeech {
*
* Note that the language is not universally supported by all engines and
* will be treated as a hint. The TTS library will try to use the specified
- * language, but there is no guarantee.
- *
- * Currently, this will change the language for the espeak engine, but it
- * has no effect on any pre-recorded speech.
+ * language as represented by the Locale, but there is no guarantee.
*
- * @param language
- * The language to be used. The languages are specified by their
- * IETF language tags as defined by BCP 47. This is the same
- * standard used for the lang attribute in HTML. See:
- * http://en.wikipedia.org/wiki/IETF_language_tag
+ * @param loc
+ * The locale describing the language to be used.
*/
- public void setLanguage(String language) {
+ public void setLanguage(Locale loc) {
synchronized (mStartLock) {
if (!mStarted) {
return;
}
try {
- mITts.setLanguage(language);
+ mITts.setLanguage(loc.getISO3Language(), loc.getISO3Country(), loc.getVariant());
} catch (RemoteException e) {
// TTS died; restart it.
mStarted = false;
diff --git a/core/java/com/android/internal/backup/IBackupTransport.aidl b/core/java/com/android/internal/backup/IBackupTransport.aidl
index 9daabca..84ed729 100644
--- a/core/java/com/android/internal/backup/IBackupTransport.aidl
+++ b/core/java/com/android/internal/backup/IBackupTransport.aidl
@@ -42,11 +42,14 @@ interface IBackupTransport {
*/
/**
* Verify that this is a suitable time for a backup pass. This should return zero
- * if a backup is reasonable right now, false otherwise. This method will be called
- * outside of the {@link #startSession}/{@link #endSession} pair.
+ * if a backup is reasonable right now, some positive value otherwise. This method
+ * will be called outside of the {@link #startSession}/{@link #endSession} pair.
*
- * <p>If this is not a suitable time for a backup, the transport should suggest a
+ * <p>If this is not a suitable time for a backup, the transport should return a
* backoff delay, in milliseconds, after which the Backup Manager should try again.
+ *
+ * @return Zero if this is a suitable time for a backup pass, or a positive time delay
+ * in milliseconds to suggest deferring the backup pass for a while.
*/
long requestBackupTime();
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index 5da0883..123c072 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -84,7 +84,7 @@ public class LocalTransport extends IBackupTransport.Stub {
bufSize = dataSize;
buf = new byte[bufSize];
}
- changeSet.readEntityData(buf, dataSize);
+ changeSet.readEntityData(buf, 0, dataSize);
if (DEBUG) Log.v(TAG, " + data size " + dataSize);
File entityFile = new File(packageDir, key);