diff options
Diffstat (limited to 'core/java')
20 files changed, 144 insertions, 459 deletions
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index eacd78d..370db31 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1917,7 +1917,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); int pid = data.readInt(); boolean aboveSystem = data.readInt() != 0; - long res = inputDispatchingTimedOut(pid, aboveSystem); + String reason = data.readString(); + long res = inputDispatchingTimedOut(pid, aboveSystem, reason); reply.writeNoException(); reply.writeLong(res); return true; @@ -4461,12 +4462,14 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } - public long inputDispatchingTimedOut(int pid, boolean aboveSystem) throws RemoteException { + public long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason) + throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(pid); data.writeInt(aboveSystem ? 1 : 0); + data.writeString(reason); mRemote.transact(INPUT_DISPATCHING_TIMED_OUT_TRANSACTION, data, reply, 0); reply.readException(); long res = reply.readInt(); diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 19a028d..64054c5 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -185,11 +185,11 @@ public class AppOpsManager { OP_CALL_PHONE, OP_READ_SMS, OP_WRITE_SMS, - OP_READ_SMS, - OP_READ_SMS, - OP_READ_SMS, - OP_READ_SMS, - OP_WRITE_SMS, + OP_RECEIVE_SMS, + OP_RECEIVE_SMS, + OP_RECEIVE_SMS, + OP_RECEIVE_SMS, + OP_SEND_SMS, OP_READ_SMS, OP_WRITE_SMS, OP_WRITE_SETTINGS, diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index af9254d..b2ae298 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -384,7 +384,8 @@ public interface IActivityManager extends IInterface { public void requestBugReport() throws RemoteException; - public long inputDispatchingTimedOut(int pid, boolean aboveSystem) throws RemoteException; + public long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason) + throws RemoteException; public Bundle getAssistContextExtras(int requestType) throws RemoteException; diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java index 8903b4a..ff9282e 100644 --- a/core/java/android/hardware/camera2/CameraManager.java +++ b/core/java/android/hardware/camera2/CameraManager.java @@ -55,7 +55,7 @@ public final class CameraManager { private final ICameraService mCameraService; private ArrayList<String> mDeviceIdList; - private HashSet<CameraListener> mListenerSet = new HashSet<CameraListener>(); + private final HashSet<CameraListener> mListenerSet = new HashSet<CameraListener>(); private final Context mContext; private final Object mLock = new Object(); @@ -332,7 +332,7 @@ public final class CameraManager { Integer oldStatus = mDeviceStatus.put(id, status); - if (oldStatus == status) { + if (oldStatus != null && oldStatus == status) { Log.v(TAG, String.format( "Device status changed to 0x%x, which is what it already was", status)); diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 4cf38b6..c78a973 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -1476,4 +1476,20 @@ public class ConnectivityManager { } catch (RemoteException e) { } } + + /** + * Set the value for enabling/disabling airplane mode + * + * @param enable whether to enable airplane mode or not + * + * <p>This method requires the call to hold the permission + * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}. + * @hide + */ + public void setAirplaneMode(boolean enable) { + try { + mService.setAirplaneMode(enable); + } catch (RemoteException e) { + } + } } diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index a6f10ec..b3fa79f 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -156,4 +156,6 @@ interface IConnectivityManager LinkQualityInfo[] getAllLinkQualityInfo(); void setProvisioningNotificationVisible(boolean visible, int networkType, in String extraInfo, in String url); + + void setAirplaneMode(boolean enable); } diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index 41c6603..d3e5752 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -105,12 +105,8 @@ public final class ApduServiceInfo implements Parcelable { if (onHost) { parser = si.loadXmlMetaData(pm, HostApduService.SERVICE_META_DATA); if (parser == null) { - Log.d(TAG, "Didn't find service meta-data, trying legacy."); - parser = si.loadXmlMetaData(pm, HostApduService.OLD_SERVICE_META_DATA); - if (parser == null) { - throw new XmlPullParserException("No " + HostApduService.SERVICE_META_DATA + - " meta-data"); - } + throw new XmlPullParserException("No " + HostApduService.SERVICE_META_DATA + + " meta-data"); } } else { parser = si.loadXmlMetaData(pm, OffHostApduService.SERVICE_META_DATA); diff --git a/core/java/android/nfc/cardemulation/CardEmulationManager.java b/core/java/android/nfc/cardemulation/CardEmulationManager.java deleted file mode 100644 index 124ea1c..0000000 --- a/core/java/android/nfc/cardemulation/CardEmulationManager.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright (C) 2013 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.nfc.cardemulation; - -import android.annotation.SdkConstant; -import android.annotation.SdkConstant.SdkConstantType; -import android.app.ActivityThread; -import android.content.ComponentName; -import android.content.Context; -import android.content.pm.IPackageManager; -import android.content.pm.PackageManager; -import android.nfc.INfcCardEmulation; -import android.nfc.NfcAdapter; -import android.os.RemoteException; -import android.os.UserHandle; -import android.provider.Settings; -import android.util.Log; - -import java.util.HashMap; -import java.util.List; - -/** - * TODO Remove when calling .apks are upgraded - * @hide - */ -public final class CardEmulationManager { - static final String TAG = "CardEmulationManager"; - - /** - * Activity action: ask the user to change the default - * card emulation service for a certain category. This will - * show a dialog that asks the user whether he wants to - * replace the current default service with the service - * identified with the ComponentName specified in - * {@link #EXTRA_SERVICE_COMPONENT}, for the category - * specified in {@link #EXTRA_CATEGORY} - */ - @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) - public static final String ACTION_CHANGE_DEFAULT = - "android.nfc.cardemulation.ACTION_CHANGE_DEFAULT"; - - /** - * The category extra for {@link #ACTION_CHANGE_DEFAULT} - * - * @see #ACTION_CHANGE_DEFAULT - */ - public static final String EXTRA_CATEGORY = "category"; - - /** - * The ComponentName object passed in as a parcelable - * extra for {@link #ACTION_CHANGE_DEFAULT} - * - * @see #ACTION_CHANGE_DEFAULT - */ - public static final String EXTRA_SERVICE_COMPONENT = "component"; - - /** - * The payment category can be used to indicate that an AID - * represents a payment application. - */ - public static final String CATEGORY_PAYMENT = "payment"; - - /** - * If an AID group does not contain a category, or the - * specified category is not defined by the platform version - * that is parsing the AID group, all AIDs in the group will - * automatically be categorized under the {@link #CATEGORY_OTHER} - * category. - */ - public static final String CATEGORY_OTHER = "other"; - - /** - * Return value for {@link #getSelectionModeForCategory(String)}. - * - * <p>In this mode, the user has set a default service for this - * AID category. If a remote reader selects any of the AIDs - * that the default service has registered in this category, - * that service will automatically be bound to to handle - * the transaction. - * - * <p>There are still cases where a service that is - * not the default for a category can selected: - * <p> - * If a remote reader selects an AID in this category - * that is not handled by the default service, and there is a set - * of other services {S} that do handle this AID, the - * user is asked if he wants to use any of the services in - * {S} instead. - * <p> - * As a special case, if the size of {S} is one, containing a single service X, - * and all AIDs X has registered in this category are not - * registered by any other service, then X will be - * selected automatically without asking the user. - * <p>Example: - * <ul> - * <li>Service A registers AIDs "1", "2" and "3" in the category - * <li>Service B registers AIDs "3" and "4" in the category - * <li>Service C registers AIDs "5" and "6" in the category - * </ul> - * In this case, the following will happen when service A - * is the default: - * <ul> - * <li>Reader selects AID "1", "2" or "3": service A is invoked automatically - * <li>Reader selects AID "4": the user is asked to confirm he - * wants to use service B, because its AIDs overlap with service A. - * <li>Reader selects AID "5" or "6": service C is invoked automatically, - * because all AIDs it has asked for are only registered by C, - * and there is no overlap. - * </ul> - * - */ - public static final int SELECTION_MODE_PREFER_DEFAULT = 0; - - /** - * Return value for {@link #getSelectionModeForCategory(String)}. - * - * <p>In this mode, whenever an AID of this category is selected, - * the user is asked which service he wants to use to handle - * the transaction, even if there is only one matching service. - */ - public static final int SELECTION_MODE_ALWAYS_ASK = 1; - - /** - * Return value for {@link #getSelectionModeForCategory(String)}. - * - * <p>In this mode, the user will only be asked to select a service - * if the selected AID has been registered by multiple applications. - */ - public static final int SELECTION_MODE_ASK_IF_CONFLICT = 2; - - static boolean sIsInitialized = false; - static HashMap<Context, CardEmulationManager> sCardEmuManagers = new HashMap(); - static INfcCardEmulation sService; - - final Context mContext; - - private CardEmulationManager(Context context, INfcCardEmulation service) { - mContext = context.getApplicationContext(); - sService = service; - } - - public static synchronized CardEmulationManager getInstance(NfcAdapter adapter) { - if (adapter == null) throw new NullPointerException("NfcAdapter is null"); - Context context = adapter.getContext(); - if (context == null) { - Log.e(TAG, "NfcAdapter context is null."); - throw new UnsupportedOperationException(); - } - if (!sIsInitialized) { - IPackageManager pm = ActivityThread.getPackageManager(); - if (pm == null) { - Log.e(TAG, "Cannot get PackageManager"); - throw new UnsupportedOperationException(); - } - try { - if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { - Log.e(TAG, "This device does not support card emulation"); - throw new UnsupportedOperationException(); - } - } catch (RemoteException e) { - Log.e(TAG, "PackageManager query failed."); - throw new UnsupportedOperationException(); - } - sIsInitialized = true; - } - CardEmulationManager manager = sCardEmuManagers.get(context); - if (manager == null) { - // Get card emu service - INfcCardEmulation service = adapter.getCardEmulationService(); - manager = new CardEmulationManager(context, service); - sCardEmuManagers.put(context, manager); - } - return manager; - } - - /** - * Allows an application to query whether a service is currently - * the default service to handle a card emulation category. - * - * <p>Note that if {@link #getSelectionModeForCategory(String)} - * returns {@link #SELECTION_MODE_ALWAYS_ASK}, this method will always - * return false. - * - * @param service The ComponentName of the service - * @param category The category - * @return whether service is currently the default service for the category. - */ - public boolean isDefaultServiceForCategory(ComponentName service, String category) { - try { - return sService.isDefaultServiceForCategory(UserHandle.myUserId(), service, category); - } catch (RemoteException e) { - // Try one more time - recoverService(); - if (sService == null) { - Log.e(TAG, "Failed to recover CardEmulationService."); - return false; - } - try { - return sService.isDefaultServiceForCategory(UserHandle.myUserId(), service, - category); - } catch (RemoteException ee) { - Log.e(TAG, "Failed to recover CardEmulationService."); - return false; - } - } - } - - /** - * - * Allows an application to query whether a service is currently - * the default handler for a specified ISO7816-4 Application ID. - * - * @param service The ComponentName of the service - * @param aid The ISO7816-4 Application ID - * @return - */ - public boolean isDefaultServiceForAid(ComponentName service, String aid) { - try { - return sService.isDefaultServiceForAid(UserHandle.myUserId(), service, aid); - } catch (RemoteException e) { - // Try one more time - recoverService(); - if (sService == null) { - Log.e(TAG, "Failed to recover CardEmulationService."); - return false; - } - try { - return sService.isDefaultServiceForAid(UserHandle.myUserId(), service, aid); - } catch (RemoteException ee) { - Log.e(TAG, "Failed to reach CardEmulationService."); - return false; - } - } - } - - /** - * Returns the application selection mode for the passed in category. - * Valid return values are: - * <p>{@link #SELECTION_MODE_PREFER_DEFAULT} the user has requested a default - * application for this category, which will be preferred. - * <p>{@link #SELECTION_MODE_ALWAYS_ASK} the user has requested to be asked - * every time what app he would like to use in this category. - * <p>{@link #SELECTION_MODE_ASK_IF_CONFLICT} the user will only be asked - * to pick a service if there is a conflict. - * @param category The category, for example {@link #CATEGORY_PAYMENT} - * @return - */ - public int getSelectionModeForCategory(String category) { - if (CATEGORY_PAYMENT.equals(category)) { - String defaultComponent = Settings.Secure.getString(mContext.getContentResolver(), - Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT); - if (defaultComponent != null) { - return SELECTION_MODE_PREFER_DEFAULT; - } else { - return SELECTION_MODE_ALWAYS_ASK; - } - } else { - // All other categories are in "only ask if conflict" mode - return SELECTION_MODE_ASK_IF_CONFLICT; - } - } - - /** - * @hide - */ - public boolean setDefaultServiceForCategory(ComponentName service, String category) { - try { - return sService.setDefaultServiceForCategory(UserHandle.myUserId(), service, category); - } catch (RemoteException e) { - // Try one more time - recoverService(); - if (sService == null) { - Log.e(TAG, "Failed to recover CardEmulationService."); - return false; - } - try { - return sService.setDefaultServiceForCategory(UserHandle.myUserId(), service, - category); - } catch (RemoteException ee) { - Log.e(TAG, "Failed to reach CardEmulationService."); - return false; - } - } - } - - /** - * @hide - */ - public boolean setDefaultForNextTap(ComponentName service) { - try { - return sService.setDefaultForNextTap(UserHandle.myUserId(), service); - } catch (RemoteException e) { - // Try one more time - recoverService(); - if (sService == null) { - Log.e(TAG, "Failed to recover CardEmulationService."); - return false; - } - try { - return sService.setDefaultForNextTap(UserHandle.myUserId(), service); - } catch (RemoteException ee) { - Log.e(TAG, "Failed to reach CardEmulationService."); - return false; - } - } - } - /** - * @hide - */ - public List<ApduServiceInfo> getServices(String category) { - try { - return sService.getServices(UserHandle.myUserId(), category); - } catch (RemoteException e) { - // Try one more time - recoverService(); - if (sService == null) { - Log.e(TAG, "Failed to recover CardEmulationService."); - return null; - } - try { - return sService.getServices(UserHandle.myUserId(), category); - } catch (RemoteException ee) { - Log.e(TAG, "Failed to reach CardEmulationService."); - return null; - } - } - } - - void recoverService() { - NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext); - sService = adapter.getCardEmulationService(); - } -} diff --git a/core/java/android/nfc/cardemulation/HostApduService.java b/core/java/android/nfc/cardemulation/HostApduService.java index 174acc0..e2c3ca6 100644 --- a/core/java/android/nfc/cardemulation/HostApduService.java +++ b/core/java/android/nfc/cardemulation/HostApduService.java @@ -50,23 +50,6 @@ public abstract class HostApduService extends Service { "android.nfc.cardemulation.host_apdu_service"; /** - * The {@link Intent} that must be declared as handled by the service. - * TODO Remove - * @hide - */ - public static final String OLD_SERVICE_INTERFACE = - "android.nfc.HostApduService"; - - /** - * The name of the meta-data element that contains - * more information about this service. - * - * TODO Remove - * @hide - */ - public static final String OLD_SERVICE_META_DATA = "android.nfc.HostApduService"; - - /** * Reason for {@link #onDeactivated(int)}. * Indicates deactivation was due to the NFC link * being lost. @@ -282,37 +265,7 @@ public abstract class HostApduService extends Service { * @return a byte-array containing the response APDU, or null if no * response APDU can be sent at this point. */ - public byte[] processCommandApdu(byte[] commandApdu, Bundle extras) { - // TODO make this abstract - return processCommandApdu(commandApdu, 0); - } - - /** - * <p>This method will be called when a command APDU has been received - * from a remote device. A response APDU can be provided directly - * by returning a byte-array in this method. Note that in general - * response APDUs must be sent as quickly as possible, given the fact - * that the user is likely holding his device over an NFC reader - * when this method is called. - * - * <p class="note">If there are multiple services that have registered for the same - * AIDs in their meta-data entry, you will only get called if the user has - * explicitly selected your service, either as a default or just for the next tap. - * - * <p class="note">This method is running on the main thread of your application. - * If you cannot return a response APDU immediately, return null - * and use the {@link #sendResponseApdu(byte[])} method later. - * - * @deprecated use {@link #processCommandApdu(byte[], Bundle)} - * @param commandApdu - * @param flags - * @return a byte-array containing the response APDU, or null if no - * response APDU can be sent at this point. - * @hide - */ - public byte[] processCommandApdu(byte[] commandApdu, int flags) { - return null; - } + public abstract byte[] processCommandApdu(byte[] commandApdu, Bundle extras); /** * This method will be called in two possible scenarios: diff --git a/core/java/android/preference/TwoStatePreference.java b/core/java/android/preference/TwoStatePreference.java index c649879..af83953 100644 --- a/core/java/android/preference/TwoStatePreference.java +++ b/core/java/android/preference/TwoStatePreference.java @@ -21,6 +21,7 @@ import android.content.SharedPreferences; import android.content.res.TypedArray; import android.os.Parcel; import android.os.Parcelable; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.view.accessibility.AccessibilityEvent; @@ -215,17 +216,17 @@ public abstract class TwoStatePreference extends Preference { TextView summaryView = (TextView) view.findViewById(com.android.internal.R.id.summary); if (summaryView != null) { boolean useDefaultSummary = true; - if (mChecked && mSummaryOn != null) { + if (mChecked && !TextUtils.isEmpty(mSummaryOn)) { summaryView.setText(mSummaryOn); useDefaultSummary = false; - } else if (!mChecked && mSummaryOff != null) { + } else if (!mChecked && !TextUtils.isEmpty(mSummaryOff)) { summaryView.setText(mSummaryOff); useDefaultSummary = false; } if (useDefaultSummary) { final CharSequence summary = getSummary(); - if (summary != null) { + if (!TextUtils.isEmpty(summary)) { summaryView.setText(summary); useDefaultSummary = false; } diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 9d52c83..a6f23a8 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -137,8 +137,18 @@ public class CallLog { public static final String NUMBER = "number"; /** - * The number presenting rules set by the network for "allowed", - * "payphone", "restricted" or "unknown". + * The number presenting rules set by the network. + * + * <p> + * Allowed values: + * <ul> + * <li>{@link #PRESENTATION_ALLOWED}</li> + * <li>{@link #PRESENTATION_RESTRICTED}</li> + * <li>{@link #PRESENTATION_UNKNOWN}</li> + * <li>{@link #PRESENTATION_PAYPHONE}</li> + * </ul> + * </p> + * * <P>Type: INTEGER</P> */ public static final String NUMBER_PRESENTATION = "presentation"; diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java index 91b3b48..43120c4 100644 --- a/core/java/android/provider/DocumentsContract.java +++ b/core/java/android/provider/DocumentsContract.java @@ -459,6 +459,7 @@ public final class DocumentsContract { private static final String PATH_SEARCH = "search"; private static final String PARAM_QUERY = "query"; + private static final String PARAM_MANAGE = "manage"; /** * Build Uri representing the roots of a document provider. When queried, a @@ -583,6 +584,16 @@ public final class DocumentsContract { return searchDocumentsUri.getQueryParameter(PARAM_QUERY); } + /** {@hide} */ + public static Uri setManageMode(Uri uri) { + return uri.buildUpon().appendQueryParameter(PARAM_MANAGE, "true").build(); + } + + /** {@hide} */ + public static boolean isManageMode(Uri uri) { + return uri.getBooleanQueryParameter(PARAM_MANAGE, false); + } + /** * Return list of all documents that the calling package has "open." These * are Uris matching {@link DocumentsContract} to which persistent diff --git a/core/java/android/provider/DocumentsProvider.java b/core/java/android/provider/DocumentsProvider.java index 1b0fc4d..d801827 100644 --- a/core/java/android/provider/DocumentsProvider.java +++ b/core/java/android/provider/DocumentsProvider.java @@ -167,6 +167,14 @@ public abstract class DocumentsProvider extends ContentProvider { String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException; + /** {@hide} */ + @SuppressWarnings("unused") + public Cursor queryChildDocumentsForManage( + String parentDocumentId, String[] projection, String sortOrder) + throws FileNotFoundException { + throw new UnsupportedOperationException("Manage not supported"); + } + /** * Return documents that that match the given query, starting the search at * the given directory. @@ -262,7 +270,12 @@ public abstract class DocumentsProvider extends ContentProvider { case MATCH_DOCUMENT: return queryDocument(getDocumentId(uri), projection); case MATCH_CHILDREN: - return queryChildDocuments(getDocumentId(uri), projection, sortOrder); + if (DocumentsContract.isManageMode(uri)) { + return queryChildDocumentsForManage( + getDocumentId(uri), projection, sortOrder); + } else { + return queryChildDocuments(getDocumentId(uri), projection, sortOrder); + } case MATCH_SEARCH: return querySearchDocuments( getDocumentId(uri), getSearchDocumentsQuery(uri), projection); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 1a80818..b70d74a 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2439,7 +2439,9 @@ public final class Settings { SIP_CALL_OPTIONS, SIP_RECEIVE_CALLS, POINTER_SPEED, - VIBRATE_WHEN_RINGING + VIBRATE_WHEN_RINGING, + RINGTONE, + NOTIFICATION_SOUND }; // Settings moved to Settings.Secure diff --git a/core/java/android/speech/RecognizerIntent.java b/core/java/android/speech/RecognizerIntent.java index 457e66c..e991d84 100644 --- a/core/java/android/speech/RecognizerIntent.java +++ b/core/java/android/speech/RecognizerIntent.java @@ -55,7 +55,10 @@ public class RecognizerIntent { * <p>Starting this intent with just {@link Activity#startActivity(Intent)} is not supported. * You must either use {@link Activity#startActivityForResult(Intent, int)}, or provide a * PendingIntent, to receive recognition results. - * + * + * <p>The implementation of this API is likely to stream audio to remote servers to perform + * speech recognition which can use a substantial amount of bandwidth. + * * <p>Required extras: * <ul> * <li>{@link #EXTRA_LANGUAGE_MODEL} diff --git a/core/java/android/speech/SpeechRecognizer.java b/core/java/android/speech/SpeechRecognizer.java index 8fee41d..94aedbd 100644 --- a/core/java/android/speech/SpeechRecognizer.java +++ b/core/java/android/speech/SpeechRecognizer.java @@ -39,8 +39,14 @@ import java.util.Queue; * This class provides access to the speech recognition service. This service allows access to the * speech recognizer. Do not instantiate this class directly, instead, call * {@link SpeechRecognizer#createSpeechRecognizer(Context)}. This class's methods must be - * invoked only from the main application thread. Please note that the application must have - * {@link android.Manifest.permission#RECORD_AUDIO} permission to use this class. + * invoked only from the main application thread. + * + * <p>The implementation of this API is likely to stream audio to remote servers to perform speech + * recognition. As such this API is not intended to be used for continuous recognition, which would + * consume a significant amount of battery and bandwidth. + * + * <p>Please note that the application must have {@link android.Manifest.permission#RECORD_AUDIO} + * permission to use this class. */ public class SpeechRecognizer { /** DEBUG value to enable verbose debug prints */ diff --git a/core/java/android/transition/Transition.java b/core/java/android/transition/Transition.java index 59df183..8ea9d48 100644 --- a/core/java/android/transition/Transition.java +++ b/core/java/android/transition/Transition.java @@ -122,6 +122,10 @@ public abstract class Transition implements Cloneable { // Whether this transition is currently paused, due to a call to pause() boolean mPaused = false; + // Whether this transition has ended. Used to avoid pause/resume on transitions + // that have completed + private boolean mEnded = false; + // The set of listeners to be sent transition lifecycle events. ArrayList<TransitionListener> mListeners = null; @@ -914,21 +918,23 @@ public abstract class Transition implements Cloneable { * @hide */ public void pause() { - ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators(); - int numOldAnims = runningAnimators.size(); - for (int i = numOldAnims - 1; i >= 0; i--) { - Animator anim = runningAnimators.keyAt(i); - anim.pause(); - } - if (mListeners != null && mListeners.size() > 0) { - ArrayList<TransitionListener> tmpListeners = - (ArrayList<TransitionListener>) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onTransitionPause(this); + if (!mEnded) { + ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators(); + int numOldAnims = runningAnimators.size(); + for (int i = numOldAnims - 1; i >= 0; i--) { + Animator anim = runningAnimators.keyAt(i); + anim.pause(); + } + if (mListeners != null && mListeners.size() > 0) { + ArrayList<TransitionListener> tmpListeners = + (ArrayList<TransitionListener>) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onTransitionPause(this); + } } + mPaused = true; } - mPaused = true; } /** @@ -940,18 +946,20 @@ public abstract class Transition implements Cloneable { */ public void resume() { if (mPaused) { - ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators(); - int numOldAnims = runningAnimators.size(); - for (int i = numOldAnims - 1; i >= 0; i--) { - Animator anim = runningAnimators.keyAt(i); - anim.resume(); - } - if (mListeners != null && mListeners.size() > 0) { - ArrayList<TransitionListener> tmpListeners = - (ArrayList<TransitionListener>) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (int i = 0; i < numListeners; ++i) { - tmpListeners.get(i).onTransitionResume(this); + if (!mEnded) { + ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators(); + int numOldAnims = runningAnimators.size(); + for (int i = numOldAnims - 1; i >= 0; i--) { + Animator anim = runningAnimators.keyAt(i); + anim.resume(); + } + if (mListeners != null && mListeners.size() > 0) { + ArrayList<TransitionListener> tmpListeners = + (ArrayList<TransitionListener>) mListeners.clone(); + int numListeners = tmpListeners.size(); + for (int i = 0; i < numListeners; ++i) { + tmpListeners.get(i).onTransitionResume(this); + } } } mPaused = false; @@ -1071,6 +1079,7 @@ public abstract class Transition implements Cloneable { tmpListeners.get(i).onTransitionStart(this); } } + mEnded = false; } mNumInstances++; } @@ -1111,6 +1120,7 @@ public abstract class Transition implements Cloneable { v.setHasTransientState(false); } } + mEnded = true; } } diff --git a/core/java/android/view/IApplicationToken.aidl b/core/java/android/view/IApplicationToken.aidl index 5f0600f..633b40f 100644 --- a/core/java/android/view/IApplicationToken.aidl +++ b/core/java/android/view/IApplicationToken.aidl @@ -23,7 +23,7 @@ interface IApplicationToken void windowsDrawn(); void windowsVisible(); void windowsGone(); - boolean keyDispatchingTimedOut(); + boolean keyDispatchingTimedOut(String reason); long getKeyDispatchingTimeout(); } diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 389d9d6..b239fbd 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -1555,8 +1555,9 @@ public class ListView extends AbsListView { } else if (mItemCount != mAdapter.getCount()) { throw new IllegalStateException("The content of the adapter has changed but " + "ListView did not receive a notification. Make sure the content of " - + "your adapter is not modified from a background thread, but only " - + "from the UI thread. [in ListView(" + getId() + ", " + getClass() + + "your adapter is not modified from a background thread, but only from " + + "the UI thread. Make sure your adapter calls notifyDataSetChanged() " + + "when its content changes. [in ListView(" + getId() + ", " + getClass() + ") with Adapter(" + mAdapter.getClass() + ")]"); } diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index b87ed7a..b75d36f 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -412,6 +412,8 @@ public class Spinner extends AbsSpinner implements OnClickListener { public void setAdapter(SpinnerAdapter adapter) { super.setAdapter(adapter); + mRecycler.clear(); + if (mPopup != null) { mPopup.setAdapter(new DropDownAdapter(adapter)); } else { @@ -426,9 +428,8 @@ public class Spinner extends AbsSpinner implements OnClickListener { if (getChildCount() > 0) { child = getChildAt(0); } else if (mAdapter != null && mAdapter.getCount() > 0) { - child = makeAndAddView(0); + child = makeView(0, false); mRecycler.put(0, child); - removeAllViewsInLayout(); } if (child != null) { @@ -536,7 +537,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { mFirstPosition = mSelectedPosition; if (mAdapter != null) { - View sel = makeAndAddView(mSelectedPosition); + View sel = makeView(mSelectedPosition, true); int width = sel.getMeasuredWidth(); int selectedOffset = childrenLeft; final int layoutDirection = getLayoutDirection(); @@ -571,17 +572,17 @@ public class Spinner extends AbsSpinner implements OnClickListener { * from the old to new positions. * * @param position Position in the spinner for the view to obtain - * @return A view that has been added to the spinner + * @param addChild true to add the child to the spinner, false to obtain and configure only. + * @return A view for the given position */ - private View makeAndAddView(int position) { - + private View makeView(int position, boolean addChild) { View child; if (!mDataChanged) { child = mRecycler.get(position); if (child != null) { // Position the view - setUpChild(child); + setUpChild(child, addChild); return child; } @@ -591,7 +592,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { child = mAdapter.getView(position, null, this); // Position the view - setUpChild(child); + setUpChild(child, addChild); return child; } @@ -601,8 +602,9 @@ public class Spinner extends AbsSpinner implements OnClickListener { * and fill out its layout paramters. * * @param child The view to position + * @param addChild true if the child should be added to the Spinner during setup */ - private void setUpChild(View child) { + private void setUpChild(View child, boolean addChild) { // Respect layout params that are already in the view. Otherwise // make some up... @@ -611,7 +613,9 @@ public class Spinner extends AbsSpinner implements OnClickListener { lp = generateDefaultLayoutParams(); } - addViewInLayout(child, 0, lp); + if (addChild) { + addViewInLayout(child, 0, lp); + } child.setSelected(hasFocus()); if (mDisableChildrenWhenDisabled) { |
