• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.telephony.cts;
17 
18 import android.net.Uri;
19 import android.os.RemoteException;
20 import android.service.carrier.CarrierMessagingService;
21 import android.service.carrier.MessagePdu;
22 
23 import java.util.List;
24 
25 /**
26  * The class that serves as a fake CarrierMessagingService. It allows
27  * CarrierMessagingServiceWrapperTest to connect to and test against.
28  */
29 public class FakeCarrierMessagingService extends CarrierMessagingService {
30     public static int FAKE_MESSAGE_REF = 1;
31     @Override
onReceiveTextSms(MessagePdu pdu, String format, int destPort, int subId, ResultCallback<Integer> callback)32     public void onReceiveTextSms(MessagePdu pdu, String format, int destPort,
33             int subId, ResultCallback<Integer> callback) {
34         try {
35             callback.onReceiveResult(CarrierMessagingService.RECEIVE_OPTIONS_DEFAULT);
36         } catch (RemoteException ex) {
37         }
38     }
39 
40     @Override
onSendTextSms(String text, int subId, String destAddress, int sendSmsFlag, ResultCallback<SendSmsResult> callback)41     public void onSendTextSms(String text, int subId, String destAddress,
42             int sendSmsFlag, ResultCallback<SendSmsResult> callback) {
43         try {
44             callback.onReceiveResult(new SendSmsResult(SEND_STATUS_OK, FAKE_MESSAGE_REF));
45         } catch (RemoteException ex) {
46         }
47     }
48 
49     @Override
onSendDataSms(byte[] data, int subId, String destAddress, int destPort, int sendSmsFlag, ResultCallback<SendSmsResult> callback)50     public void onSendDataSms(byte[] data, int subId, String destAddress,
51             int destPort, int sendSmsFlag, ResultCallback<SendSmsResult> callback) {
52         try {
53             callback.onReceiveResult(new SendSmsResult(SEND_STATUS_OK, FAKE_MESSAGE_REF));
54         } catch (RemoteException ex) {
55         }
56     }
57 
58     @Override
onSendMultipartTextSms(List<String> parts, int subId, String destAddress, int sendSmsFlag, ResultCallback<SendMultipartSmsResult> callback)59     public void onSendMultipartTextSms(List<String> parts, int subId,
60             String destAddress, int sendSmsFlag,
61             ResultCallback<SendMultipartSmsResult> callback) {
62         try {
63             callback.onReceiveResult(new SendMultipartSmsResult(
64                     SEND_STATUS_OK, new int[] {FAKE_MESSAGE_REF}));
65         } catch (RemoteException ex) {
66         }
67     }
68 
69     @Override
onSendMms(Uri pduUri, int subId, Uri location, ResultCallback<SendMmsResult> callback)70     public void onSendMms(Uri pduUri, int subId, Uri location,
71             ResultCallback<SendMmsResult> callback) {
72         try {
73             callback.onReceiveResult(new SendMmsResult(
74                     SEND_STATUS_OK, new byte[0]));
75         } catch (RemoteException ex) {
76         }
77     }
78 
79     @Override
onDownloadMms(Uri contentUri, int subId, Uri location, ResultCallback<Integer> callback)80     public void onDownloadMms(Uri contentUri, int subId, Uri location,
81             ResultCallback<Integer> callback) {
82         try {
83             callback.onReceiveResult(CarrierMessagingService.RECEIVE_OPTIONS_DEFAULT);
84         } catch (RemoteException ex) {
85         }
86     }
87 }
88