diff options
| -rw-r--r-- | api/current.xml | 4 | ||||
| -rw-r--r-- | core/java/android/app/SearchManager.java | 9 | ||||
| -rw-r--r-- | core/java/android/backup/BackupManager.java | 3 | ||||
| -rwxr-xr-x | core/java/android/speech/tts/ITts.aidl | 24 | ||||
| -rw-r--r-- | core/java/android/speech/tts/TextToSpeech.java | 23 | ||||
| -rw-r--r-- | core/java/android/webkit/WebSettings.java | 171 | ||||
| -rw-r--r-- | libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp | 2 | ||||
| -rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.cpp | 7 | ||||
| -rwxr-xr-x | packages/TtsService/src/android/tts/TtsService.java | 145 | ||||
| -rw-r--r-- | services/java/com/android/server/WifiService.java | 210 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiStateTracker.java | 13 |
11 files changed, 126 insertions, 485 deletions
diff --git a/api/current.xml b/api/current.xml index 9ed9b76b1a8e..b17466f1a290 100644 --- a/api/current.xml +++ b/api/current.xml @@ -25846,7 +25846,7 @@ synchronized="false" static="false" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > <parameter name="dialog" type="android.content.DialogInterface"> @@ -25859,7 +25859,7 @@ synchronized="false" static="false" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > <parameter name="dialog" type="android.content.DialogInterface"> diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index 5d25f10e3401..0291882b8a4e 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -1719,11 +1719,16 @@ public class SearchManager } - // TODO: remove the DialogInterface interfaces from SearchManager. - // This changes the public API, so I'll do it in a separate change. + /** + * @deprecated This method is an obsolete internal implementation detail. Do not use. + */ public void onCancel(DialogInterface dialog) { throw new UnsupportedOperationException(); } + + /** + * @deprecated This method is an obsolete internal implementation detail. Do not use. + */ public void onDismiss(DialogInterface dialog) { throw new UnsupportedOperationException(); } diff --git a/core/java/android/backup/BackupManager.java b/core/java/android/backup/BackupManager.java index 34a1a0c8f2f4..86d89218c766 100644 --- a/core/java/android/backup/BackupManager.java +++ b/core/java/android/backup/BackupManager.java @@ -42,6 +42,9 @@ import android.util.Log; public class BackupManager { private static final String TAG = "BackupManager"; + /** @hide TODO: REMOVE THIS */ + public static final boolean EVEN_THINK_ABOUT_DOING_RESTORE = true; + private Context mContext; private static IBackupManager sService; diff --git a/core/java/android/speech/tts/ITts.aidl b/core/java/android/speech/tts/ITts.aidl index c9a6180d4e69..5b18b5d8d785 100755 --- a/core/java/android/speech/tts/ITts.aidl +++ b/core/java/android/speech/tts/ITts.aidl @@ -27,37 +27,37 @@ import android.content.Intent; * {@hide}
*/
interface ITts {
- int setSpeechRate(in int speechRate);
+ int setSpeechRate(in String callingApp, in int speechRate);
- int setPitch(in int pitch);
+ int setPitch(in String callingApp, in int pitch);
- int speak(in String text, in int queueMode, in String[] params);
+ int speak(in String callingApp, in String text, in int queueMode, in String[] params);
boolean isSpeaking();
- int stop();
+ int stop(in String callingApp);
- void addSpeech(in String text, in String packageName, in int resId);
+ void addSpeech(in String callingApp, in String text, in String packageName, in int resId);
- void addSpeechFile(in String text, in String filename);
+ void addSpeechFile(in String callingApp, in String text, in String filename);
String[] getLanguage();
int isLanguageAvailable(in String language, in String country, in String variant);
- int setLanguage(in String language, in String country, in String variant);
+ int setLanguage(in String callingApp, in String language, in String country, in String variant);
- boolean synthesizeToFile(in String text, in String[] params, in String outputDirectory);
+ boolean synthesizeToFile(in String callingApp, in String text, in String[] params, in String outputDirectory);
- int playEarcon(in String earcon, in int queueMode, in String[] params);
+ int playEarcon(in String callingApp, in String earcon, in int queueMode, in String[] params);
- void addEarcon(in String earcon, in String packageName, in int resId);
+ void addEarcon(in String callingApp, in String earcon, in String packageName, in int resId);
- void addEarconFile(in String earcon, in String filename);
+ void addEarconFile(in String callingApp, in String earcon, in String filename);
void registerCallback(ITtsCallback cb);
void unregisterCallback(ITtsCallback cb);
- int playSilence(in long duration, in int queueMode, in String[] params);
+ int playSilence(in String callingApp, in long duration, in int queueMode, in String[] params);
}
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index ed1e4ff63923..e09eb042ab74 100644 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -139,6 +139,7 @@ public class TextToSpeech { private ITts mITts = null; private Context mContext = null; + private String mPackageName = ""; private OnInitListener mInitListener = null; private boolean mStarted = false; private final Object mStartLock = new Object(); @@ -159,6 +160,7 @@ public class TextToSpeech { */ public TextToSpeech(Context context, OnInitListener listener) { mContext = context; + mPackageName = mContext.getPackageName(); mInitListener = listener; mCachedParams = new String[2*4]; // 4 parameters, store key and value @@ -261,7 +263,7 @@ public class TextToSpeech { return TTS_ERROR; } try { - mITts.addSpeech(text, packagename, resourceId); + mITts.addSpeech(mPackageName, text, packagename, resourceId); return TTS_SUCCESS; } catch (RemoteException e) { // TTS died; restart it. @@ -299,7 +301,7 @@ public class TextToSpeech { return TTS_ERROR; } try { - mITts.addSpeechFile(text, filename); + mITts.addSpeechFile(mPackageName, text, filename); return TTS_SUCCESS; } catch (RemoteException e) { // TTS died; restart it. @@ -346,7 +348,7 @@ public class TextToSpeech { } try { // TODO support extra parameters, passing cache of current parameters for the moment - result = mITts.speak(text, queueMode, mCachedParams); + result = mITts.speak(mPackageName, text, queueMode, mCachedParams); } catch (RemoteException e) { // TTS died; restart it. mStarted = false; @@ -387,7 +389,7 @@ public class TextToSpeech { } try { // TODO support extra parameters, passing null for the moment - result = mITts.playEarcon(earcon, queueMode, null); + result = mITts.playEarcon(mPackageName, earcon, queueMode, null); } catch (RemoteException e) { // TTS died; restart it. mStarted = false; @@ -425,7 +427,7 @@ public class TextToSpeech { } try { // TODO support extra parameters, passing cache of current parameters for the moment - result = mITts.playSilence(durationInMs, queueMode, mCachedParams); + result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams); } catch (RemoteException e) { // TTS died; restart it. mStarted = false; @@ -487,7 +489,7 @@ public class TextToSpeech { return result; } try { - result = mITts.stop(); + result = mITts.stop(mPackageName); } catch (RemoteException e) { // TTS died; restart it. mStarted = false; @@ -532,7 +534,7 @@ public class TextToSpeech { if (speechRate > 0) { int rate = (int)(speechRate*100); mCachedParams[Engine.TTS_PARAM_POSITION_RATE + 1] = String.valueOf(rate); - result = mITts.setSpeechRate(rate); + result = mITts.setSpeechRate(mPackageName, rate); } } catch (RemoteException e) { // TTS died; restart it. @@ -568,7 +570,7 @@ public class TextToSpeech { } try { if (pitch > 0) { - result = mITts.setPitch((int)(pitch*100)); + result = mITts.setPitch(mPackageName, (int)(pitch*100)); } } catch (RemoteException e) { // TTS died; restart it. @@ -603,7 +605,8 @@ public class TextToSpeech { mCachedParams[Engine.TTS_PARAM_POSITION_LANGUAGE + 1] = loc.getISO3Language(); mCachedParams[Engine.TTS_PARAM_POSITION_COUNTRY + 1] = loc.getISO3Country(); mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] = loc.getVariant(); - result = mITts.setLanguage(mCachedParams[Engine.TTS_PARAM_POSITION_LANGUAGE + 1], + result = mITts.setLanguage(mPackageName, + mCachedParams[Engine.TTS_PARAM_POSITION_LANGUAGE + 1], mCachedParams[Engine.TTS_PARAM_POSITION_COUNTRY + 1], mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] ); } catch (RemoteException e) { @@ -694,7 +697,7 @@ public class TextToSpeech { } try { // TODO support extra parameters, passing null for the moment - if (mITts.synthesizeToFile(text, null, filename)){ + if (mITts.synthesizeToFile(mPackageName, text, null, filename)){ result = TTS_SUCCESS; } } catch (RemoteException e) { diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java index f02d43c26b9d..8f3d55f8f676 100644 --- a/core/java/android/webkit/WebSettings.java +++ b/core/java/android/webkit/WebSettings.java @@ -16,27 +16,13 @@ package android.webkit; -import android.content.ContentValues; import android.content.Context; -import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.os.Build; import android.os.Handler; import android.os.Message; -import android.preference.PreferenceManager; import android.provider.Checkin; -import android.provider.Settings; -import android.util.Log; - -import java.io.File; import java.lang.SecurityException; - -import android.content.SharedPreferences.Editor; -import android.content.pm.PackageManager; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteException; -import android.database.sqlite.SQLiteStatement; - -import java.util.HashSet; import java.util.Locale; /** @@ -197,43 +183,6 @@ public class WebSettings { private boolean mAppCacheEnabled = false; private boolean mDomStorageEnabled = false; - // Donut-specific hack to keep Gears permissions in sync with the - // system location setting. - // TODO: Make sure this hack is removed in Eclair, when Gears - // is also removed. - // Used to remember if we checked the Gears permissions already. - static boolean mCheckedGearsPermissions = false; - // The Gears permissions database directory. - private final static String GEARS_DATABASE_DIR = "gears"; - // The Gears permissions database file name. - private final static String GEARS_DATABASE_FILE = "permissions.db"; - // The Gears location permissions table. - private final static String GEARS_LOCATION_ACCESS_TABLE_NAME = - "LocationAccess"; - // The Gears storage access permissions table. - private final static String GEARS_STORAGE_ACCESS_TABLE_NAME = "Access"; - // The Gears permissions db schema version table. - private final static String GEARS_SCHEMA_VERSION_TABLE_NAME = - "VersionInfo"; - // The shared pref name. - private static final String LAST_KNOWN_LOCATION_SETTING = - "lastKnownLocationSystemSetting"; - // The Browser package name. - private static final String BROWSER_PACKAGE_NAME = "com.android.browser"; - // The Google URLs whitelisted for Gears location access. - private static HashSet<String> sGearsWhiteList; - - static { - sGearsWhiteList = new HashSet<String>(); - // NOTE: DO NOT ADD A "/" AT THE END! - sGearsWhiteList.add("http://www.google.com"); - sGearsWhiteList.add("http://www.google.co.uk"); - } - - private static final String LOGTAG = "webcore"; - static final boolean DEBUG = false; - static final boolean LOGV_ENABLED = DEBUG; - // Class to handle messages before WebCore is ready. private class EventHandler { // Message id for syncing @@ -254,7 +203,6 @@ public class WebSettings { switch (msg.what) { case SYNC: synchronized (WebSettings.this) { - checkGearsPermissions(); if (mBrowserFrame.mNativeFrame != 0) { nativeSync(mBrowserFrame.mNativeFrame); } @@ -1327,123 +1275,6 @@ public class WebSettings { return size; } - private void checkGearsPermissions() { - // Did we already check the permissions? - if (mCheckedGearsPermissions) { - return; - } - // Are we running in the browser? - if (!BROWSER_PACKAGE_NAME.equals(mContext.getPackageName())) { - return; - } - - // Remember we checked the Gears permissions. - mCheckedGearsPermissions = true; - // Get the current system settings. - int setting = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.USE_LOCATION_FOR_SERVICES, -1); - // Check if we need to set the Gears permissions. - if (setting != -1 && locationSystemSettingChanged(setting)) { - setGearsPermissionForGoogleDomains(setting); - } - } - - private boolean locationSystemSettingChanged(int newSetting) { - SharedPreferences prefs = - PreferenceManager.getDefaultSharedPreferences(mContext); - int oldSetting = 0; - oldSetting = prefs.getInt(LAST_KNOWN_LOCATION_SETTING, oldSetting); - if (oldSetting == newSetting) { - return false; - } - Editor ed = prefs.edit(); - ed.putInt(LAST_KNOWN_LOCATION_SETTING, newSetting); - ed.commit(); - return true; - } - - private void setGearsPermissionForGoogleDomains(int systemPermission) { - // Transform the system permission into a Gears permission - int gearsPermission = (systemPermission == 1 ? 1 : 2); - // Build the path to the Gears library. - - // hack for now - File file = mContext.getDir("plugins", 0); - if (file == null) { - return; - } - file = file.getParentFile(); - // Build the Gears database file name. - file = new File(file.getAbsolutePath() + File.separator - + GEARS_DATABASE_DIR + File.separator + GEARS_DATABASE_FILE); - // Remember whether or not we need to create the LocationAccess table. - boolean needToCreateTables = !file.exists(); - // Try opening the Gears database. - SQLiteDatabase permissions; - try { - permissions = SQLiteDatabase.openOrCreateDatabase(file, null); - } catch (SQLiteException e) { - if (LOGV_ENABLED) { - Log.v(LOGTAG, "Could not open Gears permission DB: " + - e.getMessage()); - } - // Just bail out. - return; - } - // We now have a database open. Begin a transaction. - permissions.beginTransaction(); - try { - if (needToCreateTables) { - // Create the tables. Note that this creates the - // Gears tables for the permissions DB schema version 2. - // The Gears schema upgrade process will take care of the rest. - // First, the storage access table. - SQLiteStatement statement = permissions.compileStatement( - "CREATE TABLE IF NOT EXISTS " + - GEARS_STORAGE_ACCESS_TABLE_NAME + - " (Name TEXT UNIQUE, Value)"); - statement.execute(); - // Next the location access table. - statement = permissions.compileStatement( - "CREATE TABLE IF NOT EXISTS " + - GEARS_LOCATION_ACCESS_TABLE_NAME + - " (Name TEXT UNIQUE, Value)"); - statement.execute(); - // Finally, the schema version table. - statement = permissions.compileStatement( - "CREATE TABLE IF NOT EXISTS " + - GEARS_SCHEMA_VERSION_TABLE_NAME + - " (Name TEXT UNIQUE, Value)"); - statement.execute(); - // Set the schema version to 2. - ContentValues schema = new ContentValues(); - schema.put("Name", "Version"); - schema.put("Value", 2); - permissions.insert(GEARS_SCHEMA_VERSION_TABLE_NAME, null, - schema); - } - - ContentValues permissionValues = new ContentValues(); - - for (String url : sGearsWhiteList) { - permissionValues.put("Name", url); - permissionValues.put("Value", gearsPermission); - permissions.replace(GEARS_LOCATION_ACCESS_TABLE_NAME, null, - permissionValues); - permissionValues.clear(); - } - // Commit the transaction. - permissions.setTransactionSuccessful(); - } catch (SQLiteException e) { - if (LOGV_ENABLED) { - Log.v(LOGTAG, "Could not set the Gears permissions: " + - e.getMessage()); - } - } finally { - permissions.endTransaction(); - permissions.close(); - } - } /* Post a SYNC message to handle syncing the native settings. */ private synchronized void postSync() { // Only post if a sync is not pending diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 5c522c5453ef..21f87e377894 100644 --- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -219,7 +219,7 @@ void DisplayHardware::init(uint32_t dpy) mDpiX = mNativeWindow->xdpi; - mDpiX = mNativeWindow->ydpi; + mDpiY = mNativeWindow->ydpi; mRefreshRate = fbDev->fps; char property[PROPERTY_VALUE_MAX]; diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index 5ac1cfd932c9..7a7574f57771 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -1212,6 +1212,13 @@ sp<ISurface> SurfaceFlinger::createSurface(ClientID clientId, int pid, { sp<LayerBaseClient> layer; sp<LayerBaseClient::Surface> surfaceHandle; + + if (int32_t(w|h) < 0) { + LOGE("createSurface() failed, w or h is negative (w=%d, h=%d)", + int(w), int(h)); + return surfaceHandle; + } + Mutex::Autolock _l(mStateLock); sp<Client> client = mClientsMap.valueFor(clientId); if (UNLIKELY(client == 0)) { diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java index 1eba4694d611..ea224103d741 100755 --- a/packages/TtsService/src/android/tts/TtsService.java +++ b/packages/TtsService/src/android/tts/TtsService.java @@ -59,23 +59,27 @@ public class TtsService extends Service implements OnCompletionListener { public int mType = TEXT; public long mDuration = 0; public String mFilename = null; + public String callingApp = ""; - public SpeechItem(String text, ArrayList<String> params, int itemType) { + public SpeechItem(String source, String text, ArrayList<String> params, int itemType) { mText = text; mParams = params; mType = itemType; + callingApp = source; } - public SpeechItem(long silenceTime) { + public SpeechItem(String source, long silenceTime) { mDuration = silenceTime; mType = SILENCE; + callingApp = source; } - public SpeechItem(String text, ArrayList<String> params, int itemType, String filename) { + public SpeechItem(String source, String text, ArrayList<String> params, int itemType, String filename) { mText = text; mParams = params; mType = itemType; mFilename = filename; + callingApp = source; } } @@ -161,10 +165,10 @@ public class TtsService extends Service implements OnCompletionListener { private void setDefaultSettings() { - setLanguage(this.getDefaultLanguage(), getDefaultCountry(), getDefaultLocVariant()); + setLanguage("", this.getDefaultLanguage(), getDefaultCountry(), getDefaultLocVariant()); // speech rate - setSpeechRate(getDefaultRate()); + setSpeechRate("", getDefaultRate()); } @@ -219,7 +223,7 @@ public class TtsService extends Service implements OnCompletionListener { } - private int setSpeechRate(int rate) { + private int setSpeechRate(String callingApp, int rate) { if (isDefaultEnforced()) { return nativeSynth.setSpeechRate(getDefaultRate()); } else { @@ -228,7 +232,7 @@ public class TtsService extends Service implements OnCompletionListener { } - private int setPitch(int pitch) { + private int setPitch(String callingApp, int pitch) { return nativeSynth.setPitch(pitch); } @@ -244,7 +248,7 @@ public class TtsService extends Service implements OnCompletionListener { } - private int setLanguage(String lang, String country, String variant) { + private int setLanguage(String callingApp, String lang, String country, String variant) { //Log.v("TTS", "TtsService.setLanguage(" + lang + ", " + country + ", " + variant + ")"); if (isDefaultEnforced()) { return nativeSynth.setLanguage(getDefaultLanguage(), getDefaultCountry(), @@ -265,7 +269,7 @@ public class TtsService extends Service implements OnCompletionListener { * @param resId * The resource ID of the sound within its package */ - private void addSpeech(String text, String packageName, int resId) { + private void addSpeech(String callingApp, String text, String packageName, int resId) { mUtterances.put(text, new SoundResource(packageName, resId)); } @@ -278,7 +282,7 @@ public class TtsService extends Service implements OnCompletionListener { * The filename of the sound resource. This must be a complete * path like: (/sdcard/mysounds/mysoundbite.mp3). */ - private void addSpeech(String text, String filename) { + private void addSpeech(String callingApp, String text, String filename) { mUtterances.put(text, new SoundResource(filename)); } @@ -292,7 +296,7 @@ public class TtsService extends Service implements OnCompletionListener { * @param resId * The resource ID of the sound within its package */ - private void addEarcon(String earcon, String packageName, int resId) { + private void addEarcon(String callingApp, String earcon, String packageName, int resId) { mEarcons.put(earcon, new SoundResource(packageName, resId)); } @@ -305,7 +309,7 @@ public class TtsService extends Service implements OnCompletionListener { * The filename of the sound resource. This must be a complete * path like: (/sdcard/mysounds/mysoundbite.mp3). */ - private void addEarcon(String earcon, String filename) { + private void addEarcon(String callingApp, String earcon, String filename) { mEarcons.put(earcon, new SoundResource(filename)); } @@ -315,17 +319,17 @@ public class TtsService extends Service implements OnCompletionListener { * @param text * The text that should be spoken * @param queueMode - * 0 for no queue (interrupts all previous utterances), 1 for - * queued + * TextToSpeech.TTS_QUEUE_FLUSH for no queue (interrupts all previous utterances), + * TextToSpeech.TTS_QUEUE_ADD for queued * @param params * An ArrayList of parameters. This is not implemented for all * engines. */ - private int speak(String text, int queueMode, ArrayList<String> params) { - if (queueMode == 0) { - stop(); + private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) { + if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { + stop(callingApp); } - mSpeechQueue.add(new SpeechItem(text, params, SpeechItem.TEXT)); + mSpeechQueue.add(new SpeechItem(callingApp, text, params, SpeechItem.TEXT)); if (!mIsSpeaking) { processSpeechQueue(); } @@ -338,18 +342,18 @@ public class TtsService extends Service implements OnCompletionListener { * @param earcon * The earcon that should be played * @param queueMode - * 0 for no queue (interrupts all previous utterances), 1 for - * queued + * TextToSpeech.TTS_QUEUE_FLUSH for no queue (interrupts all previous utterances), + * TextToSpeech.TTS_QUEUE_ADD for queued * @param params * An ArrayList of parameters. This is not implemented for all * engines. */ - private int playEarcon(String earcon, int queueMode, + private int playEarcon(String callingApp, String earcon, int queueMode, ArrayList<String> params) { - if (queueMode == 0) { - stop(); + if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { + stop(callingApp); } - mSpeechQueue.add(new SpeechItem(earcon, params, SpeechItem.EARCON)); + mSpeechQueue.add(new SpeechItem(callingApp, earcon, params, SpeechItem.EARCON)); if (!mIsSpeaking) { processSpeechQueue(); } @@ -359,7 +363,7 @@ public class TtsService extends Service implements OnCompletionListener { /** * Stops all speech output and removes any utterances still in the queue. */ - private int stop() { + private int stop(String callingApp) { int result = TextToSpeech.TTS_ERROR; boolean speechQueueAvailable = false; try{ @@ -368,7 +372,11 @@ public class TtsService extends Service implements OnCompletionListener { speechQueueAvailable = speechQueueLock.tryLock(1000, TimeUnit.MILLISECONDS); if (speechQueueAvailable) { Log.i("TTS", "Stopping"); - mSpeechQueue.clear(); + for (int i = mSpeechQueue.size() - 1; i > -1; i--){ + if (mSpeechQueue.get(i).callingApp.equals(callingApp)){ + mSpeechQueue.remove(i); + } + } result = nativeSynth.stop(); mIsSpeaking = false; @@ -398,12 +406,12 @@ public class TtsService extends Service implements OnCompletionListener { processSpeechQueue(); } - private int playSilence(long duration, int queueMode, + private int playSilence(String callingApp, long duration, int queueMode, ArrayList<String> params) { - if (queueMode == 0) { - stop(); + if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { + stop(callingApp); } - mSpeechQueue.add(new SpeechItem(duration)); + mSpeechQueue.add(new SpeechItem(callingApp, duration)); if (!mIsSpeaking) { processSpeechQueue(); } @@ -448,7 +456,7 @@ public class TtsService extends Service implements OnCompletionListener { for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ - setSpeechRate(Integer.parseInt(params.get(i+1))); + setSpeechRate("", Integer.parseInt(params.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ language = params.get(i+1); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ @@ -458,7 +466,7 @@ public class TtsService extends Service implements OnCompletionListener { } } if (language.length() > 0){ - setLanguage(language, country, variant); + setLanguage("", language, country, variant); } } nativeSynth.speak(text); @@ -503,7 +511,7 @@ public class TtsService extends Service implements OnCompletionListener { for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ - setSpeechRate(Integer.parseInt(params.get(i+1))); + setSpeechRate("", Integer.parseInt(params.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ language = params.get(i+1); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ @@ -513,7 +521,7 @@ public class TtsService extends Service implements OnCompletionListener { } } if (language.length() > 0){ - setLanguage(language, country, variant); + setLanguage("", language, country, variant); } } nativeSynth.synthesizeToFile(text, filename); @@ -574,6 +582,7 @@ public class TtsService extends Service implements OnCompletionListener { if (currentSpeechItem.mText.length() < MAX_SPEECH_ITEM_CHAR_LENGTH){ return currentSpeechItem; } else { + String callingApp = currentSpeechItem.callingApp; ArrayList<SpeechItem> splitItems = new ArrayList<SpeechItem>(); int start = 0; int end = start + MAX_SPEECH_ITEM_CHAR_LENGTH - 1; @@ -581,13 +590,13 @@ public class TtsService extends Service implements OnCompletionListener { SpeechItem splitItem; while (end < currentSpeechItem.mText.length()){ splitText = currentSpeechItem.mText.substring(start, end); - splitItem = new SpeechItem(splitText, null, SpeechItem.TEXT); + splitItem = new SpeechItem(callingApp, splitText, null, SpeechItem.TEXT); splitItems.add(splitItem); start = end; end = start + MAX_SPEECH_ITEM_CHAR_LENGTH - 1; } splitText = currentSpeechItem.mText.substring(start); - splitItem = new SpeechItem(splitText, null, SpeechItem.TEXT); + splitItem = new SpeechItem(callingApp, splitText, null, SpeechItem.TEXT); splitItems.add(splitItem); mSpeechQueue.remove(0); for (int i = splitItems.size() - 1; i >= 0; i--){ @@ -701,7 +710,7 @@ public class TtsService extends Service implements OnCompletionListener { * something like "/sdcard/myappsounds/mysound.wav". * @return A boolean that indicates if the synthesis succeeded */ - private boolean synthesizeToFile(String text, ArrayList<String> params, + private boolean synthesizeToFile(String callingApp, String text, ArrayList<String> params, String filename) { // Don't allow a filename that is too long if (filename.length() > MAX_FILENAME_LENGTH) { @@ -712,7 +721,7 @@ public class TtsService extends Service implements OnCompletionListener { if (text.length() >= MAX_SPEECH_ITEM_CHAR_LENGTH){ return false; } - mSpeechQueue.add(new SpeechItem(text, params, SpeechItem.TEXT_TO_FILE, filename)); + mSpeechQueue.add(new SpeechItem(callingApp, text, params, SpeechItem.TEXT_TO_FILE, filename)); if (!mIsSpeaking) { processSpeechQueue(); } @@ -750,18 +759,18 @@ public class TtsService extends Service implements OnCompletionListener { * @param text * The text that should be spoken * @param queueMode - * 0 for no queue (interrupts all previous utterances), 1 for - * queued + * TextToSpeech.TTS_QUEUE_FLUSH for no queue (interrupts all previous utterances) + * TextToSpeech.TTS_QUEUE_ADD for queued * @param params * An ArrayList of parameters. The first element of this * array controls the type of voice to use. */ - public int speak(String text, int queueMode, String[] params) { + public int speak(String callingApp, String text, int queueMode, String[] params) { ArrayList<String> speakingParams = new ArrayList<String>(); if (params != null) { speakingParams = new ArrayList<String>(Arrays.asList(params)); } - return mSelf.speak(text, queueMode, speakingParams); + return mSelf.speak(callingApp, text, queueMode, speakingParams); } /** @@ -770,17 +779,17 @@ public class TtsService extends Service implements OnCompletionListener { * @param earcon * The earcon that should be played * @param queueMode - * 0 for no queue (interrupts all previous utterances), 1 for - * queued + * TextToSpeech.TTS_QUEUE_FLUSH for no queue (interrupts all previous utterances) + * TextToSpeech.TTS_QUEUE_ADD for queued * @param params * An ArrayList of parameters. */ - public int playEarcon(String earcon, int queueMode, String[] params) { + public int playEarcon(String callingApp, String earcon, int queueMode, String[] params) { ArrayList<String> speakingParams = new ArrayList<String>(); if (params != null) { speakingParams = new ArrayList<String>(Arrays.asList(params)); } - return mSelf.playEarcon(earcon, queueMode, speakingParams); + return mSelf.playEarcon(callingApp, earcon, queueMode, speakingParams); } /** @@ -789,25 +798,25 @@ public class TtsService extends Service implements OnCompletionListener { * @param duration * The duration of the silence that should be played * @param queueMode - * 0 for no queue (interrupts all previous utterances), 1 for - * queued + * TextToSpeech.TTS_QUEUE_FLUSH for no queue (interrupts all previous utterances) + * TextToSpeech.TTS_QUEUE_ADD for queued * @param params * An ArrayList of parameters. */ - public int playSilence(long duration, int queueMode, String[] params) { + public int playSilence(String callingApp, long duration, int queueMode, String[] params) { ArrayList<String> speakingParams = new ArrayList<String>(); if (params != null) { speakingParams = new ArrayList<String>(Arrays.asList(params)); } - return mSelf.playSilence(duration, queueMode, speakingParams); + return mSelf.playSilence(callingApp, duration, queueMode, speakingParams); } /** * Stops all speech output and removes any utterances still in the * queue. */ - public int stop() { - return mSelf.stop(); + public int stop(String callingApp) { + return mSelf.stop(callingApp); } /** @@ -829,8 +838,8 @@ public class TtsService extends Service implements OnCompletionListener { * @param resId * The resource ID of the sound within its package */ - public void addSpeech(String text, String packageName, int resId) { - mSelf.addSpeech(text, packageName, resId); + public void addSpeech(String callingApp, String text, String packageName, int resId) { + mSelf.addSpeech(callingApp, text, packageName, resId); } /** @@ -842,8 +851,8 @@ public class TtsService extends Service implements OnCompletionListener { * The filename of the sound resource. This must be a * complete path like: (/sdcard/mysounds/mysoundbite.mp3). */ - public void addSpeechFile(String text, String filename) { - mSelf.addSpeech(text, filename); + public void addSpeechFile(String callingApp, String text, String filename) { + mSelf.addSpeech(callingApp, text, filename); } /** @@ -856,8 +865,8 @@ public class TtsService extends Service implements OnCompletionListener { * @param resId * The resource ID of the sound within its package */ - public void addEarcon(String earcon, String packageName, int resId) { - mSelf.addEarcon(earcon, packageName, resId); + public void addEarcon(String callingApp, String earcon, String packageName, int resId) { + mSelf.addEarcon(callingApp, earcon, packageName, resId); } /** @@ -869,8 +878,8 @@ public class TtsService extends Service implements OnCompletionListener { * The filename of the sound resource. This must be a * complete path like: (/sdcard/mysounds/mysoundbite.mp3). */ - public void addEarconFile(String earcon, String filename) { - mSelf.addEarcon(earcon, filename); + public void addEarconFile(String callingApp, String earcon, String filename) { + mSelf.addEarcon(callingApp, earcon, filename); } /** @@ -880,8 +889,8 @@ public class TtsService extends Service implements OnCompletionListener { * @param speechRate * The speech rate that should be used */ - public int setSpeechRate(int speechRate) { - return mSelf.setSpeechRate(speechRate); + public int setSpeechRate(String callingApp, int speechRate) { + return mSelf.setSpeechRate(callingApp, speechRate); } /** @@ -891,8 +900,8 @@ public class TtsService extends Service implements OnCompletionListener { * @param pitch * The pitch that should be used for the synthesized voice */ - public int setPitch(int pitch) { - return mSelf.setPitch(pitch); + public int setPitch(String callingApp, int pitch) { + return mSelf.setPitch(callingApp, pitch); } /** @@ -926,8 +935,8 @@ public class TtsService extends Service implements OnCompletionListener { * @param country the three letter ISO country code. * @param variant the variant code associated with the country and language pair. */ - public int setLanguage(String lang, String country, String variant) { - return mSelf.setLanguage(lang, country, variant); + public int setLanguage(String callingApp, String lang, String country, String variant) { + return mSelf.setLanguage(callingApp, lang, country, variant); } /** @@ -944,13 +953,13 @@ public class TtsService extends Service implements OnCompletionListener { * be something like "/sdcard/myappsounds/mysound.wav". * @return A boolean that indicates if the synthesis succeeded */ - public boolean synthesizeToFile(String text, String[] params, + public boolean synthesizeToFile(String callingApp, String text, String[] params, String filename) { ArrayList<String> speakingParams = new ArrayList<String>(); if (params != null) { speakingParams = new ArrayList<String>(Arrays.asList(params)); } - return mSelf.synthesizeToFile(text, speakingParams, filename); + return mSelf.synthesizeToFile(callingApp, text, speakingParams, filename); } }; diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index e612a04e6509..55b7a30a7b16 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -142,28 +142,6 @@ public class WifiService extends IWifiManager.Stub { private final WifiHandler mWifiHandler; /* - * Map used to keep track of hidden networks presence, which - * is needed to switch between active and passive scan modes. - * If there is at least one hidden network that is currently - * present (enabled), we want to do active scans instead of - * passive. - */ - private final Map<Integer, Boolean> mIsHiddenNetworkPresent; - /* - * The number of currently present hidden networks. When this - * counter goes from 0 to 1 or from 1 to 0, we change the - * scan mode to active or passive respectively. Initially, we - * set the counter to 0 and we increment it every time we add - * a new present (enabled) hidden network. - */ - private int mNumHiddenNetworkPresent; - /* - * Whether we change the scan mode is due to a hidden network - * (in this class, this is always the case) - */ - private final static boolean SET_DUE_TO_A_HIDDEN_NETWORK = true; - - /* * Cache of scan results objects (size is somewhat arbitrary) */ private static final int SCAN_RESULT_CACHE_SIZE = 80; @@ -194,12 +172,6 @@ public class WifiService extends IWifiManager.Stub { mWifiStateTracker = tracker; mBatteryStats = BatteryStatsService.getService(); - /* - * Initialize the hidden-networks state - */ - mIsHiddenNetworkPresent = new HashMap<Integer, Boolean>(); - mNumHiddenNetworkPresent = 0; - mScanResultCache = new LinkedHashMap<String, ScanResult>( SCAN_RESULT_CACHE_SIZE, 0.75f, true) { /* @@ -253,155 +225,6 @@ public class WifiService extends IWifiManager.Stub { setWifiEnabledBlocking(wifiEnabled, false, Process.myUid()); } - /** - * Initializes the hidden networks state. Must be called when we - * enable Wi-Fi. - */ - private synchronized void initializeHiddenNetworksState() { - // First, reset the state - resetHiddenNetworksState(); - - // ... then add networks that are marked as hidden - List<WifiConfiguration> networks = getConfiguredNetworks(); - if (!networks.isEmpty()) { - for (WifiConfiguration config : networks) { - if (config != null && config.hiddenSSID) { - addOrUpdateHiddenNetwork( - config.networkId, - config.status != WifiConfiguration.Status.DISABLED); - } - } - - } - } - - /** - * Resets the hidden networks state. - */ - private synchronized void resetHiddenNetworksState() { - mNumHiddenNetworkPresent = 0; - mIsHiddenNetworkPresent.clear(); - } - - /** - * Marks all but netId network as not present. - */ - private synchronized void markAllHiddenNetworksButOneAsNotPresent(int netId) { - for (Map.Entry<Integer, Boolean> entry : mIsHiddenNetworkPresent.entrySet()) { - if (entry != null) { - Integer networkId = entry.getKey(); - if (networkId != netId) { - updateNetworkIfHidden( - networkId, false); - } - } - } - } - - /** - * Updates the netId network presence status if netId is an existing - * hidden network. - */ - private synchronized void updateNetworkIfHidden(int netId, boolean present) { - if (isHiddenNetwork(netId)) { - addOrUpdateHiddenNetwork(netId, present); - } - } - - /** - * Updates the netId network presence status if netId is an existing - * hidden network. If the network does not exist, adds the network. - */ - private synchronized void addOrUpdateHiddenNetwork(int netId, boolean present) { - if (0 <= netId) { - - // If we are adding a new entry or modifying an existing one - Boolean isPresent = mIsHiddenNetworkPresent.get(netId); - if (isPresent == null || isPresent != present) { - if (present) { - incrementHiddentNetworkPresentCounter(); - } else { - // If we add a new hidden network, no need to change - // the counter (it must be 0) - if (isPresent != null) { - decrementHiddentNetworkPresentCounter(); - } - } - mIsHiddenNetworkPresent.put(netId, present); - } - } else { - Log.e(TAG, "addOrUpdateHiddenNetwork(): Invalid (negative) network id!"); - } - } - - /** - * Removes the netId network if it is hidden (being kept track of). - */ - private synchronized void removeNetworkIfHidden(int netId) { - if (isHiddenNetwork(netId)) { - removeHiddenNetwork(netId); - } - } - - /** - * Removes the netId network. For the call to be successful, the network - * must be hidden. - */ - private synchronized void removeHiddenNetwork(int netId) { - if (0 <= netId) { - Boolean isPresent = - mIsHiddenNetworkPresent.remove(netId); - if (isPresent != null) { - // If we remove an existing hidden network that is not - // present, no need to change the counter - if (isPresent) { - decrementHiddentNetworkPresentCounter(); - } - } else { - if (DBG) { - Log.d(TAG, "removeHiddenNetwork(): Removing a non-existent network!"); - } - } - } else { - Log.e(TAG, "removeHiddenNetwork(): Invalid (negative) network id!"); - } - } - - /** - * Returns true if netId is an existing hidden network. - */ - private synchronized boolean isHiddenNetwork(int netId) { - return mIsHiddenNetworkPresent.containsKey(netId); - } - - /** - * Increments the present (enabled) hidden networks counter. If the - * counter value goes from 0 to 1, changes the scan mode to active. - */ - private void incrementHiddentNetworkPresentCounter() { - ++mNumHiddenNetworkPresent; - if (1 == mNumHiddenNetworkPresent) { - // Switch the scan mode to "active" - mWifiStateTracker.setScanMode(true, SET_DUE_TO_A_HIDDEN_NETWORK); - } - } - - /** - * Decrements the present (enabled) hidden networks counter. If the - * counter goes from 1 to 0, changes the scan mode back to passive. - */ - private void decrementHiddentNetworkPresentCounter() { - if (0 < mNumHiddenNetworkPresent) { - --mNumHiddenNetworkPresent; - if (0 == mNumHiddenNetworkPresent) { - // Switch the scan mode to "passive" - mWifiStateTracker.setScanMode(false, SET_DUE_TO_A_HIDDEN_NETWORK); - } - } else { - Log.e(TAG, "Hidden-network counter invariant violation!"); - } - } - private boolean getPersistedWifiEnabled() { final ContentResolver cr = mContext.getContentResolver(); try { @@ -543,12 +366,10 @@ public class WifiService extends IWifiManager.Stub { setWifiEnabledState(eventualWifiState, uid); /* - * Initialize the hidden networks state and the number of allowed - * radio channels if Wi-Fi is being turned on. + * Initialize the number of allowed radio channels if Wi-Fi is being turned on. */ if (enable) { mWifiStateTracker.setNumAllowedChannels(); - initializeHiddenNetworksState(); } return true; @@ -883,15 +704,6 @@ public class WifiService extends IWifiManager.Stub { } mNeedReconfig = mNeedReconfig || doReconfig; - /* - * If we have hidden networks, we may have to change the scan mode - */ - if (config.hiddenSSID) { - // Mark the network as present unless it is disabled - addOrUpdateHiddenNetwork( - netId, config.status != WifiConfiguration.Status.DISABLED); - } - setVariables: { /* * Note that if a networkId for a non-existent network @@ -1219,11 +1031,6 @@ public class WifiService extends IWifiManager.Stub { public boolean removeNetwork(int netId) { enforceChangePermission(); - /* - * If we have hidden networks, we may have to change the scan mode - */ - removeNetworkIfHidden(netId); - return mWifiStateTracker.removeNetwork(netId); } @@ -1237,16 +1044,6 @@ public class WifiService extends IWifiManager.Stub { public boolean enableNetwork(int netId, boolean disableOthers) { enforceChangePermission(); - /* - * If we have hidden networks, we may have to change the scan mode - */ - synchronized(this) { - if (disableOthers) { - markAllHiddenNetworksButOneAsNotPresent(netId); - } - updateNetworkIfHidden(netId, true); - } - synchronized (mWifiStateTracker) { return WifiNative.enableNetworkCommand(netId, disableOthers); } @@ -1261,11 +1058,6 @@ public class WifiService extends IWifiManager.Stub { public boolean disableNetwork(int netId) { enforceChangePermission(); - /* - * If we have hidden networks, we may have to change the scan mode - */ - updateNetworkIfHidden(netId, false); - synchronized (mWifiStateTracker) { return WifiNative.disableNetworkCommand(netId); } diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index afbb19b302b5..0e2eb38b5627 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -242,7 +242,6 @@ public class WifiStateTracker extends NetworkStateTracker { private SettingsObserver mSettingsObserver; private boolean mIsScanModeActive; - private boolean mIsScanModeSetDueToAHiddenNetwork; // Wi-Fi run states: private static final int RUN_STATE_STARTING = 1; @@ -314,7 +313,6 @@ public class WifiStateTracker extends NetworkStateTracker { mScanResults = new ArrayList<ScanResult>(); // Allocate DHCP info object once, and fill it in on each request mDhcpInfo = new DhcpInfo(); - mIsScanModeSetDueToAHiddenNetwork = false; mRunState = RUN_STATE_STARTING; // Setting is in seconds @@ -1019,12 +1017,7 @@ public class WifiStateTracker extends NetworkStateTracker { * On receiving the first scan results after connecting to * the supplicant, switch scan mode over to passive. */ - if (!mIsScanModeSetDueToAHiddenNetwork) { - // This is the only place at the moment where we set - // the scan mode NOT due to a hidden network. This is - // what the second parameter value (false) stands for. - setScanMode(false, false); - } + setScanMode(false); break; case EVENT_POLL_INTERVAL: @@ -1162,9 +1155,7 @@ public class WifiStateTracker extends NetworkStateTracker { return disabledNetwork; } - public synchronized void setScanMode( - boolean isScanModeActive, boolean setDueToAHiddenNetwork) { - mIsScanModeSetDueToAHiddenNetwork = setDueToAHiddenNetwork; + public synchronized void setScanMode(boolean isScanModeActive) { if (mIsScanModeActive != isScanModeActive) { WifiNative.setScanModeCommand(mIsScanModeActive = isScanModeActive); } |