Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c3e1df7 authored by Andrew Flynn's avatar Andrew Flynn
Browse files

Check for presence of carrier app in data notification.

When ConnectivityService checks the mobile data connection and notices that
there is no connectivity, first do a check to see if a valid carrier app for
the current MCC/MNC exists. If so, launch that app instead of checking for a
provisioning URL or hoping for a DNS redirect in the browser. If no such app
exists, continue on as normal.

Bug: 9622645
Change-Id: Ic88b06250af89825d8eee7e4945fb8d7c28d16e1
parent 5aa495cb
Loading
Loading
Loading
Loading
+22 −9
Original line number Original line Diff line number Diff line
@@ -111,6 +111,7 @@ import com.android.internal.net.VpnProfile;
import com.android.internal.telephony.DctConstants;
import com.android.internal.telephony.DctConstants;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.XmlUtils;
import com.android.server.am.BatteryStatsService;
import com.android.server.am.BatteryStatsService;
@@ -4434,6 +4435,17 @@ public class ConnectivityService extends IConnectivityManager.Stub {
            mdst.enableMobileProvisioning(url);
            mdst.enableMobileProvisioning(url);
        } else {
        } else {
            if (DBG) log("handleMobileProvisioningAction: on default network");
            if (DBG) log("handleMobileProvisioningAction: on default network");
            // Check for  apps that can handle provisioning first
            Intent provisioningIntent = new Intent(TelephonyIntents.ACTION_CARRIER_SETUP);
            provisioningIntent.addCategory(TelephonyIntents.CATEGORY_MCCMNC_PREFIX
                    + mTelephonyManager.getSimOperator());
            if (mContext.getPackageManager().resolveActivity(provisioningIntent, 0 /* flags */)
                    != null) {
                provisioningIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT |
                        Intent.FLAG_ACTIVITY_NEW_TASK);
                mContext.startActivity(provisioningIntent);
            } else {
                // If no apps exist, use standard URL ACTION_VIEW method
                Intent newIntent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
                Intent newIntent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
                        Intent.CATEGORY_APP_BROWSER);
                        Intent.CATEGORY_APP_BROWSER);
                newIntent.setData(Uri.parse(url));
                newIntent.setData(Uri.parse(url));
@@ -4446,6 +4458,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                }
                }
            }
            }
        }
        }
    }


    private static final String NOTIFICATION_ID = "CaptivePortal.Notification";
    private static final String NOTIFICATION_ID = "CaptivePortal.Notification";
    private volatile boolean mIsNotificationVisible = false;
    private volatile boolean mIsNotificationVisible = false;