aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-19 18:43:00 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita13e03e988f85a67366f2ffe39bae67576e425bc (patch)
tree5c41114e9bc54ca203877c76d48bb245d1b653c0
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).
-rw-r--r--backends/module.mk63
-rw-r--r--backends/networking/connection/islimited-android.cpp35
-rw-r--r--backends/networking/connection/islimited-default.cpp36
-rw-r--r--backends/networking/connection/islimited.h34
-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
-rw-r--r--dists/android/AndroidManifest.xml2
-rw-r--r--dists/android/AndroidManifest.xml.in2
10 files changed, 184 insertions, 21 deletions
diff --git a/backends/module.mk b/backends/module.mk
index aea0f77d08..d227f41eec 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -162,14 +162,17 @@ MODULE_OBJS += \
ifeq ($(BACKEND),android)
MODULE_OBJS += \
- networking/browser/openurl-android.o
+ networking/browser/openurl-android.o \
+ networking/connection/islimited-android.o
else
ifdef MACOSX
MODULE_OBJS += \
- networking/browser/openurl-osx.o
+ networking/browser/openurl-osx.o \
+ networking/connection/islimited-default.o
else
MODULE_OBJS += \
- networking/browser/openurl-posix.o
+ networking/browser/openurl-posix.o \
+ networking/connection/islimited-default.o
endif
endif
endif
@@ -193,14 +196,16 @@ MODULE_OBJS += \
saves/windows/windows-saves.o \
updates/win32/win32-updates.o \
taskbar/win32/win32-taskbar.o \
- networking/browser/openurl-windows.o
+ networking/browser/openurl-windows.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),androidsdl)
MODULE_OBJS += \
events/androidsdl/androidsdl-events.o \
graphics/androidsdl/androidsdl-graphics.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifdef AMIGAOS
@@ -208,7 +213,8 @@ MODULE_OBJS += \
fs/amigaos4/amigaos4-fs.o \
fs/amigaos4/amigaos4-fs-factory.o \
midi/camd.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifdef PLAYSTATION3
@@ -217,7 +223,8 @@ MODULE_OBJS += \
fs/posix/posix-fs-factory.o \
fs/ps3/ps3-fs-factory.o \
events/ps3sdl/ps3sdl-events.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifdef USE_LINUXCD
@@ -228,7 +235,8 @@ endif
ifeq ($(BACKEND),tizen)
MODULE_OBJS += \
timer/tizen/timer.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),ds)
@@ -236,35 +244,40 @@ MODULE_OBJS += \
fs/ds/ds-fs.o \
fs/ds/ds-fs-factory.o \
plugins/ds/ds-provider.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),dingux)
MODULE_OBJS += \
events/dinguxsdl/dinguxsdl-events.o \
graphics/dinguxsdl/dinguxsdl-graphics.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),gph)
MODULE_OBJS += \
events/gph/gph-events.o \
graphics/gph/gph-graphics.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),linuxmoto)
MODULE_OBJS += \
events/linuxmotosdl/linuxmotosdl-events.o \
graphics/linuxmotosdl/linuxmotosdl-graphics.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),maemo)
MODULE_OBJS += \
events/maemosdl/maemosdl-events.o \
graphics/maemosdl/maemosdl-graphics.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),n64)
@@ -272,14 +285,16 @@ MODULE_OBJS += \
fs/n64/n64-fs.o \
fs/n64/n64-fs-factory.o \
fs/n64/romfsstream.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),openpandora)
MODULE_OBJS += \
events/openpandora/op-events.o \
graphics/openpandora/op-graphics.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),ps2)
@@ -287,7 +302,8 @@ MODULE_OBJS += \
fs/ps2/ps2-fs.o \
fs/ps2/ps2-fs-factory.o \
plugins/ps2/ps2-provider.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),psp)
@@ -298,20 +314,23 @@ MODULE_OBJS += \
plugins/psp/psp-provider.o \
saves/psp/psp-saves.o \
timer/psp/timer.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),samsungtv)
MODULE_OBJS += \
events/samsungtvsdl/samsungtvsdl-events.o \
graphics/samsungtvsdl/samsungtvsdl-graphics.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),webos)
MODULE_OBJS += \
events/webossdl/webossdl-events.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),wince)
@@ -322,7 +341,8 @@ MODULE_OBJS += \
graphics/wincesdl/wincesdl-graphics.o \
mixer/wincesdl/wincesdl-mixer.o \
plugins/win32/win32-provider.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifeq ($(BACKEND),wii)
@@ -330,7 +350,8 @@ MODULE_OBJS += \
fs/wii/wii-fs.o \
fs/wii/wii-fs-factory.o \
plugins/wii/wii-provider.o \
- networking/browser/openurl-default.o
+ networking/browser/openurl-default.o \
+ networking/connection/islimited-default.o
endif
ifdef ENABLE_EVENTRECORDER
diff --git a/backends/networking/connection/islimited-android.cpp b/backends/networking/connection/islimited-android.cpp
new file mode 100644
index 0000000000..8989f218ec
--- /dev/null
+++ b/backends/networking/connection/islimited-android.cpp
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/networking/connection/islimited.h"
+#include "backends/platform/android/jni.h"
+
+namespace Networking {
+namespace Connection {
+
+bool isLimited() {
+ return JNI::isConnectionLimited();
+}
+
+} // End of namespace Connection
+} // End of namespace Networking
+
diff --git a/backends/networking/connection/islimited-default.cpp b/backends/networking/connection/islimited-default.cpp
new file mode 100644
index 0000000000..a993077fff
--- /dev/null
+++ b/backends/networking/connection/islimited-default.cpp
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/networking/connection/islimited.h"
+#include "common/textconsole.h"
+
+namespace Networking {
+namespace Connection {
+
+bool isLimited() {
+ warning("Networking::Connection::isLimited(): not limited by default");
+ return false;
+}
+
+} // End of namespace Connection
+} // End of namespace Networking
+
diff --git a/backends/networking/connection/islimited.h b/backends/networking/connection/islimited.h
new file mode 100644
index 0000000000..69be26701c
--- /dev/null
+++ b/backends/networking/connection/islimited.h
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef NETWORKING_CONNECTION_ISLIMITED_H
+#define NETWORKING_CONNECTION_ISLIMITED_H
+
+namespace Networking {
+namespace Connection {
+
+bool isLimited();
+
+} // End of namespace Connection
+} // End of namespace Networking
+
+#endif /*NETWORKING_CONNECTION_ISLIMITED_H*/
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) {
diff --git a/dists/android/AndroidManifest.xml b/dists/android/AndroidManifest.xml
index c091039266..64870a459b 100644
--- a/dists/android/AndroidManifest.xml
+++ b/dists/android/AndroidManifest.xml
@@ -40,6 +40,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" android:required="true"/>
+
<uses-feature android:name="android.hardware.screen.landscape"
android:required="false" />
diff --git a/dists/android/AndroidManifest.xml.in b/dists/android/AndroidManifest.xml.in
index 7eaece9d1f..9601425c74 100644
--- a/dists/android/AndroidManifest.xml.in
+++ b/dists/android/AndroidManifest.xml.in
@@ -40,6 +40,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" android:required="true"/>
+
<uses-feature android:name="android.hardware.screen.landscape"
android:required="false" />