Loading android/app/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,7 @@ android_app { "-Xep:OperatorPrecedence:ERROR", "-Xep:ReferenceEquality:ERROR", "-Xep:ReturnAtTheEndOfVoidFunction:ERROR", "-Xep:StaticGuardedByInstance:ERROR", "-Xep:StringCaseLocaleUsage:ERROR", "-Xep:StringCharset:ERROR", "-Xep:SynchronizeOnNonFinalField:ERROR", Loading android/app/src/com/android/bluetooth/map/BluetoothMapService.java +27 −35 Original line number Diff line number Diff line Loading @@ -46,7 +46,6 @@ import android.os.RemoteException; import android.os.SystemProperties; import android.sysprop.BluetoothProperties; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; Loading Loading @@ -126,10 +125,9 @@ public class BluetoothMapService extends ProfileService { new HashMap<BluetoothMapAccountItem, BluetoothMapMasInstance>(1); // The remote connected device - protect access private static BluetoothDevice sRemoteDevice = null; private BluetoothDevice mRemoteDevice = null; private List<BluetoothMapAccountItem> mEnabledAccounts = null; private static String sRemoteDeviceName = null; private int mState = BluetoothMap.STATE_DISCONNECTED; private BluetoothMapAppObserver mAppObserver = null; Loading Loading @@ -184,7 +182,7 @@ public class BluetoothMapService extends ProfileService { mWakeLock = null; } sRemoteDevice = null; mRemoteDevice = null; // no need to invalidate cache here because setState did it above if (mSessionStatusHandler == null) { Loading Loading @@ -240,7 +238,7 @@ public class BluetoothMapService extends ProfileService { if (mBluetoothMnsObexClient == null) { mBluetoothMnsObexClient = new BluetoothMnsObexClient(sRemoteDevice, mMnsRecord, mSessionStatusHandler); new BluetoothMnsObexClient(mRemoteDevice, mMnsRecord, mSessionStatusHandler); } boolean connected = false; Loading Loading @@ -328,7 +326,7 @@ public class BluetoothMapService extends ProfileService { if (lastMasInst) { setState(BluetoothMap.STATE_DISCONNECTED); mPermission = BluetoothDevice.ACCESS_UNKNOWN; sRemoteDevice = null; mRemoteDevice = null; // no need to invalidate cache here because setState did it above if (mAccountChanged) { updateMasInstances(UPDATE_MAS_INSTANCES_ACCOUNT_DISCONNECT); Loading Loading @@ -377,7 +375,7 @@ public class BluetoothMapService extends ProfileService { SystemProperties.get( Utils.PAIRING_UI_PROPERTY, getString(R.string.pairing_ui_package))); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, sRemoteDevice); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice); intent.putExtra( BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS); Loading Loading @@ -433,9 +431,9 @@ public class BluetoothMapService extends ProfileService { } break; case MSG_MNS_SDP_SEARCH: if (sRemoteDevice != null) { if (mRemoteDevice != null) { Log.d(TAG, "MNS SDP Initiate Search .."); sRemoteDevice.sdpSearch(BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mRemoteDevice.sdpSearch(BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); } else { Log.w(TAG, "remoteDevice info not available"); ContentProfileErrorReportUtils.report( Loading Loading @@ -479,7 +477,7 @@ public class BluetoothMapService extends ProfileService { } private void onConnectHandler(int masId) { if (mIsWaitingAuthorization || sRemoteDevice == null || mSdpSearchInitiated) { if (mIsWaitingAuthorization || mRemoteDevice == null || mSdpSearchInitiated) { return; } BluetoothMapMasInstance masInst = mMasInstances.get(masId); Loading @@ -490,7 +488,7 @@ public class BluetoothMapService extends ProfileService { Log.v( TAG, "incoming connection accepted from: " + sRemoteDeviceName + mRemoteDevice + " automatically as trusted device"); if (mBluetoothMnsObexClient != null && masInst != null) { masInst.startObexServerSession(mBluetoothMnsObexClient); Loading Loading @@ -520,7 +518,7 @@ public class BluetoothMapService extends ProfileService { } public BluetoothDevice getRemoteDevice() { return sRemoteDevice; return mRemoteDevice; } private void setState(int state) { Loading @@ -533,13 +531,13 @@ public class BluetoothMapService extends ProfileService { int prevState = mState; mState = state; mAdapterService.updateProfileConnectionAdapterProperties( sRemoteDevice, BluetoothProfile.MAP, mState, prevState); mRemoteDevice, BluetoothProfile.MAP, mState, prevState); BluetoothMap.invalidateBluetoothGetConnectionStateCache(); Intent intent = new Intent(BluetoothMap.ACTION_CONNECTION_STATE_CHANGED); intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState); intent.putExtra(BluetoothProfile.EXTRA_STATE, mState); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, sRemoteDevice); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice); sendBroadcast(intent, BLUETOOTH_CONNECT, Utils.getTempBroadcastOptions().toBundle()); } } Loading Loading @@ -571,8 +569,8 @@ public class BluetoothMapService extends ProfileService { List<BluetoothDevice> getConnectedDevices() { List<BluetoothDevice> devices = new ArrayList<>(); synchronized (this) { if (mState == BluetoothMap.STATE_CONNECTED && sRemoteDevice != null) { devices.add(sRemoteDevice); if (mState == BluetoothMap.STATE_CONNECTED && mRemoteDevice != null) { devices.add(mRemoteDevice); } } return devices; Loading Loading @@ -919,18 +917,13 @@ public class BluetoothMapService extends ProfileService { // As this can be called from each MasInstance, we need to lock access to member variables synchronized (this) { if (sRemoteDevice == null) { sRemoteDevice = remoteDevice; if (mRemoteDevice == null) { mRemoteDevice = remoteDevice; if (getState() == BluetoothMap.STATE_CONNECTED) { BluetoothMap.invalidateBluetoothGetConnectionStateCache(); } sRemoteDeviceName = Utils.getName(sRemoteDevice); // In case getRemoteName failed and return null if (TextUtils.isEmpty(sRemoteDeviceName)) { sRemoteDeviceName = getString(R.string.defaultname); } mPermission = mAdapterService.getMessageAccessPermission(sRemoteDevice); mPermission = mAdapterService.getMessageAccessPermission(mRemoteDevice); if (mPermission == BluetoothDevice.ACCESS_UNKNOWN) { sendIntent = true; mIsWaitingAuthorization = true; Loading @@ -939,10 +932,10 @@ public class BluetoothMapService extends ProfileService { cancelConnection = true; } else if (mPermission == BluetoothDevice.ACCESS_ALLOWED) { mAdapterService.sdpSearch( sRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mSdpSearchInitiated = true; } } else if (!sRemoteDevice.equals(remoteDevice)) { } else if (!mRemoteDevice.equals(remoteDevice)) { Log.w( TAG, "Unexpected connection from a second Remote Device received. name: " Loading @@ -967,7 +960,7 @@ public class BluetoothMapService extends ProfileService { intent.putExtra( BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, sRemoteDevice); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice); sendOrderedBroadcast( intent, BLUETOOTH_CONNECT, Loading @@ -978,7 +971,7 @@ public class BluetoothMapService extends ProfileService { null, null); Log.v(TAG, "waiting for authorization for connection from: " + sRemoteDeviceName); Log.v(TAG, "Waiting for authorization for connection from: " + mRemoteDevice); // Queue USER_TIMEOUT to disconnect MAP OBEX session. If user doesn't // accept or reject authorization request } else if (cancelConnection) { Loading Loading @@ -1146,13 +1139,13 @@ public class BluetoothMapService extends ProfileService { mPermission = BluetoothDevice.ACCESS_ALLOWED; if (intent.getBooleanExtra(BluetoothDevice.EXTRA_ALWAYS_ALLOWED, false)) { boolean result = sRemoteDevice.setMessageAccessPermission( mRemoteDevice.setMessageAccessPermission( BluetoothDevice.ACCESS_ALLOWED); Log.d(TAG, "setMessageAccessPermission(ACCESS_ALLOWED) result=" + result); } mAdapterService.sdpSearch( sRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mSdpSearchInitiated = true; } else { // Auth. declined by user, serverSession should not be running, but Loading @@ -1160,7 +1153,7 @@ public class BluetoothMapService extends ProfileService { mPermission = BluetoothDevice.ACCESS_REJECTED; if (intent.getBooleanExtra(BluetoothDevice.EXTRA_ALWAYS_ALLOWED, false)) { boolean result = sRemoteDevice.setMessageAccessPermission( mRemoteDevice.setMessageAccessPermission( BluetoothDevice.ACCESS_REJECTED); Log.d(TAG, "setMessageAccessPermission(ACCESS_REJECTED) result=" + result); } Loading Loading @@ -1194,7 +1187,7 @@ public class BluetoothMapService extends ProfileService { if (!mIsWaitingAuthorization) { return; } if (sRemoteDevice == null || device == null) { if (mRemoteDevice == null || device == null) { Log.e(TAG, "Unexpected error!"); ContentProfileErrorReportUtils.report( BluetoothProfile.MAP, Loading @@ -1206,7 +1199,7 @@ public class BluetoothMapService extends ProfileService { Log.v(TAG, "ACL disconnected for " + device); if (sRemoteDevice.equals(device)) { if (mRemoteDevice.equals(device)) { // Send any pending timeout now, since ACL got disconnected mSessionStatusHandler.removeMessages(USER_TIMEOUT); mSessionStatusHandler.obtainMessage(USER_TIMEOUT).sendToTarget(); Loading Loading @@ -1466,8 +1459,7 @@ public class BluetoothMapService extends ProfileService { @Override public void dump(StringBuilder sb) { super.dump(sb); println(sb, "mRemoteDevice: " + sRemoteDevice); println(sb, "sRemoteDeviceName: " + sRemoteDeviceName); println(sb, "mRemoteDevice: " + mRemoteDevice); println(sb, "mState: " + mState); println(sb, "mAppObserver: " + mAppObserver); println(sb, "mIsWaitingAuthorization: " + mIsWaitingAuthorization); Loading Loading
android/app/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,7 @@ android_app { "-Xep:OperatorPrecedence:ERROR", "-Xep:ReferenceEquality:ERROR", "-Xep:ReturnAtTheEndOfVoidFunction:ERROR", "-Xep:StaticGuardedByInstance:ERROR", "-Xep:StringCaseLocaleUsage:ERROR", "-Xep:StringCharset:ERROR", "-Xep:SynchronizeOnNonFinalField:ERROR", Loading
android/app/src/com/android/bluetooth/map/BluetoothMapService.java +27 −35 Original line number Diff line number Diff line Loading @@ -46,7 +46,6 @@ import android.os.RemoteException; import android.os.SystemProperties; import android.sysprop.BluetoothProperties; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; Loading Loading @@ -126,10 +125,9 @@ public class BluetoothMapService extends ProfileService { new HashMap<BluetoothMapAccountItem, BluetoothMapMasInstance>(1); // The remote connected device - protect access private static BluetoothDevice sRemoteDevice = null; private BluetoothDevice mRemoteDevice = null; private List<BluetoothMapAccountItem> mEnabledAccounts = null; private static String sRemoteDeviceName = null; private int mState = BluetoothMap.STATE_DISCONNECTED; private BluetoothMapAppObserver mAppObserver = null; Loading Loading @@ -184,7 +182,7 @@ public class BluetoothMapService extends ProfileService { mWakeLock = null; } sRemoteDevice = null; mRemoteDevice = null; // no need to invalidate cache here because setState did it above if (mSessionStatusHandler == null) { Loading Loading @@ -240,7 +238,7 @@ public class BluetoothMapService extends ProfileService { if (mBluetoothMnsObexClient == null) { mBluetoothMnsObexClient = new BluetoothMnsObexClient(sRemoteDevice, mMnsRecord, mSessionStatusHandler); new BluetoothMnsObexClient(mRemoteDevice, mMnsRecord, mSessionStatusHandler); } boolean connected = false; Loading Loading @@ -328,7 +326,7 @@ public class BluetoothMapService extends ProfileService { if (lastMasInst) { setState(BluetoothMap.STATE_DISCONNECTED); mPermission = BluetoothDevice.ACCESS_UNKNOWN; sRemoteDevice = null; mRemoteDevice = null; // no need to invalidate cache here because setState did it above if (mAccountChanged) { updateMasInstances(UPDATE_MAS_INSTANCES_ACCOUNT_DISCONNECT); Loading Loading @@ -377,7 +375,7 @@ public class BluetoothMapService extends ProfileService { SystemProperties.get( Utils.PAIRING_UI_PROPERTY, getString(R.string.pairing_ui_package))); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, sRemoteDevice); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice); intent.putExtra( BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS); Loading Loading @@ -433,9 +431,9 @@ public class BluetoothMapService extends ProfileService { } break; case MSG_MNS_SDP_SEARCH: if (sRemoteDevice != null) { if (mRemoteDevice != null) { Log.d(TAG, "MNS SDP Initiate Search .."); sRemoteDevice.sdpSearch(BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mRemoteDevice.sdpSearch(BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); } else { Log.w(TAG, "remoteDevice info not available"); ContentProfileErrorReportUtils.report( Loading Loading @@ -479,7 +477,7 @@ public class BluetoothMapService extends ProfileService { } private void onConnectHandler(int masId) { if (mIsWaitingAuthorization || sRemoteDevice == null || mSdpSearchInitiated) { if (mIsWaitingAuthorization || mRemoteDevice == null || mSdpSearchInitiated) { return; } BluetoothMapMasInstance masInst = mMasInstances.get(masId); Loading @@ -490,7 +488,7 @@ public class BluetoothMapService extends ProfileService { Log.v( TAG, "incoming connection accepted from: " + sRemoteDeviceName + mRemoteDevice + " automatically as trusted device"); if (mBluetoothMnsObexClient != null && masInst != null) { masInst.startObexServerSession(mBluetoothMnsObexClient); Loading Loading @@ -520,7 +518,7 @@ public class BluetoothMapService extends ProfileService { } public BluetoothDevice getRemoteDevice() { return sRemoteDevice; return mRemoteDevice; } private void setState(int state) { Loading @@ -533,13 +531,13 @@ public class BluetoothMapService extends ProfileService { int prevState = mState; mState = state; mAdapterService.updateProfileConnectionAdapterProperties( sRemoteDevice, BluetoothProfile.MAP, mState, prevState); mRemoteDevice, BluetoothProfile.MAP, mState, prevState); BluetoothMap.invalidateBluetoothGetConnectionStateCache(); Intent intent = new Intent(BluetoothMap.ACTION_CONNECTION_STATE_CHANGED); intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState); intent.putExtra(BluetoothProfile.EXTRA_STATE, mState); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, sRemoteDevice); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice); sendBroadcast(intent, BLUETOOTH_CONNECT, Utils.getTempBroadcastOptions().toBundle()); } } Loading Loading @@ -571,8 +569,8 @@ public class BluetoothMapService extends ProfileService { List<BluetoothDevice> getConnectedDevices() { List<BluetoothDevice> devices = new ArrayList<>(); synchronized (this) { if (mState == BluetoothMap.STATE_CONNECTED && sRemoteDevice != null) { devices.add(sRemoteDevice); if (mState == BluetoothMap.STATE_CONNECTED && mRemoteDevice != null) { devices.add(mRemoteDevice); } } return devices; Loading Loading @@ -919,18 +917,13 @@ public class BluetoothMapService extends ProfileService { // As this can be called from each MasInstance, we need to lock access to member variables synchronized (this) { if (sRemoteDevice == null) { sRemoteDevice = remoteDevice; if (mRemoteDevice == null) { mRemoteDevice = remoteDevice; if (getState() == BluetoothMap.STATE_CONNECTED) { BluetoothMap.invalidateBluetoothGetConnectionStateCache(); } sRemoteDeviceName = Utils.getName(sRemoteDevice); // In case getRemoteName failed and return null if (TextUtils.isEmpty(sRemoteDeviceName)) { sRemoteDeviceName = getString(R.string.defaultname); } mPermission = mAdapterService.getMessageAccessPermission(sRemoteDevice); mPermission = mAdapterService.getMessageAccessPermission(mRemoteDevice); if (mPermission == BluetoothDevice.ACCESS_UNKNOWN) { sendIntent = true; mIsWaitingAuthorization = true; Loading @@ -939,10 +932,10 @@ public class BluetoothMapService extends ProfileService { cancelConnection = true; } else if (mPermission == BluetoothDevice.ACCESS_ALLOWED) { mAdapterService.sdpSearch( sRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mSdpSearchInitiated = true; } } else if (!sRemoteDevice.equals(remoteDevice)) { } else if (!mRemoteDevice.equals(remoteDevice)) { Log.w( TAG, "Unexpected connection from a second Remote Device received. name: " Loading @@ -967,7 +960,7 @@ public class BluetoothMapService extends ProfileService { intent.putExtra( BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, sRemoteDevice); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mRemoteDevice); sendOrderedBroadcast( intent, BLUETOOTH_CONNECT, Loading @@ -978,7 +971,7 @@ public class BluetoothMapService extends ProfileService { null, null); Log.v(TAG, "waiting for authorization for connection from: " + sRemoteDeviceName); Log.v(TAG, "Waiting for authorization for connection from: " + mRemoteDevice); // Queue USER_TIMEOUT to disconnect MAP OBEX session. If user doesn't // accept or reject authorization request } else if (cancelConnection) { Loading Loading @@ -1146,13 +1139,13 @@ public class BluetoothMapService extends ProfileService { mPermission = BluetoothDevice.ACCESS_ALLOWED; if (intent.getBooleanExtra(BluetoothDevice.EXTRA_ALWAYS_ALLOWED, false)) { boolean result = sRemoteDevice.setMessageAccessPermission( mRemoteDevice.setMessageAccessPermission( BluetoothDevice.ACCESS_ALLOWED); Log.d(TAG, "setMessageAccessPermission(ACCESS_ALLOWED) result=" + result); } mAdapterService.sdpSearch( sRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mRemoteDevice, BluetoothMnsObexClient.BLUETOOTH_UUID_OBEX_MNS); mSdpSearchInitiated = true; } else { // Auth. declined by user, serverSession should not be running, but Loading @@ -1160,7 +1153,7 @@ public class BluetoothMapService extends ProfileService { mPermission = BluetoothDevice.ACCESS_REJECTED; if (intent.getBooleanExtra(BluetoothDevice.EXTRA_ALWAYS_ALLOWED, false)) { boolean result = sRemoteDevice.setMessageAccessPermission( mRemoteDevice.setMessageAccessPermission( BluetoothDevice.ACCESS_REJECTED); Log.d(TAG, "setMessageAccessPermission(ACCESS_REJECTED) result=" + result); } Loading Loading @@ -1194,7 +1187,7 @@ public class BluetoothMapService extends ProfileService { if (!mIsWaitingAuthorization) { return; } if (sRemoteDevice == null || device == null) { if (mRemoteDevice == null || device == null) { Log.e(TAG, "Unexpected error!"); ContentProfileErrorReportUtils.report( BluetoothProfile.MAP, Loading @@ -1206,7 +1199,7 @@ public class BluetoothMapService extends ProfileService { Log.v(TAG, "ACL disconnected for " + device); if (sRemoteDevice.equals(device)) { if (mRemoteDevice.equals(device)) { // Send any pending timeout now, since ACL got disconnected mSessionStatusHandler.removeMessages(USER_TIMEOUT); mSessionStatusHandler.obtainMessage(USER_TIMEOUT).sendToTarget(); Loading Loading @@ -1466,8 +1459,7 @@ public class BluetoothMapService extends ProfileService { @Override public void dump(StringBuilder sb) { super.dump(sb); println(sb, "mRemoteDevice: " + sRemoteDevice); println(sb, "sRemoteDeviceName: " + sRemoteDeviceName); println(sb, "mRemoteDevice: " + mRemoteDevice); println(sb, "mState: " + mState); println(sb, "mAppObserver: " + mAppObserver); println(sb, "mIsWaitingAuthorization: " + mIsWaitingAuthorization); Loading