mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 23:25:20 +03:00
Improve code further with some conditionals & audio handling
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
2fb58e8cab
commit
52d522ed37
2 changed files with 41 additions and 8 deletions
|
@ -496,8 +496,19 @@ public class CallController extends BaseController {
|
|||
final MagicAudioManager.AudioDevice device, final Set<MagicAudioManager.AudioDevice> availableDevices) {
|
||||
Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", "
|
||||
+ "selected: " + device);
|
||||
|
||||
final boolean shouldDisableProximityLock = (device.equals(MagicAudioManager.AudioDevice.WIRED_HEADSET)
|
||||
|| device.equals(MagicAudioManager.AudioDevice.SPEAKER_PHONE)
|
||||
|| device.equals(MagicAudioManager.AudioDevice.BLUETOOTH));
|
||||
|
||||
if (shouldDisableProximityLock) {
|
||||
powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.WITHOUT_PROXIMITY_SENSOR_LOCK);
|
||||
} else {
|
||||
powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.WITH_PROXIMITY_SENSOR_LOCK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void cameraInitialization() {
|
||||
videoCapturer = createCameraCapturer(cameraEnumerator);
|
||||
|
||||
|
|
|
@ -134,16 +134,31 @@ public class PowerManagerUtils {
|
|||
private synchronized void setWakeLockState(WakeLockState newState) {
|
||||
switch(newState) {
|
||||
case FULL:
|
||||
fullLock.acquire();
|
||||
partialLock.acquire();
|
||||
wifiLock.acquire();
|
||||
if (!fullLock.isHeld()) {
|
||||
fullLock.acquire();
|
||||
}
|
||||
|
||||
if (!partialLock.isHeld()) {
|
||||
partialLock.acquire();
|
||||
}
|
||||
|
||||
if (!wifiLock.isHeld()) {
|
||||
wifiLock.acquire();
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
proximityLock.release();
|
||||
}
|
||||
break;
|
||||
case PARTIAL:
|
||||
partialLock.acquire();
|
||||
wifiLock.acquire();
|
||||
if (!partialLock.isHeld()) {
|
||||
partialLock.acquire();
|
||||
}
|
||||
|
||||
if (!wifiLock.isHeld()) {
|
||||
wifiLock.acquire();
|
||||
}
|
||||
|
||||
fullLock.release();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
proximityLock.release();
|
||||
|
@ -158,9 +173,16 @@ public class PowerManagerUtils {
|
|||
}
|
||||
break;
|
||||
case PROXIMITY:
|
||||
partialLock.acquire();
|
||||
wifiLock.acquire();
|
||||
fullLock.release();
|
||||
if (!partialLock.isHeld()) {
|
||||
partialLock.acquire();
|
||||
}
|
||||
|
||||
if (!wifiLock.isHeld()) {
|
||||
wifiLock.acquire();
|
||||
}
|
||||
fullLock.release(
|
||||
|
||||
);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
proximityLock.acquire();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue