diff --git a/android/pandora/mmi2grpc/mmi2grpc/map.py b/android/pandora/mmi2grpc/mmi2grpc/map.py index 138f4d3a20de87e9a4e9ea5c570be67f60d346f1..df347e70bc11d3d8251d0daf0d823448c4d6b079 100644 --- a/android/pandora/mmi2grpc/mmi2grpc/map.py +++ b/android/pandora/mmi2grpc/mmi2grpc/map.py @@ -39,6 +39,7 @@ class MAPProxy(ProfileProxy): self._android = Android(channel) self.connection = None + self._init_send_sms() @assert_description def TSC_MMI_iut_connectable(self, **kwargs): @@ -60,11 +61,16 @@ class MAPProxy(ProfileProxy): return "OK" @assert_description - def TSC_OBEX_MMI_iut_accept_connect(self, pts_addr: bytes, **kwargs): + def TSC_OBEX_MMI_iut_accept_connect(self, test: str, pts_addr: bytes, **kwargs): """ Please accept the OBEX CONNECT REQ. """ + if test in {"MAP/MSE/GOEP/BC/BV-01-I", "MAP/MSE/GOEP/BC/BV-03-I", "MAP/MSE/MMN/BV-02-I"}: + if self.connection is None: + self._android.SetAccessPermission(address=pts_addr, access_type=AccessType.ACCESS_MESSAGE) + self.connection = self.host.WaitConnection(address=pts_addr).connection + return "OK" @assert_description @@ -106,7 +112,7 @@ class MAPProxy(ProfileProxy): @assert_description def TSC_OBEX_MMI_iut_accept_set_path(self, **kwargs): """ - Please accept the SET_PATH command. + Please accept the SET_PATH command. """ return "OK" @@ -114,7 +120,7 @@ class MAPProxy(ProfileProxy): @assert_description def TSC_OBEX_MMI_iut_accept_get_srm(self, **kwargs): """ - Please accept the GET REQUEST with an SRM ENABLED header. + Please accept the GET REQUEST with an SRM ENABLED header. """ return "OK" @@ -122,7 +128,7 @@ class MAPProxy(ProfileProxy): @assert_description def TSC_OBEX_MMI_iut_accept_browse_folders(self, **kwargs): """ - Please accept the browse folders (GET) command. + Please accept the browse folders (GET) command. """ return "OK" @@ -155,6 +161,9 @@ class MAPProxy(ProfileProxy): """ Send Set Event Report with New GSM Message. """ + + self._android.SendSMS() + return "OK" @assert_description @@ -171,3 +180,9 @@ class MAPProxy(ProfileProxy): """ return "OK" + + def _init_send_sms(self): + + min_sms_count = 2 # Few test cases requires minimum 2 sms to pass + for index in range(min_sms_count): + self._android.SendSMS() diff --git a/android/pandora/server/configs/pts_bot_tests_config.json b/android/pandora/server/configs/pts_bot_tests_config.json index b907453b0cda7d44e901f698e57ca71571c279e5..69098c9583e7bf69d05123279b452ac831af47a6 100644 --- a/android/pandora/server/configs/pts_bot_tests_config.json +++ b/android/pandora/server/configs/pts_bot_tests_config.json @@ -342,6 +342,8 @@ "L2CAP/LE/CPU/BI-02-C", "L2CAP/LE/CPU/BV-02-C", "L2CAP/LE/REJ/BI-01-C", + "MAP/MSE/GOEP/BC/BV-01-I", + "MAP/MSE/GOEP/BC/BV-03-I", "MAP/MSE/GOEP/CON/BV-01-C", "MAP/MSE/GOEP/CON/BV-02-C", "MAP/MSE/GOEP/ROB/BV-01-C", @@ -351,13 +353,20 @@ "MAP/MSE/GOEP/SRM/BI-05-C", "MAP/MSE/GOEP/SRM/BV-04-C", "MAP/MSE/GOEP/SRM/BV-08-C", + "MAP/MSE/GOEP/SRMP/BV-02-C", "MAP/MSE/MMB/BV-09-I", "MAP/MSE/MMB/BV-10-I", "MAP/MSE/MMB/BV-11-I", + "MAP/MSE/MMB/BV-13-I", + "MAP/MSE/MMB/BV-14-I", + "MAP/MSE/MMB/BV-15-I", "MAP/MSE/MMB/BV-16-I", "MAP/MSE/MMB/BV-20-I", "MAP/MSE/MMB/BV-36-I", + "MAP/MSE/MMD/BV-02-I", "MAP/MSE/MMI/BV-02-I", + "MAP/MSE/MMN/BV-02-I", + "MAP/MSE/MMN/BV-04-I", "MAP/MSE/MMN/BV-06-I", "MAP/MSE/MMU/BV-03-I", "MAP/MSE/MNR/BV-03-I", @@ -751,16 +760,7 @@ "L2CAP/LE/CID/BV-02-C", "L2CAP/LE/CPU/BV-01-C", "L2CAP/LE/REJ/BI-02-C", - "MAP/MSE/GOEP/BC/BV-01-I", - "MAP/MSE/GOEP/BC/BV-03-I", "MAP/MSE/GOEP/SRMP/BI-02-C", - "MAP/MSE/GOEP/SRMP/BV-02-C", - "MAP/MSE/MMB/BV-13-I", - "MAP/MSE/MMB/BV-14-I", - "MAP/MSE/MMB/BV-15-I", - "MAP/MSE/MMD/BV-02-I", - "MAP/MSE/MMN/BV-02-I", - "MAP/MSE/MMN/BV-04-I", "MAP/MSE/MMN/BV-07-I", "MAP/MSE/MMN/BV-14-I", "MAP/MSE/MMU/BV-02-I", @@ -1575,6 +1575,7 @@ "TSPC_MAP_0_6": true, "TSPC_MAP_0a_5": true, "TSPC_MAP_1_1": true, + "TSPC_MAP_2_6c": false, "TSPC_MAP_3_1": true, "TSPC_MAP_3_1a": true, "TSPC_MAP_3_1b": true, @@ -1594,7 +1595,7 @@ "TSPC_MAP_3_5": true, "TSPC_MAP_3_5a": true, "TSPC_MAP_3_6b": true, - "TSPC_MAP_3_6c": true, + "TSPC_MAP_3_6c": false, "TSPC_MAP_3_7": true, "TSPC_MAP_3_7a": true, "TSPC_MAP_3_8": true, diff --git a/android/pandora/server/src/com/android/pandora/AndroidInternal.kt b/android/pandora/server/src/com/android/pandora/AndroidInternal.kt index 9dbf601e3208ea6520cfe30dee4ba1d01fa38749..21b73d2897f80957a5559c88d7ef9ce3e5aaf112 100644 --- a/android/pandora/server/src/com/android/pandora/AndroidInternal.kt +++ b/android/pandora/server/src/com/android/pandora/AndroidInternal.kt @@ -20,6 +20,11 @@ import android.util.Log import android.content.Context import com.google.protobuf.Empty import io.grpc.stub.StreamObserver +import android.provider.Telephony.* +import android.telephony.SmsManager +import android.telephony.SubscriptionManager +import android.telephony.TelephonyManager +import android.net.Uri import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothDevice import android.bluetooth.BluetoothManager @@ -32,11 +37,13 @@ import pandora.AndroidProto.* private const val TAG = "PandoraAndroidInternal" @kotlinx.coroutines.ExperimentalCoroutinesApi -class AndroidInternal(context: Context) : AndroidImplBase() { +class AndroidInternal(val context: Context) : AndroidImplBase() { private val scope: CoroutineScope = CoroutineScope(Dispatchers.Default) private val bluetoothManager = context.getSystemService(BluetoothManager::class.java)!! private val bluetoothAdapter = bluetoothManager.adapter + private var telephonyManager = context.getSystemService(TelephonyManager::class.java) + private val DEFAULT_MESSAGE_LEN = 130 fun deinit() { scope.cancel() @@ -61,4 +68,16 @@ class AndroidInternal(context: Context) : AndroidImplBase() { Empty.getDefaultInstance() } } + + override fun sendSMS(request: Empty, responseObserver: StreamObserver<Empty>) { + grpcUnary<Empty>(scope, responseObserver) { + val smsManager = SmsManager.getDefault() + val defaultSmsSub = SubscriptionManager.getDefaultSmsSubscriptionId() + telephonyManager = telephonyManager.createForSubscriptionId(defaultSmsSub) + val avdPhoneNumber = telephonyManager.getLine1Number() + + smsManager.sendTextMessage(avdPhoneNumber, avdPhoneNumber, generateAlphanumericString(DEFAULT_MESSAGE_LEN), null, null) + Empty.getDefaultInstance() + } + } } diff --git a/android/pandora/server/src/com/android/pandora/MediaPlayerBrowserService.kt b/android/pandora/server/src/com/android/pandora/MediaPlayerBrowserService.kt index 89817870235d832fc8bd680c1682f837fabbd749..e8a783d5b97247725689484cbe7cfda535fcc53b 100644 --- a/android/pandora/server/src/com/android/pandora/MediaPlayerBrowserService.kt +++ b/android/pandora/server/src/com/android/pandora/MediaPlayerBrowserService.kt @@ -31,7 +31,6 @@ class MediaPlayerBrowserService : MediaBrowserService() { private lateinit var mediaSession: MediaSession private lateinit var playbackStateBuilder: PlaybackState.Builder - private val alphanumeric = ('A'..'Z') + ('a'..'z') + ('0'..'9') private val mediaIdToChildren = mutableMapOf<String, MutableList<MediaItem>>() private var metadataItems = mutableMapOf<String, MediaMetadata>() private var queue = mutableListOf<MediaSession.QueueItem>() @@ -132,10 +131,6 @@ class MediaPlayerBrowserService : MediaBrowserService() { ) } - private fun generateAlphanumericString(length: Int): String { - return buildString { repeat(length) { append(alphanumeric.random()) } } - } - private val mSessionCallback: MediaSession.Callback = object : MediaSession.Callback() { override fun onPlay() { diff --git a/android/pandora/server/src/com/android/pandora/Utils.kt b/android/pandora/server/src/com/android/pandora/Utils.kt index 96a59dbfcaca5341168a91bdfbf208a8de4215bb..a88ffae0a3b7c153e017acc97292d8afd107d5ef 100644 --- a/android/pandora/server/src/com/android/pandora/Utils.kt +++ b/android/pandora/server/src/com/android/pandora/Utils.kt @@ -58,6 +58,7 @@ import pandora.AndroidProto.InternalConnectionRef import pandora.HostProto.Connection private const val TAG = "PandoraUtils" +private val alphanumeric = ('A'..'Z') + ('a'..'z') + ('0'..'9') fun shell(cmd: String): String { val fd = InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(cmd) @@ -340,3 +341,13 @@ fun buildAudioTrack(): AudioTrack? { .setBufferSizeInBytes(44100 * 2 * 2) .build() } + +/** + * Generates Alpha-numeric string of given length. + * + * @param length required string size. + * @return a generated string + */ +fun generateAlphanumericString(length: Int): String { + return buildString { repeat(length) { append(alphanumeric.random()) } } +} diff --git a/pandora/interfaces/pandora_experimental/_android.proto b/pandora/interfaces/pandora_experimental/_android.proto index 0419b2309c5062cb683cd824660ff57629945ea0..27960fc17f77795d2a43c43f4131a6538f393a83 100644 --- a/pandora/interfaces/pandora_experimental/_android.proto +++ b/pandora/interfaces/pandora_experimental/_android.proto @@ -16,6 +16,8 @@ service Android { rpc Log(LogRequest) returns (LogResponse); // Set Message, PhoneBook and SIM access permission rpc SetAccessPermission(SetAccessPermissionRequest) returns (google.protobuf.Empty); + // Send SMS + rpc SendSMS(google.protobuf.Empty) returns (google.protobuf.Empty); } message LogRequest {