Log whether idle mode is ON when proxy registration fails

This commit is contained in:
Sylvain Berfini 2019-03-05 16:00:56 +01:00
parent 5cce0fdce4
commit 50be31fdc6
3 changed files with 18 additions and 0 deletions

View file

@ -1102,6 +1102,11 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
final RegistrationState state,
final String message) {
Log.i("[Manager] New registration state [" + state + "]");
if (state == RegistrationState.Failed) {
boolean isIdle = Compatibility.isAppIdleMode(mServiceContext);
Log.w("[Manager] PowerManager isIdleMode returned " + isIdle);
}
}
public Context getContext() {

View file

@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import android.annotation.TargetApi;
import android.content.Context;
import android.os.PowerManager;
import android.widget.TextView;
@TargetApi(23)
@ -27,4 +29,8 @@ class ApiTwentyThreePlus {
public static void setTextAppearance(TextView textview, int style) {
textview.setTextAppearance(style);
}
public static boolean isAppIdleMode(Context context) {
return ((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isDeviceIdleMode();
}
}

View file

@ -203,4 +203,11 @@ public class Compatibility {
}
return false;
}
public static boolean isAppIdleMode(Context context) {
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
return ApiTwentyThreePlus.isAppIdleMode(context);
}
return false;
}
}