Browse Source

android: make code a bit more readable

master
Saúl Ibarra Corretgé 5 years ago
parent
commit
f0dcb51915

+ 14
- 17
android/sdk/src/main/java/org/jitsi/meet/sdk/AudioDeviceHandlerConnectionService.java View File

@@ -18,6 +18,7 @@ package org.jitsi.meet.sdk;
18 18
 
19 19
 import android.content.Context;
20 20
 import android.os.Build;
21
+import android.telecom.CallAudioState;
21 22
 import androidx.annotation.RequiresApi;
22 23
 
23 24
 import java.util.HashSet;
@@ -52,20 +53,20 @@ class AudioDeviceHandlerConnectionService implements
52 53
      */
53 54
     private static int audioDeviceToRouteInt(String audioDevice) {
54 55
         if (audioDevice == null) {
55
-            return android.telecom.CallAudioState.ROUTE_EARPIECE;
56
+            return CallAudioState.ROUTE_EARPIECE;
56 57
         }
57 58
         switch (audioDevice) {
58 59
             case AudioModeModule.DEVICE_BLUETOOTH:
59
-                return android.telecom.CallAudioState.ROUTE_BLUETOOTH;
60
+                return CallAudioState.ROUTE_BLUETOOTH;
60 61
             case AudioModeModule.DEVICE_EARPIECE:
61
-                return android.telecom.CallAudioState.ROUTE_EARPIECE;
62
+                return CallAudioState.ROUTE_EARPIECE;
62 63
             case AudioModeModule.DEVICE_HEADPHONES:
63
-                return android.telecom.CallAudioState.ROUTE_WIRED_HEADSET;
64
+                return CallAudioState.ROUTE_WIRED_HEADSET;
64 65
             case AudioModeModule.DEVICE_SPEAKER:
65
-                return android.telecom.CallAudioState.ROUTE_SPEAKER;
66
+                return CallAudioState.ROUTE_SPEAKER;
66 67
             default:
67 68
                 JitsiMeetLogger.e(TAG + " Unsupported device name: " + audioDevice);
68
-                return android.telecom.CallAudioState.ROUTE_EARPIECE;
69
+                return CallAudioState.ROUTE_EARPIECE;
69 70
         }
70 71
     }
71 72
 
@@ -78,20 +79,16 @@ class AudioDeviceHandlerConnectionService implements
78 79
      */
79 80
     private static Set<String> routesToDeviceNames(int supportedRouteMask) {
80 81
         Set<String> devices = new HashSet<>();
81
-        if ((supportedRouteMask & android.telecom.CallAudioState.ROUTE_EARPIECE)
82
-                == android.telecom.CallAudioState.ROUTE_EARPIECE) {
82
+        if ((supportedRouteMask & CallAudioState.ROUTE_EARPIECE) == CallAudioState.ROUTE_EARPIECE) {
83 83
             devices.add(AudioModeModule.DEVICE_EARPIECE);
84 84
         }
85
-        if ((supportedRouteMask & android.telecom.CallAudioState.ROUTE_BLUETOOTH)
86
-                == android.telecom.CallAudioState.ROUTE_BLUETOOTH) {
85
+        if ((supportedRouteMask & CallAudioState.ROUTE_BLUETOOTH) == CallAudioState.ROUTE_BLUETOOTH) {
87 86
             devices.add(AudioModeModule.DEVICE_BLUETOOTH);
88 87
         }
89
-        if ((supportedRouteMask & android.telecom.CallAudioState.ROUTE_SPEAKER)
90
-                == android.telecom.CallAudioState.ROUTE_SPEAKER) {
88
+        if ((supportedRouteMask & CallAudioState.ROUTE_SPEAKER) == CallAudioState.ROUTE_SPEAKER) {
91 89
             devices.add(AudioModeModule.DEVICE_SPEAKER);
92 90
         }
93
-        if ((supportedRouteMask & android.telecom.CallAudioState.ROUTE_WIRED_HEADSET)
94
-                == android.telecom.CallAudioState.ROUTE_WIRED_HEADSET) {
91
+        if ((supportedRouteMask & CallAudioState.ROUTE_WIRED_HEADSET) == CallAudioState.ROUTE_WIRED_HEADSET) {
95 92
             devices.add(AudioModeModule.DEVICE_HEADPHONES);
96 93
         }
97 94
         return devices;
@@ -109,13 +106,13 @@ class AudioDeviceHandlerConnectionService implements
109 106
     }
110 107
 
111 108
     @Override
112
-    public void onCallAudioStateChange(final android.telecom.CallAudioState callAudioState) {
109
+    public void onCallAudioStateChange(final CallAudioState state) {
113 110
         module.runInAudioThread(new Runnable() {
114 111
             @Override
115 112
             public void run() {
116 113
                 boolean audioRouteChanged
117
-                    = audioDeviceToRouteInt(module.getSelectedDevice()) != callAudioState.getRoute();
118
-                int newSupportedRoutes = callAudioState.getSupportedRouteMask();
114
+                    = audioDeviceToRouteInt(module.getSelectedDevice()) != state.getRoute();
115
+                int newSupportedRoutes = state.getSupportedRouteMask();
119 116
                 boolean audioDevicesChanged = supportedRouteMask != newSupportedRoutes;
120 117
                 if (audioDevicesChanged) {
121 118
                     supportedRouteMask = newSupportedRoutes;

Loading…
Cancel
Save