aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-19 18:43:00 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita13e03e988f85a67366f2ffe39bae67576e425bc (patch)
tree5c41114e9bc54ca203877c76d48bb245d1b653c0 /backends/platform
parent0c1c274abdbdb4183d9a08669082227aa912b1ea (diff)
downloadscummvm-rg350-a13e03e988f85a67366f2ffe39bae67576e425bc.tar.gz
scummvm-rg350-a13e03e988f85a67366f2ffe39bae67576e425bc.tar.bz2
scummvm-rg350-a13e03e988f85a67366f2ffe39bae67576e425bc.zip
CLOUD: Add Networking::Connection::isLimited()
`false` everywhere by default, but works on Android (`true` if not Wi-Fi).
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/android/jni.cpp18
-rw-r--r--backends/platform/android/jni.h2
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVM.java1
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java12
4 files changed, 33 insertions, 0 deletions
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 6360bb1416..91d9a572c2 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -77,6 +77,7 @@ bool JNI::_ready_for_events = 0;
jmethodID JNI::_MID_getDPI = 0;
jmethodID JNI::_MID_displayMessageOnOSD = 0;
jmethodID JNI::_MID_openUrl = 0;
+jmethodID JNI::_MID_isConnectionLimited = 0;
jmethodID JNI::_MID_setWindowCaption = 0;
jmethodID JNI::_MID_showVirtualKeyboard = 0;
jmethodID JNI::_MID_getSysArchives = 0;
@@ -252,6 +253,22 @@ bool JNI::openUrl(const char *url) {
return success;
}
+bool JNI::isConnectionLimited() {
+ bool limited = false;
+ JNIEnv *env = JNI::getEnv();
+ limited = env->CallBooleanMethod(_jobj, _MID_isConnectionLimited);
+
+ if (env->ExceptionCheck()) {
+ LOGE("Failed to check whether connection's limited");
+
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ limited = true;
+ }
+
+ return limited;
+}
+
void JNI::setWindowCaption(const char *caption) {
JNIEnv *env = JNI::getEnv();
jstring java_caption = env->NewStringUTF(caption);
@@ -432,6 +449,7 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, getDPI, "([F)V");
FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V");
FIND_METHOD(, openUrl, "(Ljava/lang/String;)V");
+ FIND_METHOD(, isConnectionLimited, "()Z");
FIND_METHOD(, showVirtualKeyboard, "(Z)V");
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h
index de4c95bd76..0798db448a 100644
--- a/backends/platform/android/jni.h
+++ b/backends/platform/android/jni.h
@@ -59,6 +59,7 @@ public:
static void getDPI(float *values);
static void displayMessageOnOSD(const char *msg);
static bool openUrl(const char *url);
+ static bool isConnectionLimited();
static void showVirtualKeyboard(bool enable);
static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
@@ -91,6 +92,7 @@ private:
static jmethodID _MID_getDPI;
static jmethodID _MID_displayMessageOnOSD;
static jmethodID _MID_openUrl;
+ static jmethodID _MID_isConnectionLimited;
static jmethodID _MID_setWindowCaption;
static jmethodID _MID_showVirtualKeyboard;
static jmethodID _MID_getSysArchives;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 50642805a4..47dcb32b22 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -54,6 +54,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
abstract protected void getDPI(float[] values);
abstract protected void displayMessageOnOSD(String msg);
abstract protected void openUrl(String url);
+ abstract protected boolean isConnectionLimited();
abstract protected void setWindowCaption(String caption);
abstract protected void showVirtualKeyboard(boolean enable);
abstract protected String[] getSysArchives();
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 2f3701a557..225496ca0d 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -2,10 +2,13 @@ package org.scummvm.scummvm;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.AudioManager;
import android.net.Uri;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
@@ -80,6 +83,15 @@ public class ScummVMActivity extends Activity {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
+ @Override
+ protected boolean isConnectionLimited() {
+ WifiManager wifiMgr = (WifiManager)getSystemService(Context.WIFI_SERVICE);
+ if (wifiMgr != null && wifiMgr.isWifiEnabled()) {
+ WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
+ return (wifiInfo == null || wifiInfo.getNetworkId() == -1); //WiFi is on, but it's not connected to any network
+ }
+ return true;
+ }
@Override
protected void setWindowCaption(final String caption) {