Loading android/app/AndroidManifest.xml +109 −102 Original line number Diff line number Diff line Loading @@ -92,6 +92,15 @@ android:defaultToDeviceProtectedStorage="true" android:memtagMode="async"> <service android:process="@string/process" android:name="com.android.bluetooth.btservice.AdapterService" android:exported="true" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE"> <intent-filter> <action android:name="android.bluetooth.IBluetooth"/> </intent-filter> </service> <!-- Advanced Audio Distribution Profile (A2DP) source Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.a2dp.A2dpService" Loading Loading @@ -336,88 +345,15 @@ </intent-filter> </service> <!-- Personal Area Network (PAN) Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pan.PanService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPan"/> </intent-filter> </service> <!-- Phonebook Access Profile (PBAP) server Profile Service and owned Activiie --> <service android:process="@string/process" android:permission="android.permission.BLUETOOTH_PRIVILEGED" android:name="com.android.bluetooth.pbap.BluetoothPbapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbap"/> </intent-filter> </service> <activity android:name="com.android.bluetooth.pbap.BluetoothPbapActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="false"> </activity> <!-- Phonebook Access Profile (PBAP) client Profile Service and owned Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.PbapClientService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbapClient"/> </intent-filter> </service> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.AuthenticationService" android:enabled="false" android:exported="true"> <intent-filter> <action android:name="android.accounts.AccountAuthenticator"/> </intent-filter> <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"/> </service> <!-- SIM Access Profile (SAP) server Profile Service --> <!-- Object Push Profile (OPP) Profile Service and owned Receives, Providers and Activiies --> <service android:process="@string/process" android:name="com.android.bluetooth.sap.SapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothSap"/> </intent-filter> </service> <!-- Telephony Bearer Service (TBS) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.tbs.TbsService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothLeCallControl" /> </intent-filter> </service> <!-- Volume Control Profile (VCP) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.vc.VolumeControlService" android:name="com.android.bluetooth.opp.BluetoothOppService" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothVolumeControl" /> </intent-filter> </service> <provider android:name=".opp.BluetoothOppProvider" android:exported="true"/> <provider android:name="com.android.bluetooth.opp.BluetoothOppProvider" android:authorities="com.android.bluetooth.opp" android:enabled="false" android:exported="true" android:process="@string/process"> <path-permission android:pathPrefix="/btopp" Loading @@ -426,26 +362,15 @@ <provider android:name="com.android.bluetooth.opp.BluetoothOppFileProvider" android:authorities="com.android.bluetooth.opp.fileprovider" android:grantUriPermissions="true" android:enabled="false" android:exported="false"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> </provider> <service android:process="@string/process" android:name="com.android.bluetooth.btservice.AdapterService" android:exported="true" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE"> <intent-filter> <action android:name="android.bluetooth.IBluetooth"/> </intent-filter> </service> <service android:process="@string/process" android:name="com.android.bluetooth.opp.BluetoothOppService" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" android:enabled="@bool/profile_supported_opp"/> <receiver android:process="@string/process" android:exported="true" android:name="com.android.bluetooth.opp.BluetoothOppReceiver" android:enabled="@bool/profile_supported_opp"> android:exported="true" android:enabled="false"> <intent-filter> <action android:name="android.btopp.intent.action.OPEN_RECEIVED_FILES"/> </intent-filter> Loading @@ -453,7 +378,8 @@ <receiver android:process="@string/process" android:name="com.android.bluetooth.opp.BluetoothOppHandoverReceiver" android:permission="com.android.permission.ALLOWLIST_BLUETOOTH_DEVICE" android:exported="true"> android:exported="true" android:enabled="false"> <intent-filter> <action android:name="android.btopp.intent.action.ACCEPTLIST_DEVICE"/> <action android:name="android.btopp.intent.action.STOP_HANDOVER_TRANSFER"/> Loading @@ -473,7 +399,7 @@ android:process="@string/process" android:theme="@android:style/Theme.Material.Light.Dialog" android:label="@string/bt_share_picker_label" android:enabled="@bool/profile_supported_opp" android:enabled="false" android:exported="true"> <intent-filter> <action android:name="android.intent.action.SEND"/> Loading Loading @@ -515,37 +441,38 @@ android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppBtErrorActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog"> android:theme="@style/dialog" android:enabled="false">> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppBtEnablingActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppIncomingFileConfirmActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppTransferActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppTransferHistory" android:process="@string/process" android:label="" android:excludeFromRecents="true" android:configChanges="orientation|keyboardHidden" android:enabled="@bool/profile_supported_opp" android:enabled="false" android:theme="@android:style/Theme.DeviceDefault.Settings" android:exported="true"> <intent-filter> Loading @@ -553,5 +480,85 @@ <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> <!-- Personal Area Network (PAN) Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pan.PanService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPan"/> </intent-filter> </service> <!-- Phonebook Access Profile (PBAP) server Profile Service and owned Activiie --> <service android:process="@string/process" android:permission="android.permission.BLUETOOTH_PRIVILEGED" android:name="com.android.bluetooth.pbap.BluetoothPbapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbap"/> </intent-filter> </service> <activity android:name="com.android.bluetooth.pbap.BluetoothPbapActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="false"> </activity> <!-- Phonebook Access Profile (PBAP) client Profile Service and owned Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.PbapClientService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbapClient"/> </intent-filter> </service> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.AuthenticationService" android:enabled="false" android:exported="true"> <intent-filter> <action android:name="android.accounts.AccountAuthenticator"/> </intent-filter> <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"/> </service> <!-- SIM Access Profile (SAP) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.sap.SapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothSap"/> </intent-filter> </service> <!-- Telephony Bearer Service (TBS) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.tbs.TbsService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothLeCallControl" /> </intent-filter> </service> <!-- Volume Control Profile (VCP) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.vc.VolumeControlService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothVolumeControl" /> </intent-filter> </service> </application> </manifest> android/app/res/values/config.xml +0 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ limitations under the License. --> <resources> <bool name="profile_supported_opp">true</bool> <bool name="pbap_include_photos_in_vcard">true</bool> <bool name="pbap_use_profile_for_owner_vcard">true</bool> Loading android/app/src/com/android/bluetooth/opp/BluetoothOppService.java +68 −7 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevicePicker; import android.bluetooth.BluetoothSocket; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; Loading @@ -52,6 +53,7 @@ import android.os.Binder; import android.os.Handler; import android.os.Message; import android.os.Process; import android.sysprop.BluetoothProperties; import android.util.Log; import com.android.bluetooth.BluetoothObexTransport; Loading @@ -78,6 +80,34 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti private static final boolean D = Constants.DEBUG; private static final boolean V = Constants.VERBOSE; /** * Owned providers and activities */ private static final String OPP_PROVIDER = BluetoothOppProvider.class.getCanonicalName(); private static final String OPP_FILE_PROVIDER = BluetoothOppFileProvider.class.getCanonicalName(); private static final String LAUNCHER_ACTIVITY = BluetoothOppLauncherActivity.class.getCanonicalName(); private static final String BT_ENABLE_ACTIVITY = BluetoothOppBtEnableActivity.class.getCanonicalName(); private static final String BT_ERROR_ACTIVITY = BluetoothOppBtErrorActivity.class.getCanonicalName(); private static final String BT_ENABLING_ACTIVITY = BluetoothOppBtEnablingActivity.class.getCanonicalName(); private static final String INCOMING_FILE_CONFIRM_ACTIVITY = BluetoothOppIncomingFileConfirmActivity.class.getCanonicalName(); private static final String TRANSFER_ACTIVITY = BluetoothOppTransferActivity.class.getCanonicalName(); private static final String TRANSFER_HISTORY_ACTIVITY = BluetoothOppTransferHistory.class.getCanonicalName(); // Normally we would dynamically define and create these but they need to be manifest receivers // because they rely on explicit intents. Explicit intents don't work with dynamic receivers. private static final String OPP_RECEIVER = BluetoothOppReceiver.class.getCanonicalName(); private static final String OPP_HANDOFF_RECEIVER = BluetoothOppHandoverReceiver.class.getCanonicalName(); private static final byte[] SUPPORTED_OPP_FORMAT = { 0x01 /* vCard 2.1 */, 0x02 /* vCard 3.0 */, Loading Loading @@ -174,6 +204,10 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti */ private BluetoothOppObexServerSession mServerSession; public static boolean isEnabled() { return BluetoothProperties.isProfileOppEnabled().orElse(false); } @Override protected IProfileServiceBinder initBinder() { return new OppBinder(this); Loading @@ -197,13 +231,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti mShares = new ArrayList(); mBatches = new ArrayList(); mBatchId = 1; final ContentResolver contentResolver = getContentResolver(); new Thread("trimDatabase") { @Override public void run() { trimDatabase(contentResolver); } }.start(); IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(mBluetoothReceiver, filter); Loading @@ -223,6 +250,27 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti if (V) { Log.v(TAG, "start()"); } setComponentAvailable(OPP_PROVIDER, true); setComponentAvailable(OPP_FILE_PROVIDER, true); setComponentAvailable(LAUNCHER_ACTIVITY, true); setComponentAvailable(BT_ENABLE_ACTIVITY, true); setComponentAvailable(BT_ERROR_ACTIVITY, true); setComponentAvailable(BT_ENABLING_ACTIVITY, true); setComponentAvailable(INCOMING_FILE_CONFIRM_ACTIVITY, true); setComponentAvailable(TRANSFER_ACTIVITY, true); setComponentAvailable(TRANSFER_HISTORY_ACTIVITY, true); setComponentAvailable(OPP_RECEIVER, true); setComponentAvailable(OPP_HANDOFF_RECEIVER, true); final ContentResolver contentResolver = getContentResolver(); new Thread("trimDatabase") { @Override public void run() { trimDatabase(contentResolver); } }.start(); mAdapterService = AdapterService.getAdapterService(); mObserver = new BluetoothShareContentObserver(); getContentResolver().registerContentObserver(BluetoothShare.CONTENT_URI, true, mObserver); Loading @@ -248,6 +296,19 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti AdapterService.ACTIVITY_ATTRIBUTION_NO_ACTIVE_DEVICE_ADDRESS); setBluetoothOppService(null); mHandler.sendMessage(mHandler.obtainMessage(STOP_LISTENER)); setComponentAvailable(OPP_PROVIDER, false); setComponentAvailable(OPP_FILE_PROVIDER, false); setComponentAvailable(LAUNCHER_ACTIVITY, false); setComponentAvailable(BT_ENABLE_ACTIVITY, false); setComponentAvailable(BT_ERROR_ACTIVITY, false); setComponentAvailable(BT_ENABLING_ACTIVITY, false); setComponentAvailable(INCOMING_FILE_CONFIRM_ACTIVITY, false); setComponentAvailable(TRANSFER_ACTIVITY, false); setComponentAvailable(TRANSFER_HISTORY_ACTIVITY, false); setComponentAvailable(OPP_RECEIVER, false); setComponentAvailable(OPP_HANDOFF_RECEIVER, false); return true; } Loading android/app/src/com/android/bluetooth/opp/Constants.java +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,10 @@ public class Constants { /** Tag used for debugging/logging */ public static final String TAG = "BluetoothOpp"; /** the permission required for others to send us handover broadcasts */ static final String PERMISSION_ALLOWLIST_BLUETOOTH_DEVICE = "com.android.permission.ALLOWLIST_BLUETOOTH_DEVICE"; /** * The intent that gets sent when the service must wake up for a retry * Note: Only retry Outbound transfers Loading android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceTest.java +2 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static org.mockito.Mockito.doReturn; import android.bluetooth.BluetoothAdapter; import android.content.Context; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import androidx.test.rule.ServiceTestRule; import androidx.test.runner.AndroidJUnit4; Loading @@ -45,7 +44,6 @@ import org.mockito.MockitoAnnotations; public class BluetoothOppServiceTest { private BluetoothOppService mService = null; private BluetoothAdapter mAdapter = null; private Context mTargetContext; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); Loading @@ -53,9 +51,8 @@ public class BluetoothOppServiceTest { @Before public void setUp() throws Exception { mTargetContext = InstrumentationRegistry.getTargetContext(); Assume.assumeTrue("Ignore test when BluetoothOppService is not enabled", mTargetContext.getResources().getBoolean(R.bool.profile_supported_opp)); BluetoothOppService.isEnabled()); MockitoAnnotations.initMocks(this); TestUtils.setAdapterService(mAdapterService); doReturn(true, false).when(mAdapterService).isStartedProfile(anyString()); Loading @@ -69,7 +66,7 @@ public class BluetoothOppServiceTest { @After public void tearDown() throws Exception { if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_opp)) { if (!BluetoothOppService.isEnabled()) { return; } TestUtils.stopService(mServiceRule, BluetoothOppService.class); Loading Loading
android/app/AndroidManifest.xml +109 −102 Original line number Diff line number Diff line Loading @@ -92,6 +92,15 @@ android:defaultToDeviceProtectedStorage="true" android:memtagMode="async"> <service android:process="@string/process" android:name="com.android.bluetooth.btservice.AdapterService" android:exported="true" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE"> <intent-filter> <action android:name="android.bluetooth.IBluetooth"/> </intent-filter> </service> <!-- Advanced Audio Distribution Profile (A2DP) source Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.a2dp.A2dpService" Loading Loading @@ -336,88 +345,15 @@ </intent-filter> </service> <!-- Personal Area Network (PAN) Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pan.PanService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPan"/> </intent-filter> </service> <!-- Phonebook Access Profile (PBAP) server Profile Service and owned Activiie --> <service android:process="@string/process" android:permission="android.permission.BLUETOOTH_PRIVILEGED" android:name="com.android.bluetooth.pbap.BluetoothPbapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbap"/> </intent-filter> </service> <activity android:name="com.android.bluetooth.pbap.BluetoothPbapActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="false"> </activity> <!-- Phonebook Access Profile (PBAP) client Profile Service and owned Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.PbapClientService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbapClient"/> </intent-filter> </service> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.AuthenticationService" android:enabled="false" android:exported="true"> <intent-filter> <action android:name="android.accounts.AccountAuthenticator"/> </intent-filter> <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"/> </service> <!-- SIM Access Profile (SAP) server Profile Service --> <!-- Object Push Profile (OPP) Profile Service and owned Receives, Providers and Activiies --> <service android:process="@string/process" android:name="com.android.bluetooth.sap.SapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothSap"/> </intent-filter> </service> <!-- Telephony Bearer Service (TBS) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.tbs.TbsService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothLeCallControl" /> </intent-filter> </service> <!-- Volume Control Profile (VCP) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.vc.VolumeControlService" android:name="com.android.bluetooth.opp.BluetoothOppService" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothVolumeControl" /> </intent-filter> </service> <provider android:name=".opp.BluetoothOppProvider" android:exported="true"/> <provider android:name="com.android.bluetooth.opp.BluetoothOppProvider" android:authorities="com.android.bluetooth.opp" android:enabled="false" android:exported="true" android:process="@string/process"> <path-permission android:pathPrefix="/btopp" Loading @@ -426,26 +362,15 @@ <provider android:name="com.android.bluetooth.opp.BluetoothOppFileProvider" android:authorities="com.android.bluetooth.opp.fileprovider" android:grantUriPermissions="true" android:enabled="false" android:exported="false"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> </provider> <service android:process="@string/process" android:name="com.android.bluetooth.btservice.AdapterService" android:exported="true" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE"> <intent-filter> <action android:name="android.bluetooth.IBluetooth"/> </intent-filter> </service> <service android:process="@string/process" android:name="com.android.bluetooth.opp.BluetoothOppService" android:permission="android.permission.ACCESS_BLUETOOTH_SHARE" android:enabled="@bool/profile_supported_opp"/> <receiver android:process="@string/process" android:exported="true" android:name="com.android.bluetooth.opp.BluetoothOppReceiver" android:enabled="@bool/profile_supported_opp"> android:exported="true" android:enabled="false"> <intent-filter> <action android:name="android.btopp.intent.action.OPEN_RECEIVED_FILES"/> </intent-filter> Loading @@ -453,7 +378,8 @@ <receiver android:process="@string/process" android:name="com.android.bluetooth.opp.BluetoothOppHandoverReceiver" android:permission="com.android.permission.ALLOWLIST_BLUETOOTH_DEVICE" android:exported="true"> android:exported="true" android:enabled="false"> <intent-filter> <action android:name="android.btopp.intent.action.ACCEPTLIST_DEVICE"/> <action android:name="android.btopp.intent.action.STOP_HANDOVER_TRANSFER"/> Loading @@ -473,7 +399,7 @@ android:process="@string/process" android:theme="@android:style/Theme.Material.Light.Dialog" android:label="@string/bt_share_picker_label" android:enabled="@bool/profile_supported_opp" android:enabled="false" android:exported="true"> <intent-filter> <action android:name="android.intent.action.SEND"/> Loading Loading @@ -515,37 +441,38 @@ android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppBtErrorActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog"> android:theme="@style/dialog" android:enabled="false">> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppBtEnablingActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppIncomingFileConfirmActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppTransferActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="@bool/profile_supported_opp"> android:enabled="false"> </activity> <activity android:name="com.android.bluetooth.opp.BluetoothOppTransferHistory" android:process="@string/process" android:label="" android:excludeFromRecents="true" android:configChanges="orientation|keyboardHidden" android:enabled="@bool/profile_supported_opp" android:enabled="false" android:theme="@android:style/Theme.DeviceDefault.Settings" android:exported="true"> <intent-filter> Loading @@ -553,5 +480,85 @@ <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> <!-- Personal Area Network (PAN) Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pan.PanService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPan"/> </intent-filter> </service> <!-- Phonebook Access Profile (PBAP) server Profile Service and owned Activiie --> <service android:process="@string/process" android:permission="android.permission.BLUETOOTH_PRIVILEGED" android:name="com.android.bluetooth.pbap.BluetoothPbapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbap"/> </intent-filter> </service> <activity android:name="com.android.bluetooth.pbap.BluetoothPbapActivity" android:process="@string/process" android:excludeFromRecents="true" android:theme="@style/dialog" android:enabled="false"> </activity> <!-- Phonebook Access Profile (PBAP) client Profile Service and owned Service --> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.PbapClientService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothPbapClient"/> </intent-filter> </service> <service android:process="@string/process" android:name="com.android.bluetooth.pbapclient.AuthenticationService" android:enabled="false" android:exported="true"> <intent-filter> <action android:name="android.accounts.AccountAuthenticator"/> </intent-filter> <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"/> </service> <!-- SIM Access Profile (SAP) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.sap.SapService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothSap"/> </intent-filter> </service> <!-- Telephony Bearer Service (TBS) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.tbs.TbsService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothLeCallControl" /> </intent-filter> </service> <!-- Volume Control Profile (VCP) server Profile Service --> <service android:process="@string/process" android:name="com.android.bluetooth.vc.VolumeControlService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.bluetooth.IBluetoothVolumeControl" /> </intent-filter> </service> </application> </manifest>
android/app/res/values/config.xml +0 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ limitations under the License. --> <resources> <bool name="profile_supported_opp">true</bool> <bool name="pbap_include_photos_in_vcard">true</bool> <bool name="pbap_use_profile_for_owner_vcard">true</bool> Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppService.java +68 −7 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevicePicker; import android.bluetooth.BluetoothSocket; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; Loading @@ -52,6 +53,7 @@ import android.os.Binder; import android.os.Handler; import android.os.Message; import android.os.Process; import android.sysprop.BluetoothProperties; import android.util.Log; import com.android.bluetooth.BluetoothObexTransport; Loading @@ -78,6 +80,34 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti private static final boolean D = Constants.DEBUG; private static final boolean V = Constants.VERBOSE; /** * Owned providers and activities */ private static final String OPP_PROVIDER = BluetoothOppProvider.class.getCanonicalName(); private static final String OPP_FILE_PROVIDER = BluetoothOppFileProvider.class.getCanonicalName(); private static final String LAUNCHER_ACTIVITY = BluetoothOppLauncherActivity.class.getCanonicalName(); private static final String BT_ENABLE_ACTIVITY = BluetoothOppBtEnableActivity.class.getCanonicalName(); private static final String BT_ERROR_ACTIVITY = BluetoothOppBtErrorActivity.class.getCanonicalName(); private static final String BT_ENABLING_ACTIVITY = BluetoothOppBtEnablingActivity.class.getCanonicalName(); private static final String INCOMING_FILE_CONFIRM_ACTIVITY = BluetoothOppIncomingFileConfirmActivity.class.getCanonicalName(); private static final String TRANSFER_ACTIVITY = BluetoothOppTransferActivity.class.getCanonicalName(); private static final String TRANSFER_HISTORY_ACTIVITY = BluetoothOppTransferHistory.class.getCanonicalName(); // Normally we would dynamically define and create these but they need to be manifest receivers // because they rely on explicit intents. Explicit intents don't work with dynamic receivers. private static final String OPP_RECEIVER = BluetoothOppReceiver.class.getCanonicalName(); private static final String OPP_HANDOFF_RECEIVER = BluetoothOppHandoverReceiver.class.getCanonicalName(); private static final byte[] SUPPORTED_OPP_FORMAT = { 0x01 /* vCard 2.1 */, 0x02 /* vCard 3.0 */, Loading Loading @@ -174,6 +204,10 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti */ private BluetoothOppObexServerSession mServerSession; public static boolean isEnabled() { return BluetoothProperties.isProfileOppEnabled().orElse(false); } @Override protected IProfileServiceBinder initBinder() { return new OppBinder(this); Loading @@ -197,13 +231,6 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti mShares = new ArrayList(); mBatches = new ArrayList(); mBatchId = 1; final ContentResolver contentResolver = getContentResolver(); new Thread("trimDatabase") { @Override public void run() { trimDatabase(contentResolver); } }.start(); IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(mBluetoothReceiver, filter); Loading @@ -223,6 +250,27 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti if (V) { Log.v(TAG, "start()"); } setComponentAvailable(OPP_PROVIDER, true); setComponentAvailable(OPP_FILE_PROVIDER, true); setComponentAvailable(LAUNCHER_ACTIVITY, true); setComponentAvailable(BT_ENABLE_ACTIVITY, true); setComponentAvailable(BT_ERROR_ACTIVITY, true); setComponentAvailable(BT_ENABLING_ACTIVITY, true); setComponentAvailable(INCOMING_FILE_CONFIRM_ACTIVITY, true); setComponentAvailable(TRANSFER_ACTIVITY, true); setComponentAvailable(TRANSFER_HISTORY_ACTIVITY, true); setComponentAvailable(OPP_RECEIVER, true); setComponentAvailable(OPP_HANDOFF_RECEIVER, true); final ContentResolver contentResolver = getContentResolver(); new Thread("trimDatabase") { @Override public void run() { trimDatabase(contentResolver); } }.start(); mAdapterService = AdapterService.getAdapterService(); mObserver = new BluetoothShareContentObserver(); getContentResolver().registerContentObserver(BluetoothShare.CONTENT_URI, true, mObserver); Loading @@ -248,6 +296,19 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti AdapterService.ACTIVITY_ATTRIBUTION_NO_ACTIVE_DEVICE_ADDRESS); setBluetoothOppService(null); mHandler.sendMessage(mHandler.obtainMessage(STOP_LISTENER)); setComponentAvailable(OPP_PROVIDER, false); setComponentAvailable(OPP_FILE_PROVIDER, false); setComponentAvailable(LAUNCHER_ACTIVITY, false); setComponentAvailable(BT_ENABLE_ACTIVITY, false); setComponentAvailable(BT_ERROR_ACTIVITY, false); setComponentAvailable(BT_ENABLING_ACTIVITY, false); setComponentAvailable(INCOMING_FILE_CONFIRM_ACTIVITY, false); setComponentAvailable(TRANSFER_ACTIVITY, false); setComponentAvailable(TRANSFER_HISTORY_ACTIVITY, false); setComponentAvailable(OPP_RECEIVER, false); setComponentAvailable(OPP_HANDOFF_RECEIVER, false); return true; } Loading
android/app/src/com/android/bluetooth/opp/Constants.java +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,10 @@ public class Constants { /** Tag used for debugging/logging */ public static final String TAG = "BluetoothOpp"; /** the permission required for others to send us handover broadcasts */ static final String PERMISSION_ALLOWLIST_BLUETOOTH_DEVICE = "com.android.permission.ALLOWLIST_BLUETOOTH_DEVICE"; /** * The intent that gets sent when the service must wake up for a retry * Note: Only retry Outbound transfers Loading
android/app/tests/unit/src/com/android/bluetooth/opp/BluetoothOppServiceTest.java +2 −5 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static org.mockito.Mockito.doReturn; import android.bluetooth.BluetoothAdapter; import android.content.Context; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import androidx.test.rule.ServiceTestRule; import androidx.test.runner.AndroidJUnit4; Loading @@ -45,7 +44,6 @@ import org.mockito.MockitoAnnotations; public class BluetoothOppServiceTest { private BluetoothOppService mService = null; private BluetoothAdapter mAdapter = null; private Context mTargetContext; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); Loading @@ -53,9 +51,8 @@ public class BluetoothOppServiceTest { @Before public void setUp() throws Exception { mTargetContext = InstrumentationRegistry.getTargetContext(); Assume.assumeTrue("Ignore test when BluetoothOppService is not enabled", mTargetContext.getResources().getBoolean(R.bool.profile_supported_opp)); BluetoothOppService.isEnabled()); MockitoAnnotations.initMocks(this); TestUtils.setAdapterService(mAdapterService); doReturn(true, false).when(mAdapterService).isStartedProfile(anyString()); Loading @@ -69,7 +66,7 @@ public class BluetoothOppServiceTest { @After public void tearDown() throws Exception { if (!mTargetContext.getResources().getBoolean(R.bool.profile_supported_opp)) { if (!BluetoothOppService.isEnabled()) { return; } TestUtils.stopService(mServiceRule, BluetoothOppService.class); Loading