diff options
66 files changed, 1477 insertions, 1327 deletions
diff --git a/api/current.xml b/api/current.xml index a31208ab7a8e..ee0a90acfc1a 100644 --- a/api/current.xml +++ b/api/current.xml @@ -115374,6 +115374,144 @@ > </field> </class> +<class name="TextToSpeech.Engine" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<constructor name="TextToSpeech.Engine" + type="android.speech.tts.TextToSpeech.Engine" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<field name="CHECK_VOICE_DATA_BAD_DATA" + type="int" + transient="false" + volatile="false" + value="-1" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="CHECK_VOICE_DATA_FAIL" + type="int" + transient="false" + volatile="false" + value="0" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="CHECK_VOICE_DATA_MISSING_DATA" + type="int" + transient="false" + volatile="false" + value="-2" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="CHECK_VOICE_DATA_MISSING_VOLUME" + type="int" + transient="false" + volatile="false" + value="-3" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="CHECK_VOICE_DATA_PASS" + type="int" + transient="false" + volatile="false" + value="1" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="TTS_DEFAULT_STREAM" + type="int" + transient="false" + volatile="false" + value="3" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="TTS_KEY_PARAM_STREAM" + type="java.lang.String" + transient="false" + volatile="false" + value=""streamType"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="TTS_KEY_PARAM_UTTERANCE_ID" + type="java.lang.String" + transient="false" + volatile="false" + value=""utteranceId"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="VOICE_DATA_FILES" + type="java.lang.String" + transient="false" + volatile="false" + value=""dataFiles"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="VOICE_DATA_FILES_INFO" + type="java.lang.String" + transient="false" + volatile="false" + value=""dataFilesInfo"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="VOICE_DATA_ROOT_DIRECTORY" + type="java.lang.String" + transient="false" + volatile="false" + value=""dataRoot"" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +</class> <interface name="TextToSpeech.OnInitListener" abstract="true" static="true" @@ -175418,6 +175556,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" @@ -175623,6 +175772,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/app/Dialog.java b/core/java/android/app/Dialog.java index 2b165fc516d4..444f222e5bde 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/SearchDialog.java b/core/java/android/app/SearchDialog.java index 13eb0347e5a5..1283b8f0fda9 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 @@ -1535,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/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java index 8530c355b935..a2e0ba0a4c26 100644 --- a/core/java/android/appwidget/AppWidgetProviderInfo.java +++ b/core/java/android/appwidget/AppWidgetProviderInfo.java @@ -57,6 +57,9 @@ public class AppWidgetProviderInfo implements Parcelable { * * <p>This field corresponds to the <code>android:updatePeriodMillis</code> attribute in * the AppWidget meta-data file. + * + * <p class="note"><b>Note:</b> Updates requested with <code>updatePeriodMillis</code> + * will not be delivered more than once every 30 minutes.</p> */ public int updatePeriodMillis; diff --git a/core/java/android/content/DialogInterface.java b/core/java/android/content/DialogInterface.java index 4afa2946176a..9f1036e6ea8b 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/res/Resources.java b/core/java/android/content/res/Resources.java index 8de938d58df2..a9aa1ee6b835 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/provider/CallLog.java b/core/java/android/provider/CallLog.java index 3d14af76d2df..b54ad5d32375 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 718a120ded94..be1bc9e9f912 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -187,6 +187,9 @@ public final class ContactsContract { public static final Uri CONTENT_SUMMARY_STREQUENT_FILTER_URI = Uri.withAppendedPath( CONTENT_SUMMARY_STREQUENT_URI, "filter"); + public static final Uri CONTENT_SUMMARY_GROUP_URI = Uri.withAppendedPath( + CONTENT_SUMMARY_URI, "group"); + /** * The MIME type of {@link #CONTENT_URI} providing a directory of * people. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 6f707cb84dc8..df3001d37698 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"; @@ -2814,7 +2820,7 @@ public final class Settings { "gtalk_nosync_heartbeat_ping_interval_ms"; /** - * The maximum heartbeat interval used while on the WIFI network. + * The maximum heartbeat interval used while on the WIFI network. */ public static final String GTALK_SERVICE_WIFI_MAX_HEARTBEAT_INTERVAL_MS = "gtalk_wifi_max_heartbeat_ping_interval_ms"; @@ -2885,7 +2891,38 @@ public final class Settings { */ public static final String PUSH_MESSAGING_REGISTRATION_URL = "push_messaging_registration_url"; - + + /** + * This is gdata url to lookup album and picture info from picasa web. + */ + public static final String GTALK_PICASA_ALBUM_URL = + "gtalk_picasa_album_url"; + + /** + * This is the url to lookup picture info from flickr. + */ + public static final String GTALK_FLICKR_PHOTO_INFO_URL = + "gtalk_flickr_photo_info_url"; + + /** + * This is the url to lookup an actual picture from flickr. + */ + public static final String GTALK_FLICKR_PHOTO_URL = + "gtalk_flickr_photo_url"; + + /** + * This is the gdata url to lookup info on a youtube video. + */ + public static final String GTALK_YOUTUBE_VIDEO_URL = + "gtalk_youtube_video_url"; + + + /** + * This is the url for getting the app token for server-to-device data messaging. + */ + public static final String DATA_MESSAGE_GET_APP_TOKEN_URL = + "data_messaging_get_app_token_url"; + /** * Enable use of ssl session caching. * 'db' - save each session in a (per process) database diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 47a1285d2f96..7a6f6bb5c0a2 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 77b1b1d5e513..13d980d336a0 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 67be6a663514..70c7d7313bae 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; diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index a2e70b8193f7..db9f8d85295d 100755 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -113,43 +113,131 @@ public class TextToSpeech { /** * Internal constants for the TTS functionality * - * {@hide} */ public class Engine { // default values for a TTS engine when settings are not found in the provider + /** + * {@hide} + */ public static final int FALLBACK_TTS_DEFAULT_RATE = 100; // 1x + /** + * {@hide} + */ public static final int FALLBACK_TTS_DEFAULT_PITCH = 100;// 1x + /** + * {@hide} + */ public static final int FALLBACK_TTS_USE_DEFAULTS = 0; // false + /** + * {@hide} + */ public static final String FALLBACK_TTS_DEFAULT_SYNTH = "com.svox.pico"; // default values for rendering public static final int TTS_DEFAULT_STREAM = AudioManager.STREAM_MUSIC; // return codes for a TTS engine's check data activity + /** + * Indicates success when checking the installation status of the resources used by the + * text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent. + */ public static final int CHECK_VOICE_DATA_PASS = 1; + /** + * Indicates failure when checking the installation status of the resources used by the + * text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent. + */ public static final int CHECK_VOICE_DATA_FAIL = 0; + /** + * Indicates erroneous data when checking the installation status of the resources used by + * the text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent. + */ public static final int CHECK_VOICE_DATA_BAD_DATA = -1; + /** + * Indicates missing resources when checking the installation status of the resources used + * by the text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent. + */ public static final int CHECK_VOICE_DATA_MISSING_DATA = -2; - public static final int CHECK_VOICE_DATA_MISSING_DATA_NO_SDCARD = -3; + /** + * Indicates missing storage volume when checking the installation status of the resources + * used by the text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent. + */ + public static final int CHECK_VOICE_DATA_MISSING_VOLUME = -3; // return codes for a TTS engine's check data activity + /** + * Extra information received with the android.intent.action.CHECK_TTS_DATA intent where + * the text-to-speech engine specifies the path to its resources. + */ public static final String VOICE_DATA_ROOT_DIRECTORY = "dataRoot"; + /** + * Extra information received with the android.intent.action.CHECK_TTS_DATA intent where + * the text-to-speech engine specifies the file names of its resources under the + * resource path. + */ public static final String VOICE_DATA_FILES = "dataFiles"; + /** + * Extra information received with the android.intent.action.CHECK_TTS_DATA intent where + * the text-to-speech engine specifies the locale associated with each resource file. + */ public static final String VOICE_DATA_FILES_INFO = "dataFilesInfo"; - // keys for the parameters passed with speak commands + // keys for the parameters passed with speak commands. Hidden keys are used internally + // to maintain engine state for each TextToSpeech instance. + /** + * {@hide} + */ public static final String TTS_KEY_PARAM_RATE = "rate"; + /** + * {@hide} + */ public static final String TTS_KEY_PARAM_LANGUAGE = "language"; + /** + * {@hide} + */ public static final String TTS_KEY_PARAM_COUNTRY = "country"; + /** + * {@hide} + */ public static final String TTS_KEY_PARAM_VARIANT = "variant"; + /** + * Parameter key to specify the audio stream type to be used when speaking text + * or playing back a file. + */ public static final String TTS_KEY_PARAM_STREAM = "streamType"; + /** + * Parameter key to identify an utterance in the completion listener after text has been + * spoken, a file has been played back or a silence duration has elapsed. + */ public static final String TTS_KEY_PARAM_UTTERANCE_ID = "utteranceId"; + + // key positions in the array of cached parameters + /** + * {@hide} + */ protected static final int TTS_PARAM_POSITION_RATE = 0; + /** + * {@hide} + */ protected static final int TTS_PARAM_POSITION_LANGUAGE = 2; + /** + * {@hide} + */ protected static final int TTS_PARAM_POSITION_COUNTRY = 4; + /** + * {@hide} + */ protected static final int TTS_PARAM_POSITION_VARIANT = 6; + /** + * {@hide} + */ protected static final int TTS_PARAM_POSITION_STREAM = 8; + /** + * {@hide} + */ protected static final int TTS_PARAM_POSITION_UTTERANCE_ID = 10; + /** + * {@hide} + */ protected static final int TTS_NB_CACHED_PARAMS = 6; } diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 09ebeed543e1..5551f64bcde3 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 57768515ad48..1e3cdb34f436 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 2c32d8b54af6..02e0515d6f28 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/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index be3dd1992439..ae509c503b01 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 54f27072b4f9..3b9f1de4c66c 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/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 0c2cd55d2ee3..90fbb77d255e 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/com/android/internal/widget/NumberPicker.java b/core/java/com/android/internal/widget/NumberPicker.java index 2f08c8dd424b..0424ced5c76e 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 000000000000..d36e403a79a8 --- /dev/null +++ b/core/jni/.android_server_BluetoothEventLoop.cpp.swp diff --git a/core/res/res/values-he-rIL/donottranslate-cldr.xml b/core/res/res/values-he-rIL/donottranslate-cldr.xml index e3feb1e33146..3378ed7227ad 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 47290552dd2e..1111658ffb90 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 f38a2d0499d7..197cb6ed16fd 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 47290552dd2e..1111658ffb90 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 72ff8b68999c..6f2d3422e9fb 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/data/etc/platform.xml b/data/etc/platform.xml index a3579c7b8d72..20aa6e787640 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/include/private/ui/SharedState.h b/include/private/ui/SharedState.h index 3bc7979ca810..c9f6b5edb9ab 100644 --- a/include/private/ui/SharedState.h +++ b/include/private/ui/SharedState.h @@ -98,6 +98,8 @@ struct layer_cblk_t // (128 bytes) struct per_client_cblk_t // 4KB max { + per_client_cblk_t() : lock(Mutex::SHARED) { } + Mutex lock; Condition cv; layer_cblk_t layers[NUM_LAYERS_MAX] __attribute__((aligned(32))); diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h index e12c4f13ea0d..d9c0af211703 100644 --- a/include/ui/EventHub.h +++ b/include/ui/EventHub.h @@ -73,6 +73,9 @@ public: int getKeycodeState(int key) const; int getKeycodeState(int32_t deviceId, int key) const; + status_t scancodeToKeycode(int32_t deviceId, int scancode, + int32_t* outKeycode, uint32_t* outFlags) const; + // special type codes when devices are added/removed. enum { DEVICE_ADDED = 0x10000000, @@ -121,7 +124,7 @@ private: mutable Mutex mLock; bool mHaveFirstKeyboard; - int32_t mFirstKeyboardId; // the API is that the build in keyboard is id 0, so map it + int32_t mFirstKeyboardId; // the API is that the built-in keyboard is id 0, so map it struct device_ent { device_t* device; diff --git a/include/utils/threads.h b/include/utils/threads.h index 5c0396596074..e9b0788895e2 100644 --- a/include/utils/threads.h +++ b/include/utils/threads.h @@ -190,8 +190,14 @@ inline thread_id_t getThreadId() { */ class Mutex { public: + enum { + NORMAL = 0, + SHARED = 1 + }; + Mutex(); Mutex(const char* name); + Mutex(int type, const char* name = NULL); ~Mutex(); // lock or unlock the mutex @@ -235,6 +241,17 @@ inline Mutex::Mutex() { inline Mutex::Mutex(const char* name) { pthread_mutex_init(&mMutex, NULL); } +inline Mutex::Mutex(int type, const char* name) { + if (type == SHARED) { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + pthread_mutex_init(&mMutex, &attr); + pthread_mutexattr_destroy(&attr); + } else { + pthread_mutex_init(&mMutex, NULL); + } +} inline Mutex::~Mutex() { pthread_mutex_destroy(&mMutex); } diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp index 13c30a795cb2..a72f055c388c 100644 --- a/libs/ui/EventHub.cpp +++ b/libs/ui/EventHub.cpp @@ -240,6 +240,35 @@ int EventHub::getKeycodeState(int32_t deviceId, int code) const return 0; } +status_t EventHub::scancodeToKeycode(int32_t deviceId, int scancode, + int32_t* outKeycode, uint32_t* outFlags) const +{ + AutoMutex _l(mLock); + device_t* device = getDevice(deviceId); + + if (device != NULL && device->layoutMap != NULL) { + status_t err = device->layoutMap->map(scancode, outKeycode, outFlags); + if (err == NO_ERROR) { + return NO_ERROR; + } + } + + if (mHaveFirstKeyboard) { + device = getDevice(mFirstKeyboardId); + + if (device != NULL && device->layoutMap != NULL) { + status_t err = device->layoutMap->map(scancode, outKeycode, outFlags); + if (err == NO_ERROR) { + return NO_ERROR; + } + } + } + + *outKeycode = 0; + *outFlags = 0; + return NAME_NOT_FOUND; +} + EventHub::device_t* EventHub::getDevice(int32_t deviceId) const { if (deviceId == 0) deviceId = mFirstKeyboardId; diff --git a/libs/utils/BackupData.cpp b/libs/utils/BackupData.cpp index cce754a08213..be04777528ea 100644 --- a/libs/utils/BackupData.cpp +++ b/libs/utils/BackupData.cpp @@ -298,10 +298,12 @@ BackupDataReader::SkipEntityData() } if (m_header.entity.dataSize > 0) { int pos = lseek(m_fd, m_dataEndPos, SEEK_SET); - return pos == -1 ? (int)errno : (int)NO_ERROR; - } else { - return NO_ERROR; + if (pos == -1) { + return errno; + } } + SKIP_PADDING(); + return NO_ERROR; } ssize_t diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index af7dae5f502f..7b9eda76d820 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -891,7 +891,7 @@ void AudioTrack::AudioTrackThread::onFirstRef() // ========================================================================= audio_track_cblk_t::audio_track_cblk_t() - : user(0), server(0), userBase(0), serverBase(0), buffers(0), frameCount(0), + : lock(Mutex::SHARED), user(0), server(0), userBase(0), serverBase(0), buffers(0), frameCount(0), loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), volumeLR(0), flowControlFlag(1), forceReady(0) { } diff --git a/obex/javax/obex/Authenticator.java b/obex/javax/obex/Authenticator.java index 7246e9166b8f..ec226fb7ada3 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 c32717fad272..022ad4fb4a34 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 b3807afe0705..65663b1a5bb9 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 d5549222edde..093538330f5d 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 f777da65cd93..8b457f66ece2 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 511b7c667531..e6ade7b58d16 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 97d65e099d2f..a7daeb533e16 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 d0ba0c92f10f..445e2675b212 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 f265f5335999..20653f26df2d 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 e81a8611391a..326b1ff56a74 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 2dc02da511f1..5daee72474fc 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 d972f78a22ad..ca420afdda37 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 f6cc9c16a95f..a2b9a37b4af1 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 6c3d9ba1801e..8710c64a46d6 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 e468b83f2f62..d93e5b61ab9c 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 3a0e81501acf..423d5a757b89 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 36e0ebf14226..9836dd60f2c6 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 21622dc5a68c..000000000000 --- 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/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java index 131e156748d0..78db6f93727e 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/AppWidgetService.java @@ -68,6 +68,7 @@ class AppWidgetService extends IAppWidgetService.Stub private static final String SETTINGS_FILENAME = "appwidgets.xml"; private static final String SETTINGS_TMP_FILENAME = SETTINGS_FILENAME + ".tmp"; + private static final int MIN_UPDATE_PERIOD = 30 * 60 * 1000; // 30 minutes /* * When identifying a Host or Provider based on the calling process, use the uid field. @@ -629,9 +630,12 @@ class AppWidgetService extends IAppWidgetService.Stub Binder.restoreCallingIdentity(token); } if (!alreadyRegistered) { + long period = p.info.updatePeriodMillis; + if (period < MIN_UPDATE_PERIOD) { + period = MIN_UPDATE_PERIOD; + } mAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, - SystemClock.elapsedRealtime() + p.info.updatePeriodMillis, - p.info.updatePeriodMillis, p.broadcast); + SystemClock.elapsedRealtime() + period, period, p.broadcast); } } } diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 69371b3312e3..20f0750bc8f8 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/InputDevice.java b/services/java/com/android/server/InputDevice.java index 9c1f9421a818..a71c39a0b3b5 100644 --- a/services/java/com/android/server/InputDevice.java +++ b/services/java/com/android/server/InputDevice.java @@ -66,19 +66,56 @@ public class InputDevice { MotionEvent generateMotion(InputDevice device, long curTime, long curTimeNano, boolean isAbs, Display display, int orientation, int metaState) { - if (!changed) { - return null; - } - float scaledX = x; float scaledY = y; float temp; float scaledPressure = 1.0f; float scaledSize = 0; int edgeFlags = 0; + + int action; + if (down != lastDown) { + if (isAbs) { + final AbsoluteInfo absX = device.absX; + final AbsoluteInfo absY = device.absY; + if (down && absX != null && absY != null) { + // We don't let downs start unless we are + // inside of the screen. There are two reasons for + // this: to avoid spurious touches when holding + // the edges of the device near the touchscreen, + // and to avoid reporting events if there are virtual + // keys on the touchscreen outside of the display + // area. + if (scaledX < absX.minValue || scaledX > absX.maxValue + || scaledY < absY.minValue || scaledY > absY.maxValue) { + if (false) Log.v("InputDevice", "Rejecting (" + scaledX + "," + + scaledY + "): outside of (" + + absX.minValue + "," + absY.minValue + + ")-(" + absX.maxValue + "," + + absY.maxValue + ")"); + return null; + } + } + } else { + x = y = 0; + } + lastDown = down; + if (down) { + action = MotionEvent.ACTION_DOWN; + downTime = curTime; + } else { + action = MotionEvent.ACTION_UP; + } + currentMove = null; + } else { + action = MotionEvent.ACTION_MOVE; + } + if (isAbs) { - int w = display.getWidth()-1; - int h = display.getHeight()-1; + final int dispW = display.getWidth()-1; + final int dispH = display.getHeight()-1; + int w = dispW; + int h = dispH; if (orientation == Surface.ROTATION_90 || orientation == Surface.ROTATION_270) { int tmp = w; @@ -120,16 +157,17 @@ public class InputDevice { break; } - if (scaledX == 0) { - edgeFlags += MotionEvent.EDGE_LEFT; - } else if (scaledX == display.getWidth() - 1.0f) { - edgeFlags += MotionEvent.EDGE_RIGHT; - } - - if (scaledY == 0) { - edgeFlags += MotionEvent.EDGE_TOP; - } else if (scaledY == display.getHeight() - 1.0f) { - edgeFlags += MotionEvent.EDGE_BOTTOM; + if (action != MotionEvent.ACTION_DOWN) { + if (scaledX <= 0) { + edgeFlags += MotionEvent.EDGE_LEFT; + } else if (scaledX >= dispW) { + edgeFlags += MotionEvent.EDGE_RIGHT; + } + if (scaledY <= 0) { + edgeFlags += MotionEvent.EDGE_TOP; + } else if (scaledY >= dispH) { + edgeFlags += MotionEvent.EDGE_BOTTOM; + } } } else { @@ -153,41 +191,25 @@ public class InputDevice { } } - changed = false; - if (down != lastDown) { - int action; - lastDown = down; - if (down) { - action = MotionEvent.ACTION_DOWN; - downTime = curTime; - } else { - action = MotionEvent.ACTION_UP; - } - currentMove = null; - if (!isAbs) { - x = y = 0; - } - return MotionEvent.obtainNano(downTime, curTime, curTimeNano, action, - scaledX, scaledY, scaledPressure, scaledSize, metaState, - xPrecision, yPrecision, device.id, edgeFlags); - } else { - if (currentMove != null) { - if (false) Log.i("InputDevice", "Adding batch x=" + scaledX - + " y=" + scaledY + " to " + currentMove); - currentMove.addBatch(curTime, scaledX, scaledY, - scaledPressure, scaledSize, metaState); - if (WindowManagerPolicy.WATCH_POINTER) { - Log.i("KeyInputQueue", "Updating: " + currentMove); - } - return null; + if (currentMove != null) { + if (false) Log.i("InputDevice", "Adding batch x=" + scaledX + + " y=" + scaledY + " to " + currentMove); + currentMove.addBatch(curTime, scaledX, scaledY, + scaledPressure, scaledSize, metaState); + if (WindowManagerPolicy.WATCH_POINTER) { + Log.i("KeyInputQueue", "Updating: " + currentMove); } - MotionEvent me = MotionEvent.obtainNano(downTime, curTime, curTimeNano, - MotionEvent.ACTION_MOVE, scaledX, scaledY, - scaledPressure, scaledSize, metaState, - xPrecision, yPrecision, device.id, edgeFlags); + return null; + } + + MotionEvent me = MotionEvent.obtainNano(downTime, curTime, + curTimeNano, action, scaledX, scaledY, + scaledPressure, scaledSize, metaState, + xPrecision, yPrecision, device.id, edgeFlags); + if (action == MotionEvent.ACTION_MOVE) { currentMove = me; - return me; } + return me; } } diff --git a/services/java/com/android/server/KeyInputQueue.java b/services/java/com/android/server/KeyInputQueue.java index 78cdf8b97eef..fd6b813e7ada 100644 --- a/services/java/com/android/server/KeyInputQueue.java +++ b/services/java/com/android/server/KeyInputQueue.java @@ -30,10 +30,20 @@ import android.view.RawInputEvent; import android.view.Surface; import android.view.WindowManagerPolicy; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + public abstract class KeyInputQueue { static final String TAG = "KeyInputQueue"; - SparseArray<InputDevice> mDevices = new SparseArray<InputDevice>(); + static final boolean DEBUG_VIRTUAL_KEYS = false; + + final SparseArray<InputDevice> mDevices = new SparseArray<InputDevice>(); + final ArrayList<VirtualKey> mVirtualKeys = new ArrayList<VirtualKey>(); int mGlobalMetaState = 0; boolean mHaveGlobalMetaState = false; @@ -44,10 +54,14 @@ public abstract class KeyInputQueue { int mCacheCount; Display mDisplay = null; + int mDisplayWidth; + int mDisplayHeight; int mOrientation = Surface.ROTATION_0; int[] mKeyRotationMap = null; + VirtualKey mPressedVirtualKey = null; + PowerManager.WakeLock mWakeLock; static final int[] KEY_90_MAP = new int[] { @@ -110,11 +124,106 @@ public abstract class KeyInputQueue { QueuedEvent next; } + /** + * A key that exists as a part of the touch-screen, outside of the normal + * display area of the screen. + */ + static class VirtualKey { + int scancode; + int centerx; + int centery; + int width; + int height; + + int hitLeft; + int hitTop; + int hitRight; + int hitBottom; + + InputDevice lastDevice; + int lastKeycode; + + boolean checkHit(int x, int y) { + return (x >= hitLeft && x <= hitRight + && y >= hitTop && y <= hitBottom); + } + + void computeHitRect(InputDevice dev, int dw, int dh) { + if (dev == lastDevice) { + return; + } + + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, "computeHitRect for " + scancode + + ": dev=" + dev + " absX=" + dev.absX + " absY=" + dev.absY); + + lastDevice = dev; + + int minx = dev.absX.minValue; + int maxx = dev.absX.maxValue; + + int halfw = width/2; + int left = centerx - halfw; + int right = centerx + halfw; + hitLeft = minx + ((left*maxx-minx)/dw); + hitRight = minx + ((right*maxx-minx)/dw); + + int miny = dev.absY.minValue; + int maxy = dev.absY.maxValue; + + int halfh = height/2; + int top = centery - halfh; + int bottom = centery + halfh; + hitTop = miny + ((top*maxy-miny)/dh); + hitBottom = miny + ((bottom*maxy-miny)/dh); + } + } + KeyInputQueue(Context context) { if (MEASURE_LATENCY) { lt = new LatencyTimer(100, 1000); } + try { + FileInputStream fis = new FileInputStream( + "/sys/board_properties/virtualkeys.synaptics-rmi-touchscreen"); + InputStreamReader isr = new InputStreamReader(fis); + BufferedReader br = new BufferedReader(isr); + String str = br.readLine(); + if (str != null) { + String[] it = str.split(":"); + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, "***** VIRTUAL KEYS: " + it); + final int N = it.length-6; + for (int i=0; i<=N; i+=6) { + if (!"0x01".equals(it[i])) { + Log.w(TAG, "Unknown virtual key type at elem #" + i + + ": " + it[i]); + continue; + } + try { + VirtualKey sb = new VirtualKey(); + sb.scancode = Integer.parseInt(it[i+1]); + sb.centerx = Integer.parseInt(it[i+2]); + sb.centery = Integer.parseInt(it[i+3]); + sb.width = Integer.parseInt(it[i+4]); + sb.height = Integer.parseInt(it[i+5]); + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, "Virtual key " + + sb.scancode + ": center=" + sb.centerx + "," + + sb.centery + " size=" + sb.width + "x" + + sb.height); + mVirtualKeys.add(sb); + } catch (NumberFormatException e) { + Log.w(TAG, "Bad number at region " + i + " in: " + + str, e); + } + } + } + br.close(); + } catch (FileNotFoundException e) { + Log.i(TAG, "No virtual keys found"); + } catch (IOException e) { + Log.w(TAG, "Error reading virtual keys", e); + } + PowerManager pm = (PowerManager)context.getSystemService( Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, @@ -131,6 +240,12 @@ public abstract class KeyInputQueue { public void setDisplay(Display display) { mDisplay = display; + + // We assume at this point that the display dimensions reflect the + // natural, unrotated display. We will perform hit tests for soft + // buttons based on that display. + mDisplayWidth = display.getWidth(); + mDisplayHeight = display.getHeight(); } public void getInputConfiguration(Configuration config) { @@ -173,6 +288,7 @@ public abstract class KeyInputQueue { public static native int getScancodeState(int deviceId, int sw); public static native int getKeycodeState(int sw); public static native int getKeycodeState(int deviceId, int sw); + public static native int scancodeToKeycode(int deviceId, int scancode); public static native boolean hasKeys(int[] keycodes, boolean[] keyExists); public static KeyEvent newKeyEvent(InputDevice device, long downTime, @@ -339,36 +455,127 @@ public abstract class KeyInputQueue { } MotionEvent me; - me = di.mAbs.generateMotion(di, curTime, curTimeNano, true, - mDisplay, mOrientation, mGlobalMetaState); - if (false) Log.v(TAG, "Absolute: x=" + di.mAbs.x - + " y=" + di.mAbs.y + " ev=" + me); - if (me != null) { - if (WindowManagerPolicy.WATCH_POINTER) { - Log.i(TAG, "Enqueueing: " + me); + + InputDevice.MotionState ms = di.mAbs; + if (ms.changed) { + ms.changed = false; + + boolean doMotion = true; + + // Look for virtual buttons. + VirtualKey vk = mPressedVirtualKey; + if (vk != null) { + doMotion = false; + if (!ms.down) { + mPressedVirtualKey = null; + ms.lastDown = ms.down; + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, + "Generate key up for: " + vk.scancode); + addLocked(di, curTimeNano, ev.flags, + RawInputEvent.CLASS_KEYBOARD, + newKeyEvent(di, di.mDownTime, + curTime, false, + vk.lastKeycode, + 0, vk.scancode, 0)); + } + } else if (ms.down && !ms.lastDown) { + vk = findSoftButton(di); + if (vk != null) { + doMotion = false; + mPressedVirtualKey = vk; + vk.lastKeycode = scancodeToKeycode( + di.id, vk.scancode); + ms.lastDown = ms.down; + di.mDownTime = curTime; + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, + "Generate key down for: " + vk.scancode + + " (keycode=" + vk.lastKeycode + ")"); + addLocked(di, curTimeNano, ev.flags, + RawInputEvent.CLASS_KEYBOARD, + newKeyEvent(di, di.mDownTime, + curTime, true, + vk.lastKeycode, 0, + vk.scancode, 0)); + } + } + + if (doMotion) { + me = ms.generateMotion(di, curTime, + curTimeNano, true, mDisplay, + mOrientation, mGlobalMetaState); + if (false) Log.v(TAG, "Absolute: x=" + di.mAbs.x + + " y=" + di.mAbs.y + " ev=" + me); + if (me != null) { + if (WindowManagerPolicy.WATCH_POINTER) { + Log.i(TAG, "Enqueueing: " + me); + } + addLocked(di, curTimeNano, ev.flags, + RawInputEvent.CLASS_TOUCHSCREEN, me); + } } - addLocked(di, curTimeNano, ev.flags, - RawInputEvent.CLASS_TOUCHSCREEN, me); } - me = di.mRel.generateMotion(di, curTime, curTimeNano, false, - mDisplay, mOrientation, mGlobalMetaState); - if (false) Log.v(TAG, "Relative: x=" + di.mRel.x - + " y=" + di.mRel.y + " ev=" + me); - if (me != null) { - addLocked(di, curTimeNano, ev.flags, - RawInputEvent.CLASS_TRACKBALL, me); + + ms = di.mRel; + if (ms.changed) { + ms.changed = false; + + me = ms.generateMotion(di, curTime, + curTimeNano, false, mDisplay, + mOrientation, mGlobalMetaState); + if (false) Log.v(TAG, "Relative: x=" + di.mRel.x + + " y=" + di.mRel.y + " ev=" + me); + if (me != null) { + addLocked(di, curTimeNano, ev.flags, + RawInputEvent.CLASS_TRACKBALL, me); + } } } } } } - } - catch (RuntimeException exc) { + + } catch (RuntimeException exc) { Log.e(TAG, "InputReaderThread uncaught exception", exc); } } }; + private VirtualKey findSoftButton(InputDevice dev) { + final int N = mVirtualKeys.size(); + if (N <= 0) { + return null; + } + + final InputDevice.AbsoluteInfo absx = dev.absX; + final InputDevice.AbsoluteInfo absy = dev.absY; + final InputDevice.MotionState absm = dev.mAbs; + if (absx == null || absy == null || absm == null) { + return null; + } + + if (absm.x >= absx.minValue && absm.x <= absx.maxValue + && absm.y >= absy.minValue && absm.y <= absy.maxValue) { + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, "Input (" + absm.x + + "," + absm.y + ") inside of display"); + return null; + } + + for (int i=0; i<N; i++) { + VirtualKey sb = mVirtualKeys.get(i); + sb.computeHitRect(dev, mDisplayWidth, mDisplayHeight); + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, "Hit test (" + absm.x + "," + + absm.y + ") in code " + sb.scancode + " - (" + sb.hitLeft + + "," + sb.hitTop + ")-(" + sb.hitRight + "," + + sb.hitBottom + ")"); + if (sb.checkHit(absm.x, absm.y)) { + if (DEBUG_VIRTUAL_KEYS) Log.v(TAG, "Hit!"); + return sb; + } + } + + return null; + } + /** * Returns a new meta state for the given keys and old state. */ diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index a561d119cd79..67e8cf3a2683 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/jni/com_android_server_KeyInputQueue.cpp b/services/jni/com_android_server_KeyInputQueue.cpp index 63830d59c24a..afca1f7ec34f 100644 --- a/services/jni/com_android_server_KeyInputQueue.cpp +++ b/services/jni/com_android_server_KeyInputQueue.cpp @@ -205,6 +205,23 @@ android_server_KeyInputQueue_getKeycodeStateDevice(JNIEnv* env, jobject clazz, return st; } +static jint +android_server_KeyInputQueue_scancodeToKeycode(JNIEnv* env, jobject clazz, + jint deviceId, jint scancode) +{ + jint res = 0; + gLock.lock(); + if (gHub != NULL) { + int32_t keycode; + uint32_t flags; + gHub->scancodeToKeycode(deviceId, scancode, &keycode, &flags); + res = keycode; + } + gLock.unlock(); + + return res; +} + static jboolean android_server_KeyInputQueue_hasKeys(JNIEnv* env, jobject clazz, jintArray keyCodes, jbooleanArray outFlags) @@ -254,6 +271,8 @@ static JNINativeMethod gInputMethods[] = { (void*) android_server_KeyInputQueue_getKeycodeStateDevice }, { "hasKeys", "([I[Z)Z", (void*) android_server_KeyInputQueue_hasKeys }, + { "scancodeToKeycode", "(II)I", + (void*) android_server_KeyInputQueue_scancodeToKeycode }, }; int register_android_server_KeyInputQueue(JNIEnv* env) diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java index 7f2b8496f592..0bb2df156c75 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 1509a6bcb1e3..fbda221ddbbb 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 da002683a895..979f0cdca574 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 0918a8c1437a..1cd6e58a8a29 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 ed2ea90d3f23..a5f9c11a9935 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 d1e4b4f21cab..ebbf096e14dc 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 5c5090ffe911..f3b7596f6bd3 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 710741297613..b96743a2fbc3 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/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index a2cdcc1d600d..12abce57eafc 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) { |