Merge "Have CaptivePortalTracker use gservices updateable provisioning urls." into jb-mr2-dev

This commit is contained in:
Wink Saville
2013-08-08 22:06:21 +00:00
committed by Android (Google) Code Review
4 changed files with 40 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ import android.os.Message;
import android.os.RemoteException; import android.os.RemoteException;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.android.internal.util.State; import com.android.internal.util.State;
import com.android.internal.util.StateMachine; import com.android.internal.util.StateMachine;
@@ -368,6 +369,7 @@ public class CaptivePortalTracker extends StateMachine {
private void setNotificationVisible(boolean visible) { private void setNotificationVisible(boolean visible) {
// if it should be hidden and it is already hidden, then noop // if it should be hidden and it is already hidden, then noop
if (!visible && !mNotificationShown) { if (!visible && !mNotificationShown) {
if (DBG) log("setNotivicationVisible: false and not shown, so noop");
return; return;
} }
@@ -379,12 +381,14 @@ public class CaptivePortalTracker extends StateMachine {
CharSequence title; CharSequence title;
CharSequence details; CharSequence details;
int icon; int icon;
String url = null;
switch (mNetworkInfo.getType()) { switch (mNetworkInfo.getType()) {
case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_WIFI:
title = r.getString(R.string.wifi_available_sign_in, 0); title = r.getString(R.string.wifi_available_sign_in, 0);
details = r.getString(R.string.network_available_sign_in_detailed, details = r.getString(R.string.network_available_sign_in_detailed,
mNetworkInfo.getExtraInfo()); mNetworkInfo.getExtraInfo());
icon = R.drawable.stat_notify_wifi_in_range; icon = R.drawable.stat_notify_wifi_in_range;
url = mUrl;
break; break;
case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE:
title = r.getString(R.string.network_available_sign_in, 0); title = r.getString(R.string.network_available_sign_in, 0);
@@ -392,12 +396,24 @@ public class CaptivePortalTracker extends StateMachine {
// name has been added to it // name has been added to it
details = mTelephonyManager.getNetworkOperatorName(); details = mTelephonyManager.getNetworkOperatorName();
icon = R.drawable.stat_notify_rssi_in_range; icon = R.drawable.stat_notify_rssi_in_range;
try {
url = mConnService.getMobileProvisioningUrl();
if (TextUtils.isEmpty(url)) {
url = mConnService.getMobileRedirectedProvisioningUrl();
}
} catch(RemoteException e) {
e.printStackTrace();
}
if (TextUtils.isEmpty(url)) {
url = mUrl;
}
break; break;
default: default:
title = r.getString(R.string.network_available_sign_in, 0); title = r.getString(R.string.network_available_sign_in, 0);
details = r.getString(R.string.network_available_sign_in_detailed, details = r.getString(R.string.network_available_sign_in_detailed,
mNetworkInfo.getExtraInfo()); mNetworkInfo.getExtraInfo());
icon = R.drawable.stat_notify_rssi_in_range; icon = R.drawable.stat_notify_rssi_in_range;
url = mUrl;
break; break;
} }
@@ -405,15 +421,17 @@ public class CaptivePortalTracker extends StateMachine {
notification.when = 0; notification.when = 0;
notification.icon = icon; notification.icon = icon;
notification.flags = Notification.FLAG_AUTO_CANCEL; notification.flags = Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUrl)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT |
Intent.FLAG_ACTIVITY_NEW_TASK); Intent.FLAG_ACTIVITY_NEW_TASK);
notification.contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0); notification.contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
notification.tickerText = title; notification.tickerText = title;
notification.setLatestEventInfo(mContext, title, details, notification.contentIntent); notification.setLatestEventInfo(mContext, title, details, notification.contentIntent);
if (DBG) log("setNotivicationVisible: make visible");
notificationManager.notify(NOTIFICATION_ID, 1, notification); notificationManager.notify(NOTIFICATION_ID, 1, notification);
} else { } else {
if (DBG) log("setNotivicationVisible: cancel notification");
notificationManager.cancel(NOTIFICATION_ID, 1); notificationManager.cancel(NOTIFICATION_ID, 1);
} }
mNotificationShown = visible; mNotificationShown = visible;

View File

@@ -1360,7 +1360,7 @@ public class ConnectivityManager {
} }
/** /**
* Get the carrier provisioning url. * Get the mobile provisioning url.
* {@hide} * {@hide}
*/ */
public String getMobileProvisioningUrl() { public String getMobileProvisioningUrl() {
@@ -1370,4 +1370,16 @@ public class ConnectivityManager {
} }
return null; return null;
} }
/**
* Get the mobile redirected provisioning url.
* {@hide}
*/
public String getMobileRedirectedProvisioningUrl() {
try {
return mService.getMobileRedirectedProvisioningUrl();
} catch (RemoteException e) {
}
return null;
}
} }

View File

@@ -136,4 +136,6 @@ interface IConnectivityManager
int checkMobileProvisioning(boolean sendNotification, int suggestedTimeOutMs, in ResultReceiver resultReceiver); int checkMobileProvisioning(boolean sendNotification, int suggestedTimeOutMs, in ResultReceiver resultReceiver);
String getMobileProvisioningUrl(); String getMobileProvisioningUrl();
String getMobileRedirectedProvisioningUrl();
} }

View File

@@ -4103,7 +4103,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
return null; return null;
} }
private String getMobileRedirectedProvisioningUrl() { @Override
public String getMobileRedirectedProvisioningUrl() {
enforceConnectivityInternalPermission();
String url = getProvisioningUrlBaseFromFile(REDIRECTED_PROVISIONING); String url = getProvisioningUrlBaseFromFile(REDIRECTED_PROVISIONING);
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
url = mContext.getResources().getString(R.string.mobile_redirected_provisioning_url); url = mContext.getResources().getString(R.string.mobile_redirected_provisioning_url);
@@ -4111,14 +4113,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
return url; return url;
} }
@Override
public String getMobileProvisioningUrl() { public String getMobileProvisioningUrl() {
enforceConnectivityInternalPermission(); enforceConnectivityInternalPermission();
String url = getProvisioningUrlBaseFromFile(PROVISIONING); String url = getProvisioningUrlBaseFromFile(PROVISIONING);
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
url = mContext.getResources().getString(R.string.mobile_provisioning_url); url = mContext.getResources().getString(R.string.mobile_provisioning_url);
log("getProvisioningUrl: mobile_provisioining_url from resource =" + url); log("getMobileProvisioningUrl: mobile_provisioining_url from resource =" + url);
} else { } else {
log("getProvisioningUrl: mobile_provisioning_url from File =" + url); log("getMobileProvisioningUrl: mobile_provisioning_url from File =" + url);
} }
// populate the iccid, imei and phone number in the provisioning url. // populate the iccid, imei and phone number in the provisioning url.
if (!TextUtils.isEmpty(url)) { if (!TextUtils.isEmpty(url)) {