@@ -41,12 +41,12 @@ public class PreCallTest extends BaseFragment implements View.OnClickListener {
4141
4242 private RtcEngine engine ;
4343 private int myUid ;
44- private Button btn_lastmile , btn_echo ;
44+ private Button btn_lastmile , btn_echo , btn_device_test ;
4545 private StatisticsInfo statisticsInfo ;
46- private TextView lastmileQuality , lastmileResult ;
46+ private TextView lastmileQuality , lastmileResult , labelDeviceTest ;
4747 private static final Integer MAX_COUNT_DOWN = 8 ;
4848 private int num ;
49- private Timer timer ;
49+ private Timer echoTimer ;
5050
5151 @ Override
5252 public void onCreate (@ Nullable Bundle savedInstanceState ) {
@@ -94,6 +94,18 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
9494 config .mAudioScenario = Constants .AudioScenario .getValue (Constants .AudioScenario .DEFAULT );
9595 config .mAreaCode = ((MainApplication )getActivity ().getApplication ()).getGlobalSettings ().getAreaCode ();
9696 engine = RtcEngine .create (config );
97+ /**
98+ * This parameter is for reporting the usages of APIExample to agora background.
99+ * Generally, it is not necessary for you to set this parameter.
100+ */
101+ engine .setParameters ("{"
102+ + "\" rtc.report_app_scenario\" :"
103+ + "{"
104+ + "\" appScenario\" :" + 100 + ","
105+ + "\" serviceType\" :" + 11 + ","
106+ + "\" appVersion\" :\" " + RtcEngine .getSdkVersion () + "\" "
107+ + "}"
108+ + "}" );
97109 }
98110 catch (Exception e ) {
99111 e .printStackTrace ();
@@ -109,10 +121,19 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
109121 btn_echo .setOnClickListener (this );
110122 btn_lastmile = view .findViewById (R .id .btn_lastmile );
111123 btn_lastmile .setOnClickListener (this );
124+ btn_device_test = view .findViewById (R .id .btn_device_test );
125+ btn_device_test .setOnClickListener (this );
126+ labelDeviceTest = view .findViewById (R .id .lb_device_test );
112127 lastmileQuality = view .findViewById (R .id .lastmile_quality );
113128 lastmileResult = view .findViewById (R .id .lastmile_result );
114129 }
115130
131+ @ Override
132+ public void onDestroy () {
133+ super .onDestroy ();
134+ RtcEngine .destroy ();
135+ }
136+
116137 @ Override
117138 public void onClick (View v ) {
118139 if (v .getId () == R .id .btn_lastmile )
@@ -137,17 +158,17 @@ else if (v.getId() == R.id.btn_echo){
137158 engine .startEchoTest (MAX_COUNT_DOWN );
138159 btn_echo .setEnabled (false );
139160 btn_echo .setText ("Recording on Microphone ..." );
140- timer = new Timer (true );
141- timer .schedule (new TimerTask (){
161+ echoTimer = new Timer (true );
162+ echoTimer .schedule (new TimerTask (){
142163 public void run () {
143164 num ++;
144165 if (num >= MAX_COUNT_DOWN * 2 ){
145166 handler .post (() -> {
146167 btn_echo .setEnabled (true );
147- btn_echo .setText ("Start" );
168+ btn_echo .setText (R . string . start );
148169 });
149170 engine .stopEchoTest ();
150- timer .cancel ();
171+ echoTimer .cancel ();
151172 }
152173 else if (num >= MAX_COUNT_DOWN ) {
153174 handler .post (() -> btn_echo .setText ("PLaying with " + (MAX_COUNT_DOWN * 2 - num ) + "Seconds" ));
@@ -157,6 +178,19 @@ else if(num >= MAX_COUNT_DOWN) {
157178 }
158179 }
159180 }, 1000 , 1000 );
181+ }else if (v .getId () == R .id .btn_device_test ){
182+ boolean enable = btn_device_test .getTag () instanceof Boolean && (Boolean ) btn_device_test .getTag ();
183+ if (!enable ){
184+ engine .startRecordingDeviceTest (500 );
185+ btn_device_test .setText (R .string .stop );
186+ btn_device_test .setTag (true );
187+ handler .postDelayed (() -> onClick (v ), 10 * 1000 );
188+ }else {
189+ engine .stopRecordingDeviceTest ();
190+ btn_device_test .setText (R .string .start );
191+ btn_device_test .setTag (null );
192+ labelDeviceTest .setText ("" );
193+ }
160194 }
161195 }
162196
@@ -284,9 +318,15 @@ public void onLastmileProbeResult(LastmileProbeResult lastmileProbeResult) {
284318 updateLastMileResult ();
285319 handler .post (() -> {
286320 btn_lastmile .setEnabled (true );
287- btn_lastmile .setText ("Start" );
321+ btn_lastmile .setText (R . string . start );
288322 });
289323 }
324+
325+ @ Override
326+ public void onAudioVolumeIndication (AudioVolumeInfo [] speakers , int totalVolume ) {
327+ super .onAudioVolumeIndication (speakers , totalVolume );
328+ runOnUIThread (() -> labelDeviceTest .append ("totalVolume=" + totalVolume + "\n " ));
329+ }
290330 };
291331
292332 private void updateLastMileResult () {
0 commit comments