summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaiyiz <kaiyiz@codeaurora.org>2013-08-26 17:50:22 +0800
committerkaiyiz <kaiyiz@codeaurora.org>2013-08-30 13:37:29 +0800
commita016da1107a5ad73f373380434ce45337013f44c (patch)
tree4d7270f5aa2bdfe477f0553c597bda47483ff901
parent4ed90ebeb4d20be36fbd77938eb8d9283b850902 (diff)
downloadandroid_packages_apps_Gello-a016da1107a5ad73f373380434ce45337013f44c.tar.gz
android_packages_apps_Gello-a016da1107a5ad73f373380434ce45337013f44c.tar.bz2
android_packages_apps_Gello-a016da1107a5ad73f373380434ce45337013f44c.zip
Browser: Alert user to choose network when surfing with both
mobile and WLAN available - Pop up one activity for user to choose the network type if both mobile and WLAN networks are available when surfing internet. CRs-Fixed: 507965 Change-Id: I10913afeaa37d1c95b82ab55dd6e53dcce6e48bd
-rw-r--r--res/values/integers.xml1
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/com/android/browser/Controller.java66
3 files changed, 65 insertions, 3 deletions
diff --git a/res/values/integers.xml b/res/values/integers.xml
index 5f757238..9fd97b23 100644
--- a/res/values/integers.xml
+++ b/res/values/integers.xml
@@ -30,4 +30,5 @@
<integer name="max_bookmark_columns">5</integer>
<!-- The duration of the titlebar animation in millisecs -->
<integer name="titlebar_animation_duration">200</integer>
+ <integer name="netswitch_type_remind">1</integer>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2aa0ddb5..1b7fe73b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1075,4 +1075,5 @@
<string name="download_path_unavailable_dlg_title">Download Directory Unavailable</string>
<string name="download_path_unavailable_dlg_msg">Please modify the Download Directory of Browser</string>
<string name="activity_not_found">Activity Not Found to Handle Intent <xliff:g id="NOACTIVITY">%s</xliff:g>.</string>
+ <string name="network_switch_remind_type">wifi_browser_interaction_remind</string>
</resources>
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 3094595b..729e79ea 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -39,8 +39,11 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.net.Uri;
import android.net.http.SslError;
+import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
@@ -55,6 +58,7 @@ import android.provider.BrowserContract;
import android.provider.BrowserContract.Images;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Intents.Insert;
+import android.provider.Settings;
import android.speech.RecognizerIntent;
import android.text.TextUtils;
import android.util.Log;
@@ -113,7 +117,9 @@ public class Controller
private static final String SEND_APP_ID_EXTRA =
"android.speech.extras.SEND_APPLICATION_ID_EXTRA";
private static final String INCOGNITO_URI = "browser:incognito";
-
+ private static final String PROP_NETSWITCH = "persist.env.browser.netswitch";
+ private static final String INTENT_WIFI_SELECTION_DATA_CONNECTION =
+ "android.net.wifi.cmcc.WIFI_SELECTION_DATA_CONNECTION";
// public message ids
public final static int LOAD_URL = 1001;
@@ -175,6 +181,7 @@ public class Controller
private Message mAutoFillSetupMessage;
private boolean mShouldShowErrorConsole;
+ private boolean mNetworkShouldNotify = true;
private SystemAllowGeolocationOrigins mSystemAllowGeolocationOrigins;
@@ -827,6 +834,41 @@ public class Controller
return mLoadStopped;
}
+ private void handleNetworkNotify(WebView view) {
+ ConnectivityManager conMgr = (ConnectivityManager) this.getContext().getSystemService(
+ Context.CONNECTIVITY_SERVICE);
+ WifiManager wifiMgr = (WifiManager) this.getContext()
+ .getSystemService(Context.WIFI_SERVICE);
+ int networkSwitchTypeOK = this.getContext().getResources()
+ .getInteger(R.integer.netswitch_type_remind);
+
+ if (wifiMgr.isWifiEnabled()) {
+ NetworkInfo mNetworkInfo = conMgr.getActiveNetworkInfo();
+ if (mNetworkInfo == null
+ || (mNetworkInfo != null && (mNetworkInfo.getType() !=
+ ConnectivityManager.TYPE_WIFI))) {
+ int isReminder = Settings.System.getInt(
+ mActivity.getContentResolver(),
+ this.getContext().getResources()
+ .getString(R.string.network_switch_remind_type),
+ networkSwitchTypeOK);
+
+ if (isReminder == networkSwitchTypeOK) {
+ Intent intent = new Intent(
+ INTENT_WIFI_SELECTION_DATA_CONNECTION);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ this.getContext().startActivity(intent);
+ }
+ mNetworkShouldNotify = false;
+ }
+ } else {
+ if (!mNetworkHandler.isNetworkUp()) {
+ view.setNetworkAvailable(false);
+ Log.v(LOGTAG, "handleNetworkNotify() Wlan is not enabled.");
+ }
+ }
+ }
+
// WebViewController
@Override
@@ -842,8 +884,26 @@ public class Controller
// reset sync timer to avoid sync starts during loading a page
CookieSyncManager.getInstance().resetSync();
- if (!mNetworkHandler.isNetworkUp()) {
- view.setNetworkAvailable(false);
+ if (SystemProperties.getBoolean(PROP_NETSWITCH, false)) {
+ if (!mNetworkHandler.isNetworkUp()) {
+ Log.d(LOGTAG, "onPageStarted() network unavailable");
+ if (mNetworkShouldNotify) {
+ handleNetworkNotify(view);
+ } else {
+ view.setNetworkAvailable(false);
+ }
+ mNetworkShouldNotify = false;
+ } else {
+ Log.d(LOGTAG, "onPageStarted() network available");
+ if (mNetworkShouldNotify) {
+ handleNetworkNotify(view);
+ }
+ mNetworkShouldNotify = false;
+ }
+ } else {
+ if (!mNetworkHandler.isNetworkUp()) {
+ view.setNetworkAvailable(false);
+ }
}
// when BrowserActivity just starts, onPageStarted may be called before