Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18ee4a42 authored by Charlie Boutier's avatar Charlie Boutier
Browse files

PandoraServer: introduce map.proto

Test: atest pts-bot:MAP
Bug: 291995194
Change-Id: I46590c50d2e218487e874344f3a0d8411dc056d6
parent 4dca7627
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ from mmi2grpc._proxy import ProfileProxy

from pandora.host_grpc import Host
from pandora.host_pb2 import Connection
from pandora_experimental.map_grpc import Map as MapProfile
from pandora_experimental._android_grpc import Android
from pandora_experimental._android_pb2 import ACCESS_MESSAGE

@@ -37,6 +38,7 @@ class MAPProxy(ProfileProxy):

        self.host = Host(channel)
        self._android = Android(channel)
        self.map_profile = MapProfile(channel)

        self.connection = None
        self._init_send_sms()
@@ -162,7 +164,7 @@ class MAPProxy(ProfileProxy):
        Send Set Event Report with New GSM Message.
        """

        self._android.SendSMS()
        self.map_profile.SendSMS()

        return "OK"

@@ -184,5 +186,5 @@ class MAPProxy(ProfileProxy):
    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()
        for _ in range(min_sms_count):
            self.map_profile.SendSMS()
+0 −20
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothManager
import android.content.Context
import android.provider.Telephony.*
import android.telephony.SmsManager
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import android.util.Log
import com.google.protobuf.Empty
@@ -69,24 +67,6 @@ class AndroidInternal(val context: Context) : AndroidImplBase() {
        }
    }

    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()
        }
    }

    override fun sendPing(request: SendPingRequest, responseObserver: StreamObserver<Empty>) {
        grpcUnary<Empty>(scope, responseObserver) {
            val pingStatus =
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 */

package com.android.pandora

import android.content.Context
import android.telephony.SmsManager
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import com.google.protobuf.Empty
import io.grpc.stub.StreamObserver
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import pandora.MapGrpc.MapImplBase
import pandora.MapProto.*

private const val TAG = "PandoraMap"

class Map(context: Context) : MapImplBase() {
    private val DEFAULT_MESSAGE_LEN = 130

    private val scope: CoroutineScope = CoroutineScope(Dispatchers.Default.limitedParallelism(1))
    private var telephonyManager = context.getSystemService(TelephonyManager::class.java)!!

    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()
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ class Opp(val context: Context) : OppImplBase(), Closeable {
    private val bluetoothAdapter = bluetoothManager.adapter
    private var uiDevice: UiDevice =
        UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())

    init {
        createImageFile()

+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ class Server(context: Context) {
                        BluetoothProfile.PAN to ::Pan,
                        BluetoothProfile.PBAP to ::Pbap,
                        BluetoothProfile.OPP to ::Opp,
                        BluetoothProfile.MAP to ::Map,
                    )
                    .filter { bluetoothAdapter.isEnabled }
                    .filter { bluetoothAdapter.getSupportedProfiles().contains(it.key) == true }
Loading