Improved proximity sensor related logs
This commit is contained in:
parent
d38aaeec9c
commit
fa6cb4515a
4 changed files with 16 additions and 15 deletions
|
@ -23,7 +23,6 @@ import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.os.PowerManager.RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY
|
import android.os.PowerManager.RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
|
|
||||||
abstract class ProximitySensorActivity : GenericActivity() {
|
abstract class ProximitySensorActivity : GenericActivity() {
|
||||||
|
@ -44,15 +43,6 @@ abstract class ProximitySensorActivity : GenericActivity() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
|
|
||||||
if (coreContext.core.callsNb > 0) {
|
|
||||||
val videoEnabled = coreContext.core.currentCall?.currentParams?.isVideoEnabled ?: false
|
|
||||||
enableProximitySensor(!videoEnabled)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
enableProximitySensor(false)
|
enableProximitySensor(false)
|
||||||
|
|
||||||
|
@ -68,7 +58,7 @@ abstract class ProximitySensorActivity : GenericActivity() {
|
||||||
protected fun enableProximitySensor(enable: Boolean) {
|
protected fun enableProximitySensor(enable: Boolean) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (!proximitySensorEnabled) {
|
if (!proximitySensorEnabled) {
|
||||||
Log.i("[Proximity Sensor Activity] Enabling proximity sensor turning off screen")
|
Log.i("[Proximity Sensor Activity] Enabling proximity sensor (turning screen OFF when wake lock is acquired)")
|
||||||
if (!proximityWakeLock.isHeld) {
|
if (!proximityWakeLock.isHeld) {
|
||||||
Log.i("[Proximity Sensor Activity] Acquiring PROXIMITY_SCREEN_OFF_WAKE_LOCK")
|
Log.i("[Proximity Sensor Activity] Acquiring PROXIMITY_SCREEN_OFF_WAKE_LOCK")
|
||||||
proximityWakeLock.acquire()
|
proximityWakeLock.acquire()
|
||||||
|
@ -77,9 +67,9 @@ abstract class ProximitySensorActivity : GenericActivity() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (proximitySensorEnabled) {
|
if (proximitySensorEnabled) {
|
||||||
Log.i("[Proximity Sensor Activity] Disabling proximity sensor turning off screen")
|
Log.i("[Proximity Sensor Activity] Disabling proximity sensor (turning screen ON when wake lock is released)")
|
||||||
if (proximityWakeLock.isHeld) {
|
if (proximityWakeLock.isHeld) {
|
||||||
Log.i("[Proximity Sensor Activity] Releasing PROXIMITY_SCREEN_OFF_WAKE_LOCK")
|
Log.i("[Proximity Sensor Activity] Asking to release PROXIMITY_SCREEN_OFF_WAKE_LOCK next time sensor detects no proximity")
|
||||||
proximityWakeLock.release(RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY)
|
proximityWakeLock.release(RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY)
|
||||||
}
|
}
|
||||||
proximitySensorEnabled = false
|
proximitySensorEnabled = false
|
||||||
|
|
|
@ -104,6 +104,7 @@ class CallActivity : ProximitySensorActivity() {
|
||||||
controlsViewModel.proximitySensorEnabled.observe(
|
controlsViewModel.proximitySensorEnabled.observe(
|
||||||
this
|
this
|
||||||
) { enabled ->
|
) { enabled ->
|
||||||
|
Log.i("[Call Activity] ${if (enabled) "Enabling" else "Disabling"} proximity sensor (if possible)")
|
||||||
enableProximitySensor(enabled)
|
enableProximitySensor(enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,6 +483,16 @@ class ControlsViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun shouldProximitySensorBeEnabled(): Boolean {
|
private fun shouldProximitySensorBeEnabled(): Boolean {
|
||||||
return forceDisableProximitySensor.value == false && !(isVideoEnabled.value ?: false) && !(nonEarpieceOutputAudioDevice.value ?: false)
|
if (forceDisableProximitySensor.value == true) {
|
||||||
|
Log.i("[Call Controls] Forcing proximity sensor to be disabled (usually in incoming/outgoing call fragments)")
|
||||||
|
} else if (isVideoEnabled.value == true) {
|
||||||
|
Log.i("[Call Controls] Active call current params says video is enabled, proximity sensor will be disabled")
|
||||||
|
} else if (nonEarpieceOutputAudioDevice.value == true) {
|
||||||
|
Log.i("[Call Controls] Current audio route is not earpiece, proximity sensor will be disabled")
|
||||||
|
}
|
||||||
|
|
||||||
|
return forceDisableProximitySensor.value == false &&
|
||||||
|
!(isVideoEnabled.value ?: false) &&
|
||||||
|
!(nonEarpieceOutputAudioDevice.value ?: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
android:id="@+id/stubbed_paused_conference"
|
android:id="@+id/stubbed_paused_conference"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout="@layout/voip_conference_paused"
|
android:layout="@layout/voip_conference_paused"
|
||||||
android:visibility="@{conferenceViewModel.isConferenceLocallyPaused ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{conferenceViewModel.isConferenceLocallyPaused ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
app:conferenceViewModel="@{conferenceViewModel}"
|
app:conferenceViewModel="@{conferenceViewModel}"
|
||||||
|
|
Loading…
Reference in a new issue