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

Commit 27ce1c8f authored by Charlie Boutier's avatar Charlie Boutier Committed by Automerger Merge Worker
Browse files

Merge changes I5d44b4e5,I46590c50 into main am: ce6b6418 am: 4872665b am: 53a29fed

parents 14b360ff 53a29fed
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@
from mmi2grpc._helpers import format_function
from mmi2grpc._helpers import assert_description

from pandora_experimental._android_grpc import Android
from pandora_experimental.os_grpc import Os


class ProfileProxy:
    """Profile proxy base class."""

    def __init__(self, channel) -> None:
        self._android = Android(channel)
        self.os = Os(channel)

    def interact(self, test: str, mmi_name: str, mmi_description: str, pts_addr: bytes):
        """Translate a MMI call to its corresponding implementation.
@@ -49,7 +49,7 @@ class ProfileProxy:
            assert False, f'Unhandled mmi {mmi_name}\n{code}'

    def log(self, text=""):
        self._android.Log(text=text)
        self.os.Log(text=text)

    def test_started(self, test: str, description: str, pts_addr: bytes):
        return "OK"
+10 −8
Original line number Diff line number Diff line
@@ -20,8 +20,9 @@ from mmi2grpc._proxy import ProfileProxy

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


class MAPProxy(ProfileProxy):
@@ -36,7 +37,8 @@ class MAPProxy(ProfileProxy):
        super().__init__(channel)

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

        self.connection = None
        self._init_send_sms()
@@ -55,7 +57,7 @@ class MAPProxy(ProfileProxy):
        Please accept the l2cap channel connection for an OBEX connection.
        """

        self._android.SetAccessPermission(address=pts_addr, access_type=ACCESS_MESSAGE)
        self.os.SetAccessPermission(address=pts_addr, access_type=ACCESS_MESSAGE)
        self.connection = self.host.WaitConnection(address=pts_addr).connection

        return "OK"
@@ -68,7 +70,7 @@ class MAPProxy(ProfileProxy):

        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=ACCESS_MESSAGE)
                self.os.SetAccessPermission(address=pts_addr, access_type=ACCESS_MESSAGE)
                self.connection = self.host.WaitConnection(address=pts_addr).connection

        return "OK"
@@ -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()
+3 −3
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ from mmi2grpc._proxy import ProfileProxy

from pandora.host_grpc import Host
from pandora_experimental.pan_grpc import PAN
from pandora_experimental._android_grpc import Android
from pandora_experimental.os_grpc import Os

# IP address of PTS
TSPX_PTS_IP_ADDRESS = "192.168.168.100"
@@ -32,7 +32,7 @@ class PANProxy(ProfileProxy):
        super().__init__(channel)
        self.host = Host(channel)
        self.pan = PAN(channel)
        self._android = Android(channel)
        self.os = Os(channel)

    def TSC_BNEP_mmi_iut_accept_transport(self, pts_addr: bytes, **kwargs):
        """
@@ -238,7 +238,7 @@ class PANProxy(ProfileProxy):
        Take action to send ICMP echo request
        """

        self._android.SendPing(ip_address=TSPX_PTS_IP_ADDRESS)
        self.os.SendPing(ip_address=TSPX_PTS_IP_ADDRESS)

        return "OK"

+5 −5
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ from mmi2grpc._helpers import assert_description, match_description
from mmi2grpc._proxy import ProfileProxy
from pandora.host_grpc import Host
from pandora.host_pb2 import Connection
from pandora_experimental._android_grpc import Android
from pandora_experimental._android_pb2 import ACCESS_PHONEBOOK
from pandora_experimental.os_grpc import Os
from pandora_experimental.os_pb2 import ACCESS_PHONEBOOK
from pandora_experimental.pbap_grpc import PBAP


@@ -39,7 +39,7 @@ class PBAPProxy(ProfileProxy):

        self.host = Host(channel)
        self.pbap = PBAP(channel)
        self._android = Android(channel)
        self.os = Os(channel)

        self.connection = None

@@ -56,7 +56,7 @@ class PBAPProxy(ProfileProxy):
        """
        Please accept the l2cap channel connection for an OBEX connection.
        """
        self._android.SetAccessPermission(address=pts_addr, access_type=ACCESS_PHONEBOOK)
        self.os.SetAccessPermission(address=pts_addr, access_type=ACCESS_PHONEBOOK)
        self.connection = self.host.WaitConnection(address=pts_addr).connection

        return "OK"
@@ -68,7 +68,7 @@ class PBAPProxy(ProfileProxy):
        """
        if ("PBAP/PSE/GOEP/BC/BV-03-I" in test):
            if self.connection is None:
                self._android.SetAccessPermission(address=pts_addr, access_type=ACCESS_PHONEBOOK)
                self.os.SetAccessPermission(address=pts_addr, access_type=ACCESS_PHONEBOOK)
                self.connection = self.host.WaitConnection(address=pts_addr).connection

        return "OK"
+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()
        }
    }
}
Loading