Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/ENH] updates to fix error handling in several different situations #719

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class BackgroundGuiHandler extends Handler {
public static final String FILEPATH = "filepath";
public static final String TRANSIDS = "transIds";

public static BackgroundAlertDialog alertDialog;
private FragmentActivity context;
private final Object lock;
private final ProgressPanel pp;
Expand Down Expand Up @@ -246,7 +247,11 @@ public void handleMessage( final Message msg ) {
}

private void showError(final FragmentManager fm, final Message msg, final Status status) {
final BackgroundAlertDialog alertDialog = BackgroundAlertDialog.newInstance(msg, status);
if (null != alertDialog && alertDialog.isVisible()) {
//ALIBI: one alert dialog at a time
alertDialog.dismiss();
}
alertDialog = BackgroundAlertDialog.newInstance(msg, status);
try {
final Activity a = MainActivity.getMainActivity();
if (null != a && !a.isFinishing()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ public void onTaskFailed(int httpStatus, JSONObject error) {
intent.putExtra("error", e);
status = Status.EXCEPTION;
} else {
bundle.putString( BackgroundGuiHandler.ERROR, "Unable to connect. (data: "+WiGLEApiManager.hasDataConnection(context)+")");
final String translated = context != null? context.getString(R.string.no_wigle_conn): "Unable to connect.";
bundle.putString( BackgroundGuiHandler.ERROR, translated+" (data: "+WiGLEApiManager.hasDataConnection(context)+")");
}
} catch (JSONException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,11 @@ else if ( newOK && NETWORK_PROVIDER.equals( newLocation.getProvider() ) ) {
// initialize previous location
prevLocation = currentLocation;
} else if (prevLocation != null){
Logging.warn("Location timestamp ("+ currentLocation.getTime()+") <= previous location timestamp ("+ prevLocation.getTime()+")");
//ALIBI: we're ignoring this rather than trying to slot it in only because we'd need an in-memory or DB route otherwise.
if (currentLocation.getTime() != prevLocation.getTime()) {
Logging.warn("Location timestamp (" + currentLocation.getTime() + ") < previous location timestamp (" + prevLocation.getTime() + ")");
//ALIBI: we're ignoring this rather than trying to slot it in only because we'd need an in-memory or DB route otherwise.
}
//ALIBI: no log message required for equal.
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
Expand All @@ -15,7 +16,6 @@
import androidx.annotation.NonNull;

import com.appmattus.certificatetransparency.CTInterceptorBuilder;
import com.google.android.gms.common.api.Api;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;

Expand Down Expand Up @@ -700,8 +700,15 @@ public static boolean hasDataConnection(final Context context) {
Logging.error("null ConnectivityManager trying to determine connection info");
return false;
}
NetworkInfo activeNetworkInfo = connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null;
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
final Network n = connectivityManager.getActiveNetwork();
if (null != n) {
final NetworkCapabilities cap = connectivityManager.getNetworkCapabilities(n);
if (cap.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
cap.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
return true;
}
}
return false;
}

/**
Expand Down