package guard.api.sensitive.ui.sapiguard.hookedapis;

import java.util.ArrayList;
import java.util.List;

import guard.api.sensitive.ui.sapiguard.utils.PrivacyManager;
import guard.api.sensitive.ui.sapiguard.XHook;
import guard.api.sensitive.ui.sapiguard.utils.XParam;

public class XGoogleMapV2 extends XHook {
	private Methods mMethod;

	private XGoogleMapV2(Methods method, String restrictionName) {
		super(restrictionName, method.name(), String.format("MapV2.%s", method.name()));
		mMethod = method;
	}

	public String getClassName() {
		if (mMethod == Methods.getPosition)
			return "com.google.android.gms.maps.model.Marker";
		else
			return "com.google.android.gms.maps.GoogleMap";
	}

	// @formatter:off

	// final Location getMyLocation()
	// final void setLocationSource(LocationSource source)
	// final void setOnMapClickListener(GoogleMap.OnMapClickListener listener)
	// final void setOnMapLongClickListener(GoogleMap.OnMapLongClickListener listener)
	// final void setOnMyLocationChangeListener(GoogleMap.OnMyLocationChangeListener listener)
	// http://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.html

	// public LatLng getPosition ()
	// http://developer.android.com/reference/com/google/android/gms/maps/model/Marker.html
	// http://developer.android.com/reference/com/google/android/gms/maps/model/LatLng.html

	// @formatter:on

	private enum Methods {
		getMyLocation, getPosition, setLocationSource, setOnMapClickListener, setOnMapLongClickListener, setOnMyLocationChangeListener
	};

	public static List<XHook> getInstances() {
		List<XHook> listHook = new ArrayList<XHook>();
		for (Methods method : Methods.values())
			listHook.add(new XGoogleMapV2(method, PrivacyManager.cLocation));
		return listHook;
	}

	@Override
	protected void before(XParam param) throws Throwable {
		switch (mMethod) {
		case getMyLocation:
			// Do nothing
			break;

		case getPosition:
			// Do nothing
			break;

		case setLocationSource:
		case setOnMapClickListener:
		case setOnMapLongClickListener:
		case setOnMyLocationChangeListener:

			break;
		}
	}

	@Override
	protected void after(XParam param) throws Throwable {
		switch (mMethod) {
		case getMyLocation:

		case getPosition:

		case setLocationSource:
		case setOnMapClickListener:
		case setOnMapLongClickListener:
		case setOnMyLocationChangeListener:
			// Do nothing
			break;
		}
	}
}
