Loading src/com/android/bluetooth/pbap/BluetoothPbapActivity.java +7 −19 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ package com.android.bluetooth.pbap; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; Loading @@ -47,7 +48,6 @@ import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; Loading Loading @@ -85,16 +85,14 @@ public class BluetoothPbapActivity extends AlertActivity private Button mOkButton; private CheckBox mAlwaysAllowed; private boolean mTimeout = false; private boolean mAlwaysAllowedValue = true; private static final int DISMISS_TIMEOUT_DIALOG = 0; private static final int DISMISS_TIMEOUT_DIALOG_VALUE = 2000; private BluetoothDevice mDevice; private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading @@ -110,6 +108,7 @@ public class BluetoothPbapActivity extends AlertActivity super.onCreate(savedInstanceState); Intent i = getIntent(); String action = i.getAction(); mDevice = i.getParcelableExtra(BluetoothPbapService.EXTRA_DEVICE); if (action.equals(BluetoothPbapService.AUTH_CHALL_ACTION)) { showPbapDialog(DIALOG_YES_NO_AUTH); mCurrentDialog = DIALOG_YES_NO_AUTH; Loading Loading @@ -142,10 +141,9 @@ public class BluetoothPbapActivity extends AlertActivity } private String createDisplayText(final int id) { String mRemoteName = BluetoothPbapService.getRemoteDeviceName(); switch (id) { case DIALOG_YES_NO_AUTH: String mMessage2 = getString(R.string.pbap_session_key_dialog_title, mRemoteName); String mMessage2 = getString(R.string.pbap_session_key_dialog_title, mDevice); return mMessage2; default: return null; Loading Loading @@ -193,16 +191,7 @@ public class BluetoothPbapActivity extends AlertActivity final String extraValue) { Intent intent = new Intent(intentName); intent.setPackage(BluetoothPbapService.THIS_PACKAGE_NAME); if (extraName != null) { intent.putExtra(extraName, extraValue); } sendBroadcast(intent); } private void sendIntentToReceiver(final String intentName, final String extraName, final boolean extraValue) { Intent intent = new Intent(intentName); intent.setPackage(BluetoothPbapService.THIS_PACKAGE_NAME); intent.putExtra(BluetoothPbapService.EXTRA_DEVICE, mDevice); if (extraName != null) { intent.putExtra(extraName, extraValue); } Loading Loading @@ -230,8 +219,7 @@ public class BluetoothPbapActivity extends AlertActivity private void onTimeout() { mTimeout = true; if (mCurrentDialog == DIALOG_YES_NO_AUTH) { mMessageView.setText(getString(R.string.pbap_authentication_timeout_message, BluetoothPbapService.getRemoteDeviceName())); mMessageView.setText(getString(R.string.pbap_authentication_timeout_message, mDevice)); mKeyView.setVisibility(View.GONE); mKeyView.clearFocus(); mKeyView.removeTextChangedListener(this); Loading src/com/android/bluetooth/pbap/BluetoothPbapAuthenticator.java +11 −17 Original line number Diff line number Diff line Loading @@ -32,8 +32,6 @@ package com.android.bluetooth.pbap; import android.os.Handler; import android.os.Message; import android.util.Log; import javax.obex.Authenticator; Loading @@ -44,39 +42,36 @@ import javax.obex.PasswordAuthentication; * authentication procedure. */ public class BluetoothPbapAuthenticator implements Authenticator { private static final String TAG = "BluetoothPbapAuthenticator"; private static final String TAG = "PbapAuthenticator"; private boolean mChallenged; private boolean mAuthCancelled; private String mSessionKey; private PbapStateMachine mPbapStateMachine; private Handler mCallback; public BluetoothPbapAuthenticator(final Handler callback) { mCallback = callback; BluetoothPbapAuthenticator(final PbapStateMachine stateMachine) { mPbapStateMachine = stateMachine; mChallenged = false; mAuthCancelled = false; mSessionKey = null; } public final synchronized void setChallenged(final boolean bool) { final synchronized void setChallenged(final boolean bool) { mChallenged = bool; } public final synchronized void setCancelled(final boolean bool) { final synchronized void setCancelled(final boolean bool) { mAuthCancelled = bool; } public final synchronized void setSessionKey(final String string) { final synchronized void setSessionKey(final String string) { mSessionKey = string; } private void waitUserConfirmation() { Message msg = Message.obtain(mCallback); msg.what = BluetoothPbapService.MSG_OBEX_AUTH_CHALL; msg.sendToTarget(); mPbapStateMachine.sendMessage(PbapStateMachine.CREATE_NOTIFICATION); mPbapStateMachine.sendMessageDelayed(PbapStateMachine.REMOVE_NOTIFICATION, BluetoothPbapService.USER_CONFIRM_TIMEOUT_VALUE); synchronized (this) { while (!mChallenged && !mAuthCancelled) { try { Loading @@ -93,8 +88,7 @@ public class BluetoothPbapAuthenticator implements Authenticator { final boolean isUserIdRequired, final boolean isFullAccess) { waitUserConfirmation(); if (mSessionKey.trim().length() != 0) { PasswordAuthentication pa = new PasswordAuthentication(null, mSessionKey.getBytes()); return pa; return new PasswordAuthentication(null, mSessionKey.getBytes()); } return null; } Loading src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java +8 −19 Original line number Diff line number Diff line Loading @@ -171,8 +171,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private boolean mVcardSelector = false; private int mMissedCallSize = 0; // record current path the client are browsing private String mCurrentPath = ""; Loading @@ -180,8 +178,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private Context mContext; private BluetoothPbapService mService; private BluetoothPbapVcardManager mVcardManager; private int mOrderBy = ORDER_BY_INDEXED; Loading @@ -204,6 +200,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private AppParamValue mConnAppParamValue; private PbapStateMachine mStateMachine; public static class ContentType { public static final int PHONEBOOK = 1; Loading @@ -216,12 +214,13 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { public static final int COMBINED_CALL_HISTORY = 5; } public BluetoothPbapObexServer(Handler callback, BluetoothPbapService service) { public BluetoothPbapObexServer(Handler callback, Context context, PbapStateMachine stateMachine) { super(); mCallback = callback; mService = service; mContext = service.getApplicationContext(); mContext = context; mVcardManager = new BluetoothPbapVcardManager(mContext); mStateMachine = stateMachine; } @Override Loading Loading @@ -284,9 +283,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { Log.v(TAG, "onConnect(): uuid is ok, will send out " + "MSG_SESSION_ESTABLISHED msg."); } Message msg = Message.obtain(mCallback); msg.what = BluetoothPbapService.MSG_SESSION_ESTABLISHED; msg.sendToTarget(); return ResponseCodes.OBEX_HTTP_OK; } Loading Loading @@ -383,14 +379,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { @Override public void onClose() { if (mCallback != null) { Message msg = Message.obtain(mCallback); msg.what = BluetoothPbapService.MSG_SERVERSESSION_CLOSE; msg.sendToTarget(); if (D) { Log.d(TAG, "onClose(): msg MSG_SERVERSESSION_CLOSE sent out."); } } mStateMachine.sendMessage(PbapStateMachine.DISCONNECT); } @Override Loading Loading @@ -1439,7 +1428,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private byte[] getDatabaseIdentifier() { mDatabaseIdentifierHigh = 0; mDatabaseIdentifierLow = mService.getDbIdentifier(); mDatabaseIdentifierLow = BluetoothPbapUtils.sDbIdentifier.get(); if (mDatabaseIdentifierLow != INVALID_VALUE_PARAMETER && mDatabaseIdentifierHigh != INVALID_VALUE_PARAMETER) { ByteBuffer ret = ByteBuffer.allocate(16); Loading Loading
src/com/android/bluetooth/pbap/BluetoothPbapActivity.java +7 −19 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ package com.android.bluetooth.pbap; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; Loading @@ -47,7 +48,6 @@ import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; Loading Loading @@ -85,16 +85,14 @@ public class BluetoothPbapActivity extends AlertActivity private Button mOkButton; private CheckBox mAlwaysAllowed; private boolean mTimeout = false; private boolean mAlwaysAllowedValue = true; private static final int DISMISS_TIMEOUT_DIALOG = 0; private static final int DISMISS_TIMEOUT_DIALOG_VALUE = 2000; private BluetoothDevice mDevice; private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading @@ -110,6 +108,7 @@ public class BluetoothPbapActivity extends AlertActivity super.onCreate(savedInstanceState); Intent i = getIntent(); String action = i.getAction(); mDevice = i.getParcelableExtra(BluetoothPbapService.EXTRA_DEVICE); if (action.equals(BluetoothPbapService.AUTH_CHALL_ACTION)) { showPbapDialog(DIALOG_YES_NO_AUTH); mCurrentDialog = DIALOG_YES_NO_AUTH; Loading Loading @@ -142,10 +141,9 @@ public class BluetoothPbapActivity extends AlertActivity } private String createDisplayText(final int id) { String mRemoteName = BluetoothPbapService.getRemoteDeviceName(); switch (id) { case DIALOG_YES_NO_AUTH: String mMessage2 = getString(R.string.pbap_session_key_dialog_title, mRemoteName); String mMessage2 = getString(R.string.pbap_session_key_dialog_title, mDevice); return mMessage2; default: return null; Loading Loading @@ -193,16 +191,7 @@ public class BluetoothPbapActivity extends AlertActivity final String extraValue) { Intent intent = new Intent(intentName); intent.setPackage(BluetoothPbapService.THIS_PACKAGE_NAME); if (extraName != null) { intent.putExtra(extraName, extraValue); } sendBroadcast(intent); } private void sendIntentToReceiver(final String intentName, final String extraName, final boolean extraValue) { Intent intent = new Intent(intentName); intent.setPackage(BluetoothPbapService.THIS_PACKAGE_NAME); intent.putExtra(BluetoothPbapService.EXTRA_DEVICE, mDevice); if (extraName != null) { intent.putExtra(extraName, extraValue); } Loading Loading @@ -230,8 +219,7 @@ public class BluetoothPbapActivity extends AlertActivity private void onTimeout() { mTimeout = true; if (mCurrentDialog == DIALOG_YES_NO_AUTH) { mMessageView.setText(getString(R.string.pbap_authentication_timeout_message, BluetoothPbapService.getRemoteDeviceName())); mMessageView.setText(getString(R.string.pbap_authentication_timeout_message, mDevice)); mKeyView.setVisibility(View.GONE); mKeyView.clearFocus(); mKeyView.removeTextChangedListener(this); Loading
src/com/android/bluetooth/pbap/BluetoothPbapAuthenticator.java +11 −17 Original line number Diff line number Diff line Loading @@ -32,8 +32,6 @@ package com.android.bluetooth.pbap; import android.os.Handler; import android.os.Message; import android.util.Log; import javax.obex.Authenticator; Loading @@ -44,39 +42,36 @@ import javax.obex.PasswordAuthentication; * authentication procedure. */ public class BluetoothPbapAuthenticator implements Authenticator { private static final String TAG = "BluetoothPbapAuthenticator"; private static final String TAG = "PbapAuthenticator"; private boolean mChallenged; private boolean mAuthCancelled; private String mSessionKey; private PbapStateMachine mPbapStateMachine; private Handler mCallback; public BluetoothPbapAuthenticator(final Handler callback) { mCallback = callback; BluetoothPbapAuthenticator(final PbapStateMachine stateMachine) { mPbapStateMachine = stateMachine; mChallenged = false; mAuthCancelled = false; mSessionKey = null; } public final synchronized void setChallenged(final boolean bool) { final synchronized void setChallenged(final boolean bool) { mChallenged = bool; } public final synchronized void setCancelled(final boolean bool) { final synchronized void setCancelled(final boolean bool) { mAuthCancelled = bool; } public final synchronized void setSessionKey(final String string) { final synchronized void setSessionKey(final String string) { mSessionKey = string; } private void waitUserConfirmation() { Message msg = Message.obtain(mCallback); msg.what = BluetoothPbapService.MSG_OBEX_AUTH_CHALL; msg.sendToTarget(); mPbapStateMachine.sendMessage(PbapStateMachine.CREATE_NOTIFICATION); mPbapStateMachine.sendMessageDelayed(PbapStateMachine.REMOVE_NOTIFICATION, BluetoothPbapService.USER_CONFIRM_TIMEOUT_VALUE); synchronized (this) { while (!mChallenged && !mAuthCancelled) { try { Loading @@ -93,8 +88,7 @@ public class BluetoothPbapAuthenticator implements Authenticator { final boolean isUserIdRequired, final boolean isFullAccess) { waitUserConfirmation(); if (mSessionKey.trim().length() != 0) { PasswordAuthentication pa = new PasswordAuthentication(null, mSessionKey.getBytes()); return pa; return new PasswordAuthentication(null, mSessionKey.getBytes()); } return null; } Loading
src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java +8 −19 Original line number Diff line number Diff line Loading @@ -171,8 +171,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private boolean mVcardSelector = false; private int mMissedCallSize = 0; // record current path the client are browsing private String mCurrentPath = ""; Loading @@ -180,8 +178,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private Context mContext; private BluetoothPbapService mService; private BluetoothPbapVcardManager mVcardManager; private int mOrderBy = ORDER_BY_INDEXED; Loading @@ -204,6 +200,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private AppParamValue mConnAppParamValue; private PbapStateMachine mStateMachine; public static class ContentType { public static final int PHONEBOOK = 1; Loading @@ -216,12 +214,13 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { public static final int COMBINED_CALL_HISTORY = 5; } public BluetoothPbapObexServer(Handler callback, BluetoothPbapService service) { public BluetoothPbapObexServer(Handler callback, Context context, PbapStateMachine stateMachine) { super(); mCallback = callback; mService = service; mContext = service.getApplicationContext(); mContext = context; mVcardManager = new BluetoothPbapVcardManager(mContext); mStateMachine = stateMachine; } @Override Loading Loading @@ -284,9 +283,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { Log.v(TAG, "onConnect(): uuid is ok, will send out " + "MSG_SESSION_ESTABLISHED msg."); } Message msg = Message.obtain(mCallback); msg.what = BluetoothPbapService.MSG_SESSION_ESTABLISHED; msg.sendToTarget(); return ResponseCodes.OBEX_HTTP_OK; } Loading Loading @@ -383,14 +379,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { @Override public void onClose() { if (mCallback != null) { Message msg = Message.obtain(mCallback); msg.what = BluetoothPbapService.MSG_SERVERSESSION_CLOSE; msg.sendToTarget(); if (D) { Log.d(TAG, "onClose(): msg MSG_SERVERSESSION_CLOSE sent out."); } } mStateMachine.sendMessage(PbapStateMachine.DISCONNECT); } @Override Loading Loading @@ -1439,7 +1428,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private byte[] getDatabaseIdentifier() { mDatabaseIdentifierHigh = 0; mDatabaseIdentifierLow = mService.getDbIdentifier(); mDatabaseIdentifierLow = BluetoothPbapUtils.sDbIdentifier.get(); if (mDatabaseIdentifierLow != INVALID_VALUE_PARAMETER && mDatabaseIdentifierHigh != INVALID_VALUE_PARAMETER) { ByteBuffer ret = ByteBuffer.allocate(16); Loading