正在查看: fieldd v4.2.4 应用的 LaunchNavigator.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: fieldd v4.2.4 应用的 LaunchNavigator.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package uk.co.workingedge;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import com.marianhello.bgloc.data.sqlite.SQLiteLocationContract;
import com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper;
import io.reactivex.annotations.SchedulerSupport;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.andremoniy.sqlbuilder.SqlExpression;
public class LaunchNavigator {
public static final String LOG_TAG = "LaunchNavigator";
public final String GEO_URI;
Map<String, String> availableApps;
Context context;
boolean geocodingEnabled;
String googleApiKey;
OkHttpClient httpClient;
ILogger logger;
private final String[] navigateParams;
PackageManager packageManager;
public final Map<String, String> supportedAppNames;
public final Map<String, String> supportedAppPackages;
public final String NO_APP_FOUND = "No Activity found to handle Intent";
public final String MAPS_PROTOCOL = "http://maps.google.com/maps?";
public final String TURN_BY_TURN_PROTOCOL = "google.navigation:";
public final String GEO = "geo";
public final String GOOGLE_MAPS = "google_maps";
public final String CITYMAPPER = "citymapper";
public final String UBER = "uber";
public final String WAZE = "waze";
public final String YANDEX = "yandex";
public final String SYGIC = "sygic";
public final String HERE_MAPS = "here_maps";
public final String MOOVIT = "moovit";
public final String LYFT = "lyft";
public final String MAPS_ME = "maps_me";
public final String CABIFY = "cabify";
public final String BAIDU = "baidu";
public final String TAXIS_99 = "taxis_99";
public final String GAODE = "gaode";
public LaunchNavigator(Context context, ILogger iLogger) throws Exception {
HashMap hashMap = new HashMap();
hashMap.put("google_maps", "com.google.android.apps.maps");
hashMap.put("citymapper", "com.citymapper.app.release");
hashMap.put("uber", "com.ubercab");
hashMap.put("waze", "com.waze");
hashMap.put("yandex", "ru.yandex.yandexnavi");
hashMap.put("sygic", "com.sygic.aura");
hashMap.put("here_maps", "com.here.app.maps");
hashMap.put("moovit", "com.tranzmate");
hashMap.put("lyft", "me.lyft.android");
hashMap.put("maps_me", "com.mapswithme.maps.pro");
hashMap.put("cabify", "com.cabify.rider");
hashMap.put("baidu", "com.baidu.BaiduMap");
hashMap.put("taxis_99", "com.taxis99");
hashMap.put("gaode", "com.autonavi.minimap");
this.supportedAppPackages = Collections.unmodifiableMap(hashMap);
HashMap hashMap2 = new HashMap();
hashMap2.put("google_maps", "Google Maps");
hashMap2.put("citymapper", "Citymapper");
hashMap2.put("uber", "Uber");
hashMap2.put("waze", "Waze");
hashMap2.put("yandex", "Yandex Navigator");
hashMap2.put("sygic", "Sygic");
hashMap2.put("here_maps", "HERE Maps");
hashMap2.put("moovit", "Moovit");
hashMap2.put("lyft", "Lyft");
hashMap2.put("maps_me", "MAPS.ME");
hashMap2.put("cabify", "Cabify");
hashMap2.put("baidu", "Baidu Maps");
hashMap2.put("taxis_99", "99 Taxi");
hashMap2.put("gaode", "Gaode Maps (Amap)");
this.supportedAppNames = Collections.unmodifiableMap(hashMap2);
this.GEO_URI = "geo:";
this.geocodingEnabled = true;
this.httpClient = new OkHttpClient();
this.navigateParams = new String[]{"app", "dType", "dest", "destNickname", "sType", "start", "startNickname", "transportMode", "launchMode", "extras"};
this.googleApiKey = null;
setLogger(iLogger);
initialize(context);
}
public LaunchNavigator(Context context, ILogger iLogger, boolean z) throws Exception {
HashMap hashMap = new HashMap();
hashMap.put("google_maps", "com.google.android.apps.maps");
hashMap.put("citymapper", "com.citymapper.app.release");
hashMap.put("uber", "com.ubercab");
hashMap.put("waze", "com.waze");
hashMap.put("yandex", "ru.yandex.yandexnavi");
hashMap.put("sygic", "com.sygic.aura");
hashMap.put("here_maps", "com.here.app.maps");
hashMap.put("moovit", "com.tranzmate");
hashMap.put("lyft", "me.lyft.android");
hashMap.put("maps_me", "com.mapswithme.maps.pro");
hashMap.put("cabify", "com.cabify.rider");
hashMap.put("baidu", "com.baidu.BaiduMap");
hashMap.put("taxis_99", "com.taxis99");
hashMap.put("gaode", "com.autonavi.minimap");
this.supportedAppPackages = Collections.unmodifiableMap(hashMap);
HashMap hashMap2 = new HashMap();
hashMap2.put("google_maps", "Google Maps");
hashMap2.put("citymapper", "Citymapper");
hashMap2.put("uber", "Uber");
hashMap2.put("waze", "Waze");
hashMap2.put("yandex", "Yandex Navigator");
hashMap2.put("sygic", "Sygic");
hashMap2.put("here_maps", "HERE Maps");
hashMap2.put("moovit", "Moovit");
hashMap2.put("lyft", "Lyft");
hashMap2.put("maps_me", "MAPS.ME");
hashMap2.put("cabify", "Cabify");
hashMap2.put("baidu", "Baidu Maps");
hashMap2.put("taxis_99", "99 Taxi");
hashMap2.put("gaode", "Gaode Maps (Amap)");
this.supportedAppNames = Collections.unmodifiableMap(hashMap2);
this.GEO_URI = "geo:";
this.geocodingEnabled = true;
this.httpClient = new OkHttpClient();
this.navigateParams = new String[]{"app", "dType", "dest", "destNickname", "sType", "start", "startNickname", "transportMode", "launchMode", "extras"};
this.googleApiKey = null;
this.geocodingEnabled = z;
setLogger(iLogger);
initialize(context);
}
public void setGoogleApiKey(String str) {
this.googleApiKey = str;
}
public void setLogger(ILogger iLogger) {
this.logger = iLogger;
}
public ILogger getLogger() {
return this.logger;
}
public void setGeocoding(boolean z) {
this.geocodingEnabled = z;
}
public JSONObject getGeoApps() throws JSONException {
JSONObject jSONObject = new JSONObject();
for (Map.Entry<String, String> entry : this.availableApps.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (!this.supportedAppPackages.containsValue(value)) {
jSONObject.put(key, value);
}
}
return jSONObject;
}
public JSONObject getAvailableApps() throws Exception {
JSONObject jSONObject = new JSONObject();
discoverAvailableApps();
for (Map.Entry<String, String> entry : this.supportedAppPackages.entrySet()) {
jSONObject.put(entry.getKey(), this.availableApps.containsValue(entry.getValue()));
}
Iterator<Map.Entry<String, String>> it = this.availableApps.entrySet().iterator();
while (it.hasNext()) {
String value = it.next().getValue();
if (!jSONObject.has(value) && !this.supportedAppPackages.containsValue(value)) {
jSONObject.put(value, true);
}
}
return jSONObject;
}
public boolean isAppAvailable(String str) {
discoverAvailableApps();
if (this.supportedAppPackages.containsKey(str)) {
str = this.supportedAppPackages.get(str);
}
return this.availableApps.containsValue(str);
}
public String navigate(JSONObject jSONObject) throws Exception {
JSONObject ensureNavigateKeys = ensureNavigateKeys(jSONObject);
String str = "Called navigate() with params";
for (String str2 : this.navigateParams) {
str = str + "; " + str2 + SqlExpression.SqlOperatorEqualTo + ensureNavigateKeys.getString(str2);
}
this.logger.debug(str);
String string = ensureNavigateKeys.getString("app");
String string2 = ensureNavigateKeys.getString("launchMode");
if (string.equals("google_maps") && !string2.equals("geo")) {
return launchGoogleMaps(ensureNavigateKeys);
}
if (string.equals("citymapper")) {
return launchCitymapper(ensureNavigateKeys);
}
if (string.equals("uber")) {
return launchUber(ensureNavigateKeys);
}
if (string.equals("waze")) {
return launchWaze(ensureNavigateKeys);
}
if (string.equals("yandex")) {
return launchYandex(ensureNavigateKeys);
}
if (string.equals("sygic")) {
return launchSygic(ensureNavigateKeys);
}
if (string.equals("here_maps")) {
return launchHereMaps(ensureNavigateKeys);
}
if (string.equals("moovit")) {
return launchMoovit(ensureNavigateKeys);
}
if (string.equals("lyft")) {
return launchLyft(ensureNavigateKeys);
}
if (string.equals("maps_me")) {
return launchMapsMe(ensureNavigateKeys);
}
if (string.equals("cabify")) {
return launchCabify(ensureNavigateKeys);
}
if (string.equals("baidu")) {
return launchBaidu(ensureNavigateKeys);
}
if (string.equals("gaode")) {
return launchGaode(ensureNavigateKeys);
}
if (string.equals("taxis_99")) {
return launch99Taxis(ensureNavigateKeys);
}
return launchApp(ensureNavigateKeys);
}
private void initialize(Context context) throws Exception {
if (context == null) {
throw new Exception("LaunchNavigator: null context passed to initialize()");
}
this.context = context;
this.packageManager = context.getPackageManager();
discoverAvailableApps();
}
private void discoverAvailableApps() {
List<ResolveInfo> queryIntentActivities = this.packageManager.queryIntentActivities(new Intent("android.intent.action.VIEW", Uri.parse("geo:")), 0);
this.availableApps = new HashMap();
Iterator<ResolveInfo> it = queryIntentActivities.iterator();
while (it.hasNext()) {
String str = it.next().activityInfo.packageName;
String appName = getAppName(str);
if (!this.supportedAppPackages.containsValue(str)) {
this.logger.debug("Found available app supporting geo protocol: " + appName + " (" + str + SqlExpression.SqlEnclosureClosingBrace);
this.availableApps.put(appName, str);
}
}
for (Map.Entry<String, String> entry : this.supportedAppPackages.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (isPackageInstalled(value, this.packageManager)) {
this.availableApps.put(this.supportedAppNames.get(key), value);
this.logger.debug(key + " is available");
} else {
this.logger.debug(key + " is not available");
}
}
}
private String launchApp(JSONObject jSONObject) throws Exception {
String locationFromPos;
String str;
String str2;
String string = jSONObject.getString("app");
String string2 = jSONObject.getString("dType");
String string3 = jSONObject.getString("destNickname");
String str3 = "Using " + getAppDisplayName(string) + " to navigate to ";
if (string2.equals("name")) {
str2 = getLocationFromName(jSONObject, "dest");
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
str = str3 + str2;
if (!isNull(locationFromPos)) {
str = str + "[" + locationFromPos + "]";
}
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
locationFromPos = getLocationFromPos(jSONObject, "dest");
str = str3 + "[" + locationFromPos + "]";
str2 = null;
}
if (!isNull(locationFromPos)) {
str2 = locationFromPos;
}
String str4 = "geo:" + locationFromPos + "?q=" + str2;
if (!isNull(string3)) {
str4 = str4 + SqlExpression.SqlEnclosureOpeningBrace + string3 + SqlExpression.SqlEnclosureClosingBrace;
str = str + SqlExpression.SqlEnclosureOpeningBrace + string3 + SqlExpression.SqlEnclosureClosingBrace;
}
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (!isNull(parseExtrasToUrl)) {
str4 = str4 + parseExtrasToUrl;
str = str + " - extras=" + parseExtrasToUrl;
}
this.logger.debug(str);
this.logger.debug("URI: " + str4);
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str4));
if (!string.equals("geo")) {
if (string.equals("google_maps")) {
string = this.supportedAppPackages.get("google_maps");
}
intent.setPackage(string);
}
invokeIntent(intent);
return null;
}
private String launchGoogleMaps(JSONObject jSONObject) throws Exception {
String str;
String str2;
String str3;
try {
String locationFromPos = jSONObject.getString("dType").equals("pos") ? getLocationFromPos(jSONObject, "dest") : getLocationFromName(jSONObject, "dest");
String string = jSONObject.getString("sType");
String locationFromPos2 = string.equals("pos") ? getLocationFromPos(jSONObject, "start") : string.equals("name") ? getLocationFromName(jSONObject, "start") : null;
String string2 = jSONObject.getString("transportMode");
String str4 = "Using Google Maps to navigate to " + locationFromPos;
if (jSONObject.getString("launchMode").equals("turn-by-turn")) {
str2 = "google.navigation:q=" + locationFromPos;
if (!isNull(string2)) {
str4 = str4 + " by transportMode=" + string2;
str2 = str2 + "&mode=" + string2;
}
str3 = str4 + " in turn-by-turn mode";
} else {
String str5 = "http://maps.google.com/maps?daddr=" + locationFromPos;
if (isNull(locationFromPos2)) {
str = str4 + " from current location";
str2 = str5;
} else {
str = str4 + " from " + locationFromPos2;
str2 = str5 + "&saddr=" + locationFromPos2;
}
str3 = str + " in maps mode";
}
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (!isNull(parseExtrasToUrl)) {
str2 = str2 + parseExtrasToUrl;
str3 = str3 + " - extras=" + parseExtrasToUrl;
}
this.logger.debug(str3);
this.logger.debug("URI: " + str2);
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str2));
intent.setClassName(this.supportedAppPackages.get("google_maps"), "com.google.android.maps.MapsActivity");
invokeIntent(intent);
return null;
} catch (JSONException e) {
String message = e.getMessage();
if (message.contains("No Activity found to handle Intent")) {
message = "Google Maps app is not installed on this device";
}
this.logger.error("Exception occurred: ".concat(message));
return message;
}
}
private java.lang.String launchCitymapper(org.json.JSONObject r23) throws java.lang.Exception {
throw new UnsupportedOperationException("Method not decompiled: uk.co.workingedge.LaunchNavigator.launchCitymapper(org.json.JSONObject):java.lang.String");
}
private java.lang.String launchUber(org.json.JSONObject r18) throws java.lang.Exception {
throw new UnsupportedOperationException("Method not decompiled: uk.co.workingedge.LaunchNavigator.launchUber(org.json.JSONObject):java.lang.String");
}
private String launchWaze(JSONObject jSONObject) throws Exception {
String locationFromPos;
String str;
String str2;
String str3;
try {
if (jSONObject.getString("dType").equals("name")) {
str = getLocationFromName(jSONObject, "dest");
locationFromPos = null;
} else {
locationFromPos = getLocationFromPos(jSONObject, "dest");
str = null;
}
if (!isNull(locationFromPos)) {
str2 = "waze://?ll=" + locationFromPos;
str3 = "Using Waze to navigate to [" + locationFromPos + "]";
} else {
str2 = "waze://?q=" + str;
str3 = "Using Waze to navigate to '" + str + "'";
}
String str4 = str2 + "&navigate=yes";
String str5 = str3 + " from current location";
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (!isNull(parseExtrasToUrl)) {
str4 = str4 + parseExtrasToUrl;
str5 = str5 + " - extras=" + parseExtrasToUrl;
}
this.logger.debug(str5);
this.logger.debug("URI: " + str4);
invokeIntent(new Intent("android.intent.action.VIEW", Uri.parse(str4)));
return null;
} catch (JSONException e) {
String message = e.getMessage();
return message.contains("No Activity found to handle Intent") ? "Waze app is not installed on this device" : message;
}
}
private String launchYandex(JSONObject jSONObject) throws Exception {
String locationFromPos;
String str;
String str2;
String str3;
String str4;
try {
String string = jSONObject.getString("dType");
String string2 = jSONObject.getString("sType");
if (string.equals("name")) {
str = getLocationFromName(jSONObject, "dest");
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
locationFromPos = getLocationFromPos(jSONObject, "dest");
str = null;
}
if (string2.equals("name")) {
str2 = getLocationFromName(jSONObject, "start");
try {
str3 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception e2) {
return "Unable to geocode start address to coordinates: " + e2.getMessage();
}
} else if (string2.equals("pos")) {
str3 = getLocationFromPos(jSONObject, "start");
str2 = null;
} else {
str2 = null;
str3 = null;
}
Intent intent = new Intent(this.supportedAppPackages.get("yandex") + ".action.BUILD_ROUTE_ON_MAP");
intent.setPackage(this.supportedAppPackages.get("yandex"));
String[] splitLatLon = splitLatLon(locationFromPos);
intent.putExtra("lat_to", splitLatLon[0]);
intent.putExtra("lon_to", splitLatLon[1]);
String str5 = "Using Yandex to navigate to [" + locationFromPos + "]";
if (!isNull(str)) {
str5 = str5 + " ('" + str + "')";
}
String str6 = str5 + " from";
if (string2.equals(SchedulerSupport.NONE)) {
str4 = str6 + " current location";
} else {
String[] splitLatLon2 = splitLatLon(str3);
intent.putExtra("lat_from", splitLatLon2[0]);
intent.putExtra("lon_from", splitLatLon2[1]);
str4 = str6 + " [" + str3 + "]";
if (!isNull(str2)) {
str4 = str4 + " ('" + str2 + "')";
}
}
String string3 = jSONObject.getString("extras");
JSONObject jSONObject2 = !isNull(string3) ? new JSONObject(string3) : null;
if (jSONObject2 != null) {
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String next = keys.next();
intent.putExtra(next, jSONObject2.getString(next));
}
}
this.logger.debug(str4);
invokeIntent(intent);
return null;
} catch (JSONException e3) {
String message = e3.getMessage();
return message.contains("No Activity found to handle Intent") ? "Yandex app is not installed on this device" : message;
}
}
private String launchSygic(JSONObject jSONObject) throws Exception {
String locationFromPos;
try {
String string = jSONObject.getString("dType");
String string2 = jSONObject.getString("transportMode");
String str = this.supportedAppPackages.get("sygic") + "://coordinate|";
String str2 = "Using Sygic to navigate to";
String str3 = string2.equals("w") ? "walk" : "drive";
if (string.equals("name")) {
str2 = "Using Sygic to navigate to '" + getLocationFromName(jSONObject, "dest") + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
locationFromPos = getLocationFromPos(jSONObject, "dest");
}
String str4 = str2 + " [" + locationFromPos + "]";
String[] splitLatLon = splitLatLon(locationFromPos);
String str5 = str + splitLatLon[1] + SqlExpression.SqlOperatorBitwiseOr + splitLatLon[0] + SqlExpression.SqlOperatorBitwiseOr + str3;
String str6 = str4 + " by " + str3;
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (!isNull(parseExtrasToUrl)) {
str5 = str5 + parseExtrasToUrl;
str6 = str6 + " - extras=" + parseExtrasToUrl;
}
this.logger.debug(str6);
this.logger.debug("URI: " + str5);
invokeIntent(new Intent("android.intent.action.VIEW", Uri.parse(str5)));
return null;
} catch (JSONException e2) {
String message = e2.getMessage();
return message.contains("No Activity found to handle Intent") ? "Sygic app is not installed on this device" : message;
}
}
private String launchHereMaps(JSONObject jSONObject) throws Exception {
Object obj;
String str;
String str2;
String str3;
String str4;
String locationFromPos;
try {
String string = jSONObject.getString("destNickname");
String string2 = jSONObject.getString("startNickname");
String string3 = jSONObject.getString("dType");
String string4 = jSONObject.getString("sType");
if (string4.equals(SchedulerSupport.NONE)) {
str3 = "https://share.here.com/r/mylocation";
str4 = "Using HERE Maps to navigate from Current Location";
obj = "name";
} else {
obj = "name";
if (string4.equals("name")) {
str = "Using HERE Maps to navigate from '" + getLocationFromName(jSONObject, "start") + "'";
try {
str2 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception e) {
return "Unable to geocode start address to coordinates: " + e.getMessage();
}
} else if (!string4.equals("pos")) {
str = "Using HERE Maps to navigate from";
str2 = null;
} else {
str2 = getLocationFromPos(jSONObject, "start");
str = "Using HERE Maps to navigate from";
}
str3 = "https://share.here.com/r/" + str2;
str4 = str + " [" + str2 + "]";
if (!isNull(string2)) {
str3 = str3 + SQLiteOpenHelper.COMMA_SEP + string2;
str4 = str4 + " (" + string2 + SqlExpression.SqlEnclosureClosingBrace;
}
}
String str5 = str3 + SqlExpression.SqlOperatorDivide;
String str6 = str4 + " to";
if (string3.equals(obj)) {
str6 = str6 + " '" + getLocationFromName(jSONObject, "dest") + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e2) {
return "Unable to geocode destination address to coordinates: " + e2.getMessage();
}
} else {
locationFromPos = getLocationFromPos(jSONObject, "dest");
}
String str7 = str6 + " [" + locationFromPos + "]";
String str8 = str5 + locationFromPos;
if (!isNull(string)) {
str8 = str8 + SQLiteOpenHelper.COMMA_SEP + string;
str7 = str7 + " (" + string + SqlExpression.SqlEnclosureClosingBrace;
}
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (!isNull(parseExtrasToUrl)) {
str8 = str8 + "?" + parseExtrasToUrl;
str7 = str7 + " - extras=" + parseExtrasToUrl;
}
this.logger.debug(str7);
this.logger.debug("URI: " + str8);
invokeIntent(new Intent("android.intent.action.VIEW", Uri.parse(str8)));
return null;
} catch (JSONException e3) {
String message = e3.getMessage();
return message.contains("No Activity found to handle Intent") ? "HERE Maps app is not installed on this device" : message;
}
}
private String launchMoovit(JSONObject jSONObject) throws Exception {
String str;
String locationFromPos;
String str2;
String locationFromPos2;
String str3;
try {
String string = jSONObject.getString("destNickname");
String string2 = jSONObject.getString("startNickname");
String string3 = jSONObject.getString("dType");
String string4 = jSONObject.getString("sType");
if (string3.equals("name")) {
str = "URI: ";
String str4 = "Using Moovit to navigate to '" + getLocationFromName(jSONObject, "dest") + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
str2 = str4;
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
str = "URI: ";
locationFromPos = getLocationFromPos(jSONObject, "dest");
str2 = "Using Moovit to navigate to";
}
String str5 = str2 + " [" + locationFromPos + "]";
String[] splitLatLon = splitLatLon(locationFromPos);
String str6 = "moovit://directions?dest_lat=" + splitLatLon[0] + "&dest_lon=" + splitLatLon[1];
if (!isNull(string)) {
str6 = str6 + "&dest_name=" + string;
str5 = str5 + " (" + string + SqlExpression.SqlEnclosureClosingBrace;
}
String str7 = str5 + " from";
if (string4.equals(SchedulerSupport.NONE)) {
str3 = str7 + " Current Location";
} else {
if (string4.equals("name")) {
str7 = str7 + " '" + getLocationFromName(jSONObject, "start") + "'";
try {
locationFromPos2 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception e2) {
return "Unable to geocode start address to coordinates: " + e2.getMessage();
}
} else {
locationFromPos2 = string4.equals("pos") ? getLocationFromPos(jSONObject, "start") : null;
}
String[] splitLatLon2 = splitLatLon(locationFromPos2);
str6 = str6 + "&orig_lat=" + splitLatLon2[0] + "&orig_lon=" + splitLatLon2[1];
str3 = str7 + " [" + locationFromPos2 + "]";
if (!isNull(string2)) {
str6 = str6 + "&orig_name=" + string2;
str3 = str3 + " (" + string2 + SqlExpression.SqlEnclosureClosingBrace;
}
}
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (!isNull(parseExtrasToUrl)) {
str6 = str6 + parseExtrasToUrl;
str3 = str3 + " - extras=" + parseExtrasToUrl;
}
this.logger.debug(str3);
this.logger.debug(str + str6);
invokeIntent(new Intent("android.intent.action.VIEW", Uri.parse(str6)));
return null;
} catch (JSONException e3) {
String message = e3.getMessage();
return message.contains("No Activity found to handle Intent") ? "Moovit app is not installed on this device" : message;
}
}
private String launchLyft(JSONObject jSONObject) throws Exception {
String locationFromPos;
String locationFromPos2;
String str;
try {
String string = jSONObject.getString("dType");
String string2 = jSONObject.getString("sType");
String str2 = "Using Lyft to navigate";
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
String str3 = "lyft://ridetype?";
if (!isNull(parseExtrasToUrl)) {
str3 = "lyft://ridetype?" + parseExtrasToUrl;
str2 = "Using Lyft to navigate - extras=" + parseExtrasToUrl;
}
if (isNull(parseExtrasToUrl) || !parseExtrasToUrl.contains("id=")) {
str3 = str3 + "id=lyft";
}
String str4 = str2 + " to";
if (string.equals("name")) {
str4 = str4 + " '" + getLocationFromName(jSONObject, "dest") + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
locationFromPos = getLocationFromPos(jSONObject, "dest");
}
String str5 = str4 + " [" + locationFromPos + "]";
String[] splitLatLon = splitLatLon(locationFromPos);
String str6 = str3 + "&destination[latitude]=" + splitLatLon[0] + "&destination[longitude]=" + splitLatLon[1];
String str7 = str5 + " from";
if (string2.equals(SchedulerSupport.NONE)) {
str = str7 + " Current Location";
} else {
if (string2.equals("name")) {
str7 = str7 + " '" + getLocationFromName(jSONObject, "start") + "'";
try {
locationFromPos2 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception e2) {
return "Unable to geocode start address to coordinates: " + e2.getMessage();
}
} else {
locationFromPos2 = string2.equals("pos") ? getLocationFromPos(jSONObject, "start") : null;
}
String[] splitLatLon2 = splitLatLon(locationFromPos2);
str6 = str6 + "&pickup[latitude]=" + splitLatLon2[0] + "&pickup[longitude]=" + splitLatLon2[1];
str = str7 + " [" + locationFromPos2 + "]";
}
this.logger.debug(str);
this.logger.debug("URI: " + str6);
invokeIntent(new Intent("android.intent.action.VIEW", Uri.parse(str6)));
return null;
} catch (JSONException e3) {
String message = e3.getMessage();
return message.contains("No Activity found to handle Intent") ? "Lyft app is not installed on this device" : message;
}
}
private String launchMapsMe(JSONObject jSONObject) throws Exception {
String locationFromPos;
String locationFromPos2;
String str;
try {
String string = jSONObject.getString("dType");
String string2 = jSONObject.getString("sType");
String string3 = jSONObject.getString("transportMode");
Intent intent = new Intent(this.supportedAppPackages.get("maps_me").concat(".action.BUILD_ROUTE"));
intent.setPackage(this.supportedAppPackages.get("maps_me"));
String str2 = "Using MAPs.ME to navigate to";
if (string.equals("name")) {
str2 = "Using MAPs.ME to navigate to '" + getLocationFromName(jSONObject, "dest") + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
locationFromPos = getLocationFromPos(jSONObject, "dest");
}
String str3 = str2 + " [" + locationFromPos + "]";
String[] splitLatLon = splitLatLon(locationFromPos);
intent.putExtra("lat_to", Double.parseDouble(splitLatLon[0]));
intent.putExtra("lon_to", Double.parseDouble(splitLatLon[1]));
String str4 = str3 + " from";
if (string2.equals(SchedulerSupport.NONE)) {
str = str4 + " Current Location";
} else {
if (string2.equals("name")) {
str4 = str4 + " '" + getLocationFromName(jSONObject, "start") + "'";
try {
locationFromPos2 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception e2) {
return "Unable to geocode start address to coordinates: " + e2.getMessage();
}
} else {
locationFromPos2 = string2.equals("pos") ? getLocationFromPos(jSONObject, "start") : null;
}
String[] splitLatLon2 = splitLatLon(locationFromPos2);
intent.putExtra("lat_from", Double.parseDouble(splitLatLon2[0]));
intent.putExtra("lon_from", Double.parseDouble(splitLatLon2[1]));
str = str4 + " [" + locationFromPos2 + "]";
}
if (string3.equals("d")) {
string3 = "vehicle";
} else if (string3.equals("w")) {
string3 = "pedestrian";
} else if (string3.equals("b")) {
string3 = "bicycle";
} else if (string3.equals("t")) {
string3 = "taxi";
}
if (!isNull(string3)) {
intent.putExtra("router", string3);
str = str + " by transportMode=" + string3;
}
this.logger.debug(str);
invokeIntent(intent);
return null;
} catch (JSONException e3) {
String message = e3.getMessage();
return message.contains("No Activity found to handle Intent") ? "MAPS.ME app is not installed on this device" : message;
}
}
private String launchCabify(JSONObject jSONObject) throws Exception {
String str;
String locationFromPos;
JSONObject jSONObject2;
String locationFromPos2;
int i;
String str2;
String str3;
JSONObject jSONObject3;
try {
String string = jSONObject.getString("destNickname");
String string2 = jSONObject.getString("startNickname");
String string3 = jSONObject.getString("dType");
String string4 = jSONObject.getString("sType");
JSONObject jSONObject4 = new JSONObject();
JSONObject jSONObject5 = new JSONObject();
String str4 = "Using Cabify to navigate to";
if (string3.equals("name")) {
str = string4;
str4 = "Using Cabify to navigate to '" + getLocationFromName(jSONObject, "dest") + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
str = string4;
locationFromPos = getLocationFromPos(jSONObject, "dest");
}
String str5 = str4 + " [" + locationFromPos + "]";
String[] splitLatLon = splitLatLon(locationFromPos);
JSONObject jSONObject6 = new JSONObject();
jSONObject6.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_LATITUDE, splitLatLon[0]);
jSONObject6.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_LONGITUDE, splitLatLon[1]);
jSONObject5.put("loc", jSONObject6);
if (!isNull(string)) {
jSONObject5.put("name", string);
str5 = str5 + " (" + string + SqlExpression.SqlEnclosureClosingBrace;
}
JSONObject jSONObject7 = new JSONObject();
String str6 = str5 + " from";
String str7 = str;
if (str7.equals(SchedulerSupport.NONE)) {
str2 = str6 + " Current Location";
jSONObject7.put("loc", "current");
jSONObject2 = jSONObject5;
str3 = string2;
i = 0;
} else {
jSONObject2 = jSONObject5;
if (str7.equals("name")) {
str6 = str6 + " '" + getLocationFromName(jSONObject, "start") + "'";
try {
locationFromPos2 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception e2) {
return "Unable to geocode start address to coordinates: " + e2.getMessage();
}
} else {
locationFromPos2 = str7.equals("pos") ? getLocationFromPos(jSONObject, "start") : null;
}
String str8 = str6 + " [" + locationFromPos2 + "]";
String[] splitLatLon2 = splitLatLon(locationFromPos2);
JSONObject jSONObject8 = new JSONObject();
i = 0;
jSONObject8.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_LATITUDE, splitLatLon2[0]);
jSONObject8.put(SQLiteLocationContract.LocationEntry.COLUMN_NAME_LONGITUDE, splitLatLon2[1]);
jSONObject7.put("loc", jSONObject8);
str2 = str8;
str3 = string2;
}
if (!isNull(str3)) {
jSONObject7.put("name", str3);
str2 = str2 + " (" + str3 + SqlExpression.SqlEnclosureClosingBrace;
}
String string5 = jSONObject.getString("extras");
if (isNull(string5)) {
jSONObject3 = jSONObject4;
} else {
jSONObject3 = new JSONObject(string5);
str2 = str2 + " - extras=" + string5;
}
JSONArray jSONArray = new JSONArray();
jSONArray.put(jSONObject7);
if (jSONObject3.has("stops")) {
JSONArray jSONArray2 = jSONObject3.getJSONArray("stops");
for (int i2 = i; i2 < jSONArray2.length(); i2++) {
jSONArray.put(jSONArray2.getJSONObject(i2));
}
}
jSONArray.put(jSONObject2);
jSONObject3.put("stops", jSONArray);
String str9 = "cabify://cabify/journey?json=" + jSONObject3.toString();
this.logger.debug(str2);
this.logger.debug("URI: " + str9);
invokeIntent(new Intent("android.intent.action.VIEW", Uri.parse(str9)));
return null;
} catch (JSONException e3) {
String message = e3.getMessage();
return message.contains("No Activity found to handle Intent") ? "Cabify app is not installed on this device" : message;
}
}
private String launchBaidu(JSONObject jSONObject) throws Exception {
String str;
String str2;
String locationFromPos;
String str3;
String str4;
try {
String string = jSONObject.getString("destNickname");
String string2 = jSONObject.getString("startNickname");
String string3 = jSONObject.getString("dType");
String string4 = jSONObject.getString("sType");
String string5 = jSONObject.getString("transportMode");
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (isNull(parseExtrasToUrl)) {
parseExtrasToUrl = "";
}
if (!parseExtrasToUrl.contains("coord_type=")) {
parseExtrasToUrl = parseExtrasToUrl + "&coord_type=wgs84";
}
String str5 = parseExtrasToUrl;
if (string3.equals("name")) {
str = getLocationFromName(jSONObject, "dest");
str2 = "Using Baidu Maps to navigate to" + str;
} else {
String locationFromPos2 = getLocationFromPos(jSONObject, "dest");
String str6 = "Using Baidu Maps to navigate to [" + locationFromPos2 + "]";
if (!isNull(string)) {
locationFromPos2 = "latlng:" + locationFromPos2 + "|name:" + string;
str6 = str6 + " (" + string + SqlExpression.SqlEnclosureClosingBrace;
}
String str7 = str6;
str = locationFromPos2;
str2 = str7;
}
String str8 = "baidumap://map/direction?destination=" + str;
String str9 = str2 + " from";
if (string4.equals(SchedulerSupport.NONE)) {
str4 = str9 + " Current Location";
} else {
if (string4.equals("name")) {
locationFromPos = getLocationFromName(jSONObject, "start");
str3 = str9 + locationFromPos;
} else {
locationFromPos = getLocationFromPos(jSONObject, "start");
str3 = str9 + " [" + locationFromPos + "]";
if (!isNull(string2)) {
locationFromPos = "latlng:" + locationFromPos + "|name:" + string2;
str3 = str3 + " (" + string2 + SqlExpression.SqlEnclosureClosingBrace;
}
}
str8 = str8 + "&origin=" + locationFromPos;
str4 = str3;
}
String str10 = "driving";
if (!string5.equals("d")) {
if (string5.equals("w")) {
str10 = "walking";
} else if (string5.equals("b")) {
str10 = "riding";
} else if (string5.equals("t")) {
str10 = "transit";
}
}
String str11 = (str8 + "&mode=" + str10) + str5;
this.logger.debug((str4 + " by transportMode=" + str10) + " - extras=" + str5);
this.logger.debug("URI: " + str11);
Intent intent = new Intent();
intent.setData(Uri.parse(str11));
invokeIntent(intent);
return null;
} catch (JSONException e) {
String message = e.getMessage();
return message.contains("No Activity found to handle Intent") ? "Baidu Maps app is not installed on this device" : message;
}
}
private String launchGaode(JSONObject jSONObject) throws Exception {
String str;
String locationFromPos;
String str2;
String locationFromPos2;
String str3;
try {
String string = jSONObject.getString("destNickname");
String string2 = jSONObject.getString("startNickname");
String string3 = jSONObject.getString("dType");
String string4 = jSONObject.getString("sType");
String string5 = jSONObject.getString("transportMode");
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (isNull(parseExtrasToUrl)) {
parseExtrasToUrl = "";
}
if (!parseExtrasToUrl.contains("sourceApplication=")) {
parseExtrasToUrl = parseExtrasToUrl + "&sourceApplication=" + Uri.encode(getThisAppName());
}
if (string3.equals("name")) {
str = parseExtrasToUrl;
str2 = "Using Gaode Maps to navigate to '" + getLocationFromName(jSONObject, "dest") + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
str = parseExtrasToUrl;
locationFromPos = getLocationFromPos(jSONObject, "dest");
str2 = "Using Gaode Maps to navigate to";
}
String str4 = str2 + " [" + locationFromPos + "]";
String[] splitLatLon = splitLatLon(locationFromPos);
String str5 = "amapuri://route/plan/?dlat=" + splitLatLon[0] + "&dlon=" + splitLatLon[1];
if (!isNull(string)) {
str4 = str4 + " (" + string + SqlExpression.SqlEnclosureClosingBrace;
str5 = str5 + "&dname=" + string;
}
String str6 = str4 + " from";
if (string4.equals(SchedulerSupport.NONE)) {
str3 = str6 + " Current Location";
} else {
if (string4.equals("name")) {
str6 = str6 + " '" + getLocationFromName(jSONObject, "start") + "'";
try {
locationFromPos2 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception unused) {
locationFromPos2 = null;
}
} else {
locationFromPos2 = getLocationFromPos(jSONObject, "start");
}
if (isNull(locationFromPos2)) {
str3 = str6;
} else {
String str7 = str6 + " [" + locationFromPos2 + "]";
String[] splitLatLon2 = splitLatLon(locationFromPos2);
str5 = str5 + "&slat=" + splitLatLon2[0] + "&slon=" + splitLatLon2[1];
if (isNull(string2)) {
str3 = str7;
} else {
str3 = str7 + " (" + string2 + SqlExpression.SqlEnclosureClosingBrace;
str5 = str5 + "&sname=" + string2;
}
}
}
String str8 = "0";
String str9 = "driving";
if (!string5.equals("d")) {
if (string5.equals("w")) {
str9 = "walking";
str8 = "2";
} else if (string5.equals("b")) {
str9 = "bicycle";
str8 = "3";
} else if (string5.equals("t")) {
str9 = "transit";
str8 = "1";
}
}
String str10 = str;
String str11 = (str5 + "&t=" + str8) + str10;
this.logger.debug((str3 + " by transportMode=" + str9) + " - extras=" + str10);
this.logger.debug("URI: " + str11);
Intent intent = new Intent();
intent.setData(Uri.parse(str11));
invokeIntent(intent);
return null;
} catch (JSONException e2) {
String message = e2.getMessage();
return message.contains("No Activity found to handle Intent") ? "Gaode Maps app is not installed on this device" : message;
}
}
private String launch99Taxis(JSONObject jSONObject) throws Exception {
String str;
String locationFromPos;
String str2;
String str3;
String locationFromPos2;
String str4;
try {
String string = jSONObject.getString("destNickname");
String string2 = jSONObject.getString("startNickname");
String string3 = jSONObject.getString("dType");
String string4 = jSONObject.getString("sType");
String parseExtrasToUrl = parseExtrasToUrl(jSONObject);
if (isNull(parseExtrasToUrl)) {
parseExtrasToUrl = "";
}
if (!parseExtrasToUrl.contains("deep_link_product_id")) {
parseExtrasToUrl = parseExtrasToUrl + "&deep_link_product_id=316";
}
if (!parseExtrasToUrl.contains("client_id")) {
parseExtrasToUrl = parseExtrasToUrl + "&client_id=MAP_123";
}
String str5 = parseExtrasToUrl;
if (string3.equals("name")) {
str3 = getLocationFromName(jSONObject, "dest");
str = "Unable to geocode start address to coordinates: ";
str2 = "Using 99 Taxi to navigate to '" + str3 + "'";
try {
locationFromPos = geocodeAddressToLatLon(jSONObject.getString("dest"));
} catch (Exception e) {
return "Unable to geocode destination address to coordinates: " + e.getMessage();
}
} else {
str = "Unable to geocode start address to coordinates: ";
locationFromPos = getLocationFromPos(jSONObject, "dest");
str2 = "Using 99 Taxi to navigate to";
str3 = null;
}
String str6 = str2 + " [" + locationFromPos + "]";
String[] splitLatLon = splitLatLon(locationFromPos);
String str7 = "taxis99://call?dropoff_latitude=" + splitLatLon[0] + "&dropoff_longitude=" + splitLatLon[1];
if (isNull(string)) {
string = !isNull(str3) ? str3 : "Dropoff";
}
String str8 = str7 + "&dropoff_title=" + string;
String str9 = (str6 + " (" + string + SqlExpression.SqlEnclosureClosingBrace) + " from";
if (string4.equals("name")) {
str4 = getLocationFromName(jSONObject, "start");
str9 = str9 + " '" + str4 + "'";
try {
locationFromPos2 = geocodeAddressToLatLon(jSONObject.getString("start"));
} catch (Exception e2) {
return str + e2.getMessage();
}
} else {
if (!string4.equals("pos")) {
return "start location is a required parameter for 99 Taxi and must be specified";
}
locationFromPos2 = getLocationFromPos(jSONObject, "start");
str4 = null;
}
String str10 = str9 + " [" + locationFromPos2 + "]";
String[] splitLatLon2 = splitLatLon(locationFromPos2);
String str11 = str8 + "&pickup_latitude=" + splitLatLon2[0] + "&pickup_longitude=" + splitLatLon2[1];
String str12 = isNull(string2) ? !isNull(str4) ? str4 : "Pickup" : string2;
String str13 = (str11 + "&pickup_title=" + str12) + str5;
this.logger.debug((str10 + " (" + str12 + SqlExpression.SqlEnclosureClosingBrace) + " - extras=" + str5);
this.logger.debug("URI: " + str13);
Intent intent = new Intent();
intent.setData(Uri.parse(str13));
invokeIntent(intent);
return null;
} catch (JSONException e3) {
String message = e3.getMessage();
return message.contains("No Activity found to handle Intent") ? "99 Taxis app is not installed on this device" : message;
}
}
private void invokeIntent(Intent intent) {
intent.addFlags(268435456);
this.context.startActivity(intent);
}
private String parseExtrasToUrl(JSONObject jSONObject) throws JSONException {
String string = jSONObject.getString("extras");
String str = null;
JSONObject jSONObject2 = !isNull(string) ? new JSONObject(string) : null;
if (jSONObject2 != null) {
Iterator<String> keys = jSONObject2.keys();
str = "";
while (keys.hasNext()) {
String next = keys.next();
str = str + SqlExpression.SqlOperatorBitwiseAnd + next + SqlExpression.SqlOperatorEqualTo + jSONObject2.getString(next);
}
}
return str;
}
private String getLocationFromPos(JSONObject jSONObject, String str) throws Exception {
JSONArray jSONArray = new JSONArray(jSONObject.getString(str));
String string = jSONArray.getString(0);
String string2 = jSONArray.getString(1);
if (isNull(string) || string.length() == 0 || isNull(string2) || string2.length() == 0) {
throw new Exception("Expected two non-empty string arguments for lat/lon.");
}
return string + SQLiteOpenHelper.COMMA_SEP + string2;
}
private String getLocationFromName(JSONObject jSONObject, String str) throws Exception {
String string = jSONObject.getString(str);
if (isNull(string) || string.length() == 0) {
throw new Exception("Expected non-empty string argument for place name.");
}
return string;
}
private String[] splitLatLon(String str) {
return str.split(SQLiteOpenHelper.COMMA_SEP);
}
private String getAppName(String str) {
ApplicationInfo applicationInfo;
try {
applicationInfo = this.packageManager.getApplicationInfo(str, 0);
} catch (PackageManager.NameNotFoundException unused) {
applicationInfo = null;
}
return (String) (applicationInfo != null ? this.packageManager.getApplicationLabel(applicationInfo) : null);
}
private boolean isPackageInstalled(String str, PackageManager packageManager) {
try {
packageManager.getPackageInfo(str, 1);
return packageManager.getApplicationInfo(str, 0).enabled;
} catch (PackageManager.NameNotFoundException unused) {
return false;
}
}
private String geocodeAddressToLatLon(String str) throws Exception {
String str2 = "Unable to geocode coords from address '" + str;
if (!this.geocodingEnabled) {
throw new Exception("Geocoding disabled: " + str2);
}
if (!isNetworkAvailable()) {
throw new Exception("No internet connection: " + str2);
}
String replaceAll = str.replaceAll(" ", "%20");
JSONObject doGeocode = doGeocode("address=" + replaceAll);
String str3 = doGeocode.getJSONObject("geometry").getJSONObject("location").getDouble("lat") + SQLiteOpenHelper.COMMA_SEP + doGeocode.getJSONObject("geometry").getJSONObject("location").getDouble("lng");
this.logger.debug("Geocoded '" + replaceAll + "' to '" + str3 + "'");
return str3;
}
private String reverseGeocodeLatLonToAddress(String str) throws Exception {
String str2 = "Unable to reverse geocode address from coords '" + str;
if (!this.geocodingEnabled) {
throw new Exception("Geocoding is disabled: " + str2);
}
if (!isNetworkAvailable()) {
throw new Exception("No internet connection: " + str2);
}
String string = doGeocode("latlng=" + str).getString("formatted_address");
this.logger.debug("Reverse geocoded '" + str + "' to '" + string + "'");
return string;
}
private JSONObject doGeocode(String str) throws Exception {
if (this.googleApiKey == null) {
throw new Exception("Google API key has not been specified");
}
JSONObject jSONObject = new JSONObject(this.httpClient.newCall(new Request.Builder().url("https://maps.google.com/maps/api/geocode/json?" + str + "&sensor=false&key=" + this.googleApiKey).build()).execute().body().string());
if (jSONObject.has("error_message")) {
throw new Exception(jSONObject.getString("error_message"));
}
JSONArray jSONArray = (JSONArray) jSONObject.get("results");
String string = jSONObject.getString("status");
if (string.equals("OK") && jSONArray.length() > 0) {
return jSONArray.getJSONObject(0);
}
throw new Exception("No geocoding results found or invalid status - " + string);
}
private boolean isNull(String str) {
return str == null || str.equals("null");
}
private JSONObject ensureNavigateKeys(JSONObject jSONObject) throws Exception {
for (String str : this.navigateParams) {
if (!jSONObject.has(str)) {
jSONObject.put(str, "null");
}
}
return jSONObject;
}
private String getAppDisplayName(String str) {
if (str.equals("geo")) {
return "[Native chooser]";
}
for (Map.Entry<String, String> entry : this.availableApps.entrySet()) {
String key = entry.getKey();
if (str.equals(entry.getValue())) {
return key;
}
}
return "[Not found]";
}
private String getThisAppName() {
return this.context.getApplicationInfo().loadLabel(this.packageManager).toString();
}
private boolean isNetworkAvailable() {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) this.context.getSystemService("connectivity")).getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
}