blob: 5f9d0b280e386fd1539c9e63f85937e3eb4a69a3 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* Copyright Statement:
2 *
3 * This software/firmware and related documentation ("MediaTek Software") are
4 * protected under relevant copyright laws. The information contained herein
5 * is confidential and proprietary to MediaTek Inc. and/or its licensors.
6 * Without the prior written permission of MediaTek inc. and/or its licensors,
7 * any reproduction, modification, use or disclosure of MediaTek Software,
8 * and information contained herein, in whole or in part, shall be strictly prohibited.
9 *
10 * MediaTek Inc. (C) 2016. All rights reserved.
11 *
12 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
13 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
14 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
15 * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
18 * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
19 * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
20 * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
21 * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
22 * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
23 * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
24 * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
25 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
26 * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
27 * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
28 * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
29 * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
30 *
31 * The following software/firmware and/or related documentation ("MediaTek Software")
32 * have been modified by MediaTek Inc. All revisions are subject to any receiver's
33 * applicable license agreements with MediaTek Inc.
34 */
35
36#ifndef RFDESENSETXTEST_H_
37#define RFDESENSETXTEST_H_
38
39#include <string>
40#include <vector>
41#include <memory>
42#include <mutex>
43#include <thread>
44#include <condition_variable>
45#include <vendor-ril/telephony/ril.h>
46#include <utils/Looper.h>
47#include <utils/Thread.h>
48#include <utils/RefBase.h>
49
50using namespace std;
51using ::android::Looper;
52using ::android::Thread;
53using ::android::MessageHandler;
54using ::android::Message;
55using ::android::sp;
56using ::android::RefBase;
57
58#include "rfdesense/RfDesenseRatInfo.h"
59#include "Radio_capability_switch_util.h"
60
61class RfDesenseTxTest: public android::RefBase {
62public:
63 RfDesenseTxTest();
64 virtual ~RfDesenseTxTest();
65 static RfDesenseTxTest* getInstance();
66 int emRfDesenseStart(int len,int *item,int multilen,char *value[]);
67 void emRadioStateOn();
68 void emRadioStateOfforNotAvailable();
69 void emOemHookRaw(int value, int slot_id);
70 void emRfDesenseAtCmdHandle(char*response, int responselen);
71 static const int STATE_NONE;
72 static const int STATE_STARTED;
73 static const int STATE_STOPPED;
74
75 static const int MSG_START_TX;
76 static const int MSG_NEXT_RAT;
77 static const int MSG_READ_POWER;
78 static const int MSG_EWMPOLICY_TDSCDMA;
79 static const int MSG_EWMPOLICY_WCDMA;
80 static const int MSG_ECSRA;
81 static const int MSG_SWITCH_RAT_DONE;
82
83 static const std::string KEY_GSM_ATCMD;
84 static const std::string KEY_TDSCDMA_ATCMD;
85 static const std::string KEY_WCDMA_ATCMD;
86 static const std::string KEY_LTE_FDD_ATCMD;
87 static const std::string KEY_LTE_TDD_ATCMD;
88 static const std::string KEY_CDMA_1X_ATCMD;
89 static const std::string KEY_CDMA_EVDO_ATCMD;
90 static const std::string KEY_TEST_DURATION;
91 static const std::string KEY_TEST_COUNT;
92 static const std::string KEY_CHECK_LIMIT;
93 static const std::string KEY_READBACK_INTREVAL;
94
95 static const std::string DEFAULT_GSM_ATCMD;
96 static const std::string DEFAULT_TDSCDMA_ATCMD;
97 static const std::string DEFAULT_WCDMA_ATCMD;
98 static const std::string DEFAULT_LTE_FDD_ATCMD;
99 static const std::string DEFAULT_LTE_TDD_ATCMD;
100 static const std::string DEFAULT_CDMA_EVDO_ATCMD;
101 static const std::string DEFAULT_CDMA_1X_ATCMD;
102 static const std::string DEFAULT_CDMA_EVDO_ATCMD_93before;
103 static const std::vector<std::string> mRatName;
104 static std::vector<std::string> mRatCmdStart;
105 static std::vector<std::string> mRatCmdStop;
106 static std::vector<std::string> mRatCmdSwitch;
107 static std::vector<std::string> mRatCmdPowerRead;
108 static std::vector<std::string> mRatBand;
109 static std::vector<std::string> mRatPowerSet;
110 static std::vector<bool> mRatCheck;
111 static std::vector<bool> mSendState;
112 static long mTestDuration;
113 static long mTestCount;
114 static long mTestDurationSended;
115 static long mTestCountSended;
116 static long mCheckLimit;
117 static long mReadbackInterval;
118 std::vector<std::shared_ptr<RfDesenseRatInfo>> mRatList;
119 std::shared_ptr<RfDesenseRatInfo> mCurrectRatInfo;
120
121 const int MSG_QUERY = 0;
122 const int MSG_SET = 1;
123 int mCurrentFlag = 0;
124 std::vector<std::string> mCurrentSettingsValues;
125 static const int INDEX_GSM = 0;
126 static const int INDEX_TDSCDMA = 1;
127 static const int INDEX_WCDMA = 2;
128 static const int INDEX_LTE_FDD = 3;
129 static const int INDEX_LTE_TDD = 4;
130 static const int INDEX_CDMA_EVDO = 5;
131 static const int INDEX_CDMA_1X = 6;
132
133 static constexpr int INDEX_GSM_SUB_BAND = 0;
134 static constexpr int INDEX_GSM_SUB_CHANNEL = 1;
135 static constexpr int INDEX_GSM_SUB_POWER = 2;
136 static constexpr int INDEX_GSM_SUB_AFC = 3;
137 static constexpr int INDEX_GSM_SUB_TSC = 4 ;
138 static constexpr int INDEX_GSM_SUB_PATTERN = 5;
139
140 static constexpr int INDEX_3G_SUB_BAND = 0;
141 static constexpr int INDEX_3G_SUB_CHANNEL = 1;
142 static constexpr int INDEX_3G_SUB_POWER = 2;
143
144 static constexpr int INDEX_CDMA_SUB_BAND = 0;
145 static constexpr int INDEX_CDMA_SUB_MODULATION = 1;
146 static constexpr int INDEX_CDMA_SUB_CHANNEL = 2;
147 static constexpr int INDEX_CDMA_SUB_POWER = 3;
148
149 static constexpr int INDEX_FDD_SUB_MODE = 0;
150 static constexpr int INDEX_FDD_SUB_BAND = 1;
151 static constexpr int INDEX_FDD_SUB_BANDWITH = 2;
152 static constexpr int INDEX_FDD_SUB_FREQ = 3;
153 static constexpr int INDEX_FDD_SUB_START = 4;
154 static constexpr int INDEX_FDD_SUB_LENGTH = 5;
155 static constexpr int INDEX_FDD_SUB_MCS = 6;
156 static constexpr int INDEX_FDD_SUB_POWER = 7;
157
158 static constexpr int INDEX_TDD_SUB_MODE = 0;
159 static constexpr int INDEX_TDD_SUB_BAND = 1;
160 static constexpr int INDEX_TDD_SUB_BANDWIDTH = 2;
161 static constexpr int INDEX_TDD_SUB_FREQ = 3;
162 static constexpr int INDEX_TDD_SUB_CONFIG = 4;
163 static constexpr int INDEX_TDD_SUB_SPECIAL = 5;
164 static constexpr int INDEX_TDD_SUB_START = 6;
165 static constexpr int INDEX_TDD_SUB_LENGTH = 7;
166 static constexpr int INDEX_TDD_SUB_MCS = 8;
167 static constexpr int INDEX_TDD_SUB_POWER = 9;
168
169 class RequestHandleThread: public Thread {
170 public:
171 RequestHandleThread(RfDesenseTxTest* tx);
172 virtual ~RequestHandleThread();
173 sp<Looper> getLooper();
174
175 protected:
176 RfDesenseTxTest* mTx;
177 virtual bool threadLoop();
178 private:
179 sp<Looper> m_looper;
180 };
181
182 class RfRequestMessage: public RefBase {
183 public:
184 RfRequestMessage(RfDesenseTxTest* tx);
185 virtual ~RfRequestMessage();
186 void sendMessage(int delayms);
187 public:
188 int mMsgType;
189 string response;
190 int responselen;
191 int slot;
192 RIL_Errno e;
193 private:
194 RfDesenseTxTest* mTx;
195 };
196
197 class RfRequestHandler: public MessageHandler {
198 public:
199 RfRequestHandler(RfDesenseTxTest* tx): mTx(tx){}
200 virtual ~RfRequestHandler();
201
202 public:
203 void sendMessage(sp<RfRequestMessage> msg, int delayms);
204 void handleMessage(const Message& message);
205 sp<RfRequestMessage> mMsg;
206 // dummy message that makes handler happy
207 Message m_dummyMsg;
208 private:
209 RfDesenseTxTest* mTx;
210 };
211
212public:
213 void emRfDesenseAtCmdHandle(sp<RfRequestMessage> msg);
214 sp<RequestHandleThread> mRequestHandleThread;
215 sp<RfRequestHandler> mRfRequestHandler;
216 // send message to request handler
217 sp<RfRequestHandler> sendMessage(sp<RfRequestMessage> msg, int delayms);
218 void handle_request(string response,int responselen,int slot, RIL_Errno e);
219
220private:
221 std::shared_ptr<RfDesenseRatInfo> getCurrectRatInfo();
222 void update_rat();
223 void tx_stop();
224 void turnOffRf();
225 void turnOnRf();
226 void emRfDesenseThread(int id);
227 void rf_send_at_cmd(std::string cmd, int flag);
228 void save(int index);
229 void txTestStop(int what);
230 static RfDesenseTxTest* m_instance;
231 static std::mutex mMutex;
232 static bool trm_flag;
233 std::condition_variable m_condVar;
234 bool m_rawUrc = false;
235 void initRatList();
236 void handle_gsm_para(const std::string& name, int last_pos,const std::string& sub_name);
237 void handle_tdscdma_para(const std::string& name, int last_pos,const std::string& sub_name);
238 void handle_wcdma_para(const std::string& name, int last_pos,const std::string& sub_name);
239 void handle_lte_fdd_para(const std::string& name, int last_pos,const std::string& sub_name);
240 void handle_lte_tdd_para(const std::string& name, int last_pos,const std::string& sub_name);
241 void handle_cdma_evdo_para(const std::string& name, int last_pos,const std::string& sub_name);
242 void handle_cdma_1X_para(const std::string& name, int last_pos,const std::string& sub_name);
243 bool handle_show_default(const std::string& standard);
244 bool handle_para(int len, int classid, int propertyid, int operatorid,const std::string& standard, int* item);
245 bool handle_start(const std::string& standard);
246
247 static int mState;
248 static std::string str_msg;
249 static int phone_id;
250 bool mIsModemEnabled = true;
251 bool mIsModemNotEnabled = true;
252private:
253 void init();
254 void deInit();
255};
256
257#endif /* RFDESENSETXTEST_H_ */