WiGLE WiFi Wardriving FOSS v2.63版本的 MD5 值为:20a157bff1dec2e81d8268d404e15cb5
以下内容为反编译后的 MappingFragment.java 源代码,内容仅作参考
package net.wigle.wigleandroid;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.goebl.simplify.PointExtractor;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
import net.wigle.wigleandroid.background.QueryThread;
import net.wigle.wigleandroid.db.DatabaseHelper;
import net.wigle.wigleandroid.model.ConcurrentLinkedHashMap;
import net.wigle.wigleandroid.model.LatLng;
import net.wigle.wigleandroid.model.Network;
import net.wigle.wigleandroid.ui.UINumberFormat;
public final class MappingFragment extends Fragment {
private static final int DEFAULT_ZOOM = 17;
private static final String DIALOG_PREFIX = "DialogPrefix";
private static final String HIGH_RES_TILE_TRAILER = "&sizeX=512&sizeY=512";
public static final String MAP_DIALOG_PREFIX = "";
private static final String MAP_TILE_URL_FORMAT = "https://wigle.net/clientTile?zoom=%d&x=%d&y=%d&startTransID=%s&endTransID=%s";
private static final int MENU_CLUSTER = 19;
private static final int MENU_FILTER = 18;
private static final int MENU_LABEL = 17;
private static final int MENU_MAP_TYPE = 21;
private static final int MENU_TOGGLE_LOCK = 15;
private static final int MENU_TOGGLE_NEWDB = 16;
private static final int MENU_TRAFFIC = 20;
private static final int MENU_WAKELOCK = 22;
private static final int MENU_ZOOM_IN = 13;
private static final int MENU_ZOOM_OUT = 14;
private static final String NOT_MINE_TILE_TRAILER = "¬mine=1";
private static final String ONLY_MINE_TILE_TRAILER = "&onlymine=1";
private static final int OVERLAY_DARK = -16777216;
private static final int POLYLINE_PERF_THRESHOLD = 2500;
private static final float POLYLINE_TOLERANCE_COARSE = 20.0f;
private static final float POLYLINE_TOLERANCE_FINE = 50.0f;
private static final float ROUTE_WIDTH = 20.0f;
private static final int SSID_FILTER = 102;
public static LocationListener STATIC_LOCATION_LISTENER = null;
static final int UPDATE_MAP_FILTER = 1;
private AtomicBoolean finishing;
private Location lastLocation;
private Menu menu;
private NumberFormat numberFormat;
private Location previousLocation;
private int previousRunNets;
public static final LatLng DEFAULT_POINT = new LatLng(41.95d, -87.65d);
private static final int OVERLAY_LIGHT = Color.parseColor("#F4D03F");
private static final PointExtractor<LatLng> latLngPointExtractor = new PointExtractor<LatLng>() {
@Override
public double getX(LatLng latLng) {
return latLng.latitude * 1000000.0d;
}
@Override
public double getY(LatLng latLng) {
return latLng.longitude * 1000000.0d;
}
};
private final String ROUTE_LINE_TAG = "routePolyline";
private final State state = new State();
private final Handler timer = new Handler();
final Runnable mUpdateTimeTask = new MapRunnable();
private int getRouteColorForMapType(int i) {
return -16777216;
}
public void addNetwork(Network network) {
}
public void reCluster() {
}
public void updateNetwork(Network network) {
}
private static class State {
private boolean firstMove;
private boolean locked;
private LatLng oldCenter;
private final int oldZoom;
private State() {
this.locked = true;
this.firstMove = true;
this.oldCenter = null;
this.oldZoom = Integer.MIN_VALUE;
}
}
@Override
public void onCreate(Bundle bundle) {
MainActivity.info("MAP: onCreate");
super.onCreate(bundle);
setHasOptionsMenu(true);
MainActivity.setLocale(getActivity());
this.finishing = new AtomicBoolean(false);
Configuration configuration = getResources().getConfiguration();
Locale locale = configuration != null ? configuration.locale : null;
if (locale == null) {
locale = Locale.US;
}
NumberFormat numberInstance = NumberFormat.getNumberInstance(locale);
this.numberFormat = numberInstance;
numberInstance.setMaximumFractionDigits(1);
getActivity().setVolumeControlStream(3);
setupQuery();
}
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
return layoutInflater.inflate(R.layout.map, viewGroup, false);
}
public static LatLng getCenter(Context context, LatLng latLng, Location location) {
LatLng latLng2 = DEFAULT_POINT;
Location location2 = ListFragment.lameStatic.location;
SharedPreferences sharedPreferences = context.getSharedPreferences(ListFragment.SHARED_PREFS, 0);
if (latLng != null) {
return latLng;
}
if (location2 != null) {
return new LatLng(location2.getLatitude(), location2.getLongitude());
}
if (location != null) {
return new LatLng(location.getLatitude(), location.getLongitude());
}
Location safelyGetLast = safelyGetLast(context, "gps");
Location safelyGetLast2 = safelyGetLast(context, DatabaseHelper.NETWORK_TABLE);
if (safelyGetLast != null) {
return new LatLng(safelyGetLast.getLatitude(), safelyGetLast.getLongitude());
}
if (safelyGetLast2 != null) {
return new LatLng(safelyGetLast2.getLatitude(), safelyGetLast2.getLongitude());
}
float f = sharedPreferences.getFloat(ListFragment.PREF_PREV_LAT, Float.MIN_VALUE);
float f2 = sharedPreferences.getFloat(ListFragment.PREF_PREV_LON, Float.MIN_VALUE);
return (f == Float.MIN_VALUE || f2 == Float.MIN_VALUE) ? latLng2 : new LatLng(f, f2);
}
private static Location safelyGetLast(Context context, String str) {
try {
return ((LocationManager) context.getSystemService(DatabaseHelper.LOCATION_TABLE)).getLastKnownLocation(str);
} catch (IllegalArgumentException | SecurityException e) {
MainActivity.info("exception getting last known location: " + e);
return null;
}
}
private class MapRunnable implements Runnable {
private MapRunnable() {
}
@Override
public void run() {
View view = MappingFragment.this.getView();
SharedPreferences sharedPreferences = MappingFragment.this.getActivity() != null ? MappingFragment.this.getActivity().getSharedPreferences(ListFragment.SHARED_PREFS, 0) : null;
if (!MappingFragment.this.finishing.get()) {
Location location = ListFragment.lameStatic.location;
if (location != null) {
if (!MappingFragment.this.state.locked && MappingFragment.this.previousLocation != null && MappingFragment.this.previousLocation.getLatitude() == location.getLatitude() && MappingFragment.this.previousLocation.getLongitude() == location.getLongitude()) {
int unused = MappingFragment.this.previousRunNets;
int i = ListFragment.lameStatic.runNets;
}
MappingFragment.this.previousLocation = location;
}
MappingFragment.this.previousRunNets = ListFragment.lameStatic.runNets;
if (view != null) {
((TextView) view.findViewById(R.id.stats_run)).setText(MappingFragment.this.getString(R.string.run) + ": " + UINumberFormat.counterFormat(ListFragment.lameStatic.runNets + ListFragment.lameStatic.runBt));
((TextView) view.findViewById(R.id.stats_wifi)).setText(UINumberFormat.counterFormat(ListFragment.lameStatic.newWifi));
((TextView) view.findViewById(R.id.stats_cell)).setText("" + UINumberFormat.counterFormat(ListFragment.lameStatic.newCells));
((TextView) view.findViewById(R.id.stats_bt)).setText("" + UINumberFormat.counterFormat(ListFragment.lameStatic.newBt));
((TextView) view.findViewById(R.id.stats_dbnets)).setText(UINumberFormat.counterFormat(ListFragment.lameStatic.dbNets));
if (sharedPreferences != null) {
((TextView) view.findViewById(R.id.rundistance)).setText(UINumberFormat.metersToString(sharedPreferences, MappingFragment.this.numberFormat, MappingFragment.this.getActivity(), sharedPreferences.getFloat(ListFragment.PREF_DISTANCE_RUN, 0.0f), true));
}
}
MappingFragment.this.timer.postDelayed(this, 1000L);
return;
}
MainActivity.info("finishing mapping timer");
}
}
private void setupTimer() {
this.timer.removeCallbacks(this.mUpdateTimeTask);
this.timer.postDelayed(this.mUpdateTimeTask, 250L);
}
@Override
public void onDetach() {
MainActivity.info("MAP: onDetach.");
super.onDetach();
}
@Override
public void onDestroy() {
MainActivity.info("MAP: destroy mapping.");
this.finishing.set(true);
super.onDestroy();
}
@Override
public void onPause() {
MainActivity.info("MAP: onPause");
super.onPause();
}
@Override
public void onResume() {
MainActivity.info("MAP: onResume");
super.onResume();
setupTimer();
getActivity().setTitle(R.string.mapping_app_name);
}
@Override
public void onSaveInstanceState(Bundle bundle) {
MainActivity.info("MAP: onSaveInstanceState");
super.onSaveInstanceState(bundle);
}
@Override
public void onLowMemory() {
MainActivity.info("MAP: onLowMemory");
super.onLowMemory();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
MainActivity.info("MAP: onCreateOptionsMenu");
SharedPreferences sharedPreferences = getActivity().getSharedPreferences(ListFragment.SHARED_PREFS, 0);
boolean z = sharedPreferences.getBoolean(ListFragment.PREF_MAP_ONLY_NEWDB, false);
boolean z2 = sharedPreferences.getBoolean(ListFragment.PREF_MAP_LABEL, true);
boolean z3 = sharedPreferences.getBoolean(ListFragment.PREF_MAP_CLUSTER, true);
boolean z4 = sharedPreferences.getBoolean(ListFragment.PREF_MAP_TRAFFIC, true);
menu.add(0, 17, 0, getString(z2 ? R.string.menu_labels_off : R.string.menu_labels_on)).setIcon(17301659);
menu.add(0, 19, 0, getString(z3 ? R.string.menu_cluster_off : R.string.menu_cluster_on)).setIcon(17301555);
menu.add(0, 20, 0, getString(z4 ? R.string.menu_traffic_off : R.string.menu_traffic_on)).setIcon(17301565);
MenuItem add = menu.add(0, 21, 0, getString(R.string.menu_map_type));
add.setIcon(17301571);
MenuItemCompat.setShowAsAction(add, 1);
MenuItem add2 = menu.add(0, 18, 0, getString(R.string.settings_map_head));
add2.setIcon(17301583);
MenuItemCompat.setShowAsAction(add2, 1);
menu.add(0, 15, 0, getString(this.state.locked ? R.string.menu_turn_off_lockon : R.string.menu_turn_on_lockon)).setIcon(17301551);
menu.add(0, 16, 0, getString(z ? R.string.menu_show_old : R.string.menu_show_new)).setIcon(17301566);
menu.add(0, 22, 0, getString(MainActivity.isScreenLocked(this) ? R.string.menu_screen_sleep : R.string.menu_screen_wake)).setIcon(17301567);
super.onCreateOptionsMenu(menu, menuInflater);
this.menu = menu;
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
State state;
SharedPreferences sharedPreferences = getActivity().getSharedPreferences(ListFragment.SHARED_PREFS, 0);
switch (menuItem.getItemId()) {
case 13:
case 14:
break;
case 15:
this.state.locked = !state.locked;
menuItem.setTitle(getString(this.state.locked ? R.string.menu_turn_off_lockon : R.string.menu_turn_on_lockon));
break;
case 16:
boolean z = !sharedPreferences.getBoolean(ListFragment.PREF_MAP_ONLY_NEWDB, false);
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putBoolean(ListFragment.PREF_MAP_ONLY_NEWDB, z);
edit.apply();
menuItem.setTitle(getString(z ? R.string.menu_show_old : R.string.menu_show_new));
return true;
case 17:
boolean z2 = !sharedPreferences.getBoolean(ListFragment.PREF_MAP_LABEL, true);
SharedPreferences.Editor edit2 = sharedPreferences.edit();
edit2.putBoolean(ListFragment.PREF_MAP_LABEL, z2);
edit2.apply();
menuItem.setTitle(getString(z2 ? R.string.menu_labels_off : R.string.menu_labels_on));
return true;
case 18:
getActivity().startActivityForResult(new Intent(getActivity(), MapFilterActivity.class), 1);
return true;
case 19:
boolean z3 = !sharedPreferences.getBoolean(ListFragment.PREF_MAP_CLUSTER, true);
SharedPreferences.Editor edit3 = sharedPreferences.edit();
edit3.putBoolean(ListFragment.PREF_MAP_CLUSTER, z3);
edit3.apply();
menuItem.setTitle(getString(z3 ? R.string.menu_cluster_off : R.string.menu_cluster_on));
return true;
case 20:
boolean z4 = !sharedPreferences.getBoolean(ListFragment.PREF_MAP_TRAFFIC, true);
SharedPreferences.Editor edit4 = sharedPreferences.edit();
edit4.putBoolean(ListFragment.PREF_MAP_TRAFFIC, z4);
edit4.apply();
menuItem.setTitle(getString(z4 ? R.string.menu_traffic_off : R.string.menu_traffic_on));
return true;
case 21:
case 22:
boolean z5 = !MainActivity.isScreenLocked(this);
MainActivity.setLockScreen(this, z5);
menuItem.setTitle(getString(z5 ? R.string.menu_screen_sleep : R.string.menu_screen_wake));
return true;
default:
return false;
}
return true;
}
public static class MapDialogFragment extends DialogFragment {
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
final String string = getArguments().getString(MappingFragment.DIALOG_PREFIX);
final Dialog dialog = getDialog();
final FragmentActivity activity = getActivity();
final View inflate = layoutInflater.inflate(R.layout.filterdialog, viewGroup);
dialog.setTitle("SSID Filter");
MainActivity.info("make new dialog. prefix: " + string);
final SharedPreferences sharedPreferences = activity.getSharedPreferences(ListFragment.SHARED_PREFS, 0);
final EditText editText = (EditText) inflate.findViewById(R.id.edit_regex);
editText.setText(sharedPreferences.getString(string + ListFragment.PREF_MAPF_REGEX, ""));
final CheckBox prefSetCheckBox = MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showinvert, string + ListFragment.PREF_MAPF_INVERT, false);
final CheckBox prefSetCheckBox2 = MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showopen, string + ListFragment.PREF_MAPF_OPEN, true);
final CheckBox prefSetCheckBox3 = MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showwep, string + ListFragment.PREF_MAPF_WEP, true);
final CheckBox prefSetCheckBox4 = MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showwpa, string + ListFragment.PREF_MAPF_WPA, true);
final CheckBox prefSetCheckBox5 = MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showcell, string + ListFragment.PREF_MAPF_CELL, true);
final CheckBox prefSetCheckBox6 = MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.enabled, string + ListFragment.PREF_MAPF_ENABLED, true);
((Button) inflate.findViewById(R.id.ok_button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(string + ListFragment.PREF_MAPF_REGEX, editText.getText().toString());
edit.putBoolean(string + ListFragment.PREF_MAPF_INVERT, prefSetCheckBox.isChecked());
edit.putBoolean(string + ListFragment.PREF_MAPF_OPEN, prefSetCheckBox2.isChecked());
edit.putBoolean(string + ListFragment.PREF_MAPF_WEP, prefSetCheckBox3.isChecked());
edit.putBoolean(string + ListFragment.PREF_MAPF_WPA, prefSetCheckBox4.isChecked());
edit.putBoolean(string + ListFragment.PREF_MAPF_CELL, prefSetCheckBox5.isChecked());
edit.putBoolean(string + ListFragment.PREF_MAPF_ENABLED, prefSetCheckBox6.isChecked());
edit.apply();
MainActivity.reclusterMap();
dialog.dismiss();
} catch (Exception e) {
MainActivity.info("exception dismissing filter dialog: " + e);
}
}
});
((Button) inflate.findViewById(R.id.cancel_button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
editText.setText(sharedPreferences.getString(string + ListFragment.PREF_MAPF_REGEX, ""));
MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showinvert, string + ListFragment.PREF_MAPF_INVERT, false);
MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showopen, string + ListFragment.PREF_MAPF_OPEN, true);
MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showwep, string + ListFragment.PREF_MAPF_WEP, true);
MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showwpa, string + ListFragment.PREF_MAPF_WPA, true);
MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.showcell, string + ListFragment.PREF_MAPF_CELL, true);
MainActivity.prefSetCheckBox((Context) activity, inflate, (int) R.id.enabled, string + ListFragment.PREF_MAPF_ENABLED, true);
dialog.dismiss();
} catch (Exception e) {
MainActivity.info("exception dismissing filter dialog: " + e);
}
}
});
return inflate;
}
}
public static DialogFragment createSsidFilterDialog(String str) {
MapDialogFragment mapDialogFragment = new MapDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(DIALOG_PREFIX, str);
mapDialogFragment.setArguments(bundle);
return mapDialogFragment;
}
private void setupQuery() {
int size = MainActivity.getNetworkCache().size();
if (size > ListFragment.lameStatic.networkCache.maxSize() / 4) {
MainActivity.info("cacheSize: " + size + ", skipping previous networks");
return;
}
QueryThread.Request request = new QueryThread.Request("SELECT bssid FROM location ORDER BY _id DESC LIMIT " + (ListFragment.lameStatic.networkCache.maxSize() * 2), new QueryThread.ResultHandler() {
@Override
public void complete() {
}
@Override
public boolean handleRow(Cursor cursor) {
Network network;
String string = cursor.getString(0);
ConcurrentLinkedHashMap<String, Network> networkCache = MainActivity.getNetworkCache();
if (networkCache.get(string) != null || (network = ListFragment.lameStatic.dbHelper.getNetwork(string)) == null) {
return true;
}
networkCache.put(network.getBssid(), network);
if (networkCache.isFull()) {
MainActivity.info("Cache is full, breaking out of query result handling");
return false;
}
return true;
}
});
if (ListFragment.lameStatic.dbHelper != null) {
ListFragment.lameStatic.dbHelper.addToQueue(request);
}
}
}