diff options
94 files changed, 1750 insertions, 1500 deletions
@@ -65,15 +65,16 @@ endif ## READ ME: ######################################################## LOCAL_SRC_FILES += \ core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \ - core/java/android/accessibilityservice/IEventListener.aidl \ + core/java/android/accessibilityservice/IEventListener.aidl \ core/java/android/accounts/IAccountManager.aidl \ core/java/android/accounts/IAccountManagerResponse.aidl \ core/java/android/accounts/IAccountAuthenticator.aidl \ core/java/android/accounts/IAccountAuthenticatorResponse.aidl \ + core/java/android/app/IActivityController.aidl \ core/java/android/app/IActivityPendingResult.aidl \ core/java/android/app/IActivityWatcher.aidl \ core/java/android/app/IAlarmManager.aidl \ - core/java/android/app/IBackupAgent.aidl \ + core/java/android/app/IBackupAgent.aidl \ core/java/android/app/IInstrumentationWatcher.aidl \ core/java/android/app/INotificationManager.aidl \ core/java/android/app/ISearchManager.aidl \ @@ -90,12 +91,12 @@ LOCAL_SRC_FILES += \ core/java/android/bluetooth/IBluetoothA2dp.aidl \ core/java/android/bluetooth/IBluetoothDevice.aidl \ core/java/android/bluetooth/IBluetoothHeadset.aidl \ - core/java/android/content/IContentService.aidl \ + core/java/android/content/IContentService.aidl \ core/java/android/content/IIntentReceiver.aidl \ core/java/android/content/IIntentSender.aidl \ core/java/android/content/ISyncAdapter.aidl \ core/java/android/content/ISyncContext.aidl \ - core/java/android/content/ISyncStatusObserver.aidl \ + core/java/android/content/ISyncStatusObserver.aidl \ core/java/android/content/pm/IPackageDataObserver.aidl \ core/java/android/content/pm/IPackageDeleteObserver.aidl \ core/java/android/content/pm/IPackageInstallObserver.aidl \ diff --git a/api/current.xml b/api/current.xml index 88e5025..75746c9 100644 --- a/api/current.xml +++ b/api/current.xml @@ -17269,6 +17269,39 @@ visibility="public" > </field> +<field name="AUTHENTICATOR_ATTRIBUTES_NAME" + type="java.lang.String" + transient="false" + volatile="false" + value=""account-authenticator"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="AUTHENTICATOR_INTENT_ACTION" + type="java.lang.String" + transient="false" + volatile="false" + value=""android.accounts.AccountAuthenticator"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="AUTHENTICATOR_META_DATA_NAME" + type="java.lang.String" + transient="false" + volatile="false" + value=""android.accounts.AccountAuthenticator"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="AUTHENTICATOR_TYPES_KEY" type="java.lang.String" transient="false" @@ -70530,6 +70563,17 @@ visibility="public" > </method> +<method name="getPremises" + return="java.lang.String" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="getSubAdminArea" return="java.lang.String" abstract="false" @@ -70541,6 +70585,28 @@ visibility="public" > </method> +<method name="getSubLocality" + return="java.lang.String" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="getSubThoroughfare" + return="java.lang.String" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="getThoroughfare" return="java.lang.String" abstract="false" @@ -70730,6 +70796,19 @@ <parameter name="postalCode" type="java.lang.String"> </parameter> </method> +<method name="setPremises" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="premises" type="java.lang.String"> +</parameter> +</method> <method name="setSubAdminArea" return="void" abstract="false" @@ -70743,6 +70822,32 @@ <parameter name="subAdminArea" type="java.lang.String"> </parameter> </method> +<method name="setSubLocality" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="sublocality" type="java.lang.String"> +</parameter> +</method> +<method name="setSubThoroughfare" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="subthoroughfare" type="java.lang.String"> +</parameter> +</method> <method name="setThoroughfare" return="void" abstract="false" @@ -115058,6 +115163,8 @@ </parameter> <parameter name="queueMode" type="int"> </parameter> +<parameter name="params" type="java.util.HashMap<java.lang.String, java.lang.String>"> +</parameter> </method> <method name="setLanguage" return="int" @@ -115072,6 +115179,19 @@ <parameter name="loc" type="java.util.Locale"> </parameter> </method> +<method name="setOnUtteranceCompletedListener" + return="int" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="listener" type="android.speech.tts.TextToSpeech.OnUtteranceCompletedListener"> +</parameter> +</method> <method name="setPitch" return="int" abstract="false" @@ -115275,6 +115395,27 @@ </parameter> </method> </interface> +<interface name="TextToSpeech.OnUtteranceCompletedListener" + abstract="true" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="onUtteranceCompleted" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="utteranceId" type="java.lang.String"> +</parameter> +</method> +</interface> </package> <package name="android.telephony" > @@ -175277,6 +175418,17 @@ <parameter name="yOffset" type="int"> </parameter> </method> +<method name="getSoftInputMode" + return="int" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="getWidth" return="int" abstract="false" @@ -175482,6 +175634,19 @@ <parameter name="touchable" type="boolean"> </parameter> </method> +<method name="setSoftInputMode" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="mode" type="int"> +</parameter> +</method> <method name="setTouchInterceptor" return="void" abstract="false" diff --git a/core/java/android/accounts/AccountAuthenticatorCache.java b/core/java/android/accounts/AccountAuthenticatorCache.java index c8fc12c..2f52f40 100644 --- a/core/java/android/accounts/AccountAuthenticatorCache.java +++ b/core/java/android/accounts/AccountAuthenticatorCache.java @@ -33,12 +33,9 @@ import android.util.AttributeSet; extends RegisteredServicesCache<AuthenticatorDescription> { private static final String TAG = "Account"; - private static final String SERVICE_INTERFACE = "android.accounts.AccountAuthenticator"; - private static final String SERVICE_META_DATA = "android.accounts.AccountAuthenticator"; - private static final String ATTRIBUTES_NAME = "account-authenticator"; - public AccountAuthenticatorCache(Context context) { - super(context, SERVICE_INTERFACE, SERVICE_META_DATA, ATTRIBUTES_NAME); + super(context, Constants.AUTHENTICATOR_INTENT_ACTION, + Constants.AUTHENTICATOR_META_DATA_NAME, Constants.AUTHENTICATOR_ATTRIBUTES_NAME); } public AuthenticatorDescription parseServiceAttributes(String packageName, AttributeSet attrs) { diff --git a/core/java/android/accounts/Constants.java b/core/java/android/accounts/Constants.java index 4c1fa02..bb7f940 100644 --- a/core/java/android/accounts/Constants.java +++ b/core/java/android/accounts/Constants.java @@ -40,6 +40,13 @@ public class Constants { public static final String ACCOUNT_AUTHENTICATOR_RESPONSE_KEY = "accountAuthenticatorResponse"; public static final String ACCOUNT_MANAGER_RESPONSE_KEY = "accountManagerResponse"; public static final String AUTH_FAILED_MESSAGE_KEY = "authFailedMessage"; + + public static final String AUTHENTICATOR_INTENT_ACTION = + "android.accounts.AccountAuthenticator"; + public static final String AUTHENTICATOR_META_DATA_NAME = + "android.accounts.AccountAuthenticator"; + public static final String AUTHENTICATOR_ATTRIBUTES_NAME = "account-authenticator"; + /** * Action sent as a broadcast Intent by the AccountsService * when accounts are added to and/or removed from the device's diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 6c2560d..4ac3b9e 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -612,6 +612,7 @@ public class Activity extends ContextThemeWrapper // set by the thread after the constructor and before onCreate(Bundle savedInstanceState) is called. private Instrumentation mInstrumentation; private IBinder mToken; + private int mIdent; /*package*/ String mEmbeddedID; private Application mApplication; /*package*/ Intent mIntent; @@ -789,9 +790,6 @@ public class Activity extends ContextThemeWrapper protected void onCreate(Bundle savedInstanceState) { mVisibleFromClient = mWindow.getWindowStyle().getBoolean( com.android.internal.R.styleable.Window_windowNoDisplay, true); - // uses super.getSystemService() since this.getSystemService() looks at the - // mSearchManager field. - mSearchManager = (SearchManager) super.getSystemService(Context.SEARCH_SERVICE); mCalled = true; } @@ -2531,6 +2529,7 @@ public class Activity extends ContextThemeWrapper */ public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData, boolean globalSearch) { + ensureSearchManager(); mSearchManager.startSearch(initialQuery, selectInitialQuery, getComponentName(), appSearchData, globalSearch); } @@ -3241,6 +3240,24 @@ public class Activity extends ContextThemeWrapper return getSharedPreferences(getLocalClassName(), mode); } + private void ensureSearchManager() { + if (mSearchManager != null) { + return; + } + + // uses super.getSystemService() since this.getSystemService() looks at the + // mSearchManager field. + mSearchManager = (SearchManager) super.getSystemService(Context.SEARCH_SERVICE); + int ident = mIdent; + if (ident == 0) { + if (mParent != null) ident = mParent.mIdent; + if (ident == 0) { + throw new IllegalArgumentException("no ident"); + } + } + mSearchManager.setIdent(ident); + } + @Override public Object getSystemService(String name) { if (getBaseContext() == null) { @@ -3251,6 +3268,7 @@ public class Activity extends ContextThemeWrapper if (WINDOW_SERVICE.equals(name)) { return mWindowManager; } else if (SEARCH_SERVICE.equals(name)) { + ensureSearchManager(); return mSearchManager; } return super.getSystemService(name); @@ -3450,14 +3468,17 @@ public class Activity extends ContextThemeWrapper Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, Object lastNonConfigurationInstance, Configuration config) { - attach(context, aThread, instr, token, application, intent, info, title, parent, id, + attach(context, aThread, instr, token, 0, application, intent, info, title, parent, id, lastNonConfigurationInstance, null, config); } - final void attach(Context context, ActivityThread aThread, Instrumentation instr, IBinder token, - Application application, Intent intent, ActivityInfo info, CharSequence title, - Activity parent, String id, Object lastNonConfigurationInstance, - HashMap<String,Object> lastNonConfigurationChildInstances, Configuration config) { + final void attach(Context context, ActivityThread aThread, + Instrumentation instr, IBinder token, int ident, + Application application, Intent intent, ActivityInfo info, + CharSequence title, Activity parent, String id, + Object lastNonConfigurationInstance, + HashMap<String,Object> lastNonConfigurationChildInstances, + Configuration config) { attachBaseContext(context); mWindow = PolicyManager.makeNewWindow(this); @@ -3470,6 +3491,7 @@ public class Activity extends ContextThemeWrapper mMainThread = aThread; mInstrumentation = instr; mToken = token; + mIdent = ident; mApplication = application; mIntent = intent; mComponent = intent.getComponent(); @@ -3554,9 +3576,6 @@ public class Activity extends ContextThemeWrapper final void performPause() { onPause(); - - // dismiss the search dialog if it is open - mSearchManager.stopSearch(); } final void performUserLeaving() { diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index dfa8139..ec7714d 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -881,11 +881,11 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } - case SET_ACTIVITY_WATCHER_TRANSACTION: { + case SET_ACTIVITY_CONTROLLER_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); - IActivityWatcher watcher = IActivityWatcher.Stub.asInterface( + IActivityController watcher = IActivityController.Stub.asInterface( data.readStrongBinder()); - setActivityWatcher(watcher); + setActivityController(watcher); return true; } @@ -1052,6 +1052,22 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeNoException(); return true; } + + case REGISTER_ACTIVITY_WATCHER_TRANSACTION: { + data.enforceInterface(IActivityManager.descriptor); + IActivityWatcher watcher = IActivityWatcher.Stub.asInterface( + data.readStrongBinder()); + registerActivityWatcher(watcher); + return true; + } + + case UNREGISTER_ACTIVITY_WATCHER_TRANSACTION: { + data.enforceInterface(IActivityManager.descriptor); + IActivityWatcher watcher = IActivityWatcher.Stub.asInterface( + data.readStrongBinder()); + unregisterActivityWatcher(watcher); + return true; + } } return super.onTransact(code, data, reply, flags); @@ -2105,13 +2121,13 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); reply.recycle(); } - public void setActivityWatcher(IActivityWatcher watcher) throws RemoteException + public void setActivityController(IActivityController watcher) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(watcher != null ? watcher.asBinder() : null); - mRemote.transact(SET_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0); + mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0); reply.readException(); data.recycle(); reply.recycle(); @@ -2290,5 +2306,29 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); } + public void registerActivityWatcher(IActivityWatcher watcher) + throws RemoteException { + Parcel data = Parcel.obtain(); + Parcel reply = Parcel.obtain(); + data.writeInterfaceToken(IActivityManager.descriptor); + data.writeStrongBinder(watcher != null ? watcher.asBinder() : null); + mRemote.transact(REGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0); + reply.readException(); + data.recycle(); + reply.recycle(); + } + + public void unregisterActivityWatcher(IActivityWatcher watcher) + throws RemoteException { + Parcel data = Parcel.obtain(); + Parcel reply = Parcel.obtain(); + data.writeInterfaceToken(IActivityManager.descriptor); + data.writeStrongBinder(watcher != null ? watcher.asBinder() : null); + mRemote.transact(UNREGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0); + reply.readException(); + data.recycle(); + reply.recycle(); + } + private IBinder mRemote; } diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 27e8fb5..f2814f2 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1090,6 +1090,7 @@ public final class ActivityThread { private static final class ActivityRecord { IBinder token; + int ident; Intent intent; Bundle state; Activity activity; @@ -1299,12 +1300,13 @@ public final class ActivityThread { // we use token to identify this activity without having to send the // activity itself back to the activity manager. (matters more with ipc) - public final void scheduleLaunchActivity(Intent intent, IBinder token, + public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, ActivityInfo info, Bundle state, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, boolean notResumed, boolean isForward) { ActivityRecord r = new ActivityRecord(); r.token = token; + r.ident = ident; r.intent = intent; r.activityInfo = info; r.state = state; @@ -2197,21 +2199,11 @@ public final class ActivityThread { } public final Activity startActivityNow(Activity parent, String id, - Intent intent, IBinder token, Bundle state) { - ActivityInfo aInfo = resolveActivityInfo(intent); - return startActivityNow(parent, id, intent, aInfo, token, state); - } - - public final Activity startActivityNow(Activity parent, String id, - Intent intent, ActivityInfo activityInfo, IBinder token, Bundle state) { - return startActivityNow(parent, id, intent, activityInfo, token, state, null); - } - - public final Activity startActivityNow(Activity parent, String id, Intent intent, ActivityInfo activityInfo, IBinder token, Bundle state, Object lastNonConfigurationInstance) { ActivityRecord r = new ActivityRecord(); r.token = token; + r.ident = 0; r.intent = intent; r.state = state; r.parent = parent; @@ -2335,10 +2327,10 @@ public final class ActivityThread { appContext.setOuterContext(activity); CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager()); Configuration config = new Configuration(mConfiguration); - activity.attach(appContext, this, getInstrumentation(), r.token, app, - r.intent, r.activityInfo, title, r.parent, r.embeddedID, - r.lastNonConfigurationInstance, r.lastNonConfigurationChildInstances, - config); + activity.attach(appContext, this, getInstrumentation(), r.token, + r.ident, app, r.intent, r.activityInfo, title, r.parent, + r.embeddedID, r.lastNonConfigurationInstance, + r.lastNonConfigurationChildInstances, config); if (customIntent != null) { activity.mIntent = customIntent; diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index b052c99..a3c6325 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -119,13 +119,15 @@ public abstract class ApplicationThreadNative extends Binder data.enforceInterface(IApplicationThread.descriptor); Intent intent = Intent.CREATOR.createFromParcel(data); IBinder b = data.readStrongBinder(); + int ident = data.readInt(); ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data); Bundle state = data.readBundle(); List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR); List<Intent> pi = data.createTypedArrayList(Intent.CREATOR); boolean notResumed = data.readInt() != 0; boolean isForward = data.readInt() != 0; - scheduleLaunchActivity(intent, b, info, state, ri, pi, notResumed, isForward); + scheduleLaunchActivity(intent, b, ident, info, state, ri, pi, + notResumed, isForward); return true; } @@ -442,7 +444,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.recycle(); } - public final void scheduleLaunchActivity(Intent intent, IBinder token, + public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, ActivityInfo info, Bundle state, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, boolean notResumed, boolean isForward) throws RemoteException { @@ -450,6 +452,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeInterfaceToken(IApplicationThread.descriptor); intent.writeToParcel(data, 0); data.writeStrongBinder(token); + data.writeInt(ident); info.writeToParcel(data, 0); data.writeBundle(state); data.writeTypedList(pendingResults); diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 2b165fc..444f222 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -20,6 +20,7 @@ import com.android.internal.policy.PolicyManager; import android.content.Context; import android.content.DialogInterface; +import android.content.ComponentName; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -86,6 +87,7 @@ public class Dialog implements DialogInterface, Window.Callback, private Message mCancelMessage; private Message mDismissMessage; + private Message mShowMessage; /** * Whether to cancel the dialog when a touch is received outside of the @@ -140,7 +142,7 @@ public class Dialog implements DialogInterface, Window.Callback, w.setWindowManager(mWindowManager, null, null); w.setGravity(Gravity.CENTER); mUiThread = Thread.currentThread(); - mDismissCancelHandler = new DismissCancelHandler(this); + mListenersHandler = new ListenersHandler(this); } /** @@ -235,6 +237,8 @@ public class Dialog implements DialogInterface, Window.Callback, } mWindowManager.addView(mDecor, l); mShowing = true; + + sendShowMessage(); } /** @@ -289,6 +293,13 @@ public class Dialog implements DialogInterface, Window.Callback, } } + private void sendShowMessage() { + if (mShowMessage != null) { + // Obtain a new message so this dialog can be re-used + Message.obtain(mShowMessage).sendToTarget(); + } + } + // internal method to make sure mcreated is set properly without requiring // users to call through to super in onCreate void dispatchOnCreate(Bundle savedInstanceState) { @@ -774,8 +785,17 @@ public class Dialog implements DialogInterface, Window.Callback, * This hook is called when the user signals the desire to start a search. */ public boolean onSearchRequested() { - // not during dialogs, no. - return false; + final SearchManager searchManager = (SearchManager) mContext + .getSystemService(Context.SEARCH_SERVICE); + + // associate search with owner activity if possible (otherwise it will default to + // global search). + final ComponentName appName = mOwnerActivity == null ? null + : mOwnerActivity.getComponentName(); + final boolean globalSearch = (appName == null); + searchManager.startSearch(null, false, appName, null, globalSearch); + dismiss(); + return true; } @@ -890,7 +910,7 @@ public class Dialog implements DialogInterface, Window.Callback, */ public void setOnCancelListener(final OnCancelListener listener) { if (listener != null) { - mCancelMessage = mDismissCancelHandler.obtainMessage(CANCEL, listener); + mCancelMessage = mListenersHandler.obtainMessage(CANCEL, listener); } else { mCancelMessage = null; } @@ -911,13 +931,26 @@ public class Dialog implements DialogInterface, Window.Callback, */ public void setOnDismissListener(final OnDismissListener listener) { if (listener != null) { - mDismissMessage = mDismissCancelHandler.obtainMessage(DISMISS, listener); + mDismissMessage = mListenersHandler.obtainMessage(DISMISS, listener); } else { mDismissMessage = null; } } /** + * Sets a listener to be invoked when the dialog is shown. + * + * @hide Pending API council approval + */ + public void setOnShowListener(OnShowListener listener) { + if (listener != null) { + mShowMessage = mListenersHandler.obtainMessage(SHOW, listener); + } else { + mShowMessage = null; + } + } + + /** * Set a message to be sent when the dialog is dismissed. * @param msg The msg to send when the dialog is dismissed. */ @@ -951,13 +984,14 @@ public class Dialog implements DialogInterface, Window.Callback, private static final int DISMISS = 0x43; private static final int CANCEL = 0x44; + private static final int SHOW = 0x45; - private Handler mDismissCancelHandler; + private Handler mListenersHandler; - private static final class DismissCancelHandler extends Handler { + private static final class ListenersHandler extends Handler { private WeakReference<DialogInterface> mDialog; - public DismissCancelHandler(Dialog dialog) { + public ListenersHandler(Dialog dialog) { mDialog = new WeakReference<DialogInterface>(dialog); } @@ -970,6 +1004,9 @@ public class Dialog implements DialogInterface, Window.Callback, case CANCEL: ((OnCancelListener) msg.obj).onCancel(mDialog.get()); break; + case SHOW: + ((OnShowListener) msg.obj).onShow(mDialog.get()); + break; } } } diff --git a/core/java/android/app/IActivityController.aidl b/core/java/android/app/IActivityController.aidl new file mode 100644 index 0000000..8f6b252 --- /dev/null +++ b/core/java/android/app/IActivityController.aidl @@ -0,0 +1,55 @@ +/* +** +** Copyright 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.app; + +import android.content.Intent; + +/** + * Testing interface to monitor what is happening in the activity manager + * while tests are running. Not for normal application development. + * {@hide} + */ +interface IActivityController +{ + /** + * The system is trying to start an activity. Return true to allow + * it to be started as normal, or false to cancel/reject this activity. + */ + boolean activityStarting(in Intent intent, String pkg); + + /** + * The system is trying to return to an activity. Return true to allow + * it to be resumed as normal, or false to cancel/reject this activity. + */ + boolean activityResuming(String pkg); + + /** + * An application process has crashed (in Java). Return true for the + * normal error recovery (app crash dialog) to occur, false to kill + * it immediately. + */ + boolean appCrashed(String processName, int pid, String shortMsg, + String longMsg, in byte[] crashData); + + /** + * An application process is not responding. Return 0 to show the "app + * not responding" dialog, 1 to continue waiting, or -1 to kill it + * immediately. + */ + int appNotResponding(String processName, int pid, String processStats); +} diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 3ec7938..ee1b69b 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -216,7 +216,7 @@ public interface IActivityManager extends IInterface { String packageName, boolean waitForDebugger, boolean persistent) throws RemoteException; public void setAlwaysFinish(boolean enabled) throws RemoteException; - public void setActivityWatcher(IActivityWatcher watcher) + public void setActivityController(IActivityController watcher) throws RemoteException; public void enterSafeMode() throws RemoteException; @@ -257,6 +257,11 @@ public interface IActivityManager extends IInterface { public void stopAppSwitches() throws RemoteException; public void resumeAppSwitches() throws RemoteException; + public void registerActivityWatcher(IActivityWatcher watcher) + throws RemoteException; + public void unregisterActivityWatcher(IActivityWatcher watcher) + throws RemoteException; + /* * Private non-Binder interfaces */ @@ -372,7 +377,7 @@ public interface IActivityManager extends IInterface { int CHECK_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+53; int GRANT_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+54; int REVOKE_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+55; - int SET_ACTIVITY_WATCHER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+56; + int SET_ACTIVITY_CONTROLLER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+56; int SHOW_WAITING_FOR_DEBUGGER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+57; int SIGNAL_PERSISTENT_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+58; int GET_RECENT_TASKS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+59; @@ -408,4 +413,6 @@ public interface IActivityManager extends IInterface { int START_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+89; int BACKUP_AGENT_CREATED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+90; int UNBIND_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+91; + int REGISTER_ACTIVITY_WATCHER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+92; + int UNREGISTER_ACTIVITY_WATCHER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+93; } diff --git a/core/java/android/app/IActivityWatcher.aidl b/core/java/android/app/IActivityWatcher.aidl index f13a385..5d36e3f 100644 --- a/core/java/android/app/IActivityWatcher.aidl +++ b/core/java/android/app/IActivityWatcher.aidl @@ -1,6 +1,6 @@ -/* //device/java/android/android/app/IInstrumentationWatcher.aidl +/* ** -** Copyright 2007, The Android Open Source Project +** Copyright 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. @@ -17,39 +17,10 @@ package android.app; -import android.content.Intent; - /** - * Testing interface to monitor what is happening in the activity manager - * while tests are running. Not for normal application development. + * Callback interface to watch the user's traversal through activities. * {@hide} */ -interface IActivityWatcher -{ - /** - * The system is trying to start an activity. Return true to allow - * it to be started as normal, or false to cancel/reject this activity. - */ - boolean activityStarting(in Intent intent, String pkg); - - /** - * The system is trying to return to an activity. Return true to allow - * it to be resumed as normal, or false to cancel/reject this activity. - */ - boolean activityResuming(String pkg); - - /** - * An application process has crashed (in Java). Return true for the - * normal error recovery (app crash dialog) to occur, false to kill - * it immediately. - */ - boolean appCrashed(String processName, int pid, String shortMsg, - String longMsg, in byte[] crashData); - - /** - * An application process is not responding. Return 0 to show the "app - * not responding" dialog, 1 to continue waiting, or -1 to kill it - * immediately. - */ - int appNotResponding(String processName, int pid, String processStats); +oneway interface IActivityWatcher { + void activityResuming(int activityId); } diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java index c0bc2a0..c915770 100644 --- a/core/java/android/app/IApplicationThread.java +++ b/core/java/android/app/IApplicationThread.java @@ -49,7 +49,7 @@ public interface IApplicationThread extends IInterface { void scheduleWindowVisibility(IBinder token, boolean showWindow) throws RemoteException; void scheduleResumeActivity(IBinder token, boolean isForward) throws RemoteException; void scheduleSendResult(IBinder token, List<ResultInfo> results) throws RemoteException; - void scheduleLaunchActivity(Intent intent, IBinder token, + void scheduleLaunchActivity(Intent intent, IBinder token, int ident, ActivityInfo info, Bundle state, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, boolean notResumed, boolean isForward) throws RemoteException; diff --git a/core/java/android/app/ISearchManager.aidl b/core/java/android/app/ISearchManager.aidl index 5b62192..84a6085 100644 --- a/core/java/android/app/ISearchManager.aidl +++ b/core/java/android/app/ISearchManager.aidl @@ -34,6 +34,7 @@ interface ISearchManager { in ComponentName launchActivity, in Bundle appSearchData, boolean globalSearch, - ISearchManagerCallback searchManagerCallback); + ISearchManagerCallback searchManagerCallback, + int ident); void stopSearch(); } diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 9f44c7e..1283b8f 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -337,16 +337,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mActivityContext = mSearchable.getActivityContext(getContext()); // show the dialog. this will call onStart(). - if (!isShowing()) { - // First make sure the keyboard is showing (if needed), so that we get the right height - // for the dropdown to respect the IME. - if (getContext().getResources().getConfiguration().hardKeyboardHidden == - Configuration.HARDKEYBOARDHIDDEN_YES) { - InputMethodManager inputManager = (InputMethodManager) - getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - inputManager.showSoftInputUnchecked(0, null); - } - + if (!isShowing()) { // The Dialog uses a ContextThemeWrapper for the context; use this to change the // theme out from underneath us, between the global search theme and the in-app // search theme. They are identical except that the global search theme does not @@ -752,6 +743,9 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS } public void afterTextChanged(Editable s) { + if (mSearchable == null) { + return; + } if (mSearchable.autoUrlDetect() && !mSearchAutoComplete.isPerformingCompletion()) { // The user changed the query, check if it is a URL and if so change the search // button in the soft keyboard to the 'Go' button. @@ -1532,7 +1526,22 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS @Override public void performCompletion() { } - + + /** + * We override this method to be sure and show the soft keyboard if appropriate when + * the TextView has focus. + */ + @Override + public void onWindowFocusChanged(boolean hasWindowFocus) { + super.onWindowFocusChanged(hasWindowFocus); + + if (hasWindowFocus) { + InputMethodManager inputManager = (InputMethodManager) + getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + inputManager.showSoftInput(this, 0); + } + } + /** * We override this method so that we can allow a threshold of zero, which ACTV does not. */ diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index 0291882..b795a54 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -1531,6 +1531,8 @@ public class SearchManager private final Context mContext; + private int mIdent; + // package private since they are used by the inner class SearchManagerCallback /* package */ boolean mIsShowing = false; /* package */ final Handler mHandler; @@ -1546,6 +1548,13 @@ public class SearchManager ServiceManager.getService(Context.SEARCH_SERVICE)); } + /*package*/ void setIdent(int ident) { + if (mIdent != 0) { + throw new IllegalStateException("mIdent already set"); + } + mIdent = ident; + } + /** * Launch search UI. * @@ -1593,11 +1602,13 @@ public class SearchManager boolean globalSearch) { if (DBG) debug("startSearch(), mIsShowing=" + mIsShowing); if (mIsShowing) return; + if (mIdent == 0) throw new IllegalArgumentException( + "Called from outside of an Activity context"); try { mIsShowing = true; // activate the search manager and start it up! mService.startSearch(initialQuery, selectInitialQuery, launchActivity, appSearchData, - globalSearch, mSearchManagerCallback); + globalSearch, mSearchManagerCallback, mIdent); } catch (RemoteException ex) { Log.e(TAG, "startSearch() failed: " + ex); } diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java index c8e952f..58e66b6 100644 --- a/core/java/android/app/SuggestionsAdapter.java +++ b/core/java/android/app/SuggestionsAdapter.java @@ -16,8 +16,13 @@ package android.app; +import android.app.SearchManager.DialogCursorProtocol; +import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.ColorStateList; import android.content.res.Resources; import android.database.Cursor; @@ -38,8 +43,6 @@ import android.widget.ImageView; import android.widget.ResourceCursorAdapter; import android.widget.TextView; -import static android.app.SearchManager.DialogCursorProtocol; - import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -310,19 +313,39 @@ class SuggestionsAdapter extends ResourceCursorAdapter { text2 = cursor.getString(mText2Col); } ((SuggestionItemView)view).setTextStrings(text1, text2, isHtml, mProviderContext); - setViewIcon(cursor, views.mIcon1, mIconName1Col); - setViewIcon(cursor, views.mIcon2, mIconName2Col); + if (views.mIcon1 != null) { + setViewDrawable(views.mIcon1, getIcon1(cursor)); + } + if (views.mIcon2 != null) { + setViewDrawable(views.mIcon2, getIcon2(cursor)); + } } - private void setViewIcon(Cursor cursor, ImageView v, int iconNameCol) { - if (v == null) { - return; - } - if (iconNameCol < 0) { - return; + private Drawable getIcon1(Cursor cursor) { + if (mIconName1Col < 0) { + return null; } - String value = cursor.getString(iconNameCol); + String value = cursor.getString(mIconName1Col); Drawable drawable = getDrawableFromResourceValue(value); + if (drawable != null) { + return drawable; + } + return getDefaultIcon1(cursor); + } + + private Drawable getIcon2(Cursor cursor) { + if (mIconName2Col < 0) { + return null; + } + String value = cursor.getString(mIconName2Col); + return getDrawableFromResourceValue(value); + } + + /** + * Sets the drawable in an image view, makes sure the view is only visible if there + * is a drawable. + */ + private void setViewDrawable(ImageView v, Drawable drawable) { // Set the icon even if the drawable is null, since we need to clear any // previous icon. v.setImageDrawable(drawable); @@ -474,6 +497,88 @@ class SuggestionsAdapter extends ResourceCursorAdapter { } /** + * Gets the left-hand side icon that will be used for the current suggestion + * if the suggestion contains an icon column but no icon or a broken icon. + * + * @param cursor A cursor positioned at the current suggestion. + * @return A non-null drawable. + */ + private Drawable getDefaultIcon1(Cursor cursor) { + // First check the component that the suggestion is originally from + String c = getColumnString(cursor, SearchManager.SUGGEST_COLUMN_INTENT_COMPONENT_NAME); + if (c != null) { + ComponentName component = ComponentName.unflattenFromString(c); + if (component != null) { + Drawable drawable = getActivityIconWithCache(component); + if (drawable != null) { + return drawable; + } + } else { + Log.w(LOG_TAG, "Bad component name: " + c); + } + } + + // Then check the component that gave us the suggestion + Drawable drawable = getActivityIconWithCache(mSearchable.getSearchActivity()); + if (drawable != null) { + return drawable; + } + + // Fall back to a default icon + return mContext.getPackageManager().getDefaultActivityIcon(); + } + + /** + * Gets the activity or application icon for an activity. + * Uses the local icon cache for fast repeated lookups. + * + * @param component Name of an activity. + * @return A drawable, or {@code null} if neither the activity nor the application + * has an icon set. + */ + private Drawable getActivityIconWithCache(ComponentName component) { + // First check the icon cache + String componentIconKey = component.flattenToShortString(); + // Using containsKey() since we also store null values. + if (mOutsideDrawablesCache.containsKey(componentIconKey)) { + return mOutsideDrawablesCache.get(componentIconKey); + } + // Then try the activity or application icon + Drawable drawable = getActivityIcon(component); + // Stick it in the cache so we don't do this lookup again. + mOutsideDrawablesCache.put(componentIconKey, drawable); + return drawable; + } + + /** + * Gets the activity or application icon for an activity. + * + * @param component Name of an activity. + * @return A drawable, or {@code null} if neither the acitivy or the application + * have an icon set. + */ + private Drawable getActivityIcon(ComponentName component) { + PackageManager pm = mContext.getPackageManager(); + final ActivityInfo activityInfo; + try { + activityInfo = pm.getActivityInfo(component, PackageManager.GET_META_DATA); + } catch (NameNotFoundException ex) { + Log.w(LOG_TAG, ex.toString()); + return null; + } + int iconId = activityInfo.getIconResource(); + if (iconId == 0) return null; + String pkg = component.getPackageName(); + Drawable drawable = pm.getDrawable(pkg, iconId, activityInfo.applicationInfo); + if (drawable == null) { + Log.w(LOG_TAG, "Invalid icon resource " + iconId + " for " + + component.flattenToShortString()); + return null; + } + return drawable; + } + + /** * Gets the value of a string column by name. * * @param cursor Cursor to read the value from. diff --git a/core/java/android/content/DialogInterface.java b/core/java/android/content/DialogInterface.java index 4afa294..9f1036e 100644 --- a/core/java/android/content/DialogInterface.java +++ b/core/java/android/content/DialogInterface.java @@ -92,6 +92,21 @@ public interface DialogInterface { } /** + * Interface used to allow the creator of a dialog to run some code when the + * dialog is shown. + * @hide Pending API council approval + */ + interface OnShowListener { + /** + * This method will be invoked when the dialog is shown. + * + * @param dialog The dialog that was shown will be passed into the + * method. + */ + public void onShow(DialogInterface dialog); + } + + /** * Interface used to allow the creator of a dialog to run some code when an * item on the dialog is clicked.. */ diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java index 13bcdd3..9d2efb5 100644 --- a/core/java/android/content/SyncStorageEngine.java +++ b/core/java/android/content/SyncStorageEngine.java @@ -326,6 +326,7 @@ public class SyncStorageEngine extends Handler { } reports.add(mChangeListeners.getBroadcastItem(i)); } + mChangeListeners.finishBroadcast(); } if (DEBUG) Log.v(TAG, "reportChange " + which + " to: " + reports); diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 8de938d..a9aa1ee 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -34,6 +34,7 @@ import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import android.util.LongSparseArray; +import android.view.Display; import java.io.IOException; import java.io.InputStream; @@ -87,6 +88,7 @@ public class Resources { PluralRules mPluralRule; private final CompatibilityInfo mCompatibilityInfo; + private Display mDefaultDisplay; private static final LongSparseArray<Object> EMPTY_ARRAY = new LongSparseArray<Object>() { @Override @@ -1915,6 +1917,24 @@ public class Resources { + Integer.toHexString(id)); } + /** + * Returns the display adjusted for the Resources' metrics. + * @hide + */ + public Display getDefaultDisplay(Display defaultDisplay) { + if (mDefaultDisplay == null) { + if (!mCompatibilityInfo.isScalingRequired() && mCompatibilityInfo.supportsScreen()) { + // the app supports the display. just use the default one. + mDefaultDisplay = defaultDisplay; + } else { + // display needs adjustment. + mDefaultDisplay = Display.createMetricsBasedDisplay( + defaultDisplay.getDisplayId(), mMetrics); + } + } + return mDefaultDisplay; + } + private TypedArray getCachedStyledAttributes(int len) { synchronized (mTmpValue) { TypedArray attrs = mCachedStyledAttributes; diff --git a/core/java/android/os/RemoteCallbackList.java b/core/java/android/os/RemoteCallbackList.java index 5ab305e..b74af16 100644 --- a/core/java/android/os/RemoteCallbackList.java +++ b/core/java/android/os/RemoteCallbackList.java @@ -50,6 +50,7 @@ public class RemoteCallbackList<E extends IInterface> { /*package*/ HashMap<IBinder, Callback> mCallbacks = new HashMap<IBinder, Callback>(); private Object[] mActiveBroadcast; + private int mBroadcastCount = -1; private boolean mKilled = false; private final class Callback implements IBinder.DeathRecipient { @@ -196,15 +197,16 @@ public class RemoteCallbackList<E extends IInterface> { * This creates a copy of the callback list, which you can retrieve items * from using {@link #getBroadcastItem}. Note that only one broadcast can * be active at a time, so you must be sure to always call this from the - * same thread (usually by scheduling with {@link Handler} or + * same thread (usually by scheduling with {@link Handler}) or * do your own synchronization. You must call {@link #finishBroadcast} * when done. * * <p>A typical loop delivering a broadcast looks like this: * * <pre> - * final int N = callbacks.beginBroadcast(); - * for (int i=0; i<N; i++) { + * int i = callbacks.beginBroadcast(); + * while (i > 0) { + * i--; * try { * callbacks.getBroadcastItem(i).somethingHappened(); * } catch (RemoteException e) { @@ -223,7 +225,12 @@ public class RemoteCallbackList<E extends IInterface> { */ public int beginBroadcast() { synchronized (mCallbacks) { - final int N = mCallbacks.size(); + if (mBroadcastCount > 0) { + throw new IllegalStateException( + "beginBroadcast() called while already in a broadcast"); + } + + final int N = mBroadcastCount = mCallbacks.size(); if (N <= 0) { return 0; } @@ -282,12 +289,19 @@ public class RemoteCallbackList<E extends IInterface> { * @see #beginBroadcast */ public void finishBroadcast() { + if (mBroadcastCount < 0) { + throw new IllegalStateException( + "finishBroadcast() called outside of a broadcast"); + } + Object[] active = mActiveBroadcast; if (active != null) { - final int N = active.length; + final int N = mBroadcastCount; for (int i=0; i<N; i++) { active[i] = null; } } + + mBroadcastCount = -1; } } diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 3d14af7..b54ad5d 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -151,34 +151,20 @@ public class CallLog { int presentation, int callType, long start, int duration) { final ContentResolver resolver = context.getContentResolver(); - // TODO(Moto): Which is correct: original code, this only changes the - // number if the number is empty and never changes the caller info name. - if (false) { - if (TextUtils.isEmpty(number)) { - if (presentation == Connection.PRESENTATION_RESTRICTED) { - number = CallerInfo.PRIVATE_NUMBER; - } else if (presentation == Connection.PRESENTATION_PAYPHONE) { - number = CallerInfo.PAYPHONE_NUMBER; - } else { - number = CallerInfo.UNKNOWN_NUMBER; - } - } - } else { - // NEWCODE: From Motorola - - //If this is a private number then set the number to Private, otherwise check - //if the number field is empty and set the number to Unavailable + // If this is a private number then set the number to Private, otherwise check + // if the number field is empty and set the number to Unavailable if (presentation == Connection.PRESENTATION_RESTRICTED) { number = CallerInfo.PRIVATE_NUMBER; - ci.name = ""; + if (ci != null) ci.name = ""; } else if (presentation == Connection.PRESENTATION_PAYPHONE) { number = CallerInfo.PAYPHONE_NUMBER; - ci.name = ""; - } else if (TextUtils.isEmpty(number) || presentation == Connection.PRESENTATION_UNKNOWN) { + if (ci != null) ci.name = ""; + } else if (TextUtils.isEmpty(number) + || presentation == Connection.PRESENTATION_UNKNOWN) { number = CallerInfo.UNKNOWN_NUMBER; - ci.name = ""; + if (ci != null) ci.name = ""; } - } + ContentValues values = new ContentValues(5); values.put(NUMBER, number); diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 04a5a0f..718a120 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -1012,6 +1012,16 @@ public final class ContactsContract { public static final String SOURCE_ID = "sourceid"; /** + * An integer that is updated whenever this contact or its data changes. + */ + public static final String VERSION = "version"; + + /** + * Set to 1 whenever the version changes + */ + public static final String DIRTY = "dirty"; + + /** * Flag indicating if the contacts belonging to this group should be * visible in any user interface. * <p> diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 6f707cb..353204e 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2714,6 +2714,12 @@ public final class Settings { public static final String GMAIL_NUM_RETRY_UPHILL_OP = "gmail_discard_error_uphill_op"; /** + * Controls if the protocol buffer version of the protocol will use a multipart request for + * attachment uploads. Value must be an integer where non-zero means true. Defaults to 0. + */ + public static final String GMAIL_USE_MULTIPART_PROTOBUF = "gmail_use_multipart_protobuf"; + + /** * the transcoder URL for mobile devices. */ public static final String TRANSCODER_URL = "mobile_transcoder_url"; diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 47a1285..7a6f6bb 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -44,7 +44,7 @@ import java.util.regex.Pattern; */ public final class Telephony { private static final String TAG = "Telephony"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = true; private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV; // Constructor @@ -1148,8 +1148,14 @@ public final class Telephony { } Uri uri = uriBuilder.build(); + if (DEBUG) { + Log.v(TAG, "getOrCreateThreadId uri: " + uri); + } Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), uri, ID_PROJECTION, null, null, null); + if (DEBUG) { + Log.v(TAG, "getOrCreateThreadId cursor cnt: " + cursor.getCount()); + } if (cursor != null) { try { if (cursor.moveToFirst()) { @@ -1642,7 +1648,7 @@ public final class Telephony { * * It is recommended to display <em>plmn</em> before / above <em>spn</em> if * both are displayed. - * + * * <p>Note this is a protected intent that can only be sent * by the system. */ diff --git a/core/java/android/server/BluetoothDeviceService.java b/core/java/android/server/BluetoothDeviceService.java index 77b1b1d..13d980d 100644 --- a/core/java/android/server/BluetoothDeviceService.java +++ b/core/java/android/server/BluetoothDeviceService.java @@ -285,6 +285,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub { if (isEnabled()) { SystemService.start("hsag"); SystemService.start("hfag"); + SystemService.start("opush"); } break; case MESSAGE_FINISH_DISABLE: diff --git a/core/java/android/server/search/SearchDialogWrapper.java b/core/java/android/server/search/SearchDialogWrapper.java index dbc1e7f..70c7d73 100644 --- a/core/java/android/server/search/SearchDialogWrapper.java +++ b/core/java/android/server/search/SearchDialogWrapper.java @@ -49,7 +49,7 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { private static final String SEARCH_UI_THREAD_NAME = "SearchDialog"; private static final int SEARCH_UI_THREAD_PRIORITY = - android.os.Process.THREAD_PRIORITY_FOREGROUND; + android.os.Process.THREAD_PRIORITY_DEFAULT; // Takes no arguments private static final int MSG_INIT = 0; @@ -63,12 +63,13 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { private static final int MSG_START_SEARCH = 1; // Takes no arguments private static final int MSG_STOP_SEARCH = 2; - // Takes no arguments - private static final int MSG_ON_CONFIGURATION_CHANGED = 3; + // arg1 is activity id + private static final int MSG_ACTIVITY_RESUMING = 3; private static final String KEY_INITIAL_QUERY = "q"; private static final String KEY_LAUNCH_ACTIVITY = "a"; private static final String KEY_APP_SEARCH_DATA = "d"; + private static final String KEY_IDENT= "i"; // Context used for getting search UI resources private final Context mContext; @@ -82,9 +83,18 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { // If the search UI is visible, this is the callback for the client that showed it. ISearchManagerCallback mCallback = null; + // Identity of last activity that started search. + private int mStartedIdent = 0; + + // Identity of currently resumed activity. + private int mResumedIdent = 0; + // Allows disabling of search dialog for stress testing runs private final boolean mDisabledOnBoot; + // True if we have registered our receivers. + private boolean mReceiverRegistered; + /** * Creates a new search dialog wrapper and a search UI thread. The search dialog itself will * be created some asynchronously on the search UI thread. @@ -116,15 +126,21 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { } private void registerBroadcastReceiver() { - IntentFilter closeDialogsFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); - mContext.registerReceiver(mBroadcastReceiver, closeDialogsFilter); - IntentFilter configurationChangedFilter = - new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED); - mContext.registerReceiver(mBroadcastReceiver, configurationChangedFilter); + if (!mReceiverRegistered) { + IntentFilter filter = new IntentFilter( + Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); + mContext.registerReceiver(mBroadcastReceiver, filter, null, + mSearchUiThread); + mReceiverRegistered = true; + } } private void unregisterBroadcastReceiver() { - mContext.unregisterReceiver(mBroadcastReceiver); + if (mReceiverRegistered) { + mContext.unregisterReceiver(mBroadcastReceiver); + mReceiverRegistered = false; + } } /** @@ -136,10 +152,10 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { String action = intent.getAction(); if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { if (DBG) debug(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); - stopSearch(); + performStopSearch(); } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { if (DBG) debug(Intent.ACTION_CONFIGURATION_CHANGED); - onConfigurationChanged(); + performOnConfigurationChanged(); } } }; @@ -159,7 +175,8 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { final ComponentName launchActivity, final Bundle appSearchData, final boolean globalSearch, - final ISearchManagerCallback searchManagerCallback) { + final ISearchManagerCallback searchManagerCallback, + int ident) { if (DBG) debug("startSearch()"); Message msg = Message.obtain(); msg.what = MSG_START_SEARCH; @@ -170,6 +187,7 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { msgData.putString(KEY_INITIAL_QUERY, initialQuery); msgData.putParcelable(KEY_LAUNCH_ACTIVITY, launchActivity); msgData.putBundle(KEY_APP_SEARCH_DATA, appSearchData); + msgData.putInt(KEY_IDENT, ident); mSearchUiThread.sendMessage(msg); } @@ -183,12 +201,15 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { } /** - * Updates the search UI in response to a configuration change. + * Updates the currently resumed activity. * Can be called from any thread. */ - void onConfigurationChanged() { - if (DBG) debug("onConfigurationChanged()"); - mSearchUiThread.sendEmptyMessage(MSG_ON_CONFIGURATION_CHANGED); + public void activityResuming(int ident) { + if (DBG) debug("startSearch()"); + Message msg = Message.obtain(); + msg.what = MSG_ACTIVITY_RESUMING; + msg.arg1 = ident; + mSearchUiThread.sendMessage(msg); } // @@ -213,8 +234,8 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { case MSG_STOP_SEARCH: performStopSearch(); break; - case MSG_ON_CONFIGURATION_CHANGED: - performOnConfigurationChanged(); + case MSG_ACTIVITY_RESUMING: + performActivityResuming(msg.arg1); break; } } @@ -228,12 +249,27 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { Bundle appSearchData = msgData.getBundle(KEY_APP_SEARCH_DATA); boolean globalSearch = msg.arg2 != 0; ISearchManagerCallback searchManagerCallback = (ISearchManagerCallback) msg.obj; + int ident = msgData.getInt(KEY_IDENT); performStartSearch(initialQuery, selectInitialQuery, launchActivity, - appSearchData, globalSearch, searchManagerCallback); + appSearchData, globalSearch, searchManagerCallback, ident); } } + void updateDialogVisibility() { + if (mStartedIdent != 0) { + // mResumedIdent == 0 means we have just booted and the user + // hasn't yet gone anywhere. + if (mResumedIdent == 0 || mStartedIdent == mResumedIdent) { + if (DBG) Log.v(TAG, "******************* DIALOG: show"); + mSearchDialog.show(); + } else { + if (DBG) Log.v(TAG, "******************* DIALOG: hide"); + mSearchDialog.hide(); + } + } + } + /** * Actually launches the search UI. * This must be called on the search UI thread. @@ -243,7 +279,8 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { ComponentName launchActivity, Bundle appSearchData, boolean globalSearch, - ISearchManagerCallback searchManagerCallback) { + ISearchManagerCallback searchManagerCallback, + int ident) { if (DBG) debug("performStartSearch()"); if (mDisabledOnBoot) { @@ -254,8 +291,11 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { registerBroadcastReceiver(); mCallback = searchManagerCallback; + mStartedIdent = ident; + if (DBG) Log.v(TAG, "******************* DIALOG: start"); mSearchDialog.show(initialQuery, selectInitialQuery, launchActivity, appSearchData, globalSearch); + updateDialogVisibility(); } /** @@ -264,7 +304,20 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { */ void performStopSearch() { if (DBG) debug("performStopSearch()"); + if (DBG) Log.v(TAG, "******************* DIALOG: cancel"); mSearchDialog.cancel(); + mStartedIdent = 0; + } + + /** + * Updates the resumed activity + * This must be called on the search UI thread. + */ + void performActivityResuming(int ident) { + if (DBG) debug("performResumingActivity(): mStartedIdent=" + + mStartedIdent + ", resuming: " + ident); + this.mResumedIdent = ident; + updateDialogVisibility(); } /** diff --git a/core/java/android/server/search/SearchManagerService.java b/core/java/android/server/search/SearchManagerService.java index f9c0f1a..7629912 100644 --- a/core/java/android/server/search/SearchManagerService.java +++ b/core/java/android/server/search/SearchManagerService.java @@ -16,6 +16,8 @@ package android.server.search; +import android.app.ActivityManagerNative; +import android.app.IActivityWatcher; import android.app.ISearchManager; import android.app.ISearchManagerCallback; import android.app.SearchManager; @@ -26,6 +28,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.Handler; +import android.os.RemoteException; import android.util.Log; import java.util.List; @@ -71,8 +74,11 @@ public class SearchManagerService extends ISearchManager.Stub { * Initializes the list of searchable activities and the search UI. */ void initialize() { - ensureSearchablesCreated(); - ensureSearchDialogCreated(); + try { + ActivityManagerNative.getDefault().registerActivityWatcher( + mActivityWatcher); + } catch (RemoteException e) { + } } private synchronized void ensureSearchablesCreated() { @@ -126,6 +132,14 @@ public class SearchManagerService extends ISearchManager.Stub { } }; + private IActivityWatcher.Stub mActivityWatcher = new IActivityWatcher.Stub() { + public void activityResuming(int activityId) throws RemoteException { + if (DBG) Log.i("foo", "********************** resuming: " + activityId); + if (mSearchDialog == null) return; + mSearchDialog.activityResuming(activityId); + } + }; + /** * Informs all listeners that the list of searchables has been updated. */ @@ -206,13 +220,15 @@ public class SearchManagerService extends ISearchManager.Stub { ComponentName launchActivity, Bundle appSearchData, boolean globalSearch, - ISearchManagerCallback searchManagerCallback) { + ISearchManagerCallback searchManagerCallback, + int ident) { getSearchDialog().startSearch(initialQuery, selectInitialQuery, launchActivity, appSearchData, globalSearch, - searchManagerCallback); + searchManagerCallback, + ident); } /** diff --git a/core/java/android/speech/tts/ITts.aidl b/core/java/android/speech/tts/ITts.aidl index 5b18b5d..1812188 100755 --- a/core/java/android/speech/tts/ITts.aidl +++ b/core/java/android/speech/tts/ITts.aidl @@ -55,9 +55,9 @@ interface ITts { void addEarconFile(in String callingApp, in String earcon, in String filename);
- void registerCallback(ITtsCallback cb);
+ int registerCallback(in String callingApp, ITtsCallback cb);
- void unregisterCallback(ITtsCallback cb);
+ int unregisterCallback(in String callingApp, ITtsCallback cb);
int playSilence(in String callingApp, in long duration, in int queueMode, in String[] params);
}
diff --git a/core/java/android/speech/tts/ITtsCallback.aidl b/core/java/android/speech/tts/ITtsCallback.aidl index 48ed73e..c9898eb 100755 --- a/core/java/android/speech/tts/ITtsCallback.aidl +++ b/core/java/android/speech/tts/ITtsCallback.aidl @@ -23,5 +23,5 @@ package android.speech.tts; * {@hide} */ oneway interface ITtsCallback { - void markReached(String mark); + void utteranceCompleted(String utteranceId); } diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index 2369535..a2e70b8 100644..100755 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -99,6 +99,18 @@ public class TextToSpeech { } /** + * Called when the TTS has completed saying something that has an utterance ID set. + * + * The OnUtteranceCompletedListener must implement the onUtteranceCompleted function. + * onUtteranceCompleted is passed a String that is the utteranceId given in + * the original speak call. + */ + public interface OnUtteranceCompletedListener {
+ public void onUtteranceCompleted(String utteranceId);
+ } + + + /** * Internal constants for the TTS functionality * * {@hide} @@ -147,6 +159,7 @@ public class TextToSpeech { private ServiceConnection mServiceConnection; private ITts mITts = null; + private ITtsCallback mITtscallback = null; private Context mContext = null; private String mPackageName = ""; private OnInitListener mInitListener = null; @@ -178,6 +191,7 @@ public class TextToSpeech { mCachedParams[Engine.TTS_PARAM_POSITION_COUNTRY] = Engine.TTS_KEY_PARAM_COUNTRY; mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT] = Engine.TTS_KEY_PARAM_VARIANT; mCachedParams[Engine.TTS_PARAM_POSITION_STREAM] = Engine.TTS_KEY_PARAM_STREAM; + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = Engine.TTS_KEY_PARAM_UTTERANCE_ID; mCachedParams[Engine.TTS_PARAM_POSITION_RATE + 1] = String.valueOf(Engine.FALLBACK_TTS_DEFAULT_RATE); @@ -189,7 +203,7 @@ public class TextToSpeech { mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = String.valueOf(Engine.TTS_DEFAULT_STREAM); - mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID+ 1] = ""; + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = ""; initTts(); } @@ -380,7 +394,7 @@ public class TextToSpeech { } extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); if (extra != null) { - mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra; } } result = mITts.speak(mPackageName, text, queueMode, mCachedParams); @@ -437,7 +451,7 @@ public class TextToSpeech { } extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); if (extra != null) { - mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra; } } result = mITts.playEarcon(mPackageName, earcon, queueMode, null); @@ -477,13 +491,19 @@ public class TextToSpeech { * * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS. */ - public int playSilence(long durationInMs, int queueMode) { + public int playSilence(long durationInMs, int queueMode, HashMap<String,String> params) { synchronized (mStartLock) { int result = TTS_ERROR; if (!mStarted) { return result; } try { + if ((params != null) && (!params.isEmpty())) { + String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); + if (extra != null) { + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra; + } + } result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams); } catch (RemoteException e) { // TTS died; restart it. @@ -845,7 +865,7 @@ public class TextToSpeech { // no need to read the stream type here String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); if (extra != null) { - mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; + mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra; } } if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){ @@ -887,4 +907,52 @@ public class TextToSpeech { mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID+ 1] = ""; } + /** + * Sets the OnUtteranceCompletedListener that will fire when an utterance completes. + * + * @param listener + * The OnUtteranceCompletedListener + * + * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS. + */ + public int setOnUtteranceCompletedListener(
+ final OnUtteranceCompletedListener listener) {
+ synchronized (mStartLock) { + int result = TTS_ERROR; + if (!mStarted) { + return result; + } + mITtscallback = new ITtsCallback.Stub() { + public void utteranceCompleted(String utteranceId) throws RemoteException {
+ if (listener != null) {
+ listener.onUtteranceCompleted(utteranceId);
+ }
+ }
+ }; + try { + result = mITts.registerCallback(mPackageName, mITtscallback); + } catch (RemoteException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - registerCallback", "RemoteException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (NullPointerException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - registerCallback", "NullPointerException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } catch (IllegalStateException e) { + // TTS died; restart it. + Log.e("TextToSpeech.java - registerCallback", "IllegalStateException"); + e.printStackTrace(); + mStarted = false; + initTts(); + } finally { + return result; + } + }
+ } + } diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 09ebeed..5551f64 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -117,5 +117,32 @@ public class Display private static final Object mStaticInit = new Object(); private static boolean mInitialized = false; + + /** + * Returns a display object which uses the metric's width/height instead. + * @hide + */ + public static Display createMetricsBasedDisplay(int displayId, DisplayMetrics metrics) { + return new CompatibleDisplay(displayId, metrics); + } + + private static class CompatibleDisplay extends Display { + private final DisplayMetrics mMetrics; + + private CompatibleDisplay(int displayId, DisplayMetrics metrics) { + super(displayId); + mMetrics = metrics; + } + + @Override + public int getWidth() { + return mMetrics.widthPixels; + } + + @Override + public int getHeight() { + return mMetrics.heightPixels; + } + } } diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 5776851..1e3cdb3 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -1374,6 +1374,15 @@ public final class ViewRoot extends Handler implements ViewParent, // is non-null and we just want to scroll to whatever that // rectangle is). View focus = mRealFocusedView; + + // When in touch mode, focus points to the previously focused view, + // which may have been removed from the view hierarchy. The following + // line checks whether the view is still in the hierarchy + if (focus == null || focus.getParent() == null) { + mRealFocusedView = null; + return false; + } + if (focus != mLastScrolledFocus) { // If the focus has changed, then ignore any requests to scroll // to a rectangle; first we want to make sure the entire focus diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 2c32d8b..02e0515 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -358,6 +358,8 @@ public abstract class Window { private class LocalWindowManager implements WindowManager { LocalWindowManager(WindowManager wm) { mWindowManager = wm; + mDefaultDisplay = mContext.getResources().getDefaultDisplay( + mWindowManager.getDefaultDisplay()); } public final void addView(View view, ViewGroup.LayoutParams params) { @@ -420,10 +422,12 @@ public abstract class Window { } public Display getDefaultDisplay() { - return mWindowManager.getDefaultDisplay(); + return mDefaultDisplay; } - WindowManager mWindowManager; + private final WindowManager mWindowManager; + + private final Display mDefaultDisplay; } /** diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java index c4b5ef8..6579660 100755 --- a/core/java/android/widget/AppSecurityPermissions.java +++ b/core/java/android/widget/AppSecurityPermissions.java @@ -18,6 +18,7 @@ package android.widget; import com.android.internal.R; import android.content.Context; +import android.content.res.Resources; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageParser; @@ -319,15 +320,14 @@ public class AppSecurityPermissions implements View.OnClickListener { boolean dangerous) { View permView = mInflater.inflate(R.layout.app_permission_item, null); Drawable icon = dangerous ? mDangerousIcon : mNormalIcon; - int grpColor = dangerous ? R.color.perms_dangerous_grp_color : - R.color.perms_normal_grp_color; - int permColor = dangerous ? R.color.perms_dangerous_perm_color : - R.color.perms_normal_perm_color; TextView permGrpView = (TextView) permView.findViewById(R.id.permission_group); TextView permDescView = (TextView) permView.findViewById(R.id.permission_list); - permGrpView.setTextColor(mContext.getResources().getColor(grpColor)); - permDescView.setTextColor(mContext.getResources().getColor(permColor)); + if (dangerous) { + final Resources resources = mContext.getResources(); + permGrpView.setTextColor(resources.getColor(R.color.perms_dangerous_grp_color)); + permDescView.setTextColor(resources.getColor(R.color.perms_dangerous_perm_color)); + } ImageView imgView = (ImageView)permView.findViewById(R.id.perm_icon); imgView.setImageDrawable(icon); diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index be3dd19..ae509c5 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -31,6 +31,7 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.EditorInfo; @@ -141,6 +142,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe mPopup = new PopupWindow(context, attrs, com.android.internal.R.attr.autoCompleteTextViewStyle); + mPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); TypedArray a = context.obtainStyledAttributes( diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 54f2707..3b9f1de 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -110,6 +110,8 @@ public class DatePicker extends FrameLayout { * subtract by one to ensure our internal state is always 0-11 */ mMonth = newVal - 1; + // Adjust max day of the month + adjustMaxDay(); if (mOnDateChangedListener != null) { mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay); } @@ -121,9 +123,12 @@ public class DatePicker extends FrameLayout { mYearPicker.setOnChangeListener(new OnChangedListener() { public void onChanged(NumberPicker picker, int oldVal, int newVal) { mYear = newVal; + // Adjust max day for leap years if needed + adjustMaxDay(); if (mOnDateChangedListener != null) { mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay); } + updateDaySpinner(); } }); @@ -318,4 +323,14 @@ public class DatePicker extends FrameLayout { public int getDayOfMonth() { return mDay; } + + private void adjustMaxDay(){ + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, mYear); + cal.set(Calendar.MONTH, mMonth); + int max = cal.getActualMaximum(Calendar.DAY_OF_MONTH); + if (mDay > max) { + mDay = max; + } + } } diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index cd965fc..2da777a 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -26,6 +26,7 @@ import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.SystemClock; +import android.util.TypedValue; import android.view.MotionEvent; /** @@ -116,17 +117,19 @@ class FastScroller { mThumbDrawable.setAlpha(ScrollFade.ALPHA_MAX); } - private void useThumbDrawable(Drawable drawable) { + private void useThumbDrawable(Context context, Drawable drawable) { mThumbDrawable = drawable; - mThumbW = 64; //mCurrentThumb.getIntrinsicWidth(); - mThumbH = 52; //mCurrentThumb.getIntrinsicHeight(); + mThumbW = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + 64, context.getResources().getDisplayMetrics()); + mThumbH = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + 52, context.getResources().getDisplayMetrics()); mChangedBounds = true; } private void init(Context context) { // Get both the scrollbar states drawables final Resources res = context.getResources(); - useThumbDrawable(res.getDrawable( + useThumbDrawable(context, res.getDrawable( com.android.internal.R.drawable.scrollbar_handle_accelerated_anim2)); mOverlayDrawable = res.getDrawable( diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 0c2cd55..90fbb77 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -27,7 +27,6 @@ import android.view.WindowManager; import android.view.Gravity; import android.view.ViewGroup; import android.view.ViewTreeObserver; -import android.view.WindowManagerImpl; import android.view.ViewTreeObserver.OnScrollChangedListener; import android.view.View.OnTouchListener; import android.graphics.PixelFormat; @@ -82,6 +81,7 @@ public class PopupWindow { private View mPopupView; private boolean mFocusable; private int mInputMethodMode = INPUT_METHOD_FROM_FOCUSABLE; + private int mSoftInputMode; private boolean mTouchable = true; private boolean mOutsideTouchable = false; private boolean mClippingEnabled = true; @@ -446,6 +446,30 @@ public class PopupWindow { public void setInputMethodMode(int mode) { mInputMethodMode = mode; } + + /** + * Sets the operating mode for the soft input area. + * + * @param mode The desired mode, see + * {@link android.view.WindowManager.LayoutParams#softInputMode} + * for the full list + * + * @see android.view.WindowManager.LayoutParams#softInputMode + * @see #getSoftInputMode() + */ + public void setSoftInputMode(int mode) { + mSoftInputMode = mode; + } + + /** + * Returns the current value in {@link #setSoftInputMode(int)}. + * + * @see #setSoftInputMode(int) + * @see android.view.WindowManager.LayoutParams#softInputMode + */ + public int getSoftInputMode() { + return mSoftInputMode; + } /** * <p>Indicates whether the popup window receives touch events.</p> @@ -822,7 +846,7 @@ public class PopupWindow { p.flags = computeFlags(p.flags); p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; p.token = token; - p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; + p.softInputMode = mSoftInputMode; p.setTitle("PopupWindow:" + Integer.toHexString(hashCode())); return p; diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java index 3b722f4..5bc2507 100644 --- a/core/java/android/widget/VideoView.java +++ b/core/java/android/widget/VideoView.java @@ -193,7 +193,9 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { i.putExtra("command", "pause"); mContext.sendBroadcast(i); - release(); + // we shouldn't clear the target state, because somebody might have + // called start() previously + release(false); try { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnPreparedListener(mPreparedListener); @@ -208,8 +210,9 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setScreenOnWhilePlaying(true); mMediaPlayer.prepareAsync(); + // we don't set the target state here either, but preserve the + // target state that was there before. mCurrentState = STATE_PREPARING; - mTargetState = STATE_PREPARED; attachMediaController(); } catch (IOException ex) { Log.w(TAG, "Unable to open content: " + mUri, ex); @@ -438,20 +441,22 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { // after we return from this we can't use the surface any more mSurfaceHolder = null; if (mMediaController != null) mMediaController.hide(); - release(); + release(true); } }; /* * release the media player in any state */ - private void release() { + private void release(boolean cleartargetstate) { if (mMediaPlayer != null) { mMediaPlayer.reset(); mMediaPlayer.release(); mMediaPlayer = null; mCurrentState = STATE_IDLE; - mTargetState = STATE_IDLE; + if (cleartargetstate) { + mTargetState = STATE_IDLE; + } } } diff --git a/core/java/com/android/internal/widget/NumberPicker.java b/core/java/com/android/internal/widget/NumberPicker.java index 2f08c8d..0424ced 100644 --- a/core/java/com/android/internal/widget/NumberPicker.java +++ b/core/java/com/android/internal/widget/NumberPicker.java @@ -243,9 +243,11 @@ public class NumberPicker extends LinearLayout implements OnClickListener, private void validateCurrentView(CharSequence str) { int val = getSelectedPos(str.toString()); if ((val >= mStart) && (val <= mEnd)) { - mPrevious = mCurrent; - mCurrent = val; - notifyChange(); + if (mCurrent != val) { + mPrevious = mCurrent; + mCurrent = val; + notifyChange(); + } } updateView(); } diff --git a/core/jni/.android_server_BluetoothEventLoop.cpp.swp b/core/jni/.android_server_BluetoothEventLoop.cpp.swp Binary files differnew file mode 100644 index 0000000..d36e403 --- /dev/null +++ b/core/jni/.android_server_BluetoothEventLoop.cpp.swp diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index ac2705e..6776dce 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -29,15 +29,6 @@ using namespace android; -enum CallbackMessageID { - kShutterCallback = 0, - kRawCallback = 1, - kJpegCallback = 2, - kPreviewCallback = 3, - kAutoFocusCallback = 4, - kErrorCallback = 5 -}; - struct fields_t { jfieldID context; jfieldID surface; diff --git a/core/res/res/drawable/expander_ic_maximized.9.png b/core/res/res/drawable/expander_ic_maximized.9.png Binary files differindex eb461e9..778255a 100644 --- a/core/res/res/drawable/expander_ic_maximized.9.png +++ b/core/res/res/drawable/expander_ic_maximized.9.png diff --git a/core/res/res/drawable/expander_ic_minimized.9.png b/core/res/res/drawable/expander_ic_minimized.9.png Binary files differindex e3cec8d..5235c18 100644 --- a/core/res/res/drawable/expander_ic_minimized.9.png +++ b/core/res/res/drawable/expander_ic_minimized.9.png diff --git a/core/res/res/drawable/ic_bullet_key_permission.png b/core/res/res/drawable/ic_bullet_key_permission.png Binary files differindex c8a4939..ccb010f 100755..100644 --- a/core/res/res/drawable/ic_bullet_key_permission.png +++ b/core/res/res/drawable/ic_bullet_key_permission.png diff --git a/core/res/res/drawable/ic_text_dot.png b/core/res/res/drawable/ic_text_dot.png Binary files differindex bb02379..47913f6 100755..100644 --- a/core/res/res/drawable/ic_text_dot.png +++ b/core/res/res/drawable/ic_text_dot.png diff --git a/core/res/res/layout/app_perms_summary.xml b/core/res/res/layout/app_perms_summary.xml index 713c179..009eb8f 100755 --- a/core/res/res/layout/app_perms_summary.xml +++ b/core/res/res/layout/app_perms_summary.xml @@ -54,7 +54,7 @@ <View android:layout_width="fill_parent" android:layout_height="1dip" - android:background="@android:drawable/divider_horizontal_dark" /> + android:background="?android:attr/listDivider" /> <LinearLayout android:orientation="horizontal" @@ -85,7 +85,7 @@ <View android:layout_width="fill_parent" android:layout_height="1dip" - android:background="@android:drawable/divider_horizontal_dark" /> + android:background="?android:attr/listDivider" /> </LinearLayout> diff --git a/core/res/res/values-he-rIL/donottranslate-cldr.xml b/core/res/res/values-he-rIL/donottranslate-cldr.xml index e3feb1e..3378ed7 100644 --- a/core/res/res/values-he-rIL/donottranslate-cldr.xml +++ b/core/res/res/values-he-rIL/donottranslate-cldr.xml @@ -61,20 +61,20 @@ <string name="day_of_week_long_friday">יום שישי</string> <string name="day_of_week_long_saturday">יום שבת</string> - <string name="day_of_week_medium_sunday">יום א'</string> - <string name="day_of_week_medium_monday">יום ב'</string> - <string name="day_of_week_medium_tuesday">יום ג'</string> - <string name="day_of_week_medium_wednesday">יום ד'</string> - <string name="day_of_week_medium_thursday">יום ה'</string> - <string name="day_of_week_medium_friday">יום ו'</string> + <string name="day_of_week_medium_sunday">יום א\'</string> + <string name="day_of_week_medium_monday">יום ב\'</string> + <string name="day_of_week_medium_tuesday">יום ג\'</string> + <string name="day_of_week_medium_wednesday">יום ד\'</string> + <string name="day_of_week_medium_thursday">יום ה\'</string> + <string name="day_of_week_medium_friday">יום ו\'</string> <string name="day_of_week_medium_saturday">שבת</string> - <string name="day_of_week_short_sunday">יום א'</string> - <string name="day_of_week_short_monday">יום ב'</string> - <string name="day_of_week_short_tuesday">יום ג'</string> - <string name="day_of_week_short_wednesday">יום ד'</string> - <string name="day_of_week_short_thursday">יום ה'</string> - <string name="day_of_week_short_friday">יום ו'</string> + <string name="day_of_week_short_sunday">יום א\'</string> + <string name="day_of_week_short_monday">יום ב\'</string> + <string name="day_of_week_short_tuesday">יום ג\'</string> + <string name="day_of_week_short_wednesday">יום ד\'</string> + <string name="day_of_week_short_thursday">יום ה\'</string> + <string name="day_of_week_short_friday">יום ו\'</string> <string name="day_of_week_short_saturday">שבת</string> <string name="day_of_week_shortest_sunday">א</string> diff --git a/core/res/res/values-pt-rBR/donottranslate-cldr.xml b/core/res/res/values-pt-rBR/donottranslate-cldr.xml index 4729055..1111658 100644 --- a/core/res/res/values-pt-rBR/donottranslate-cldr.xml +++ b/core/res/res/values-pt-rBR/donottranslate-cldr.xml @@ -95,7 +95,7 @@ <string name="hour_minute_ampm">%-l:%M %p</string> <string name="hour_minute_cap_ampm">%-l:%M %^p</string> <string name="twelve_hour_time_format">h:mm a</string> - <string name="twenty_four_hour_time_format">H'h'mm</string> + <string name="twenty_four_hour_time_format">H\'h\'mm</string> <string name="numeric_date">%d/%m/%Y</string> <string name="numeric_date_format">dd/MM/yyyy</string> <string name="numeric_date_template">"%s/%s/%s"</string> diff --git a/core/res/res/values-pt-rPT/donottranslate-cldr.xml b/core/res/res/values-pt-rPT/donottranslate-cldr.xml index f38a2d0..197cb6e 100644 --- a/core/res/res/values-pt-rPT/donottranslate-cldr.xml +++ b/core/res/res/values-pt-rPT/donottranslate-cldr.xml @@ -95,7 +95,7 @@ <string name="hour_minute_ampm">%-l:%M %p</string> <string name="hour_minute_cap_ampm">%-l:%M %^p</string> <string name="twelve_hour_time_format">h:mm a</string> - <string name="twenty_four_hour_time_format">H'h'mm</string> + <string name="twenty_four_hour_time_format">H\'h\'mm</string> <string name="numeric_date">%d/%m/%Y</string> <string name="numeric_date_format">dd/MM/yyyy</string> <string name="numeric_date_template">"%s/%s/%s"</string> diff --git a/core/res/res/values-pt/donottranslate-cldr.xml b/core/res/res/values-pt/donottranslate-cldr.xml index 4729055..1111658 100644 --- a/core/res/res/values-pt/donottranslate-cldr.xml +++ b/core/res/res/values-pt/donottranslate-cldr.xml @@ -95,7 +95,7 @@ <string name="hour_minute_ampm">%-l:%M %p</string> <string name="hour_minute_cap_ampm">%-l:%M %^p</string> <string name="twelve_hour_time_format">h:mm a</string> - <string name="twenty_four_hour_time_format">H'h'mm</string> + <string name="twenty_four_hour_time_format">H\'h\'mm</string> <string name="numeric_date">%d/%m/%Y</string> <string name="numeric_date_format">dd/MM/yyyy</string> <string name="numeric_date_template">"%s/%s/%s"</string> diff --git a/core/res/res/values-vi-rVN/donottranslate-cldr.xml b/core/res/res/values-vi-rVN/donottranslate-cldr.xml index 72ff8b6..6f2d342 100644 --- a/core/res/res/values-vi-rVN/donottranslate-cldr.xml +++ b/core/res/res/values-vi-rVN/donottranslate-cldr.xml @@ -133,8 +133,8 @@ <string name="same_month_md1_time1_md2_time2">%3$s %2$s %5$s - %8$s %7$s %10$s</string> <string name="same_year_wday1_md1_time1_wday2_md2_time2">%1$s %3$s %2$s %5$s - %6$s %8$s %7$s %10$s</string> <string name="same_month_wday1_md1_time1_wday2_md2_time2">%1$s %3$s %2$s %5$s - %6$s %8$s %7$s %10$s</string> - <string name="same_year_mdy1_time1_mdy2_time2">Ngày %3$s tháng %2$s năm %4$s %5$s - 'Ngày %8$s tháng %7$s năm %9$s %10$s</string> - <string name="same_month_mdy1_time1_mdy2_time2">Ngày %3$s tháng %2$s năm %4$s %5$s - 'Ngày %8$s tháng %7$s năm %9$s %10$s</string> + <string name="same_year_mdy1_time1_mdy2_time2">Ngày %3$s tháng %2$s năm %4$s %5$s - \'Ngày %8$s tháng %7$s năm %9$s %10$s</string> + <string name="same_month_mdy1_time1_mdy2_time2">Ngày %3$s tháng %2$s năm %4$s %5$s - \'Ngày %8$s tháng %7$s năm %9$s %10$s</string> <string name="same_year_wday1_mdy1_time1_wday2_mdy2_time2">%1$s, %3$s %2$s %4$s %5$s - %6$s, %8$s %7$s %9$s %10$s</string> <string name="same_month_wday1_mdy1_time1_wday2_mdy2_time2">%1$s, %3$s %2$s %4$s %5$s - %6$s, %8$s %7$s %9$s %10$s</string> <string name="same_month_wday1_mdy1_wday2_mdy2">%1$s, %3$s %2$s %4$s - %6$s, %8$s %7$s %9$s</string> diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index b7de997..0fd6861 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -68,10 +68,8 @@ <color name="darker_gray">#aaa</color> <!-- For security permissions --> - <color name="perms_dangerous_grp_color">#ffd57e</color> - <color name="perms_dangerous_perm_color">#ddb66a</color> - <color name="perms_normal_grp_color">#eeeeee</color> - <color name="perms_normal_perm_color">#c0c0c0</color> + <color name="perms_dangerous_grp_color">#dd6826</color> + <color name="perms_dangerous_perm_color">#dd6826</color> <!-- For search-related UIs --> <color name="search_url_text_normal">#7fa87f</color> diff --git a/data/etc/platform.xml b/data/etc/platform.xml index a3579c7..20aa6e7 100644 --- a/data/etc/platform.xml +++ b/data/etc/platform.xml @@ -133,6 +133,7 @@ <assign-permission name="android.permission.READ_FRAME_BUFFER" uid="shell" /> <assign-permission name="android.permission.DEVICE_POWER" uid="shell" /> <assign-permission name="android.permission.INSTALL_LOCATION_PROVIDER" uid="shell" /> + <assign-permission name="android.permission.BACKUP" uid="shell" /> <assign-permission name="android.permission.MODIFY_AUDIO_SETTINGS" uid="media" /> <assign-permission name="android.permission.ACCESS_DRM" uid="media" /> @@ -147,5 +148,7 @@ file="/system/framework/android.test.runner.jar" /> <library name="com.android.im.plugin" file="/system/framework/com.android.im.plugin.jar"/> + <library name="javax.obex" + file="/system/framework/javax.obex.jar"/> </permissions> diff --git a/libs/audioflinger/Android.mk b/libs/audioflinger/Android.mk index ea7d6c2..bb224be 100644 --- a/libs/audioflinger/Android.mk +++ b/libs/audioflinger/Android.mk @@ -54,4 +54,10 @@ ifeq ($(BOARD_HAVE_BLUETOOTH),true) LOCAL_C_INCLUDES += $(call include-path-for, bluez) endif +ifeq ($(TARGET_SIMULATOR),true) + ifeq ($(HOST_OS),linux) + LOCAL_LDLIBS += -lrt -lpthread + endif +endif + include $(BUILD_SHARED_LIBRARY) diff --git a/libs/surfaceflinger/Android.mk b/libs/surfaceflinger/Android.mk index 93cb5ae..88e76dc 100644 --- a/libs/surfaceflinger/Android.mk +++ b/libs/surfaceflinger/Android.mk @@ -28,7 +28,7 @@ endif # need "-lrt" on Linux simulator to pick up clock_gettime ifeq ($(TARGET_SIMULATOR),true) ifeq ($(HOST_OS),linux) - LOCAL_LDLIBS += -lrt + LOCAL_LDLIBS += -lrt -lpthread endif endif diff --git a/location/java/android/location/Address.java b/location/java/android/location/Address.java index 3551363..ac275c6 100644 --- a/location/java/android/location/Address.java +++ b/location/java/android/location/Address.java @@ -41,7 +41,10 @@ public class Address implements Parcelable { private String mAdminArea; private String mSubAdminArea; private String mLocality; + private String mSubLocality; private String mThoroughfare; + private String mSubThoroughfare; + private String mPremises; private String mPostalCode; private String mCountryCode; private String mCountryName; @@ -175,6 +178,21 @@ public class Address implements Parcelable { } /** + * Returns the sub-locality of the address, or null if it is unknown. + * For example, this may correspond to the neighborhood of the locality. + */ + public String getSubLocality() { + return mSubLocality; + } + + /** + * Sets the sub-locality of the address to the given String, which may be null. + */ + public void setSubLocality(String sublocality) { + mSubLocality = sublocality; + } + + /** * Returns the thoroughfare name of the address, for example, "1600 Ampitheater Parkway", * which may be null */ @@ -190,6 +208,35 @@ public class Address implements Parcelable { } /** + * Returns the sub-thoroughfare name of the address, which may be null. + * This may correspond to the street number of the address. + */ + public String getSubThoroughfare() { + return mSubThoroughfare; + } + + /** + * Sets the sub-thoroughfare name of the address, which may be null. + */ + public void setSubThoroughfare(String subthoroughfare) { + this.mSubThoroughfare = subthoroughfare; + } + + /** + * Returns the premises of the address, or null if it is unknown. + */ + public String getPremises() { + return mPremises; + } + + /** + * Sets the premises of the address to the given String, which may be null. + */ + public void setPremises(String premises) { + mPremises = premises; + } + + /** * Returns the postal code of the address, for example "94110", * or null if it is unknown. */ diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk index 806ef52..ebbf13f 100644 --- a/media/libmedia/Android.mk +++ b/media/libmedia/Android.mk @@ -26,7 +26,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE:= libmedia ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) -LOCAL_LDLIBS += -ldl +LOCAL_LDLIBS += -ldl -lpthread endif ifneq ($(TARGET_SIMULATOR),true) diff --git a/obex/javax/obex/Authenticator.java b/obex/javax/obex/Authenticator.java index 7246e91..ec226fb 100644 --- a/obex/javax/obex/Authenticator.java +++ b/obex/javax/obex/Authenticator.java @@ -34,53 +34,50 @@ package javax.obex; /** * This interface provides a way to respond to authentication challenge and - * authentication response headers. When a client or server receives an + * authentication response headers. When a client or server receives an * authentication challenge or authentication response header, the * <code>onAuthenticationChallenge()</code> or - * <code>onAuthenticationResponse()</code> will be called, respectively, by - * the implementation. + * <code>onAuthenticationResponse()</code> will be called, respectively, by the + * implementation. * <P> * For more information on how the authentication procedure works in OBEX, - * please review the IrOBEX specification at - * <A HREF="http://www.irda.org">http://www.irda.org</A>. + * please review the IrOBEX specification at <A + * HREF="http://www.irda.org">http://www.irda.org</A>. * <P> * <STRONG>Authentication Challenges</STRONG> * <P> * When a client or server receives an authentication challenge header, the - * <code>onAuthenticationChallenge()</code> method will be invoked by the - * OBEX API implementation. The application will then return the user name - * (if needed) and password via a <code>PasswordAuthentication</code> object. - * The password in this object is not sent in the authentication response. - * Instead, the 16-byte challenge received in the authentication challenge is - * combined with the password returned from the - * <code>onAuthenticationChallenge()</code> method and passed through the MD5 - * hash algorithm. The resulting value is sent in the authentication response - * along with the user name if it was provided. + * <code>onAuthenticationChallenge()</code> method will be invoked by the OBEX + * API implementation. The application will then return the user name (if + * needed) and password via a <code>PasswordAuthentication</code> object. The + * password in this object is not sent in the authentication response. Instead, + * the 16-byte challenge received in the authentication challenge is combined + * with the password returned from the <code>onAuthenticationChallenge()</code> + * method and passed through the MD5 hash algorithm. The resulting value is sent + * in the authentication response along with the user name if it was provided. * <P> * <STRONG>Authentication Responses</STRONG> * <P> * When a client or server receives an authentication response header, the * <code>onAuthenticationResponse()</code> method is invoked by the API * implementation with the user name received in the authentication response - * header. (The user name will be <code>null</code> if no user name was - * provided in the authentication response header.) The application must - * determine the correct password. This value should be returned from the - * <code>onAuthenticationResponse()</code> method. If the authentication - * request should fail without the implementation checking the password, - * <code>null</code> should - * be returned by the application. (This is needed for reasons like not - * recognizing the user name, etc.) If the returned value is not - * <code>null</code>, the OBEX API implementation will combine the password + * header. (The user name will be <code>null</code> if no user name was provided + * in the authentication response header.) The application must determine the + * correct password. This value should be returned from the + * <code>onAuthenticationResponse()</code> method. If the authentication request + * should fail without the implementation checking the password, + * <code>null</code> should be returned by the application. (This is needed for + * reasons like not recognizing the user name, etc.) If the returned value is + * not <code>null</code>, the OBEX API implementation will combine the password * returned from the <code>onAuthenticationResponse()</code> method and * challenge sent via the authentication challenge, apply the MD5 hash * algorithm, and compare the result to the response hash received in the - * authentication response header. If the values are not equal, an - * <code>IOException</code> will be thrown if the client requested authentication. - * If the server requested authentication, the + * authentication response header. If the values are not equal, an + * <code>IOException</code> will be thrown if the client requested + * authentication. If the server requested authentication, the * <code>onAuthenticationFailure()</code> method will be called on the - * <code>ServerRequestHandler</code> that failed authentication. The - * connection is <B>not</B> closed if authentication failed. - * + * <code>ServerRequestHandler</code> that failed authentication. The connection + * is <B>not</B> closed if authentication failed. * @hide */ public interface Authenticator { @@ -90,35 +87,29 @@ public interface Authenticator { * header. It should respond to the challenge with a * <code>PasswordAuthentication</code> that contains the correct user name * and password for the challenge. - * - * @param description the description of which user name and password - * should be used; if no description is provided in the authentication - * challenge or the description is encoded in an encoding scheme that is - * not supported, an empty string will be provided - * + * @param description the description of which user name and password should + * be used; if no description is provided in the authentication + * challenge or the description is encoded in an encoding scheme that + * is not supported, an empty string will be provided * @param isUserIdRequired <code>true</code> if the user ID is required; - * <code>false</code> if the user ID is not required - * - * @param isFullAccess <code>true</code> if full access to the server - * will be granted; <code>false</code> if read only access will be - * granted - * - * @return a <code>PasswordAuthentication</code> object containing the - * user name and password used for authentication + * <code>false</code> if the user ID is not required + * @param isFullAccess <code>true</code> if full access to the server will + * be granted; <code>false</code> if read only access will be granted + * @return a <code>PasswordAuthentication</code> object containing the user + * name and password used for authentication */ PasswordAuthentication onAuthenticationChallenge(String description, boolean isUserIdRequired, boolean isFullAccess); /** * Called when a client or server receives an authentication response - * header. This method will provide the user name and expect the correct + * header. This method will provide the user name and expect the correct * password to be returned. - * - * @param userName the user name provided in the authentication response; - * may be <code>null</code> - * + * @param userName the user name provided in the authentication response; may + * be <code>null</code> * @return the correct password for the user name provided; if - * <code>null</code> is returned then the authentication request failed + * <code>null</code> is returned then the authentication request + * failed */ byte[] onAuthenticationResponse(byte[] userName); } diff --git a/obex/javax/obex/BaseStream.java b/obex/javax/obex/BaseStream.java index c32717f..022ad4f 100644 --- a/obex/javax/obex/BaseStream.java +++ b/obex/javax/obex/BaseStream.java @@ -37,46 +37,39 @@ import java.io.IOException; /** * This interface defines the methods needed by a parent that uses the * PrivateInputStream and PrivateOutputStream objects defined in this package. - * * @hide */ public interface BaseStream { /** * Verifies that this object is still open. - * * @throws IOException if the object is closed */ void ensureOpen() throws IOException; /** - * Verifies that additional information may be sent. In other words, the + * Verifies that additional information may be sent. In other words, the * operation is not done. - * * @throws IOException if the operation is completed */ void ensureNotDone() throws IOException; /** * Continues the operation since there is no data to read. - * - * @param sendEmpty <code>true</code> if the operation should send an - * empty packet or not send anything if there is no data to send - * @param inStream <code>true</code> if the stream is input stream or - * is output stream + * @param sendEmpty <code>true</code> if the operation should send an empty + * packet or not send anything if there is no data to send + * @param inStream <code>true</code> if the stream is input stream or is + * output stream * @return <code>true</code> if the operation was completed; - * <code>false</code> if no operation took place - * + * <code>false</code> if no operation took place * @throws IOException if an IO error occurs */ boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException; /** * Called when the output or input stream is closed. - * * @param inStream <code>true</code> if the input stream is closed; - * <code>false</code> if the output stream is closed - * + * <code>false</code> if the output stream is closed * @throws IOException if an IO error occurs */ void streamClosed(boolean inStream) throws IOException; diff --git a/obex/javax/obex/ClientOperation.java b/obex/javax/obex/ClientOperation.java index b3807af..65663b1 100644 --- a/obex/javax/obex/ClientOperation.java +++ b/obex/javax/obex/ClientOperation.java @@ -40,9 +40,8 @@ import java.io.DataOutputStream; import java.io.ByteArrayOutputStream; /** - * This class implements the <code>Operation</code> interface. It will read - * and write data via puts and gets. - * + * This class implements the <code>Operation</code> interface. It will read and + * write data via puts and gets. * @hide */ public final class ClientOperation implements Operation, BaseStream { @@ -73,15 +72,14 @@ public final class ClientOperation implements Operation, BaseStream { private boolean mEndOfBodySent; - /** + /** * Creates new OperationImpl to read and write data to a server * @param maxSize the maximum packet size * @param p the parent to this object * @param type <code>true</code> if this is a get request; - * <code>false</code. if this is a put request - * @param headers the headers to set in the initial request - * - * @throws IOExcpetion if the an IO error occured + * <code>false</code. if this is a put request + * @param header the header to set in the initial request + * @throws IOException if the an IO error occurred */ public ClientOperation(int maxSize, ClientSession p, HeaderSet header, boolean type) throws IOException { @@ -126,20 +124,14 @@ public final class ClientOperation implements Operation, BaseStream { } /** - * Sends an ABORT message to the server. By calling this method, the + * Sends an ABORT message to the server. By calling this method, the * corresponding input and output streams will be closed along with this * object. - * - * @throws IOException if the transaction has already ended or if an - * OBEX server called this method + * @throws IOException if the transaction has already ended or if an OBEX + * server called this method */ public synchronized void abort() throws IOException { ensureOpen(); - // need check again . - // if(isDone) { - // throw new IOException("Operation has already ended"); - // } - //no compatible with sun-ri if ((mOperationDone) && (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE)) { throw new IOException("Operation has already ended"); @@ -165,15 +157,14 @@ public final class ClientOperation implements Operation, BaseStream { } /** - * Retrieves the response code retrieved from the server. Response codes - * are defined in the <code>ResponseCodes</code> interface. - * + * Retrieves the response code retrieved from the server. Response codes are + * defined in the <code>ResponseCodes</code> interface. * @return the response code retrieved from the server - * * @throws IOException if an error occurred in the transport layer during - * the transaction; if this method is called on a <code>HeaderSet</code> - * object created by calling <code>createHeaderSet</code> in a - * <code>ClientSession</code> object + * the transaction; if this method is called on a + * <code>HeaderSet</code> object created by calling + * <code>createHeaderSet</code> in a <code>ClientSession</code> + * object */ public synchronized int getResponseCode() throws IOException { //avoid dup validateConnection @@ -187,7 +178,6 @@ public final class ClientOperation implements Operation, BaseStream { /** * This method will always return <code>null</code> - * * @return <code>null</code> */ public String getEncoding() { @@ -198,9 +188,8 @@ public final class ClientOperation implements Operation, BaseStream { * Returns the type of content that the resource connected to is providing. * E.g. if the connection is via HTTP, then the value of the content-type * header field is returned. - * * @return the content type of the resource that the URL references, or - * <code>null</code> if not known + * <code>null</code> if not known */ public String getType() { try { @@ -212,11 +201,10 @@ public final class ClientOperation implements Operation, BaseStream { /** * Returns the length of the content which is being provided. E.g. if the - * connection is via HTTP, then the value of the content-length header - * field is returned. - * + * connection is via HTTP, then the value of the content-length header field + * is returned. * @return the content length of the resource that this connection's URL - * references, or -1 if the content length is not known + * references, or -1 if the content length is not known */ public long getLength() { try { @@ -234,9 +222,7 @@ public final class ClientOperation implements Operation, BaseStream { /** * Open and return an input stream for a connection. - * * @return an input stream - * * @throws IOException if an I/O error occurs */ public InputStream openInputStream() throws IOException { @@ -259,11 +245,9 @@ public final class ClientOperation implements Operation, BaseStream { return mPrivateInput; } - /**8 + /** * Open and return a data input stream for a connection. - * * @return an input stream - * * @throws IOException if an I/O error occurs */ public DataInputStream openDataInputStream() throws IOException { @@ -272,9 +256,7 @@ public final class ClientOperation implements Operation, BaseStream { /** * Open and return an output stream for a connection. - * * @return an output stream - * * @throws IOException if an I/O error occurs */ public OutputStream openOutputStream() throws IOException { @@ -301,9 +283,7 @@ public final class ClientOperation implements Operation, BaseStream { /** * Open and return a data output stream for a connection. - * * @return an output stream - * * @throws IOException if an I/O error occurs */ public DataOutputStream openDataOutputStream() throws IOException { @@ -312,7 +292,6 @@ public final class ClientOperation implements Operation, BaseStream { /** * Closes the connection and ends the transaction - * * @throws IOException if the operation has already ended or is closed */ public void close() throws IOException { @@ -324,11 +303,9 @@ public final class ClientOperation implements Operation, BaseStream { /** * Returns the headers that have been received during the operation. - * Modifying the object returned has no effect on the headers that are - * sent or retrieved. - * + * Modifying the object returned has no effect on the headers that are sent + * or retrieved. * @return the headers received during this <code>Operation</code> - * * @throws IOException if this <code>Operation</code> has been closed */ public HeaderSet getReceivedHeader() throws IOException { @@ -340,15 +317,11 @@ public final class ClientOperation implements Operation, BaseStream { /** * Specifies the headers that should be sent in the next OBEX message that * is sent. - * * @param headers the headers to send in the next message - * - * @throws IOException if this <code>Operation</code> has been closed - * or the transaction has ended and no further messages will be exchanged - * + * @throws IOException if this <code>Operation</code> has been closed or the + * transaction has ended and no further messages will be exchanged * @throws IllegalArgumentException if <code>headers</code> was not created - * by a call to <code>ServerRequestHandler.createHeaderSet()</code> - * + * by a call to <code>ServerRequestHandler.createHeaderSet()</code> * @throws NullPointerException if <code>headers</code> is <code>null</code> */ public void sendHeaders(HeaderSet headers) throws IOException { @@ -370,62 +343,8 @@ public final class ClientOperation implements Operation, BaseStream { } /** - * Reads a response from the server. It will populate the appropriate body - * and headers. - * - * @return <code>true</code> if the transaction should end; - * <code>false</code> if the transaction should not end - * - * @throws IOException if an IO error occurred - */ - /* - private boolean readResponse() throws IOException { - mReplyHeader.responseCode = mInput.read(); - int packetLength = mInput.read(); - packetLength = (packetLength << 8) + mInput.read(); - - if (packetLength > ObexHelper.MAX_PACKET_SIZE_INT) { - if (mExceptionMessage != null) { - abort(); - } - throw new IOException("Received a packet that was too big"); - } - - if (packetLength > ObexHelper.BASE_PACKET_LENGTH) { - int dataLength = packetLength - ObexHelper.BASE_PACKET_LENGTH; - byte[] data = new byte[dataLength]; - int readLength = mInput.read(data); - if (readLength != dataLength) { - throw new IOException("Received a packet without data as decalred length"); - } - byte[] body = ObexHelper.updateHeaderSet(mReplyHeader, data); - - if (body != null) { - mPrivateInput.writeBytes(body, 1); - - /* - * Determine if a body (0x48) header or an end of body (0x49) - * was received. If we received an end of body and - * a response code of OBEX_HTTP_OK, then the operation should - * end. - * - if ((body[0] == 0x49) && (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_OK)) { - return false; - } - } - } - - if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) { - return true; - } else { - return false; - } - } - */ - /** - * Verifies that additional information may be sent. In other words, the + * Verifies that additional information may be sent. In other words, the * operation is not done. - * * @throws IOException if the operation is completed */ public void ensureNotDone() throws IOException { @@ -436,7 +355,6 @@ public final class ClientOperation implements Operation, BaseStream { /** * Verifies that the connection is open and no exceptions should be thrown. - * * @throws IOException if an exception needs to be thrown */ public void ensureOpen() throws IOException { @@ -452,7 +370,6 @@ public final class ClientOperation implements Operation, BaseStream { /** * Verifies that the connection is open and the proper data has been read. - * * @throws IOException if an IO error occurs */ private void validateConnection() throws IOException { @@ -466,15 +383,12 @@ public final class ClientOperation implements Operation, BaseStream { /** * Sends a request to the client of the specified type - * - * @param response the response code to send back to the client - * + * @param opCode the request code to send to the client * @return <code>true</code> if there is more data to send; - * <code>false</code> if there is no more data to send - * + * <code>false</code> if there is no more data to send * @throws IOException if an IO error occurs */ - private boolean sendRequest(int type) throws IOException { + private boolean sendRequest(int opCode) throws IOException { boolean returnValue = false; ByteArrayOutputStream out = new ByteArrayOutputStream(); int bodyLength = -1; @@ -519,7 +433,7 @@ public final class ClientOperation implements Operation, BaseStream { byte[] sendHeader = new byte[end - start]; System.arraycopy(headerArray, start, sendHeader, 0, sendHeader.length); - if (!mParent.sendRequest(type, sendHeader, mReplyHeader, mPrivateInput)) { + if (!mParent.sendRequest(opCode, sendHeader, mReplyHeader, mPrivateInput)) { return false; } @@ -559,7 +473,7 @@ public final class ClientOperation implements Operation, BaseStream { * (End of Body) otherwise, we need to send 0x48 (Body) */ if ((mPrivateOutput.isClosed()) && (!returnValue) && (!mEndOfBodySent) - && ((type & 0x80) != 0)) { + && ((opCode & 0x80) != 0)) { out.write(0x49); mEndOfBodySent = true; } else { @@ -577,7 +491,7 @@ public final class ClientOperation implements Operation, BaseStream { if (mPrivateOutputOpen && bodyLength <= 0 && !mEndOfBodySent) { // only 0x82 or 0x83 can send 0x49 - if ((type & 0x80) == 0) { + if ((opCode & 0x80) == 0) { out.write(0x48); } else { out.write(0x49); @@ -591,13 +505,13 @@ public final class ClientOperation implements Operation, BaseStream { } if (out.size() == 0) { - if (!mParent.sendRequest(type, null, mReplyHeader, mPrivateInput)) { + if (!mParent.sendRequest(opCode, null, mReplyHeader, mPrivateInput)) { return false; } return returnValue; } if ((out.size() > 0) - && (!mParent.sendRequest(type, out.toByteArray(), mReplyHeader, mPrivateInput))) { + && (!mParent.sendRequest(opCode, out.toByteArray(), mReplyHeader, mPrivateInput))) { return false; } @@ -610,10 +524,9 @@ public final class ClientOperation implements Operation, BaseStream { } /** - * This method starts the processing thread results. It will send the - * initial request. If the response takes more then one packet, a thread + * This method starts the processing thread results. It will send the + * initial request. If the response takes more then one packet, a thread * will be started to handle additional requests - * * @throws IOException if an IO error occurs */ private synchronized void startProcessing() throws IOException { @@ -659,11 +572,10 @@ public final class ClientOperation implements Operation, BaseStream { /** * Continues the operation since there is no data to read. - * - * @param sendEmpty <code>true</code> if the operation should send an - * empty packet or not send anything if there is no data to send - * @param inStream <code>true</code> if the stream is input stream or - * is output stream + * @param sendEmpty <code>true</code> if the operation should send an empty + * packet or not send anything if there is no data to send + * @param inStream <code>true</code> if the stream is input stream or is + * output stream * @throws IOException if an IO error occurs */ public synchronized boolean continueOperation(boolean sendEmpty, boolean inStream) @@ -717,10 +629,8 @@ public final class ClientOperation implements Operation, BaseStream { /** * Called when the output or input stream is closed. - * * @param inStream <code>true</code> if the input stream is closed; - * <code>false</code> if the output stream is closed - * + * <code>false</code> if the output stream is closed * @throws IOException if an IO error occurs */ public void streamClosed(boolean inStream) throws IOException { @@ -804,7 +714,6 @@ public final class ClientOperation implements Operation, BaseStream { if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) { mOperationDone = true; } - } } } diff --git a/obex/javax/obex/ClientSession.java b/obex/javax/obex/ClientSession.java index d554922..0935383 100644 --- a/obex/javax/obex/ClientSession.java +++ b/obex/javax/obex/ClientSession.java @@ -39,7 +39,6 @@ import java.io.OutputStream; /** * This class in an implementation of the OBEX ClientSession. - * * @hide */ public final class ClientSession extends ObexSession { @@ -163,7 +162,7 @@ public final class ClientSession extends ObexSession { } /** - * 0xCB Connection Id an identifier used for OBEX connection multiplexing + * 0xCB Connection Id an identifier used for OBEX connection multiplexing */ public void setConnectionID(long id) { if ((id < 0) || (id > 0xFFFFFFFFL)) { @@ -365,7 +364,6 @@ public final class ClientSession extends ObexSession { /** * Verifies that the connection is open. - * * @throws IOException if the connection is closed */ public synchronized void ensureOpen() throws IOException { @@ -375,9 +373,8 @@ public final class ClientSession extends ObexSession { } /** - * Set request inactive. - * Allows Put and get operation objects to tell this object when they are - * done. + * Set request inactive. Allows Put and get operation objects to tell this + * object when they are done. */ /*package*/synchronized void setRequestInactive() { mRequestActive = false; @@ -395,27 +392,17 @@ public final class ClientSession extends ObexSession { } /** - * Sends a standard request to the client. It will then wait for the reply - * and update the header set object provided. If any authentication - * headers (i.e. authentication challenge or authentication response) are - * received, they will be processed. - * + * Sends a standard request to the client. It will then wait for the reply + * and update the header set object provided. If any authentication headers + * (i.e. authentication challenge or authentication response) are received, + * they will be processed. * @param opCode the type of request to send to the client - * - * @param head the headers to send to the server - * - * @param challenge the nonce that was sent in the authentication - * challenge header located in <code>head</code>; <code>null</code> - * if no authentication header is included in <code>head</code> - * + * @param head the headers to send to the client * @param header the header object to update with the response - * - * @param input the input stream used by the Operation object; null if this - * is called on a CONNECT, SETPATH or DISCONNECT - * - * return <code>true</code> if the operation completed successfully; - * <code>false</code> if an authentication response failed to pass - * + * @param privateInput the input stream used by the Operation object; null + * if this is called on a CONNECT, SETPATH or DISCONNECT return + * <code>true</code> if the operation completed successfully; + * <code>false</code> if an authentication response failed to pass * @throws IOException if an IO error occurs */ public boolean sendRequest(int opCode, byte[] head, HeaderSet header, diff --git a/obex/javax/obex/HeaderSet.java b/obex/javax/obex/HeaderSet.java index f777da6..8b457f6 100644 --- a/obex/javax/obex/HeaderSet.java +++ b/obex/javax/obex/HeaderSet.java @@ -40,28 +40,27 @@ import java.util.Random; /** * This class implements the javax.obex.HeaderSet interface for OBEX over * RFCOMM. - * * @hide */ public final class HeaderSet { /** - * Represents the OBEX Count header. This allows the connection statement - * to tell the server how many objects it plans to send or retrieve. + * Represents the OBEX Count header. This allows the connection statement to + * tell the server how many objects it plans to send or retrieve. * <P> * The value of <code>COUNT</code> is 0xC0 (192). */ public static final int COUNT = 0xC0; /** - * Represents the OBEX Name header. This specifies the name of the object. + * Represents the OBEX Name header. This specifies the name of the object. * <P> * The value of <code>NAME</code> is 0x01 (1). */ public static final int NAME = 0x01; /** - * Represents the OBEX Type header. This allows a request to specify the + * Represents the OBEX Type header. This allows a request to specify the * type of the object (e.g. text, html, binary, etc.). * <P> * The value of <code>TYPE</code> is 0x42 (66). @@ -69,7 +68,7 @@ public final class HeaderSet { public static final int TYPE = 0x42; /** - * Represents the OBEX Length header. This is the length of the object in + * Represents the OBEX Length header. This is the length of the object in * bytes. * <P> * The value of <code>LENGTH</code> is 0xC3 (195). @@ -77,32 +76,32 @@ public final class HeaderSet { public static final int LENGTH = 0xC3; /** - * Represents the OBEX Time header using the ISO 8601 standards. This is - * the preferred time header. + * Represents the OBEX Time header using the ISO 8601 standards. This is the + * preferred time header. * <P> * The value of <code>TIME_ISO_8601</code> is 0x44 (68). */ public static final int TIME_ISO_8601 = 0x44; /** - * Represents the OBEX Time header using the 4 byte representation. This - * is only included for backwards compatibility. It represents the number - * of seconds since January 1, 1970. + * Represents the OBEX Time header using the 4 byte representation. This is + * only included for backwards compatibility. It represents the number of + * seconds since January 1, 1970. * <P> * The value of <code>TIME_4_BYTE</code> is 0xC4 (196). */ public static final int TIME_4_BYTE = 0xC4; /** - * Represents the OBEX Description header. This is a text description of - * the object. + * Represents the OBEX Description header. This is a text description of the + * object. * <P> * The value of <code>DESCRIPTION</code> is 0x05 (5). */ public static final int DESCRIPTION = 0x05; /** - * Represents the OBEX Target header. This is the name of the service an + * Represents the OBEX Target header. This is the name of the service an * operation is targeted to. * <P> * The value of <code>TARGET</code> is 0x46 (70). @@ -110,7 +109,7 @@ public final class HeaderSet { public static final int TARGET = 0x46; /** - * Represents the OBEX HTTP header. This allows an HTTP 1.X header to be + * Represents the OBEX HTTP header. This allows an HTTP 1.X header to be * included in a request or reply. * <P> * The value of <code>HTTP</code> is 0x47 (71). @@ -132,7 +131,7 @@ public final class HeaderSet { public static final int END_OF_BODY = 0x49; /** - * Represents the OBEX Who header. Identifies the OBEX application to + * Represents the OBEX Who header. Identifies the OBEX application to * determine if the two peers are talking to each other. * <P> * The value of <code>WHO</code> is 0x4A (74). @@ -149,7 +148,7 @@ public final class HeaderSet { public static final int CONNECTION_ID = 0xCB; /** - * Represents the OBEX Application Parameter header. This header specifies + * Represents the OBEX Application Parameter header. This header specifies * additional application request and response information. * <P> * The value of <code>APPLICATION_PARAMETER</code> is 0x4C (76). @@ -171,8 +170,8 @@ public final class HeaderSet { public static final int AUTH_RESPONSE = 0x4E; /** - * Represents the OBEX Object Class header. This header specifies the - * OBEX object class of the object. + * Represents the OBEX Object Class header. This header specifies the OBEX + * object class of the object. * <P> * The value of <code>OBJECT_CLASS</code> is 0x4F (79). */ @@ -200,12 +199,6 @@ public final class HeaderSet { private byte[] mAppParam; // byte sequence of the form tag length value - public byte[] mAuthChall; // The authentication challenge header - - public byte[] mAuthResp; // The authentication response header - - public byte[] mConnectionID; // THe connection ID - private byte[] mObjectClass; // byte sequence private String[] mUnicodeUserDefined; //null terminated unicode string @@ -216,15 +209,20 @@ public final class HeaderSet { private Long[] mIntegerUserDefined; // 4 byte unsigned integer - /*package*/int responseCode; + private final Random mRandom; - /*package*/byte[] nonce; + /*package*/ byte[] nonce; - private final Random mRandom; + public byte[] mAuthChall; // The authentication challenge header + + public byte[] mAuthResp; // The authentication response header + + public byte[] mConnectionID; // THe connection ID + + public int responseCode; /** * Creates new <code>HeaderSet</code> object. - * * @param size the max packet size for this connection */ public HeaderSet() { @@ -237,20 +235,17 @@ public final class HeaderSet { } /** - * Sets the value of the header identifier to the value provided. The type + * Sets the value of the header identifier to the value provided. The type * of object must correspond to the Java type defined in the description of - * this interface. If <code>null</code> is passed as the + * this interface. If <code>null</code> is passed as the * <code>headerValue</code> then the header will be removed from the set of * headers to include in the next request. - * * @param headerID the identifier to include in the message - * * @param headerValue the value of the header identifier - * - * @throws IllegalArgumentException if the header identifier provided is - * not one defined in this interface or a user-defined header; if the type of - * <code>headerValue</code> is not the correct Java type as defined in the - * description of this interface\ + * @throws IllegalArgumentException if the header identifier provided is not + * one defined in this interface or a user-defined header; if the + * type of <code>headerValue</code> is not the correct Java type as + * defined in the description of this interface\ */ public void setHeader(int headerID, Object headerValue) { long temp = -1; @@ -435,20 +430,16 @@ public final class HeaderSet { } /** - * Retrieves the value of the header identifier provided. The type of the + * Retrieves the value of the header identifier provided. The type of the * Object returned is defined in the description of this interface. - * * @param headerID the header identifier whose value is to be returned - * * @return the value of the header provided or <code>null</code> if the - * header identifier specified is not part of this <code>HeaderSet</code> - * object - * - * @throws IllegalArgumentException if the <code>headerID</code> is not - * one defined in this interface or any of the user-defined headers - * + * header identifier specified is not part of this + * <code>HeaderSet</code> object + * @throws IllegalArgumentException if the <code>headerID</code> is not one + * defined in this interface or any of the user-defined headers * @throws IOException if an error occurred in the transport layer during - * the operation or if the connection has been closed + * the operation or if the connection has been closed */ public Object getHeader(int headerID) throws IOException { @@ -500,17 +491,14 @@ public final class HeaderSet { /** * Retrieves the list of headers that may be retrieved via the - * <code>getHeader</code> method that will not return <code>null</code>. - * In other words, this method returns all the headers that are available - * in this object. - * + * <code>getHeader</code> method that will not return <code>null</code>. In + * other words, this method returns all the headers that are available in + * this object. * @see #getHeader - * * @return the array of headers that are set in this object or - * <code>null</code> if no headers are available - * + * <code>null</code> if no headers are available * @throws IOException if an error occurred in the transport layer during - * the operation or the connection has been closed + * the operation or the connection has been closed */ public int[] getHeaderList() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -594,51 +582,41 @@ public final class HeaderSet { } /** - * Sets the authentication challenge header. The <code>realm</code> will - * be encoded based upon the default encoding scheme used by the - * implementation to encode strings. Therefore, the encoding scheme used - * to encode the <code>realm</code> is application dependent. - * + * Sets the authentication challenge header. The <code>realm</code> will be + * encoded based upon the default encoding scheme used by the implementation + * to encode strings. Therefore, the encoding scheme used to encode the + * <code>realm</code> is application dependent. * @param realm a short description that describes what password to use; if - * <code>null</code> no realm will be sent in the authentication challenge - * header - * + * <code>null</code> no realm will be sent in the authentication + * challenge header * @param userID if <code>true</code>, a user ID is required in the reply; - * if <code>false</code>, no user ID is required - * + * if <code>false</code>, no user ID is required * @param access if <code>true</code> then full access will be granted if - * successful; if <code>false</code> then read-only access will be granted - * if successful + * successful; if <code>false</code> then read-only access will be + * granted if successful * @throws IOException */ public void createAuthenticationChallenge(String realm, boolean userID, boolean access) throws IOException { - try { - nonce = new byte[16]; - for (int i = 0; i < 16; i++) { - nonce[i] = (byte)mRandom.nextInt(); - } - - mAuthChall = ObexHelper.computeAuthenticationChallenge(nonce, realm, access, userID); - } catch (IOException e) { - throw e; + nonce = new byte[16]; + for (int i = 0; i < 16; i++) { + nonce[i] = (byte)mRandom.nextInt(); } + + mAuthChall = ObexHelper.computeAuthenticationChallenge(nonce, realm, access, userID); } /** - * Returns the response code received from the server. Response codes - * are defined in the <code>ResponseCodes</code> class. - * + * Returns the response code received from the server. Response codes are + * defined in the <code>ResponseCodes</code> class. * @see ResponseCodes - * * @return the response code retrieved from the server - * * @throws IOException if an error occurred in the transport layer during - * the transaction; if this method is called on a <code>HeaderSet</code> - * object created by calling <code>createHeaderSet()</code> in a - * <code>ClientSession</code> object; if this object was created by an OBEX - * server + * the transaction; if this method is called on a + * <code>HeaderSet</code> object created by calling + * <code>createHeaderSet()</code> in a <code>ClientSession</code> + * object; if this object was created by an OBEX server */ public int getResponseCode() throws IOException { if (responseCode == -1) { diff --git a/obex/javax/obex/ObexHelper.java b/obex/javax/obex/ObexHelper.java index 511b7c6..e6ade7b 100644 --- a/obex/javax/obex/ObexHelper.java +++ b/obex/javax/obex/ObexHelper.java @@ -43,16 +43,14 @@ import java.util.TimeZone; /** * This class defines a set of helper methods for the implementation of Obex. - * * @hide */ public final class ObexHelper { /** - * Defines the basic packet length used by OBEX. Every OBEX packet has the + * Defines the basic packet length used by OBEX. Every OBEX packet has the * same basic format:<BR> - * Byte 0: Request or Response Code - * Byte 1&2: Length of the packet. + * Byte 0: Request or Response Code Byte 1&2: Length of the packet. */ public static final int BASE_PACKET_LENGTH = 3; @@ -61,17 +59,14 @@ public final class ObexHelper { } /** - * The maximum packet size for OBEX packets that this client can handle. - * At present, this must be changed for each port. - * - * TODO: The max packet size should be the Max incoming MTU minus - * TODO: L2CAP package headers and RFCOMM package headers. - * - * TODO: Retrieve the max incoming MTU from - * TODO: LocalDevice.getProperty(). + * The maximum packet size for OBEX packets that this client can handle. At + * present, this must be changed for each port. TODO: The max packet size + * should be the Max incoming MTU minus TODO: L2CAP package headers and + * RFCOMM package headers. TODO: Retrieve the max incoming MTU from TODO: + * LocalDevice.getProperty(). */ - /** android note - * set as 0xFFFE to match remote MPS + /* + * android note set as 0xFFFE to match remote MPS */ public static final int MAX_PACKET_SIZE_INT = 0xFFFE; @@ -119,34 +114,46 @@ public final class ObexHelper { /** * Updates the HeaderSet with the headers received in the byte array - * provided. Invalid headers are ignored. + * provided. Invalid headers are ignored. * <P> - * The first two bits of an OBEX Header specifies the type of object that - * is being sent. The table below specifies the meaning of the high - * bits. + * The first two bits of an OBEX Header specifies the type of object that is + * being sent. The table below specifies the meaning of the high bits. * <TABLE> - * <TR><TH>Bits 8 and 7</TH><TH>Value</TH><TH>Description</TH></TR> - * <TR><TD>00</TD><TD>0x00</TD><TD>Null Terminated Unicode text, prefixed - * with 2 byte unsigned integer</TD></TR> - * <TR><TD>01</TD><TD>0x40</TD><TD>Byte Sequence, length prefixed with - * 2 byte unsigned integer</TD></TR> - * <TR><TD>10</TD><TD>0x80</TD><TD>1 byte quantity</TD></TR> - * <TR><TD>11</TD><TD>0xC0</TD><TD>4 byte quantity - transmitted in - * network byte order (high byte first</TD></TR> + * <TR> + * <TH>Bits 8 and 7</TH> + * <TH>Value</TH> + * <TH>Description</TH> + * </TR> + * <TR> + * <TD>00</TD> + * <TD>0x00</TD> + * <TD>Null Terminated Unicode text, prefixed with 2 byte unsigned integer</TD> + * </TR> + * <TR> + * <TD>01</TD> + * <TD>0x40</TD> + * <TD>Byte Sequence, length prefixed with 2 byte unsigned integer</TD> + * </TR> + * <TR> + * <TD>10</TD> + * <TD>0x80</TD> + * <TD>1 byte quantity</TD> + * </TR> + * <TR> + * <TD>11</TD> + * <TD>0xC0</TD> + * <TD>4 byte quantity - transmitted in network byte order (high byte first</TD> + * </TR> * </TABLE> * This method uses the information in this table to determine the type of - * Java object to create and passes that object with the full header - * to setHeader() to update the HeaderSet object. Invalid headers will - * cause an exception to be thrown. When it is thrown, it is ignored. - * + * Java object to create and passes that object with the full header to + * setHeader() to update the HeaderSet object. Invalid headers will cause an + * exception to be thrown. When it is thrown, it is ignored. * @param header the HeaderSet to update - * * @param headerArray the byte array containing headers - * * @return the result of the last start body or end body header provided; - * the first byte in the result will specify if a body or end of body is - * received - * + * the first byte in the result will specify if a body or end of + * body is received * @throws IOException if an invalid header was found */ public static byte[] updateHeaderSet(HeaderSet header, byte[] headerArray) throws IOException { @@ -316,18 +323,13 @@ public final class ObexHelper { /** * Creates the header part of OBEX packet based on the header provided. - * - * TODO: Could use getHeaderList() to get the array of headers to - * TODO: include and then use the high two bits to determine the - * TODO: the type of the object and construct the byte array from - * TODO: that. This will make the size smaller. - * + * TODO: Could use getHeaderList() to get the array of headers to include + * and then use the high two bits to determine the the type of the object + * and construct the byte array from that. This will make the size smaller. * @param head the header used to construct the byte array - * * @param nullOut <code>true</code> if the header should be set to - * <code>null</code> once it is added to the array or <code>false</code> - * if it should not be nulled out - * + * <code>null</code> once it is added to the array or + * <code>false</code> if it should not be nulled out * @return the header of an OBEX packet */ public static byte[] createHeader(HeaderSet head, boolean nullOut) { @@ -342,9 +344,6 @@ public final class ObexHelper { int length; HeaderSet headImpl = null; ByteArrayOutputStream out = new ByteArrayOutputStream(); - if (!(head instanceof HeaderSet)) { - throw new IllegalArgumentException("Header not created by createHeaderSet"); - } headImpl = head; try { @@ -675,18 +674,14 @@ public final class ObexHelper { } /** - * Determines where the maximum divide is between headers. This method is + * Determines where the maximum divide is between headers. This method is * used by put and get operations to separate headers to a size that meets * the max packet size allowed. - * * @param headerArray the headers to separate - * * @param start the starting index to search - * * @param maxSize the maximum size of a packet - * * @return the index of the end of the header block to send or -1 if the - * header could not be divided because the header is too large + * header could not be divided because the header is too large */ public static int findHeaderEnd(byte[] headerArray, int start, int maxSize) { @@ -757,9 +752,7 @@ public final class ObexHelper { /** * Converts the byte array to a long. - * * @param b the byte array to convert to a long - * * @return the byte array as a long */ public static long convertToLong(byte[] b) { @@ -781,10 +774,8 @@ public final class ObexHelper { } /** - * Converts the long to a 4 byte array. The long must be non negative. - * + * Converts the long to a 4 byte array. The long must be non negative. * @param l the long to convert - * * @return a byte array that is the same as the long */ public static byte[] convertToByteArray(long l) { @@ -799,11 +790,9 @@ public final class ObexHelper { } /** - * Converts the String to a UNICODE byte array. It will also add the ending + * Converts the String to a UNICODE byte array. It will also add the ending * null characters to the end of the string. - * * @param s the string to convert - * * @return the unicode byte array of the string */ public static byte[] convertToUnicodeByteArray(String s) { @@ -826,13 +815,10 @@ public final class ObexHelper { } /** - * Retrieves the value from the byte array for the tag value specified. The + * Retrieves the value from the byte array for the tag value specified. The * array should be of the form Tag - Length - Value triplet. - * * @param tag the tag to retrieve from the byte array - * * @param triplet the byte sequence containing the tag length value form - * * @return the value of the specified tag */ public static byte[] getTagValue(byte tag, byte[] triplet) { @@ -854,11 +840,8 @@ public final class ObexHelper { /** * Finds the index that starts the tag value pair in the byte array provide. - * * @param tag the tag to look for - * * @param value the byte array to search - * * @return the starting index of the tag or -1 if the tag could not be found */ public static int findTag(byte tag, byte[] value) { @@ -884,16 +867,12 @@ public final class ObexHelper { /** * Converts the byte array provided to a unicode string. - * * @param b the byte array to convert to a string - * * @param includesNull determine if the byte string provided contains the - * UNICODE null character at the end or not; if it does, it will be - * removed - * + * UNICODE null character at the end or not; if it does, it will be + * removed * @return a Unicode string - * - * @param IllegalArgumentException if the byte array has an odd length + * @throws IllegalArgumentException if the byte array has an odd length */ public static String convertToUnicode(byte[] b, boolean includesNull) { if (b == null) { @@ -926,9 +905,8 @@ public final class ObexHelper { } /** - * Compute the MD5 hash of the byte array provided. - * Does not accumulate input. - * + * Compute the MD5 hash of the byte array provided. Does not accumulate + * input. * @param in the byte array to hash * @return the MD5 hash of the byte array */ @@ -939,23 +917,16 @@ public final class ObexHelper { /** * Computes an authentication challenge header. - * - * - * @param nonce the challenge that will be provided to the peer; the - * challenge must be 16 bytes long - * + * @param nonce the challenge that will be provided to the peer; the + * challenge must be 16 bytes long * @param realm a short description that describes what password to use - * * @param access if <code>true</code> then full access will be granted if - * successful; if <code>false</code> then read only access will be granted - * if successful - * + * successful; if <code>false</code> then read only access will be + * granted if successful * @param userID if <code>true</code>, a user ID is required in the reply; - * if <code>false</code>, no user ID is required - * - * @throws IllegalArgumentException if the challenge is not 16 bytes - * long; if the realm can not be encoded in less then 255 bytes - * + * if <code>false</code>, no user ID is required + * @throws IllegalArgumentException if the challenge is not 16 bytes long; + * if the realm can not be encoded in less then 255 bytes * @throws IOException if the encoding scheme ISO 8859-1 is not supported */ public static byte[] computeAuthenticationChallenge(byte[] nonce, String realm, boolean access, diff --git a/obex/javax/obex/ObexSession.java b/obex/javax/obex/ObexSession.java index 97d65e0..a7daeb5 100644 --- a/obex/javax/obex/ObexSession.java +++ b/obex/javax/obex/ObexSession.java @@ -41,10 +41,8 @@ import java.io.IOException; * of the same connection, which is established by server's accepting of a * client issued "CONNECT". * <P> - * * This interface serves as the common super class for * <CODE>ClientSession</CODE> and <CODE>ServerSession</CODE>. - * * @hide */ public class ObexSession { @@ -56,10 +54,7 @@ public class ObexSession { /** * Called when the server received an authentication challenge header. This * will cause the authenticator to handle the authentication challenge. - * - * @param header - * the header with the authentication challenge - * + * @param header the header with the authentication challenge * @return <code>true</code> if the last request should be resent; * <code>false</code> if the last request should not be resent * @throws IOException @@ -188,10 +183,7 @@ public class ObexSession { /** * Called when the server received an authentication response header. This * will cause the authenticator to handle the authentication response. - * - * @param authResp - * the authentication response - * + * @param authResp the authentication response * @return <code>true</code> if the response passed; <code>false</code> if * the response failed */ diff --git a/obex/javax/obex/ObexTransport.java b/obex/javax/obex/ObexTransport.java index d0ba0c9..445e267 100644 --- a/obex/javax/obex/ObexTransport.java +++ b/obex/javax/obex/ObexTransport.java @@ -51,7 +51,6 @@ import java.io.OutputStream; * Different kind of medium may have different construction - for example, the * RFCOMM device file medium may be constructed from a file descriptor or simply * a string while the TCP medium usually from a socket. - * * @hide */ public interface ObexTransport { diff --git a/obex/javax/obex/Operation.java b/obex/javax/obex/Operation.java index f265f53..20653f2 100644 --- a/obex/javax/obex/Operation.java +++ b/obex/javax/obex/Operation.java @@ -40,44 +40,39 @@ import java.io.OutputStream; /** * The <code>Operation</code> interface provides ways to manipulate a single - * OBEX PUT or GET operation. The implementation of this interface sends - * OBEX packets as they are built. If during the operation the peer in the - * operation ends the operation, an <code>IOException</code> is thrown on - * the next read from the input stream, write to the output stream, or call to + * OBEX PUT or GET operation. The implementation of this interface sends OBEX + * packets as they are built. If during the operation the peer in the operation + * ends the operation, an <code>IOException</code> is thrown on the next read + * from the input stream, write to the output stream, or call to * <code>sendHeaders()</code>. * <P> - * <STRONG>Definition of methods inherited from <code>ContentConnection</code></STRONG> + * <STRONG>Definition of methods inherited from <code>ContentConnection</code> + * </STRONG> * <P> - * <code>getEncoding()</code> will always return <code>null</code>. - * <BR><code>getLength()</code> will return the length specified by the OBEX Length - * header or -1 if the OBEX Length header was not included. - * <BR><code>getType()</code> will return the value specified in the OBEX Type + * <code>getEncoding()</code> will always return <code>null</code>. <BR> + * <code>getLength()</code> will return the length specified by the OBEX Length + * header or -1 if the OBEX Length header was not included. <BR> + * <code>getType()</code> will return the value specified in the OBEX Type * header or <code>null</code> if the OBEX Type header was not included.<BR> * <P> * <STRONG>How Headers are Handled</STRONG> * <P> * As headers are received, they may be retrieved through the - * <code>getReceivedHeaders()</code> method. If new headers are set during the + * <code>getReceivedHeaders()</code> method. If new headers are set during the * operation, the new headers will be sent during the next packet exchange. * <P> * <STRONG>PUT example</STRONG> * <P> * <PRE> - * void putObjectViaOBEX(ClientSession conn, HeaderSet head, byte[] obj) - * throws IOException { - * + * void putObjectViaOBEX(ClientSession conn, HeaderSet head, byte[] obj) throws IOException { * // Include the length header * head.setHeader(head.LENGTH, new Long(obj.length)); - * * // Initiate the PUT request * Operation op = conn.put(head); - * * // Open the output stream to put the object to it * DataOutputStream out = op.openDataOutputStream(); - * * // Send the object to the server * out.write(obj); - * * // End the transaction * out.close(); * op.close(); @@ -88,64 +83,55 @@ import java.io.OutputStream; * <P> * <PRE> * byte[] getObjectViaOBEX(ClientSession conn, HeaderSet head) throws IOException { - * * // Send the initial GET request to the server * Operation op = conn.get(head); - * * // Retrieve the length of the object being sent back * int length = op.getLength(); - * - * // Create space for the object - * byte[] obj = new byte[length]; - * + * // Create space for the object + * byte[] obj = new byte[length]; * // Get the object from the input stream * DataInputStream in = trans.openDataInputStream(); * in.read(obj); - * * // End the transaction * in.close(); * op.close(); - * * return obj; * } * </PRE> - * <H3>Client PUT Operation Flow</H3> - * For PUT operations, a call to <code>close()</code> the <code>OutputStream</code> - * returned from <code>openOutputStream()</code> or <code>openDataOutputStream()</code> - * will signal that the request is done. (In OBEX terms, the End-Of-Body header should - * be sent and the final bit in the request will be set.) At this point, the - * reply from the server may begin to be processed. A call to + * + * <H3>Client PUT Operation Flow</H3> For PUT operations, a call to + * <code>close()</code> the <code>OutputStream</code> returned from + * <code>openOutputStream()</code> or <code>openDataOutputStream()</code> will + * signal that the request is done. (In OBEX terms, the End-Of-Body header + * should be sent and the final bit in the request will be set.) At this point, + * the reply from the server may begin to be processed. A call to * <code>getResponseCode()</code> will do an implicit close on the * <code>OutputStream</code> and therefore signal that the request is done. - * <H3>Client GET Operation Flow</H3> - * For GET operation, a call to <code>openInputStream()</code> or - * <code>openDataInputStream()</code> will signal that the request is done. (In OBEX - * terms, the final bit in the request will be set.) A call to - * <code>getResponseCode()</code> will cause an implicit close on the - * <code>InputStream</code>. No further data may be read at this point. - * + * <H3>Client GET Operation Flow</H3> For GET operation, a call to + * <code>openInputStream()</code> or <code>openDataInputStream()</code> will + * signal that the request is done. (In OBEX terms, the final bit in the request + * will be set.) A call to <code>getResponseCode()</code> will cause an implicit + * close on the <code>InputStream</code>. No further data may be read at this + * point. * @hide */ public interface Operation { /** - * Sends an ABORT message to the server. By calling this method, the + * Sends an ABORT message to the server. By calling this method, the * corresponding input and output streams will be closed along with this - * object. No headers are sent in the abort request. This will end the + * object. No headers are sent in the abort request. This will end the * operation since <code>close()</code> will be called by this method. - * - * @throws IOException if the transaction has already ended or if an - * OBEX server calls this method + * @throws IOException if the transaction has already ended or if an OBEX + * server calls this method */ void abort() throws IOException; /** * Returns the headers that have been received during the operation. - * Modifying the object returned has no effect on the headers that are - * sent or retrieved. - * + * Modifying the object returned has no effect on the headers that are sent + * or retrieved. * @return the headers received during this <code>Operation</code> - * * @throws IOException if this <code>Operation</code> has been closed */ HeaderSet getReceivedHeader() throws IOException; @@ -153,30 +139,23 @@ public interface Operation { /** * Specifies the headers that should be sent in the next OBEX message that * is sent. - * * @param headers the headers to send in the next message - * - * @throws IOException if this <code>Operation</code> has been closed - * or the transaction has ended and no further messages will be exchanged - * + * @throws IOException if this <code>Operation</code> has been closed or the + * transaction has ended and no further messages will be exchanged * @throws IllegalArgumentException if <code>headers</code> was not created - * by a call to <code>ServerRequestHandler.createHeaderSet()</code> or - * <code>ClientSession.createHeaderSet()</code> - * + * by a call to <code>ServerRequestHandler.createHeaderSet()</code> + * or <code>ClientSession.createHeaderSet()</code> * @throws NullPointerException if <code>headers</code> if <code>null</code> */ void sendHeaders(HeaderSet headers) throws IOException; /** - * Returns the response code received from the server. Response codes - * are defined in the <code>ResponseCodes</code> class. - * + * Returns the response code received from the server. Response codes are + * defined in the <code>ResponseCodes</code> class. * @see ResponseCodes - * * @return the response code retrieved from the server - * * @throws IOException if an error occurred in the transport layer during - * the transaction; if this object was created by an OBEX server + * the transaction; if this object was created by an OBEX server */ int getResponseCode() throws IOException; diff --git a/obex/javax/obex/PasswordAuthentication.java b/obex/javax/obex/PasswordAuthentication.java index e81a861..326b1ff 100644 --- a/obex/javax/obex/PasswordAuthentication.java +++ b/obex/javax/obex/PasswordAuthentication.java @@ -34,7 +34,6 @@ package javax.obex; /** * This class holds user name and password combinations. - * * @hide */ public final class PasswordAuthentication { @@ -44,15 +43,12 @@ public final class PasswordAuthentication { private final byte[] mPassword; /** - * Creates a new <code>PasswordAuthentication</code> with the user name - * and password provided. - * + * Creates a new <code>PasswordAuthentication</code> with the user name and + * password provided. * @param userName the user name to include; this may be <code>null</code> - * * @param password the password to include in the response - * * @throws NullPointerException if <code>password</code> is - * <code>null</code> + * <code>null</code> */ public PasswordAuthentication(final byte[] userName, final byte[] password) { if (userName != null) { @@ -65,9 +61,8 @@ public final class PasswordAuthentication { } /** - * Retrieves the user name that was specified in the constructor. - * The user name may be <code>null</code>. - * + * Retrieves the user name that was specified in the constructor. The user + * name may be <code>null</code>. * @return the user name */ public byte[] getUserName() { @@ -76,7 +71,6 @@ public final class PasswordAuthentication { /** * Retrieves the password. - * * @return the password */ public byte[] getPassword() { diff --git a/obex/javax/obex/PrivateInputStream.java b/obex/javax/obex/PrivateInputStream.java index 2dc02da..5daee72 100644 --- a/obex/javax/obex/PrivateInputStream.java +++ b/obex/javax/obex/PrivateInputStream.java @@ -38,7 +38,6 @@ import java.io.IOException; /** * This object provides an input stream to the Operation objects used in this * package. - * * @hide */ public final class PrivateInputStream extends InputStream { @@ -53,7 +52,6 @@ public final class PrivateInputStream extends InputStream { /** * Creates an input stream for the <code>Operation</code> to read from - * * @param p the connection this input stream is for */ public PrivateInputStream(BaseStream p) { @@ -68,10 +66,8 @@ public final class PrivateInputStream extends InputStream { * input stream without blocking by the next caller of a method for this * input stream. The next caller might be the same thread or or another * thread. - * * @return the number of bytes that can be read from this input stream - * without blocking - * + * without blocking * @throws IOException if an I/O error occurs */ @Override @@ -82,14 +78,12 @@ public final class PrivateInputStream extends InputStream { /** * Reads the next byte of data from the input stream. The value byte is - * returned as an int in the range 0 to 255. If no byte is available - * because the end of the stream has been reached, the value -1 is - * returned. This method blocks until input data is available, the end of - * the stream is detected, or an exception is thrown. - * - * @return the byte read from the input stream or -1 if it reaches the end - * of stream - * + * returned as an int in the range 0 to 255. If no byte is available because + * the end of the stream has been reached, the value -1 is returned. This + * method blocks until input data is available, the end of the stream is + * detected, or an exception is thrown. + * @return the byte read from the input stream or -1 if it reaches the end of + * stream * @throws IOException if an I/O error occurs */ @Override @@ -147,9 +141,7 @@ public final class PrivateInputStream extends InputStream { /** * Allows the <code>OperationImpl</code> thread to add body data to the * input stream. - * * @param body the data to add to the stream - * * @param start the start of the body to array to copy */ public synchronized void writeBytes(byte[] body, int start) { @@ -167,7 +159,6 @@ public final class PrivateInputStream extends InputStream { /** * Verifies that this stream is open - * * @throws IOException if the stream is not open */ private void ensureOpen() throws IOException { @@ -178,9 +169,8 @@ public final class PrivateInputStream extends InputStream { } /** - * Closes the input stream. If the input stream is already closed, do + * Closes the input stream. If the input stream is already closed, do * nothing. - * * @throws IOException this will never happen */ @Override diff --git a/obex/javax/obex/PrivateOutputStream.java b/obex/javax/obex/PrivateOutputStream.java index d972f78..ca420af 100644 --- a/obex/javax/obex/PrivateOutputStream.java +++ b/obex/javax/obex/PrivateOutputStream.java @@ -39,7 +39,6 @@ import java.io.ByteArrayOutputStream; /** * This object provides an output stream to the Operation objects used in this * package. - * * @hide */ public final class PrivateOutputStream extends OutputStream { @@ -54,18 +53,17 @@ public final class PrivateOutputStream extends OutputStream { /** * Creates an empty <code>PrivateOutputStream</code> to write to. - * * @param p the connection that this stream runs over */ public PrivateOutputStream(BaseStream p, int maxSize) { mParent = p; mArray = new ByteArrayOutputStream(); mMaxPacketSize = maxSize; + mOpen = true; } /** * Determines how many bytes have been written to the output stream. - * * @return the number of bytes written to the output stream */ public int size() { @@ -73,13 +71,11 @@ public final class PrivateOutputStream extends OutputStream { } /** - * Writes the specified byte to this output stream. The general contract - * for write is that one byte is written to the output stream. The byte to - * be written is the eight low-order bits of the argument b. The 24 - * high-order bits of b are ignored. - * + * Writes the specified byte to this output stream. The general contract for + * write is that one byte is written to the output stream. The byte to be + * written is the eight low-order bits of the argument b. The 24 high-order + * bits of b are ignored. * @param b the byte to write - * * @throws IOException if an I/O error occurs */ @Override @@ -128,9 +124,7 @@ public final class PrivateOutputStream extends OutputStream { /** * Reads the bytes that have been written to this stream. - * * @param size the size of the array to return - * * @return the byte array that is written */ public synchronized byte[] readBytes(int size) { @@ -150,7 +144,6 @@ public final class PrivateOutputStream extends OutputStream { /** * Verifies that this stream is open - * * @throws IOException if the stream is not open */ private void ensureOpen() throws IOException { @@ -161,9 +154,8 @@ public final class PrivateOutputStream extends OutputStream { } /** - * Closes the output stream. If the input stream is already closed, do + * Closes the output stream. If the input stream is already closed, do * nothing. - * * @throws IOException this will never happen */ @Override @@ -174,9 +166,8 @@ public final class PrivateOutputStream extends OutputStream { /** * Determines if the connection is closed - * - * @return <code>true</code> if the connection is closed; - * <code>false</code> if the connection is open + * @return <code>true</code> if the connection is closed; <code>false</code> + * if the connection is open */ public boolean isClosed() { return !mOpen; diff --git a/obex/javax/obex/ResponseCodes.java b/obex/javax/obex/ResponseCodes.java index f6cc9c1..a2b9a37 100644 --- a/obex/javax/obex/ResponseCodes.java +++ b/obex/javax/obex/ResponseCodes.java @@ -33,8 +33,8 @@ package javax.obex; /** - * The <code>ResponseCodes</code> class contains the list of valid - * response codes a server may send to a client. + * The <code>ResponseCodes</code> class contains the list of valid response + * codes a server may send to a client. * <P> * <STRONG>IMPORTANT NOTE</STRONG> * <P> @@ -42,13 +42,12 @@ package javax.obex; * specification, which is different with the HTTP specification. * <P> * <code>OBEX_DATABASE_FULL</code> and <code>OBEX_DATABASE_LOCKED</code> require - * further description since they are not defined in HTTP. The server will send + * further description since they are not defined in HTTP. The server will send * an <code>OBEX_DATABASE_FULL</code> message when the client requests that * something be placed into a database but the database is full (cannot take - * more data). <code>OBEX_DATABASE_LOCKED</code> will be returned when the + * more data). <code>OBEX_DATABASE_LOCKED</code> will be returned when the * client wishes to access a database, database table, or database record that * has been locked. - * * @hide */ public final class ResponseCodes { diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java index 6c3d9ba..8710c64 100644 --- a/obex/javax/obex/ServerOperation.java +++ b/obex/javax/obex/ServerOperation.java @@ -42,18 +42,14 @@ import java.io.ByteArrayOutputStream; /** * This class implements the Operation interface for server side connections. * <P> - * <STRONG>Request Codes</STRONG> - * There are four different request codes that are in this class. 0x02 is a - * PUT request that signals that the request is not complete and requires an - * additional OBEX packet. 0x82 is a PUT request that says that request is - * complete. In this case, the server can begin sending the response. The - * 0x03 is a GET request that signals that the request is not finished. When - * the server receives a 0x83, the client is signaling the server that it is - * done with its request. - * - * TODO: Extend the ClientOperation and reuse the methods defined - * TODO: in that class. - * + * <STRONG>Request Codes</STRONG> There are four different request codes that + * are in this class. 0x02 is a PUT request that signals that the request is not + * complete and requires an additional OBEX packet. 0x82 is a PUT request that + * says that request is complete. In this case, the server can begin sending the + * response. The 0x03 is a GET request that signals that the request is not + * finished. When the server receives a 0x83, the client is signaling the server + * that it is done with its request. TODO: Extend the ClientOperation and reuse + * the methods defined TODO: in that class. * @hide */ public final class ServerOperation implements Operation, BaseStream { @@ -94,19 +90,12 @@ public final class ServerOperation implements Operation, BaseStream { /** * Creates new ServerOperation - * * @param p the parent that created this object - * * @param in the input stream to read from - * * @param out the output stream to write to - * * @param request the initial request that was received from the client - * * @param maxSize the max packet size that the client will accept - * * @param listen the listener that is responding to the request - * * @throws IOException if an IO error occurs */ public ServerOperation(ServerSession p, InputStream in, int request, int maxSize, @@ -240,17 +229,16 @@ public final class ServerOperation implements Operation, BaseStream { } /** - * Determines if the operation should continue or should wait. If it - * should continue, this method will continue the operation. - * + * Determines if the operation should continue or should wait. If it should + * continue, this method will continue the operation. * @param sendEmpty if <code>true</code> then this will continue the - * operation even if no headers will be sent; if <code>false</code> then - * this method will only continue the operation if there are headers to - * send - * @param isStream if<code>true</code> the stream is input stream, otherwise - * output stream + * operation even if no headers will be sent; if <code>false</code> + * then this method will only continue the operation if there are + * headers to send + * @param inStream if<code>true</code> the stream is input stream, otherwise + * output stream * @return <code>true</code> if the operation was completed; - * <code>false</code> if no operation took place + * <code>false</code> if no operation took place */ public synchronized boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException { @@ -277,15 +265,13 @@ public final class ServerOperation implements Operation, BaseStream { } /** - * Sends a reply to the client. If the reply is a OBEX_HTTP_CONTINUE, it + * Sends a reply to the client. If the reply is a OBEX_HTTP_CONTINUE, it * will wait for a response from the client before ending. - * * @param type the response code to send back to the client - * * @return <code>true</code> if the final bit was not set on the reply; - * <code>false</code> if no reply was received because the operation ended, - * an abort was received, or the final bit was set in the reply - * + * <code>false</code> if no reply was received because the operation + * ended, an abort was received, or the final bit was set in the + * reply * @throws IOException if an IO error occurs */ public synchronized boolean sendReply(int type) throws IOException { @@ -492,12 +478,11 @@ public final class ServerOperation implements Operation, BaseStream { } /** - * Sends an ABORT message to the server. By calling this method, the + * Sends an ABORT message to the server. By calling this method, the * corresponding input and output streams will be closed along with this * object. - * - * @throws IOException if the transaction has already ended or if an - * OBEX server called this method + * @throws IOException if the transaction has already ended or if an OBEX + * server called this method */ public void abort() throws IOException { throw new IOException("Called from a server"); @@ -505,11 +490,9 @@ public final class ServerOperation implements Operation, BaseStream { /** * Returns the headers that have been received during the operation. - * Modifying the object returned has no effect on the headers that are - * sent or retrieved. - * + * Modifying the object returned has no effect on the headers that are sent + * or retrieved. * @return the headers received during this <code>Operation</code> - * * @throws IOException if this <code>Operation</code> has been closed */ public HeaderSet getReceivedHeader() throws IOException { @@ -520,14 +503,11 @@ public final class ServerOperation implements Operation, BaseStream { /** * Specifies the headers that should be sent in the next OBEX message that * is sent. - * * @param headers the headers to send in the next message - * - * @throws IOException if this <code>Operation</code> has been closed - * or the transaction has ended and no further messages will be exchanged - * + * @throws IOException if this <code>Operation</code> has been closed or the + * transaction has ended and no further messages will be exchanged * @throws IllegalArgumentException if <code>headers</code> was not created - * by a call to <code>ServerRequestHandler.createHeaderSet()</code> + * by a call to <code>ServerRequestHandler.createHeaderSet()</code> */ public void sendHeaders(HeaderSet headers) throws IOException { ensureOpen(); @@ -546,15 +526,14 @@ public final class ServerOperation implements Operation, BaseStream { } /** - * Retrieves the response code retrieved from the server. Response codes - * are defined in the <code>ResponseCodes</code> interface. - * + * Retrieves the response code retrieved from the server. Response codes are + * defined in the <code>ResponseCodes</code> interface. * @return the response code retrieved from the server - * * @throws IOException if an error occurred in the transport layer during - * the transaction; if this method is called on a <code>HeaderSet</code> - * object created by calling <code>createHeaderSet</code> in a - * <code>ClientSession</code> object; if this is called from a server + * the transaction; if this method is called on a + * <code>HeaderSet</code> object created by calling + * <code>createHeaderSet</code> in a <code>ClientSession</code> + * object; if this is called from a server */ public int getResponseCode() throws IOException { throw new IOException("Called from a server"); @@ -562,7 +541,6 @@ public final class ServerOperation implements Operation, BaseStream { /** * Always returns <code>null</code> - * * @return <code>null</code> */ public String getEncoding() { @@ -573,9 +551,8 @@ public final class ServerOperation implements Operation, BaseStream { * Returns the type of content that the resource connected to is providing. * E.g. if the connection is via HTTP, then the value of the content-type * header field is returned. - * * @return the content type of the resource that the URL references, or - * <code>null</code> if not known + * <code>null</code> if not known */ public String getType() { try { @@ -587,11 +564,10 @@ public final class ServerOperation implements Operation, BaseStream { /** * Returns the length of the content which is being provided. E.g. if the - * connection is via HTTP, then the value of the content-length header - * field is returned. - * + * connection is via HTTP, then the value of the content-length header field + * is returned. * @return the content length of the resource that this connection's URL - * references, or -1 if the content length is not known + * references, or -1 if the content length is not known */ public long getLength() { try { @@ -613,9 +589,7 @@ public final class ServerOperation implements Operation, BaseStream { /** * Open and return an input stream for a connection. - * * @return an input stream - * * @throws IOException if an I/O error occurs */ public InputStream openInputStream() throws IOException { @@ -625,9 +599,7 @@ public final class ServerOperation implements Operation, BaseStream { /** * Open and return a data input stream for a connection. - * * @return an input stream - * * @throws IOException if an I/O error occurs */ public DataInputStream openDataInputStream() throws IOException { @@ -636,9 +608,7 @@ public final class ServerOperation implements Operation, BaseStream { /** * Open and return an output stream for a connection. - * * @return an output stream - * * @throws IOException if an I/O error occurs */ public OutputStream openOutputStream() throws IOException { @@ -661,9 +631,7 @@ public final class ServerOperation implements Operation, BaseStream { /** * Open and return a data output stream for a connection. - * * @return an output stream - * * @throws IOException if an I/O error occurs */ public DataOutputStream openDataOutputStream() throws IOException { @@ -672,7 +640,6 @@ public final class ServerOperation implements Operation, BaseStream { /** * Closes the connection and ends the transaction - * * @throws IOException if the operation has already ended or is closed */ public void close() throws IOException { @@ -682,7 +649,6 @@ public final class ServerOperation implements Operation, BaseStream { /** * Verifies that the connection is open and no exceptions should be thrown. - * * @throws IOException if an exception needs to be thrown */ public void ensureOpen() throws IOException { @@ -695,26 +661,23 @@ public final class ServerOperation implements Operation, BaseStream { } /** - * Verifies that additional information may be sent. In other words, the + * Verifies that additional information may be sent. In other words, the * operation is not done. * <P> - * Included to implement the BaseStream interface only. It does not do + * Included to implement the BaseStream interface only. It does not do * anything on the server side since the operation of the Operation object * is not done until after the handler returns from its method. - * * @throws IOException if the operation is completed */ public void ensureNotDone() throws IOException { } /** - * Called when the output or input stream is closed. It does not do - * anything on the server side since the operation of the Operation object - * is not done until after the handler returns from its method. - * + * Called when the output or input stream is closed. It does not do anything + * on the server side since the operation of the Operation object is not + * done until after the handler returns from its method. * @param inStream <code>true</code> if the input stream is closed; - * <code>false</code> if the output stream is closed - * + * <code>false</code> if the output stream is closed * @throws IOException if an IO error occurs */ public void streamClosed(boolean inStream) throws IOException { diff --git a/obex/javax/obex/ServerRequestHandler.java b/obex/javax/obex/ServerRequestHandler.java index e468b83..d93e5b6 100644 --- a/obex/javax/obex/ServerRequestHandler.java +++ b/obex/javax/obex/ServerRequestHandler.java @@ -33,40 +33,38 @@ package javax.obex; /** - * The <code>ServerRequestHandler</code> class defines an event - * listener that will respond to OBEX requests made to the server. + * The <code>ServerRequestHandler</code> class defines an event listener that + * will respond to OBEX requests made to the server. * <P> - * The <code>onConnect()</code>, <code>onSetPath()</code>, <code>onDelete()</code>, - * <code>onGet()</code>, - * and <code>onPut()</code> methods may return any response code defined - * in the <code>ResponseCodes</code> class except for - * <code>OBEX_HTTP_CONTINUE</code>. If <code>OBEX_HTTP_CONTINUE</code> or - * a value not defined in the <code>ResponseCodes</code> class is returned, - * the server implementation will send an <code>OBEX_HTTP_INTERNAL_ERROR</code> - * response to the client. + * The <code>onConnect()</code>, <code>onSetPath()</code>, + * <code>onDelete()</code>, <code>onGet()</code>, and <code>onPut()</code> + * methods may return any response code defined in the + * <code>ResponseCodes</code> class except for <code>OBEX_HTTP_CONTINUE</code>. + * If <code>OBEX_HTTP_CONTINUE</code> or a value not defined in the + * <code>ResponseCodes</code> class is returned, the server implementation will + * send an <code>OBEX_HTTP_INTERNAL_ERROR</code> response to the client. * <P> * <STRONG>Connection ID and Target Headers</STRONG> * <P> * According to the IrOBEX specification, a packet may not contain a Connection - * ID and Target header. Since the Connection ID header is managed by the + * ID and Target header. Since the Connection ID header is managed by the * implementation, it will not send a Connection ID header, if a Connection ID - * was specified, in a packet that has a Target header. In other words, if an - * application adds a Target header to a <code>HeaderSet</code> object used - * in an OBEX operation and a Connection ID was specified, no Connection ID - * will be sent in the packet containing the Target header. + * was specified, in a packet that has a Target header. In other words, if an + * application adds a Target header to a <code>HeaderSet</code> object used in + * an OBEX operation and a Connection ID was specified, no Connection ID will be + * sent in the packet containing the Target header. * <P> * <STRONG>CREATE-EMPTY Requests</STRONG> * <P> * A CREATE-EMPTY request allows clients to create empty objects on the server. - * When a CREATE-EMPTY request is received, the <code>onPut()</code> method - * will be called by the implementation. To differentiate between a normal - * PUT request and a CREATE-EMPTY request, an application must open the - * <code>InputStream</code> from the <code>Operation</code> object passed - * to the <code>onPut()</code> method. For a PUT request, the application - * will be able to read Body data from this <code>InputStream</code>. For - * a CREATE-EMPTY request, there will be no Body data to read. Therefore, - * a call to <code>InputStream.read()</code> will return -1. - * + * When a CREATE-EMPTY request is received, the <code>onPut()</code> method will + * be called by the implementation. To differentiate between a normal PUT + * request and a CREATE-EMPTY request, an application must open the + * <code>InputStream</code> from the <code>Operation</code> object passed to the + * <code>onPut()</code> method. For a PUT request, the application will be able + * to read Body data from this <code>InputStream</code>. For a CREATE-EMPTY + * request, there will be no Body data to read. Therefore, a call to + * <code>InputStream.read()</code> will return -1. * @hide */ public class ServerRequestHandler { @@ -74,8 +72,8 @@ public class ServerRequestHandler { private long mConnectionId; /** - * Creates a <code>ServerRequestHandler</code>. - */ + * Creates a <code>ServerRequestHandler</code>. + */ protected ServerRequestHandler() { /* * A connection ID of -1 implies there is no conenction ID @@ -85,12 +83,10 @@ public class ServerRequestHandler { /** * Sets the connection ID header to include in the reply packets. - * - * @param connectionId the connection ID to use; -1 if no connection ID should be - * sent - * - * @throws IllegalArgumentException if <code>id</code> is not in the - * range -1 to 2<sup>32</sup>-1 + * @param connectionId the connection ID to use; -1 if no connection ID + * should be sent + * @throws IllegalArgumentException if <code>id</code> is not in the range + * -1 to 2<sup>32</sup>-1 */ public void setConnectionId(final long connectionId) { if ((connectionId < -1) || (connectionId > 0xFFFFFFFFL)) { @@ -102,9 +98,8 @@ public class ServerRequestHandler { /** * Retrieves the connection ID that is being used in the present connection. * This method will return -1 if no connection ID is being used. - * * @return the connection id being used or -1 if no connection ID is being - * used + * used */ public long getConnectionId() { return mConnectionId; @@ -113,23 +108,21 @@ public class ServerRequestHandler { /** * Called when a CONNECT request is received. * <P> - * If this method is not implemented by the class that extends this - * class, <code>onConnect()</code> will always return an - * <code>OBEX_HTTP_OK</code> response code. + * If this method is not implemented by the class that extends this class, + * <code>onConnect()</code> will always return an <code>OBEX_HTTP_OK</code> + * response code. * <P> * The headers received in the request can be retrieved from the - * <code>request</code> argument. The headers that should be sent - * in the reply must be specified in the <code>reply</code> argument. - * + * <code>request</code> argument. The headers that should be sent in the + * reply must be specified in the <code>reply</code> argument. * @param request contains the headers sent by the client; - * <code>request</code> will never be <code>null</code> - * + * <code>request</code> will never be <code>null</code> * @param reply the headers that should be sent in the reply; - * <code>reply</code> will never be <code>null</code> - * - * @return a response code defined in <code>ResponseCodes</code> that will be - * returned to the client; if an invalid response code is provided, the - * <code>OBEX_HTTP_INTERNAL_ERROR</code> response code will be used + * <code>reply</code> will never be <code>null</code> + * @return a response code defined in <code>ResponseCodes</code> that will + * be returned to the client; if an invalid response code is + * provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code + * will be used */ public int onConnect(HeaderSet request, HeaderSet reply) { return ResponseCodes.OBEX_HTTP_OK; @@ -139,14 +132,12 @@ public class ServerRequestHandler { * Called when a DISCONNECT request is received. * <P> * The headers received in the request can be retrieved from the - * <code>request</code> argument. The headers that should be sent - * in the reply must be specified in the <code>reply</code> argument. - * + * <code>request</code> argument. The headers that should be sent in the + * reply must be specified in the <code>reply</code> argument. * @param request contains the headers sent by the client; - * <code>request</code> will never be <code>null</code> - * + * <code>request</code> will never be <code>null</code> * @param reply the headers that should be sent in the reply; - * <code>reply</code> will never be <code>null</code> + * <code>reply</code> will never be <code>null</code> */ public void onDisconnect(HeaderSet request, HeaderSet reply) { } @@ -154,32 +145,28 @@ public class ServerRequestHandler { /** * Called when a SETPATH request is received. * <P> - * If this method is not implemented by the class that extends this - * class, <code>onSetPath()</code> will always return an + * If this method is not implemented by the class that extends this class, + * <code>onSetPath()</code> will always return an * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code. * <P> * The headers received in the request can be retrieved from the - * <code>request</code> argument. The headers that should be sent - * in the reply must be specified in the <code>reply</code> argument. - * + * <code>request</code> argument. The headers that should be sent in the + * reply must be specified in the <code>reply</code> argument. * @param request contains the headers sent by the client; - * <code>request</code> will never be <code>null</code> - * + * <code>request</code> will never be <code>null</code> * @param reply the headers that should be sent in the reply; - * <code>reply</code> will never be <code>null</code> - * + * <code>reply</code> will never be <code>null</code> * @param backup <code>true</code> if the client requests that the server - * back up one directory before changing to the path described by - * <code>name</code>; <code>false</code> to apply the request to the present - * path - * + * back up one directory before changing to the path described by + * <code>name</code>; <code>false</code> to apply the request to the + * present path * @param create <code>true</code> if the path should be created if it does - * not already exist; <code>false</code> if the path should not be created - * if it does not exist and an error code should be returned - * - * @return a response code defined in <code>ResponseCodes</code> that will be - * returned to the client; if an invalid response code is provided, the - * <code>OBEX_HTTP_INTERNAL_ERROR</code> response code will be used + * not already exist; <code>false</code> if the path should not be + * created if it does not exist and an error code should be returned + * @return a response code defined in <code>ResponseCodes</code> that will + * be returned to the client; if an invalid response code is + * provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code + * will be used */ public int onSetPath(HeaderSet request, HeaderSet reply, boolean backup, boolean create) { @@ -189,23 +176,21 @@ public class ServerRequestHandler { /** * Called when a DELETE request is received. * <P> - * If this method is not implemented by the class that extends this - * class, <code>onDelete()</code> will always return an + * If this method is not implemented by the class that extends this class, + * <code>onDelete()</code> will always return an * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code. * <P> * The headers received in the request can be retrieved from the - * <code>request</code> argument. The headers that should be sent - * in the reply must be specified in the <code>reply</code> argument. - * + * <code>request</code> argument. The headers that should be sent in the + * reply must be specified in the <code>reply</code> argument. * @param request contains the headers sent by the client; - * <code>request</code> will never be <code>null</code> - * + * <code>request</code> will never be <code>null</code> * @param reply the headers that should be sent in the reply; - * <code>reply</code> will never be <code>null</code> - * - * @return a response code defined in <code>ResponseCodes</code> that will be - * returned to the client; if an invalid response code is provided, the - * <code>OBEX_HTTP_INTERNAL_ERROR</code> response code will be used + * <code>reply</code> will never be <code>null</code> + * @return a response code defined in <code>ResponseCodes</code> that will + * be returned to the client; if an invalid response code is + * provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code + * will be used */ public int onDelete(HeaderSet request, HeaderSet reply) { return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED; @@ -214,20 +199,19 @@ public class ServerRequestHandler { /** * Called when a PUT request is received. * <P> - * If this method is not implemented by the class that extends this - * class, <code>onPut()</code> will always return an + * If this method is not implemented by the class that extends this class, + * <code>onPut()</code> will always return an * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code. * <P> * If an ABORT request is received during the processing of a PUT request, * <code>op</code> will be closed by the implementation. - * * @param operation contains the headers sent by the client and allows new - * headers to be sent in the reply; <code>op</code> will never be - * <code>null</code> - * - * @return a response code defined in <code>ResponseCodes</code> that will be - * returned to the client; if an invalid response code is provided, the - * <code>OBEX_HTTP_INTERNAL_ERROR</code> response code will be used + * headers to be sent in the reply; <code>op</code> will never be + * <code>null</code> + * @return a response code defined in <code>ResponseCodes</code> that will + * be returned to the client; if an invalid response code is + * provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code + * will be used */ public int onPut(Operation operation) { return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED; @@ -236,20 +220,19 @@ public class ServerRequestHandler { /** * Called when a GET request is received. * <P> - * If this method is not implemented by the class that extends this - * class, <code>onGet()</code> will always return an + * If this method is not implemented by the class that extends this class, + * <code>onGet()</code> will always return an * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code. * <P> * If an ABORT request is received during the processing of a GET request, * <code>op</code> will be closed by the implementation. - * * @param operation contains the headers sent by the client and allows new - * headers to be sent in the reply; <code>op</code> will never be - * <code>null</code> - * - * @return a response code defined in <code>ResponseCodes</code> that will be - * returned to the client; if an invalid response code is provided, the - * <code>OBEX_HTTP_INTERNAL_ERROR</code> response code will be used + * headers to be sent in the reply; <code>op</code> will never be + * <code>null</code> + * @return a response code defined in <code>ResponseCodes</code> that will + * be returned to the client; if an invalid response code is + * provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code + * will be used */ public int onGet(Operation operation) { return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED; @@ -262,9 +245,8 @@ public class ServerRequestHandler { * <P> * If this method is not implemented by the class that extends this class, * this method will do nothing. - * * @param userName the user name returned in the authentication response; - * <code>null</code> if no user name was provided in the response + * <code>null</code> if no user name was provided in the response */ public void onAuthenticationFailure(byte[] userName) { } @@ -274,7 +256,6 @@ public class ServerRequestHandler { * <P> * If this method is not implemented by the class that extends this class, * this method will do nothing. - * */ public void updateStatus(String message) { } @@ -284,7 +265,6 @@ public class ServerRequestHandler { * <P> * If this method is not implemented by the class that extends this class, * this method will do nothing. - * */ public void onClose() { } diff --git a/obex/javax/obex/ServerSession.java b/obex/javax/obex/ServerSession.java index 3a0e8150..423d5a7 100644 --- a/obex/javax/obex/ServerSession.java +++ b/obex/javax/obex/ServerSession.java @@ -40,7 +40,6 @@ import java.io.OutputStream; /** * This class in an implementation of the OBEX ServerSession. - * * @hide */ public final class ServerSession extends ObexSession implements Runnable { @@ -63,19 +62,11 @@ public final class ServerSession extends ObexSession implements Runnable { /** * Creates new ServerSession. - * - * @param trans - * the connection to the client - * - * @param handler - * the event listener that will process requests - * - * @param auth - * the authenticator to use with this connection - * - * @throws IOException - * if an error occurred while opening the input and output - * streams + * @param trans the connection to the client + * @param handler the event listener that will process requests + * @param auth the authenticator to use with this connection + * @throws IOException if an error occurred while opening the input and + * output streams */ public ServerSession(ObexTransport trans, ServerRequestHandler handler, Authenticator auth) throws IOException { @@ -163,12 +154,8 @@ public final class ServerSession extends ObexSession implements Runnable { * <code>ServerOperation</code> object will always reply with a * OBEX_HTTP_CONTINUE reply. It will only reply if further information is * needed. - * - * @param type - * the type of request received; either 0x02 or 0x82 - * - * @throws IOException - * if an error occurred at the transport layer + * @param type the type of request received; either 0x02 or 0x82 + * @throws IOException if an error occurred at the transport layer */ private void handlePutRequest(int type) throws IOException { ServerOperation op = new ServerOperation(this, mInput, type, mMaxPacketLength, mListener); @@ -191,7 +178,14 @@ public final class ServerSession extends ObexSession implements Runnable { op.sendReply(response); } } catch (Exception e) { - sendResponse(ResponseCodes.OBEX_HTTP_INTERNAL_ERROR, null); + /*To fix bugs in aborted cases, + *(client abort file transfer prior to the last packet which has the end of body header, + *internal error should not be sent because server has already replied with + *OK response in "sendReply") + */ + if (!op.isAborted) { + sendResponse(ResponseCodes.OBEX_HTTP_INTERNAL_ERROR, null); + } } } @@ -205,12 +199,8 @@ public final class ServerSession extends ObexSession implements Runnable { * <code>ServerOperation</code> object will always reply with a * OBEX_HTTP_CONTINUE reply. It will only reply if further information is * needed. - * - * @param type - * the type of request received; either 0x03 or 0x83 - * - * @throws IOException - * if an error occurred at the transport layer + * @param type the type of request received; either 0x03 or 0x83 + * @throws IOException if an error occurred at the transport layer */ private void handleGetRequest(int type) throws IOException { ServerOperation op = new ServerOperation(this, mInput, type, mMaxPacketLength, mListener); @@ -227,15 +217,9 @@ public final class ServerSession extends ObexSession implements Runnable { /** * Send standard response. - * - * @param code - * the response code to send - * - * @param header - * the headers to include in the response - * - * @throws IOException - * if an IO error occurs + * @param code the response code to send + * @param header the headers to include in the response + * @throws IOException if an IO error occurs */ public void sendResponse(int code, byte[] header) throws IOException { int totalLength = 3; @@ -265,9 +249,7 @@ public final class ServerSession extends ObexSession implements Runnable { * <code>ServerRequestHandler</code> object. After the handler processes the * request, this method will create a reply message to send to the server * with the response code provided. - * - * @throws IOException - * if an error occurred at the transport layer + * @throws IOException if an error occurred at the transport layer */ private void handleSetPathRequest() throws IOException { int length; @@ -393,9 +375,7 @@ public final class ServerSession extends ObexSession implements Runnable { * will create a <code>HeaderSet</code> object to pass to the * <code>ServerRequestHandler</code> object. After the handler processes the * request, this method will create a reply message to send to the server. - * - * @throws IOException - * if an error occurred at the transport layer + * @throws IOException if an error occurred at the transport layer */ private void handleDisconnectRequest() throws IOException { int length; @@ -500,9 +480,7 @@ public final class ServerSession extends ObexSession implements Runnable { * <code>ServerRequestHandler</code> object. After the handler processes the * request, this method will create a reply message to send to the server * with the response code provided. - * - * @throws IOException - * if an error occurred at the transport layer + * @throws IOException if an error occurred at the transport layer */ private void handleConnectRequest() throws IOException { int packetLength; @@ -660,10 +638,7 @@ public final class ServerSession extends ObexSession implements Runnable { /** * Verifies that the response code is valid. If it is not valid, it will * return the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code. - * - * @param code - * the response code to check - * + * @param code the response code to check * @return the valid response code or <code>OBEX_HTTP_INTERNAL_ERROR</code> * if <code>code</code> is not valid */ diff --git a/obex/javax/obex/SessionNotifier.java b/obex/javax/obex/SessionNotifier.java index 36e0ebf..9836dd6 100644 --- a/obex/javax/obex/SessionNotifier.java +++ b/obex/javax/obex/SessionNotifier.java @@ -36,73 +36,53 @@ import java.io.IOException; /** * The <code>SessionNotifier</code> interface defines a connection notifier for - * server-side OBEX connections. When a <code>SessionNotifier</code> is - * created and calls <code>acceptAndOpen()</code>, it will begin listening for - * clients to create a connection at the transport layer. When the transport - * layer connection is received, the <code>acceptAndOpen()</code> method will - * return a <code>javax.microedition.io.Connection</code> that is the - * connection to the client. The <code>acceptAndOpen()</code> method also takes a + * server-side OBEX connections. When a <code>SessionNotifier</code> is created + * and calls <code>acceptAndOpen()</code>, it will begin listening for clients + * to create a connection at the transport layer. When the transport layer + * connection is received, the <code>acceptAndOpen()</code> method will return a + * <code>javax.microedition.io.Connection</code> that is the connection to the + * client. The <code>acceptAndOpen()</code> method also takes a * <code>ServerRequestHandler</code> argument that will process the requests * from the client that connects to the server. - * * @hide */ public interface SessionNotifier { /** * Waits for a transport layer connection to be established and specifies - * the handler to handle the requests from the client. No authenticator - * is associated with this connection, therefore, it is implementation + * the handler to handle the requests from the client. No authenticator is + * associated with this connection, therefore, it is implementation * dependent as to how an authentication challenge and authentication * response header will be received and processed. * <P> - * <H4>Additional Note for OBEX over Bluetooth</H4> - * If this method is called on a <code>SessionNotifier</code> object that - * does not have a <code>ServiceRecord</code> in the SDDB, the - * <code>ServiceRecord</code> for this object will be added to the SDDB. - * This method requests the BCC to put the - * local device in connectible mode so that it will respond to + * <H4>Additional Note for OBEX over Bluetooth</H4> If this method is called + * on a <code>SessionNotifier</code> object that does not have a + * <code>ServiceRecord</code> in the SDDB, the <code>ServiceRecord</code> + * for this object will be added to the SDDB. This method requests the BCC + * to put the local device in connectable mode so that it will respond to * connection attempts by clients. * <P> - * The following checks are done to verify that the service record - * provided is valid. If any of these checks fail, then a + * The following checks are done to verify that the service record provided + * is valid. If any of these checks fail, then a * <code>ServiceRegistrationException</code> is thrown. * <UL> - * <LI>ServiceClassIDList and ProtocolDescriptorList, the mandatory - * service attributes for a <code>btgoep</code> service record, must be - * present in the <code>ServiceRecord</code> associated with this notifier. + * <LI>ServiceClassIDList and ProtocolDescriptorList, the mandatory service + * attributes for a <code>btgoep</code> service record, must be present in + * the <code>ServiceRecord</code> associated with this notifier. * <LI>L2CAP, RFCOMM and OBEX must all be in the ProtocolDescriptorList - * <LI>The <code>ServiceRecord</code> associated with this notifier must - * not have changed the RFCOMM server channel number + * <LI>The <code>ServiceRecord</code> associated with this notifier must not + * have changed the RFCOMM server channel number * </UL> * <P> * This method will not ensure that <code>ServiceRecord</code> associated - * with this notifier is a completely - * valid service record. It is the responsibility of the application to - * ensure that the service record follows all of the applicable - * syntactic and semantic rules for service record correctness. - * + * with this notifier is a completely valid service record. It is the + * responsibility of the application to ensure that the service record + * follows all of the applicable syntactic and semantic rules for service + * record correctness. * @param handler the request handler that will respond to OBEX requests - * * @return the connection to the client - * * @throws IOException if an error occurs in the transport layer - * - * @throws NullPointerException if <code>handler</code> is - * <code>null</code> - * - * @throws ServiceRegistrationException if the structure of the - * associated service record is invalid or if the service record - * could not be added successfully to the local SDDB. The - * structure of service record is invalid if the service - * record is missing any mandatory service attributes, or has - * changed any of the values described above which are fixed and - * cannot be changed. Failures to add the record to the SDDB could - * be due to insufficient disk space, database locks, etc. - * - * @throws BluetoothStateException if the server device could - * not be placed in connectible mode because the device user has - * configured the device to be non-connectible + * @throws NullPointerException if <code>handler</code> is <code>null</code> */ ObexSession acceptAndOpen(ServerRequestHandler handler) throws IOException; @@ -112,56 +92,37 @@ public interface SessionNotifier { * <code>Authenticator</code> to use to respond to authentication challenge * and authentication response headers. * <P> - * <H4>Additional Note for OBEX over Bluetooth</H4> - * If this method is called on a <code>SessionNotifier</code> object that - * does not have a <code>ServiceRecord</code> in the SDDB, the - * <code>ServiceRecord</code> for this object will be added to the SDDB. - * This method requests the BCC to put the - * local device in connectible mode so that it will respond to + * <H4>Additional Note for OBEX over Bluetooth</H4> If this method is called + * on a <code>SessionNotifier</code> object that does not have a + * <code>ServiceRecord</code> in the SDDB, the <code>ServiceRecord</code> + * for this object will be added to the SDDB. This method requests the BCC + * to put the local device in connectable mode so that it will respond to * connection attempts by clients. * <P> - * The following checks are done to verify that the service record - * provided is valid. If any of these checks fail, then a + * The following checks are done to verify that the service record provided + * is valid. If any of these checks fail, then a * <code>ServiceRegistrationException</code> is thrown. * <UL> - * <LI>ServiceClassIDList and ProtocolDescriptorList, the mandatory - * service attributes for a <code>btgoep</code> service record, must be - * present in the <code>ServiceRecord</code> associated with this notifier. + * <LI>ServiceClassIDList and ProtocolDescriptorList, the mandatory service + * attributes for a <code>btgoep</code> service record, must be present in + * the <code>ServiceRecord</code> associated with this notifier. * <LI>L2CAP, RFCOMM and OBEX must all be in the ProtocolDescriptorList - * <LI>The <code>ServiceRecord</code> associated with this notifier must - * not have changed the RFCOMM server channel number + * <LI>The <code>ServiceRecord</code> associated with this notifier must not + * have changed the RFCOMM server channel number * </UL> * <P> * This method will not ensure that <code>ServiceRecord</code> associated - * with this notifier is a completely - * valid service record. It is the responsibility of the application to - * ensure that the service record follows all of the applicable - * syntactic and semantic rules for service record correctness. - * + * with this notifier is a completely valid service record. It is the + * responsibility of the application to ensure that the service record + * follows all of the applicable syntactic and semantic rules for service + * record correctness. * @param handler the request handler that will respond to OBEX requests - * * @param auth the <code>Authenticator</code> to use with this connection; - * if <code>null</code> then no <code>Authenticator</code> will be used - * + * if <code>null</code> then no <code>Authenticator</code> will be + * used * @return the connection to the client - * * @throws IOException if an error occurs in the transport layer - * - * @throws NullPointerException if <code>handler</code> is - * <code>null</code> - * - * @throws ServiceRegistrationException if the structure of the - * associated service record is invalid or if the service record - * could not be added successfully to the local SDDB. The - * structure of service record is invalid if the service - * record is missing any mandatory service attributes, or has - * changed any of the values described above which are fixed and - * cannot be changed. Failures to add the record to the SDDB could - * be due to insufficient disk space, database locks, etc. - * - * @throws BluetoothStateException if the server device could - * not be placed in connectible mode because the device user has - * configured the device to be non-connectible + * @throws NullPointerException if <code>handler</code> is <code>null</code> */ ObexSession acceptAndOpen(ServerRequestHandler handler, Authenticator auth) throws IOException; } diff --git a/opengl/include/EGL/eglnatives.h b/opengl/include/EGL/eglnatives.h deleted file mode 100644 index 21622dc..0000000 --- a/opengl/include/EGL/eglnatives.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef ANDROID_EGLNATIVES_H -#define ANDROID_EGLNATIVES_H - -#include <sys/types.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -/* flags returned from swapBuffer */ -#define EGL_NATIVES_FLAG_SIZE_CHANGED 0x00000001 - -/* surface flags */ -#define EGL_NATIVES_FLAG_DESTROY_BACKBUFFER 0x00000001 - -enum native_pixel_format_t -{ - NATIVE_PIXEL_FORMAT_RGBA_8888 = 1, - NATIVE_PIXEL_FORMAT_RGB_565 = 4, - NATIVE_PIXEL_FORMAT_BGRA_8888 = 5, - NATIVE_PIXEL_FORMAT_RGBA_5551 = 6, - NATIVE_PIXEL_FORMAT_RGBA_4444 = 7, - NATIVE_PIXEL_FORMAT_YCbCr_422_SP= 0x10, - NATIVE_PIXEL_FORMAT_YCbCr_420_SP= 0x11, -}; - -enum native_memory_type_t -{ - NATIVE_MEMORY_TYPE_PMEM = 0, - NATIVE_MEMORY_TYPE_GPU = 1, - NATIVE_MEMORY_TYPE_FB = 2, - NATIVE_MEMORY_TYPE_HEAP = 128 -}; - - -struct egl_native_window_t -{ - /* - * magic must be set to 0x600913 - */ - uint32_t magic; - - /* - * must be sizeof(egl_native_window_t) - */ - uint32_t version; - - /* - * ident is reserved for the Android platform - */ - uint32_t ident; - - /* - * width, height and stride of the window in pixels - * Any of these value can be nul in which case GL commands are - * accepted and processed as usual, but not rendering occurs. - */ - int width; // w=h=0 is legal - int height; - int stride; - - /* - * format of the native window (see ui/PixelFormat.h) - */ - int format; - - /* - * Offset of the bits in the VRAM - */ - intptr_t offset; - - /* - * flags describing some attributes of this surface - * EGL_NATIVES_FLAG_DESTROY_BACKBUFFER: backbuffer not preserved after - * eglSwapBuffers - */ - uint32_t flags; - - /* - * horizontal and vertical resolution in DPI - */ - float xdpi; - float ydpi; - - /* - * refresh rate in frames per second (Hz) - */ - float fps; - - - /* - * Base memory virtual address of the surface in the CPU side - */ - intptr_t base; - - /* - * Heap the offset above is based from - */ - int fd; - - /* - * Memory type the surface resides into - */ - uint8_t memory_type; - - /* - * Reserved for future use. MUST BE ZERO. - */ - uint8_t reserved_pad[3]; - int reserved[8]; - - /* - * Vertical stride (only relevant with planar formats) - */ - - int vstride; - - /* - * Hook called by EGL to hold a reference on this structure - */ - void (*incRef)(struct egl_native_window_t* window); - - /* - * Hook called by EGL to release a reference on this structure - */ - void (*decRef)(struct egl_native_window_t* window); - - /* - * Hook called by EGL to perform a page flip. This function - * may update the size attributes above, in which case it returns - * the EGL_NATIVES_FLAG_SIZE_CHANGED bit set. - */ - uint32_t (*swapBuffers)(struct egl_native_window_t* window); - - /* - * Reserved for future use. MUST BE ZERO. - */ - void (*reserved_proc_0)(void); - - /* - * Reserved for future use. MUST BE ZERO. - */ - void (*reserved_proc_1)(void); - - /* - * Reserved for future use. MUST BE ZERO. - */ - void (*reserved_proc_2)(void); - - - /* - * Hook called by EGL when the native surface is associated to EGL - * (eglCreateWindowSurface). Can be NULL. - */ - void (*connect)(struct egl_native_window_t* window); - - /* - * Hook called by EGL when eglDestroySurface is called. Can be NULL. - */ - void (*disconnect)(struct egl_native_window_t* window); - - /* - * Reserved for future use. MUST BE ZERO. - */ - void (*reserved_proc[11])(void); - - /* - * Some storage reserved for the oem driver. - */ - intptr_t oem[4]; -}; - - -struct egl_native_pixmap_t -{ - int32_t version; /* must be 32 */ - int32_t width; - int32_t height; - int32_t stride; - uint8_t* data; - uint8_t format; - uint8_t rfu[3]; - union { - uint32_t compressedFormat; - int32_t vstride; - }; - int32_t reserved; -}; - -/*****************************************************************************/ - -/* - * This a convenience function to create a NativeWindowType surface - * that maps to the whole screen - * This function is actually implemented in libui.so - */ - -struct egl_native_window_t* android_createDisplaySurface(); - -/*****************************************************************************/ - - -/* - * OEM's egl's library (libhgl.so) must imlement these hooks to allocate - * the GPU memory they need - */ - - -typedef struct -{ - // for internal use - void* user; - // virtual address of this area - void* base; - // size of this area in bytes - size_t size; - // physical address of this area - void* phys; - // offset in this area available to the GPU - size_t offset; - // fd of this area - int fd; -} gpu_area_t; - -typedef struct -{ - // area where GPU registers are mapped - gpu_area_t regs; - // number of extra areas (currently limited to 2) - int32_t count; - // extra GPU areas (currently limited to 2) - gpu_area_t gpu[2]; -} request_gpu_t; - - -typedef request_gpu_t* (*OEM_EGL_acquire_gpu_t)(void* user); -typedef int (*OEM_EGL_release_gpu_t)(void* user, request_gpu_t* handle); -typedef void (*register_gpu_t) - (void* user, OEM_EGL_acquire_gpu_t, OEM_EGL_release_gpu_t); - -void oem_register_gpu( - void* user, - OEM_EGL_acquire_gpu_t acquire, - OEM_EGL_release_gpu_t release); - - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#endif /* ANDROID_EGLNATIVES_H */ diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java index 949dfae..4d25183 100755 --- a/packages/TtsService/src/android/tts/TtsService.java +++ b/packages/TtsService/src/android/tts/TtsService.java @@ -60,27 +60,29 @@ public class TtsService extends Service implements OnCompletionListener { public int mType = TEXT; public long mDuration = 0; public String mFilename = null; - public String callingApp = ""; + public String mCallingApp = ""; public SpeechItem(String source, String text, ArrayList<String> params, int itemType) { mText = text; mParams = params; mType = itemType; - callingApp = source; + mCallingApp = source; } - public SpeechItem(String source, long silenceTime) { + public SpeechItem(String source, long silenceTime, ArrayList<String> params) { mDuration = silenceTime; + mParams = params; mType = SILENCE; - callingApp = source; + mCallingApp = source; } - public SpeechItem(String source, 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; + mCallingApp = source; } } @@ -117,13 +119,17 @@ public class TtsService extends Service implements OnCompletionListener { private static final String CATEGORY = "android.intent.category.TTS"; private static final String PKGNAME = "android.tts"; - final RemoteCallbackList<android.speech.tts.ITtsCallback> mCallbacks = new RemoteCallbackList<ITtsCallback>(); + private final RemoteCallbackList<ITtsCallback> mCallbacks + = new RemoteCallbackList<ITtsCallback>(); + + private HashMap<String, ITtsCallback> mCallbacksMap; private Boolean mIsSpeaking; private ArrayList<SpeechItem> mSpeechQueue; private HashMap<String, SoundResource> mEarcons; private HashMap<String, SoundResource> mUtterances; private MediaPlayer mPlayer; + private SpeechItem mCurrentSpeechItem; private TtsService mSelf; private ContentResolver mResolver; @@ -147,9 +153,11 @@ public class TtsService extends Service implements OnCompletionListener { mEarcons = new HashMap<String, SoundResource>(); mUtterances = new HashMap<String, SoundResource>(); + mCallbacksMap = new HashMap<String, android.speech.tts.ITtsCallback>(); mSpeechQueue = new ArrayList<SpeechItem>(); mPlayer = null; + mCurrentSpeechItem = null; setDefaultSettings(); } @@ -377,7 +385,7 @@ public class TtsService extends Service implements OnCompletionListener { if (speechQueueAvailable) { Log.i("TTS", "Stopping"); for (int i = mSpeechQueue.size() - 1; i > -1; i--){ - if (mSpeechQueue.get(i).callingApp.equals(callingApp)){ + if (mSpeechQueue.get(i).mCallingApp.equals(callingApp)){ mSpeechQueue.remove(i); } } @@ -399,6 +407,7 @@ public class TtsService extends Service implements OnCompletionListener { } finally { // This check is needed because finally will always run; even if the // method returns somewhere in the try block. + mCurrentSpeechItem = null; if (speechQueueAvailable) { speechQueueLock.unlock(); } @@ -407,6 +416,21 @@ public class TtsService extends Service implements OnCompletionListener { } public void onCompletion(MediaPlayer arg0) { + String callingApp = mCurrentSpeechItem.mCallingApp; + ArrayList<String> params = mCurrentSpeechItem.mParams; + String utteranceId = ""; + if (params != null){ + for (int i = 0; i < params.size() - 1; i = i + 2){ + String param = params.get(i); + if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){ + utteranceId = params.get(i+1); + } + } + } + if (utteranceId.length() > 0){ + dispatchUtteranceCompletedCallback(utteranceId, callingApp); + } + mCurrentSpeechItem = null; processSpeechQueue(); } @@ -415,21 +439,34 @@ public class TtsService extends Service implements OnCompletionListener { if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { stop(callingApp); } - mSpeechQueue.add(new SpeechItem(callingApp, duration)); + mSpeechQueue.add(new SpeechItem(callingApp, duration, params)); if (!mIsSpeaking) { processSpeechQueue(); } return TextToSpeech.TTS_SUCCESS; } - private void silence(final long duration) { + private void silence(final SpeechItem speechItem) { class SilenceThread implements Runnable { public void run() { + String utteranceId = ""; + if (speechItem.mParams != null){ + for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){ + String param = speechItem.mParams.get(i); + if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){ + utteranceId = speechItem.mParams.get(i+1); + } + } + } try { - Thread.sleep(duration); + Thread.sleep(speechItem.mDuration); } catch (InterruptedException e) { e.printStackTrace(); } finally { + if (utteranceId.length() > 0){ + dispatchUtteranceCompletedCallback(utteranceId, speechItem.mCallingApp); + } + mCurrentSpeechItem = null; processSpeechQueue(); } } @@ -439,11 +476,11 @@ public class TtsService extends Service implements OnCompletionListener { slnc.start(); } - private void speakInternalOnly(final String text, - final ArrayList<String> params) { + private void speakInternalOnly(final SpeechItem speechItem) { class SynthThread implements Runnable { public void run() { boolean synthAvailable = false; + String utteranceId = ""; try { synthAvailable = synthesizerLock.tryLock(); if (!synthAvailable) { @@ -454,24 +491,28 @@ public class TtsService extends Service implements OnCompletionListener { return; } int streamType = DEFAULT_STREAM_TYPE; - if (params != null){ + if (speechItem.mParams != null){ String language = ""; String country = ""; String variant = ""; - for (int i = 0; i < params.size() - 1; i = i + 2){ - String param = params.get(i); + for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){ + String param = speechItem.mParams.get(i); if (param != null) { if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)) { - setSpeechRate("", Integer.parseInt(params.get(i+1))); + setSpeechRate("", + Integer.parseInt(speechItem.mParams.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ - language = params.get(i+1); + language = speechItem.mParams.get(i+1); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ - country = params.get(i+1); + country = speechItem.mParams.get(i+1); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){ - variant = params.get(i+1); + variant = speechItem.mParams.get(i+1); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){ + utteranceId = speechItem.mParams.get(i+1); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_STREAM)) { try { - streamType = Integer.parseInt(params.get(i + 1)); + streamType + = Integer.parseInt(speechItem.mParams.get(i + 1)); } catch (NumberFormatException e) { streamType = DEFAULT_STREAM_TYPE; } @@ -482,7 +523,7 @@ public class TtsService extends Service implements OnCompletionListener { setLanguage("", language, country, variant); } } - nativeSynth.speak(text, streamType); + nativeSynth.speak(speechItem.mText, streamType); } catch (InterruptedException e) { Log.e("TTS speakInternalOnly", "tryLock interrupted"); e.printStackTrace(); @@ -493,6 +534,10 @@ public class TtsService extends Service implements OnCompletionListener { if (synthAvailable) { synthesizerLock.unlock(); } + if (utteranceId.length() > 0){ + dispatchUtteranceCompletedCallback(utteranceId, speechItem.mCallingApp); + } + mCurrentSpeechItem = null; processSpeechQueue(); } } @@ -502,12 +547,12 @@ public class TtsService extends Service implements OnCompletionListener { synth.start(); } - private void synthToFileInternalOnly(final String text, - final ArrayList<String> params, final String filename) { + private void synthToFileInternalOnly(final SpeechItem speechItem) { class SynthThread implements Runnable { public void run() { - Log.i("TTS", "Synthesizing to " + filename); boolean synthAvailable = false; + String utteranceId = ""; + Log.i("TTS", "Synthesizing to " + speechItem.mFilename); try { synthAvailable = synthesizerLock.tryLock(); if (!synthAvailable) { @@ -517,21 +562,24 @@ public class TtsService extends Service implements OnCompletionListener { synth.start(); return; } - if (params != null){ + if (speechItem.mParams != null){ String language = ""; String country = ""; String variant = ""; - for (int i = 0; i < params.size() - 1; i = i + 2){ - String param = params.get(i); + for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){ + String param = speechItem.mParams.get(i); if (param != null){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ - setSpeechRate("", Integer.parseInt(params.get(i+1))); + setSpeechRate("", + Integer.parseInt(speechItem.mParams.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ - language = params.get(i+1); + language = speechItem.mParams.get(i+1); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){ - country = params.get(i+1); + country = speechItem.mParams.get(i+1); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){ - variant = params.get(i+1); + variant = speechItem.mParams.get(i+1); + } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){ + utteranceId = speechItem.mParams.get(i+1); } } } @@ -539,7 +587,7 @@ public class TtsService extends Service implements OnCompletionListener { setLanguage("", language, country, variant); } } - nativeSynth.synthesizeToFile(text, filename); + nativeSynth.synthesizeToFile(speechItem.mText, speechItem.mFilename); } catch (InterruptedException e) { Log.e("TTS synthToFileInternalOnly", "tryLock interrupted"); e.printStackTrace(); @@ -550,6 +598,10 @@ public class TtsService extends Service implements OnCompletionListener { if (synthAvailable) { synthesizerLock.unlock(); } + if (utteranceId.length() > 0){ + dispatchUtteranceCompletedCallback(utteranceId, speechItem.mCallingApp); + } + mCurrentSpeechItem = null; processSpeechQueue(); } } @@ -577,17 +629,20 @@ public class TtsService extends Service implements OnCompletionListener { sendBroadcast(i); } - private void dispatchSpeechCompletedCallbacks(String mark) { + + private void dispatchUtteranceCompletedCallback(String utteranceId, String packageName) { + ITtsCallback cb = mCallbacksMap.get(packageName); + if (cb == null){ + return; + } Log.i("TTS callback", "dispatch started"); // Broadcast to all clients the new value. final int N = mCallbacks.beginBroadcast(); - for (int i = 0; i < N; i++) { - try { - mCallbacks.getBroadcastItem(i).markReached(mark); - } catch (RemoteException e) { - // The RemoteCallbackList will take care of removing - // the dead object for us. - } + try { + cb.utteranceCompleted(utteranceId); + } catch (RemoteException e) { + // The RemoteCallbackList will take care of removing + // the dead object for us. } mCallbacks.finishBroadcast(); Log.i("TTS callback", "dispatch completed to " + N); @@ -597,7 +652,7 @@ public class TtsService extends Service implements OnCompletionListener { if (currentSpeechItem.mText.length() < MAX_SPEECH_ITEM_CHAR_LENGTH){ return currentSpeechItem; } else { - String callingApp = currentSpeechItem.callingApp; + String callingApp = currentSpeechItem.mCallingApp; ArrayList<SpeechItem> splitItems = new ArrayList<SpeechItem>(); int start = 0; int end = start + MAX_SPEECH_ITEM_CHAR_LENGTH - 1; @@ -634,23 +689,21 @@ public class TtsService extends Service implements OnCompletionListener { return; } - SpeechItem currentSpeechItem = mSpeechQueue.get(0); + mCurrentSpeechItem = mSpeechQueue.get(0); mIsSpeaking = true; - SoundResource sr = getSoundResource(currentSpeechItem); + SoundResource sr = getSoundResource(mCurrentSpeechItem); // Synth speech as needed - synthesizer should call // processSpeechQueue to continue running the queue - Log.i("TTS processing: ", currentSpeechItem.mText); + Log.i("TTS processing: ", mCurrentSpeechItem.mText); if (sr == null) { - if (currentSpeechItem.mType == SpeechItem.TEXT) { - currentSpeechItem = splitCurrentTextIfNeeded(currentSpeechItem); - speakInternalOnly(currentSpeechItem.mText, - currentSpeechItem.mParams); - } else if (currentSpeechItem.mType == SpeechItem.TEXT_TO_FILE) { - synthToFileInternalOnly(currentSpeechItem.mText, - currentSpeechItem.mParams, currentSpeechItem.mFilename); + if (mCurrentSpeechItem.mType == SpeechItem.TEXT) { + mCurrentSpeechItem = splitCurrentTextIfNeeded(mCurrentSpeechItem); + speakInternalOnly(mCurrentSpeechItem); + } else if (mCurrentSpeechItem.mType == SpeechItem.TEXT_TO_FILE) { + synthToFileInternalOnly(mCurrentSpeechItem); } else { // This is either silence or an earcon that was missing - silence(currentSpeechItem.mDuration); + silence(mCurrentSpeechItem); } } else { cleanUpPlayer(); @@ -684,7 +737,7 @@ public class TtsService extends Service implements OnCompletionListener { } mPlayer.setOnCompletionListener(this); try { - mPlayer.setAudioStreamType(getStreamTypeFromParams(currentSpeechItem.mParams)); + mPlayer.setAudioStreamType(getStreamTypeFromParams(mCurrentSpeechItem.mParams)); mPlayer.start(); } catch (IllegalStateException e) { mSpeechQueue.clear(); @@ -775,14 +828,22 @@ public class TtsService extends Service implements OnCompletionListener { private final android.speech.tts.ITts.Stub mBinder = new Stub() { - public void registerCallback(ITtsCallback cb) { - if (cb != null) + public int registerCallback(String packageName, ITtsCallback cb) { + if (cb != null) { mCallbacks.register(cb); + mCallbacksMap.put(packageName, cb); + return TextToSpeech.TTS_SUCCESS; + } + return TextToSpeech.TTS_ERROR; } - public void unregisterCallback(ITtsCallback cb) { - if (cb != null) + public int unregisterCallback(String packageName, ITtsCallback cb) { + if (cb != null) { + mCallbacksMap.remove(packageName); mCallbacks.unregister(cb); + return TextToSpeech.TTS_SUCCESS; + } + return TextToSpeech.TTS_ERROR; } /** diff --git a/packages/VpnServices/src/com/android/server/vpn/AndroidServiceProxy.java b/packages/VpnServices/src/com/android/server/vpn/AndroidServiceProxy.java index 7e8185e..c6c9452 100644 --- a/packages/VpnServices/src/com/android/server/vpn/AndroidServiceProxy.java +++ b/packages/VpnServices/src/com/android/server/vpn/AndroidServiceProxy.java @@ -84,6 +84,7 @@ public class AndroidServiceProxy extends ProcessProxy { throw new RuntimeException(e); } } + Log.d(mTag, "----- Stop: " + mServiceName); SystemProperties.set(SVC_STOP_CMD, mServiceName); } @@ -105,7 +106,7 @@ public class AndroidServiceProxy extends ProcessProxy { @Override protected void performTask() throws IOException { String svc = mServiceName; - Log.d(mTag, "+++++ Execute: " + svc); + Log.d(mTag, "+++++ Start: " + svc); SystemProperties.set(SVC_START_CMD, svc); boolean success = blockUntil(SVC_STATE_RUNNING, WAITING_TIME); diff --git a/packages/VpnServices/src/com/android/server/vpn/VpnService.java b/packages/VpnServices/src/com/android/server/vpn/VpnService.java index b2a9445..26322f4 100644 --- a/packages/VpnServices/src/com/android/server/vpn/VpnService.java +++ b/packages/VpnServices/src/com/android/server/vpn/VpnService.java @@ -299,12 +299,12 @@ abstract class VpnService<E extends VpnProfile> { private void saveVpnDnsProperties() { mOriginalDns1 = mOriginalDns2 = ""; - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 5; i++) { mVpnDns1 = SystemProperties.get(VPN_DNS1); mVpnDns2 = SystemProperties.get(VPN_DNS2); if (mOriginalDns1.equals(mVpnDns1)) { Log.d(TAG, "wait for vpn dns to settle in..." + i); - sleep(500); + sleep(200); } else { mOriginalDns1 = SystemProperties.get(DNS1); mOriginalDns2 = SystemProperties.get(DNS2); @@ -317,7 +317,9 @@ abstract class VpnService<E extends VpnProfile> { return; } } - Log.e(TAG, "saveVpnDnsProperties(): DNS not updated??"); + Log.d(TAG, "saveVpnDnsProperties(): DNS not updated??"); + mOriginalDns1 = mVpnDns1 = SystemProperties.get(DNS1); + mOriginalDns2 = mVpnDns2 = SystemProperties.get(DNS2); } private void saveAndSetDomainSuffices() { @@ -374,7 +376,7 @@ abstract class VpnService<E extends VpnProfile> { private void checkDnsProperties() { String dns1 = SystemProperties.get(DNS1); if (!mVpnDns1.equals(dns1)) { - Log.w(TAG, " @@ !!! dns being overridden"); + Log.w(TAG, " dns being overridden by: " + dns1); onError(); } } diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 69371b3..20f0750 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -1548,8 +1548,6 @@ class BackupManagerService extends IBackupManager.Stub { @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { synchronized (mQueueLock) { - long oldId = Binder.clearCallingIdentity(); - pw.println("Backup Manager is " + (mEnabled ? "enabled" : "disabled") + " / " + (!mProvisioned ? "not " : "") + "provisioned"); pw.println("Available transports:"); @@ -1572,8 +1570,6 @@ class BackupManagerService extends IBackupManager.Stub { for (BackupRequest req : mPendingBackups.values()) { pw.println(" " + req); } - - Binder.restoreCallingIdentity(oldId); } } } diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index a561d11..67e8cf3 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -171,6 +171,7 @@ public class WifiService extends IWifiManager.Stub { WifiService(Context context, WifiStateTracker tracker) { mContext = context; mWifiStateTracker = tracker; + mWifiStateTracker.enableRssiPolling(true); mBatteryStats = BatteryStatsService.getService(); mScanResultCache = new LinkedHashMap<String, ScanResult>( @@ -1367,9 +1368,11 @@ public class WifiService extends IWifiManager.Stub { mAlarmManager.cancel(mIdleIntent); mDeviceIdle = false; mScreenOff = false; + mWifiStateTracker.enableRssiPolling(true); } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { Log.d(TAG, "ACTION_SCREEN_OFF"); mScreenOff = true; + mWifiStateTracker.enableRssiPolling(false); /* * Set a timer to put Wi-Fi to sleep, but only if the screen is off * AND the "stay on while plugged in" setting doesn't match the diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 856ae42..25991f2 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -32,6 +32,7 @@ import android.app.ActivityThread; import android.app.AlertDialog; import android.app.ApplicationErrorReport; import android.app.Dialog; +import android.app.IActivityController; import android.app.IActivityWatcher; import android.app.IApplicationThread; import android.app.IInstrumentationWatcher; @@ -76,6 +77,7 @@ import android.os.Parcel; import android.os.ParcelFileDescriptor; import android.os.PowerManager; import android.os.Process; +import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; @@ -831,8 +833,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen String mOrigDebugApp = null; boolean mOrigWaitForDebugger = false; boolean mAlwaysFinishActivities = false; - IActivityWatcher mWatcher = null; + IActivityController mController = null; + final RemoteCallbackList<IActivityWatcher> mWatchers + = new RemoteCallbackList<IActivityWatcher>(); + /** * Callback of last caller to {@link #requestPss}. */ @@ -1629,7 +1634,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen /** * This is a simplified version of topRunningActivityLocked that provides a number of - * optional skip-over modes. It is intended for use with the ActivityWatcher hook only. + * optional skip-over modes. It is intended for use with the ActivityController hook only. * * @param token If non-null, any history records matching this token will be skipped. * @param taskId If non-zero, we'll attempt to skip over records with the same task ID. @@ -1734,10 +1739,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } ensurePackageDexOpt(r.intent.getComponent().getPackageName()); app.thread.scheduleLaunchActivity(new Intent(r.intent), r, + System.identityHashCode(r), r.info, r.icicle, results, newIntents, !andResume, isNextTransitionForward()); - // Update usage stats for launched activity - updateUsageStats(r, true); } catch (RemoteException e) { if (r.launchFailed) { // This is the second time we failed -- finish activity @@ -2190,6 +2194,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen mHandler.sendMessage(msg); } + reportResumedActivity(next); + next.thumbnail = null; setFocusedActivityLocked(next); next.resumeKeyDispatchingLocked(); @@ -2460,6 +2466,26 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } + private void reportResumedActivity(HistoryRecord r) { + //Log.i(TAG, "**** REPORT RESUME: " + r); + + final int identHash = System.identityHashCode(r); + updateUsageStats(r, true); + + int i = mWatchers.beginBroadcast(); + while (i > 0) { + i--; + IActivityWatcher w = mWatchers.getBroadcastItem(i); + if (w != null) { + try { + w.activityResuming(identHash); + } catch (RemoteException e) { + } + } + } + mWatchers.finishBroadcast(); + } + /** * Ensure that the top activity in the stack is resumed. * @@ -2648,10 +2674,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen EventLog.writeEvent(LOG_AM_RESUME_ACTIVITY, System.identityHashCode(next), next.task.taskId, next.shortComponentName); - updateUsageStats(next, true); next.app.thread.scheduleResumeActivity(next, isNextTransitionForward()); + pauseIfSleepingLocked(); } catch (Exception e) { @@ -3068,16 +3094,16 @@ public final class ActivityManagerService extends ActivityManagerNative implemen throw new SecurityException(msg); } - if (mWatcher != null) { + if (mController != null) { boolean abort = false; try { // The Intent we give to the watcher has the extra data // stripped off, since it can contain private information. Intent watchIntent = intent.cloneFilter(); - abort = !mWatcher.activityStarting(watchIntent, + abort = !mController.activityStarting(watchIntent, aInfo.applicationInfo.packageName); } catch (RemoteException e) { - mWatcher = null; + mController = null; } if (abort) { @@ -3974,16 +4000,16 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } synchronized(this) { - if (mWatcher != null) { + if (mController != null) { // Find the first activity that is not finishing. HistoryRecord next = topRunningActivityLocked(token, 0); if (next != null) { // ask watcher if this is allowed boolean resumeOK = true; try { - resumeOK = mWatcher.activityResuming(next.packageName); + resumeOK = mController.activityResuming(next.packageName); } catch (RemoteException e) { - mWatcher = null; + mController = null; } if (!resumeOK) { @@ -4475,9 +4501,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } - if (mWatcher != null) { + if (mController != null) { try { - int res = mWatcher.appNotResponding(app.processName, + int res = mController.appNotResponding(app.processName, app.pid, info.toString()); if (res != 0) { if (res < 0) { @@ -4493,7 +4519,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } } catch (RemoteException e) { - mWatcher = null; + mController = null; } } @@ -6618,7 +6644,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } /** - * TODO: Add mWatcher hook + * TODO: Add mController hook */ public void moveTaskToFront(int task) { enforceCallingPermission(android.Manifest.permission.REORDER_TASKS, @@ -6763,7 +6789,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // If we have a watcher, preflight the move before committing to it. First check // for *other* available tasks, but if none are available, then try again allowing the // current task to be selected. - if (mWatcher != null) { + if (mController != null) { HistoryRecord next = topRunningActivityLocked(null, task); if (next == null) { next = topRunningActivityLocked(null, 0); @@ -6772,9 +6798,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // ask watcher if this is allowed boolean moveOK = true; try { - moveOK = mWatcher.activityResuming(next.packageName); + moveOK = mController.activityResuming(next.packageName); } catch (RemoteException e) { - mWatcher = null; + mController = null; } if (!moveOK) { return false; @@ -7685,14 +7711,22 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } } - public void setActivityWatcher(IActivityWatcher watcher) { + public void setActivityController(IActivityController controller) { enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER, - "setActivityWatcher()"); + "setActivityController()"); synchronized (this) { - mWatcher = watcher; + mController = controller; } } + public void registerActivityWatcher(IActivityWatcher watcher) { + mWatchers.register(watcher); + } + + public void unregisterActivityWatcher(IActivityWatcher watcher) { + mWatchers.unregister(watcher); + } + public final void enterSafeMode() { synchronized(this) { // It only makes sense to do this before the system is ready @@ -8288,11 +8322,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen //Process.sendSignal(MY_PID, Process.SIGNAL_QUIT); } - if (mWatcher != null) { + if (mController != null) { try { String name = r != null ? r.processName : null; int pid = r != null ? r.pid : Binder.getCallingPid(); - if (!mWatcher.appCrashed(name, pid, + if (!mController.appCrashed(name, pid, shortMsg, longMsg, crashData)) { Log.w(TAG, "Force-killing crashed app " + name + " at watcher's request"); @@ -8300,7 +8334,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return 0; } } catch (RemoteException e) { - mWatcher = null; + mController = null; } } @@ -8727,7 +8761,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen + " mDebugTransient=" + mDebugTransient + " mOrigWaitForDebugger=" + mOrigWaitForDebugger); pw.println(" mAlwaysFinishActivities=" + mAlwaysFinishActivities - + " mWatcher=" + mWatcher); + + " mController=" + mController); } } diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java index 7f2b849..0bb2df1 100644 --- a/telephony/java/com/android/internal/telephony/Phone.java +++ b/telephony/java/com/android/internal/telephony/Phone.java @@ -22,6 +22,7 @@ import android.os.Handler; import android.os.Message; import android.preference.PreferenceManager; import android.telephony.CellLocation; +import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -260,8 +261,8 @@ public interface Phone { /** * Get current coarse-grained voice call state. - * Use {@link #registerForPhoneStateChanged(Handler, int, Object) - * registerForPhoneStateChanged()} for change notification. <p> + * Use {@link #registerForPreciseCallStateChanged(Handler, int, Object) + * registerForPreciseCallStateChanged()} for change notification. <p> * If the phone has an active call and call waiting occurs, * then the phone state is RINGING not OFFHOOK * <strong>Note:</strong> @@ -315,18 +316,21 @@ public interface Phone { void unregisterForUnknownConnection(Handler h); /** - * Notifies when any aspect of the voice call state changes. + * Register for getting notifications for change in the Call State {@link Call.State} + * This is called PreciseCallState because the call state is more precise than the + * {@link Phone.State} which can be obtained using the {@link PhoneStateListener} + * * Resulting events will have an AsyncResult in <code>Message.obj</code>. * AsyncResult.userData will be set to the obj argument here. * The <em>h</em> parameter is held only by a weak reference. */ - void registerForPhoneStateChanged(Handler h, int what, Object obj); + void registerForPreciseCallStateChanged(Handler h, int what, Object obj); /** * Unregisters for voice call state change notifications. * Extraneous calls are tolerated silently. */ - void unregisterForPhoneStateChanged(Handler h); + void unregisterForPreciseCallStateChanged(Handler h); /** @@ -556,8 +560,8 @@ public interface Phone { /** * Answers a ringing or waiting call. Active calls, if any, go on hold. * Answering occurs asynchronously, and final notification occurs via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. * * @exception CallStateException when no call is ringing or waiting */ @@ -567,8 +571,8 @@ public interface Phone { * Reject (ignore) a ringing call. In GSM, this means UDUB * (User Determined User Busy). Reject occurs asynchronously, * and final notification occurs via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. * * @exception CallStateException when no call is ringing or waiting */ @@ -578,8 +582,8 @@ public interface Phone { * Places any active calls on hold, and makes any held calls * active. Switch occurs asynchronously and may fail. * Final notification occurs via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. * * @exception CallStateException if a call is ringing, waiting, or * dialing/alerting. In these cases, this operation may not be performed. @@ -596,8 +600,8 @@ public interface Phone { /** * Conferences holding and active. Conference occurs asynchronously * and may fail. Final notification occurs via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. * * @exception CallStateException if canConference() would return false. * In these cases, this operation may not be performed. @@ -631,8 +635,8 @@ public interface Phone { * Connects the two calls and disconnects the subscriber from both calls * Explicit Call Transfer occurs asynchronously * and may fail. Final notification occurs via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. * * @exception CallStateException if canTransfer() would return false. * In these cases, this operation may not be performed. @@ -659,8 +663,8 @@ public interface Phone { * IDLE, ACTIVE, DIALING, ALERTING, or DISCONNECTED. * * State change notification is available via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. */ Call getForegroundCall(); @@ -676,8 +680,8 @@ public interface Phone { * IDLE, HOLDING or DISCONNECTED. * * State change notification is available via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. */ Call getBackgroundCall(); @@ -693,8 +697,8 @@ public interface Phone { * IDLE, INCOMING, WAITING or DISCONNECTED. * * State change notification is available via - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()}. + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()}. */ Call getRingingCall(); @@ -1067,8 +1071,8 @@ public interface Phone { /** * Gets current mute status. Use - * {@link #registerForPhoneStateChanged(android.os.Handler, int, - * java.lang.Object) registerForPhoneStateChanged()} + * {@link #registerForPreciseCallStateChanged(android.os.Handler, int, + * java.lang.Object) registerForPreciseCallStateChanged()} * as a change notifcation, although presently phone state changed is not * fired when setMute() is called. * diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java index 1509a6b..fbda221 100644 --- a/telephony/java/com/android/internal/telephony/PhoneBase.java +++ b/telephony/java/com/android/internal/telephony/PhoneBase.java @@ -119,7 +119,7 @@ public abstract class PhoneBase implements Phone { } - protected final RegistrantList mPhoneStateRegistrants + protected final RegistrantList mPreciseCallStateRegistrants = new RegistrantList(); protected final RegistrantList mNewRingingConnectionRegistrants @@ -221,25 +221,24 @@ public abstract class PhoneBase implements Phone { } // Inherited documentation suffices. - public void registerForPhoneStateChanged(Handler h, int what, Object obj) { + public void registerForPreciseCallStateChanged(Handler h, int what, Object obj) { checkCorrectThread(h); - mPhoneStateRegistrants.addUnique(h, what, obj); + mPreciseCallStateRegistrants.addUnique(h, what, obj); } // Inherited documentation suffices. - public void unregisterForPhoneStateChanged(Handler h) { - mPhoneStateRegistrants.remove(h); + public void unregisterForPreciseCallStateChanged(Handler h) { + mPreciseCallStateRegistrants.remove(h); } /** - * Notify registrants of a PhoneStateChanged. * Subclasses of Phone probably want to replace this with a * version scoped to their packages */ - protected void notifyCallStateChangedP() { + protected void notifyPreciseCallStateChangedP() { AsyncResult ar = new AsyncResult(null, this, null); - mPhoneStateRegistrants.notifyRegistrants(ar); + mPreciseCallStateRegistrants.notifyRegistrants(ar); } // Inherited documentation suffices. diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java index da00268..979f0cd 100644 --- a/telephony/java/com/android/internal/telephony/PhoneProxy.java +++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java @@ -25,6 +25,7 @@ import android.os.Handler; import android.os.Message; import android.preference.PreferenceManager; import android.telephony.CellLocation; +import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.util.Log; @@ -210,12 +211,12 @@ public class PhoneProxy extends Handler implements Phone { mActivePhone.unregisterForUnknownConnection(h); } - public void registerForPhoneStateChanged(Handler h, int what, Object obj) { - mActivePhone.registerForPhoneStateChanged(h, what, obj); + public void registerForPreciseCallStateChanged(Handler h, int what, Object obj) { + mActivePhone.registerForPreciseCallStateChanged(h, what, obj); } - public void unregisterForPhoneStateChanged(Handler h) { - mActivePhone.unregisterForPhoneStateChanged(h); + public void unregisterForPreciseCallStateChanged(Handler h) { + mActivePhone.unregisterForPreciseCallStateChanged(h); } public void registerForNewRingingConnection(Handler h, int what, Object obj) { diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java index 0918a8c..1cd6e58 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java +++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java @@ -36,6 +36,7 @@ import android.telephony.SignalStrength; import android.text.TextUtils; import android.util.Log; +import com.android.internal.telephony.Call; import com.android.internal.telephony.CallStateException; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.CommandsInterface; @@ -783,19 +784,19 @@ public class CDMAPhone extends PhoneBase { } /** - * Notify any interested party of a Phone state change. + * Notify any interested party of a Phone state change {@link Phone.State} */ /*package*/ void notifyPhoneStateChanged() { mNotifier.notifyPhoneState(this); } /** - * Notifies registrants (ie, activities in the Phone app) about - * changes to call state (including Phone and Connection changes). + * Notify registrants of a change in the call state. This notifies changes in {@link Call.State} + * Use this when changes in the precise call state are needed, else use notifyPhoneStateChanged. */ - /*package*/ void notifyCallStateChanged() { + /*package*/ void notifyPreciseCallStateChanged() { /* we'd love it if this was package-scoped*/ - super.notifyCallStateChangedP(); + super.notifyPreciseCallStateChangedP(); } void notifyServiceStateChanged(ServiceState ss) { diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java index ed2ea90..a5f9c11 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java @@ -222,7 +222,7 @@ public final class CdmaCallTracker extends CallTracker { } updatePhoneState(); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); return pendingMO; } @@ -305,7 +305,7 @@ public final class CdmaCallTracker extends CallTracker { internalClearDisconnected(); updatePhoneState(); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); } boolean @@ -644,7 +644,7 @@ public final class CdmaCallTracker extends CallTracker { } if (hasNonHangupStateChanged || newRinging != null) { - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); } //dumpState(); @@ -678,7 +678,7 @@ public final class CdmaCallTracker extends CallTracker { // the hangup reason is user ignoring or timing out. So conn.onDisconnect() // is not called here. Instead, conn.onLocalDisconnect() is called. conn.onLocalDisconnect(); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); return; } else { try { @@ -821,7 +821,7 @@ public final class CdmaCallTracker extends CallTracker { // the status of the call is after a call waiting is answered, // 3 way call merged or a switch between calls. foregroundCall.setGeneric(true); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); } private Phone.SuppService getFailedService(int what) { @@ -926,7 +926,7 @@ public final class CdmaCallTracker extends CallTracker { updatePhoneState(); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); droppedDuringPoll.clear(); break; diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java index d1e4b4f..ebbf096 100755 --- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java +++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java @@ -51,6 +51,7 @@ import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDI import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOICE; import static com.android.internal.telephony.TelephonyProperties.PROPERTY_BASEBAND_VERSION; +import com.android.internal.telephony.Call; import com.android.internal.telephony.CallForwardInfo; import com.android.internal.telephony.CallStateException; import com.android.internal.telephony.CommandsInterface; @@ -378,20 +379,19 @@ public class GSMPhone extends PhoneBase { } /** - * Notify any interested party of a Phone state change. + * Notify any interested party of a Phone state change {@link Phone.State} */ /*package*/ void notifyPhoneStateChanged() { mNotifier.notifyPhoneState(this); } /** - * Notifies registrants (ie, activities in the Phone app) about - * changes to call state (including Phone and Connection changes). + * Notify registrants of a change in the call state. This notifies changes in {@link Call.State} + * Use this when changes in the precise call state are needed, else use notifyPhoneStateChanged. */ - /*package*/ void - notifyCallStateChanged() { + /*package*/ void notifyPreciseCallStateChanged() { /* we'd love it if this was package-scoped*/ - super.notifyCallStateChangedP(); + super.notifyPreciseCallStateChangedP(); } /*package*/ void diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java index 5c5090f..f3b7596 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmCallTracker.java @@ -212,7 +212,7 @@ public final class GsmCallTracker extends CallTracker { } updatePhoneState(); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); return pendingMO; } @@ -279,7 +279,7 @@ public final class GsmCallTracker extends CallTracker { internalClearDisconnected(); updatePhoneState(); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); } boolean @@ -600,7 +600,7 @@ public final class GsmCallTracker extends CallTracker { } if (hasNonHangupStateChanged || newRinging != null) { - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); } //dumpState(); @@ -883,7 +883,7 @@ public final class GsmCallTracker extends CallTracker { updatePhoneState(); - phone.notifyCallStateChanged(); + phone.notifyPreciseCallStateChanged(); droppedDuringPoll.clear(); break; diff --git a/tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java b/tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java index 7107412..b96743a 100644 --- a/tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java +++ b/tests/CoreTests/com/android/internal/telephony/gsm/GSMPhoneTest.java @@ -81,7 +81,7 @@ public class GSMPhoneTest extends AndroidTestCase implements PerformanceTestCase mRadioControl = mGSMTestHandler.getSimulatedCommands(); mHandler = mGSMTestHandler.getHandler(); - mGSMPhone.registerForPhoneStateChanged(mHandler, EVENT_PHONE_STATE_CHANGED, null); + mGSMPhone.registerForPreciseCallStateChanged(mHandler, EVENT_PHONE_STATE_CHANGED, null); mGSMPhone.registerForNewRingingConnection(mHandler, EVENT_RINGING, null); mGSMPhone.registerForDisconnect(mHandler, EVENT_DISCONNECT, null); @@ -109,7 +109,7 @@ public class GSMPhoneTest extends AndroidTestCase implements PerformanceTestCase protected void tearDown() throws Exception { mRadioControl.shutdown(); - mGSMPhone.unregisterForPhoneStateChanged(mHandler); + mGSMPhone.unregisterForPreciseCallStateChanged(mHandler); mGSMPhone.unregisterForNewRingingConnection(mHandler); mGSMPhone.unregisterForDisconnect(mHandler); mGSMPhone.setOnPostDialCharacter(mHandler, 0, null); diff --git a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java index 14d3d73..c782045 100644 --- a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java +++ b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java @@ -134,8 +134,8 @@ public class ActivityManagerPermissionTests extends TestCase { @SmallTest public void testSET_ACTIVITY_WATCHER() { try { - mAm.setActivityWatcher(null); - fail("IActivityManager.setActivityWatcher did not throw SecurityException as" + mAm.setActivityController(null); + fail("IActivityManager.setActivityController did not throw SecurityException as" + " expected"); } catch (SecurityException e) { // expected diff --git a/vpn/java/android/net/vpn/VpnState.java b/vpn/java/android/net/vpn/VpnState.java index ebd9364..6e61f9c 100644 --- a/vpn/java/android/net/vpn/VpnState.java +++ b/vpn/java/android/net/vpn/VpnState.java @@ -26,8 +26,13 @@ package android.net.vpn; * {@link DISCONNECTING} and then {@link IDLE}. * {@link CANCELLED} is a state when a VPN connection attempt is aborted, and * is in transition to {@link IDLE}. + * The {@link UNUSABLE} state indicates that the profile is not in a state for + * connecting due to possibly the integrity of the fields or another profile is + * connecting etc. + * The {@link UNKNOWN} state indicates that the profile state is to be + * determined. * {@hide} */ public enum VpnState { - CONNECTING, DISCONNECTING, CANCELLED, CONNECTED, IDLE + CONNECTING, DISCONNECTING, CANCELLED, CONNECTED, IDLE, UNUSABLE, UNKNOWN } diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index a2cdcc1..12abce5 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -242,6 +242,7 @@ public class WifiStateTracker extends NetworkStateTracker { private SettingsObserver mSettingsObserver; private boolean mIsScanModeActive; + private boolean mEnableRssiPolling; // Wi-Fi run states: private static final int RUN_STATE_STARTING = 1; @@ -340,6 +341,7 @@ public class WifiStateTracker extends NetworkStateTracker { private void setSupplicantState(SupplicantState state) { mWifiInfo.setSupplicantState(state); updateNetworkInfo(); + checkPollTimer(); } public SupplicantState getSupplicantState() { @@ -354,6 +356,7 @@ public class WifiStateTracker extends NetworkStateTracker { private void setSupplicantState(String stateName) { mWifiInfo.setSupplicantState(stateName); updateNetworkInfo(); + checkPollTimer(); } /** @@ -550,8 +553,10 @@ public class WifiStateTracker extends NetworkStateTracker { * Set the interval timer for polling connection information * that is not delivered asynchronously. */ - private synchronized void setPollTimer () { - if (!hasMessages(EVENT_POLL_INTERVAL)) { + private synchronized void checkPollTimer() { + if (mEnableRssiPolling && + mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED && + !hasMessages(EVENT_POLL_INTERVAL)) { sendEmptyMessageDelayed(EVENT_POLL_INTERVAL, POLL_STATUS_INTERVAL_MSECS); } } @@ -651,6 +656,13 @@ public class WifiStateTracker extends NetworkStateTracker { setBluetoothScanMode(isBluetoothPlaying); } + public void enableRssiPolling(boolean enable) { + if (mEnableRssiPolling != enable) { + mEnableRssiPolling = enable; + checkPollTimer(); + } + } + @Override public void releaseWakeLock() { if (mReleaseWakeLockCallback != null) { @@ -1031,9 +1043,7 @@ public class WifiStateTracker extends NetworkStateTracker { case EVENT_POLL_INTERVAL: if (mWifiInfo.getSupplicantState() != SupplicantState.UNINITIALIZED) { requestPolledInfo(mWifiInfo, true); - if (mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED) { - setPollTimer(); - } + checkPollTimer(); } break; @@ -1170,7 +1180,7 @@ public class WifiStateTracker extends NetworkStateTracker { } private void configureInterface() { - setPollTimer(); + checkPollTimer(); mLastSignalLevel = -1; if (!mUseStaticIp) { if (!mHaveIpAddress && !mObtainingIpAddress) { |