diff --git a/play-services-api/build.gradle b/play-services-api/build.gradle index 44c2d884..5e627850 100644 --- a/play-services-api/build.gradle +++ b/play-services-api/build.gradle @@ -37,6 +37,4 @@ dependencies { api project(':play-services-cast-api') api project(':play-services-cast-framework-api') api project(':play-services-iid-api') - api project(':play-services-location-api') - api project(':play-services-wearable-api') } diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/GoogleMapOptions.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/GoogleMapOptions.aidl deleted file mode 100644 index e2cf4afd..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/GoogleMapOptions.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps; - -parcelable GoogleMapOptions; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICameraUpdateFactoryDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICameraUpdateFactoryDelegate.aidl deleted file mode 100644 index a8ea7626..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICameraUpdateFactoryDelegate.aidl +++ /dev/null @@ -1,20 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -interface ICameraUpdateFactoryDelegate { - IObjectWrapper zoomIn(); - IObjectWrapper zoomOut(); - IObjectWrapper scrollBy(float x, float y); - IObjectWrapper zoomTo(float zoom); - IObjectWrapper zoomBy(float zoomDelta); - IObjectWrapper zoomByWithFocus(float zoomDelta, int x, int y); - IObjectWrapper newCameraPosition(in CameraPosition cameraPosition); - IObjectWrapper newLatLng(in LatLng latLng); - IObjectWrapper newLatLngZoom(in LatLng latLng, float zoom); - IObjectWrapper newLatLngBounds(in LatLngBounds bounds, int padding); - IObjectWrapper newLatLngBoundsWithSize(in LatLngBounds bounds, int width, int height, int padding); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICancelableCallback.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICancelableCallback.aidl deleted file mode 100644 index 0cc5938f..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICancelableCallback.aidl +++ /dev/null @@ -1,6 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface ICancelableCallback { - void onFinish(); - void onCancel(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICreator.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICreator.aidl deleted file mode 100644 index f10ab345..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ICreator.aidl +++ /dev/null @@ -1,17 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.GoogleMapOptions; -import com.google.android.gms.maps.internal.IMapFragmentDelegate; -import com.google.android.gms.maps.internal.IMapViewDelegate; -import com.google.android.gms.maps.internal.ICameraUpdateFactoryDelegate; -import com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate; - -interface ICreator { - void init(IObjectWrapper resources); - IMapFragmentDelegate newMapFragmentDelegate(IObjectWrapper activity); - IMapViewDelegate newMapViewDelegate(IObjectWrapper context, in GoogleMapOptions options); - ICameraUpdateFactoryDelegate newCameraUpdateFactoryDelegate(); - IBitmapDescriptorFactoryDelegate newBitmapDescriptorFactoryDelegate(); - void initV2(IObjectWrapper resources, int flags); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IGoogleMapDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IGoogleMapDelegate.aidl deleted file mode 100644 index b8866644..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IGoogleMapDelegate.aidl +++ /dev/null @@ -1,143 +0,0 @@ -package com.google.android.gms.maps.internal; - -import android.location.Location; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.internal.ICancelableCallback; -import com.google.android.gms.maps.internal.ILocationSourceDelegate; -import com.google.android.gms.maps.internal.IUiSettingsDelegate; -import com.google.android.gms.maps.internal.IProjectionDelegate; -import com.google.android.gms.maps.internal.IOnCameraChangeListener; -import com.google.android.gms.maps.internal.IOnCameraIdleListener; -import com.google.android.gms.maps.internal.IOnCameraMoveCanceledListener; -import com.google.android.gms.maps.internal.IOnCameraMoveListener; -import com.google.android.gms.maps.internal.IOnCameraMoveStartedListener; -import com.google.android.gms.maps.internal.IOnMapClickListener; -import com.google.android.gms.maps.internal.IOnMapLongClickListener; -import com.google.android.gms.maps.internal.IOnMarkerClickListener; -import com.google.android.gms.maps.internal.IOnMarkerDragListener; -import com.google.android.gms.maps.internal.IOnInfoWindowClickListener; -import com.google.android.gms.maps.internal.IInfoWindowAdapter; -import com.google.android.gms.maps.internal.IOnMapLoadedCallback; -import com.google.android.gms.maps.internal.IOnMyLocationChangeListener; -import com.google.android.gms.maps.internal.IOnMyLocationButtonClickListener; -import com.google.android.gms.maps.internal.ISnapshotReadyCallback; -import com.google.android.gms.maps.model.CircleOptions; -import com.google.android.gms.maps.model.GroundOverlayOptions; -import com.google.android.gms.maps.model.LatLngBounds; -import com.google.android.gms.maps.model.MarkerOptions; -import com.google.android.gms.maps.model.PolygonOptions; -import com.google.android.gms.maps.model.PolylineOptions; -import com.google.android.gms.maps.model.TileOverlayOptions; -import com.google.android.gms.maps.model.internal.IPolylineDelegate; -import com.google.android.gms.maps.model.internal.IPolygonDelegate; -import com.google.android.gms.maps.model.internal.IMarkerDelegate; -import com.google.android.gms.maps.model.internal.ICircleDelegate; -import com.google.android.gms.maps.model.internal.IGroundOverlayDelegate; -import com.google.android.gms.maps.model.internal.ITileOverlayDelegate; - -interface IGoogleMapDelegate { - CameraPosition getCameraPosition() = 0; - - float getMaxZoomLevel() = 1; - float getMinZoomLevel() = 2; - - void moveCamera(IObjectWrapper cameraUpdate) = 3; - void animateCamera(IObjectWrapper cameraUpdate) = 4; - void animateCameraWithCallback(IObjectWrapper cameraUpdate, ICancelableCallback callback) = 5; - void animateCameraWithDurationAndCallback(IObjectWrapper cameraUpdate, int duration, ICancelableCallback callback) = 6; - void stopAnimation() = 7; - - IPolylineDelegate addPolyline(in PolylineOptions options) = 8; - IPolygonDelegate addPolygon(in PolygonOptions options) = 9; - IMarkerDelegate addMarker(in MarkerOptions options) = 10; - IGroundOverlayDelegate addGroundOverlay(in GroundOverlayOptions options) = 11; - ITileOverlayDelegate addTileOverlay(in TileOverlayOptions options) = 12; - - void clear() = 13; - - int getMapType() = 14; - void setMapType(int type) = 15; - boolean isTrafficEnabled() = 16; - void setTrafficEnabled(boolean traffic) = 17; - boolean isIndoorEnabled() = 18; - void setIndoorEnabled(boolean indoor) = 19; - - boolean isMyLocationEnabled() = 20; - void setMyLocationEnabled(boolean myLocation) = 21; - Location getMyLocation() = 22; - void setLocationSource(ILocationSourceDelegate locationSource) = 23; - - IUiSettingsDelegate getUiSettings() = 24; - IProjectionDelegate getProjection() = 25; - - void setOnCameraChangeListener(IOnCameraChangeListener listener) = 26; - void setOnMapClickListener(IOnMapClickListener listener) = 27; - void setOnMapLongClickListener(IOnMapLongClickListener listener) = 28; - void setOnMarkerClickListener(IOnMarkerClickListener listener) = 29; - void setOnMarkerDragListener(IOnMarkerDragListener listener) = 30; - void setOnInfoWindowClickListener(IOnInfoWindowClickListener listener) = 31; - void setInfoWindowAdapter(IInfoWindowAdapter adapter) = 32; - - IObjectWrapper getTestingHelper() = 33; - - ICircleDelegate addCircle(in CircleOptions options) = 34; - - void setOnMyLocationChangeListener(IOnMyLocationChangeListener listener) = 35; - void setOnMyLocationButtonClickListener(IOnMyLocationButtonClickListener listener) = 36; - - void snapshot(ISnapshotReadyCallback callback, IObjectWrapper bitmap) = 37; - - void setPadding(int left, int top, int right, int bottom) = 38; - - boolean isBuildingsEnabled() = 39; - void setBuildingsEnabled(boolean buildings) = 40; - - void setOnMapLoadedCallback(IOnMapLoadedCallback callback) = 41; - - //IIndoorBuildingDelegate getFocusedBuilding() = 43; - //void setIndoorStateChangeListener(IOnIndoorStateChangeListener listener) = 44; - - void setWatermarkEnabled(boolean watermark) = 50; - - //void getMapAsync(IOnMapReadyCallback callback) = 52; - void onCreate(in Bundle savedInstanceState) = 53; - void onResume() = 54; - void onPause() = 55; - void onDestroy() = 56; - void onLowMemory() = 57; - boolean useViewLifecycleWhenInFragment() = 58; - void onSaveInstanceState(out Bundle outState) = 59; - - void setContentDescription(String desc) = 60; - - //void snapshotForTest(ISnapshotReadyCallback callback) = 70; - - //void setPoiClickListener(IOnPoiClickListener listener) = 79; - void onEnterAmbient(in Bundle bundle) = 80; - void onExitAmbient() = 81; - - //void setOnGroundOverlayClickListener(IOnGroundOverlayClickListener listener) = 82; - //void setInfoWindowLongClickListener(IOnInfoWindowLongClickListener listener) = 83; - //void setPolygonClickListener(IOnPolygonClickListener listener) = 84; - //void setInfoWindowCloseListener(IOnInfoWindowCloseListener listener) = 85; - //void setPolylineClickListener(IOnPolylineClickListener listener) = 86; - //void setCircleClickListener(IOnCircleClickListener listener) = 88; - - //boolean setMapStyle(in MapStyleOptions options) = 90; - void setMinZoomPreference(float minZoom) = 91; - void setMaxZoomPreference(float maxZoom) = 92; - void resetMinMaxZoomPreference() = 93; - void setLatLngBoundsForCameraTarget(in LatLngBounds bounds) = 94; - - void setCameraMoveStartedListener(IOnCameraMoveStartedListener listener) = 95; - void setCameraMoveListener(IOnCameraMoveListener listener) = 96; - void setCameraMoveCanceledListener(IOnCameraMoveCanceledListener listener) = 97; - void setCameraIdleListener(IOnCameraIdleListener listener) = 98; - - void onStart() = 100; - void onStop() = 101; - - //void setOnMyLocationClickListener(IOnMyLocationClickListener listener) = 106; -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IInfoWindowAdapter.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IInfoWindowAdapter.aidl deleted file mode 100644 index d11d71d4..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IInfoWindowAdapter.aidl +++ /dev/null @@ -1,9 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.model.internal.IMarkerDelegate; - -interface IInfoWindowAdapter { - IObjectWrapper getInfoWindow(IMarkerDelegate marker); - IObjectWrapper getInfoContents(IMarkerDelegate marker); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ILocationSourceDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ILocationSourceDelegate.aidl deleted file mode 100644 index 203ec69f..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ILocationSourceDelegate.aidl +++ /dev/null @@ -1,4 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface ILocationSourceDelegate { -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IMapFragmentDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IMapFragmentDelegate.aidl deleted file mode 100644 index c08c987b..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IMapFragmentDelegate.aidl +++ /dev/null @@ -1,27 +0,0 @@ -package com.google.android.gms.maps.internal; - -import android.os.Bundle; - -import com.google.android.gms.maps.internal.IGoogleMapDelegate; -import com.google.android.gms.maps.internal.IOnMapReadyCallback; -import com.google.android.gms.maps.GoogleMapOptions; -import com.google.android.gms.dynamic.IObjectWrapper; - -interface IMapFragmentDelegate { - IGoogleMapDelegate getMap(); - void onInflate(IObjectWrapper activity, in GoogleMapOptions options, in Bundle savedInstanceState); - void onCreate(in Bundle savedInstanceState); - IObjectWrapper onCreateView(IObjectWrapper layoutInflater, IObjectWrapper container, in Bundle savedInstanceState); - void onResume(); - void onPause(); - void onDestroyView(); - void onDestroy(); - void onLowMemory(); - void onSaveInstanceState(inout Bundle outState); - boolean isReady(); - void getMapAsync(IOnMapReadyCallback callback); - void onEnterAmbient(in Bundle bundle); - void onExitAmbient(); - void onStart(); - void onStop(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IMapViewDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IMapViewDelegate.aidl deleted file mode 100644 index d22db6c6..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IMapViewDelegate.aidl +++ /dev/null @@ -1,23 +0,0 @@ -package com.google.android.gms.maps.internal; - -import android.os.Bundle; - -import com.google.android.gms.maps.internal.IGoogleMapDelegate; -import com.google.android.gms.maps.internal.IOnMapReadyCallback; -import com.google.android.gms.dynamic.IObjectWrapper; - -interface IMapViewDelegate { - IGoogleMapDelegate getMap(); - void onCreate(in Bundle savedInstanceState); - void onResume(); - void onPause(); - void onDestroy(); - void onLowMemory(); - void onSaveInstanceState(inout Bundle outState); - IObjectWrapper getView(); - void getMapAsync(IOnMapReadyCallback callback); - void onEnterAmbient(in Bundle bundle); - void onExitAmbient(); - void onStart(); - void onStop(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraChangeListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraChangeListener.aidl deleted file mode 100644 index 8abd2929..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraChangeListener.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.maps.model.CameraPosition; - -interface IOnCameraChangeListener { - void onCameraChange(in CameraPosition update); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraIdleListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraIdleListener.aidl deleted file mode 100644 index caa686a8..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraIdleListener.aidl +++ /dev/null @@ -1,5 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface IOnCameraIdleListener { - void onCameraIdle(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveCanceledListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveCanceledListener.aidl deleted file mode 100644 index bb1494e8..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveCanceledListener.aidl +++ /dev/null @@ -1,5 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface IOnCameraMoveCanceledListener { - void onCameraMoveCanceled(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveListener.aidl deleted file mode 100644 index 6b404d65..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveListener.aidl +++ /dev/null @@ -1,5 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface IOnCameraMoveListener { - void onCameraMove(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveStartedListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveStartedListener.aidl deleted file mode 100644 index 2a5f65d9..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnCameraMoveStartedListener.aidl +++ /dev/null @@ -1,5 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface IOnCameraMoveStartedListener { - void onCameraMoveStarted(int i); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnInfoWindowClickListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnInfoWindowClickListener.aidl deleted file mode 100644 index 7c396ce7..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnInfoWindowClickListener.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.maps.model.internal.IMarkerDelegate; - -interface IOnInfoWindowClickListener { - void onInfoWindowClick(IMarkerDelegate marker); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapClickListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapClickListener.aidl deleted file mode 100644 index 6b3b2ec8..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapClickListener.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.maps.model.LatLng; - -interface IOnMapClickListener { - void onMapClick(in LatLng latLng); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapLoadedCallback.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapLoadedCallback.aidl deleted file mode 100644 index d3fc105d..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapLoadedCallback.aidl +++ /dev/null @@ -1,5 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface IOnMapLoadedCallback { - void onMapLoaded(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapLongClickListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapLongClickListener.aidl deleted file mode 100644 index 11201b2c..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapLongClickListener.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.maps.model.LatLng; - -interface IOnMapLongClickListener { - void onMapLongClick(in LatLng latLng); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapReadyCallback.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapReadyCallback.aidl deleted file mode 100644 index 1e6760ef..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMapReadyCallback.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.maps.internal.IGoogleMapDelegate; - -interface IOnMapReadyCallback { - void onMapReady(IGoogleMapDelegate map); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMarkerClickListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMarkerClickListener.aidl deleted file mode 100644 index 94c4465d..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMarkerClickListener.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.maps.model.internal.IMarkerDelegate; - -interface IOnMarkerClickListener { - boolean onMarkerClick(IMarkerDelegate marker); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMarkerDragListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMarkerDragListener.aidl deleted file mode 100644 index b4601a7a..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMarkerDragListener.aidl +++ /dev/null @@ -1,9 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.maps.model.internal.IMarkerDelegate; - -interface IOnMarkerDragListener { - void onMarkerDragStart(IMarkerDelegate marker) = 0; - void onMarkerDrag(IMarkerDelegate marker) = 1; - void onMarkerDragEnd(IMarkerDelegate marker) = 2; -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMyLocationButtonClickListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMyLocationButtonClickListener.aidl deleted file mode 100644 index b10880dd..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMyLocationButtonClickListener.aidl +++ /dev/null @@ -1,4 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface IOnMyLocationButtonClickListener { -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMyLocationChangeListener.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMyLocationChangeListener.aidl deleted file mode 100644 index 35a6b6c2..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IOnMyLocationChangeListener.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; - -interface IOnMyLocationChangeListener { - void onMyLocationChanged(IObjectWrapper location); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IProjectionDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IProjectionDelegate.aidl deleted file mode 100644 index 9b2da90b..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IProjectionDelegate.aidl +++ /dev/null @@ -1,11 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.VisibleRegion; - -interface IProjectionDelegate { - LatLng fromScreenLocation(IObjectWrapper obj); - IObjectWrapper toScreenLocation(in LatLng latLng); - VisibleRegion getVisibleRegion(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ISnapshotReadyCallback.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ISnapshotReadyCallback.aidl deleted file mode 100644 index f907e336..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/ISnapshotReadyCallback.aidl +++ /dev/null @@ -1,9 +0,0 @@ -package com.google.android.gms.maps.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; -import android.graphics.Bitmap; - -interface ISnapshotReadyCallback { - void onBitmapReady(in Bitmap bitmap); - void onBitmapWrappedReady(IObjectWrapper wrapper); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IUiSettingsDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IUiSettingsDelegate.aidl deleted file mode 100644 index 12c78123..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/internal/IUiSettingsDelegate.aidl +++ /dev/null @@ -1,25 +0,0 @@ -package com.google.android.gms.maps.internal; - -interface IUiSettingsDelegate { - void setZoomControlsEnabled(boolean zoom); - void setCompassEnabled(boolean compass); - void setMyLocationButtonEnabled(boolean locationButton); - void setScrollGesturesEnabled(boolean scrollGestures); - void setZoomGesturesEnabled(boolean zoomGestures); - void setTiltGesturesEnabled(boolean tiltGestures); - void setRotateGesturesEnabled(boolean rotateGestures); - void setAllGesturesEnabled(boolean gestures); - boolean isZoomControlsEnabled(); - boolean isCompassEnabled(); - boolean isMyLocationButtonEnabled(); - boolean isScrollGesturesEnabled(); - boolean isZoomGesturesEnabled(); - boolean isTiltGesturesEnabled(); - boolean isRotateGesturesEnabled(); - void setIndoorLevelPickerEnabled(boolean indoorLevelPicker); - boolean isIndoorLevelPickerEnabled(); - void setMapToolbarEnabled(boolean mapToolbar); - boolean isMapToolbarEnabled(); - void setScrollGesturesEnabledDuringRotateOrZoom(boolean scrollDuringZoom); - boolean isScrollGesturesEnabledDuringRotateOrZoom(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/CameraPosition.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/CameraPosition.aidl deleted file mode 100644 index bb5ab701..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/CameraPosition.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable CameraPosition; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/CircleOptions.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/CircleOptions.aidl deleted file mode 100644 index 33ae4542..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/CircleOptions.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable CircleOptions; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/GroundOverlayOptions.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/GroundOverlayOptions.aidl deleted file mode 100644 index 5bdbefaf..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/GroundOverlayOptions.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable GroundOverlayOptions; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/MarkerOptions.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/MarkerOptions.aidl deleted file mode 100644 index dc4abbcf..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/MarkerOptions.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable MarkerOptions; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/PolygonOptions.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/PolygonOptions.aidl deleted file mode 100644 index adac82a0..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/PolygonOptions.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable PolygonOptions; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/PolylineOptions.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/PolylineOptions.aidl deleted file mode 100644 index 7c165891..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/PolylineOptions.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable PolylineOptions; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/Tile.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/Tile.aidl deleted file mode 100644 index 54f1872f..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/Tile.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable Tile; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/TileOverlayOptions.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/TileOverlayOptions.aidl deleted file mode 100644 index 85f5ac32..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/TileOverlayOptions.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable TileOverlayOptions; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/VisibleRegion.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/VisibleRegion.aidl deleted file mode 100644 index 09d22101..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/VisibleRegion.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable VisibleRegion; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IBitmapDescriptorFactoryDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IBitmapDescriptorFactoryDelegate.aidl deleted file mode 100644 index dca49b60..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IBitmapDescriptorFactoryDelegate.aidl +++ /dev/null @@ -1,14 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -import android.graphics.Bitmap; -import com.google.android.gms.dynamic.IObjectWrapper; - -interface IBitmapDescriptorFactoryDelegate { - IObjectWrapper fromResource(int resourceId); - IObjectWrapper fromAsset(String assetName); - IObjectWrapper fromFile(String fileName); - IObjectWrapper defaultMarker(); - IObjectWrapper defaultMarkerWithHue(float hue); - IObjectWrapper fromBitmap(in Bitmap bitmap); - IObjectWrapper fromPath(String absolutePath); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ICircleDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ICircleDelegate.aidl deleted file mode 100644 index 719d8eab..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ICircleDelegate.aidl +++ /dev/null @@ -1,24 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -import com.google.android.gms.maps.model.LatLng; - -interface ICircleDelegate { - void remove(); - String getId(); - void setCenter(in LatLng center); - LatLng getCenter(); - void setRadius(double radius); - double getRadius(); - void setStrokeWidth(float width); - float getStrokeWidth(); - void setStrokeColor(int color); - int getStrokeColor(); - void setFillColor(int color); - int getFillColor(); - void setZIndex(float zIndex); - float getZIndex(); - void setVisible(boolean visible); - boolean isVisible(); - boolean equalsRemote(ICircleDelegate other); - int hashCodeRemote(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IGroundOverlayDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IGroundOverlayDelegate.aidl deleted file mode 100644 index 0a1a0632..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IGroundOverlayDelegate.aidl +++ /dev/null @@ -1,29 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -interface IGroundOverlayDelegate { - void remove(); - String getId(); - void setPosition(in LatLng pos); - LatLng getPosition(); - void setDimension(float dimension); - void setDimensions(float width, float height); - float getWidth(); - float getHeight(); - void setPositionFromBounds(in LatLngBounds bounds); - LatLngBounds getBounds(); - void setBearing(float bearing); - float getBearing(); - void setZIndex(float zIndex); - float getZIndex(); - void setVisible(boolean visible); - boolean isVisible(); - void setTransparency(float transparency); - float getTransparency(); - boolean equalsRemote(IGroundOverlayDelegate other); - int hashCodeRemote(); - void todo(IObjectWrapper obj); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IMarkerDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IMarkerDelegate.aidl deleted file mode 100644 index ca2d2603..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IMarkerDelegate.aidl +++ /dev/null @@ -1,37 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.model.LatLng; - -interface IMarkerDelegate { - void remove(); - String getId(); - void setPosition(in LatLng pos); - LatLng getPosition(); - void setTitle(String title); - String getTitle(); - void setSnippet(String snippet); - String getSnippet(); - void setDraggable(boolean drag); - boolean isDraggable(); - void showInfoWindow(); - void hideInfoWindow(); - boolean isInfoWindowShown(); - void setVisible(boolean visible); - boolean isVisible(); - boolean equalsRemote(IMarkerDelegate other); - int hashCodeRemote(); - void setIcon(IObjectWrapper obj); - void setAnchor(float x, float y); - void setFlat(boolean flat); - boolean isFlat(); - void setRotation(float rotation); - float getRotation(); - void setInfoWindowAnchor(float x, float y); - void setAlpha(float alpha); - float getAlpha(); - void setZIndex(float zIndex); - float getZIndex(); - void setTag(IObjectWrapper obj); - IObjectWrapper getTag(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IPolygonDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IPolygonDelegate.aidl deleted file mode 100644 index 67f0517b..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IPolygonDelegate.aidl +++ /dev/null @@ -1,27 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -import com.google.android.gms.maps.model.LatLng; - -interface IPolygonDelegate { - void remove(); - String getId(); - void setPoints(in List points); - List getPoints(); - void setHoles(in List holes); - List getHoles(); - void setStrokeWidth(float width); - float getStrokeWidth(); - void setStrokeColor(int color); - int getStrokeColor(); - void setFillColor(int color); - int getFillColor(); - void setZIndex(float zIndex); - float getZIndex(); - void setVisible(boolean visible); - boolean isVisible(); - void setGeodesic(boolean geod); - boolean isGeodesic(); - boolean equalsRemote(IPolygonDelegate other); - int hashCodeRemote(); - -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IPolylineDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IPolylineDelegate.aidl deleted file mode 100644 index ebbb336b..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/IPolylineDelegate.aidl +++ /dev/null @@ -1,22 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -import com.google.android.gms.maps.model.LatLng; - -interface IPolylineDelegate { - void remove(); - String getId(); - void setPoints(in List points); - List getPoints(); - void setWidth(float width); - float getWidth(); - void setColor(int color); - int getColor(); - void setZIndex(float zIndex); - float getZIndex(); - void setVisible(boolean visible); - boolean isVisible(); - void setGeodesic(boolean geod); - boolean isGeodesic(); - boolean equalsRemote(IPolylineDelegate other); - int hashCodeRemote(); -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ITileOverlayDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ITileOverlayDelegate.aidl deleted file mode 100644 index 417cb024..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ITileOverlayDelegate.aidl +++ /dev/null @@ -1,4 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -interface ITileOverlayDelegate { -} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ITileProviderDelegate.aidl b/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ITileProviderDelegate.aidl deleted file mode 100644 index d6dc516b..00000000 --- a/play-services-api/src/main/aidl/com/google/android/gms/maps/model/internal/ITileProviderDelegate.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.maps.model.internal; - -import com.google.android.gms.maps.model.Tile; - -interface ITileProviderDelegate { - Tile getTile(int x, int y, int zoom); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/GoogleMapOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/GoogleMapOptions.java deleted file mode 100644 index 405f31d1..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/GoogleMapOptions.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps; - -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.model.LatLngBounds; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public final class GoogleMapOptions extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode; - @SafeParceled(2) - private int zOrderOnTop; - @SafeParceled(3) - private boolean useViewLifecycleInFragment; - @SafeParceled(4) - private int mapType; - @SafeParceled(5) - private CameraPosition camera; - @SafeParceled(6) - private boolean zoomControlsEnabled; - @SafeParceled(7) - private boolean compassEnabled; - @SafeParceled(8) - private boolean scrollGesturesEnabled = true; - @SafeParceled(9) - private boolean zoomGesturesEnabled = true; - @SafeParceled(10) - private boolean tiltGesturesEnabled = true; - @SafeParceled(11) - private boolean rotateGesturesEnabled = true; - @SafeParceled(12) - private boolean liteMode = false; - @SafeParceled(14) - private boolean mapToobarEnabled = false; - @SafeParceled(15) - private boolean ambientEnabled = false; - @SafeParceled(16) - private float minZoom; - @SafeParceled(17) - private float maxZoom; - @SafeParceled(18) - private LatLngBounds boundsForCamera; - @SafeParceled(19) - private boolean scrollGesturesEnabledDuringRotateOrZoom = true; - - public GoogleMapOptions() { - } - - public Boolean getAmbientEnabled() { - return ambientEnabled; - } - - public CameraPosition getCamera() { - return camera; - } - - public Boolean getCompassEnabled() { - return compassEnabled; - } - - public LatLngBounds getLatLngBoundsForCameraTarget() { - return boundsForCamera; - } - - public Boolean getLiteMode() { - return liteMode; - } - - public Boolean getMapToolbarEnabled() { - return mapToobarEnabled; - } - - public int getMapType() { - return mapType; - } - - public Float getMaxZoomPreference() { - return maxZoom; - } - - public Float getMinZoomPreference() { - return minZoom; - } - - public Boolean getRotateGesturesEnabled() { - return rotateGesturesEnabled; - } - - public Boolean getScrollGesturesEnabled() { - return scrollGesturesEnabled; - } - - public Boolean getScrollGesturesEnabledDuringRotateOrZoom() { - return scrollGesturesEnabledDuringRotateOrZoom; - } - - public Boolean getTiltGesturesEnabled() { - return tiltGesturesEnabled; - } - - public Boolean getUseViewLifecycleInFragment() { - return useViewLifecycleInFragment; - } - - public Boolean getZOrderOnTop() { - return zOrderOnTop == 1; // TODO - } - - public Boolean getZoomControlsEnabled() { - return zoomControlsEnabled; - } - - public Boolean getZoomGesturesEnabled() { - return zoomGesturesEnabled; - } - - @Deprecated - public boolean isCompassEnabled() { - return compassEnabled; - } - - @Deprecated - public boolean isZoomControlsEnabled() { - return zoomControlsEnabled; - } - - @Deprecated - public boolean isScrollGesturesEnabled() { - return scrollGesturesEnabled; - } - - @Deprecated - public boolean isZoomGesturesEnabled() { - return zoomGesturesEnabled; - } - - @Deprecated - public boolean isTiltGesturesEnabled() { - return tiltGesturesEnabled; - } - - @Deprecated - public boolean isRotateGesturesEnabled() { - return rotateGesturesEnabled; - } - - - public static Creator CREATOR = new AutoCreator(GoogleMapOptions.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/StreetViewPanoramaOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/StreetViewPanoramaOptions.java deleted file mode 100644 index e59c7935..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/StreetViewPanoramaOptions.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps; - -public class StreetViewPanoramaOptions { -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/internal/Point.java b/play-services-api/src/main/java/com/google/android/gms/maps/internal/Point.java deleted file mode 100644 index 9d31c133..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/internal/Point.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.internal; - -public class Point { -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/BitmapDescriptor.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/BitmapDescriptor.java deleted file mode 100644 index 881c8abb..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/BitmapDescriptor.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import com.google.android.gms.dynamic.IObjectWrapper; - -import org.microg.gms.common.PublicApi; - -/** - * Defines an image. For a marker, it can be used to set the image of the marker icon. For a ground - * overlay, it can be used to set the image to place on the surface of the earth. - */ -@PublicApi -public class BitmapDescriptor { - private final IObjectWrapper remoteObject; - - public BitmapDescriptor(IObjectWrapper remoteObject) { - this.remoteObject = remoteObject; - } - - public IObjectWrapper getRemoteObject() { - return remoteObject; - } -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/CameraPosition.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/CameraPosition.java deleted file mode 100644 index c6fbe415..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/CameraPosition.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import android.content.Context; -import android.util.AttributeSet; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.Arrays; - -/** - * An immutable class that aggregates all camera position parameters. - */ -@PublicApi -public final class CameraPosition extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - /** - * The location that the camera is pointing at. - */ - @SafeParceled(2) - public final LatLng target; - /** - * Zoom level near the center of the screen. - * See {@link Builder#zoom(float)} for the definition of the camera's zoom level. - */ - @SafeParceled(3) - public final float zoom; - /** - * The angle, in degrees, of the camera angle from the nadir (directly facing the Earth). - * See {@link Builder#tilt(float)} for details of restrictions on the range of values. - */ - @SafeParceled(4) - public final float tilt; - /** - * Direction that the camera is pointing in, in degrees clockwise from north. - */ - @SafeParceled(5) - public final float bearing; - - /** - * This constructor is dirty setting the final fields to make the compiler happy. - * In fact, those are replaced by their real values later using SafeParcelUtil. - */ - private CameraPosition() { - target = null; - zoom = tilt = bearing = 0; - } - - /** - * Constructs a CameraPosition. - * - * @param target The target location to align with the center of the screen. - * @param zoom Zoom level at target. See {@link #zoom} for details of restrictions. - * @param tilt The camera angle, in degrees, from the nadir (directly down). See - * {@link #tilt} for details of restrictions. - * @param bearing Direction that the camera is pointing in, in degrees clockwise from north. - * This value will be normalized to be within 0 degrees inclusive and 360 - * degrees exclusive. - * @throws NullPointerException if {@code target} is {@code null} - * @throws IllegalArgumentException if {@code tilt} is outside range of {@code 0} to {@code 90} - * degrees inclusive - */ - public CameraPosition(LatLng target, float zoom, float tilt, float bearing) - throws NullPointerException, IllegalArgumentException { - if (target == null) { - throw new NullPointerException("null camera target"); - } - this.target = target; - this.zoom = zoom; - if (tilt < 0 || 90 < tilt) { - throw new IllegalArgumentException("Tilt needs to be between 0 and 90 inclusive"); - } - this.tilt = tilt; - if (bearing <= 0) { - bearing += 360; - } - this.bearing = bearing % 360; - } - - /** - * Creates a builder for a camera position. - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Creates a builder for a camera position, initialized to a given position. - */ - public static Builder builder(CameraPosition camera) { - return new Builder(camera); - } - - /** - * Creates a CameraPostion from the attribute set - * - * @throws UnsupportedOperationException - */ - public static CameraPosition createFromAttributes(Context context, AttributeSet attrs) { - return null; // TODO - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - CameraPosition that = (CameraPosition) o; - - if (Float.compare(that.bearing, bearing) != 0) - return false; - if (Float.compare(that.tilt, tilt) != 0) - return false; - if (Float.compare(that.zoom, zoom) != 0) - return false; - if (!target.equals(that.target)) - return false; - - return true; - } - - /** - * Constructs a CameraPosition pointed for a particular target and zoom level. The resultant - * bearing is North, and the viewing angle is perpendicular to the Earth's surface. i.e., - * directly facing the Earth's surface, with the top of the screen pointing North. - * - * @param target The target location to align with the center of the screen. - * @param zoom Zoom level at target. See {@link Builder#zoom(float)} for details on the range - * the value will be clamped to. The larger the value the more zoomed in the - * camera is. - */ - public static final CameraPosition fromLatLngZoom(LatLng target, float zoom) { - return builder().target(target).zoom(zoom).build(); - } - - @Override - public int hashCode() { - return Arrays.hashCode(new Object[] { target, zoom, tilt, bearing }); - } - - @Override - public String toString() { - return "CameraPosition{" + - "target=" + target + - ", zoom=" + zoom + - ", tilt=" + tilt + - ", bearing=" + bearing + - '}'; - } - - public static Creator CREATOR = new AutoCreator(CameraPosition.class); - - /** - * Builds camera position. - */ - public static final class Builder { - private LatLng target; - private float zoom; - private float tilt; - private float bearing; - - public Builder() { - } - - public Builder(CameraPosition previous) { - target = previous.target; - zoom = previous.zoom; - tilt = previous.tilt; - bearing = previous.bearing; - } - - /** - * Sets the direction that the camera is pointing in, in degrees clockwise from north. - */ - public Builder bearing(float bearing) { - this.bearing = bearing; - return this; - } - - /** - * Builds a {@link CameraPosition}. - */ - public CameraPosition build() { - return new CameraPosition(target, zoom, tilt, bearing); - } - - /** - * Sets the location that the camera is pointing at. - */ - public Builder target(LatLng target) { - this.target = target; - return this; - } - - /** - * Sets the angle, in degrees, of the camera from the nadir (directly facing the Earth). - * When changing the camera position for a map, this value is restricted depending on the - * zoom level of the camera. The restrictions are as follows: - *
    - *
  • For zoom levels less than 10 the maximum is 30.
  • - *
  • For zoom levels from 10 to 14 the maximum increases linearly from 30 to 45 (e.g. at - * zoom level 12, the maximum is 37.5).
  • - *
  • For zoom levels from 14 to 15.5 the maximum increases linearly from 45 to 67.5.
  • - *
  • For zoom levels greater than 15.5 the maximum is 67.5.
  • - *
- * The minimum is always 0 (directly down). If you specify a value outside this range and try to move the camera to this camera position it will be clamped to these bounds. - */ - public Builder tilt(float tilt) { - this.tilt = tilt; - return this; - } - - /** - * Sets the zoom level of the camera. Zoom level is defined such that at zoom level 0, the - * whole world is approximately 256dp wide (assuming that the camera is not tilted). - * Increasing the zoom level by 1 doubles the width of the world on the screen. Hence at - * zoom level N, the width of the world is approximately 256 * 2 N dp, i.e., at zoom level - * 2, the whole world is approximately 1024dp wide. - *

- * When changing the camera position for a map, the zoom level of the camera is restricted - * to a certain range depending on various factors including location, map type and map - * size. Note that the camera zoom need not be an integer value. - */ - public Builder zoom(float zoom) { - this.zoom = zoom; - return this; - } - } -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/CircleOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/CircleOptions.java deleted file mode 100644 index 9f611060..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/CircleOptions.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import android.graphics.Color; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * Defines options for a Circle. - */ -@PublicApi -public class CircleOptions extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode; - @SafeParceled(2) - private LatLng center; - @SafeParceled(3) - private double radius = 0; - @SafeParceled(4) - private float strokeWidth = 10; - @SafeParceled(5) - private int strokeColor = Color.BLACK; - @SafeParceled(6) - private int fillColor = Color.TRANSPARENT; - @SafeParceled(7) - private float zIndex = 0; - @SafeParceled(8) - private boolean visible = true; - - /** - * Creates circle options. - */ - public CircleOptions() { - } - - /** - * Sets the center using a {@link LatLng}. - *

- * The center must not be {@code null}. - *

- * This method is mandatory because there is no default center. - * - * @param center The geographic center as a {@link LatLng}. - * @return this {@link CircleOptions} object - */ - public CircleOptions center(LatLng center) { - this.center = center; - return this; - } - - /** - * Sets the fill color. - *

- * The fill color is the color inside the circle, in the integer format specified by - * {@link Color}. If TRANSPARENT is used then no fill is drawn. - *

- * By default the fill color is transparent ({@code 0x00000000}). - * - * @param color color in the {@link Color} format - * @return this {@link CircleOptions} object - */ - public CircleOptions fillColor(int color) { - this.fillColor = color; - return this; - } - - /** - * Returns the center as a {@link LatLng}. - * - * @return The geographic center as a {@link LatLng}. - */ - public LatLng getCenter() { - return center; - } - - /** - * Returns the fill color. - * - * @return The color in the {@link Color} format. - */ - public int getFillColor() { - return fillColor; - } - - /** - * Returns the circle's radius, in meters. - * - * @return The radius in meters. - */ - public double getRadius() { - return radius; - } - - /** - * Returns the stroke color. - * - * @return The color in the {@link Color} format. - */ - public int getStrokeColor() { - return strokeColor; - } - - /** - * Returns the stroke width. - * - * @return The width in screen pixels. - */ - public float getStrokeWidth() { - return strokeWidth; - } - - /** - * Returns the zIndex. - * - * @return The zIndex value. - */ - public float getZIndex() { - return zIndex; - } - - /** - * Checks whether the circle is visible. - * - * @return {code true} if the circle is visible; {@code false} if it is invisible. - */ - public boolean isVisible() { - return visible; - } - - /** - * Sets the radius in meters. - *

- * The radius must be zero or greater. The default radius is zero. - * - * @param radius radius in meters - * @return this {@link CircleOptions} object - */ - public CircleOptions radius(double radius) { - this.radius = radius; - return this; - } - - /** - * Sets the stroke color. - *

- * The stroke color is the color of this circle's outline, in the integer format specified by - * {@link Color}. If TRANSPARENT is used then no outline is drawn. - *

- * By default the stroke color is black ({@code 0xff000000}). - * - * @param color color in the {@link Color} format - * @return this {@link CircleOptions} object - */ - public CircleOptions strokeColor(int color) { - this.strokeColor = color; - return this; - } - - /** - * Sets the stroke width. - *

- * The stroke width is the width (in screen pixels) of the circle's outline. It must be zero or - * greater. If it is zero then no outline is drawn. - *

- * The default width is 10 pixels. - * - * @param width width in screen pixels - * @return this {@link CircleOptions} object - */ - public CircleOptions strokeWidth(float width) { - this.strokeWidth = width; - return this; - } - - /** - * Sets the visibility. - *

- * If this circle is not visible then it is not drawn, but all other state is preserved. - * - * @param visible {@code false} to make this circle invisible - * @return this {@link CircleOptions} object - */ - public CircleOptions visible(boolean visible) { - this.visible = visible; - return this; - } - - /** - * Sets the zIndex. - *

- * Overlays (such as circles) with higher zIndices are drawn above those with lower indices. - *

- * By default the zIndex is {@code 0.0}. - * - * @param zIndex zIndex value - * @return this {@link CircleOptions} object - */ - public CircleOptions zIndex(float zIndex) { - this.zIndex = zIndex; - return this; - } - - public static Creator CREATOR = new AutoCreator(CircleOptions.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/GroundOverlayOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/GroundOverlayOptions.java deleted file mode 100644 index b29afdf7..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/GroundOverlayOptions.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import android.os.IBinder; - -import com.google.android.gms.dynamic.ObjectWrapper; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * Defines options for a ground overlay. - */ -@PublicApi -public class GroundOverlayOptions extends AutoSafeParcelable { - /** - * Flag for when no dimension is specified for the height. - */ - public static final float NO_DIMENSION = -1; - - @SafeParceled(1) - private int versionCode; - @SafeParceled(2) - private IBinder image; - private BitmapDescriptor imageDescriptor; - @SafeParceled(3) - private LatLng location; - @SafeParceled(4) - private float width; - @SafeParceled(5) - private float height; - @SafeParceled(6) - private LatLngBounds bounds; - @SafeParceled(7) - private float bearing; - @SafeParceled(8) - private float zIndex; - @SafeParceled(9) - private boolean visible; - @SafeParceled(10) - private float transparency = 0; - @SafeParceled(11) - private float anchorU; - @SafeParceled(12) - private float anchorV; - - /** - * Creates a new set of ground overlay options. - */ - public GroundOverlayOptions() { - } - - /** - * Specifies the anchor to be at a particular point in the image. - *

- * The anchor specifies the point in the image that aligns with the ground overlay's location. - *

- * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) - * is the top-left corner of the image, and (1, 1) is the bottom-right corner. - * - * @param u u-coordinate of the anchor, as a ratio of the image width (in the range [0, 1]) - * @param v v-coordinate of the anchor, as a ratio of the image height (in the range [0, 1]) - * @return this {@link GroundOverlayOptions} object with a new anchor set. - */ - public GroundOverlayOptions anchor(float u, float v) { - this.anchorU = u; - this.anchorV = v; - return this; - } - - /** - * Specifies the bearing of the ground overlay in degrees clockwise from north. The rotation is - * performed about the anchor point. If not specified, the default is 0 (i.e., up on the image - * points north). - *

- * If a ground overlay with position set using {@link #positionFromBounds(LatLngBounds)} is - * rotated, its size will preserved and it will no longer be guaranteed to fit inside the - * bounds. - * - * @param bearing the bearing in degrees clockwise from north. Values outside the range - * [0, 360) will be normalized. - * @return this {@link GroundOverlayOptions} object with a new bearing set. - */ - public GroundOverlayOptions bearing(float bearing) { - this.bearing = bearing; - return this; - } - - /** - * Horizontal distance, normalized to [0, 1], of the anchor from the left edge. - * - * @return the u value of the anchor. - */ - public float getAnchorU() { - return anchorU; - } - - /** - * Vertical distance, normalized to [0, 1], of the anchor from the top edge. - * - * @return the v value of the anchor. - */ - public float getAnchorV() { - return anchorV; - } - - /** - * Gets the bearing set for this options object. - * - * @return the bearing of the ground overlay. - */ - public float getBearing() { - return bearing; - } - - /** - * Gets the bounds set for this options object. - * - * @return the bounds of the ground overlay. This will be {@code null} if the position was set - * using {@link #position(LatLng, float)} or {@link #position(LatLng, float, float)} - */ - public LatLngBounds getBounds() { - return bounds; - } - - /** - * Gets the height set for this options object. - * - * @return the height of the ground overlay. - */ - public float getHeight() { - return height; - } - - /** - * Gets the image set for this options object. - * - * @return the image of the ground overlay. - */ - public BitmapDescriptor getImage() { - if (imageDescriptor == null && image != null) { - imageDescriptor = new BitmapDescriptor(ObjectWrapper.asInterface(image)); - } - return imageDescriptor; - } - - /** - * Gets the location set for this options object. - * - * @return the location to place the anchor of the ground overlay. This will be {@code null} - * if the position was set using {@link #positionFromBounds(LatLngBounds)}. - */ - public LatLng getLocation() { - return location; - } - - /** - * Gets the transparency set for this options object. - * - * @return the transparency of the ground overlay. - */ - public float getTransparency() { - return transparency; - } - - /** - * Gets the width set for this options object. - * - * @return the width of the ground overlay. - */ - public float getWidth() { - return width; - } - - /** - * Gets the zIndex set for this options object. - * - * @return the zIndex of the ground overlay. - */ - public float getZIndex() { - return zIndex; - } - - /** - * Specifies the image for this ground overlay. - *

- * To load an image as a texture (which is used to draw the image on a map), it must be - * converted into an image with sides that are powers of two. This is so that a mipmap can be - * created in order to render the texture at various zoom levels - see - * Mipmap (Wikipedia) for details. Hence, to - * conserve memory by avoiding this conversion, it is advised that the dimensions of the image - * are powers of two. - * - * @param image the {@link BitmapDescriptor} to use for this ground overlay - * @return this {@link GroundOverlayOptions} object with a new image set. - */ - public GroundOverlayOptions image(BitmapDescriptor image) { - this.imageDescriptor = image; - this.image = imageDescriptor.getRemoteObject().asBinder(); - return this; - } - - /** - * Gets the visibility setting for this options object. - * - * @return {@code true} if the ground overlay is to be visible; {@code false} if it is not. - */ - public boolean isVisible() { - return visible; - } - - /** - * Specifies the position for this ground overlay using an anchor point (a {@link LatLng}), - * width and height (both in meters). When rendered, the image will be scaled to fit the - * dimensions specified (i.e., its proportions will not necessarily be preserved). - * - * @param location the location on the map {@code LatLng} to which the anchor point in the - * given image will remain fixed. The anchor will remain fixed to the position - * on the ground when transformations are applied (e.g., setDimensions, - * setBearing, etc.). - * @param width the width of the overlay (in meters) - * @param height the height of the overlay (in meters) - * @return this {@link GroundOverlayOptions} object with a new position set. - * @throws IllegalArgumentException if anchor is null - * @throws IllegalArgumentException if width or height are negative - * @throws IllegalStateException if the position was already set using - * {@link #positionFromBounds(LatLngBounds)} - */ - public GroundOverlayOptions position(LatLng location, float width, float height) - throws IllegalArgumentException, IllegalStateException { - position(location, width); - if (height < 0) - throw new IllegalArgumentException("height must not be negative"); - this.height = height; - return this; - } - - /** - * Specifies the position for this ground overlay using an anchor point (a {@link LatLng}) and - * the width (in meters). When rendered, the image will retain its proportions from the bitmap, - * i.e., the height will be calculated to preserve the original proportions of the image. - * - * @param location the location on the map {@link LatLng} to which the anchor point in the - * given image will remain fixed. The anchor will remain fixed to the position - * on the ground when transformations are applied (e.g., setDimensions, - * setBearing, etc.). - * @param width the width of the overlay (in meters). The height will be determined - * automatically based on the image proportions. - * @return this {@link GroundOverlayOptions} object with a new position set. - * @throws IllegalArgumentException if anchor is null - * @throws IllegalArgumentException if width is negative - * @throws IllegalStateException if the position was already set using - * {@link #positionFromBounds(LatLngBounds)} - */ - public GroundOverlayOptions position(LatLng location, float width) - throws IllegalArgumentException, IllegalStateException { - if (location == null) - throw new IllegalArgumentException("location must not be null"); - if (width < 0) - throw new IllegalArgumentException("width must not be negative"); - if (bounds != null) - throw new IllegalStateException("Position already set using positionFromBounds()"); - this.location = location; - this.width = width; - return this; - } - - /** - * Specifies the position for this ground overlay. When rendered, the image will be scaled to - * fit the bounds (i.e., its proportions will not necessarily be preserved). - * - * @param bounds a {@link LatLngBounds} in which to place the ground overlay - * @return this {@link GroundOverlayOptions} object with a new position set. - * @throws IllegalStateException if the position was already set using - * {@link #position(LatLng, float)} or - * {@link #position(LatLng, float, float)} - */ - public GroundOverlayOptions positionFromBounds(LatLngBounds bounds) - throws IllegalStateException { - if (location != null) - throw new IllegalStateException("Position already set using position()"); - this.bounds = bounds; - return this; - } - - /** - * Specifies the transparency of the ground overlay. The default transparency is {code 0} - * (opaque). - * - * @param transparency a float in the range {@code [0..1]} where {@code 0} means that the - * ground overlay is opaque and {code 1} means that the ground overlay is - * transparent - * @return this {@link GroundOverlayOptions} object with a new visibility setting. - * @throws IllegalArgumentException if the transparency is outside the range [0..1]. - */ - public GroundOverlayOptions transparency(float transparency) throws IllegalArgumentException { - if (transparency < 0 || transparency > 1) - throw new IllegalArgumentException("transparency must be in range [0..1]"); - this.transparency = transparency; - return this; - } - - /** - * Specifies the visibility for the ground overlay. The default visibility is {@code true}. - * - * @return this {@link GroundOverlayOptions} object with a new visibility setting. - */ - public GroundOverlayOptions visible(boolean visible) { - this.visible = visible; - return this; - } - - /** - * Specifies the ground overlay's zIndex, i.e., the order in which it will be drawn. See the - * documentation at the top of this class for more information about zIndex. - * - * @return this {@link GroundOverlayOptions} object with a new zIndex set. - */ - public GroundOverlayOptions zIndex(float zIndex) { - this.zIndex = zIndex; - return this; - } - - public static Creator CREATOR = new AutoCreator(GroundOverlayOptions.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/MarkerOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/MarkerOptions.java deleted file mode 100644 index a950cd34..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/MarkerOptions.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import android.os.IBinder; -import com.google.android.gms.dynamic.ObjectWrapper; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -@PublicApi -public class MarkerOptions extends AutoSafeParcelable { - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private LatLng position; - @SafeParceled(3) - private String title; - @SafeParceled(4) - private String snippet; - /** - * This is a IBinder to the remote BitmapDescriptor created using BitmapDescriptorFactory - */ - @SafeParceled(5) - private IBinder iconBinder; - private BitmapDescriptor icon; - @SafeParceled(6) - private float anchorU = 0.5F; - @SafeParceled(7) - private float anchorV = 1F; - @SafeParceled(8) - private boolean draggable; - @SafeParceled(9) - private boolean visible; - @SafeParceled(10) - private boolean flat; - @SafeParceled(11) - private float rotation = 0F; - @SafeParceled(12) - private float infoWindowAnchorU = 0F; - @SafeParceled(13) - private float infoWindowAnchorV = 1F; - @SafeParceled(14) - private float alpha = 1F; - @SafeParceled(15) - private float zIndex = 0F; - - /** - * Creates a new set of marker options. - */ - public MarkerOptions() { - } - - /** - * Sets the alpha (opacity) of the marker. This is a value from 0 to 1, where 0 means the - * marker is completely transparent and 1 means the marker is completely opaque. - * - * @return the object for which the method was called, with the new alpha set. - */ - public MarkerOptions alpha(float alpha) { - this.alpha = alpha; - return this; - } - - /** - * Specifies the anchor to be at a particular point in the marker image. - *

- * The anchor specifies the point in the icon image that is anchored to the marker's position - * on the Earth's surface. - *

- * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) - * is the top-left corner of the image, and (1, 1) is the bottom-right corner. The anchoring - * point in a W x H image is the nearest discrete grid point in a (W + 1) x (H + 1) grid, - * obtained by scaling the then rounding. For example, in a 4 x 2 image, the anchor point - * (0.7, 0.6) resolves to the grid point at (3, 1). - * - * @param u u-coordinate of the anchor, as a ratio of the image width (in the range [0, 1]) - * @param v v-coordinate of the anchor, as a ratio of the image height (in the range [0, 1]) - * @return the object for which the method was called, with the new anchor set. - */ - public MarkerOptions anchor(float u, float v) { - this.anchorU = u; - this.anchorV = v; - return this; - } - - /** - * Sets the draggability for the marker. - * - * @return the object for which the method was called, with the new draggable state set. - */ - public MarkerOptions draggable(boolean draggable) { - this.draggable = draggable; - return this; - } - - /** - * Sets whether this marker should be flat against the map true or a billboard facing the - * camera false. If the marker is flat against the map, it will remain stuck to the map as the - * camera rotates and tilts but will still remain the same size as the camera zooms, unlike a - * GroundOverlay. If the marker is a billboard, it will always be drawn facing the camera - * and will rotate and tilt with the camera. The default value is false. - * - * @return the object for which the method was called, with the new flat state set. - */ - public MarkerOptions flat(boolean flat) { - this.flat = flat; - return this; - } - - /** - * Gets the alpha set for this MarkerOptions object. - * - * @return the alpha of the marker in the range [0, 1]. - */ - public float getAlpha() { - return alpha; - } - - /** - * Horizontal distance, normalized to [0, 1], of the anchor from the left edge. - * - * @return the u value of the anchor. - */ - public float getAnchorU() { - return anchorU; - } - - /** - * Vertical distance, normalized to [0, 1], of the anchor from the top edge. - * - * @return the v value of the anchor. - */ - public float getAnchorV() { - return anchorV; - } - - /** - * Gets the custom icon set for this MarkerOptions object. - * - * @return An {@link BitmapDescriptor} representing the custom icon, or {@code null} if no - * custom icon is set. - */ - public BitmapDescriptor getIcon() { - if (icon == null && iconBinder != null) { - icon = new BitmapDescriptor(ObjectWrapper.asInterface(iconBinder)); - } - return icon; - } - - /** - * Horizontal distance, normalized to [0, 1], of the info window anchor from the left edge. - * - * @return the u value of the info window anchor. - */ - public float getInfoWindowAnchorU() { - return infoWindowAnchorU; - } - - /** - * Vertical distance, normalized to [0, 1], of the info window anchor from the top edge. - * - * @return the v value of the info window anchor. - */ - public float getInfoWindowAnchorV() { - return infoWindowAnchorV; - } - - /** - * Returns the position set for this MarkerOptions object. - * - * @return A {@link LatLng} object specifying the marker's current position. - */ - public LatLng getPosition() { - return position; - } - - /** - * Gets the rotation set for this MarkerOptions object. - * - * @return the rotation of the marker in degrees clockwise from the default position. - */ - public float getRotation() { - return rotation; - } - - /** - * Gets the snippet set for this MarkerOptions object. - * - * @return A string containing the marker's snippet. - */ - public String getSnippet() { - return snippet; - } - - /** - * Gets the title set for this MarkerOptions object. - * - * @return A string containing the marker's title. - */ - public String getTitle() { - return title; - } - - /** - * Sets the icon for the marker. - * - * @param icon if null, the default marker is used. - * @return the object for which the method was called, with the new icon set. - */ - public MarkerOptions icon(BitmapDescriptor icon) { - this.icon = icon; - this.iconBinder = icon == null ? null : icon.getRemoteObject().asBinder(); - return this; - } - - /** - * Specifies the anchor point of the info window on the marker image. This is specified in the - * same coordinate system as the anchor. See {@link MarkerOptions#anchor(float, float)} for - * more details. The default is the top middle of the image. - * - * @param u u-coordinate of the info window anchor, as a ratio of the image width (in the range [0, 1]) - * @param v v-coordinate of the info window anchor, as a ratio of the image height (in the range [0, 1]) - * @return the object for which the method was called, with the new info window anchor set. - */ - public MarkerOptions infoWindowAnchor(float u, float v) { - this.infoWindowAnchorU = u; - this.infoWindowAnchorV = v; - return this; - } - - /** - * Gets the draggability setting for this MarkerOptions object. - * - * @return {@code true} if the marker is draggable; otherwise, returns {@code false}. - */ - public boolean isDraggable() { - return draggable; - } - - /** - * Gets the flat setting for this MarkerOptions object. - * - * @return {@code true} if the marker is flat against the map; {@code false} if the marker - * should face the camera. - */ - public boolean isFlat() { - return flat; - } - - /** - * Gets the visibility setting for this MarkerOptions object. - * - * @return {@code true} if the marker is visible; otherwise, returns {@code false}. - */ - public boolean isVisible() { - return visible; - } - - /** - * Sets the location for the marker. - * - * @return the object for which the method was called, with the new position set. - */ - public MarkerOptions position(LatLng position) { - this.position = position; - return this; - } - - /** - * Sets the rotation of the marker in degrees clockwise about the marker's anchor point. The - * axis of rotation is perpendicular to the marker. A rotation of 0 corresponds to the default - * position of the marker. When the marker is flat on the map, the default position is North - * aligned and the rotation is such that the marker always remains flat on the map. When the - * marker is a billboard, the default position is pointing up and the rotation is such that - * the marker is always facing the camera. The default value is 0. - * - * @return the object for which the method was called, with the new rotation set. - */ - public MarkerOptions rotation(float rotation) { - this.rotation = rotation; - return this; - } - - /** - * Sets the snippet for the marker. - * - * @return the object for which the method was called, with the new snippet set. - */ - public MarkerOptions snippet(String snippet) { - this.snippet = snippet; - return this; - } - - /** - * Sets the title for the marker. - * - * @return the object for which the method was called, with the new title set. - */ - public MarkerOptions title(String title) { - this.title = title; - return this; - } - - /** - * Sets the visibility for the marker. - * - * @return the object for which the method was called, with the new visibility state set. - */ - public MarkerOptions visible(boolean visible) { - this.visible = visible; - return this; - } - - public MarkerOptions zIndex(float zIndex) { - this.zIndex = zIndex; - return this; - } - - public float getZIndex() { - return this.zIndex; - } - - public static Creator CREATOR = new AutoCreator(MarkerOptions.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/PolygonOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/PolygonOptions.java deleted file mode 100644 index 94fca7e1..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/PolygonOptions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import android.graphics.Color; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.ArrayList; -import java.util.List; - -/** - * Defines options for a polygon. - * TODO: Docs - */ -@PublicApi -public class PolygonOptions extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(value = 2, subClass = LatLng.class) - private List points = new ArrayList(); - @SafeParceled(value = 3, subClass = LatLng.class, useClassLoader = true) - private List> holes = new ArrayList>(); - @SafeParceled(4) - private float strokeWidth = 10; - @SafeParceled(5) - private int strokeColor = Color.BLACK; - @SafeParceled(6) - private int fillColor = Color.TRANSPARENT; - @SafeParceled(7) - private float zIndex = 0; - @SafeParceled(8) - private boolean visible = true; - @SafeParceled(9) - private boolean geodesic = false; - - /** - * Creates polygon options. - */ - public PolygonOptions() { - } - - public PolygonOptions add(LatLng point) { - points.add(point); - return this; - } - - public PolygonOptions add(LatLng... points) { - for (LatLng point : points) { - this.points.add(point); - } - return this; - } - - public PolygonOptions add(Iterable points) { - for (LatLng point : points) { - this.points.add(point); - } - return this; - } - - public PolygonOptions addHole(Iterable points) { - ArrayList hole = new ArrayList(); - for (LatLng point : points) { - hole.add(point); - } - holes.add(hole); - return this; - } - - public PolygonOptions fillColor(int color) { - this.fillColor = color; - return this; - } - - public PolygonOptions geodesic(boolean geodesic) { - this.geodesic = geodesic; - return this; - } - - public int getFillColor() { - return fillColor; - } - - public List> getHoles() { - return holes; - } - - public List getPoints() { - return points; - } - - public int getStrokeColor() { - return strokeColor; - } - - public float getStrokeWidth() { - return strokeWidth; - } - - public float getZIndex() { - return zIndex; - } - - public boolean isGeodesic() { - return geodesic; - } - - public boolean isVisible() { - return visible; - } - - public PolygonOptions strokeColor(int color) { - this.strokeColor = color; - return this; - } - - public PolygonOptions strokeWidth(float width) { - this.strokeWidth = width; - return this; - } - - public PolygonOptions visible(boolean visible) { - this.visible = visible; - return this; - } - - public PolygonOptions zIndex(float zIndex) { - this.zIndex = zIndex; - return this; - } - - public static Creator CREATOR = new AutoCreator(PolygonOptions.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/PolylineOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/PolylineOptions.java deleted file mode 100644 index d9a9dc5b..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/PolylineOptions.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import android.graphics.Color; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.ArrayList; -import java.util.List; - -/** - * Defines options for a polyline. - * TODO - */ -@PublicApi -public class PolylineOptions extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(value = 2, subClass = LatLng.class) - private List points = new ArrayList(); - @SafeParceled(3) - private float width = 10; - @SafeParceled(4) - private int color = Color.BLACK; - @SafeParceled(5) - private float zIndex = 0; - @SafeParceled(6) - private boolean visible = true; - @SafeParceled(7) - private boolean geodesic = false; - - public PolylineOptions() { - } - - public PolylineOptions add(LatLng point) { - points.add(point); - return this; - } - - public PolylineOptions add(LatLng... points) { - for (LatLng point : points) { - this.points.add(point); - } - return this; - } - - public PolylineOptions addAll(Iterable points) { - for (LatLng point : points) { - this.points.add(point); - } - return this; - } - - public PolylineOptions color(int color) { - this.color = color; - return this; - } - - public PolylineOptions geodesic(boolean geodesic) { - this.geodesic = geodesic; - return this; - } - - public int getColor() { - return color; - } - - public List getPoints() { - return points; - } - - public float getWidth() { - return width; - } - - public float getZIndex() { - return zIndex; - } - - public boolean isGeodesic() { - return geodesic; - } - - public boolean isVisible() { - return visible; - } - - public PolylineOptions visible(boolean visible) { - this.visible = visible; - return this; - } - - public PolylineOptions width(float width) { - this.width = width; - return this; - } - - public PolylineOptions zIndex(float zIndex) { - this.zIndex = zIndex; - return this; - } - - public static Creator CREATOR = new AutoCreator(PolylineOptions.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaCamera.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaCamera.java deleted file mode 100644 index 2737de9d..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaCamera.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; - -@PublicApi -public class StreetViewPanoramaCamera { -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaLink.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaLink.java deleted file mode 100644 index 2dfcbd03..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaLink.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; - -@PublicApi -public class StreetViewPanoramaLink { -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaLocation.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaLocation.java deleted file mode 100644 index b1254689..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaLocation.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; - -@PublicApi -public class StreetViewPanoramaLocation { -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaOrientation.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaOrientation.java deleted file mode 100644 index fa7f657f..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/StreetViewPanoramaOrientation.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; - -@PublicApi -public class StreetViewPanoramaOrientation { -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/Tile.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/Tile.java deleted file mode 100644 index 3f0deea5..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/Tile.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * Contains information about a Tile that is returned by a {@link TileProvider}. - * TODO SafeParceled - */ -@PublicApi -public class Tile extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - /** - * The width of the image encoded by {@link #data} in pixels. - */ - @SafeParceled(2) - public final int width; - /** - * The height of the image encoded by {@link #data} in pixels. - */ - @SafeParceled(3) - public final int height; - /** - * A byte array containing the image data. The image will be created from this data by calling - * {@link android.graphics.BitmapFactory#decodeByteArray(byte[], int, int)}. - */ - @SafeParceled(4) - public final byte[] data; - - private Tile() { - width = height = 0; - data = null; - } - - /** - * Constructs a {@link Tile}. - * - * @param width the width of the image in pixels - * @param height the height of the image in pixels - * @param data A byte array containing the image data. The image will be created from this - * data by calling - * {@link android.graphics.BitmapFactory#decodeByteArray(byte[], int, int)}. - */ - public Tile(int width, int height, byte[] data) { - this.width = width; - this.height = height; - this.data = data; - } - - public static Creator CREATOR = new AutoCreator(Tile.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/TileOverlayOptions.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/TileOverlayOptions.java deleted file mode 100644 index 1fdffe36..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/TileOverlayOptions.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import android.os.IBinder; -import android.os.RemoteException; - -import com.google.android.gms.maps.model.internal.ITileProviderDelegate; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * Defines options for a TileOverlay. - */ -@PublicApi -public class TileOverlayOptions extends AutoSafeParcelable { - - @SafeParceled(1) - private int versionCode = 1; - /** - * This is a IBinder to the {@link #tileProvider}, built using {@link ITileProviderDelegate}. - */ - @SafeParceled(2) - private IBinder tileProviderBinder; - private TileProvider tileProvider; - @SafeParceled(3) - private boolean visible = true; - @SafeParceled(4) - private float zIndex; - @SafeParceled(5) - private boolean fadeIn = true; - - /** - * Creates a new set of tile overlay options. - */ - public TileOverlayOptions() { - } - - /** - * Specifies whether the tiles should fade in. The default is {@code true}. - * - * @return this {@link TileOverlayOptions} object with a new fadeIn setting. - */ - public TileOverlayOptions fadeIn(boolean fadeIn) { - this.fadeIn = fadeIn; - return this; - } - - /** - * Gets whether the tiles should fade in. - * - * @return {@code true} if the tiles are to fade in; {@code false} if it is not. - */ - public boolean getFadeIn() { - return fadeIn; - } - - /** - * Gets the tile provider set for this {@link TileOverlayOptions} object. - * - * @return the {@link TileProvider} of the tile overlay. - */ - public TileProvider getTileProvider() { - return tileProvider; - } - - /** - * Gets the zIndex set for this {@link TileOverlayOptions} object. - * - * @return the zIndex of the tile overlay. - */ - public float getZIndex() { - return zIndex; - } - - /** - * Gets the visibility setting for this {@link TileOverlayOptions} object. - * - * @return {@code true} if the tile overlay is to be visible; {@code false} if it is not. - */ - public boolean isVisible() { - return visible; - } - - /** - * Specifies the tile provider to use for this tile overlay. - * - * @param tileProvider the {@link TileProvider} to use for this tile overlay. - * @return the object for which the method was called, with the new tile provider set. - */ - public TileOverlayOptions tileProvider(final TileProvider tileProvider) { - this.tileProvider = tileProvider; - this.tileProviderBinder = new ITileProviderDelegate.Stub() { - @Override - public Tile getTile(int x, int y, int zoom) throws RemoteException { - return tileProvider.getTile(x, y, zoom); - } - }; - return this; - } - - /** - * Specifies the visibility for the tile overlay. The default visibility is {@code true}. - * - * @return this {@link TileOverlayOptions} object with a new visibility setting. - */ - public TileOverlayOptions visible(boolean visible) { - this.visible = visible; - return this; - } - - /** - * Specifies the tile overlay's zIndex, i.e., the order in which it will be drawn where - * overlays with larger values are drawn above those with lower values. See the documentation - * at the top of this class for more information about zIndex. - * - * @return this {@link TileOverlayOptions} object with a new zIndex set. - */ - public TileOverlayOptions zIndex(float zIndex) { - this.zIndex = zIndex; - return this; - } - - public static Creator CREATOR = new AutoCreator(TileOverlayOptions.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/TileProvider.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/TileProvider.java deleted file mode 100644 index 9a1e930d..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/TileProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -/** - * An interface for a class that provides the tile images for a TileOverlay. For information about - * the tile coordinate system, see TileOverlay. - *

- * Calls to methods in this interface might be made from multiple threads so implementations of - * this interface must be threadsafe. - */ -public interface TileProvider { - public static final Tile NO_TILE = new Tile(-1, -1, null); - - /** - * Returns the tile to be used for this tile coordinate. - * - * @param x The x coordinate of the tile. This will be in the range [0, 2^(zoom - 1)] inclusive. - * @param y The y coordinate of the tile. This will be in the range [0, 2^(zoom - 1)] inclusive. - * @param zoom The zoom level of the tile. - * @return the {@link Tile} to be used for this tile coordinate. If you do not wish to provide - * a tile for this tile coordinate, return {@link #NO_TILE}. If the tile could not be found at - * this point in time, return null and further requests might be made with an exponential - * backoff. - */ - public Tile getTile(int x, int y, int zoom); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/VisibleRegion.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/VisibleRegion.java deleted file mode 100644 index 93c4d813..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/VisibleRegion.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -@PublicApi -public class VisibleRegion extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode; - @SafeParceled(2) - private LatLng nearLeft; - @SafeParceled(3) - private LatLng nearRight; - @SafeParceled(4) - private LatLng farLeft; - @SafeParceled(5) - private LatLng farRight; - @SafeParceled(6) - private LatLngBounds bounds; - - private VisibleRegion() { - } - - public VisibleRegion(int versionCode, LatLng nearLeft, LatLng nearRight, LatLng farLeft, - LatLng farRight, LatLngBounds bounds) { - this.versionCode = versionCode; - this.nearLeft = nearLeft; - this.nearRight = nearRight; - this.farLeft = farLeft; - this.farRight = farRight; - this.bounds = bounds; - } - - public VisibleRegion(LatLng nearLeft, LatLng nearRight, LatLng farLeft, LatLng farRight, - LatLngBounds bounds) { - this(1, nearLeft, nearRight, farLeft, farRight, bounds); - } - - /** - * This is assuming that the visible region matches the bounds, which means that it's a north - * orientated top view - */ - public VisibleRegion(LatLngBounds bounds) { - this(bounds.southwest, new LatLng(bounds.southwest.latitude, bounds.northeast.longitude), - new LatLng(bounds.northeast.latitude, bounds.southwest.longitude), bounds.northeast, - bounds); - } - - public static Creator CREATOR = new AutoCreator(VisibleRegion.class); -} diff --git a/play-services-api/src/main/java/com/google/android/gms/maps/model/package-info.java b/play-services-api/src/main/java/com/google/android/gms/maps/model/package-info.java deleted file mode 100644 index 8c40c393..00000000 --- a/play-services-api/src/main/java/com/google/android/gms/maps/model/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Contains the Google Maps Android API model classes. - */ -package com.google.android.gms.maps.model; diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle index b55d79ef..3e99b490 100644 --- a/play-services-core/build.gradle +++ b/play-services-core/build.gradle @@ -36,28 +36,15 @@ dependencies { api "uk.uuid.slf4j:slf4j-android:1.7.25-1" implementation project(':play-services-base-core') - implementation project(':play-services-location-core') implementation project(':play-services-core:microg-ui-tools') // deprecated implementation project(':play-services-api') implementation project(':play-services-cast-api') - implementation project(':play-services-wearable') - implementation "org.microg:wearable:$wearableVersion" - implementation "org.microg.gms:remote-droid-guard:$remoteDroidGuardVersion" - - mapboxImplementation project(':play-services-maps-core-mapbox') - vtmImplementation project(':play-services-maps-core-vtm') // AndroidX UI implementation "androidx.multidex:multidex:$multidexVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" implementation "androidx.mediarouter:mediarouter:$mediarouterVersion" implementation "androidx.preference:preference:$preferenceVersion" - - // Navigation - implementation "androidx.navigation:navigation-fragment:$navigationVersion" - implementation "androidx.navigation:navigation-ui:$navigationVersion" - implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion" - implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion" } android { diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index 9b89596a..91201149 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -36,26 +36,6 @@ android:name="com.mgoogle.android.googleapps.permission.GOOGLE_AUTH" android:icon="@drawable/proprietary_auth_ic_scope_icon_default" /> - - - - - - - - - @@ -83,9 +58,6 @@ - - - @@ -111,47 +83,6 @@ android:name="fake-signature" android:value="@string/fake_signature" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -475,16 +399,6 @@ android:label="@string/gms_settings_name" android:theme="@style/Theme.AppCompat.DayNight" /> - - - - - - - - - diff --git a/play-services-core/src/main/java/org/microg/gms/snet/Attestation.java b/play-services-core/src/main/java/org/microg/gms/snet/Attestation.java deleted file mode 100644 index 5c8720f7..00000000 --- a/play-services-core/src/main/java/org/microg/gms/snet/Attestation.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.snet; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.Signature; -import android.util.Base64; -import android.util.Log; - -import com.squareup.wire.Wire; - -import org.microg.gms.common.Build; -import org.microg.gms.common.Constants; -import org.microg.gms.common.Utils; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.zip.GZIPInputStream; - -import okio.ByteString; - -public class Attestation { - private static final String TAG = "GmsSafetyNetAttest"; - - private Context context; - private String packageName; - private byte[] payload; - private String droidGaurdResult; - - public Attestation(Context context, String packageName) { - this.context = context; - this.packageName = packageName; - } - - public void setPayload(byte[] payload) { - this.payload = payload; - } - - public byte[] buildPayload(byte[] nonce) { - this.droidGaurdResult = null; - SafetyNetData payload = new SafetyNetData.Builder() - .nonce(ByteString.of(nonce)) - .currentTimeMs(System.currentTimeMillis()) - .packageName(packageName) - .fileDigest(getPackageFileDigest()) - .signatureDigest(getPackageSignatures()) - .gmsVersionCode(Constants.MAX_REFERENCE_VERSION) - //.googleCn(false) - .seLinuxState(new SELinuxState(true, true)) - .suCandidates(Collections.emptyList()) - .build(); - return this.payload = payload.toByteArray(); - } - - public byte[] getPayload() { - return payload; - } - - public String getPayloadHashBase64() { - try { - MessageDigest digest = getSha256Digest(); - return Base64.encodeToString(digest.digest(payload), Base64.NO_WRAP); - } catch (NoSuchAlgorithmException e) { - Log.w(TAG, e); - return null; - } - } - - private static MessageDigest getSha256Digest() throws NoSuchAlgorithmException { - return MessageDigest.getInstance("SHA-256"); - } - - public void setDroidGaurdResult(String droidGaurdResult) { - this.droidGaurdResult = droidGaurdResult; - } - - private ByteString getPackageFileDigest() { - try { - FileInputStream is = new FileInputStream(new File(context.getPackageManager().getApplicationInfo(packageName, 0).sourceDir)); - MessageDigest digest = getSha256Digest(); - byte[] data = new byte[16384]; - while (true) { - int read = is.read(data); - if (read < 0) break; - digest.update(data, 0, read); - } - return ByteString.of(digest.digest()); - } catch (Exception e) { - Log.w(TAG, e); - return null; - } - } - - @SuppressLint("PackageManagerGetSignatures") - private List getPackageSignatures() { - try { - PackageInfo pi = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES); - ArrayList res = new ArrayList<>(); - MessageDigest digest = getSha256Digest(); - for (Signature signature : pi.signatures) { - res.add(ByteString.of(digest.digest(signature.toByteArray()))); - } - return res; - } catch (Exception e) { - Log.w(TAG, e); - return null; - } - } - - public String attest(String apiKey) throws IOException { - if (payload == null) { - throw new IllegalStateException("missing payload"); - } - return attest(new AttestRequest(ByteString.of(payload), droidGaurdResult), apiKey).result; - } - - private AttestResponse attest(AttestRequest request, String apiKey) throws IOException { - String requestUrl = SafetyNetPrefs.get(context).getServiceUrl() + "?alt=PROTO&key=" + apiKey; - HttpURLConnection connection = (HttpURLConnection) new URL(requestUrl).openConnection(); - connection.setRequestMethod("POST"); - connection.setDoInput(true); - connection.setDoOutput(true); - connection.setRequestProperty("content-type", "application/x-protobuf"); - connection.setRequestProperty("Accept-Encoding", "gzip"); - Build build = Utils.getBuild(context); - connection.setRequestProperty("User-Agent", "SafetyNet/" + Constants.MAX_REFERENCE_VERSION + " (" + build.device + " " + build.id + "); gzip"); - - OutputStream os = connection.getOutputStream(); - os.write(request.toByteArray()); - os.close(); - - if (connection.getResponseCode() != 200) { - byte[] bytes = null; - String ex = null; - try { - bytes = Utils.readStreamToEnd(connection.getErrorStream()); - ex = new String(Utils.readStreamToEnd(new GZIPInputStream(new ByteArrayInputStream(bytes)))); - } catch (Exception e) { - if (bytes != null) { - throw new IOException(getBytesAsString(bytes), e); - } - throw new IOException(connection.getResponseMessage(), e); - } - throw new IOException(ex); - } - - InputStream is = connection.getInputStream(); - byte[] bytes = Utils.readStreamToEnd(new GZIPInputStream(is)); - try { - return new Wire().parseFrom(bytes, AttestResponse.class); - } catch (IOException e) { - Log.d(TAG, Base64.encodeToString(bytes, 0)); - throw e; - } - } - - - private String getBytesAsString(byte[] bytes) { - if (bytes == null) return "null"; - try { - CharsetDecoder d = Charset.forName("US-ASCII").newDecoder(); - CharBuffer r = d.decode(ByteBuffer.wrap(bytes)); - return r.toString(); - } catch (Exception e) { - return Base64.encodeToString(bytes, Base64.NO_WRAP); - } - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientService.java b/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientService.java deleted file mode 100644 index 893ba303..00000000 --- a/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientService.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.snet; - -import android.os.RemoteException; - -import com.google.android.gms.common.internal.GetServiceRequest; -import com.google.android.gms.common.internal.IGmsCallbacks; - -import org.microg.gms.BaseService; -import org.microg.gms.common.GmsService; - -public class SafetyNetClientService extends BaseService { - - public SafetyNetClientService() { - super("GmsSafetyNetClientSvc", GmsService.SAFETY_NET_CLIENT); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, new SafetyNetClientServiceImpl(this, request.packageName), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientServiceImpl.java deleted file mode 100644 index 848d1343..00000000 --- a/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientServiceImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.snet; - -import android.content.Context; -import android.os.Bundle; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Base64; -import android.util.Log; - -import com.google.android.gms.common.api.CommonStatusCodes; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.safetynet.AttestationData; -import com.google.android.gms.safetynet.HarmfulAppsData; -import com.google.android.gms.safetynet.internal.ISafetyNetCallbacks; -import com.google.android.gms.safetynet.internal.ISafetyNetService; - -import org.microg.gms.checkin.LastCheckinInfo; -import org.microg.gms.common.PackageUtils; -import org.microg.gms.droidguard.RemoteDroidGuardConnector; - -import java.io.IOException; -import java.util.ArrayList; - -public class SafetyNetClientServiceImpl extends ISafetyNetService.Stub { - private static final String TAG = "GmsSafetyNetClientImpl"; - private static final String DEFAULT_API_KEY = "AIzaSyDqVnJBjE5ymo--oBJt3On7HQx9xNm1RHA"; - - private Context context; - private String packageName; - private Attestation attestation; - - public SafetyNetClientServiceImpl(Context context, String packageName) { - this.context = context; - this.packageName = packageName; - this.attestation = new Attestation(context, packageName); - } - - @Override - public void attest(ISafetyNetCallbacks callbacks, byte[] nonce) throws RemoteException { - attestWithApiKey(callbacks, nonce, DEFAULT_API_KEY); - } - - @Override - public void attestWithApiKey(final ISafetyNetCallbacks callbacks, final byte[] nonce, String apiKey) throws RemoteException { - if (nonce == null) { - callbacks.onAttestationData(new Status(CommonStatusCodes.DEVELOPER_ERROR), null); - return; - } - - if (!SafetyNetPrefs.get(context).isEnabled()) { - Log.d(TAG, "ignoring SafetyNet request, it's disabled"); - callbacks.onAttestationData(Status.CANCELED, null); - return; - } - - new Thread(new Runnable() { - @Override - public void run() { - try { - try { - attestation.buildPayload(nonce); - RemoteDroidGuardConnector conn = new RemoteDroidGuardConnector(context); - Bundle bundle = new Bundle(); - bundle.putString("contentBinding", attestation.getPayloadHashBase64()); - RemoteDroidGuardConnector.Result dg = conn.guard("attest", Long.toString(LastCheckinInfo.read(context).androidId), bundle); - if (!SafetyNetPrefs.get(context).isOfficial() || dg != null && dg.getStatusCode() == 0 && dg.getResult() != null) { - if (dg != null && dg.getStatusCode() == 0 && dg.getResult() != null) { - attestation.setDroidGaurdResult(Base64.encodeToString(dg.getResult(), Base64.NO_WRAP + Base64.NO_PADDING + Base64.URL_SAFE)); - } - AttestationData data = new AttestationData(attestation.attest(apiKey)); - callbacks.onAttestationData(Status.SUCCESS, data); - } else { - callbacks.onAttestationData(dg == null ? Status.INTERNAL_ERROR : new Status(dg.getStatusCode()), null); - } - } catch (IOException e) { - Log.w(TAG, e); - callbacks.onAttestationData(Status.INTERNAL_ERROR, null); - } - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - }).start(); - } - - @Override - public void getSharedUuid(ISafetyNetCallbacks callbacks) throws RemoteException { - PackageUtils.checkPackageUid(context, packageName, getCallingUid()); - PackageUtils.assertExtendedAccess(context); - - // TODO - Log.d(TAG, "dummy Method: getSharedUuid"); - callbacks.onString("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"); - } - - @Override - public void lookupUri(ISafetyNetCallbacks callbacks, String s1, int[] threatTypes, int i, String s2) throws RemoteException { - Log.d(TAG, "unimplemented Method: lookupUri"); - - } - - @Override - public void init(ISafetyNetCallbacks callbacks) throws RemoteException { - Log.d(TAG, "dummy Method: init"); - callbacks.onBoolean(Status.SUCCESS, true); - } - - @Override - public void getHarmfulAppsList(ISafetyNetCallbacks callbacks) throws RemoteException { - Log.d(TAG, "dummy Method: unknown4"); - callbacks.onHarmfulAppsData(Status.SUCCESS, new ArrayList()); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetPrefs.java b/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetPrefs.java deleted file mode 100644 index a6475791..00000000 --- a/play-services-core/src/main/java/org/microg/gms/snet/SafetyNetPrefs.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.snet; - -import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; - -public class SafetyNetPrefs implements SharedPreferences.OnSharedPreferenceChangeListener { - private static final String OFFICIAL_ATTEST_BASE_URL = "https://www.googleapis.com/androidcheck/v1/attestations/attest"; - - public static final String PREF_SNET_DISABLED = "snet_disabled"; - public static final String PREF_SNET_OFFICIAL = "snet_official"; - public static final String PREF_SNET_THIRD_PARTY = "snet_third_party"; - public static final String PREF_SNET_CUSTOM_URL = "snet_custom_url"; - public static final String PREF_SNET_SELF_SIGNED = "snet_self_signed"; - - private static SafetyNetPrefs INSTANCE; - - public static SafetyNetPrefs get(Context context) { - if (INSTANCE == null) { - if (context == null) return new SafetyNetPrefs(null); - INSTANCE = new SafetyNetPrefs(context.getApplicationContext()); - } - return INSTANCE; - } - - private boolean disabled; - private boolean official; - private boolean selfSigned; - private boolean thirdParty; - private String customUrl; - - private SharedPreferences defaultPreferences; - - private SafetyNetPrefs(Context context) { - if (context != null) { - defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context); - defaultPreferences.registerOnSharedPreferenceChangeListener(this); - update(); - } - } - - public void update() { - disabled = defaultPreferences.getBoolean(PREF_SNET_DISABLED, true); - official = defaultPreferences.getBoolean(PREF_SNET_OFFICIAL, false); - selfSigned = defaultPreferences.getBoolean(PREF_SNET_SELF_SIGNED, false); - thirdParty = defaultPreferences.getBoolean(PREF_SNET_THIRD_PARTY, false); - customUrl = defaultPreferences.getString(PREF_SNET_CUSTOM_URL, null); - } - - @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) { - update(); - } - - public boolean isEnabled() { - return !disabled && (official || selfSigned || thirdParty); - } - - public void setEnabled(boolean enabled) { - defaultPreferences.edit().putBoolean(PREF_SNET_DISABLED, !enabled).apply(); - if (enabled && !isEnabled()) { - official = true; - defaultPreferences.edit().putBoolean(PREF_SNET_OFFICIAL, true).apply(); - } - } - - public boolean isSelfSigned() { - return selfSigned; - } - - public boolean isOfficial() { - return official; - } - - public boolean isThirdParty() { - return thirdParty; - } - - public String getServiceUrl() { - if (official) return OFFICIAL_ATTEST_BASE_URL; - return customUrl; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/ui/PlacePickerActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/PlacePickerActivity.java deleted file mode 100644 index e83ff7ef..00000000 --- a/play-services-core/src/main/java/org/microg/gms/ui/PlacePickerActivity.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (C) 2013-2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.ui; - -import android.content.Intent; -import android.location.Address; -import android.location.Geocoder; -import android.location.Location; -import android.location.LocationManager; -import android.os.Build; -import android.os.Bundle; -import android.text.Html; -import android.text.TextUtils; -import android.util.Log; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.SearchView; -import androidx.appcompat.widget.Toolbar; -import androidx.core.app.ActivityCompat; -import androidx.core.view.MenuItemCompat; - -import com.mgoogle.android.gms.R; -import com.google.android.gms.common.api.CommonStatusCodes; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.places.internal.PlaceImpl; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -import org.microg.gms.location.LocationConstants; -//import org.microg.gms.maps.vtm.BackendMapView; -//import org.microg.gms.maps.vtm.GmsMapsTypeHelper; -import org.microg.safeparcel.SafeParcelUtil; -//import org.oscim.core.MapPosition; -//import org.oscim.event.Event; -//import org.oscim.map.Map; - -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import static android.Manifest.permission.ACCESS_COARSE_LOCATION; -import static android.Manifest.permission.ACCESS_FINE_LOCATION; -import static android.content.pm.PackageManager.PERMISSION_GRANTED; -import static org.microg.gms.location.LocationConstants.EXTRA_PRIMARY_COLOR; -import static org.microg.gms.location.LocationConstants.EXTRA_PRIMARY_COLOR_DARK; -//import static org.microg.gms.maps.vtm.GmsMapsTypeHelper.fromLatLngBounds; - -public class - - -PlacePickerActivity extends AppCompatActivity /*implements Map.UpdateListener*/ { - private static final String TAG = "GmsPlacePicker"; - - private PlaceImpl place; -// private BackendMapView mapView; - private Intent resultIntent; - private AtomicBoolean geocoderInProgress = new AtomicBoolean(false); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - resultIntent = new Intent(); - place = new PlaceImpl(); - - setContentView(R.layout.pick_place); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setDisplayShowHomeEnabled(true); - - if (getIntent().hasExtra(EXTRA_PRIMARY_COLOR)) { - toolbar.setBackgroundColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR, 0)); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - getWindow().setStatusBarColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0)); - ((TextView) findViewById(R.id.place_picker_title)).setTextColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0)); - } - -// mapView = (BackendMapView) findViewById(R.id.map); -// mapView.map().getEventLayer().enableRotation(false); -// mapView.map().getEventLayer().enableTilt(false); -// mapView.map().events.bind(this); - - LatLngBounds latLngBounds = getIntent().getParcelableExtra(LocationConstants.EXTRA_BOUNDS); - if (latLngBounds != null) { - place.viewport = latLngBounds; -// MapPosition mp = new MapPosition(); -// mp.setByBoundingBox(fromLatLngBounds(latLngBounds), mapView.map().getWidth(), mapView.map().getHeight()); -// mapView.map().getMapPosition(mp); - } else { - if (ActivityCompat.checkSelfPermission(PlacePickerActivity.this, ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(PlacePickerActivity.this, new String[]{ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION}, 0); - } else { - updateMapFromLocationManager(); - } - } - - findViewById(R.id.place_picker_select).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - resultIntent.putExtra(LocationConstants.EXTRA_STATUS, SafeParcelUtil.asByteArray(new Status(CommonStatusCodes.SUCCESS))); - resultIntent.putExtra(LocationConstants.EXTRA_PLACE, SafeParcelUtil.asByteArray(place)); - resultIntent.putExtra(LocationConstants.EXTRA_FINAL_BOUNDS, SafeParcelUtil.asByteArray(place.viewport)); - setResult(RESULT_OK, resultIntent); - finish(); - } - }); - } - - @SuppressWarnings("MissingPermission") - private void updateMapFromLocationManager() { - LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); - Location last = null; - for (String provider : lm.getAllProviders()) { - if (lm.isProviderEnabled(provider)) { - Location t = lm.getLastKnownLocation(provider); - if (t != null && (last == null || t.getTime() > last.getTime())) { - last = t; - } - } - } - Log.d(TAG, "Set location to " + last); - if (last != null) { -// mapView.map().setMapPosition(new MapPosition(last.getLatitude(), last.getLongitude(), 4096)); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == 0) { - for (int grantResult : grantResults) { - if (grantResult != PERMISSION_GRANTED) return; - } - updateMapFromLocationManager(); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.pick_place, menu); - SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_action_search)); - // TODO: search - return true; - } - - @Override - protected void onResume() { - super.onResume(); -// mapView.onResume(); - } - - @Override - protected void onPause() { -// mapView.onPause(); - super.onPause(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) { - finish(); - return true; - } - return super.onOptionsItemSelected(item); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - } - - /* - @Override - public void onMapEvent(Event event, MapPosition position) { -// place.viewport = GmsMapsTypeHelper.toLatLngBounds(mapView.map().viewport().getBBox(null, 0)); -// resultIntent.putExtra(LocationConstants.EXTRA_FINAL_BOUNDS, place.viewport); -// place.latLng = GmsMapsTypeHelper.toLatLng(position.getGeoPoint()); - place.name = ""; - place.address = ""; - updateInfoText(); - if (geocoderInProgress.compareAndSet(false, true)) { - new Thread(new Runnable() { - @Override - public void run() { - try { - LatLng ll = null; - while (ll != place.latLng) { - ll = place.latLng; - Thread.sleep(1000); - } - Geocoder geocoder = new Geocoder(PlacePickerActivity.this); - List

addresses = geocoder.getFromLocation(place.latLng.latitude, place.latLng.longitude, 1); - if (addresses != null && !addresses.isEmpty() && addresses.get(0).getMaxAddressLineIndex() > 0) { - Address address = addresses.get(0); - StringBuilder sb = new StringBuilder(address.getAddressLine(0)); - for (int i = 1; i < address.getMaxAddressLineIndex(); ++i) { - if (i == 1 && sb.toString().equals(address.getFeatureName())) { - sb = new StringBuilder(address.getAddressLine(i)); - continue; - } - sb.append(", ").append(address.getAddressLine(i)); - } - if (place.latLng == ll) { - place.address = sb.toString(); - place.name = address.getFeatureName(); - runOnUiThread(new Runnable() { - @Override - public void run() { - updateInfoText(); - } - }); - } - } - } catch (Exception ignored) { - Log.w(TAG, ignored); - } finally { - geocoderInProgress.lazySet(false); - } - } - }).start(); - } - }*/ - - private void updateInfoText() { - if (TextUtils.isEmpty(place.address)) { - ((TextView) findViewById(R.id.place_picker_info)).setText(getString(R.string.place_picker_location_lat_lng, place.latLng.latitude, place.latLng.longitude)); - } else if (TextUtils.isEmpty(place.name)) { - ((TextView) findViewById(R.id.place_picker_info)).setText(place.address); - } else { - ((TextView) findViewById(R.id.place_picker_info)).setText(Html.fromHtml("" + place.name + ", " + place.address)); - } - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/ui/SafetyNetAdvancedFragment.java b/play-services-core/src/main/java/org/microg/gms/ui/SafetyNetAdvancedFragment.java deleted file mode 100644 index ff1a433f..00000000 --- a/play-services-core/src/main/java/org/microg/gms/ui/SafetyNetAdvancedFragment.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.ui; - -import android.os.Bundle; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; -import androidx.preference.Preference; - -import com.mgoogle.android.gms.R; - -import org.microg.tools.ui.AbstractSettingsActivity; -import org.microg.tools.ui.RadioButtonPreference; -import org.microg.tools.ui.ResourceSettingsFragment; - -import static org.microg.gms.snet.SafetyNetPrefs.PREF_SNET_OFFICIAL; -import static org.microg.gms.snet.SafetyNetPrefs.PREF_SNET_SELF_SIGNED; -import static org.microg.gms.snet.SafetyNetPrefs.PREF_SNET_THIRD_PARTY; - -public class SafetyNetAdvancedFragment extends ResourceSettingsFragment { - - public SafetyNetAdvancedFragment() { - preferencesResource = R.xml.preferences_snet_advanced; - } - - private RadioButtonPreference radioOfficial; - private RadioButtonPreference radioSelfSigned; - private RadioButtonPreference radioThirdParty; - - @Override - public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) { - super.onCreatePreferences(savedInstanceState, rootKey); - - radioOfficial = (RadioButtonPreference) findPreference(PREF_SNET_OFFICIAL); - radioSelfSigned = (RadioButtonPreference) findPreference(PREF_SNET_SELF_SIGNED); - radioThirdParty = (RadioButtonPreference) findPreference(PREF_SNET_THIRD_PARTY); - } - - @Override - public boolean onPreferenceTreeClick(Preference preference) { - if (preference == radioOfficial) { - radioOfficial.setChecked(true); - radioSelfSigned.setChecked(false); - radioThirdParty.setChecked(false); - return true; - } else if (preference == radioSelfSigned) { - radioOfficial.setChecked(false); - radioSelfSigned.setChecked(true); - radioThirdParty.setChecked(false); - return true; - } else if (preference == radioThirdParty) { - radioOfficial.setChecked(false); - radioSelfSigned.setChecked(false); - radioThirdParty.setChecked(true); - return true; - } - return super.onPreferenceTreeClick(preference); - } - - public static class AsActivity extends AbstractSettingsActivity { - public AsActivity() { - showHomeAsUp = true; - } - - @Override - protected Fragment getFragment() { - return new SafetyNetAdvancedFragment(); - } - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/ui/SafetyNetFragment.java b/play-services-core/src/main/java/org/microg/gms/ui/SafetyNetFragment.java deleted file mode 100644 index c5ef88a4..00000000 --- a/play-services-core/src/main/java/org/microg/gms/ui/SafetyNetFragment.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.ui; - -import android.content.Intent; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import com.mgoogle.android.gms.R; - -import org.microg.gms.snet.SafetyNetPrefs; -import org.microg.tools.ui.AbstractSettingsActivity; -import org.microg.tools.ui.SwitchBarResourceSettingsFragment; - -public class SafetyNetFragment extends SwitchBarResourceSettingsFragment { - private final int MENU_ADVANCED = Menu.FIRST; - - public SafetyNetFragment() { - preferencesResource = R.xml.preferences_snet; - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - setHasOptionsMenu(true); - switchBar.setChecked(SafetyNetPrefs.get(getContext()).isEnabled()); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - menu.add(0, MENU_ADVANCED, 0, R.string.menu_advanced); - super.onCreateOptionsMenu(menu, inflater); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case MENU_ADVANCED: - Intent intent = new Intent(getContext(), SafetyNetAdvancedFragment.AsActivity.class); - startActivity(intent); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override - public void onSwitchBarChanged(boolean isChecked) { - SafetyNetPrefs.get(getContext()).setEnabled(isChecked); - } - - public static class AsActivity extends AbstractSettingsActivity { - public AsActivity() { - showHomeAsUp = true; - } - - @Override - protected Fragment getFragment() { - return new SafetyNetFragment(); - } - } -} \ No newline at end of file diff --git a/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java index 0a356b53..88b8f2b0 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/SettingsActivity.java @@ -27,7 +27,6 @@ import com.mgoogle.android.gms.R; import org.microg.gms.gcm.GcmDatabase; import org.microg.gms.gcm.GcmPrefs; -import org.microg.gms.snet.SafetyNetPrefs; //import org.microg.nlp.Preferences; import org.microg.tools.ui.AbstractDashboardActivity; import org.microg.tools.ui.ResourceSettingsFragment; @@ -82,21 +81,7 @@ public class SettingsActivity extends AbstractDashboardActivity { findPreference(PREF_GCM).setSummary(R.string.abc_capital_off); } - if (SafetyNetPrefs.get(getContext()).isEnabled()) { - String snet_info = ""; - - if (SafetyNetPrefs.get(getContext()).isOfficial()) { - snet_info = getString(R.string.pref_snet_status_official_info); - } else if (SafetyNetPrefs.get(getContext()).isSelfSigned()) { - snet_info = getString(R.string.pref_snet_status_self_signed_info); - } else if (SafetyNetPrefs.get(getContext()).isThirdParty()) { - snet_info = getString(R.string.pref_snet_status_third_party_info); - } - - findPreference(PREF_SNET).setSummary(getString(R.string.service_status_enabled) + " / " + snet_info); - } else { findPreference(PREF_SNET).setSummary(R.string.service_status_disabled); - } // Preferences unifiedNlPrefs = new Preferences(getContext()); // int backendCount = TextUtils.isEmpty(unifiedNlPrefs.getLocationBackends()) ? 0 : diff --git a/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendDetailsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendDetailsActivity.java index 6f786653..f28aa901 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendDetailsActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendDetailsActivity.java @@ -2,8 +2,6 @@ package org.microg.gms.ui; import androidx.fragment.app.Fragment; -import org.microg.nlp.ui.BackendDetailsFragment; -import org.microg.nlp.ui.BackendListFragment; import org.microg.tools.ui.AbstractSettingsActivity; public class UnifiedBackendDetailsActivity extends AbstractSettingsActivity { @@ -13,6 +11,6 @@ public class UnifiedBackendDetailsActivity extends AbstractSettingsActivity { @Override protected Fragment getFragment() { - return new BackendDetailsFragment(); + return null; } } diff --git a/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendListActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendListActivity.java index 7bfd0aff..d9ec16fa 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendListActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/UnifiedBackendListActivity.java @@ -8,7 +8,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; -import org.microg.nlp.ui.BackendListFragment; import org.microg.tools.ui.AbstractSettingsActivity; public class UnifiedBackendListActivity extends AppCompatActivity { @@ -21,7 +20,7 @@ public class UnifiedBackendListActivity extends AppCompatActivity { } catch (Exception e) { Log.w("GmsCoreSettingUi", e); } - getSupportFragmentManager().beginTransaction().add(new BackendListFragment(), null).commit(); + getSupportFragmentManager().beginTransaction().add(null, null).commit(); } @Override diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/CapabilityManager.java b/play-services-core/src/main/java/org/microg/gms/wearable/CapabilityManager.java deleted file mode 100644 index 0c8f59ff..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/CapabilityManager.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.Context; -import android.net.Uri; - -import com.google.android.gms.common.api.CommonStatusCodes; -import com.google.android.gms.common.data.DataHolder; -import com.google.android.gms.wearable.Node; -import com.google.android.gms.wearable.WearableStatusCodes; -import com.google.android.gms.wearable.internal.NodeParcelable; - -import org.microg.gms.common.PackageUtils; - -import java.util.HashSet; -import java.util.Set; - -public class CapabilityManager { - private static final Uri ROOT = Uri.parse("wear:/capabilities/"); - private final Context context; - private final WearableImpl wearable; - private final String packageName; - - private Set capabilities = new HashSet(); - - public CapabilityManager(Context context, WearableImpl wearable, String packageName) { - this.context = context; - this.wearable = wearable; - this.packageName = packageName; - } - - private Uri buildCapabilityUri(String capability, boolean withAuthority) { - Uri.Builder builder = ROOT.buildUpon(); - if (withAuthority) builder.authority(wearable.getLocalNodeId()); - builder.appendPath(packageName); - builder.appendPath(PackageUtils.firstSignatureDigest(context, packageName)); - builder.appendPath(Uri.encode(capability)); - return builder.build(); - } - - public Set getNodesForCapability(String capability) { - DataHolder dataHolder = wearable.getDataItemsByUriAsHolder(buildCapabilityUri(capability, false), packageName); - Set nodes = new HashSet<>(); - for (int i = 0; i < dataHolder.getCount(); i++) { - nodes.add(dataHolder.getString("host", i, 0)); - } - dataHolder.close(); - return nodes; - } - - public int add(String capability) { - if (this.capabilities.contains(capability)) { - return WearableStatusCodes.DUPLICATE_CAPABILITY; - } - DataItemInternal dataItem = new DataItemInternal(buildCapabilityUri(capability, true)); - DataItemRecord record = wearable.putDataItem(packageName, PackageUtils.firstSignatureDigest(context, packageName), wearable.getLocalNodeId(), dataItem); - this.capabilities.add(capability); - wearable.syncRecordToAll(record); - return CommonStatusCodes.SUCCESS; - } - - public int remove(String capability) { - if (!this.capabilities.contains(capability)) { - return WearableStatusCodes.UNKNOWN_CAPABILITY; - } - wearable.deleteDataItems(buildCapabilityUri(capability, true), packageName); - capabilities.remove(capability); - return CommonStatusCodes.SUCCESS; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/ClockworkNodePreferences.java b/play-services-core/src/main/java/org/microg/gms/wearable/ClockworkNodePreferences.java deleted file mode 100644 index d6fc016a..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/ClockworkNodePreferences.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.Context; -import android.content.SharedPreferences; - -import java.util.UUID; - -public class ClockworkNodePreferences { - - private static final String CLOCKWORK_NODE_PREFERENCES = "cw_node"; - private static final String CLOCKWORK_NODE_PREFERENCE_NODE_ID = "node_id"; - private static final String CLOCKWORK_NODE_PREFERENCE_NEXT_SEQ_ID_BLOCK = "nextSeqIdBlock"; - - private static final Object lock = new Object(); - private static long seqIdBlock; - private static long seqIdInBlock = -1; - - private Context context; - - public ClockworkNodePreferences(Context context) { - this.context = context; - } - - public String getLocalNodeId() { - SharedPreferences preferences = context.getSharedPreferences(CLOCKWORK_NODE_PREFERENCES, Context.MODE_PRIVATE); - String nodeId = preferences.getString(CLOCKWORK_NODE_PREFERENCE_NODE_ID, null); - if (nodeId == null) { - nodeId = UUID.randomUUID().toString(); - preferences.edit().putString(CLOCKWORK_NODE_PREFERENCE_NODE_ID, nodeId).apply(); - } - return nodeId; - } - - public long getNextSeqId() { - synchronized (lock) { - SharedPreferences preferences = context.getSharedPreferences(CLOCKWORK_NODE_PREFERENCES, Context.MODE_PRIVATE); - if (seqIdInBlock < 0) seqIdInBlock = 1000; - if (seqIdInBlock >= 1000) { - seqIdBlock = preferences.getLong(CLOCKWORK_NODE_PREFERENCE_NEXT_SEQ_ID_BLOCK, 100); - preferences.edit().putLong(CLOCKWORK_NODE_PREFERENCE_NEXT_SEQ_ID_BLOCK, seqIdBlock + seqIdInBlock).apply(); - seqIdInBlock = 0; - } - return seqIdBlock + seqIdInBlock++; - } - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/ConfigurationDatabaseHelper.java b/play-services-core/src/main/java/org/microg/gms/wearable/ConfigurationDatabaseHelper.java deleted file mode 100644 index 01c8a1a8..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/ConfigurationDatabaseHelper.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; - -import com.google.android.gms.wearable.ConnectionConfiguration; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public class ConfigurationDatabaseHelper extends SQLiteOpenHelper { - - public static final String NULL_STRING = "NULL_STRING"; - public static final String TABLE_NAME = "connectionConfigurations"; - public static final String BY_NAME = "name=?"; - - public ConfigurationDatabaseHelper(Context context) { - super(context, "connectionconfig.db", null, 2); - } - - @Override - public void onCreate(SQLiteDatabase db) { - db.execSQL("CREATE TABLE connectionConfigurations (_id INTEGER PRIMARY KEY AUTOINCREMENT,androidId TEXT,name TEXT NOT NULL,pairedBtAddress TEXT NOT NULL,connectionType INTEGER NOT NULL,role INTEGER NOT NULL,connectionEnabled INTEGER NOT NULL,nodeId TEXT, UNIQUE(name) ON CONFLICT REPLACE);"); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - - } - - private static ConnectionConfiguration configFromCursor(final Cursor cursor) { - String name = cursor.getString(cursor.getColumnIndex("name")); - String pairedBtAddress = cursor.getString(cursor.getColumnIndex("pairedBtAddress")); - int connectionType = cursor.getInt(cursor.getColumnIndex("connectionType")); - int role = cursor.getInt(cursor.getColumnIndex("role")); - int enabled = cursor.getInt(cursor.getColumnIndex("connectionEnabled")); - String nodeId = cursor.getString(cursor.getColumnIndex("nodeId")); - if (NULL_STRING.equals(name)) name = null; - if (NULL_STRING.equals(pairedBtAddress)) pairedBtAddress = null; - return new ConnectionConfiguration(name, pairedBtAddress, connectionType, role, enabled > 0, nodeId); - } - - public ConnectionConfiguration getConfiguration(String name) { - Cursor cursor = getReadableDatabase().query(TABLE_NAME, null, BY_NAME, new String[]{name}, null, null, null); - ConnectionConfiguration config = null; - if (cursor != null) { - if (cursor.moveToNext()) - config = configFromCursor(cursor); - cursor.close(); - } - return config; - } - - public void putConfiguration(ConnectionConfiguration config) { - putConfiguration(config, null); - } - - public void putConfiguration(ConnectionConfiguration config, String oldNodeId) { - ContentValues contentValues = new ContentValues(); - if (config.name != null) { - contentValues.put("name", config.name); - } else if (config.role == 2) { - contentValues.put("name", "server"); - } else { - contentValues.put("name", "NULL_STRING"); - } - if (config.address != null) { - contentValues.put("pairedBtAddress", config.address); - } else { - contentValues.put("pairedBtAddress", "NULL_STRING"); - } - contentValues.put("connectionType", config.type); - contentValues.put("role", config.role); - contentValues.put("connectionEnabled", true); - contentValues.put("nodeId", config.nodeId); - if (oldNodeId == null) { - getWritableDatabase().insert(TABLE_NAME, null, contentValues); - } else { - getWritableDatabase().update(TABLE_NAME, contentValues, "nodeId=?", new String[]{oldNodeId}); - } - } - - public ConnectionConfiguration[] getAllConfigurations() { - Cursor cursor = getReadableDatabase().query(TABLE_NAME, null, null, null, null, null, null); - if (cursor != null) { - List configurations = new ArrayList(); - while (cursor.moveToNext()) { - configurations.add(configFromCursor(cursor)); - } - cursor.close(); - return configurations.toArray(new ConnectionConfiguration[configurations.size()]); - } else { - return null; - } - } - - public void setEnabledState(String name, boolean enabled) { - getWritableDatabase().execSQL("UPDATE connectionConfigurations SET connectionEnabled=? WHERE name=?", new String[]{enabled ? "1" : "0", name}); - } - - public int deleteConfiguration(String name) { - return getWritableDatabase().delete(TABLE_NAME, BY_NAME, new String[]{name}); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/DataItemInternal.java b/play-services-core/src/main/java/org/microg/gms/wearable/DataItemInternal.java deleted file mode 100644 index 678c8ef4..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/DataItemInternal.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.net.Uri; - -import com.google.android.gms.wearable.Asset; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class DataItemInternal { - public final String host; - public final String path; - public final Uri uri; - public byte[] data; - private Map assets = new HashMap(); - - public DataItemInternal(String host, String path) { - this.host = host; - this.path = path; - this.uri = new Uri.Builder().scheme("wear").authority(host).path(path).build(); - } - - public DataItemInternal(Uri uri) { - this.uri = uri; - this.host = uri.getAuthority(); - this.path = uri.getPath(); - } - - public DataItemInternal addAsset(String key, Asset asset) { - this.assets.put(key, asset); - return this; - } - - public Map getAssets() { - return Collections.unmodifiableMap(new HashMap(assets)); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("DataItemInternal{"); - sb.append("uri=").append(uri); - sb.append(", assets=").append(assets.size()); - sb.append('}'); - return sb.toString(); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/DataItemRecord.java b/play-services-core/src/main/java/org/microg/gms/wearable/DataItemRecord.java deleted file mode 100644 index 06052128..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/DataItemRecord.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.ContentValues; -import android.database.Cursor; -import android.net.Uri; -import android.util.Log; - -import com.google.android.gms.common.data.DataHolder; -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.internal.DataItemAssetParcelable; -import com.google.android.gms.wearable.internal.DataItemParcelable; - -import org.microg.wearable.proto.AssetEntry; -import org.microg.wearable.proto.SetDataItem; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import okio.ByteString; - -public class DataItemRecord { - private static String[] EVENT_DATA_HOLDER_FIELDS = new String[] { "event_type", "path", "data", "tags", "asset_key", "asset_id" }; - - public DataItemInternal dataItem; - public String source; - public long seqId; - public long v1SeqId; - public long lastModified; - public boolean deleted; - public boolean assetsAreReady; - public String packageName; - public String signatureDigest; - - public ContentValues toContentValues() { - ContentValues contentValues = new ContentValues(); - contentValues.put("sourceNode", source); - contentValues.put("seqId", seqId); - contentValues.put("v1SourceNode", source); - contentValues.put("v1SeqId", v1SeqId); - contentValues.put("timestampMs", lastModified); - if (deleted) { - contentValues.put("deleted", 1); - contentValues.putNull("data"); - } else { - contentValues.put("deleted", 0); - contentValues.put("data", dataItem.data); - } - contentValues.put("assetsPresent", assetsAreReady ? 1 : 0); - return contentValues; - } - - public DataHolder toEventDataHolder() { - DataHolder.Builder builder = DataHolder.builder(EVENT_DATA_HOLDER_FIELDS); - HashMap data = new HashMap(); - data.put("path", dataItem.uri.toString()); - if (deleted) { - data.put("event_type", 2); - builder.withRow(data); - } else { - data.put("event_type", 1); - data.put("data", dataItem.data); - data.put("tags", ""); - boolean added = false; - for (Map.Entry entry : dataItem.getAssets().entrySet()) { - added = true; - data.put("asset_id", entry.getValue().getDigest()); - data.put("asset_key", entry.getKey()); - builder.withRow(data); - data = new HashMap(); - data.put("path", dataItem.uri.toString()); - } - if (!added) { - builder.withRow(data); - } - } - return builder.build(0); - } - - public DataItemParcelable toParcelable() { - Map assets = new HashMap<>(); - for (Map.Entry entry : dataItem.getAssets().entrySet()) { - assets.put(entry.getKey(), new DataItemAssetParcelable(entry.getValue().getDigest(), entry.getKey())); - } - DataItemParcelable parcelable = new DataItemParcelable(dataItem.uri, assets); - parcelable.data = dataItem.data; - return parcelable; - } - - public SetDataItem toSetDataItem() { - SetDataItem.Builder builder = new SetDataItem.Builder() - .packageName(packageName) - .signatureDigest(signatureDigest) - .uri(dataItem.uri.toString()) - .seqId(seqId) - .deleted(deleted) - .lastModified(lastModified); - if (source != null) builder.source(source); - if (dataItem.data != null) builder.data(ByteString.of(dataItem.data)); - List protoAssets = new ArrayList(); - Map assets = dataItem.getAssets(); - for (String key : assets.keySet()) { - protoAssets.add(new AssetEntry.Builder() - .key(key) - .unknown3(4) - .value(new org.microg.wearable.proto.Asset.Builder() - .digest(assets.get(key).getDigest()) - .build()).build()); - } - builder.assets(protoAssets); - return builder.build(); - } - - public static DataItemRecord fromCursor(Cursor cursor) { - DataItemRecord record = new DataItemRecord(); - record.packageName = cursor.getString(1); - record.signatureDigest = cursor.getString(2); - record.dataItem = new DataItemInternal(cursor.getString(3), cursor.getString(4)); - record.seqId = cursor.getLong(5); - record.deleted = cursor.getLong(6) > 0; - record.source = cursor.getString(7); - record.dataItem.data = cursor.getBlob(8); - record.lastModified = cursor.getLong(9); - record.assetsAreReady = cursor.getLong(10) > 0; - if (cursor.getString(11) != null) { - record.dataItem.addAsset(cursor.getString(11), Asset.createFromRef(cursor.getString(12))); - while (cursor.moveToNext()) { - if (cursor.getLong(5) == record.seqId) { - record.dataItem.addAsset(cursor.getString(11), Asset.createFromRef(cursor.getString(12))); - } - } - cursor.moveToPrevious(); - } - return record; - } - - public static DataItemRecord fromSetDataItem(SetDataItem setDataItem) { - DataItemRecord record = new DataItemRecord(); - record.dataItem = new DataItemInternal(Uri.parse(setDataItem.uri)); - if (setDataItem.data != null) record.dataItem.data = setDataItem.data.toByteArray(); - if (setDataItem.assets != null) { - for (AssetEntry asset : setDataItem.assets) { - record.dataItem.addAsset(asset.key, Asset.createFromRef(asset.value.digest)); - } - } - record.source = setDataItem.source; - record.seqId = setDataItem.seqId; - record.v1SeqId = -1; - record.lastModified = setDataItem.lastModified; - record.deleted = setDataItem.deleted == null ? false : setDataItem.deleted; - record.packageName = setDataItem.packageName; - record.signatureDigest = setDataItem.signatureDigest; - return record; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("DataItemRecord{"); - sb.append("dataItem=").append(dataItem); - sb.append(", source='").append(source).append('\''); - sb.append(", seqId=").append(seqId); - sb.append(", v1SeqId=").append(v1SeqId); - sb.append(", lastModified=").append(lastModified); - sb.append(", deleted=").append(deleted); - sb.append(", assetsAreReady=").append(assetsAreReady); - sb.append(", packageName='").append(packageName).append('\''); - sb.append(", signatureDigest='").append(signatureDigest).append('\''); - sb.append('}'); - return sb.toString(); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/MessageHandler.java b/play-services-core/src/main/java/org/microg/gms/wearable/MessageHandler.java deleted file mode 100644 index b648b3ae..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/MessageHandler.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.text.TextUtils; -import android.util.Log; - -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.ConnectionConfiguration; -import com.google.android.gms.wearable.internal.MessageEventParcelable; - -import org.microg.gms.checkin.LastCheckinInfo; -import org.microg.gms.common.Build; -import org.microg.wearable.ServerMessageListener; -import org.microg.wearable.proto.AckAsset; -import org.microg.wearable.proto.Connect; -import org.microg.wearable.proto.FetchAsset; -import org.microg.wearable.proto.FilePiece; -import org.microg.wearable.proto.Heartbeat; -import org.microg.wearable.proto.Request; -import org.microg.wearable.proto.RootMessage; -import org.microg.wearable.proto.SetAsset; -import org.microg.wearable.proto.SetDataItem; -import org.microg.wearable.proto.SyncStart; -import org.microg.wearable.proto.SyncTableEntry; - -import java.io.IOException; -import java.util.Arrays; - -public class MessageHandler extends ServerMessageListener { - private static final String TAG = "GmsWearMsgHandler"; - private final WearableImpl wearable; - private final String oldConfigNodeId; - private String peerNodeId; - - public MessageHandler(WearableImpl wearable, ConnectionConfiguration config) { - this(wearable, config, new Build().model, config.nodeId, LastCheckinInfo.read(wearable.getContext()).androidId); - } - - private MessageHandler(WearableImpl wearable, ConnectionConfiguration config, String name, String networkId, long androidId) { - super(new Connect.Builder() - .name(name) - .id(wearable.getLocalNodeId()) - .networkId(networkId) - .peerAndroidId(androidId) - .unknown4(3) - .peerVersion(1) - .build()); - this.wearable = wearable; - this.oldConfigNodeId = config.nodeId; - } - - @Override - public void onConnect(Connect connect) { - super.onConnect(connect); - peerNodeId = connect.id; - wearable.onConnectReceived(getConnection(), oldConfigNodeId, connect); - try { - getConnection().writeMessage(new RootMessage.Builder().syncStart(new SyncStart.Builder() - .receivedSeqId(-1L) - .version(2) - .syncTable(Arrays.asList( - new SyncTableEntry.Builder().key("cloud").value(1L).build(), - new SyncTableEntry.Builder().key(wearable.getLocalNodeId()).value(wearable.getCurrentSeqId(wearable.getLocalNodeId())).build(), // TODO - new SyncTableEntry.Builder().key(peerNodeId).value(wearable.getCurrentSeqId(peerNodeId)).build() // TODO - )).build()).build()); - } catch (IOException e) { - Log.w(TAG, e); - } - } - - @Override - public void onDisconnected() { - Connect connect = getRemoteConnect(); - if (connect == null) - connect = new Connect.Builder().id(oldConfigNodeId).name("Wear device").build(); - wearable.onDisconnectReceived(getConnection(), connect); - super.onDisconnected(); - } - - @Override - public void onSetAsset(SetAsset setAsset) { - Log.d(TAG, "onSetAsset: " + setAsset); - Asset asset; - if (setAsset.data != null) { - asset = Asset.createFromBytes(setAsset.data.toByteArray()); - } else { - asset = Asset.createFromRef(setAsset.digest); - } - wearable.addAssetToDatabase(asset, setAsset.appkeys.appKeys); - } - - @Override - public void onAckAsset(AckAsset ackAsset) { - Log.d(TAG, "onAckAsset: " + ackAsset); - } - - @Override - public void onFetchAsset(FetchAsset fetchAsset) { - Log.d(TAG, "onFetchAsset: " + fetchAsset); - } - - @Override - public void onSyncStart(SyncStart syncStart) { - Log.d(TAG, "onSyncStart: " + syncStart); - if (syncStart.version < 2) { - Log.d(TAG, "Sync uses version " + syncStart.version + " which is not supported (yet)"); - } - boolean hasLocalNode = false; - if (syncStart.syncTable != null) { - for (SyncTableEntry entry : syncStart.syncTable) { - wearable.syncToPeer(peerNodeId, entry.key, entry.value); - if (wearable.getLocalNodeId().equals(entry.key)) hasLocalNode = true; - } - } else { - Log.d(TAG, "No sync table given."); - } - if (!hasLocalNode) wearable.syncToPeer(peerNodeId, wearable.getLocalNodeId(), 0); - } - - @Override - public void onSetDataItem(SetDataItem setDataItem) { - Log.d(TAG, "onSetDataItem: " + setDataItem); - wearable.putDataItem(DataItemRecord.fromSetDataItem(setDataItem)); - } - - @Override - public void onRpcRequest(Request rpcRequest) { - Log.d(TAG, "onRpcRequest: " + rpcRequest); - if (TextUtils.isEmpty(rpcRequest.targetNodeId) || rpcRequest.targetNodeId.equals(wearable.getLocalNodeId())) { - MessageEventParcelable messageEvent = new MessageEventParcelable(); - messageEvent.data = rpcRequest.rawData != null ? rpcRequest.rawData.toByteArray() : null; - messageEvent.path = rpcRequest.path; - messageEvent.requestId = rpcRequest.requestId + 31 * (rpcRequest.generation + 527); - messageEvent.sourceNodeId = TextUtils.isEmpty(rpcRequest.sourceNodeId) ? peerNodeId : rpcRequest.sourceNodeId; - - wearable.sendMessageReceived(rpcRequest.packageName, messageEvent); - } else if (rpcRequest.targetNodeId.equals(peerNodeId)) { - // Drop it - } else { - // TODO: find next hop - } - try { - getConnection().writeMessage(new RootMessage.Builder().heartbeat(new Heartbeat()).build()); - } catch (IOException e) { - onDisconnected(); - } - } - - @Override - public void onHeartbeat(Heartbeat heartbeat) { - Log.d(TAG, "onHeartbeat: " + heartbeat); - } - - @Override - public void onFilePiece(FilePiece filePiece) { - Log.d(TAG, "onFilePiece: " + filePiece); - wearable.handleFilePiece(getConnection(), filePiece.fileName, filePiece.piece.toByteArray(), filePiece.finalPiece ? filePiece.digest : null); - } - - @Override - public void onChannelRequest(Request channelRequest) { - Log.d(TAG, "onChannelRequest:" + channelRequest); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java b/play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java deleted file mode 100644 index d0bfe058..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.text.TextUtils; -import android.util.Log; - -import com.google.android.gms.wearable.Asset; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class NodeDatabaseHelper extends SQLiteOpenHelper { - private static final String TAG = "GmsWearNodeDB"; - - private static final String DB_NAME = "node.db"; - private static final String[] GDIBHAP_FIELDS = new String[]{"dataitems_id", "packageName", "signatureDigest", "host", "path", "seqId", "deleted", "sourceNode", "data", "timestampMs", "assetsPresent", "assetname", "assets_digest", "v1SourceNode", "v1SeqId"}; - private static final int VERSION = 9; - - private ClockworkNodePreferences clockworkNodePreferences; - - public NodeDatabaseHelper(Context context) { - super(context, DB_NAME, null, VERSION); - clockworkNodePreferences = new ClockworkNodePreferences(context); - } - - @Override - public void onCreate(SQLiteDatabase db) { - db.execSQL("CREATE TABLE appkeys(_id INTEGER PRIMARY KEY AUTOINCREMENT,packageName TEXT NOT NULL,signatureDigest TEXT NOT NULL);"); - db.execSQL("CREATE TABLE dataitems(_id INTEGER PRIMARY KEY AUTOINCREMENT, appkeys_id INTEGER NOT NULL REFERENCES appkeys(_id), host TEXT NOT NULL, path TEXT NOT NULL, seqId INTEGER NOT NULL, deleted INTEGER NOT NULL, sourceNode TEXT NOT NULL, data BLOB, timestampMs INTEGER NOT NULL, assetsPresent INTEGER NOT NULL, v1SourceNode TEXT NOT NULL, v1SeqId INTEGER NOT NULL);"); - db.execSQL("CREATE TABLE assets(digest TEXT PRIMARY KEY, dataPresent INTEGER NOT NULL DEFAULT 0, timestampMs INTEGER NOT NULL);"); - db.execSQL("CREATE TABLE assetrefs(assetname TEXT NOT NULL, dataitems_id INTEGER NOT NULL REFERENCES dataitems(_id), assets_digest TEXT NOT NULL REFERENCES assets(digest));"); - db.execSQL("CREATE TABLE assetsacls(appkeys_id INTEGER NOT NULL REFERENCES appkeys(_id), assets_digest TEXT NOT NULL);"); - db.execSQL("CREATE TABLE nodeinfo(node TEXT NOT NULL PRIMARY KEY, seqId INTEGER, lastActivityMs INTEGER);"); - db.execSQL("CREATE VIEW appKeyDataItems AS SELECT appkeys._id AS appkeys_id, appkeys.packageName AS packageName, appkeys.signatureDigest AS signatureDigest, dataitems._id AS dataitems_id, dataitems.host AS host, dataitems.path AS path, dataitems.seqId AS seqId, dataitems.deleted AS deleted, dataitems.sourceNode AS sourceNode, dataitems.data AS data, dataitems.timestampMs AS timestampMs, dataitems.assetsPresent AS assetsPresent, dataitems.v1SourceNode AS v1SourceNode, dataitems.v1SeqId AS v1SeqId FROM appkeys, dataitems WHERE appkeys._id=dataitems.appkeys_id"); - db.execSQL("CREATE VIEW appKeyAcls AS SELECT appkeys._id AS appkeys_id, appkeys.packageName AS packageName, appkeys.signatureDigest AS signatureDigest, assetsacls.assets_digest AS assets_digest FROM appkeys, assetsacls WHERE _id=appkeys_id"); - db.execSQL("CREATE VIEW dataItemsAndAssets AS SELECT appKeyDataItems.packageName AS packageName, appKeyDataItems.signatureDigest AS signatureDigest, appKeyDataItems.dataitems_id AS dataitems_id, appKeyDataItems.host AS host, appKeyDataItems.path AS path, appKeyDataItems.seqId AS seqId, appKeyDataItems.deleted AS deleted, appKeyDataItems.sourceNode AS sourceNode, appKeyDataItems.data AS data, appKeyDataItems.timestampMs AS timestampMs, appKeyDataItems.assetsPresent AS assetsPresent, assetrefs.assetname AS assetname, assetrefs.assets_digest AS assets_digest, appKeyDataItems.v1SourceNode AS v1SourceNode, appKeyDataItems.v1SeqId AS v1SeqId FROM appKeyDataItems LEFT OUTER JOIN assetrefs ON appKeyDataItems.dataitems_id=assetrefs.dataitems_id"); - db.execSQL("CREATE VIEW assetsReadyStatus AS SELECT dataitems_id AS dataitems_id, COUNT(*) = SUM(dataPresent) AS nowReady, assetsPresent AS markedReady FROM assetrefs, dataitems LEFT OUTER JOIN assets ON assetrefs.assets_digest = assets.digest WHERE assetrefs.dataitems_id=dataitems._id GROUP BY dataitems_id;"); - db.execSQL("CREATE UNIQUE INDEX appkeys_NAME_AND_SIG ON appkeys(packageName,signatureDigest);"); - db.execSQL("CREATE UNIQUE INDEX assetrefs_ASSET_REFS ON assetrefs(assets_digest,dataitems_id,assetname);"); - db.execSQL("CREATE UNIQUE INDEX assets_DIGEST ON assets(digest);"); - db.execSQL("CREATE UNIQUE INDEX assetsacls_APPKEY_AND_DIGEST ON assetsacls(appkeys_id,assets_digest);"); - db.execSQL("CREATE UNIQUE INDEX dataitems_APPKEY_HOST_AND_PATH ON dataitems(appkeys_id,host,path);"); - db.execSQL("CREATE UNIQUE INDEX dataitems_SOURCENODE_AND_SEQID ON dataitems(sourceNode,seqId);"); - db.execSQL("CREATE UNIQUE INDEX dataitems_SOURCENODE_DELETED_AND_SEQID ON dataitems(sourceNode,deleted,seqId);"); - } - - public synchronized Cursor getDataItemsForDataHolder(String packageName, String signatureDigest) { - return getDataItemsForDataHolderByHostAndPath(packageName, signatureDigest, null, null); - } - - public synchronized Cursor getDataItemsForDataHolderByHostAndPath(String packageName, String signatureDigest, String host, String path) { - String[] params; - String selection; - if (path == null) { - params = new String[]{packageName, signatureDigest}; - selection = "packageName = ? AND signatureDigest = ?"; - } else if (TextUtils.isEmpty(host)) { - if (path.endsWith("/")) path = path + "%"; - path = path.replace("*", "%"); - params = new String[]{packageName, signatureDigest, path}; - selection = "packageName = ? AND signatureDigest = ? AND path LIKE ?"; - } else { - if (path.endsWith("/")) path = path + "%"; - path = path.replace("*", "%"); - host = host.replace("*", "%"); - params = new String[]{packageName, signatureDigest, host, path}; - selection = "packageName = ? AND signatureDigest = ? AND host = ? AND path LIKE ?"; - } - selection += " AND deleted=0 AND assetsPresent !=0"; - return getReadableDatabase().rawQuery("SELECT host AS host,path AS path,data AS data,\'\' AS tags,assetname AS asset_key,assets_digest AS asset_id FROM dataItemsAndAssets WHERE " + selection, params); - } - - public synchronized Cursor getDataItemsByHostAndPath(String packageName, String signatureDigest, String host, String path) { - Log.d(TAG, "getDataItemsByHostAndPath: " + packageName + ", " + signatureDigest + ", " + host + ", " + path); - return getDataItemsByHostAndPath(getReadableDatabase(), packageName, signatureDigest, host, path); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - if (oldVersion != VERSION) { - // TODO: Upgrade not supported, cleaning up - db.execSQL("DROP TABLE IF EXISTS appkeys;"); - db.execSQL("DROP TABLE IF EXISTS dataitems;"); - db.execSQL("DROP TABLE IF EXISTS assets;"); - db.execSQL("DROP TABLE IF EXISTS assetrefs;"); - db.execSQL("DROP TABLE IF EXISTS assetsacls;"); - db.execSQL("DROP TABLE IF EXISTS nodeinfo;"); - db.execSQL("DROP VIEW IF EXISTS appKeyDataItems;"); - db.execSQL("DROP VIEW IF EXISTS appKeyAcls;"); - db.execSQL("DROP VIEW IF EXISTS dataItemsAndAssets;"); - db.execSQL("DROP VIEW IF EXISTS assetsReadyStatus;"); - onCreate(db); - } - } - - private static synchronized long getAppKey(SQLiteDatabase db, String packageName, String signatureDigest) { - Cursor cursor = db.rawQuery("SELECT _id FROM appkeys WHERE packageName=? AND signatureDigest=?", new String[]{packageName, signatureDigest}); - if (cursor != null) { - try { - if (cursor.moveToNext()) { - return cursor.getLong(0); - } - } finally { - cursor.close(); - } - } - ContentValues appKey = new ContentValues(); - appKey.put("packageName", packageName); - appKey.put("signatureDigest", signatureDigest); - return db.insert("appkeys", null, appKey); - } - - public synchronized void putRecord(DataItemRecord record) { - SQLiteDatabase db = getWritableDatabase(); - db.beginTransaction(); - Cursor cursor = getDataItemsByHostAndPath(db, record.packageName, record.signatureDigest, record.dataItem.host, record.dataItem.path); - try { - String key; - if (cursor.moveToNext()) { - // update - key = cursor.getString(0); - updateRecord(db, key, record); - } else { - // insert - key = insertRecord(db, record); - } - if (record.assetsAreReady) { - ContentValues update = new ContentValues(); - update.put("assetsPresent", 1); - db.update("dataitems", update, "_id=?", new String[]{key}); - } - db.setTransactionSuccessful(); - } finally { - cursor.close(); - } - db.endTransaction(); - } - - private static void updateRecord(SQLiteDatabase db, String key, DataItemRecord record) { - ContentValues cv = record.toContentValues(); - db.update("dataitems", cv, "_id=?", new String[]{key}); - finishRecord(db, key, record); - } - - private static String insertRecord(SQLiteDatabase db, DataItemRecord record) { - ContentValues contentValues = record.toContentValues(); - contentValues.put("appkeys_id", getAppKey(db, record.packageName, record.signatureDigest)); - contentValues.put("host", record.dataItem.host); - contentValues.put("path", record.dataItem.path); - String key = Long.toString(db.insertWithOnConflict("dataitems", "host", contentValues, SQLiteDatabase.CONFLICT_REPLACE)); - return finishRecord(db, key, record); - } - - private static String finishRecord(SQLiteDatabase db, String key, DataItemRecord record) { - if (!record.deleted) { - for (Map.Entry asset : record.dataItem.getAssets().entrySet()) { - ContentValues assetValues = new ContentValues(); - assetValues.put("assets_digest", asset.getValue().getDigest()); - assetValues.put("dataitems_id", key); - assetValues.put("assetname", asset.getKey()); - db.insertWithOnConflict("assetrefs", "assetname", assetValues, SQLiteDatabase.CONFLICT_IGNORE); - } - Cursor status = db.query("assetsReadyStatus", new String[]{"nowReady"}, "dataitems_id=?", new String[]{key}, null, null, null); - if (status.moveToNext()) { - record.assetsAreReady = status.getLong(0) != 0; - } - status.close(); - } else { - record.assetsAreReady = false; - } - return key; - } - - private static Cursor getDataItemsByHostAndPath(SQLiteDatabase db, String packageName, String signatureDigest, String host, String path) { - String[] params; - String selection; - if (path == null) { - params = new String[]{packageName, signatureDigest}; - selection = "packageName =? AND signatureDigest =?"; - } else if (host == null) { - params = new String[]{packageName, signatureDigest, path}; - selection = "packageName =? AND signatureDigest =? AND path =?"; - } else { - params = new String[]{packageName, signatureDigest, host, path}; - selection = "packageName =? AND signatureDigest =? AND host =? AND path =?"; - } - selection += " AND deleted=0"; - return db.query("dataItemsAndAssets", GDIBHAP_FIELDS, selection, params, null, null, "packageName, signatureDigest, host, path"); - } - - public Cursor getModifiedDataItems(final String nodeId, final long seqId, final boolean excludeDeleted) { - String selection = "sourceNode =? AND seqId >?" + (excludeDeleted ? " AND deleted =0" : ""); - return getReadableDatabase().query("dataItemsAndAssets", GDIBHAP_FIELDS, selection, new String[]{nodeId, Long.toString(seqId)}, null, null, "seqId", null); - } - - public synchronized List deleteDataItems(String packageName, String signatureDigest, String host, String path) { - List updated = new ArrayList(); - SQLiteDatabase db = getWritableDatabase(); - db.beginTransaction(); - Cursor cursor = getDataItemsByHostAndPath(db, packageName, signatureDigest, host, path); - while (cursor.moveToNext()) { - DataItemRecord record = DataItemRecord.fromCursor(cursor); - record.deleted = true; - record.assetsAreReady = true; - record.dataItem.data = null; - record.seqId = clockworkNodePreferences.getNextSeqId(); - record.v1SeqId = record.seqId; - updateRecord(db, cursor.getString(0), record); - updated.add(record); - } - db.setTransactionSuccessful(); - db.endTransaction(); - return updated; - } - - public long getCurrentSeqId(String sourceNode) { - if (TextUtils.isEmpty(sourceNode)) return 1; - return getCurrentSeqId(getReadableDatabase(), sourceNode); - } - - private long getCurrentSeqId(SQLiteDatabase db, String sourceNode) { - Cursor cursor = db.query("dataItemsAndAssets", new String[]{"seqId"}, "sourceNode=?", new String[]{sourceNode}, null, null, "seqId DESC", "1"); - long res = 1; - if (cursor != null) { - if (cursor.moveToFirst()) { - res = cursor.getLong(0); - } - cursor.close(); - } - return res; - } - - public synchronized void putAsset(Asset asset, boolean dataPresent) { - ContentValues cv = new ContentValues(); - cv.put("digest", asset.getDigest()); - cv.put("dataPresent", dataPresent ? 1 : 0); - cv.put("timestampMs", System.currentTimeMillis()); - getWritableDatabase().insertWithOnConflict("assets", null, cv, SQLiteDatabase.CONFLICT_REPLACE); - } - - public synchronized void allowAssetAccess(String digest, String packageName, String signatureDigest) { - SQLiteDatabase db = getWritableDatabase(); - ContentValues cv = new ContentValues(); - cv.put("assets_digest", digest); - cv.put("appkeys_id", getAppKey(db, packageName, signatureDigest)); - db.insertWithOnConflict("assetsacls", null, cv, SQLiteDatabase.CONFLICT_REPLACE); - } - - public Cursor listMissingAssets() { - return getReadableDatabase().query("dataItemsAndAssets", GDIBHAP_FIELDS, "assetsPresent = 0 AND assets_digest NOT NULL", null, null, null, "packageName, signatureDigest, host, path"); - } - - public boolean hasAsset(Asset asset) { - Cursor cursor = getReadableDatabase().query("assets", new String[]{"dataPresent"}, "digest=?", new String[]{asset.getDigest()}, null, null, null); - if (cursor == null) return false; - try { - return (cursor.moveToNext() && cursor.getInt(0) == 1); - } finally { - cursor.close(); - } - } - - public synchronized void markAssetAsPresent(String digest) { - ContentValues cv = new ContentValues(); - cv.put("dataPresent", 1); - SQLiteDatabase db = getWritableDatabase(); - db.update("assets", cv, "digest=?", new String[]{digest}); - Cursor status = db.query("assetsReadyStatus", null, "nowReady != markedReady", null, null, null, null); - while (status.moveToNext()) { - cv = new ContentValues(); - cv.put("assetsPresent", status.getInt(status.getColumnIndex("nowReady"))); - db.update("dataitems", cv, "_id=?", new String[]{Integer.toString(status.getInt(status.getColumnIndex("dataitems_id")))}); - } - status.close(); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/RpcHelper.java b/play-services-core/src/main/java/org/microg/gms/wearable/RpcHelper.java deleted file mode 100644 index b6a638cd..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/RpcHelper.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.Context; -import android.content.SharedPreferences; - -import java.util.HashMap; -import java.util.Map; - -public class RpcHelper { - private final Map rpcStateMap = new HashMap(); - private final SharedPreferences preferences; - private final Context context; - - public RpcHelper(Context context) { - this.context = context; - this.preferences = context.getSharedPreferences("wearable.rpc_service.settings", 0); - } - - private String getRpcConnectionId(String packageName, String targetNodeId, String path) { - String mode = "lo"; - if (packageName.equals("com.google.android.wearable.app") && path.startsWith("/s3")) - mode = "hi"; - return targetNodeId + ":" + mode; - } - - public RpcHelper.RpcConnectionState useConnectionState(String packageName, String targetNodeId, String path) { - String rpcConnectionId = getRpcConnectionId(packageName, targetNodeId, path); - synchronized (rpcStateMap) { - if (!rpcStateMap.containsKey(rpcConnectionId)) { - int g = preferences.getInt(rpcConnectionId, 1)+1; - preferences.edit().putInt(rpcConnectionId, g).apply(); - rpcStateMap.put(rpcConnectionId, new RpcConnectionState(g)); - } - RpcHelper.RpcConnectionState res = rpcStateMap.get(rpcConnectionId); - res.lastRequestId++; - return res.freeze(); - } - } - - public static class RpcConnectionState { - public int generation; - public int lastRequestId; - - public RpcConnectionState(int generation) { - this.generation = generation; - } - - public RpcConnectionState freeze() { - RpcConnectionState res = new RpcConnectionState(generation); - res.lastRequestId = lastRequestId; - return res; - } - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/WearableImpl.java b/play-services-core/src/main/java/org/microg/gms/wearable/WearableImpl.java deleted file mode 100644 index 7a30d100..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/WearableImpl.java +++ /dev/null @@ -1,634 +0,0 @@ -/* - * Copyright (C) 2013-2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.database.Cursor; -import android.net.Uri; -import android.os.Handler; -import android.os.Looper; -import android.os.RemoteException; -import android.text.TextUtils; -import android.util.Base64; -import android.util.Log; - -import androidx.annotation.Nullable; - -import com.google.android.gms.common.data.DataHolder; -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.ConnectionConfiguration; -import com.google.android.gms.wearable.Node; -import com.google.android.gms.wearable.internal.IWearableListener; -import com.google.android.gms.wearable.internal.MessageEventParcelable; -import com.google.android.gms.wearable.internal.NodeParcelable; -import com.google.android.gms.wearable.internal.PutDataRequest; - -import org.microg.gms.common.PackageUtils; -import org.microg.gms.common.RemoteListenerProxy; -import org.microg.gms.common.Utils; -import org.microg.wearable.SocketConnectionThread; -import org.microg.wearable.WearableConnection; -import org.microg.wearable.proto.AckAsset; -import org.microg.wearable.proto.AppKey; -import org.microg.wearable.proto.AppKeys; -import org.microg.wearable.proto.Connect; -import org.microg.wearable.proto.FetchAsset; -import org.microg.wearable.proto.FilePiece; -import org.microg.wearable.proto.Request; -import org.microg.wearable.proto.RootMessage; -import org.microg.wearable.proto.SetAsset; -import org.microg.wearable.proto.SetDataItem; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import okio.ByteString; - -public class WearableImpl { - - private static final String TAG = "GmsWear"; - - private static final int WEAR_TCP_PORT = 5601; - - private final Context context; - private final NodeDatabaseHelper nodeDatabase; - private final ConfigurationDatabaseHelper configDatabase; - private final Map> listeners = new HashMap>(); - private final Set connectedNodes = new HashSet(); - private final Map activeConnections = new HashMap(); - private RpcHelper rpcHelper; - private SocketConnectionThread sct; - private ConnectionConfiguration[] configurations; - private boolean configurationsUpdated = false; - private ClockworkNodePreferences clockworkNodePreferences; - public Handler networkHandler; - - public WearableImpl(Context context, NodeDatabaseHelper nodeDatabase, ConfigurationDatabaseHelper configDatabase) { - this.context = context; - this.nodeDatabase = nodeDatabase; - this.configDatabase = configDatabase; - this.clockworkNodePreferences = new ClockworkNodePreferences(context); - this.rpcHelper = new RpcHelper(context); - new Thread(() -> { - Looper.prepare(); - networkHandler = new Handler(Looper.myLooper()); - Looper.loop(); - }).start(); - } - - public String getLocalNodeId() { - return clockworkNodePreferences.getLocalNodeId(); - } - - public DataItemRecord putDataItem(String packageName, String signatureDigest, String source, DataItemInternal dataItem) { - DataItemRecord record = new DataItemRecord(); - record.packageName = packageName; - record.signatureDigest = signatureDigest; - record.deleted = false; - record.source = source; - record.dataItem = dataItem; - record.v1SeqId = clockworkNodePreferences.getNextSeqId(); - if (record.source.equals(getLocalNodeId())) record.seqId = record.v1SeqId; - nodeDatabase.putRecord(record); - return record; - } - - public DataItemRecord putDataItem(DataItemRecord record) { - nodeDatabase.putRecord(record); - if (!record.assetsAreReady) { - for (Asset asset : record.dataItem.getAssets().values()) { - if (!nodeDatabase.hasAsset(asset)) { - Log.d(TAG, "Asset is missing: " + asset); - } - } - } - Intent intent = new Intent("com.google.android.gms.wearable.DATA_CHANGED"); - intent.setPackage(record.packageName); - intent.setData(record.dataItem.uri); - invokeListeners(intent, listener -> listener.onDataChanged(record.toEventDataHolder())); - return record; - } - - private Asset prepareAsset(String packageName, Asset asset) { - if (asset.getFd() != null && asset.data == null) { - try { - asset.data = Utils.readStreamToEnd(new FileInputStream(asset.getFd().getFileDescriptor())); - } catch (IOException e) { - Log.w(TAG, e); - } - } - if (asset.data != null) { - String digest = calculateDigest(asset.data); - File assetFile = createAssetFile(digest); - boolean success = assetFile.exists(); - if (!success) { - File tmpFile = new File(assetFile.getParent(), assetFile.getName() + ".tmp"); - - try { - FileOutputStream stream = new FileOutputStream(tmpFile); - stream.write(asset.data); - stream.close(); - success = tmpFile.renameTo(assetFile); - } catch (IOException e) { - Log.w(TAG, e); - } - } - if (success) { - Log.d(TAG, "Successfully created asset file " + assetFile); - return Asset.createFromRef(digest); - } else { - Log.w(TAG, "Failed creating asset file " + assetFile); - } - } - return null; - } - - public File createAssetFile(String digest) { - File dir = new File(new File(context.getFilesDir(), "assets"), digest.substring(digest.length() - 2)); - dir.mkdirs(); - return new File(dir, digest + ".asset"); - } - - private File createAssetReceiveTempFile(String name) { - File dir = new File(context.getFilesDir(), "piece"); - dir.mkdirs(); - return new File(dir, name); - } - - private String calculateDigest(byte[] data) { - try { - return Base64.encodeToString(MessageDigest.getInstance("SHA1").digest(data), Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } - } - - public synchronized ConnectionConfiguration[] getConfigurations() { - if (configurations == null) { - configurations = configDatabase.getAllConfigurations(); - } - if (configurationsUpdated) { - configurationsUpdated = false; - ConnectionConfiguration[] newConfigurations = configDatabase.getAllConfigurations(); - for (ConnectionConfiguration configuration : configurations) { - for (ConnectionConfiguration newConfiguration : newConfigurations) { - if (newConfiguration.name.equals(configuration.name)) { - newConfiguration.connected = configuration.connected; - newConfiguration.peerNodeId = configuration.peerNodeId; - newConfiguration.nodeId = configuration.nodeId; - break; - } - } - } - configurations = newConfigurations; - } - Log.d(TAG, "Configurations reported: " + Arrays.toString(configurations)); - return configurations; - } - - private void addConnectedNode(Node node) { - connectedNodes.add(node); - onConnectedNodes(getConnectedNodesParcelableList()); - } - - private void removeConnectedNode(String nodeId) { - for (Node connectedNode : new ArrayList(connectedNodes)) { - if (connectedNode.getId().equals(nodeId)) - connectedNodes.remove(connectedNode); - } - onConnectedNodes(getConnectedNodesParcelableList()); - } - - - public Context getContext() { - return context; - } - - public void syncToPeer(String peerNodeId, String nodeId, long seqId) { - Log.d(TAG, "-- Start syncing over to " + peerNodeId + ", nodeId " + nodeId + " starting with seqId " + seqId); - Cursor cursor = nodeDatabase.getModifiedDataItems(nodeId, seqId, true); - if (cursor != null) { - while (cursor.moveToNext()) { - if (!syncRecordToPeer(peerNodeId, DataItemRecord.fromCursor(cursor))) break; - } - cursor.close(); - } - Log.d(TAG, "-- Done syncing over to " + peerNodeId + ", nodeId " + nodeId + " starting with seqId " + seqId); - } - - - void syncRecordToAll(DataItemRecord record) { - for (String nodeId : new ArrayList(activeConnections.keySet())) { - syncRecordToPeer(nodeId, record); - } - } - - private boolean syncRecordToPeer(String nodeId, DataItemRecord record) { - for (Asset asset : record.dataItem.getAssets().values()) { - try { - syncAssetToPeer(nodeId, record, asset); - } catch (Exception e) { - Log.w(TAG, "Could not sync asset " + asset + " for " + nodeId + " and " + record, e); - closeConnection(nodeId); - return false; - } - } - - try { - SetDataItem item = record.toSetDataItem(); - activeConnections.get(nodeId).writeMessage(new RootMessage.Builder().setDataItem(item).build()); - } catch (Exception e) { - Log.w(TAG, e); - closeConnection(nodeId); - return false; - } - return true; - } - - private void syncAssetToPeer(String nodeId, DataItemRecord record, Asset asset) throws IOException { - RootMessage announceMessage = new RootMessage.Builder().setAsset(new SetAsset.Builder() - .digest(asset.getDigest()) - .appkeys(new AppKeys(Collections.singletonList(new AppKey(record.packageName, record.signatureDigest)))) - .build()).hasAsset(true).build(); - activeConnections.get(nodeId).writeMessage(announceMessage); - File assetFile = createAssetFile(asset.getDigest()); - String fileName = calculateDigest(announceMessage.toByteArray()); - FileInputStream fis = new FileInputStream(assetFile); - byte[] arr = new byte[12215]; - ByteString lastPiece = null; - int c = 0; - while ((c = fis.read(arr)) > 0) { - if (lastPiece != null) { - activeConnections.get(nodeId).writeMessage(new RootMessage.Builder().filePiece(new FilePiece(fileName, false, lastPiece, null)).build()); - } - lastPiece = ByteString.of(arr, 0, c); - } - activeConnections.get(nodeId).writeMessage(new RootMessage.Builder().filePiece(new FilePiece(fileName, true, lastPiece, asset.getDigest())).build()); - } - - public void addAssetToDatabase(Asset asset, List appKeys) { - nodeDatabase.putAsset(asset, false); - for (AppKey appKey : appKeys) { - nodeDatabase.allowAssetAccess(asset.getDigest(), appKey.packageName, appKey.signatureDigest); - } - } - - public long getCurrentSeqId(String nodeId) { - return nodeDatabase.getCurrentSeqId(nodeId); - } - - public void handleFilePiece(WearableConnection connection, String fileName, byte[] bytes, String finalPieceDigest) { - File file = createAssetReceiveTempFile(fileName); - try { - FileOutputStream fos = new FileOutputStream(file, true); - fos.write(bytes); - fos.close(); - } catch (IOException e) { - Log.w(TAG, e); - } - if (finalPieceDigest != null) { - // This is a final piece. If digest matches we're so happy! - try { - String digest = calculateDigest(Utils.readStreamToEnd(new FileInputStream(file))); - if (digest.equals(finalPieceDigest)) { - if (file.renameTo(createAssetFile(digest))) { - nodeDatabase.markAssetAsPresent(digest); - connection.writeMessage(new RootMessage.Builder().ackAsset(new AckAsset(digest)).build()); - } else { - Log.w(TAG, "Could not rename to target file name. delete=" + file.delete()); - } - } else { - Log.w(TAG, "Received digest does not match. delete=" + file.delete()); - } - } catch (IOException e) { - Log.w(TAG, "Failed working with temp file. delete=" + file.delete(), e); - } - } - } - - public void onConnectReceived(WearableConnection connection, String nodeId, Connect connect) { - for (ConnectionConfiguration config : getConfigurations()) { - if (config.nodeId.equals(nodeId)) { - if (config.nodeId != nodeId) { - config.nodeId = connect.id; - configDatabase.putConfiguration(config, nodeId); - } - config.peerNodeId = connect.id; - config.connected = true; - } - } - Log.d(TAG, "Adding connection to list of open connections: " + connection + " with connect " + connect); - activeConnections.put(connect.id, connection); - onPeerConnected(new NodeParcelable(connect.id, connect.name)); - // Fetch missing assets - Cursor cursor = nodeDatabase.listMissingAssets(); - if (cursor != null) { - while (cursor.moveToNext()) { - try { - Log.d(TAG, "Fetch for " + cursor.getString(12)); - connection.writeMessage(new RootMessage.Builder() - .fetchAsset(new FetchAsset.Builder() - .assetName(cursor.getString(12)) - .packageName(cursor.getString(1)) - .signatureDigest(cursor.getString(2)) - .permission(false) - .build()).build()); - } catch (IOException e) { - Log.w(TAG, e); - closeConnection(connect.id); - } - } - cursor.close(); - } - } - - public void onDisconnectReceived(WearableConnection connection, Connect connect) { - for (ConnectionConfiguration config : getConfigurations()) { - if (config.nodeId.equals(connect.id)) { - config.connected = false; - } - } - Log.d(TAG, "Removing connection from list of open connections: " + connection); - activeConnections.remove(connect.id); - onPeerDisconnected(new NodeParcelable(connect.id, connect.name)); - } - - public List getConnectedNodesParcelableList() { - List nodes = new ArrayList(); - for (Node connectedNode : connectedNodes) { - nodes.add(new NodeParcelable(connectedNode)); - } - return nodes; - } - - interface ListenerInvoker { - void invoke(IWearableListener listener) throws RemoteException; - } - - private void invokeListeners(@Nullable Intent intent, ListenerInvoker invoker) { - for (String packageName : new ArrayList<>(listeners.keySet())) { - List listeners = this.listeners.get(packageName); - if (listeners == null) continue; - for (int i = 0; i < listeners.size(); i++) { - boolean filterMatched = false; - if (intent != null) { - for (IntentFilter filter : listeners.get(i).filters) { - filterMatched |= filter.match(context.getContentResolver(), intent, false, TAG) > 0; - } - } - if (filterMatched || listeners.get(i).filters.length == 0) { - try { - invoker.invoke(listeners.get(i).listener); - } catch (RemoteException e) { - Log.w(TAG, "Registered listener at package " + packageName + " failed, removing."); - listeners.remove(i); - i--; - } - } - } - if (listeners.isEmpty()) { - this.listeners.remove(packageName); - } - } - if (intent != null) { - try { - invoker.invoke(RemoteListenerProxy.get(context, intent, IWearableListener.class, "com.google.android.gms.wearable.BIND_LISTENER")); - } catch (RemoteException e) { - Log.w(TAG, "Failed to deliver message received to " + intent, e); - } - } - } - - public void onPeerConnected(NodeParcelable node) { - Log.d(TAG, "onPeerConnected: " + node); - invokeListeners(null, listener -> listener.onPeerConnected(node)); - addConnectedNode(node); - } - - public void onPeerDisconnected(NodeParcelable node) { - Log.d(TAG, "onPeerDisconnected: " + node); - invokeListeners(null, listener -> listener.onPeerDisconnected(node)); - removeConnectedNode(node.getId()); - } - - public void onConnectedNodes(List nodes) { - Log.d(TAG, "onConnectedNodes: " + nodes); - invokeListeners(null, listener -> listener.onConnectedNodes(nodes)); - } - - public DataItemRecord putData(PutDataRequest request, String packageName) { - DataItemInternal dataItem = new DataItemInternal(fixHost(request.getUri().getHost(), true), request.getUri().getPath()); - for (Map.Entry assetEntry : request.getAssets().entrySet()) { - Asset asset = prepareAsset(packageName, assetEntry.getValue()); - if (asset != null) { - nodeDatabase.putAsset(asset, true); - dataItem.addAsset(assetEntry.getKey(), asset); - } - } - dataItem.data = request.getData(); - DataItemRecord record = putDataItem(packageName, PackageUtils.firstSignatureDigest(context, packageName), getLocalNodeId(), dataItem); - syncRecordToAll(record); - return record; - } - - public DataHolder getDataItemsAsHolder(String packageName) { - Cursor dataHolderItems = nodeDatabase.getDataItemsForDataHolder(packageName, PackageUtils.firstSignatureDigest(context, packageName)); - return new DataHolder(dataHolderItems, 0, null); - } - - private String fixHost(String host, boolean nothingToLocal) { - if (TextUtils.isEmpty(host) && nothingToLocal) return getLocalNodeId(); - if (TextUtils.isEmpty(host)) return null; - if (host.equals("local")) return getLocalNodeId(); - return host; - } - - public DataHolder getDataItemsByUriAsHolder(Uri uri, String packageName) { - String firstSignature; - try { - firstSignature = PackageUtils.firstSignatureDigest(context, packageName); - } catch (Exception e) { - return null; - } - Cursor dataHolderItems = nodeDatabase.getDataItemsForDataHolderByHostAndPath(packageName, firstSignature, fixHost(uri.getHost(), false), uri.getPath()); - DataHolder dataHolder = new DataHolder(dataHolderItems, 0, null); - Log.d(TAG, "Returning data holder of size " + dataHolder.getCount() + " for query " + uri); - return dataHolder; - } - - public synchronized void addListener(String packageName, IWearableListener listener, IntentFilter[] filters) { - if (!listeners.containsKey(packageName)) { - listeners.put(packageName, new ArrayList()); - } - listeners.get(packageName).add(new ListenerInfo(listener, filters)); - } - - public void removeListener(IWearableListener listener) { - for (List list : listeners.values()) { - for (int i = 0; i < list.size(); i++) { - if (list.get(i).listener.equals(listener)) { - list.remove(i); - i--; - } - } - } - } - - public void enableConnection(String name) { - configDatabase.setEnabledState(name, true); - configurationsUpdated = true; - if (name.equals("server") && sct == null) { - Log.d(TAG, "Starting server on :" + WEAR_TCP_PORT); - (sct = SocketConnectionThread.serverListen(WEAR_TCP_PORT, new MessageHandler(this, configDatabase.getConfiguration(name)))).start(); - } - } - - public void disableConnection(String name) { - configDatabase.setEnabledState(name, false); - configurationsUpdated = true; - if (name.equals("server") && sct != null) { - activeConnections.remove(sct.getWearableConnection()); - sct.close(); - sct.interrupt(); - sct = null; - } - } - - public void deleteConnection(String name) { - configDatabase.deleteConfiguration(name); - configurationsUpdated = true; - } - - public void createConnection(ConnectionConfiguration config) { - if (config.nodeId == null) config.nodeId = getLocalNodeId(); - Log.d(TAG, "putConfig[nyp]: " + config); - configDatabase.putConfiguration(config); - configurationsUpdated = true; - } - - public int deleteDataItems(Uri uri, String packageName) { - List records = nodeDatabase.deleteDataItems(packageName, PackageUtils.firstSignatureDigest(context, packageName), fixHost(uri.getHost(), false), uri.getPath()); - for (DataItemRecord record : records) { - syncRecordToAll(record); - } - return records.size(); - } - - public void sendMessageReceived(String packageName, MessageEventParcelable messageEvent) { - Log.d(TAG, "onMessageReceived: " + messageEvent); - Intent intent = new Intent("com.google.android.gms.wearable.MESSAGE_RECEIVED"); - intent.setPackage(packageName); - intent.setData(Uri.parse("wear://" + getLocalNodeId() + "/" + messageEvent.getPath())); - invokeListeners(intent, listener -> listener.onMessageReceived(messageEvent)); - } - - public DataItemRecord getDataItemByUri(Uri uri, String packageName) { - Cursor cursor = nodeDatabase.getDataItemsByHostAndPath(packageName, PackageUtils.firstSignatureDigest(context, packageName), fixHost(uri.getHost(), true), uri.getPath()); - DataItemRecord record = null; - if (cursor != null) { - if (cursor.moveToNext()) { - record = DataItemRecord.fromCursor(cursor); - } - cursor.close(); - } - Log.d(TAG, "getDataItem: " + record); - return record; - } - - private IWearableListener getListener(String packageName, String action, Uri uri) { - Intent intent = new Intent(action); - intent.setPackage(packageName); - intent.setData(uri); - - return RemoteListenerProxy.get(context, intent, IWearableListener.class, "com.google.android.gms.wearable.BIND_LISTENER"); - } - - private void closeConnection(String nodeId) { - WearableConnection connection = activeConnections.get(nodeId); - try { - connection.close(); - } catch (IOException e1) { - Log.w(TAG, e1); - } - if (connection == sct.getWearableConnection()) { - sct.close(); - sct = null; - } - activeConnections.remove(nodeId); - for (ConnectionConfiguration config : getConfigurations()) { - if (nodeId.equals(config.nodeId) || nodeId.equals(config.peerNodeId)) { - config.connected = false; - } - } - onPeerDisconnected(new NodeParcelable(nodeId, "Wear device")); - Log.d(TAG, "Closed connection to " + nodeId + " on error"); - } - - public int sendMessage(String packageName, String targetNodeId, String path, byte[] data) { - if (activeConnections.containsKey(targetNodeId)) { - WearableConnection connection = activeConnections.get(targetNodeId); - RpcHelper.RpcConnectionState state = rpcHelper.useConnectionState(packageName, targetNodeId, path); - try { - connection.writeMessage(new RootMessage.Builder().rpcRequest(new Request.Builder() - .targetNodeId(targetNodeId) - .path(path) - .rawData(ByteString.of(data)) - .packageName(packageName) - .signatureDigest(PackageUtils.firstSignatureDigest(context, packageName)) - .sourceNodeId(getLocalNodeId()) - .generation(state.generation) - .requestId(state.lastRequestId) - .build()).build()); - } catch (IOException e) { - Log.w(TAG, "Error while writing, closing link", e); - closeConnection(targetNodeId); - return -1; - } - return (state.generation + 527) * 31 + state.lastRequestId; - } - Log.d(TAG, targetNodeId + " seems not reachable"); - return -1; - } - - public void stop() { - this.networkHandler.getLooper().quit(); - } - - private class ListenerInfo { - private IWearableListener listener; - private IntentFilter[] filters; - - private ListenerInfo(IWearableListener listener, IntentFilter[] filters) { - this.listener = listener; - this.filters = filters; - } - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/WearableService.java b/play-services-core/src/main/java/org/microg/gms/wearable/WearableService.java deleted file mode 100644 index 737b045d..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/WearableService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.os.RemoteException; - -import com.google.android.gms.common.internal.GetServiceRequest; -import com.google.android.gms.common.internal.IGmsCallbacks; - -import org.microg.gms.BaseService; -import org.microg.gms.common.GmsService; -import org.microg.gms.common.PackageUtils; - -public class WearableService extends BaseService { - - private WearableImpl wearable; - - public WearableService() { - super("GmsWearSvc", GmsService.WEARABLE); - } - - @Override - public void onCreate() { - super.onCreate(); - ConfigurationDatabaseHelper configurationDatabaseHelper = new ConfigurationDatabaseHelper(getApplicationContext()); - NodeDatabaseHelper nodeDatabaseHelper = new NodeDatabaseHelper(getApplicationContext()); - wearable = new WearableImpl(getApplicationContext(), nodeDatabaseHelper, configurationDatabaseHelper); - } - - @Override - public void onDestroy() { - super.onDestroy(); - wearable.stop(); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - PackageUtils.getAndCheckCallingPackage(this, request.packageName); - callback.onPostInitComplete(0, new WearableServiceImpl(this, wearable, request.packageName), null); - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/WearableServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/wearable/WearableServiceImpl.java deleted file mode 100644 index e091ba72..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/WearableServiceImpl.java +++ /dev/null @@ -1,527 +0,0 @@ -/* - * Copyright (C) 2013-2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.Context; -import android.net.Uri; -import android.os.Handler; -import android.os.Parcel; -import android.os.ParcelFileDescriptor; -import android.os.RemoteException; -import android.util.Base64; -import android.util.Log; - -import com.google.android.gms.common.api.Status; -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.ConnectionConfiguration; -import com.google.android.gms.wearable.internal.AddListenerRequest; -import com.google.android.gms.wearable.internal.AddLocalCapabilityResponse; -import com.google.android.gms.wearable.internal.AncsNotificationParcelable; -import com.google.android.gms.wearable.internal.CapabilityInfoParcelable; -import com.google.android.gms.wearable.internal.DeleteDataItemsResponse; -import com.google.android.gms.wearable.internal.GetCapabilityResponse; -import com.google.android.gms.wearable.internal.GetCloudSyncSettingResponse; -import com.google.android.gms.wearable.internal.GetConfigResponse; -import com.google.android.gms.wearable.internal.GetConfigsResponse; -import com.google.android.gms.wearable.internal.GetConnectedNodesResponse; -import com.google.android.gms.wearable.internal.GetDataItemResponse; -import com.google.android.gms.wearable.internal.GetFdForAssetResponse; -import com.google.android.gms.wearable.internal.GetLocalNodeResponse; -import com.google.android.gms.wearable.internal.IChannelStreamCallbacks; -import com.google.android.gms.wearable.internal.IWearableCallbacks; -import com.google.android.gms.wearable.internal.IWearableService; -import com.google.android.gms.wearable.internal.NodeParcelable; -import com.google.android.gms.wearable.internal.PutDataRequest; -import com.google.android.gms.wearable.internal.PutDataResponse; -import com.google.android.gms.wearable.internal.RemoveListenerRequest; -import com.google.android.gms.wearable.internal.RemoveLocalCapabilityResponse; -import com.google.android.gms.wearable.internal.SendMessageResponse; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -public class WearableServiceImpl extends IWearableService.Stub { - private static final String TAG = "GmsWearSvcImpl"; - - private final Context context; - private final String packageName; - private final WearableImpl wearable; - private final Handler mainHandler; - private final CapabilityManager capabilities; - - public WearableServiceImpl(Context context, WearableImpl wearable, String packageName) { - this.context = context; - this.wearable = wearable; - this.packageName = packageName; - this.capabilities = new CapabilityManager(context, wearable, packageName); - this.mainHandler = new Handler(context.getMainLooper()); - } - - private void postMain(IWearableCallbacks callbacks, RemoteExceptionRunnable runnable) { - mainHandler.post(new CallbackRunnable(callbacks) { - @Override - public void run(IWearableCallbacks callbacks) throws RemoteException { - runnable.run(); - } - }); - } - - private void postNetwork(IWearableCallbacks callbacks, RemoteExceptionRunnable runnable) { - this.wearable.networkHandler.post(new CallbackRunnable(callbacks) { - @Override - public void run(IWearableCallbacks callbacks) throws RemoteException { - runnable.run(); - } - }); - } - - /* - * Config - */ - - @Override - public void putConfig(IWearableCallbacks callbacks, final ConnectionConfiguration config) throws RemoteException { - postMain(callbacks, () -> { - wearable.createConnection(config); - callbacks.onStatus(Status.SUCCESS); - }); - } - - @Override - public void deleteConfig(IWearableCallbacks callbacks, final String name) throws RemoteException { - postMain(callbacks, () -> { - wearable.deleteConnection(name); - callbacks.onStatus(Status.SUCCESS); - }); - } - - @Override - public void getConfigs(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "getConfigs"); - postMain(callbacks, () -> { - try { - callbacks.onGetConfigsResponse(new GetConfigsResponse(0, wearable.getConfigurations())); - } catch (Exception e) { - callbacks.onGetConfigsResponse(new GetConfigsResponse(8, new ConnectionConfiguration[0])); - } - }); - } - - - @Override - public void enableConfig(IWearableCallbacks callbacks, final String name) throws RemoteException { - Log.d(TAG, "enableConfig: " + name); - postMain(callbacks, () -> { - wearable.enableConnection(name); - callbacks.onStatus(Status.SUCCESS); - }); - } - - @Override - public void disableConfig(IWearableCallbacks callbacks, final String name) throws RemoteException { - Log.d(TAG, "disableConfig: " + name); - postMain(callbacks, () -> { - wearable.disableConnection(name); - callbacks.onStatus(Status.SUCCESS); - }); - } - - /* - * DataItems - */ - - @Override - public void putData(IWearableCallbacks callbacks, final PutDataRequest request) throws RemoteException { - Log.d(TAG, "putData: " + request.toString(true)); - this.wearable.networkHandler.post(new CallbackRunnable(callbacks) { - @Override - public void run(IWearableCallbacks callbacks) throws RemoteException { - DataItemRecord record = wearable.putData(request, packageName); - callbacks.onPutDataResponse(new PutDataResponse(0, record.toParcelable())); - } - }); - } - - @Override - public void getDataItem(IWearableCallbacks callbacks, final Uri uri) throws RemoteException { - Log.d(TAG, "getDataItem: " + uri); - postMain(callbacks, () -> { - DataItemRecord record = wearable.getDataItemByUri(uri, packageName); - if (record != null) { - callbacks.onGetDataItemResponse(new GetDataItemResponse(0, record.toParcelable())); - } else { - callbacks.onGetDataItemResponse(new GetDataItemResponse(0, null)); - } - }); - } - - @Override - public void getDataItems(final IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "getDataItems: " + callbacks); - postMain(callbacks, () -> { - callbacks.onDataItemChanged(wearable.getDataItemsAsHolder(packageName)); - }); - } - - @Override - public void getDataItemsByUri(IWearableCallbacks callbacks, Uri uri) throws RemoteException { - getDataItemsByUriWithFilter(callbacks, uri, 0); - } - - @Override - public void getDataItemsByUriWithFilter(IWearableCallbacks callbacks, final Uri uri, int typeFilter) throws RemoteException { - Log.d(TAG, "getDataItemsByUri: " + uri); - postMain(callbacks, () -> { - callbacks.onDataItemChanged(wearable.getDataItemsByUriAsHolder(uri, packageName)); - }); - } - - @Override - public void deleteDataItems(IWearableCallbacks callbacks, Uri uri) throws RemoteException { - deleteDataItemsWithFilter(callbacks, uri, 0); - } - - @Override - public void deleteDataItemsWithFilter(IWearableCallbacks callbacks, final Uri uri, int typeFilter) throws RemoteException { - Log.d(TAG, "deleteDataItems: " + uri); - this.wearable.networkHandler.post(new CallbackRunnable(callbacks) { - @Override - public void run(IWearableCallbacks callbacks) throws RemoteException { - callbacks.onDeleteDataItemsResponse(new DeleteDataItemsResponse(0, wearable.deleteDataItems(uri, packageName))); - } - }); - } - - @Override - public void sendMessage(IWearableCallbacks callbacks, final String targetNodeId, final String path, final byte[] data) throws RemoteException { - Log.d(TAG, "sendMessage: " + targetNodeId + " / " + path + ": " + (data == null ? null : Base64.encodeToString(data, Base64.NO_WRAP))); - this.wearable.networkHandler.post(new CallbackRunnable(callbacks) { - @Override - public void run(IWearableCallbacks callbacks) throws RemoteException { - SendMessageResponse sendMessageResponse = new SendMessageResponse(); - try { - sendMessageResponse.requestId = wearable.sendMessage(packageName, targetNodeId, path, data); - if (sendMessageResponse.requestId == -1) { - sendMessageResponse.statusCode = 4000; - } - } catch (Exception e) { - sendMessageResponse.statusCode = 8; - } - mainHandler.post(() -> { - try { - callbacks.onSendMessageResponse(sendMessageResponse); - } catch (RemoteException e) { - e.printStackTrace(); - } - }); - } - }); - } - - @Override - public void getFdForAsset(IWearableCallbacks callbacks, final Asset asset) throws RemoteException { - Log.d(TAG, "getFdForAsset " + asset); - postMain(callbacks, () -> { - // TODO: Access control - try { - callbacks.onGetFdForAssetResponse(new GetFdForAssetResponse(0, ParcelFileDescriptor.open(wearable.createAssetFile(asset.getDigest()), ParcelFileDescriptor.MODE_READ_ONLY))); - } catch (FileNotFoundException e) { - callbacks.onGetFdForAssetResponse(new GetFdForAssetResponse(8, null)); - } - }); - } - - @Override - public void optInCloudSync(IWearableCallbacks callbacks, boolean enable) throws RemoteException { - callbacks.onStatus(Status.SUCCESS); - } - - @Override - @Deprecated - public void getCloudSyncOptInDone(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getCloudSyncOptInDone"); - } - - @Override - public void setCloudSyncSetting(IWearableCallbacks callbacks, boolean enable) throws RemoteException { - Log.d(TAG, "unimplemented Method: setCloudSyncSetting"); - } - - @Override - public void getCloudSyncSetting(IWearableCallbacks callbacks) throws RemoteException { - callbacks.onGetCloudSyncSettingResponse(new GetCloudSyncSettingResponse(0, false)); - } - - @Override - public void getCloudSyncOptInStatus(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getCloudSyncOptInStatus"); - } - - @Override - public void sendRemoteCommand(IWearableCallbacks callbacks, byte b) throws RemoteException { - Log.d(TAG, "unimplemented Method: sendRemoteCommand: " + b); - } - - @Override - public void getLocalNode(IWearableCallbacks callbacks) throws RemoteException { - postMain(callbacks, () -> { - try { - callbacks.onGetLocalNodeResponse(new GetLocalNodeResponse(0, new NodeParcelable(wearable.getLocalNodeId(), wearable.getLocalNodeId()))); - } catch (Exception e) { - callbacks.onGetLocalNodeResponse(new GetLocalNodeResponse(8, null)); - } - }); - } - - @Override - public void getConnectedNodes(IWearableCallbacks callbacks) throws RemoteException { - postMain(callbacks, () -> { - callbacks.onGetConnectedNodesResponse(new GetConnectedNodesResponse(0, wearable.getConnectedNodesParcelableList())); - }); - } - - /* - * Capability - */ - - @Override - public void getConnectedCapability(IWearableCallbacks callbacks, String capability, int nodeFilter) throws RemoteException { - Log.d(TAG, "unimplemented Method: getConnectedCapability " + capability + ", " + nodeFilter); - postMain(callbacks, () -> { - List nodes = new ArrayList<>(); - for (String host : capabilities.getNodesForCapability(capability)) { - nodes.add(new NodeParcelable(host, host)); - } - CapabilityInfoParcelable capabilityInfo = new CapabilityInfoParcelable(capability, nodes); - callbacks.onGetCapabilityResponse(new GetCapabilityResponse(0, capabilityInfo)); - }); - } - - @Override - public void getConnectedCapaibilties(IWearableCallbacks callbacks, int nodeFilter) throws RemoteException { - Log.d(TAG, "unimplemented Method: getConnectedCapaibilties: " + nodeFilter); - } - - @Override - public void addLocalCapability(IWearableCallbacks callbacks, String capability) throws RemoteException { - Log.d(TAG, "unimplemented Method: addLocalCapability: " + capability); - this.wearable.networkHandler.post(new CallbackRunnable(callbacks) { - @Override - public void run(IWearableCallbacks callbacks) throws RemoteException { - callbacks.onAddLocalCapabilityResponse(new AddLocalCapabilityResponse(capabilities.add(capability))); - } - }); - } - - @Override - public void removeLocalCapability(IWearableCallbacks callbacks, String capability) throws RemoteException { - Log.d(TAG, "unimplemented Method: removeLocalCapability: " + capability); - this.wearable.networkHandler.post(new CallbackRunnable(callbacks) { - @Override - public void run(IWearableCallbacks callbacks) throws RemoteException { - callbacks.onRemoveLocalCapabilityResponse(new RemoveLocalCapabilityResponse(capabilities.remove(capability))); - } - }); - } - - @Override - public void addListener(IWearableCallbacks callbacks, AddListenerRequest request) throws RemoteException { - if (request.listener != null) { - wearable.addListener(packageName, request.listener, request.intentFilters); - } - callbacks.onStatus(Status.SUCCESS); - } - - @Override - public void removeListener(IWearableCallbacks callbacks, RemoveListenerRequest request) throws RemoteException { - wearable.removeListener(request.listener); - callbacks.onStatus(Status.SUCCESS); - } - - @Override - public void getStorageInformation(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: getStorageInformation"); - } - - @Override - public void clearStorage(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: clearStorage"); - } - - @Override - public void endCall(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: endCall"); - } - - @Override - public void acceptRingingCall(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: acceptRingingCall"); - } - - @Override - public void silenceRinger(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: silenceRinger"); - } - - /* - * Apple Notification Center Service - */ - - @Override - public void injectAncsNotificationForTesting(IWearableCallbacks callbacks, AncsNotificationParcelable notification) throws RemoteException { - Log.d(TAG, "unimplemented Method: injectAncsNotificationForTesting: " + notification); - } - - @Override - public void doAncsPositiveAction(IWearableCallbacks callbacks, int i) throws RemoteException { - Log.d(TAG, "unimplemented Method: doAncsPositiveAction: " + i); - } - - @Override - public void doAncsNegativeAction(IWearableCallbacks callbacks, int i) throws RemoteException { - Log.d(TAG, "unimplemented Method: doAncsNegativeAction: " + i); - } - - @Override - public void openChannel(IWearableCallbacks callbacks, String s1, String s2) throws RemoteException { - Log.d(TAG, "unimplemented Method: openChannel; " + s1 + ", " + s2); - } - - /* - * Channels - */ - - @Override - public void closeChannel(IWearableCallbacks callbacks, String s) throws RemoteException { - Log.d(TAG, "unimplemented Method: closeChannel: " + s); - } - - @Override - public void closeChannelWithError(IWearableCallbacks callbacks, String s, int errorCode) throws RemoteException { - Log.d(TAG, "unimplemented Method: closeChannelWithError:" + s + ", " + errorCode); - - } - - @Override - public void getChannelInputStream(IWearableCallbacks callbacks, IChannelStreamCallbacks channelCallbacks, String s) throws RemoteException { - Log.d(TAG, "unimplemented Method: getChannelInputStream: " + s); - } - - @Override - public void getChannelOutputStream(IWearableCallbacks callbacks, IChannelStreamCallbacks channelCallbacks, String s) throws RemoteException { - Log.d(TAG, "unimplemented Method: getChannelOutputStream: " + s); - } - - @Override - public void writeChannelInputToFd(IWearableCallbacks callbacks, String s, ParcelFileDescriptor fd) throws RemoteException { - Log.d(TAG, "unimplemented Method: writeChannelInputToFd: " + s); - } - - @Override - public void readChannelOutputFromFd(IWearableCallbacks callbacks, String s, ParcelFileDescriptor fd, long l1, long l2) throws RemoteException { - Log.d(TAG, "unimplemented Method: readChannelOutputFromFd: " + s + ", " + l1 + ", " + l2); - } - - @Override - public void syncWifiCredentials(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "unimplemented Method: syncWifiCredentials"); - } - - /* - * Connection deprecated - */ - - @Override - @Deprecated - public void putConnection(IWearableCallbacks callbacks, ConnectionConfiguration config) throws RemoteException { - Log.d(TAG, "unimplemented Method: putConnection"); - } - - @Override - @Deprecated - public void getConnection(IWearableCallbacks callbacks) throws RemoteException { - Log.d(TAG, "getConfig"); - postMain(callbacks, () -> { - ConnectionConfiguration[] configurations = wearable.getConfigurations(); - if (configurations == null || configurations.length == 0) { - callbacks.onGetConfigResponse(new GetConfigResponse(1, new ConnectionConfiguration(null, null, 0, 0, false))); - } else { - callbacks.onGetConfigResponse(new GetConfigResponse(0, configurations[0])); - } - }); - } - - @Override - @Deprecated - public void enableConnection(IWearableCallbacks callbacks) throws RemoteException { - postMain(callbacks, () -> { - ConnectionConfiguration[] configurations = wearable.getConfigurations(); - if (configurations.length > 0) { - enableConfig(callbacks, configurations[0].name); - } - }); - } - - @Override - @Deprecated - public void disableConnection(IWearableCallbacks callbacks) throws RemoteException { - postMain(callbacks, () -> { - ConnectionConfiguration[] configurations = wearable.getConfigurations(); - if (configurations.length > 0) { - disableConfig(callbacks, configurations[0].name); - } - }); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } - - public abstract class CallbackRunnable implements Runnable { - private IWearableCallbacks callbacks; - - public CallbackRunnable(IWearableCallbacks callbacks) { - this.callbacks = callbacks; - } - - @Override - public void run() { - try { - run(callbacks); - } catch (RemoteException e) { - mainHandler.post(() -> { - try { - callbacks.onStatus(Status.CANCELED); - } catch (RemoteException e2) { - Log.w(TAG, e); - } - }); - } - } - - public abstract void run(IWearableCallbacks callbacks) throws RemoteException; - } - - public interface RemoteExceptionRunnable { - void run() throws RemoteException; - } -} diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/location/WearableLocationService.java b/play-services-core/src/main/java/org/microg/gms/wearable/location/WearableLocationService.java deleted file mode 100644 index 2757f0db..00000000 --- a/play-services-core/src/main/java/org/microg/gms/wearable/location/WearableLocationService.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable.location; - -import android.content.Context; -import android.util.Log; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.internal.ClientIdentity; -import com.google.android.gms.location.internal.LocationRequestInternal; -import com.google.android.gms.wearable.DataMap; -import com.google.android.gms.wearable.MessageEvent; -import com.google.android.gms.wearable.Node; -import com.google.android.gms.wearable.Wearable; -import com.google.android.gms.wearable.WearableListenerService; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class WearableLocationService extends WearableListenerService { - private static final String TAG = "GmsWearLocSvc"; - - public static final String PATH_LOCATION_REQUESTS = "com/google/android/location/fused/wearable/LOCATION_REQUESTS"; - public static final String PATH_CAPABILITY_QUERY = "com/google/android/location/fused/wearable/CAPABILITY_QUERY"; - public static final String PATH_CAPABILITY = "com/google/android/location/fused/wearable/CAPABILITY"; - - private GoogleApiClient apiClient; - private Map> requestMap = new HashMap>(); - - @Override - public void onMessageReceived(MessageEvent messageEvent) { - if (messageEvent.getPath().equals(PATH_LOCATION_REQUESTS)) { - DataMap dataMap = DataMap.fromByteArray(messageEvent.getData()); - onLocationRequests(messageEvent.getSourceNodeId(), readLocationRequestList(dataMap, this), dataMap.getBoolean("TRIGGER_UPDATE", false)); - } else if (messageEvent.getPath().equals(PATH_CAPABILITY_QUERY)) { - onCapabilityQuery(messageEvent.getSourceNodeId()); - } - } - - @Override - public void onPeerDisconnected(Node peer) { - onLocationRequests(peer.getId(), null, false); - } - - public void onLocationRequests(String nodeId, Collection requests, boolean triggerUpdate) { - if (requests == null || requests.isEmpty()) { - requestMap.remove(nodeId); - } else { - requestMap.put(nodeId, requests); - } - Log.d(TAG, "Requests: "+requestMap.entrySet()); - // TODO actually request - } - - public void onCapabilityQuery(String nodeId) { - Wearable.MessageApi.sendMessage(getApiClient(), nodeId, PATH_CAPABILITY, writeLocationCapability(new DataMap(), true).toByteArray()); - } - - private GoogleApiClient getApiClient() { - if (apiClient == null) { - apiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build(); - } - if (!apiClient.isConnected()) { - apiClient.connect(); - } - return apiClient; - } - - public static DataMap writeLocationCapability(DataMap dataMap, boolean locationCapable) { - dataMap.putBoolean("CAPABILITY_LOCATION", locationCapable); - return dataMap; - } - - public static Collection readLocationRequestList(DataMap dataMap, Context context) { - if (!dataMap.containsKey("REQUEST_LIST")) { - Log.w(TAG, "malformed DataMap: missing key REQUEST_LIST"); - return Collections.emptyList(); - } - List requestMapList = dataMap.getDataMapArrayList("REQUEST_LIST"); - List locationRequests = new ArrayList(); - for (DataMap map : requestMapList) { - locationRequests.add(readLocationRequest(map, context)); - } - return locationRequests; - } - - private static LocationRequestInternal readLocationRequest(DataMap dataMap, Context context) { - LocationRequestInternal request = new LocationRequestInternal(); - request.triggerUpdate = true; - request.request = new LocationRequest(); - request.clients = Collections.emptyList(); - - if (dataMap.containsKey("PRIORITY")) - request.request.setPriority(dataMap.getInt("PRIORITY", 0)); - if (dataMap.containsKey("INTERVAL_MS")) - request.request.setInterval(dataMap.getLong("INTERVAL_MS", 0)); - if (dataMap.containsKey("FASTEST_INTERVAL_MS")) - request.request.setFastestInterval(dataMap.getLong("FASTEST_INTERVAL_MS", 0)); - //if (dataMap.containsKey("MAX_WAIT_TIME_MS")) - if (dataMap.containsKey("SMALLEST_DISPLACEMENT_METERS")) - request.request.setSmallestDisplacement(dataMap.getFloat("SMALLEST_DISPLACEMENT_METERS", 0)); - if (dataMap.containsKey("NUM_UPDATES")) - request.request.setNumUpdates(dataMap.getInt("NUM_UPDATES", 0)); - if (dataMap.containsKey("EXPIRATION_DURATION_MS")) - request.request.setExpirationDuration(dataMap.getLong("EXPIRATION_DURATION_MS", 0)); - if (dataMap.containsKey("TAG")) - request.tag = dataMap.getString("TAG"); - if (dataMap.containsKey("CLIENTS_PACKAGE_ARRAY")) { - String[] packages = dataMap.getStringArray("CLIENTS_PACKAGE_ARRAY"); - if (packages != null) { - request.clients = new ArrayList(); - for (String packageName : packages) { - request.clients.add(generateClientIdentity(packageName, context)); - } - } - } - - return request; - } - - private static ClientIdentity generateClientIdentity(String packageName, Context context) { - return null; - /*try { - return new ClientIdentity(context.getPackageManager().getApplicationInfo(packageName, 0).uid, packageName); - } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "Unknown client identity: " + packageName, e); - return new ClientIdentity(context.getApplicationInfo().uid, context.getPackageName()); - }*/ - } -} diff --git a/play-services-location-api/build.gradle b/play-services-location-api/build.gradle deleted file mode 100644 index 7d1eb81f..00000000 --- a/play-services-location-api/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013-2015 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.library' - -android { - compileSdkVersion androidCompileSdk - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName version - minSdkVersion androidMinSdk - targetSdkVersion androidTargetSdk - } - - compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - } -} - -dependencies { - api project(':play-services-basement') -} diff --git a/play-services-location-api/gradle.properties b/play-services-location-api/gradle.properties deleted file mode 100644 index de0a3085..00000000 --- a/play-services-location-api/gradle.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2013-2016 microG Project Team -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Play Services Internal Location API -POM_DESCRIPTION=Interfaces and objects for IPC between Play Services Library and Play Services Core - -POM_PACKAGING=aar - -POM_URL=https://github.com/microg/android_external_GmsApi - -POM_SCM_URL=https://github.com/microg/android_external_GmsApi -POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git - -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=mar-v-in -POM_DEVELOPER_NAME=Marvin W - diff --git a/play-services-location-api/src/main/AndroidManifest.xml b/play-services-location-api/src/main/AndroidManifest.xml deleted file mode 100644 index 4a97d616..00000000 --- a/play-services-location-api/src/main/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/ActivityRecognitionResult.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/ActivityRecognitionResult.aidl deleted file mode 100644 index 52b4c775..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/ActivityRecognitionResult.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable ActivityRecognitionResult; \ No newline at end of file diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/GeofencingRequest.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/GeofencingRequest.aidl deleted file mode 100644 index d88a3ac8..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/GeofencingRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable GeofencingRequest; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/GestureRequest.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/GestureRequest.aidl deleted file mode 100644 index 9fffa77a..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/GestureRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable GestureRequest; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/ILocationCallback.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/ILocationCallback.aidl deleted file mode 100644 index bbccd355..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/ILocationCallback.aidl +++ /dev/null @@ -1,11 +0,0 @@ -package com.google.android.gms.location; - -import android.location.Location; - -import com.google.android.gms.location.LocationAvailability; -import com.google.android.gms.location.LocationResult; - -interface ILocationCallback { - void onLocationResult(in LocationResult result) = 0; - void onLocationAvailability(in LocationAvailability availability) = 1; -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/ILocationListener.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/ILocationListener.aidl deleted file mode 100644 index 323f9059..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/ILocationListener.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.location; - -import android.location.Location; - -interface ILocationListener { - void onLocationChanged(in Location location); -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationAvailability.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationAvailability.aidl deleted file mode 100644 index 8037232b..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationAvailability.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable LocationAvailability; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationRequest.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationRequest.aidl deleted file mode 100644 index 915aa2ae..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable LocationRequest; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationResult.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationResult.aidl deleted file mode 100644 index d79917b7..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationResult.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable LocationResult; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationSettingsRequest.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationSettingsRequest.aidl deleted file mode 100644 index 2552ed66..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationSettingsRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable LocationSettingsRequest; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationSettingsResult.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationSettingsResult.aidl deleted file mode 100644 index 54dad656..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationSettingsResult.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable LocationSettingsResult; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationStatus.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationStatus.aidl deleted file mode 100644 index 398d9c18..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/LocationStatus.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location; - -parcelable LocationStatus; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/FusedLocationProviderResult.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/FusedLocationProviderResult.aidl deleted file mode 100644 index 37a17787..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/FusedLocationProviderResult.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.internal; - -parcelable FusedLocationProviderResult; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IFusedLocationProviderCallback.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IFusedLocationProviderCallback.aidl deleted file mode 100644 index c0560fe5..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IFusedLocationProviderCallback.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.location.internal; - -import com.google.android.gms.location.internal.FusedLocationProviderResult; - -interface IFusedLocationProviderCallback { - void onFusedLocationProviderResult(in FusedLocationProviderResult result) = 0; -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IGeofencerCallbacks.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IGeofencerCallbacks.aidl deleted file mode 100644 index ac3950f5..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IGeofencerCallbacks.aidl +++ /dev/null @@ -1,9 +0,0 @@ -package com.google.android.gms.location.internal; - -import android.app.PendingIntent; - -interface IGeofencerCallbacks { - void onAddGeofenceResult(int statusCode, in String[] requestIds) = 0; - void onRemoveGeofencesByRequestIdsResult(int statusCode, in String[] requestIds) = 1; - void onRemoveGeofencesByPendingIntentResult(int statusCode, in PendingIntent pendingIntent) = 2; -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IGoogleLocationManagerService.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IGoogleLocationManagerService.aidl deleted file mode 100644 index 8e78a899..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/IGoogleLocationManagerService.aidl +++ /dev/null @@ -1,88 +0,0 @@ -package com.google.android.gms.location.internal; - -import android.app.PendingIntent; -import android.location.Location; -import android.os.Bundle; - -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.places.AutocompleteFilter; -import com.google.android.gms.location.places.internal.IPlacesCallbacks; -import com.google.android.gms.location.internal.ISettingsCallbacks; -import com.google.android.gms.location.internal.LocationRequestInternal; -import com.google.android.gms.location.internal.LocationRequestUpdateData; -import com.google.android.gms.location.internal.ParcelableGeofence; -import com.google.android.gms.location.places.NearbyAlertRequest; -import com.google.android.gms.location.places.PlaceFilter; -import com.google.android.gms.location.places.PlaceRequest; -import com.google.android.gms.location.places.PlaceReport; -import com.google.android.gms.location.places.internal.PlacesParams; -import com.google.android.gms.location.places.UserAddedPlace; -import com.google.android.gms.location.places.UserDataType; -import com.google.android.gms.location.ActivityRecognitionResult; -import com.google.android.gms.location.GeofencingRequest; -import com.google.android.gms.location.GestureRequest; -import com.google.android.gms.location.LocationAvailability; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.LocationSettingsRequest; -import com.google.android.gms.location.LocationStatus; -import com.google.android.gms.location.internal.IGeofencerCallbacks; -import com.google.android.gms.location.ILocationListener; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -interface IGoogleLocationManagerService { - void addGeofencesList(in List geofences, in PendingIntent pendingIntent, IGeofencerCallbacks callbacks, String packageName) = 0; - void addGeofences(in GeofencingRequest geofencingRequest, in PendingIntent pendingIntent, IGeofencerCallbacks callbacks) = 56; - void removeGeofencesByIntent(in PendingIntent pendingIntent, IGeofencerCallbacks callbacks, String packageName) = 1; - void removeGeofencesById(in String[] geofenceRequestIds, IGeofencerCallbacks callbacks, String packageName) = 2; - void removeAllGeofences(IGeofencerCallbacks callbacks, String packageName) = 3; - - void requestActivityUpdates(long detectionIntervalMillis, boolean alwaysTrue, in PendingIntent callbackIntent) = 4; - void removeActivityUpdates(in PendingIntent callbackIntent) = 5; - ActivityRecognitionResult getLastActivity(String packageName) = 63; - Status iglms65(in PendingIntent pendingIntent) = 64; - Status iglms66(in PendingIntent pendingIntent) = 65; - - Status requestGestureUpdates(in GestureRequest request, in PendingIntent pendingIntent) = 59; - Status iglms61(in PendingIntent pendingIntent) = 60; - - Location getLastLocation() = 6; - void requestLocationUpdatesWithListener(in LocationRequest request, ILocationListener listener) = 7; - void requestLocationUpdatesWithPackage(in LocationRequest request, ILocationListener listener, String packageName) = 19; - void requestLocationUpdatesWithIntent(in LocationRequest request, in PendingIntent callbackIntent) = 8; - void requestLocationUpdatesInternalWithListener(in LocationRequestInternal request, ILocationListener listener) = 51; - void requestLocationUpdatesInternalWithIntent(in LocationRequestInternal request, in PendingIntent callbackIntent) = 52; - void removeLocationUpdatesWithListener(ILocationListener listener) = 9; - void removeLocationUpdatesWithIntent(in PendingIntent callbackIntent) = 10; - void updateLocationRequest(in LocationRequestUpdateData locationRequestUpdateData) = 58; - //void flushLocations(IFusedLocationProviderCallback callback = 66; - - void setMockMode(boolean mockMode) = 11; - void setMockLocation(in Location mockLocation) = 12; - - Location getLastLocationWithPackage(String packageName) = 20; - void iglms26(in Location var1, int var2) = 25; - LocationAvailability getLocationAvailabilityWithPackage(String packageName) = 33; - - IBinder iglms51() = 50; - void requestLocationSettingsDialog(in LocationSettingsRequest settingsRequest, ISettingsCallbacks callback, String packageName) = 62; - - void iglms14(in LatLngBounds var1, int var2, in PlaceFilter var3, in PlacesParams var4, IPlacesCallbacks var5) = 13; - void iglms15(String var1, in PlacesParams var2, IPlacesCallbacks var3) = 14; - void iglms16(in LatLng var1, in PlaceFilter var2, in PlacesParams var3, IPlacesCallbacks var4) = 15; - void iglms17(in PlaceFilter var1, in PlacesParams var2, IPlacesCallbacks var3) = 16; - void iglms18(in PlaceRequest var1, in PlacesParams var2, in PendingIntent var3) = 17; - void iglms19(in PlacesParams var1, in PendingIntent var2) = 18; - void iglms25(in PlaceReport var1, in PlacesParams var2) = 24; - void iglms42(String var1, in PlacesParams var2, IPlacesCallbacks var3) = 41; - void iglms46(in UserAddedPlace var1, in PlacesParams var2, IPlacesCallbacks var3) = 45; - void iglms47(in LatLngBounds var1, int var2, String var3, in PlaceFilter var4, in PlacesParams var5, IPlacesCallbacks var6) = 46; - void iglms48(in NearbyAlertRequest var1, in PlacesParams var2, in PendingIntent var3) = 47; - void iglms49(in PlacesParams var1, in PendingIntent var2) = 48; - void iglms50(in UserDataType var1, in LatLngBounds var2, in List var3, in PlacesParams var4, IPlacesCallbacks var5) = 49; - IBinder iglms54() = 53; - void iglms55(String var1, in LatLngBounds var2, in AutocompleteFilter var3, in PlacesParams var4, IPlacesCallbacks var5) = 54; - void iglms58(in List var1, in PlacesParams var2, IPlacesCallbacks var3) = 57; - - //void updateDeviceOrientationRequest(in DeviceOrientationRequestUpdateData request) = 74; -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallbacks.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallbacks.aidl deleted file mode 100644 index f710d11f..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/ISettingsCallbacks.aidl +++ /dev/null @@ -1,7 +0,0 @@ -package com.google.android.gms.location.internal; - -import com.google.android.gms.location.LocationSettingsResult; - -interface ISettingsCallbacks { - void onLocationSettingsResult(in LocationSettingsResult result); -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/LocationRequestInternal.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/LocationRequestInternal.aidl deleted file mode 100644 index 4604714a..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/LocationRequestInternal.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.internal; - -parcelable LocationRequestInternal; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/LocationRequestUpdateData.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/LocationRequestUpdateData.aidl deleted file mode 100644 index 812f2ca5..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/LocationRequestUpdateData.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.internal; - -parcelable LocationRequestUpdateData; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/ParcelableGeofence.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/ParcelableGeofence.aidl deleted file mode 100644 index d4d69547..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/internal/ParcelableGeofence.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.internal; - -parcelable ParcelableGeofence; \ No newline at end of file diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/AutocompleteFilter.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/AutocompleteFilter.aidl deleted file mode 100644 index 10b7539c..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/AutocompleteFilter.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places; - -parcelable AutocompleteFilter; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/NearbyAlertRequest.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/NearbyAlertRequest.aidl deleted file mode 100644 index b34605c8..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/NearbyAlertRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places; - -parcelable NearbyAlertRequest; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceFilter.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceFilter.aidl deleted file mode 100644 index 07a4eec6..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceFilter.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places; - -parcelable PlaceFilter; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceReport.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceReport.aidl deleted file mode 100644 index 993899de..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceReport.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places; - -parcelable PlaceReport; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceRequest.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceRequest.aidl deleted file mode 100644 index 8de920ef..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/PlaceRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places; - -parcelable PlaceRequest; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/UserAddedPlace.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/UserAddedPlace.aidl deleted file mode 100644 index aa543a60..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/UserAddedPlace.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places; - -parcelable UserAddedPlace; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/UserDataType.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/UserDataType.aidl deleted file mode 100644 index 503493a3..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/UserDataType.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places; - -parcelable UserDataType; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/internal/IPlacesCallbacks.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/internal/IPlacesCallbacks.aidl deleted file mode 100644 index 6e912606..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/internal/IPlacesCallbacks.aidl +++ /dev/null @@ -1,9 +0,0 @@ -package com.google.android.gms.location.places.internal; - -import com.google.android.gms.common.data.DataHolder; - -interface IPlacesCallbacks { - void X(in DataHolder dataHolder); - void Y(in DataHolder dataHolder); - void Z(in DataHolder dataHolder); -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/internal/PlacesParams.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/internal/PlacesParams.aidl deleted file mode 100644 index fa569540..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/places/internal/PlacesParams.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.places.internal; - -parcelable PlacesParams; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/ReportingState.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/ReportingState.aidl deleted file mode 100644 index 4b1bf63c..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/ReportingState.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.reporting; - -parcelable ReportingState; \ No newline at end of file diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/UploadRequest.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/UploadRequest.aidl deleted file mode 100644 index 69547d7e..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/UploadRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.reporting; - -parcelable UploadRequest; \ No newline at end of file diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/UploadRequestResult.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/UploadRequestResult.aidl deleted file mode 100644 index cf3ec3be..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/UploadRequestResult.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.location.reporting; - -parcelable UploadRequestResult; \ No newline at end of file diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/internal/IReportingService.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/internal/IReportingService.aidl deleted file mode 100644 index 715b6779..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/location/reporting/internal/IReportingService.aidl +++ /dev/null @@ -1,15 +0,0 @@ -package com.google.android.gms.location.reporting.internal; - -import android.accounts.Account; -import com.google.android.gms.location.places.PlaceReport; -import com.google.android.gms.location.reporting.ReportingState; -import com.google.android.gms.location.reporting.UploadRequest; -import com.google.android.gms.location.reporting.UploadRequestResult; - -interface IReportingService { - ReportingState getReportingState(in Account account) = 0; - int tryOptIn(in Account account) = 1; - UploadRequestResult requestUpload(in UploadRequest request) = 2; - int cancelUploadRequest(long l) = 3; - int reportDeviceAtPlace(in Account account, in PlaceReport report) = 4; -} diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/maps/model/LatLng.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/maps/model/LatLng.aidl deleted file mode 100644 index 42df9312..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/maps/model/LatLng.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable LatLng; diff --git a/play-services-location-api/src/main/aidl/com/google/android/gms/maps/model/LatLngBounds.aidl b/play-services-location-api/src/main/aidl/com/google/android/gms/maps/model/LatLngBounds.aidl deleted file mode 100644 index 70538794..00000000 --- a/play-services-location-api/src/main/aidl/com/google/android/gms/maps/model/LatLngBounds.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.maps.model; - -parcelable LatLngBounds; \ No newline at end of file diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/ActivityRecognitionResult.java b/play-services-location-api/src/main/java/com/google/android/gms/location/ActivityRecognitionResult.java deleted file mode 100644 index 614c8552..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/ActivityRecognitionResult.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.content.Intent; -import android.os.Bundle; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParcelUtil; -import org.microg.safeparcel.SafeParceled; - -import java.util.Collections; -import java.util.List; - -/** - * Result of an activity recognition. - *

- * It contains a list of activities that a user may have been doing at a particular time. The - * activities are sorted by the most probable activity first. A confidence is associated with each - * activity which indicates how likely that activity is. - *

- * {@link #getMostProbableActivity()} will return the most probable activity of the user at the time - * that activity recognition was run. - */ -@PublicApi -public class ActivityRecognitionResult extends AutoSafeParcelable { - - @PublicApi(exclude = true) - public static final String EXTRA_ACTIVITY_RESULT = "com.google.android.location.internal.EXTRA_ACTIVITY_RESULT"; - @PublicApi(exclude = true) - public static final String EXTRA_ACTIVITY_RESULT_LIST = "com.google.android.location.internal.EXTRA_ACTIVITY_RESULT_LIST"; - - @SafeParceled(1000) - private int versionCode = 2; - - @SafeParceled(value = 1, subClass = DetectedActivity.class) - private List probableActivities; - - @SafeParceled(2) - private long time; - - @SafeParceled(3) - private long elapsedRealtimeMillis; - - @SafeParceled(5) - private Bundle extras; - - /** - * Constructs an ActivityRecognitionResult. - * - * @param probableActivities the activities that where detected, sorted by confidence (most probable first). - * @param time the UTC time of this detection, in milliseconds since January 1, 1970. - * @param elapsedRealtimeMillis milliseconds since boot - */ - public ActivityRecognitionResult(List probableActivities, long time, long elapsedRealtimeMillis) { - this(probableActivities, time, elapsedRealtimeMillis, null); - } - - /** - * Constructs an ActivityRecognitionResult from a single activity. - * - * @param activity the most probable activity of the device. - * @param time the UTC time of this detection, in milliseconds since January 1, 1970. - * @param elapsedRealtimeMillis milliseconds since boot - */ - public ActivityRecognitionResult(DetectedActivity activity, long time, long elapsedRealtimeMillis) { - this(Collections.singletonList(activity), time, elapsedRealtimeMillis); - } - - private ActivityRecognitionResult(List probableActivities, long time, long elapsedRealtimeMillis, Bundle extras) { - if (probableActivities == null || probableActivities.isEmpty()) - throw new IllegalArgumentException("Must have at least 1 detected activity"); - if (time <= 0 || elapsedRealtimeMillis <= 0) - throw new IllegalArgumentException("Must set times"); - this.probableActivities = probableActivities; - this.time = time; - this.elapsedRealtimeMillis = elapsedRealtimeMillis; - this.extras = extras; - } - - /** - * Extracts the ActivityRecognitionResult from an Intent. - *

- * This is a utility function which extracts the ActivityRecognitionResult from the extras of - * an Intent that was sent from the activity detection service. - * - * @return an ActivityRecognitionResult, or {@code null} if the intent doesn't contain an - * ActivityRecognitionResult. - */ - public static ActivityRecognitionResult extractResult(Intent intent) { - if (intent.hasExtra(EXTRA_ACTIVITY_RESULT_LIST)) { - intent.setExtrasClassLoader(ActivityRecognitionResult.class.getClassLoader()); - List list = intent.getParcelableArrayListExtra(EXTRA_ACTIVITY_RESULT_LIST); - if (list != null && !list.isEmpty()) - return list.get(list.size() - 1); - } - if (intent.hasExtra(EXTRA_ACTIVITY_RESULT)) { - Bundle extras = intent.getExtras(); - extras.setClassLoader(ActivityRecognitionResult.class.getClassLoader()); - Object res = extras.get(EXTRA_ACTIVITY_RESULT); - if (res instanceof ActivityRecognitionResult) - return (ActivityRecognitionResult) res; - if (res instanceof byte[]) - return SafeParcelUtil.fromByteArray((byte[]) res, CREATOR); - } - return null; - } - - /** - * Returns the confidence of the given activity type. - */ - public int getActivityConfidence(int activityType) { - for (DetectedActivity activity : probableActivities) { - if (activity.getType() == activityType) - return activity.getConfidence(); - } - return 0; - } - - /** - * Returns the elapsed real time of this detection in milliseconds since boot, including time - * spent in sleep as obtained by SystemClock.elapsedRealtime(). - */ - public long getElapsedRealtimeMillis() { - return elapsedRealtimeMillis; - } - - /** - * Returns the most probable activity of the user. - */ - public DetectedActivity getMostProbableActivity() { - return probableActivities.get(0); - } - - /** - * Returns the list of activities that where detected with the confidence value associated with - * each activity. The activities are sorted by most probable activity first. - *

- * The sum of the confidences of all detected activities this method returns does not have to - * be <= 100 since some activities are not mutually exclusive (for example, you can be walking - * while in a bus) and some activities are hierarchical (ON_FOOT is a generalization of WALKING - * and RUNNING). - */ - public List getProbableActivities() { - return probableActivities; - } - - /** - * Returns the UTC time of this detection, in milliseconds since January 1, 1970. - */ - public long getTime() { - return time; - } - - /** - * Returns true if an Intent contains an ActivityRecognitionResult. - *

- * This is a utility function that can be called from inside an intent receiver to make sure - * the received intent is from activity recognition. - * - * @return true if the intent contains an ActivityRecognitionResult, false otherwise or the given intent is null - */ - public static boolean hasResult(Intent intent) { - if (intent == null) return false; - if (intent.hasExtra(EXTRA_ACTIVITY_RESULT)) return true; - intent.setExtrasClassLoader(ActivityRecognitionResult.class.getClassLoader()); - List list = intent.getParcelableArrayListExtra(EXTRA_ACTIVITY_RESULT_LIST); - return list != null && !list.isEmpty(); - } - - @Override - public String toString() { - return "ActivityRecognitionResult [probableActivities=" + probableActivities + ", timeMillis" + time + ", elapsedRealtimeMillis=" + elapsedRealtimeMillis + "]"; - } - - public static final Creator CREATOR = new AutoCreator(ActivityRecognitionResult.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/DetectedActivity.java b/play-services-location-api/src/main/java/com/google/android/gms/location/DetectedActivity.java deleted file mode 100644 index 4a75a4d2..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/DetectedActivity.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * The detected activity of the device with an an associated confidence. See ActivityRecognitionApi - * for details on how to obtain a DetectedActivity. - */ -@PublicApi -public class DetectedActivity extends AutoSafeParcelable { - - /** - * The device is in a vehicle, such as a car. - */ - public static final int IN_VEHICLE = 0; - - /** - * The device is on a bicycle. - */ - public static final int ON_BICYCLE = 1; - - /** - * The device is on a user who is walking or running. - */ - public static final int ON_FOOT = 2; - - /** - * The device is on a user who is running. This is a sub-activity of ON_FOOT. - */ - public static final int RUNNING = 8; - - /** - * The device is still (not moving). - */ - public static final int STILL = 3; - - /** - * The device angle relative to gravity changed significantly. This often occurs when a device - * is picked up from a desk or a user who is sitting stands up. - */ - public static final int TILTING = 5; - - /** - * Unable to detect the current activity. - */ - public static final int UNKNOWN = 4; - - /** - * The device is on a user who is walking. This is a sub-activity of ON_FOOT. - */ - public static final int WALKING = 7; - - @SafeParceled(1000) - private int versionCode = 1; - - @SafeParceled(1) - private int type; - - @SafeParceled(2) - private int confidence; - - private DetectedActivity() { - } - - - /** - * Constructs a DetectedActivity. - * - * @param activityType the activity that was detected. - * @param confidence value from 0 to 100 indicating how likely it is that the user is performing this activity. - */ - public DetectedActivity(int activityType, int confidence) { - this.type = activityType; - this.confidence = confidence; - } - - @PublicApi(exclude = true) - public DetectedActivity(int versionCode, int type, int confidence) { - this.versionCode = versionCode; - this.type = type; - this.confidence = confidence; - } - - /** - * Returns a value from 0 to 100 indicating the likelihood that the user is performing this - * activity. - *

- * The larger the value, the more consistent the data used to perform the classification is - * with the detected activity. - *

- * This value will be <= 100. It means that larger values indicate that it's likely that the - * detected activity is correct, while a value of <= 50 indicates that there may be another - * activity that is just as or more likely. - *

- * Multiple activities may have high confidence values. For example, the ON_FOOT may have a - * confidence of 100 while the RUNNING activity may have a confidence of 95. The sum of the - * confidences of all detected activities for a classification does not have to be <= 100 since - * some activities are not mutually exclusive (for example, you can be walking while in a bus) - * and some activities are hierarchical (ON_FOOT is a generalization of WALKING and RUNNING). - */ - public int getConfidence() { - return confidence; - } - - /** - * Returns the type of activity that was detected. - */ - public int getType() { - return type; - } - - @PublicApi(exclude = true) - public int getVersionCode() { - return versionCode; - } - - @Override - public String toString() { - return "DetectedActivity [type=" + typeToString(getType()) + ", confidence=" + getConfidence() + "]"; - } - - @PublicApi(exclude = true) - public static String typeToString(int type) { - switch (type) { - case 0: - return "IN_VEHICLE"; - case 1: - return "ON_BICYCLE"; - case 2: - return "ON_FOOT"; - case 3: - return "STILL"; - case 4: - return "UNKNOWN"; - case 5: - return "TILTING"; - case 6: - default: - return Integer.toString(type); - case 7: - return "WALKING"; - case 8: - return "RUNNING"; - } - } - - public static final Creator CREATOR = new AutoCreator(DetectedActivity.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/Geofence.java b/play-services-location-api/src/main/java/com/google/android/gms/location/Geofence.java deleted file mode 100644 index 194aed75..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/Geofence.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.os.SystemClock; - -import com.google.android.gms.location.internal.ParcelableGeofence; - -/** - * Represents a geographical region, also known as a geofence. Geofences can be monitored by - * geofencer service. And when the user crosses the boundary of a geofence, an alert will be - * generated. - */ -public interface Geofence { - int GEOFENCE_TRANSITION_DWELL = 4; - - /** - * The transition type indicating that the user enters the geofence(s). - */ - int GEOFENCE_TRANSITION_ENTER = 1; - - /** - * The transition type indicating that the user exits the geofence(s). - */ - int GEOFENCE_TRANSITION_EXIT = 2; - - /** - * Expiration value that indicates the geofence should never expire. - */ - long NEVER_EXPIRE = -1L; - - /** - * Returns the request ID of this geofence. The request ID is a string to identify this geofence - * inside your application. When two geofences with the same requestId are monitored, the new - * one will replace the old one regardless the geographical region these two geofences - * represent. - */ - String getRequestId(); - - /** - * A builder that builds {@link Geofence}. - */ - class Builder { - private int regionType = -1; - private double latitude; - private double longitude; - private float radius; - private long expirationTime = Long.MIN_VALUE; - private int loiteringDelay = -1; - private int notificationResponsiveness; - private String requestId; - private int transitionTypes; - - /** - * Creates a geofence object. - * - * @throws IllegalArgumentException if any parameters are not set or out of range - */ - public Geofence build() throws IllegalArgumentException { - if (requestId == null) { - throw new IllegalArgumentException("Request ID not set."); - } else if (transitionTypes == 0) { - throw new IllegalArgumentException("Transition types not set."); - } else if ((transitionTypes & GEOFENCE_TRANSITION_DWELL) > 0 && loiteringDelay < 0) { - throw new IllegalArgumentException("Non-negative loitering delay needs to be set when transition types include GEOFENCE_TRANSITION_DWELLING."); - } else if (expirationTime == Long.MIN_VALUE) { - throw new IllegalArgumentException("Expiration not set."); - } else if (regionType == -1) { - throw new IllegalArgumentException("Geofence region not set."); - } else if (notificationResponsiveness < 0) { - throw new IllegalArgumentException("Notification responsiveness should be nonnegative."); - } else { - return new ParcelableGeofence(requestId, expirationTime, regionType, latitude, longitude, radius, transitionTypes, notificationResponsiveness, loiteringDelay); - } - } - - /** - * Sets the region of this geofence. The geofence represents a circular area on a flat, horizontal plane. - * - * @param latitude latitude in degrees, between -90 and +90 inclusive - * @param longitude longitude in degrees, between -180 and +180 inclusive - * @param radius radius in meters - */ - public Builder setCircularRegion(double latitude, double longitude, float radius) { - this.regionType = 1; - this.latitude = latitude; - this.longitude = longitude; - this.radius = radius; - return this; - } - - /** - * Sets the expiration duration of geofence. This geofence will be removed automatically - * after this period of time. - * - * @param durationMillis time for this proximity alert, in milliseconds, or {@link #NEVER_EXPIRE} - * to indicate no expiration. When positive, this geofence will be - * removed automatically after this amount of time. - */ - public Builder setExpirationDuration(long durationMillis) { - if (durationMillis < 0) { - expirationTime = -1; - } else { - expirationTime = SystemClock.elapsedRealtime() + durationMillis; - } - return this; - } - - public Builder setLoiteringDelay(int loiteringDelayMs) { - this.loiteringDelay = loiteringDelayMs; - return this; - } - - /** - * Sets the best-effort notification responsiveness of the geofence. Defaults to 0. Setting - * a big responsiveness value, for example 5 minutes, can save power significantly. However, - * setting a very small responsiveness value, for example 5 seconds, doesn't necessarily - * mean you will get notified right after the user enters or exits a geofence: internally, - * the geofence might adjust the responsiveness value to save power when needed. - * - * @param notificationResponsivenessMs notificationResponsivenessMs (milliseconds) defines - * the best-effort description of how soon should the - * callback be called when the transition associated - * with the Geofence is triggered. For instance, if set - * to 300000 milliseconds the callback will be called 5 - * minutes within entering or exiting the geofence. - */ - public Builder setNotificationResponsiveness(int notificationResponsivenessMs) { - this.notificationResponsiveness = notificationResponsivenessMs; - return this; - } - - /** - * Sets the request ID of the geofence. Request ID is a string to identify this geofence - * inside your application. When two geofences with the same requestId are monitored, the - * new one will replace the old one regardless the geographical region these two geofences - * represent. - * - * @param requestId the request ID. The length of the string can be up to 100 characters. - */ - public Builder setRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - /** - * Sets the transition types of interest. Alerts are only generated for the given transition - * types. - * - * @param transitionTypes geofence transition types of interest, as a bitwise-OR of - * GEOFENCE_TRANSITION_ flags. - */ - public Builder setTransitionTypes(int transitionTypes) { - this.transitionTypes = transitionTypes; - return this; - } - } -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/GeofenceStatusCodes.java b/play-services-location-api/src/main/java/com/google/android/gms/location/GeofenceStatusCodes.java deleted file mode 100644 index 8733e4cb..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/GeofenceStatusCodes.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import com.google.android.gms.common.api.CommonStatusCodes; - -public class GeofenceStatusCodes extends CommonStatusCodes { - /** - * Geofence service is not available now. Typically this is because the user turned off - * location access in settings > location access. - */ - public static final int GEOFENCE_NOT_AVAILABLE = 1000; - - /** - * Your app has registered more than 100 geofences. Remove unused ones before adding new - * geofences. - */ - public static final int GEOFENCE_TOO_MANY_GEOFENCES = 1001; - - /** - * You have provided more than 5 different PendingIntents to the addGeofences(GoogleApiClient, - * GeofencingRequest, PendingIntent) call. - */ - public static final int GEOFENCE_TOO_MANY_PENDING_INTENTS = 1002; - - /** - * Returns an untranslated debug (not user-friendly!) string based on the current status code. - */ - public static String getStatusCodeString(int statusCode) { - switch (statusCode) { - case GEOFENCE_NOT_AVAILABLE: - return "GEOFENCE_NOT_AVAILABLE"; - case GEOFENCE_TOO_MANY_GEOFENCES: - return "GEOFENCE_TOO_MANY_GEOFENCES"; - case GEOFENCE_TOO_MANY_PENDING_INTENTS: - return "GEOFENCE_TOO_MANY_PENDING_INTENTS"; - default: - return CommonStatusCodes.getStatusCodeString(statusCode); - } - } -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/GeofencingEvent.java b/play-services-location-api/src/main/java/com/google/android/gms/location/GeofencingEvent.java deleted file mode 100644 index 82b3a107..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/GeofencingEvent.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.content.Intent; -import android.location.Location; - -import com.google.android.gms.location.internal.ParcelableGeofence; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.SafeParcelUtil; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents an event from the GeofencingApi API. The event can be - *

- * A geofence triggering event generated when a geofence transition happens. - * An error happens after geofences are registered and being monitored. - */ -@PublicApi -public class GeofencingEvent { - @PublicApi(exclude = true) - public static final String EXTRA_ERROR_CODE = "gms_error_code"; - @PublicApi(exclude = true) - public static final String EXTRA_TRIGGERING_LOCATION = "com.google.android.location.intent.extra.triggering_location"; - @PublicApi(exclude = true) - public static final String EXTRA_TRANSITION = "com.google.android.location.intent.extra.transition"; - @PublicApi(exclude = true) - public static final String EXTRA_GEOFENCE_LIST = "com.google.android.location.intent.extra.geofence_list"; - - private int errorCode; - private int geofenceTransition; - private List triggeringGeofences; - private Location triggeringLocation; - - /** - * Creates a {@link GeofencingEvent} object from the given intent. - * - * @param intent the intent to extract the geofencing event data from - * @return a {@link GeofencingEvent} object or {@code null} if the given intent is {@code null} - */ - public static GeofencingEvent fromIntent(Intent intent) { - if (intent == null) { - return null; - } - GeofencingEvent event = new GeofencingEvent(); - event.errorCode = intent.getIntExtra(EXTRA_ERROR_CODE, -1); - event.geofenceTransition = intent.getIntExtra(EXTRA_TRANSITION, -1); - if (event.geofenceTransition != 1 && event.geofenceTransition != 2 && event.geofenceTransition != 4) - event.geofenceTransition = -1; - ArrayList parceledGeofences = (ArrayList) intent.getSerializableExtra(EXTRA_GEOFENCE_LIST); - if (parceledGeofences != null) { - event.triggeringGeofences = new ArrayList(); - for (byte[] parceledGeofence : parceledGeofences) { - event.triggeringGeofences.add(SafeParcelUtil.fromByteArray(parceledGeofence, ParcelableGeofence.CREATOR)); - } - } - event.triggeringLocation = intent.getParcelableExtra(EXTRA_TRIGGERING_LOCATION); - return event; - } - - /** - * Returns the error code that explains the error that triggered the intent specified in - * {@link #fromIntent(Intent)}. - * - * @return the error code specified in {@link GeofenceStatusCodes} or {@code -1} if - * {@link #hasError()} returns false. - */ - public int getErrorCode() { - return errorCode; - } - - /** - * Returns the transition type of the geofence transition alert. - * - * @return -1 if the intent specified in {@link #fromIntent(Intent)} is not generated for a - * transition alert; Otherwise returns the GEOFENCE_TRANSITION_ flags value defined in - * {@link Geofence}. - */ - public int getGeofenceTransition() { - return geofenceTransition; - } - - - /** - * Returns a list of geofences that triggered this geofence transition alert. - * - * @return a list of geofences that triggered this geofence transition alert or {@code null} if - * the intent specified in {@link #fromIntent(Intent)} is not generated for a geofence - * transition alert - */ - public List getTriggeringGeofences() { - return triggeringGeofences; - } - - /** - * Gets the location that triggered the geofence transition. Triggering location is only - * available if the calling app links against Google Play services 5.0 SDK. - * - * @return the location that triggered this geofence alert or {@code null} if it's not included - * in the intent specified in {@link #fromIntent(Intent)} - */ - public Location getTriggeringLocation() { - return triggeringLocation; - } - - /** - * Whether an error triggered this intent. - * - * @return {@code true} if an error triggered the intent specified in - * {@link #fromIntent(Intent)}, otherwise {@code false} - */ - public boolean hasError() { - return errorCode != -1; - } -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/GeofencingRequest.java b/play-services-location-api/src/main/java/com/google/android/gms/location/GeofencingRequest.java deleted file mode 100644 index 2601d629..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/GeofencingRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import org.microg.safeparcel.AutoSafeParcelable; - -/** - * TODO: usage - */ -public class GeofencingRequest extends AutoSafeParcelable { - - public static final Creator CREATOR = new AutoCreator(GeofencingRequest.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/GestureRequest.java b/play-services-location-api/src/main/java/com/google/android/gms/location/GestureRequest.java deleted file mode 100644 index 5222b259..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/GestureRequest.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import org.microg.safeparcel.AutoSafeParcelable; - -public class GestureRequest extends AutoSafeParcelable { - public static final Creator CREATOR = new AutoCreator(GestureRequest.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationAvailability.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationAvailability.java deleted file mode 100644 index c24c5bbc..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationAvailability.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.content.Intent; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.Arrays; - -/** - * Status on the availability of location data. - *

- * Delivered from LocationCallback registered via FusedLocationProviderApi#requestLocationUpdates(GoogleApiClient, LocationRequest, LocationCallback, Looper) - * or from a PendingIntent registered via FusedLocationProviderApi#requestLocationUpdates(GoogleApiClient, LocationRequest, PendingIntent). - * It is also available on demand via FusedLocationProviderApi#getLocationAvailability(GoogleApiClient). - */ -@PublicApi -public class LocationAvailability extends AutoSafeParcelable { - private static final String EXTRA_KEY = "com.google.android.gms.location.EXTRA_LOCATION_AVAILABILITY"; - - @PublicApi(exclude = true) - public static final int STATUS_SUCCESSFUL = 0; - @PublicApi(exclude = true) - public static final int STATUS_UNKNOWN = 1; - @PublicApi(exclude = true) - public static final int STATUS_TIMED_OUT_ON_SCAN = 2; - @PublicApi(exclude = true) - public static final int STATUS_NO_INFO_IN_DATABASE = 3; - @PublicApi(exclude = true) - public static final int STATUS_INVALID_SCAN = 4; - @PublicApi(exclude = true) - public static final int STATUS_UNABLE_TO_QUERY_DATABASE = 5; - @PublicApi(exclude = true) - public static final int STATUS_SCANS_DISABLED_IN_SETTINGS = 6; - @PublicApi(exclude = true) - public static final int STATUS_LOCATION_DISABLED_IN_SETTINGS = 7; - @PublicApi(exclude = true) - public static final int STATUS_IN_PROGRESS = 8; - - @SafeParceled(1000) - private int versionCode = 2; - - @SafeParceled(1) - @PublicApi(exclude = true) - public int cellStatus; - - @SafeParceled(2) - @PublicApi(exclude = true) - public int wifiStatus; - - @SafeParceled(3) - @PublicApi(exclude = true) - public long elapsedRealtimeNs; - - @SafeParceled(4) - @PublicApi(exclude = true) - public int locationStatus; - - @PublicApi(exclude = true) - public LocationAvailability() { - } - - @Override - public boolean equals(Object o) { - if (o instanceof LocationAvailability) { - LocationAvailability other = (LocationAvailability) o; - return other.cellStatus == cellStatus && other.wifiStatus == wifiStatus && other.elapsedRealtimeNs == elapsedRealtimeNs && other.locationStatus == locationStatus; - } - return false; - } - - /** - * Extracts the {@link LocationAvailability} from an Intent. - *

- * This is a utility function which extracts the {@link LocationAvailability} from the extras - * of an Intent that was sent in response to a location request. - * - * @return a {@link LocationAvailability}, or null if the Intent doesn't contain this data. - */ - public static LocationAvailability extractLocationAvailability(Intent intent) { - if (!hasLocationAvailability(intent)) { - return null; - } - return intent.getParcelableExtra(EXTRA_KEY); - } - - /** - * Returns true if an Intent contains a {@link LocationAvailability}. - *

- * This is a utility function that can be called from inside an intent receiver to make sure the - * received intent contains location availability data. - * - * @return true if the intent contains a {@link LocationAvailability}, false otherwise. - */ - public static boolean hasLocationAvailability(Intent intent) { - return intent != null && intent.hasExtra(EXTRA_KEY); - } - - @Override - public int hashCode() { - return Arrays.hashCode(new Object[]{locationStatus, cellStatus, wifiStatus, elapsedRealtimeNs}); - } - - /** - * Returns true if the device location is known and reasonably up to date within the hints - * requested by the active {@link LocationRequest}s. Failure to determine location may result - * from a number of causes including disabled location settings or an inability to retrieve - * sensor data in the device's environment. - */ - public boolean isLocationAvailable() { - return locationStatus < 1000; - } - - @Override - public String toString() { - return "LocationAvailability[isLocationAvailable: " + isLocationAvailable() + "]"; - } - - public static final Creator CREATOR = new AutoCreator(LocationAvailability.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationRequest.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationRequest.java deleted file mode 100644 index 15d159e8..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationRequest.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.os.SystemClock; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.Arrays; - -/** - * A data object that contains quality of service parameters for requests to the - * FusedLocationProviderApi. - *

- * LocationRequest objects are used to request a quality of service for location updates from the - * FusedLocationProviderApi. - *

- * For example, if your application wants high accuracy location it should create a location - * request with {@link #setPriority(int)} set to {@link #PRIORITY_HIGH_ACCURACY} and - * {@link #setInterval(long)} to 5 seconds. This would be appropriate for mapping applications that - * are showing your location in real-time. - *

- * At the other extreme, if you want negligible power impact, but to still receive location updates - * when available, then create a location request with {@link #setPriority(int)} set to - * {@link #PRIORITY_NO_POWER}. With this request your application will not trigger (and therefore - * will not receive any power blame) any location updates, but will receive locations triggered by - * other applications. This would be appropriate for applications that have no firm requirement for - * location, but can take advantage when available. - *

- * In between these two extremes is a very common use-case, where applications definitely want to - * receive updates at a specified interval, and can receive them faster when available, but still - * want a low power impact. These applications should consider - * {@link #PRIORITY_BALANCED_POWER_ACCURACY} combined with a faster - * {@link #setFastestInterval(long)} (such as 1 minute) and a slower {@link #setInterval(long)} - * (such as 60 minutes). They will only be assigned power blame for the interval set by - * {@link #setInterval(long)}, but can still receive locations triggered by other applications at a - * rate up to {@link #setFastestInterval(long)}. This style of request is appropriate for many - * location aware applications, including background usage. Do be careful to also throttle - * {@link #setFastestInterval(long)} if you perform heavy-weight work after receiving an update - - * such as using the network. - *

- * Activities should strongly consider removing all location request when entering the background - * (for example at {@link android.app.Activity#onPause()}), or at least swap the request to a - * larger interval and lower quality. - *

- * Applications cannot specify the exact location sources, such as GPS, that are used by the - * LocationClient. In fact, the system may have multiple location sources (providers) running and - * may fuse the results from several sources into a single Location object. - *

- * Location requests from applications with - * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} and not - * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} will be automatically throttled to a - * slower interval, and the location object will be obfuscated to only show a coarse level of - * accuracy. - *

- * All location requests are considered hints, and you may receive locations that are more/less - * accurate, and faster/slower than requested. - */ -public class LocationRequest extends AutoSafeParcelable { - - /** - * Used with {@link #setPriority(int)} to request "block" level accuracy. - *

- * Block level accuracy is considered to be about 100 meter accuracy. Using a coarse accuracy - * such as this often consumes less power. - */ - public static final int PRIORITY_BALANCED_POWER_ACCURACY = 102; - /** - * Used with {@link #setPriority(int)} to request the most accurate locations available. - *

- * This will return the finest location available. - */ - public static final int PRIORITY_HIGH_ACCURACY = 100; - /** - * Used with {@link #setPriority(int)} to request "city" level accuracy. - *

- * City level accuracy is considered to be about 10km accuracy. Using a coarse accuracy such as - * this often consumes less power. - */ - public static final int PRIORITY_LOW_POWER = 104; - /** - * Used with {@link #setPriority(int)} to request the best accuracy possible with zero - * additional power consumption. - *

- * No locations will be returned unless a different client has requested location updates in - * which case this request will act as a passive listener to those locations. - */ - public static final int PRIORITY_NO_POWER = 105; - - @SafeParceled(1000) - private int versionCode = 1; - @SafeParceled(1) - private int priority; - @SafeParceled(2) - private long interval; - @SafeParceled(3) - private long fastestInterval; - @SafeParceled(4) - private boolean explicitFastestInterval; - @SafeParceled(5) - private long expirationTime; - @SafeParceled(6) - private int numUpdates; - @SafeParceled(7) - private float smallestDesplacement; - @SafeParceled(8) - private long maxWaitTime; - - public LocationRequest() { - this.priority = PRIORITY_BALANCED_POWER_ACCURACY; - this.interval = 3600000; - this.fastestInterval = 600000; - this.explicitFastestInterval = false; - this.expirationTime = Long.MAX_VALUE; - this.numUpdates = Integer.MAX_VALUE; - this.smallestDesplacement = 0; - this.maxWaitTime = 0; - } - - /** - * Create a location request with default parameters. - *

- * Default parameters are for a block accuracy, slowly updated location. It can then be - * adjusted as required by the applications before passing to the FusedLocationProviderApi. - * - * @return a new location request - */ - public static LocationRequest create() { - return new LocationRequest(); - } - - /** - * Get the request expiration time, in milliseconds since boot. - *

- * This value can be compared to {@link SystemClock#elapsedRealtime()} to determine - * the time until expiration. - * - * @return expiration time of request, in milliseconds since boot including suspend - */ - public long getExpirationTime() { - return expirationTime; - } - - /** - * Get the fastest interval of this request, in milliseconds. - *

- * The system will never provide location updates faster than the minimum of - * {@link #getFastestInterval()} and {@link #getInterval()}. - * - * @return fastest interval in milliseconds, exact - */ - public long getFastestInterval() { - return fastestInterval; - } - - /** - * Get the desired interval of this request, in milliseconds. - * - * @return desired interval in milliseconds, inexact - */ - public long getInterval() { - return interval; - } - - /** - * Get the number of updates requested. - *

- * By default this is {@link java.lang.Integer#MAX_VALUE}, which indicates that locations are - * updated until the request is explicitly removed. - * - * @return number of updates - */ - public int getNumUpdates() { - return numUpdates; - } - - /** - * Get the quality of the request. - * - * @return an accuracy constant - */ - public int getPriority() { - return priority; - } - - /** - * Get the minimum displacement between location updates in meters - *

- * By default this is 0. - * - * @return minimum displacement between location updates in meters - */ - public float getSmallestDesplacement() { - return smallestDesplacement; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - LocationRequest that = (LocationRequest) o; - - if (expirationTime != that.expirationTime) - return false; - if (explicitFastestInterval != that.explicitFastestInterval) - return false; - if (fastestInterval != that.fastestInterval) - return false; - if (interval != that.interval) - return false; - if (maxWaitTime != that.maxWaitTime) - return false; - if (numUpdates != that.numUpdates) - return false; - if (priority != that.priority) - return false; - if (Float.compare(that.smallestDesplacement, smallestDesplacement) != 0) - return false; - - return true; - } - - @Override - public int hashCode() { - return Arrays.hashCode( - new Object[] { priority, interval, fastestInterval, explicitFastestInterval, - explicitFastestInterval, numUpdates, smallestDesplacement, maxWaitTime - }); - } - - /** - * Set the duration of this request, in milliseconds. - *

- * The duration begins immediately (and not when the request is passed to the location client), - * so call this method again if the request is re-used at a later time. - *

- * The location client will automatically stop updates after the request expires. - *

- * The duration includes suspend time. Values less than 0 are allowed, but indicate that the - * request has already expired. - * - * @param millis duration of request in milliseconds - * @return the same object, so that setters can be chained - */ - public LocationRequest setExpirationDuration(long millis) { - expirationTime = SystemClock.elapsedRealtime() + millis; - return this; - } - - /** - * Set the request expiration time, in millisecond since boot. - *

- * This expiration time uses the same time base as {@link SystemClock#elapsedRealtime()}. - *

- * The location client will automatically stop updates after the request expires. - *

- * The duration includes suspend time. Values before {@link SystemClock#elapsedRealtime()} are - * allowed, but indicate that the request has already expired. - * - * @param millis expiration time of request, in milliseconds since boot including suspend - * @return the same object, so that setters can be chained - */ - public LocationRequest setExpirationTime(long millis) { - expirationTime = millis; - return this; - } - - /** - * Explicitly set the fastest interval for location updates, in milliseconds. - *

- * This controls the fastest rate at which your application will receive location updates, - * which might be faster than {@link #setInterval(long)} in some situations (for example, if - * other applications are triggering location updates). - *

- * This allows your application to passively acquire locations at a rate faster than it - * actively acquires locations, saving power. - *

- * Unlike {@link #setInterval(long)}, this parameter is exact. Your application will never - * receive updates faster than this value. - *

- * If you don't call this method, a fastest interval will be selected for you. It will be a - * value faster than your active interval ({@link #setInterval(long)}). - *

- * An interval of 0 is allowed, but not recommended, since location updates may be extremely - * fast on future implementations. - *

- * If {@link #setFastestInterval(long)} is set slower than {@link #setInterval(long)}, then - * your effective fastest interval is {@link #setInterval(long)}. - * - * @param millis fastest interval for updates in milliseconds, exact - * @return the same object, so that setters can be chained - * @throws IllegalArgumentException if the interval is less than zero - */ - public LocationRequest setFastestInterval(long millis) throws IllegalArgumentException { - if (millis < 0) - throw new IllegalArgumentException("interval must not be negative"); - fastestInterval = millis; - return this; - } - - /** - * Set the desired interval for active location updates, in milliseconds. - *

- * The location client will actively try to obtain location updates for your application at - * this interval, so it has a direct influence on the amount of power used by your application. - * Choose your interval wisely. - *

- * This interval is inexact. You may not receive updates at all (if no location sources are - * available), or you may receive them slower than requested. You may also receive them faster - * than requested (if other applications are requesting location at a faster interval). The - * fastest rate that that you will receive updates can be controlled with - * {@link #setFastestInterval(long)}. By default this fastest rate is 6x the interval frequency. - *

- * Applications with only the coarse location permission may have their interval silently - * throttled. - *

- * An interval of 0 is allowed, but not recommended, since location updates may be extremely - * fast on future implementations. - *

- * {@link #setPriority(int)} and {@link #setInterval(long)} are the most important parameters - * on a location request. - * - * @param millis desired interval in millisecond, inexact - * @return the same object, so that setters can be chained - * @throws IllegalArgumentException if the interval is less than zero - */ - public LocationRequest setInterval(long millis) throws IllegalArgumentException { - if (millis < 0) - throw new IllegalArgumentException("interval must not be negative"); - interval = millis; - return this; - } - - /** - * Set the number of location updates. - *

- * By default locations are continuously updated until the request is explicitly removed, - * however you can optionally request a set number of updates. For example, if your application - * only needs a single fresh location, then call this method with a value of 1 before passing - * the request to the location client. - *

- * When using this option care must be taken to either explicitly remove the request when no - * longer needed or to set an expiration with ({@link #setExpirationDuration(long)} or - * {@link #setExpirationTime(long)}. Otherwise in some cases if a location can't be computed, - * this request could stay active indefinitely consuming power. - * - * @param numUpdates the number of location updates requested - * @return the same object, so that setters can be chained - * @throws IllegalArgumentException if numUpdates is 0 or less - */ - public LocationRequest setNumUpdates(int numUpdates) throws IllegalArgumentException { - if (numUpdates <= 0) - throw new IllegalArgumentException("numUpdates must not be 0 or negative"); - this.numUpdates = numUpdates; - return this; - } - - /** - * Set the priority of the request. - *

- * Use with a priority constant such as {@link #PRIORITY_HIGH_ACCURACY}. No other values are - * accepted. - *

- * The priority of the request is a strong hint to the LocationClient for which location - * sources to use. For example, {@link #PRIORITY_HIGH_ACCURACY} is more likely to use GPS, and - * {@link #PRIORITY_BALANCED_POWER_ACCURACY} is more likely to use WIFI & Cell tower - * positioning, but it also depends on many other factors (such as which sources are available) - * and is implementation dependent. - *

- * {@link #setPriority(int)} and {@link #setInterval(long)} are the most important parameters - * on a location request. - * - * @param priority an accuracy or power constant - * @return the same object, so that setters can be chained - * @throws IllegalArgumentException if the quality constant is not valid - */ - public LocationRequest setPriority(int priority) { - switch (priority) { - default: - throw new IllegalArgumentException("priority is not a known constant"); - case PRIORITY_BALANCED_POWER_ACCURACY: - case PRIORITY_HIGH_ACCURACY: - case PRIORITY_LOW_POWER: - case PRIORITY_NO_POWER: - this.priority = priority; - } - return this; - } - - /** - * Set the minimum displacement between location updates in meters - *

- * By default this is 0. - * - * @param smallestDisplacementMeters the smallest displacement in meters the user must move - * between location updates. - * @return the same object, so that setters can be chained - * @throws IllegalArgumentException if smallestDisplacementMeters is negative - */ - public LocationRequest setSmallestDisplacement(float smallestDisplacementMeters) { - if (smallestDisplacementMeters < 0) - throw new IllegalArgumentException("smallestDisplacementMeters must not be negative"); - this.smallestDesplacement = smallestDisplacementMeters; - return this; - } - - @Override - public String toString() { - return "LocationRequest{" + - "priority=" + priority + - ", interval=" + interval + - ", fastestInterval=" + fastestInterval + - ", explicitFastestInterval=" + explicitFastestInterval + - ", expirationTime=" + expirationTime + - ", numUpdates=" + numUpdates + - ", smallestDesplacement=" + smallestDesplacement + - ", maxWaitTime=" + maxWaitTime + - '}'; - } - - public static final Creator CREATOR = new AutoCreator(LocationRequest.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationResult.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationResult.java deleted file mode 100644 index d09109fe..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationResult.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.location.Location; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.List; - -@PublicApi -public class LocationResult extends AutoSafeParcelable { - - @SafeParceled(1000) - private int versionCode = 2; - - @SafeParceled(value = 1, subClass = Location.class) - public final List locations; - - private LocationResult(List locations) { - this.locations = locations; - } - - public static LocationResult create(List locations) { - return new LocationResult(locations); - } - - public static final Creator CREATOR = new AutoCreator(LocationResult.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsRequest.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsRequest.java deleted file mode 100644 index 517ab1c8..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsRequest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -@PublicApi -public class LocationSettingsRequest extends AutoSafeParcelable { - @SafeParceled(1000) - private int versionCode = 2; - - @SafeParceled(value = 1, subClass = LocationRequest.class) - @PublicApi(exclude = true) - public List requests; - - @SafeParceled(2) - @PublicApi(exclude = true) - public boolean alwaysShow; - - @PublicApi(exclude = true) - public boolean needBle; - - private LocationSettingsRequest() { - } - - private LocationSettingsRequest(List requests, boolean alwaysShow, boolean needBle) { - this.requests = requests; - this.alwaysShow = alwaysShow; - this.needBle = needBle; - } - - /** - * A builder that builds {@link LocationSettingsRequest}. - */ - public static class Builder { - private List requests = new ArrayList(); - private boolean alwaysShow = false; - private boolean needBle = false; - - /** - * Adds a collection of {@link LocationRequest}s that the client is interested in. Settings - * will be checked for optimal performance of all {@link LocationRequest}s. - */ - public Builder addAllLocationRequests(Collection requests) { - this.requests.addAll(requests); - return this; - } - - /** - * Adds one {@link LocationRequest} that the client is interested in. Settings will be - * checked for optimal performance of all {@link LocationRequest}s. - */ - public Builder addLocationRequest(LocationRequest request) { - requests.add(request); - return this; - } - - /** - * Creates a LocationSettingsRequest that can be used with SettingsApi. - */ - public LocationSettingsRequest build() { - return new LocationSettingsRequest(requests, alwaysShow, needBle); - } - - /** - * Whether or not location is required by the calling app in order to continue. Set this to - * true if location is required to continue and false if having location provides better - * results, but is not required. This changes the wording/appearance of the dialog - * accordingly. - */ - public Builder setAlwaysShow(boolean show) { - alwaysShow = show; - return this; - } - - /** - * Sets whether the client wants BLE scan to be enabled. When this flag is set to true, if - * the platform supports BLE scan mode and Bluetooth is off, the dialog will prompt the - * user to enable BLE scan. If the platform doesn't support BLE scan mode, the dialog will - * prompt to enable Bluetooth. - */ - public Builder setNeedBle(boolean needBle) { - this.needBle = needBle; - return this; - } - } - - public static final Creator CREATOR = new AutoCreator(LocationSettingsRequest.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsResult.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsResult.java deleted file mode 100644 index 4269b429..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsResult.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * Result of checking settings via checkLocationSettings(GoogleApiClient, LocationSettingsRequest), - * indicates whether a dialog should be shown to ask the user's consent to change their settings. - * The method getStatus() can be be used to confirm if the request was successful. If the current - * location settings don't satisfy the app's requirements and the user has permission to change the - * settings, the app could use startResolutionForResult(Activity, int) to start an intent to show a - * dialog, asking for user's consent to change the settings. The current location settings states - * can be accessed via getLocationSettingsStates(). See LocationSettingsResult for more details. - */ -@PublicApi -public class LocationSettingsResult extends AutoSafeParcelable implements Result { - - @SafeParceled(1000) - private int versionCode = 1; - - @SafeParceled(1) - private Status status; - - @SafeParceled(2) - private LocationSettingsStates settings; - - - /** - * Retrieves the location settings states. - */ - public LocationSettingsStates getLocationSettingsStates() { - return settings; - } - - @Override - public Status getStatus() { - return status; - } - - @PublicApi(exclude = true) - public LocationSettingsResult(LocationSettingsStates settings, Status status) { - this.settings = settings; - this.status = status; - } - - @PublicApi(exclude = true) - public LocationSettingsResult(Status status) { - this.status = status; - } - - public static final Creator CREATOR = new AutoCreator(LocationSettingsResult.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsStates.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsStates.java deleted file mode 100644 index 194982b2..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsStates.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * Stores the current states of all location-related settings. - */ -@PublicApi -public class LocationSettingsStates extends AutoSafeParcelable { - - @SafeParceled(1000) - private int versionCode = 2; - - @SafeParceled(1) - private boolean gpsUsable; - - @SafeParceled(2) - private boolean networkLocationUsable; - - @SafeParceled(3) - private boolean bleUsable; - - @SafeParceled(4) - private boolean gpsPresent; - - @SafeParceled(5) - private boolean networkLocationPresent; - - @SafeParceled(6) - private boolean blePresent; - - public boolean isBlePresent() { - return blePresent; - } - - public boolean isBleUsable() { - return bleUsable; - } - - public boolean isGpsPresent() { - return gpsPresent; - } - - public boolean isGpsUsable() { - return gpsUsable; - } - - public boolean isLocationPresent() { - return isGpsPresent() || isNetworkLocationPresent(); - } - - public boolean isLocationUsable() { - return isGpsUsable() || isNetworkLocationUsable(); - } - - public boolean isNetworkLocationPresent() { - return networkLocationPresent; - } - - public boolean isNetworkLocationUsable() { - return networkLocationUsable; - } - - public LocationSettingsStates(boolean gpsUsable, boolean networkLocationUsable, boolean bleUsable, boolean gpsPresent, boolean networkLocationPresent, boolean blePresent) { - this.gpsUsable = gpsUsable; - this.networkLocationUsable = networkLocationUsable; - this.bleUsable = bleUsable; - this.gpsPresent = gpsPresent; - this.networkLocationPresent = networkLocationPresent; - this.blePresent = blePresent; - } - - public static final Creator CREATOR = new AutoCreator(LocationSettingsStates.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsStatusCodes.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsStatusCodes.java deleted file mode 100644 index 028de68c..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationSettingsStatusCodes.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import com.google.android.gms.common.api.CommonStatusCodes; -import com.google.android.gms.common.api.Status; - -import org.microg.gms.common.PublicApi; - -/** - * Location settings specific status codes, for use in {@link Status#getStatusCode()} - */ -@PublicApi -public class LocationSettingsStatusCodes extends CommonStatusCodes { - /** - * Location settings can't be changed to meet the requirements, no dialog pops up - */ - public static final int SETTINGS_CHANGE_UNAVAILABLE = 8502; -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationStatus.java b/play-services-location-api/src/main/java/com/google/android/gms/location/LocationStatus.java deleted file mode 100644 index 6cd2060a..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/LocationStatus.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.Arrays; - -public class LocationStatus extends AutoSafeParcelable { - public static final int STATUS_SUCCESSFUL = 0; - public static final int STATUS_UNKNOWN = 1; - public static final int STATUS_TIMED_OUT_ON_SCAN = 2; - public static final int STATUS_NO_INFO_IN_DATABASE = 3; - public static final int STATUS_INVALID_SCAN = 4; - public static final int STATUS_UNABLE_TO_QUERY_DATABASE = 5; - public static final int STATUS_SCANS_DISABLED_IN_SETTINGS = 6; - public static final int STATUS_LOCATION_DISABLED_IN_SETTINGS = 7; - public static final int STATUS_IN_PROGRESS = 8; - @SafeParceled(1000) - private int versionCode = 1; - @SafeParceled(1) - int cellStatus; - @SafeParceled(2) - int wifiStatus; - @SafeParceled(3) - long elapsedRealtimeNanos; - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - LocationStatus that = (LocationStatus) o; - - if (cellStatus != that.cellStatus) - return false; - if (elapsedRealtimeNanos != that.elapsedRealtimeNanos) - return false; - if (wifiStatus != that.wifiStatus) - return false; - - return true; - } - - @Override - public int hashCode() { - return Arrays.hashCode(new Object[] { cellStatus, wifiStatus, elapsedRealtimeNanos }); - } - - private String statusToString(int status) { - switch (status) { - case STATUS_SUCCESSFUL: - return "STATUS_SUCCESSFUL"; - case STATUS_UNKNOWN: - default: - return "STATUS_UNKNOWN"; - case STATUS_TIMED_OUT_ON_SCAN: - return "STATUS_TIMED_OUT_ON_SCAN"; - case STATUS_NO_INFO_IN_DATABASE: - return "STATUS_NO_INFO_IN_DATABASE"; - case STATUS_INVALID_SCAN: - return "STATUS_INVALID_SCAN"; - case STATUS_UNABLE_TO_QUERY_DATABASE: - return "STATUS_UNABLE_TO_QUERY_DATABASE"; - case STATUS_SCANS_DISABLED_IN_SETTINGS: - return "STATUS_SCANS_DISABLED_IN_SETTINGS"; - case STATUS_LOCATION_DISABLED_IN_SETTINGS: - return "STATUS_LOCATION_DISABLED_IN_SETTINGS"; - case STATUS_IN_PROGRESS: - return "STATUS_IN_PROGRESS"; - } - } - - public static final Creator CREATOR = new AutoCreator(LocationStatus.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/ClientIdentity.java b/play-services-location-api/src/main/java/com/google/android/gms/location/internal/ClientIdentity.java deleted file mode 100644 index a92c6516..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/ClientIdentity.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.internal; - -import org.microg.safeparcel.AutoSafeParcelable; - -public class ClientIdentity extends AutoSafeParcelable { - public static final Creator CREATOR = new AutoCreator(ClientIdentity.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/FusedLocationProviderResult.java b/play-services-location-api/src/main/java/com/google/android/gms/location/internal/FusedLocationProviderResult.java deleted file mode 100644 index b4b6516d..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/FusedLocationProviderResult.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.internal; - -import com.google.android.gms.common.api.Status; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class FusedLocationProviderResult extends AutoSafeParcelable { - public static final FusedLocationProviderResult SUCCESS = FusedLocationProviderResult.create(Status.SUCCESS); - - @SafeParceled(1000) - private int versionCode = 1; - - @SafeParceled(1) - public Status status; - - public static FusedLocationProviderResult create(Status status) { - FusedLocationProviderResult result = new FusedLocationProviderResult(); - result.status = status; - return result; - } - - public static final Creator CREATOR = new AutoCreator(FusedLocationProviderResult.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/LocationRequestInternal.java b/play-services-location-api/src/main/java/com/google/android/gms/location/internal/LocationRequestInternal.java deleted file mode 100644 index c803a841..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/LocationRequestInternal.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.internal; - -import com.google.android.gms.location.LocationRequest; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.List; - -public class LocationRequestInternal extends AutoSafeParcelable { - - @SafeParceled(1000) - private int versionCode = 1; - - @SafeParceled(1) - public LocationRequest request; - - @SafeParceled(2) - public boolean requestNlpDebugInfo; - - @SafeParceled(3) - public boolean restorePendingIntentListeners; - - @SafeParceled(4) - public boolean triggerUpdate; - - @SafeParceled(value = 5, subClass = ClientIdentity.class) - public List clients; - - @SafeParceled(6) - public String tag; - - @SafeParceled(7) - public boolean hideFromAppOps; - - @SafeParceled(8) - public boolean forceCoarseLocation; - - @Override - public String toString() { - return "LocationRequestInternal{" + - "request=" + request + - ", requestNlpDebugInfo=" + requestNlpDebugInfo + - ", restorePendingIntentListeners=" + restorePendingIntentListeners + - ", triggerUpdate=" + triggerUpdate + - ", clients=" + clients + - ", tag='" + tag + '\'' + - ", hideFromAppOps=" + hideFromAppOps + - ", forceCoarseLocation=" + forceCoarseLocation + - '}'; - } - - public static final Creator CREATOR = new AutoCreator(LocationRequestInternal.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/LocationRequestUpdateData.java b/play-services-location-api/src/main/java/com/google/android/gms/location/internal/LocationRequestUpdateData.java deleted file mode 100644 index 6da81cc3..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/LocationRequestUpdateData.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.internal; - -import android.app.PendingIntent; - -import com.google.android.gms.location.ILocationCallback; -import com.google.android.gms.location.ILocationListener; -import com.google.android.gms.location.internal.IFusedLocationProviderCallback; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class LocationRequestUpdateData extends AutoSafeParcelable { - - public static final int REQUEST_UPDATES = 1; - public static final int REMOVE_UPDATES = 2; - - @SafeParceled(1000) - private int versionCode; - - @SafeParceled(1) - public int opCode; - - @SafeParceled(2) - public LocationRequestInternal request; - - @SafeParceled(3) - public ILocationListener listener; - - @SafeParceled(4) - public PendingIntent pendingIntent; - - @SafeParceled(5) - public ILocationCallback callback; - - @SafeParceled(6) - public IFusedLocationProviderCallback fusedLocationProviderCallback; - - @Override - public String toString() { - return "LocationRequestUpdateData{" + - "opCode=" + opCode + - ", request=" + request + - ", listener=" + (listener != null ? listener.asBinder() : null) + - ", pendingIntent=" + pendingIntent + - ", callback=" + (callback != null ? callback.asBinder() : null) + - ", fusedLocationProviderCallback=" + (fusedLocationProviderCallback != null ? fusedLocationProviderCallback.asBinder() : null) + - '}'; - } - - public static final Creator CREATOR = new AutoCreator(LocationRequestUpdateData.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/ParcelableGeofence.java b/play-services-location-api/src/main/java/com/google/android/gms/location/internal/ParcelableGeofence.java deleted file mode 100644 index 3abc611c..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/internal/ParcelableGeofence.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.internal; - -import com.google.android.gms.location.Geofence; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class ParcelableGeofence extends AutoSafeParcelable implements Geofence { - - @SafeParceled(1000) - private int versionCode = 1; - - @SafeParceled(1) - public String requestId; - - @SafeParceled(2) - public long expirationTime; - - @SafeParceled(3) - public int regionType; - - @SafeParceled(4) - public double latitude; - - @SafeParceled(5) - public double longitude; - - @SafeParceled(6) - public float radius; - - @SafeParceled(7) - public int transitionType; - - @SafeParceled(8) - public int notificationResponsiveness; - - @SafeParceled(9) - public int loiteringDelay; - - private ParcelableGeofence() { - } - - public ParcelableGeofence(String requestId, long expirationTime, int regionType, double latitude, double longitude, float radius, int transitionType, int notificationResponsiveness, int loiteringDelay) { - this.requestId = requestId; - this.expirationTime = expirationTime; - this.regionType = regionType; - this.latitude = latitude; - this.longitude = longitude; - this.radius = radius; - this.transitionType = transitionType; - this.notificationResponsiveness = notificationResponsiveness; - this.loiteringDelay = loiteringDelay; - } - - @Override - public String getRequestId() { - return requestId; - } - - public static final Creator CREATOR = new AutoCreator(ParcelableGeofence.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/AutocompleteFilter.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/AutocompleteFilter.java deleted file mode 100644 index cf0f9238..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/AutocompleteFilter.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * TODO usage - */ -public class AutocompleteFilter extends AutoSafeParcelable { - - @SafeParceled(1000) - private int versionCode = 1; - - public static final Creator CREATOR = new AutoCreator(AutocompleteFilter.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/NearbyAlertRequest.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/NearbyAlertRequest.java deleted file mode 100644 index 97c7b7e8..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/NearbyAlertRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import org.microg.safeparcel.AutoSafeParcelable; - -/** - * TODO: usage - */ -public class NearbyAlertRequest extends AutoSafeParcelable { - - public static final Creator CREATOR = new AutoCreator(NearbyAlertRequest.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/Place.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/Place.java deleted file mode 100644 index 25ad8f3f..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/Place.java +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import android.net.Uri; - -import com.google.android.gms.common.data.Freezable; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -import java.util.List; -import java.util.Locale; - -public interface Place extends Freezable { - int TYPE_ACCOUNTING = 1; - - int TYPE_ADMINISTRATIVE_AREA_LEVEL_1 = 1001; - - int TYPE_ADMINISTRATIVE_AREA_LEVEL_2 = 1002; - - int TYPE_ADMINISTRATIVE_AREA_LEVEL_3 = 1003; - - int TYPE_AIRPORT = 2; - - int TYPE_AMUSEMENT_PARK = 3; - - int TYPE_AQUARIUM = 4; - - int TYPE_ART_GALLERY = 5; - - int TYPE_ATM = 6; - - int TYPE_BAKERY = 7; - - int TYPE_BANK = 8; - - int TYPE_BAR = 9; - - int TYPE_BEAUTY_SALON = 10; - - int TYPE_BICYCLE_STORE = 11; - - int TYPE_BOOK_STORE = 12; - - int TYPE_BOWLING_ALLEY = 13; - - int TYPE_BUS_STATION = 14; - - int TYPE_CAFE = 15; - - int TYPE_CAMPGROUND = 16; - - int TYPE_CAR_DEALER = 17; - - int TYPE_CAR_RENTAL = 18; - - int TYPE_CAR_REPAIR = 19; - - int TYPE_CAR_WASH = 20; - - int TYPE_CASINO = 21; - - int TYPE_CEMETERY = 22; - - int TYPE_CHURCH = 23; - - int TYPE_CITY_HALL = 24; - - int TYPE_CLOTHING_STORE = 25; - - int TYPE_COLLOQUIAL_AREA = 1004; - - int TYPE_CONVENIENCE_STORE = 26; - - int TYPE_COUNTRY = 1005; - - int TYPE_COURTHOUSE = 27; - - int TYPE_DENTIST = 28; - - int TYPE_DEPARTMENT_STORE = 29; - - int TYPE_DOCTOR = 30; - - int TYPE_ELECTRICIAN = 31; - - int TYPE_ELECTRONICS_STORE = 32; - - int TYPE_EMBASSY = 33; - - int TYPE_ESTABLISHMENT = 34; - - int TYPE_FINANCE = 35; - - int TYPE_FIRE_STATION = 36; - - int TYPE_FLOOR = 1006; - - int TYPE_FLORIST = 37; - - int TYPE_FOOD = 38; - - int TYPE_FUNERAL_HOME = 39; - - int TYPE_FURNITURE_STORE = 40; - - int TYPE_GAS_STATION = 41; - - int TYPE_GENERAL_CONTRACTOR = 42; - - int TYPE_GEOCODE = 1007; - - int TYPE_GROCERY_OR_SUPERMARKET = 43; - - int TYPE_GYM = 44; - - int TYPE_HAIR_CARE = 45; - - int TYPE_HARDWARE_STORE = 46; - - int TYPE_HEALTH = 47; - - int TYPE_HINDU_TEMPLE = 48; - - int TYPE_HOME_GOODS_STORE = 49; - - int TYPE_HOSPITAL = 50; - - int TYPE_INSURANCE_AGENCY = 51; - - int TYPE_INTERSECTION = 1008; - - int TYPE_JEWELRY_STORE = 52; - - int TYPE_LAUNDRY = 53; - - int TYPE_LAWYER = 54; - - int TYPE_LIBRARY = 55; - - int TYPE_LIQUOR_STORE = 56; - - int TYPE_LOCALITY = 1009; - - int TYPE_LOCAL_GOVERNMENT_OFFICE = 57; - - int TYPE_LOCKSMITH = 58; - - int TYPE_LODGING = 59; - - int TYPE_MEAL_DELIVERY = 60; - - int TYPE_MEAL_TAKEAWAY = 61; - - int TYPE_MOSQUE = 62; - - int TYPE_MOVIE_RENTAL = 63; - - int TYPE_MOVIE_THEATER = 64; - - int TYPE_MOVING_COMPANY = 65; - - int TYPE_MUSEUM = 66; - - int TYPE_NATURAL_FEATURE = 1010; - - int TYPE_NEIGHBORHOOD = 1011; - - int TYPE_NIGHT_CLUB = 67; - - int TYPE_OTHER = 0; - - int TYPE_PAINTER = 68; - - int TYPE_PARK = 69; - - int TYPE_PARKING = 70; - - int TYPE_PET_STORE = 71; - - int TYPE_PHARMACY = 72; - - int TYPE_PHYSIOTHERAPIST = 73; - - int TYPE_PLACE_OF_WORSHIP = 74; - - int TYPE_PLUMBER = 75; - - int TYPE_POINT_OF_INTEREST = 1013; - - int TYPE_POLICE = 76; - - int TYPE_POLITICAL = 1012; - - int TYPE_POSTAL_CODE = 1015; - - int TYPE_POSTAL_CODE_PREFIX = 1016; - - int TYPE_POSTAL_TOWN = 1017; - - int TYPE_POST_BOX = 1014; - - int TYPE_POST_OFFICE = 77; - - int TYPE_PREMISE = 1018; - - int TYPE_REAL_ESTATE_AGENCY = 78; - - int TYPE_RESTAURANT = 79; - - int TYPE_ROOFING_CONTRACTOR = 80; - - int TYPE_ROOM = 1019; - - int TYPE_ROUTE = 1020; - - int TYPE_RV_PARK = 81; - - int TYPE_SCHOOL = 82; - - int TYPE_SHOE_STORE = 83; - - int TYPE_SHOPPING_MALL = 84; - - int TYPE_SPA = 85; - - int TYPE_STADIUM = 86; - - int TYPE_STORAGE = 87; - - int TYPE_STORE = 88; - - int TYPE_STREET_ADDRESS = 1021; - - int TYPE_SUBLOCALITY = 1022; - - int TYPE_SUBLOCALITY_LEVEL_1 = 1023; - - int TYPE_SUBLOCALITY_LEVEL_2 = 1024; - - int TYPE_SUBLOCALITY_LEVEL_3 = 1025; - - int TYPE_SUBLOCALITY_LEVEL_4 = 1026; - - int TYPE_SUBLOCALITY_LEVEL_5 = 1027; - - int TYPE_SUBPREMISE = 1028; - - int TYPE_SUBWAY_STATION = 89; - - int TYPE_SYNAGOGUE = 90; - - int TYPE_SYNTHETIC_GEOCODE = 1029; - - int TYPE_TAXI_STAND = 91; - - int TYPE_TRAIN_STATION = 92; - - int TYPE_TRANSIT_STATION = 1030; - - int TYPE_TRAVEL_AGENCY = 93; - - int TYPE_UNIVERSITY = 94; - - int TYPE_VETERINARY_CARE = 95; - - int TYPE_ZOO = 96; - - /** - * Returns a human readable address for this Place. May return null if the address is unknown. - *

- * The address is localized according to the locale returned by {@link com.google.android.gms.location.places.Place#getLocale()}. - */ - CharSequence getAddress(); - - /** - * Returns the attributions to be shown to the user if data from the {@link com.google.android.gms.location.places.Place} is used. - *

- * We recommend placing this information below any place information. See - * Displaying Attributions for more details. - * - * @return The attributions in HTML format, or null if there are no attributions to display. - */ - CharSequence getAttributions(); - - /** - * Returns the unique id of this Place. - *

- * This ID can be passed to {@link com.google.android.gms.location.places.GeoDataApi#getPlaceById(com.google.android.gms.common.api.GoogleApiClient, java.lang.String...)} to lookup the same place at a later - * time, but it is not guaranteed that such a lookup will succeed (the place may no longer exist - * in our database). It is possible that the returned Place in such a lookup will have a - * different ID (so there may be multiple ID's for one given place). - */ - String getId(); - - /** - * Returns the location of this Place. - *

- * The location is not necessarily the center of the Place, or any particular entry or exit - * point, but some arbitrarily chosen point within the geographic extent of the Place. - */ - LatLng getLatLng(); - - /** - * Returns the locale in which the names and addresses were localized. - */ - Locale getLocale(); - - /** - * Returns the name of this Place. - *

- * The name is localized according to the locale returned by {@link com.google.android.gms.location.places.Place#getLocale()}. - */ - CharSequence getName(); - - /** - * Returns the place's phone number in international format. Returns null if no phone number is - * known, or the place has no phone number. - *

- * International format includes the country code, and is prefixed with the plus (+) sign. For - * example, the international phone number for Google's Mountain View, USA office is +1 - * 650-253-0000. - */ - CharSequence getPhoneNumber(); - - /** - * Returns a list of place types for this Place. - *

- * The elements of this list are drawn from Place.TYPE_* constants, though one should - * expect there could be new place types returned that were introduced after an app was - * published. - */ - List getPlaceTypes(); - - /** - * Returns the price level for this place on a scale from 0 (cheapest) to 4. - *

- * If no price level is known, a negative value is returned. - *

- * The price level of the place, on a scale of 0 to 4. The exact amount indicated by a specific - * value will vary from region to region. Price levels are interpreted as follows: - */ - int getPriceLevel(); - - /** - * Returns the place's rating, from 1.0 to 5.0, based on aggregated user reviews. - *

- * If no rating is known, a negative value is returned. - */ - float getRating(); - - /** - * Returns a viewport for displaying this Place. May return null if the size of the place is not - * known. - *

- * This returns a viewport of a size that is suitable for displaying this Place. For example, a - * Place representing a store may have a relatively small viewport, while a Place representing a - * country may have a very large viewport. - */ - LatLngBounds getViewport(); - - /** - * Returns the URI of the website of this Place. Returns null if no website is known. - *

- * This is the URI of the website maintained by the Place, if available. Note this is a - * third-party website not affiliated with the Places API. - */ - Uri getWebsiteUri(); - -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceFilter.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceFilter.java deleted file mode 100644 index 22bffb6b..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceFilter.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import org.microg.safeparcel.AutoSafeParcelable; - -/** - * TODO: usage - */ -public class PlaceFilter extends AutoSafeParcelable { - - public static final Creator CREATOR = new AutoCreator(PlaceFilter.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceReport.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceReport.java deleted file mode 100644 index 5919e691..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceReport.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -@PublicApi -public class PlaceReport extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode; - @SafeParceled(2) - private String placeId; - @SafeParceled(3) - private String tag; - @SafeParceled(4) - private String source; - - public String getPlaceId() { - return placeId; - } - - public String getTag() { - return tag; - } - - public static final Creator CREATOR = new AutoCreator(PlaceReport.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceRequest.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceRequest.java deleted file mode 100644 index ed6a8556..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/PlaceRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import org.microg.safeparcel.AutoSafeParcelable; - -/** - * TODO: usage - */ -public class PlaceRequest extends AutoSafeParcelable { - public static final Creator CREATOR = new AutoCreator(PlaceRequest.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/UserAddedPlace.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/UserAddedPlace.java deleted file mode 100644 index eb916696..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/UserAddedPlace.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * TODO: usage - */ -public class UserAddedPlace extends AutoSafeParcelable { - - @SafeParceled(1000) - private int versionCode = 1; - - public static final Creator CREATOR = new AutoCreator(UserAddedPlace.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/UserDataType.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/UserDataType.java deleted file mode 100644 index 2e8776fd..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/UserDataType.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places; - -import org.microg.safeparcel.AutoSafeParcelable; - -/** - * TODO: usage - */ -public class UserDataType extends AutoSafeParcelable { - - public static final Creator CREATOR = new AutoCreator(UserDataType.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/internal/PlaceImpl.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/internal/PlaceImpl.java deleted file mode 100644 index dbc23035..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/internal/PlaceImpl.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places.internal; - -import android.net.Uri; -import android.os.Bundle; - -import com.google.android.gms.location.places.Place; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -public class PlaceImpl extends AutoSafeParcelable implements Place { - @SafeParceled(1000) - private int versionCode = 2; - @SafeParceled(1) - public String id; - @SafeParceled(2) - public Bundle addressComponents; - @SafeParceled(4) - public LatLng latLng; - @SafeParceled(5) - public float levelNumber; - @SafeParceled(6) - public LatLngBounds viewport; - @SafeParceled(7) - public String timezoneId; - @SafeParceled(8) - public Uri websiteUri; - @SafeParceled(9) - public boolean isPermanentlyClosed; - @SafeParceled(10) - public float rating; - @SafeParceled(11) - public int priceLevel; - @SafeParceled(12) - public long timestampSecs; - @SafeParceled(value = 13, subClass = Integer.class) - public List typesDeprecated = new ArrayList(); - @SafeParceled(14) - public String address; - @SafeParceled(15) - public String phoneNumber; - @SafeParceled(16) - public String regularOpenHours; - @SafeParceled(value = 17, subClass = String.class) - public List attributions = new ArrayList(); - @SafeParceled(19) - public String name; - @SafeParceled(value = 20, subClass = Integer.class) - public List placeTypes = new ArrayList(); - - @Override - public CharSequence getAddress() { - return address; - } - - @Override - public CharSequence getAttributions() { - return Arrays.toString(attributions.toArray()); - } - - @Override - public String getId() { - return id; - } - - @Override - public LatLng getLatLng() { - return latLng; - } - - @Override - public Locale getLocale() { - return Locale.getDefault(); - } - - @Override - public CharSequence getName() { - return name; - } - - @Override - public CharSequence getPhoneNumber() { - return phoneNumber; - } - - @Override - public List getPlaceTypes() { - return placeTypes; - } - - @Override - public int getPriceLevel() { - return priceLevel; - } - - @Override - public float getRating() { - return rating; - } - - @Override - public LatLngBounds getViewport() { - return viewport; - } - - @Override - public Uri getWebsiteUri() { - return websiteUri; - } - - @Override - public Place freeze() { - return this; - } - - @Override - public boolean isDataValid() { - return true; - } - - public static final Creator CREATOR = new AutoSafeParcelable.AutoCreator(PlaceImpl.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/places/internal/PlacesParams.java b/play-services-location-api/src/main/java/com/google/android/gms/location/places/internal/PlacesParams.java deleted file mode 100644 index eb365fa3..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/places/internal/PlacesParams.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.places.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class PlacesParams extends AutoSafeParcelable { - - @SafeParceled(1000) - private int versionCode = 1; - @SafeParceled(1) - public final String clientPackageName; - @SafeParceled(2) - public final String locale; - @SafeParceled(3) - public final String accountName; - @SafeParceled(4) - public final String gCoreClientName; - - private PlacesParams() { - clientPackageName = locale = accountName = gCoreClientName = null; - } - - public static final Creator CREATOR = new AutoCreator(PlacesParams.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/ReportingState.java b/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/ReportingState.java deleted file mode 100644 index 1a223471..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/ReportingState.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.reporting; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class ReportingState extends AutoSafeParcelable { - @SafeParceled(1) - public int versionCode = 2; - @SafeParceled(2) - public int reportingEnabled; - @SafeParceled(3) - public int historyEnabled; - @SafeParceled(4) - public boolean allowed; - @SafeParceled(5) - public boolean active; - @SafeParceled(6) - public boolean defer; - @SafeParceled(7) - public int expectedOptInResult; - @SafeParceled(8) - public Integer deviceTag; - @SafeParceled(9) - public int expectedOptInResultAssumingLocationEnabled; - - public static final Creator CREATOR = new AutoCreator(ReportingState.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/UploadRequest.java b/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/UploadRequest.java deleted file mode 100644 index d3896f3c..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/UploadRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.reporting; - -import android.accounts.Account; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class UploadRequest extends AutoSafeParcelable { - @SafeParceled(1) - public int versionCode = 1; - @SafeParceled(2) - public Account account; - @SafeParceled(3) - public String reason; - @SafeParceled(4) - public long durationMillis; - @SafeParceled(5) - public long movingLatencyMillis; - @SafeParceled(6) - public long stationaryLatencyMillis; - @SafeParceled(7) - public String appSpecificKey; - - public static final Creator CREATOR = new AutoCreator(UploadRequest.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/UploadRequestResult.java b/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/UploadRequestResult.java deleted file mode 100644 index 2937a81c..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/location/reporting/UploadRequestResult.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location.reporting; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class UploadRequestResult extends AutoSafeParcelable { - @SafeParceled(1) - public int versionCode = 1; - @SafeParceled(2) - public int resultCode; - @SafeParceled(3) - public long requestId; - - public UploadRequestResult() { - } - - public static final Creator CREATOR = new AutoCreator(UploadRequestResult.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/maps/model/LatLng.java b/play-services-location-api/src/main/java/com/google/android/gms/maps/model/LatLng.java deleted file mode 100644 index 545d8b46..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/maps/model/LatLng.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * An immutable class representing a pair of latitude and longitude coordinates, stored as degrees. - */ -@PublicApi -public final class LatLng extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - /** - * Latitude, in degrees. This value is in the range [-90, 90]. - */ - @SafeParceled(2) - public final double latitude; - /** - * Longitude, in degrees. This value is in the range [-180, 180). - */ - @SafeParceled(3) - public final double longitude; - - /** - * This constructor is dirty setting the final fields to make the compiler happy. - * In fact, those are replaced by their real values later using SafeParcelUtil. - */ - private LatLng() { - latitude = longitude = 0; - } - - /** - * Constructs a LatLng with the given latitude and longitude, measured in degrees. - * - * @param latitude The point's latitude. This will be clamped to between -90 degrees and - * +90 degrees inclusive. - * @param longitude The point's longitude. This will be normalized to be within -180 degrees - * inclusive and +180 degrees exclusive. - */ - public LatLng(double latitude, double longitude) { - this.latitude = Math.max(-90, Math.min(90, latitude)); - if ((-180 <= longitude) && (longitude < 180)) { - this.longitude = longitude; - } else { - this.longitude = ((360 + (longitude - 180) % 360) % 360 - 180); - } - } - - /** - * Tests if this LatLng is equal to another. - *

- * Two points are considered equal if and only if their latitudes are bitwise equal and their - * longitudes are bitwise equal. This means that two {@link LatLng}s that are very near, in - * terms of geometric distance, might not be considered {@code .equal()}. - */ - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - LatLng latLng = (LatLng) o; - - if (Double.compare(latLng.latitude, latitude) != 0) - return false; - if (Double.compare(latLng.longitude, longitude) != 0) - return false; - - return true; - } - - @Override - public final int hashCode() { - long tmp1 = Double.doubleToLongBits(latitude); - int tmp2 = 31 + (int) (tmp1 ^ tmp1 >>> 32); - tmp1 = Double.doubleToLongBits(longitude); - return tmp2 * 31 + (int) (tmp1 ^ tmp1 >>> 32); - } - - @Override - public String toString() { - return "lat/lng: (" + latitude + "," + longitude + ")"; - } - - public static Creator CREATOR = new AutoCreator(LatLng.class); -} diff --git a/play-services-location-api/src/main/java/com/google/android/gms/maps/model/LatLngBounds.java b/play-services-location-api/src/main/java/com/google/android/gms/maps/model/LatLngBounds.java deleted file mode 100644 index 21177235..00000000 --- a/play-services-location-api/src/main/java/com/google/android/gms/maps/model/LatLngBounds.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.model; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.Arrays; - -/** - * An immutable class representing a latitude/longitude aligned rectangle. - */ -@PublicApi -public final class LatLngBounds extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - /** - * Southwest corner of the bound. - */ - @SafeParceled(2) - public final LatLng southwest; - /** - * Northeast corner of the bound. - */ - @SafeParceled(3) - public final LatLng northeast; - - /** - * This constructor is dirty setting the final fields to make the compiler happy. - * In fact, those are replaced by their real values later using SafeParcelUtil. - */ - private LatLngBounds() { - southwest = northeast = null; - } - - /** - * Creates a new bounds based on a southwest and a northeast corner. - *

- * The bounds conceptually includes all points where: - *

    - *
  • the latitude is in the range [northeast.latitude, southwest.latitude];
  • - *
  • the longitude is in the range [southwest.longtitude, northeast.longitude] - * if southwest.longtitude ≤ northeast.longitude; and
  • - *
  • the longitude is in the range [southwest.longitude, 180) ∪ [-180, northeast.longitude] - * if southwest.longtitude > northeast.longitude.
  • - *
- * - * @param southwest southwest corner - * @param northeast northeast corner - * @throws IllegalArgumentException if the latitude of the northeast corner is below the - * latitude of the southwest corner. - */ - public LatLngBounds(LatLng southwest, LatLng northeast) throws IllegalArgumentException { - if (northeast.latitude < southwest.latitude) - throw new IllegalArgumentException("latitude of northeast corner must not be" + - " lower than latitude of southwest corner"); - this.southwest = southwest; - this.northeast = northeast; - } - - /** - * Creates a new builder. - */ - public Builder builder() { - return new Builder(); - } - - /** - * Returns whether this contains the given {@link LatLng}. - * - * @param point the {@link LatLng} to test - * @return {@code true} if this contains the given point; {@code false} if not. - */ - public boolean contains(LatLng point) { - return containsLatitude(point.latitude) && containsLongitude(point.longitude); - } - - private boolean containsLatitude(double latitude) { - return southwest.latitude <= latitude && latitude <= northeast.latitude; - } - - private boolean containsLongitude(double longitude) { - return southwest.longitude <= northeast.longitude ? ( - southwest.longitude <= longitude && longitude <= northeast.longitude - ) : ( - southwest.longitude >= longitude && longitude < 180 || - longitude >= -180 && longitude <= northeast.longitude - ); - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - LatLngBounds that = (LatLngBounds) o; - - if (!northeast.equals(that.northeast)) - return false; - if (!southwest.equals(that.southwest)) - return false; - - return true; - } - - /** - * Returns the center of this {@link LatLngBounds}. The center is simply the average of the - * coordinates (taking into account if it crosses the antimeridian). This is approximately the - * geographical center (it would be exact if the Earth were a perfect sphere). It will not - * necessarily be the center of the rectangle as drawn on the map due to the Mercator - * projection. - * - * @return A {@link LatLng} that is the center of the {@link LatLngBounds}. - */ - public LatLng getCenter() { - double lat = (southwest.latitude + northeast.latitude) / 2.0; - double lon = (southwest.longitude + northeast.longitude) / 2.0 + - southwest.longitude <= northeast.latitude ? 0 : 180.0; - return new LatLng(lat, lon); - } - - @Override - public int hashCode() { - return Arrays.hashCode(new Object[] { southwest, northeast }); - } - - /** - * Returns a new {@link LatLngBounds} that extends this {@link LatLngBounds} to include the - * given {@link LatLng}. This will return the smallest LatLngBounds that contains both this - * and the extra point. - *

- * In particular, it will consider extending the bounds both in the eastward and westward - * directions (one of which may cross the antimeridian) and choose the smaller of the two. In - * the case that both directions result in a LatLngBounds of the same size, this will extend - * it in the eastward direction. - * - * @param point a {@link LatLng} to be included in the new bounds - * @return A new {@link LatLngBounds} that contains this and the extra point. - */ - public LatLngBounds including(LatLng point) { - double latMin = Math.min(southwest.latitude, point.latitude); - double latMax = Math.max(northeast.latitude, point.latitude); - double lonMin = southwest.longitude; - double lonMax = northeast.longitude; - if (!containsLongitude(point.longitude)) { - if ((southwest.longitude - point.longitude + 360.0) % 360.0 < - (point.longitude - northeast.longitude + 360.0D) % 360.0D) { - lonMin = point.longitude; - } else { - lonMax = point.longitude; - } - } - return new LatLngBounds(new LatLng(latMin, lonMin), new LatLng(latMax, lonMax)); - } - - @Override - public String toString() { - return "LatLngBounds{" + - "southwest=" + southwest + - ", northeast=" + northeast + - '}'; - } - - public static Creator CREATOR = new AutoCreator(LatLngBounds.class); - - /** - * This is a builder that is able to create a minimum bound based on a set of LatLng points. - */ - public static final class Builder { - private LatLngBounds bounds; - - public Builder() { - - } - - /** - * Creates the LatLng bounds. - * - * @throws IllegalStateException if no points have been included. - */ - public LatLngBounds build() throws IllegalStateException { - if (bounds == null) - throw new IllegalStateException( - "You must not call build() before adding points to the Builder"); - return bounds; - } - - /** - * Includes this point for building of the bounds. The bounds will be extended in a - * minimum way to include this point. - *

- * More precisely, it will consider extending the bounds both in the eastward and westward - * directions (one of which may cross the antimeridian) and choose the smaller of the two. - * In the case that both directions result in a LatLngBounds of the same size, this will - * extend it in the eastward direction. For example, adding points (0, -179) and (1, 179) - * will create a bound crossing the 180 longitude. - * - * @param point A {@link LatLng} to be included in the bounds. - * @return This builder object with a new point added. - */ - public Builder include(LatLng point) { - if (bounds == null) { - bounds = new LatLngBounds(point, point); - } else { - bounds = bounds.including(point); - } - return this; - } - } -} diff --git a/play-services-location-api/src/main/java/org/microg/gms/location/LocationConstants.java b/play-services-location-api/src/main/java/org/microg/gms/location/LocationConstants.java deleted file mode 100644 index fc256bc6..00000000 --- a/play-services-location-api/src/main/java/org/microg/gms/location/LocationConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -public class LocationConstants { - public static final String KEY_MOCK_LOCATION = "mockLocation"; - - // Place picker client->service - public static final String EXTRA_PRIMARY_COLOR = "primary_color"; - public static final String EXTRA_PRIMARY_COLOR_DARK = "primary_color_dark"; - public static final String EXTRA_CLIENT_VERSION = "gmscore_client_jar_version"; - public static final String EXTRA_BOUNDS = "latlng_bounds"; - - // Place picker service->client - public static final String EXTRA_ATTRIBUTION = "third_party_attributions"; - public static final String EXTRA_FINAL_BOUNDS = "final_latlng_bounds"; - public static final String EXTRA_PLACE = "selected_place"; - public static final String EXTRA_STATUS = "status"; -} diff --git a/play-services-location-core/build.gradle b/play-services-location-core/build.gradle deleted file mode 100644 index 0556c781..00000000 --- a/play-services-location-core/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020, microG Project Team - * SPDX-License-Identifier: Apache-2.0 - */ - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -dependencies { - api project(':play-services-location-api') - - implementation project(':play-services-base-core') - implementation "org.microg.nlp:geocode-v1:$nlpVersion" - implementation "org.microg.nlp:location-v2:$nlpVersion" - implementation "org.microg.nlp:location-v3:$nlpVersion" - implementation "org.microg.nlp:service:$nlpVersion" - implementation "org.microg.nlp:client:$nlpVersion" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion" - api "org.microg.nlp:ui:$nlpVersion" -} - -android { - compileSdkVersion androidCompileSdk - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName version - minSdkVersion androidMinSdk - targetSdkVersion androidTargetSdk - } - - compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - } -} diff --git a/play-services-location-core/src/main/AndroidManifest.xml b/play-services-location-core/src/main/AndroidManifest.xml deleted file mode 100644 index 4786a8e7..00000000 --- a/play-services-location-core/src/main/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManager.java b/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManager.java deleted file mode 100644 index ae767666..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManager.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.Manifest; -import android.app.PendingIntent; -import android.content.Context; -import android.location.Location; -import android.location.LocationManager; -import android.os.Binder; -import android.os.RemoteException; - -import com.google.android.gms.location.ILocationListener; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.internal.FusedLocationProviderResult; -import com.google.android.gms.location.internal.LocationRequestUpdateData; - -import org.microg.gms.common.PackageUtils; -import org.microg.gms.common.Utils; - -import java.util.ArrayList; -import java.util.List; - -import static android.Manifest.permission.ACCESS_COARSE_LOCATION; -import static android.Manifest.permission.ACCESS_FINE_LOCATION; -import static android.content.pm.PackageManager.PERMISSION_GRANTED; -import static android.location.LocationManager.GPS_PROVIDER; -import static android.location.LocationManager.NETWORK_PROVIDER; -import static com.google.android.gms.location.LocationRequest.PRIORITY_HIGH_ACCURACY; -import static com.google.android.gms.location.LocationRequest.PRIORITY_NO_POWER; - -public class GoogleLocationManager implements LocationChangeListener { - private static final String TAG = "GmsLocManager"; - private static final String MOCK_PROVIDER = "mock"; - private static final long SWITCH_ON_FRESHNESS_CLIFF_MS = 30000; // 30 seconds - private static final String ACCESS_MOCK_LOCATION = "android.permission.ACCESS_MOCK_LOCATION"; - - private final Context context; - private final RealLocationProvider gpsProvider; - private final UnifiedLocationProvider networkProvider; - private final MockLocationProvider mockProvider; - private final List currentRequests = new ArrayList(); - - public GoogleLocationManager(Context context) { - this.context = context; - LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - if (Utils.hasSelfPermissionOrNotify(context, Manifest.permission.ACCESS_FINE_LOCATION)) { - this.gpsProvider = new RealLocationProvider(locationManager, GPS_PROVIDER, this); - } else { - this.gpsProvider = null; - } - if (Utils.hasSelfPermissionOrNotify(context, Manifest.permission.ACCESS_COARSE_LOCATION)) { - if (locationManager.getAllProviders().contains(NETWORK_PROVIDER)) { - this.networkProvider = new UnifiedLocationProvider(context, this); - } else { - // TODO: Add ability to directly contact UnifiedNlp without the system location provider - this.networkProvider = null; - } - } else { - this.networkProvider = null; - } - mockProvider = new MockLocationProvider(this); - } - - public Location getLastLocation(String packageName) { - return getLocation(hasFineLocationPermission(), hasCoarseLocationPermission()); - } - - public Location getLocation(boolean gpsPermission, boolean networkPermission) { - if (mockProvider.getLocation() != null) - return mockProvider.getLocation(); - if (gpsPermission) { - Location network = networkProvider == null ? null : networkProvider.getLastLocation(); - Location gps = gpsProvider == null ? null : gpsProvider.getLastLocation(); - if (network == null) - return gps; - if (gps == null) - return network; - if (gps.getTime() > network.getTime() - SWITCH_ON_FRESHNESS_CLIFF_MS) - return gps; - return network; - } else if (networkPermission) { - Location network = networkProvider == null ? null : networkProvider.getLastLocation(); - if (network != null && network.getExtras() != null && network.getExtras().getParcelable("no_gps_location") instanceof Location) { - network = network.getExtras().getParcelable("no_gps_location"); - } - return network; - } - return null; - } - - private boolean hasCoarseLocationPermission() { - return context.checkCallingPermission(ACCESS_COARSE_LOCATION) == PERMISSION_GRANTED || hasFineLocationPermission(); - } - - private boolean hasFineLocationPermission() { - return context.checkCallingPermission(ACCESS_FINE_LOCATION) == PERMISSION_GRANTED; - } - - private boolean hasMockLocationPermission() { - return context.checkCallingPermission(ACCESS_MOCK_LOCATION) == PERMISSION_GRANTED; - } - - private void requestLocationUpdates(LocationRequestHelper request) { - LocationRequestHelper old = null; - for (LocationRequestHelper req : currentRequests) { - if (req.respondsTo(request.pendingIntent) || req.respondsTo(request.listener) || req.respondsTo(request.callback)) { - old = req; - break; - } - } - if (old != null) { - currentRequests.remove(old); - } - currentRequests.add(request); - if (gpsProvider != null && request.hasFinePermission() && request.locationRequest.getPriority() == PRIORITY_HIGH_ACCURACY) { - gpsProvider.addRequest(request); - } else if (gpsProvider != null && old != null) { - gpsProvider.removeRequest(old); - } - if (networkProvider != null && request.hasCoarsePermission() && request.locationRequest.getPriority() != PRIORITY_NO_POWER) { - networkProvider.addRequest(request); - } else if (networkProvider != null && old != null) { - networkProvider.removeRequest(old); - } - } - - public void requestLocationUpdates(LocationRequest request, ILocationListener listener, String packageName) { - requestLocationUpdates(new LocationRequestHelper(context, request, packageName, Binder.getCallingUid(), listener)); - } - - public void requestLocationUpdates(LocationRequest request, PendingIntent intent, String packageName) { - requestLocationUpdates(new LocationRequestHelper(context, request, packageName, Binder.getCallingUid(), intent)); - } - - private void removeLocationUpdates(LocationRequestHelper request) { - currentRequests.remove(request); - if (gpsProvider != null) gpsProvider.removeRequest(request); - if (networkProvider != null) networkProvider.removeRequest(request); - } - - public void removeLocationUpdates(ILocationListener listener, String packageName) { - for (int i = 0; i < currentRequests.size(); i++) { - if (currentRequests.get(i).respondsTo(listener)) { - removeLocationUpdates(currentRequests.get(i)); - i--; - } - } - } - - public void removeLocationUpdates(PendingIntent intent, String packageName) { - for (int i = 0; i < currentRequests.size(); i++) { - if (currentRequests.get(i).respondsTo(intent)) { - removeLocationUpdates(currentRequests.get(i)); - i--; - } - } - } - - public void updateLocationRequest(LocationRequestUpdateData data) { - String packageName = PackageUtils.getCallingPackage(context); - if (data.pendingIntent != null) - packageName = PackageUtils.packageFromPendingIntent(data.pendingIntent); - if (data.opCode == LocationRequestUpdateData.REQUEST_UPDATES) { - requestLocationUpdates(new LocationRequestHelper(context, packageName, Binder.getCallingUid(), data)); - } else if (data.opCode == LocationRequestUpdateData.REMOVE_UPDATES) { - for (int i = 0; i < currentRequests.size(); i++) { - if (currentRequests.get(i).respondsTo(data.listener) - || currentRequests.get(i).respondsTo(data.pendingIntent) - || currentRequests.get(i).respondsTo(data.callback)) { - removeLocationUpdates(currentRequests.get(i)); - i--; - } - } - } - if (data.fusedLocationProviderCallback != null) { - try { - data.fusedLocationProviderCallback.onFusedLocationProviderResult(FusedLocationProviderResult.SUCCESS); - } catch (RemoteException ignored) { - } - } - } - - public void setMockMode(boolean mockMode) { - if (!hasMockLocationPermission()) - return; - mockProvider.setMockEnabled(mockMode); - } - - public void setMockLocation(Location mockLocation) { - if (!hasMockLocationPermission()) - return; - mockProvider.setLocation(mockLocation); - } - - @Override - public void onLocationChanged() { - for (int i = 0; i < currentRequests.size(); i++) { - LocationRequestHelper request = currentRequests.get(i); - if (!request.report(getLocation(request.initialHasFinePermission, request.initialHasCoarsePermission))) { - removeLocationUpdates(request); - i--; - } - } - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java b/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java deleted file mode 100644 index 1a105150..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.os.RemoteException; - -import com.google.android.gms.common.internal.GetServiceRequest; -import com.google.android.gms.common.internal.IGmsCallbacks; - -import org.microg.gms.BaseService; -import org.microg.gms.common.GmsService; - -public class GoogleLocationManagerService extends BaseService { - private GoogleLocationManagerServiceImpl impl = new GoogleLocationManagerServiceImpl(this); - - public GoogleLocationManagerService() { - super("GmsLocManagerSvc", GmsService.LOCATION_MANAGER, GmsService.GEODATA, GmsService.PLACE_DETECTION); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, impl.asBinder(), null); - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerServiceImpl.java b/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerServiceImpl.java deleted file mode 100644 index 31ac74a3..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerServiceImpl.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.app.PendingIntent; -import android.content.Context; -import android.location.Location; -import android.os.Binder; -import android.os.IBinder; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.ActivityRecognitionResult; -import com.google.android.gms.location.GeofencingRequest; -import com.google.android.gms.location.GestureRequest; -import com.google.android.gms.location.ILocationListener; -import com.google.android.gms.location.LocationAvailability; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.LocationSettingsRequest; -import com.google.android.gms.location.LocationSettingsResult; -import com.google.android.gms.location.LocationSettingsStates; -import com.google.android.gms.location.internal.IGeofencerCallbacks; -import com.google.android.gms.location.internal.IGoogleLocationManagerService; -import com.google.android.gms.location.internal.ISettingsCallbacks; -import com.google.android.gms.location.internal.LocationRequestInternal; -import com.google.android.gms.location.internal.LocationRequestUpdateData; -import com.google.android.gms.location.internal.ParcelableGeofence; -import com.google.android.gms.location.places.AutocompleteFilter; -import com.google.android.gms.location.places.NearbyAlertRequest; -import com.google.android.gms.location.places.PlaceFilter; -import com.google.android.gms.location.places.PlaceReport; -import com.google.android.gms.location.places.PlaceRequest; -import com.google.android.gms.location.places.UserAddedPlace; -import com.google.android.gms.location.places.UserDataType; -import com.google.android.gms.location.places.internal.IPlacesCallbacks; -import com.google.android.gms.location.places.internal.PlacesParams; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -import org.microg.gms.common.PackageUtils; - -import java.util.Arrays; -import java.util.List; - -public class GoogleLocationManagerServiceImpl extends IGoogleLocationManagerService.Stub { - private static final String TAG = "GmsLocManagerSvcImpl"; - - private final Context context; - private GoogleLocationManager locationManager; - - public GoogleLocationManagerServiceImpl(Context context) { - this.context = context; - } - - private GoogleLocationManager getLocationManager() { - if (locationManager == null) - locationManager = new GoogleLocationManager(context); - return locationManager; - } - - @Override - public void addGeofencesList(List geofences, PendingIntent pendingIntent, - IGeofencerCallbacks callbacks, String packageName) throws RemoteException { - Log.d(TAG, "addGeofencesList: " + geofences); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - } - - @Override - public void removeGeofencesByIntent(PendingIntent pendingIntent, IGeofencerCallbacks callbacks, - String packageName) throws RemoteException { - Log.d(TAG, "removeGeofencesByIntent: " + pendingIntent); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - } - - @Override - public void removeGeofencesById(String[] geofenceRequestIds, IGeofencerCallbacks callbacks, - String packageName) throws RemoteException { - Log.d(TAG, "removeGeofencesById: " + Arrays.toString(geofenceRequestIds)); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - } - - @Override - public void removeAllGeofences(IGeofencerCallbacks callbacks, String packageName) throws RemoteException { - Log.d(TAG, "removeAllGeofences"); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - } - - @Override - public void requestActivityUpdates(long detectionIntervalMillis, boolean alwaysTrue, - PendingIntent callbackIntent) throws RemoteException { - Log.d(TAG, "requestActivityUpdates: " + callbackIntent); - } - - @Override - public void removeActivityUpdates(PendingIntent callbackIntent) throws RemoteException { - Log.d(TAG, "removeActivityUpdates: " + callbackIntent); - } - - @Override - public ActivityRecognitionResult getLastActivity(String packageName) throws RemoteException { - Log.d(TAG, "getLastActivity"); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - return null; - } - - @Override - public Status iglms65(PendingIntent pendingIntent) throws RemoteException { - Log.d(TAG, "iglms65"); - return null; - } - - @Override - public Status iglms66(PendingIntent pendingIntent) throws RemoteException { - Log.d(TAG, "iglms66"); - return null; - } - - @Override - public Status requestGestureUpdates(GestureRequest request, PendingIntent pendingIntent) throws RemoteException { - Log.d(TAG, "requestGestureUpdates"); - return null; - } - - @Override - public Status iglms61(PendingIntent pendingIntent) throws RemoteException { - Log.d(TAG, "iglms61"); - return null; - } - - @Override - public Location getLastLocation() throws RemoteException { - Log.d(TAG, "getLastLocation"); - return getLocationManager().getLastLocation(PackageUtils.getCallingPackage(context)); - } - - @Override - public void requestLocationUpdatesWithListener(LocationRequest request, - final ILocationListener listener) throws RemoteException { - Log.d(TAG, "requestLocationUpdatesWithListener: " + request); - getLocationManager().requestLocationUpdates(request, listener, PackageUtils.getCallingPackage(context)); - } - - @Override - public void requestLocationUpdatesWithIntent(LocationRequest request, - PendingIntent callbackIntent) throws RemoteException { - Log.d(TAG, "requestLocationUpdatesWithIntent: " + request); - getLocationManager().requestLocationUpdates(request, callbackIntent, PackageUtils.packageFromPendingIntent(callbackIntent)); - } - - @Override - public void removeLocationUpdatesWithListener(ILocationListener listener) - throws RemoteException { - Log.d(TAG, "removeLocationUpdatesWithListener: " + listener); - getLocationManager().removeLocationUpdates(listener, PackageUtils.getCallingPackage(context)); - } - - @Override - public void removeLocationUpdatesWithIntent(PendingIntent callbackIntent) - throws RemoteException { - Log.d(TAG, "removeLocationUpdatesWithIntent: " + callbackIntent); - getLocationManager().removeLocationUpdates(callbackIntent, PackageUtils.packageFromPendingIntent(callbackIntent)); - } - - @Override - public void updateLocationRequest(LocationRequestUpdateData locationRequestUpdateData) throws RemoteException { - Log.d(TAG, "updateLocationRequest: " + locationRequestUpdateData); - getLocationManager().updateLocationRequest(locationRequestUpdateData); - } - - @Override - public void setMockMode(boolean mockMode) throws RemoteException { - Log.d(TAG, "setMockMode: " + mockMode); - getLocationManager().setMockMode(mockMode); - } - - @Override - public void setMockLocation(Location mockLocation) throws RemoteException { - Log.d(TAG, "setMockLocation: " + mockLocation); - getLocationManager().setMockLocation(mockLocation); - } - - @Override - public void iglms14(LatLngBounds var1, int var2, PlaceFilter var3, PlacesParams var4, - IPlacesCallbacks var5) throws RemoteException { - Log.d(TAG, "iglms14: " + var1); - } - - @Override - public void iglms15(String var1, PlacesParams var2, IPlacesCallbacks var3) - throws RemoteException { - Log.d(TAG, "iglms15: " + var1); - } - - @Override - public void iglms16(LatLng var1, PlaceFilter var2, PlacesParams var3, IPlacesCallbacks var4) - throws RemoteException { - Log.d(TAG, "iglms16: " + var1); - } - - @Override - public void iglms17(PlaceFilter var1, PlacesParams var2, IPlacesCallbacks var3) - throws RemoteException { - Log.d(TAG, "iglms17: " + var1); - } - - @Override - public void iglms18(PlaceRequest var1, PlacesParams var2, PendingIntent var3) - throws RemoteException { - Log.d(TAG, "iglms18: " + var1); - } - - @Override - public void iglms19(PlacesParams var1, PendingIntent var2) throws RemoteException { - Log.d(TAG, "iglms19: " + var1); - } - - @Override - public void requestLocationUpdatesWithPackage(LocationRequest request, ILocationListener listener, - String packageName) throws RemoteException { - Log.d(TAG, "requestLocationUpdatesWithPackage: " + request); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - getLocationManager().requestLocationUpdates(request, listener, packageName); - } - - @Override - public Location getLastLocationWithPackage(String packageName) throws RemoteException { - Log.d(TAG, "getLastLocationWithPackage: " + packageName); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - return getLocationManager().getLastLocation(packageName); - } - - @Override - public void iglms25(PlaceReport var1, PlacesParams var2) throws RemoteException { - Log.d(TAG, "iglms25: " + var1); - } - - @Override - public void iglms26(Location var1, int var2) throws RemoteException { - Log.d(TAG, "iglms26: " + var1); - } - - @Override - public LocationAvailability getLocationAvailabilityWithPackage(String packageName) throws RemoteException { - Log.d(TAG, "getLocationAvailabilityWithPackage: " + packageName); - PackageUtils.checkPackageUid(context, packageName, Binder.getCallingUid()); - return new LocationAvailability(); - } - - @Override - public void iglms42(String var1, PlacesParams var2, IPlacesCallbacks var3) - throws RemoteException { - Log.d(TAG, "iglms42: " + var1); - } - - @Override - public void iglms46(UserAddedPlace var1, PlacesParams var2, IPlacesCallbacks var3) - throws RemoteException { - Log.d(TAG, "iglms46: " + var1); - } - - @Override - public void iglms47(LatLngBounds var1, int var2, String var3, PlaceFilter var4, - PlacesParams var5, IPlacesCallbacks var6) throws RemoteException { - Log.d(TAG, "iglms47: " + var1); - } - - @Override - public void iglms48(NearbyAlertRequest var1, PlacesParams var2, PendingIntent var3) - throws RemoteException { - Log.d(TAG, "iglms48: " + var1); - } - - @Override - public void iglms49(PlacesParams var1, PendingIntent var2) throws RemoteException { - Log.d(TAG, "iglms49: " + var1); - } - - @Override - public void iglms50(UserDataType var1, LatLngBounds var2, List var3, PlacesParams var4, - IPlacesCallbacks var5) throws RemoteException { - Log.d(TAG, "iglms50: " + var1); - } - - @Override - public IBinder iglms51() throws RemoteException { - Log.d(TAG, "iglms51"); - return null; - } - - @Override - public void requestLocationSettingsDialog(LocationSettingsRequest settingsRequest, ISettingsCallbacks callback, String packageName) throws RemoteException { - Log.d(TAG, "requestLocationSettingsDialog: " + settingsRequest); - PackageUtils.getAndCheckCallingPackage(context, packageName); - callback.onLocationSettingsResult(new LocationSettingsResult(new LocationSettingsStates(true, true, false, true, true, false), Status.SUCCESS)); - } - - @Override - public void requestLocationUpdatesInternalWithListener(LocationRequestInternal request, - ILocationListener listener) throws RemoteException { - Log.d(TAG, "requestLocationUpdatesInternalWithListener: " + request); - getLocationManager().requestLocationUpdates(request.request, listener, PackageUtils.getCallingPackage(context)); - } - - @Override - public void requestLocationUpdatesInternalWithIntent(LocationRequestInternal request, - PendingIntent callbackIntent) throws RemoteException { - Log.d(TAG, "requestLocationUpdatesInternalWithIntent: " + request); - getLocationManager().requestLocationUpdates(request.request, callbackIntent, PackageUtils.packageFromPendingIntent(callbackIntent)); - } - - @Override - public IBinder iglms54() throws RemoteException { - Log.d(TAG, "iglms54"); - return null; - } - - @Override - public void iglms55(String var1, LatLngBounds var2, AutocompleteFilter var3, PlacesParams var4, - IPlacesCallbacks var5) throws RemoteException { - Log.d(TAG, "iglms55: " + var1); - } - - @Override - public void addGeofences(GeofencingRequest geofencingRequest, PendingIntent pendingIntent, - IGeofencerCallbacks callbacks) throws RemoteException { - Log.d(TAG, "addGeofences: " + geofencingRequest); - } - - @Override - public void iglms58(List var1, PlacesParams var2, IPlacesCallbacks var3) - throws RemoteException { - Log.d(TAG, "iglms58: " + var1); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/LocationChangeListener.java b/play-services-location-core/src/main/java/org/microg/gms/location/LocationChangeListener.java deleted file mode 100644 index f574746d..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/LocationChangeListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -public interface LocationChangeListener { - public void onLocationChanged(); -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/LocationRequestHelper.java b/play-services-location-core/src/main/java/org/microg/gms/location/LocationRequestHelper.java deleted file mode 100644 index ad67ae31..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/LocationRequestHelper.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.annotation.TargetApi; -import android.app.ActivityManager; -import android.app.AppOpsManager; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.location.Location; -import android.os.Binder; -import android.os.Build; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.location.ILocationCallback; -import com.google.android.gms.location.ILocationListener; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.LocationResult; -import com.google.android.gms.location.internal.LocationRequestUpdateData; - -import org.microg.gms.common.PackageUtils; - -import java.util.Arrays; -import java.util.List; - -import static android.Manifest.permission.ACCESS_BACKGROUND_LOCATION; -import static android.Manifest.permission.ACCESS_COARSE_LOCATION; -import static android.Manifest.permission.ACCESS_FINE_LOCATION; - -public class LocationRequestHelper { - public static final String TAG = "GmsLocRequestHelper"; - private final Context context; - public final LocationRequest locationRequest; - public final boolean initialHasFinePermission; - public final boolean initialHasCoarsePermission; - public final String packageName; - public final int uid; - private final boolean selfHasAppOpsRights; - public ILocationListener listener; - public PendingIntent pendingIntent; - public ILocationCallback callback; - - private Location lastReport; - private int numReports = 0; - - private LocationRequestHelper(Context context, LocationRequest locationRequest, String packageName, int uid) { - this.context = context; - this.locationRequest = locationRequest; - this.packageName = packageName; - this.uid = uid; - - this.initialHasFinePermission = context.getPackageManager().checkPermission(ACCESS_FINE_LOCATION, packageName) == PackageManager.PERMISSION_GRANTED; - this.initialHasCoarsePermission = context.getPackageManager().checkPermission(ACCESS_COARSE_LOCATION, packageName) == PackageManager.PERMISSION_GRANTED; - - this.selfHasAppOpsRights = context.getPackageManager().checkPermission("android.permission.UPDATE_APP_OPS_STATS", context.getPackageName()) == PackageManager.PERMISSION_GRANTED; - } - - public LocationRequestHelper(Context context, LocationRequest locationRequest, String packageName, int uid, ILocationListener listener) { - this(context, locationRequest, packageName, uid); - this.listener = listener; - } - - public LocationRequestHelper(Context context, LocationRequest locationRequest, String packageName, int uid, PendingIntent pendingIntent) { - this(context, locationRequest, packageName, uid); - this.pendingIntent = pendingIntent; - } - - public LocationRequestHelper(Context context, String packageName, int uid, LocationRequestUpdateData data) { - this(context, data.request.request, packageName, uid); - this.listener = data.listener; - this.pendingIntent = data.pendingIntent; - this.callback = data.callback; - } - - /** - * @return whether to continue sending reports to this {@link LocationRequestHelper} - */ - public boolean report(Location location) { - if (location == null) return true; - if (!hasCoarsePermission()) return false; - if (lastReport != null) { - if (location.getTime() - lastReport.getTime() < locationRequest.getFastestInterval()) { - return true; - } - if (location.distanceTo(lastReport) < locationRequest.getSmallestDesplacement()) { - return true; - } - } - lastReport = new Location(location); - lastReport.setProvider("fused"); - Log.d(TAG, "sending Location: " + location + " to " + packageName); - if (listener != null) { - try { - listener.onLocationChanged(lastReport); - } catch (RemoteException e) { - return false; - } - } else if (pendingIntent != null) { - Intent intent = new Intent(); - intent.putExtra("com.google.android.location.LOCATION", lastReport); - try { - pendingIntent.send(context, 0, intent); - } catch (PendingIntent.CanceledException e) { - return false; - } - } else if (callback != null) { - try { - callback.onLocationResult(LocationResult.create(Arrays.asList(lastReport))); - } catch (RemoteException e) { - return false; - } - } - numReports++; - return numReports < locationRequest.getNumUpdates(); - } - - @Override - public String toString() { - return "LocationRequestHelper{" + - "locationRequest=" + locationRequest + - ", hasFinePermission=" + hasFinePermission() + - ", hasCoarsePermission=" + hasCoarsePermission() + - ", packageName='" + packageName + '\'' + - ", lastReport=" + lastReport + - '}'; - } - - public boolean respondsTo(ILocationListener listener) { - return this.listener != null && listener != null && - this.listener.asBinder().equals(listener.asBinder()); - } - - public boolean respondsTo(ILocationCallback callback) { - return this.callback != null && callback != null && - this.callback.asBinder().equals(callback.asBinder()); - } - - public boolean respondsTo(PendingIntent pendingIntent) { - return this.pendingIntent != null && this.pendingIntent.equals(pendingIntent); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - LocationRequestHelper that = (LocationRequestHelper) o; - - if (!locationRequest.equals(that.locationRequest)) return false; - if (packageName != null ? !packageName.equals(that.packageName) : that.packageName != null) return false; - if (listener != null ? !listener.equals(that.listener) : that.listener != null) return false; - if (pendingIntent != null ? !pendingIntent.equals(that.pendingIntent) : that.pendingIntent != null) - return false; - return !(callback != null ? !callback.equals(that.callback) : that.callback != null); - } - - public boolean hasFinePermission() { - if (Build.VERSION.SDK_INT >= 19) { - return isAppOpsAllowed(AppOpsManager.OPSTR_FINE_LOCATION, initialHasFinePermission); - } else { - return initialHasFinePermission; - } - } - - public boolean hasCoarsePermission() { - if (Build.VERSION.SDK_INT >= 19) { - return isAppOpsAllowed(AppOpsManager.OPSTR_COARSE_LOCATION, initialHasCoarsePermission); - } else { - return initialHasCoarsePermission; - } - } - - @TargetApi(19) - private boolean isAppOpsAllowed(String op, boolean def) { - AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); - if (appOpsManager == null) return def; - try { - if (Binder.getCallingUid() == uid && Build.VERSION.SDK_INT >= 23) { - return appOpsManager.noteProxyOpNoThrow(op, packageName) == AppOpsManager.MODE_ALLOWED; - } else if (Build.VERSION.SDK_INT >= 29) { - return appOpsManager.noteProxyOpNoThrow(op, packageName, uid) == AppOpsManager.MODE_ALLOWED; - } else if (selfHasAppOpsRights) { - return appOpsManager.noteOpNoThrow(op, uid, packageName) == AppOpsManager.MODE_ALLOWED; - } else { - // TODO: More variant that works pre-29 and without perms? - Log.w(TAG, "Can't check appops (yet)"); - return def; - } - } catch (Exception e) { - Log.w(TAG, e); - return def; - } - } - - @Override - public int hashCode() { - int result = locationRequest.hashCode(); - result = 31 * result + (packageName != null ? packageName.hashCode() : 0); - result = 31 * result + (listener != null ? listener.hashCode() : 0); - result = 31 * result + (pendingIntent != null ? pendingIntent.hashCode() : 0); - result = 31 * result + (callback != null ? callback.hashCode() : 0); - return result; - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/MockLocationProvider.java b/play-services-location-core/src/main/java/org/microg/gms/location/MockLocationProvider.java deleted file mode 100644 index bdeb7318..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/MockLocationProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.location.Location; -import android.os.Bundle; - -import static org.microg.gms.location.LocationConstants.KEY_MOCK_LOCATION; - -public class MockLocationProvider { - private boolean mockEnabled = false; - private Location mockLocation = null; - private final LocationChangeListener changeListener; - - public MockLocationProvider(LocationChangeListener changeListener) { - this.changeListener = changeListener; - } - - public void setMockEnabled(boolean mockEnabled) { - this.mockEnabled = mockEnabled; - } - - public Location getLocation() { - return mockEnabled ? mockLocation : null; - } - - public void setLocation(Location mockLocation) { - if (mockLocation.getExtras() == null) { - mockLocation.setExtras(new Bundle()); - } - mockLocation.getExtras().putBoolean(KEY_MOCK_LOCATION, false); - this.mockLocation = mockLocation; - this.changeListener.onLocationChanged(); - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java b/play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java deleted file mode 100644 index 0ae75148..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.os.Bundle; -import android.os.Looper; -import android.util.Log; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -@SuppressWarnings("MissingPermission") -public class RealLocationProvider { - public static final String TAG = "GmsLocProviderReal"; - - private final LocationManager locationManager; - private final String name; - private final AtomicBoolean connected = new AtomicBoolean(false); - private final LocationChangeListener changeListener; - - private long connectedMinTime; - private float connectedMinDistance; - private Location lastLocation; - private final List requests = new ArrayList(); - private LocationListener listener = new LocationListener() { - @Override - public void onLocationChanged(Location location) { - lastLocation = location; - changeListener.onLocationChanged(); - } - - @Override - public void onStatusChanged(String s, int i, Bundle bundle) { - - } - - @Override - public void onProviderEnabled(String s) { - - } - - @Override - public void onProviderDisabled(String s) { - - } - }; - - public RealLocationProvider(LocationManager locationManager, String name, LocationChangeListener changeListener) { - this.locationManager = locationManager; - this.name = name; - this.changeListener = changeListener; - updateLastLocation(); - } - - private void updateLastLocation() { - Location newLocation = locationManager.getLastKnownLocation(name); - if (newLocation != null) lastLocation = newLocation; - } - - public Location getLastLocation() { - if (!connected.get()) { - updateLastLocation(); - } - if (lastLocation == null) { - Log.d(TAG, "uh-ok: last location for " + name + " is null!"); - } - return lastLocation; - } - - public void addRequest(LocationRequestHelper request) { - Log.d(TAG, name + ": addRequest " + request); - for (int i = 0; i < requests.size(); i++) { - LocationRequestHelper req = requests.get(i); - if (req.respondsTo(request.pendingIntent) || req.respondsTo(request.listener) || req.respondsTo(request.callback)) { - requests.remove(i); - i--; - } - } - requests.add(request); - updateConnection(); - } - - public void removeRequest(LocationRequestHelper request) { - Log.d(TAG, name + ": removeRequest " + request); - requests.remove(request); - updateConnection(); - } - - private synchronized void updateConnection() { - if (connected.get() && requests.isEmpty()) { - Log.d(TAG, name + ": no longer requesting location update"); - locationManager.removeUpdates(listener); - connected.set(false); - } else if (!requests.isEmpty()) { - long minTime = Long.MAX_VALUE; - float minDistance = Float.MAX_VALUE; - StringBuilder sb = new StringBuilder(); - for (LocationRequestHelper request : requests) { - minTime = Math.min(request.locationRequest.getInterval(), minTime); - minDistance = Math.min(request.locationRequest.getSmallestDesplacement(), minDistance); - if (sb.length() != 0) sb.append(", "); - sb.append(request.packageName).append(":").append(request.locationRequest.getInterval()).append("ms"); - } - Log.d(TAG, name + ": requesting location updates with interval " + minTime + "ms (" + sb + "), minDistance=" + minDistance); - if (connected.get()) { - if (connectedMinTime != minTime || connectedMinDistance != minDistance) { - locationManager.removeUpdates(listener); - locationManager.requestLocationUpdates(name, minTime, minDistance, listener, - Looper.getMainLooper()); - } - } else { - locationManager.requestLocationUpdates(name, minTime, minDistance, listener, Looper.getMainLooper()); - } - connected.set(true); - connectedMinTime = minTime; - connectedMinDistance = minDistance; - } - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/ReportingAndroidService.java b/play-services-location-core/src/main/java/org/microg/gms/location/ReportingAndroidService.java deleted file mode 100644 index d382cdcc..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/ReportingAndroidService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.os.RemoteException; - -import com.google.android.gms.common.internal.GetServiceRequest; -import com.google.android.gms.common.internal.IGmsCallbacks; - -import org.microg.gms.BaseService; -import org.microg.gms.common.GmsService; - -public class ReportingAndroidService extends BaseService { - private ReportingServiceImpl reportingService = new ReportingServiceImpl(); - - public ReportingAndroidService() { - super("GmsLocReportingSvc", GmsService.LOCATION_REPORTING); - } - - @Override - public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { - callback.onPostInitComplete(0, reportingService.asBinder(), null); - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/ReportingServiceImpl.java b/play-services-location-core/src/main/java/org/microg/gms/location/ReportingServiceImpl.java deleted file mode 100644 index c091cbde..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/ReportingServiceImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.accounts.Account; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.location.places.PlaceReport; -import com.google.android.gms.location.reporting.ReportingState; -import com.google.android.gms.location.reporting.UploadRequest; -import com.google.android.gms.location.reporting.UploadRequestResult; -import com.google.android.gms.location.reporting.internal.IReportingService; - -public class ReportingServiceImpl extends IReportingService.Stub { - private static final String TAG = "GmsLocReportSvcImpl"; - - @Override - public ReportingState getReportingState(Account account) throws RemoteException { - Log.d(TAG, "getReportingState"); - return new ReportingState(); - } - - @Override - public int tryOptIn(Account account) throws RemoteException { - Log.d(TAG, "tryOptIn"); - return 0; - } - - @Override - public UploadRequestResult requestUpload(UploadRequest request) throws RemoteException { - Log.d(TAG, "requestUpload"); - return new UploadRequestResult(); - } - - @Override - public int cancelUploadRequest(long l) throws RemoteException { - Log.d(TAG, "cancelUploadRequest"); - return 0; - } - - @Override - public int reportDeviceAtPlace(Account account, PlaceReport report) throws RemoteException { - Log.d(TAG, "reportDeviceAtPlace"); - return 0; - } -} diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/UnifiedLocationProvider.kt b/play-services-location-core/src/main/java/org/microg/gms/location/UnifiedLocationProvider.kt deleted file mode 100644 index 51cbfbf5..00000000 --- a/play-services-location-core/src/main/java/org/microg/gms/location/UnifiedLocationProvider.kt +++ /dev/null @@ -1,95 +0,0 @@ -package org.microg.gms.location - -import android.content.Context -import android.location.Location -import android.util.Log -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import org.microg.nlp.client.UnifiedLocationClient -import java.util.* -import java.util.concurrent.atomic.AtomicBoolean - -class UnifiedLocationProvider(context: Context?, changeListener: LocationChangeListener) { - private val client: UnifiedLocationClient - private var connectedMinTime: Long = 0 - private var lastLocation: Location? = null - private val connected = AtomicBoolean(false) - private val changeListener: LocationChangeListener - private val requests: MutableList = ArrayList() - private val listener: UnifiedLocationClient.LocationListener = object : UnifiedLocationClient.LocationListener { - override fun onLocation(location: Location) { - lastLocation = location - changeListener.onLocationChanged() - } - } - - private fun updateLastLocation() { - GlobalScope.launch { - client.getLastLocation()?.let { lastLocation = it } - } - } - - fun addRequest(request: LocationRequestHelper) { - Log.d(TAG, "unified network: addRequest $request") - for (i in 0..requests.size) { - if (i >= requests.size) break - val req = requests[i] - if (req.respondsTo(request.pendingIntent) || req.respondsTo(request.listener) || req.respondsTo(request.callback)) { - requests.removeAt(i) - } - } - requests.add(request) - updateConnection() - } - - fun removeRequest(request: LocationRequestHelper) { - Log.d(TAG, "unified network: removeRequest $request") - requests.remove(request) - updateConnection() - } - - fun getLastLocation(): Location? { - if (lastLocation == null) { - Log.d(TAG, "uh-ok: last location for unified network is null!") - } - return lastLocation - } - - @Synchronized - private fun updateConnection() { - if (connected.get() && requests.isEmpty()) { - Log.d(TAG, "unified network: no longer requesting location update") - client.removeLocationUpdates(listener) - connected.set(false) - } else if (!requests.isEmpty()) { - var minTime = Long.MAX_VALUE - val sb = StringBuilder() - var opPackageName: String? = null - for (request in requests) { - if (request.locationRequest.interval < minTime) { - opPackageName = request.packageName - minTime = request.locationRequest.interval - } - if (sb.isNotEmpty()) sb.append(", ") - sb.append("${request.packageName}:${request.locationRequest.interval}ms") - } - client.opPackageName = opPackageName - Log.d(TAG, "unified network: requesting location updates with interval ${minTime}ms ($sb)") - if (!connected.get() || connectedMinTime != minTime) { - client.requestLocationUpdates(listener, minTime) - } - connected.set(true) - connectedMinTime = minTime - } - } - - companion object { - const val TAG = "GmsLocProviderU" - } - - init { - client = UnifiedLocationClient[context!!] - this.changeListener = changeListener - updateLastLocation() - } -} \ No newline at end of file diff --git a/play-services-location/build.gradle b/play-services-location/build.gradle deleted file mode 100644 index a19126df..00000000 --- a/play-services-location/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2015 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.library' - -String getMyVersionName() { - def stdout = new ByteArrayOutputStream() - if (rootProject.file("gradlew").exists()) - exec { commandLine 'git', 'describe', '--tags', '--always', '--dirty'; standardOutput = stdout } - else // automatic build system, don't tag dirty - exec { commandLine 'git', 'describe', '--tags', '--always'; standardOutput = stdout } - return stdout.toString().trim().substring(1) -} - -android { - compileSdkVersion androidCompileSdk() - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName getMyVersionName() - minSdkVersion androidMinSdk() - targetSdkVersion androidTargetSdk() - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -dependencies { - api project(':play-services-base') - api project(':play-services-location-api') -} \ No newline at end of file diff --git a/play-services-location/gradle.properties b/play-services-location/gradle.properties deleted file mode 100644 index bfc9b4b2..00000000 --- a/play-services-location/gradle.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2013-2016 microG Project Team -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Play Services Cast Library -POM_DESCRIPTION=The Play Services Library module to access Google Location Services - -POM_PACKAGING=aar - -POM_URL=https://github.com/microg/android_external_GmsLib - -POM_SCM_URL=https://github.com/microg/android_external_GmsLib -POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git - -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=mar-v-in -POM_DEVELOPER_NAME=Marvin W - diff --git a/play-services-location/src/main/AndroidManifest.xml b/play-services-location/src/main/AndroidManifest.xml deleted file mode 100644 index 79e10fc2..00000000 --- a/play-services-location/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - diff --git a/play-services-location/src/main/java/com/google/android/gms/location/ActivityRecognition.java b/play-services-location/src/main/java/com/google/android/gms/location/ActivityRecognition.java deleted file mode 100644 index ef9d76c3..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/ActivityRecognition.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import com.google.android.gms.common.api.Api; -import com.google.android.gms.common.api.GoogleApiClient.Builder; - -import org.microg.gms.location.ActivityRecognitionApiBuilder; -import org.microg.gms.location.ActivityRecognitionApiImpl; - -/** - * The main entry point for activity recognition integration. - */ -public class ActivityRecognition { - public static final String CLIENT_NAME = "activity_recognition"; - - /** - * Token to pass to {@link Builder#addApi(Api)} to enable ContextServices. - */ - public static final Api API = new Api(new ActivityRecognitionApiBuilder()); - - /** - * Entry point to the activity recognition APIs. - */ - public static final ActivityRecognitionApi ActivityRecognitionApi = new ActivityRecognitionApiImpl(); -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/ActivityRecognitionApi.java b/play-services-location/src/main/java/com/google/android/gms/location/ActivityRecognitionApi.java deleted file mode 100644 index 08bc50b9..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/ActivityRecognitionApi.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.app.PendingIntent; -import android.os.Bundle; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; - -/** - * The main entry point for interacting with activity recognition. - *

- * The methods must be used in conjunction with a GoogleApiClient. E.g. - *

- *  new GoogleApiClient.Builder(context)
- *          .addApi(ActivityRecognition.API)
- *          .addConnectionCallbacks(this)
- *          .addOnConnectionFailedListener(this)
- *          .build()
- * 
- */ -public interface ActivityRecognitionApi { - /** - * Removes all activity updates for the specified PendingIntent. - *

- * Calling this function requires the com.google.android.gms.permission.ACTIVITY_RECOGNITION - * permission. - * - * @param client An existing GoogleApiClient. It must be connected at the time of this - * call, which is normally achieved by calling {@link GoogleApiClient#connect()} - * and waiting for {@link ConnectionCallbacks#onConnected(Bundle)} to be - * called. - * @param callbackIntent the PendingIntent that was used in {@code #requestActivityUpdates(GoogleApiClient, long, PendingIntent)} - * or is equal as defined by {@link Object#equals(Object)}. - * @return a PendingResult for the call, check {@link Status#isSuccess()} to determine if it - * was successful. - */ - PendingResult removeActivityUpdates(GoogleApiClient client, PendingIntent callbackIntent); - - /** - * Register for activity recognition updates. - *

- * The activities are detected by periodically waking up the device and reading short bursts of - * sensor data. It only makes use of low power sensors in order to keep the power usage to a - * minimum. For example, it can detect if the user is currently on foot, in a car, on a bicycle - * or still. See {@link DetectedActivity} for more details. - *

- * The activity detection update interval can be controlled with the detectionIntervalMillis - * parameter. Larger values will result in fewer activity detections while improving battery - * life. Smaller values will result in more frequent activity detections but will consume more - * power since the device must be woken up more frequently. {@code Long.MAX_VALUE} means it only - * monitors the results requested by other clients without consuming additional power. - *

- * Activities may be received more frequently than the detectionIntervalMillis parameter if - * another application has also requested activity updates at a faster rate. It may also receive - * updates faster when the activity detection service receives a signal that the current - * activity may change, such as if the device has been still for a long period of time and is - * then unplugged from a phone charger. - *

- * Activities may arrive several seconds after the requested detectionIntervalMillis if the - * activity detection service requires more samples to make a more accurate prediction. - *

- * To conserve battery, activity reporting may stop when the device is 'STILL' for an extended - * period of time. It will resume once the device moves again. This only happens on devices that - * support the Sensor.TYPE_SIGNIFICANT_MOTION hardware. - *

- * Beginning in API 21, activities may be received less frequently than the - * detectionIntervalMillis parameter if the device is in power save mode and the screen is off. - *

- * A common use case is that an application wants to monitor activities in the background and - * perform an action when a specific activity is detected. To do this without needing a service - * that is always on in the background consuming resources, detected activities are delivered - * via an intent. The application specifies a PendingIntent callback (typically an - * IntentService) which will be called with an intent when activities are detected. The intent - * recipient can extract the {@link ActivityRecognitionResult} using {@link ActivityRecognitionResult#extractResult(android.content.Intent)}. - * See the documentation of {@link PendingIntent} for more details. - *

- * Any requests previously registered with {@link #requestActivityUpdates(GoogleApiClient, long, PendingIntent)} - * that have the same PendingIntent (as defined by {@link Object#equals(Object)}) will be - * replaced by this request. - *

- * Calling this function requires the com.google.android.gms.permission.ACTIVITY_RECOGNITION - * permission. - * - * @param client An existing GoogleApiClient. It must be connected at the time - * of this call, which is normally achieved by calling {@link GoogleApiClient#connect()} - * and waiting for {@link ConnectionCallbacks#onConnected(Bundle)} - * to be called. - * @param detectionIntervalMillis the desired time between activity detections. Larger values - * will result in fewer activity detections while improving - * battery life. A value of 0 will result in activity detections - * at the fastest possible rate. - * @param callbackIntent a PendingIntent to be sent for each activity detection. - * @return a PendingResult for the call, check {@link Status#isSuccess()} to determine if it - * was successful. - */ - PendingResult requestActivityUpdates(GoogleApiClient client, long detectionIntervalMillis, PendingIntent callbackIntent); -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/FusedLocationProviderApi.java b/play-services-location/src/main/java/com/google/android/gms/location/FusedLocationProviderApi.java deleted file mode 100644 index 768111b5..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/FusedLocationProviderApi.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.app.PendingIntent; -import android.location.Location; -import android.os.Looper; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; - -import org.microg.gms.location.LocationConstants; - -public interface FusedLocationProviderApi { - @Deprecated - String KEY_LOCATION_CHANGED = "com.google.android.location.LOCATION"; - String KEY_MOCK_LOCATION = LocationConstants.KEY_MOCK_LOCATION; - - Location getLastLocation(GoogleApiClient client); - - PendingResult requestLocationUpdates(GoogleApiClient client, LocationRequest request, - LocationListener listener); - - PendingResult requestLocationUpdates(GoogleApiClient client, LocationRequest request, - LocationListener listener, Looper looper); - - PendingResult requestLocationUpdates(GoogleApiClient client, LocationRequest request, - PendingIntent callbackIntent); - - PendingResult removeLocationUpdates(GoogleApiClient client, LocationListener listener); - - PendingResult removeLocationUpdates(GoogleApiClient client, - PendingIntent callbackIntent); - - PendingResult setMockMode(GoogleApiClient client, boolean isMockMode); - - PendingResult setMockLocation(GoogleApiClient client, Location mockLocation); -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/GeofencingApi.java b/play-services-location/src/main/java/com/google/android/gms/location/GeofencingApi.java deleted file mode 100644 index 784c5c3e..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/GeofencingApi.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.app.PendingIntent; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; - -import java.util.List; - -/** - * The main entry point for interacting with the geofencing APIs. - *

- * The methods must be used in conjunction with a GoogleApiClient. E.g. - *

- *  new GoogleApiClient.Builder(context)
- *          .addApi(LocationServices.API)
- *          .addConnectionCallbacks(this)
- *          .addOnConnectionFailedListener(this)
- *          .build()
- * 
- */ -public interface GeofencingApi { - PendingResult addGeofences(GoogleApiClient client, GeofencingRequest geofencingRequest, PendingIntent pendingIntent); - - @Deprecated - PendingResult addGeofences(GoogleApiClient client, List geofences, PendingIntent pendingIntent); - - PendingResult removeGeofences(GoogleApiClient client, List geofenceRequestIds); - - PendingResult removeGeofences(GoogleApiClient client, PendingIntent pendingIntent); -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/LocationClient.java b/play-services-location/src/main/java/com/google/android/gms/location/LocationClient.java deleted file mode 100644 index 47ec9568..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/LocationClient.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.app.PendingIntent; -import android.content.Context; -import android.location.Location; -import android.os.Looper; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; - -import org.microg.gms.common.ForwardConnectionCallbacks; -import org.microg.gms.common.ForwardConnectionFailedListener; -import org.microg.gms.common.api.AbstractPlayServicesClient; - -/** - * This class is deprecated as of play services 6.5, do not use it in production systems, - * it's just a forwarder for the {@link FusedLocationProviderApi}. - */ -@Deprecated -public class LocationClient extends AbstractPlayServicesClient { - public static final String KEY_LOCATION_CHANGED = "com.google.android.location.LOCATION"; - - public LocationClient(Context context, ConnectionCallbacks callbacks, - OnConnectionFailedListener connectionFailedListener) { - super(new GoogleApiClient.Builder(context) - .addApi(LocationServices.API) - .addConnectionCallbacks(new ForwardConnectionCallbacks(callbacks)) - .addOnConnectionFailedListener(new ForwardConnectionFailedListener - (connectionFailedListener)) - .build()); - } - - public Location getLastLocation() { - assertConnected(); - return LocationServices.FusedLocationApi.getLastLocation(googleApiClient); - } - - public void requestLocationUpdates(LocationRequest request, - LocationListener listener) { - assertConnected(); - LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, - listener).await(); - } - - public void requestLocationUpdates(LocationRequest request, - LocationListener listener, Looper looper) { - assertConnected(); - LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, - listener, looper).await(); - } - - public void requestLocationUpdates(LocationRequest request, - PendingIntent callbackIntent) { - assertConnected(); - LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, - callbackIntent).await(); - } - - public void removeLocationUpdates(LocationListener listener) { - assertConnected(); - LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, listener).await(); - } - - public void removeLocationUpdates(PendingIntent callbackIntent) { - assertConnected(); - LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, - callbackIntent).await(); - } - - public void setMockMode(boolean isMockMode) { - assertConnected(); - LocationServices.FusedLocationApi.setMockMode(googleApiClient, isMockMode).await(); - } - - public void setMockLocation(Location mockLocation) { - assertConnected(); - LocationServices.FusedLocationApi.setMockLocation(googleApiClient, mockLocation).await(); - } -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/LocationListener.java b/play-services-location/src/main/java/com/google/android/gms/location/LocationListener.java deleted file mode 100644 index 59c9585c..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/LocationListener.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import android.location.Location; - -/** - * Used for receiving notifications from the {@link FusedLocationProviderApi} when the location has - * changed. The methods are called if the LocationListener has been registered with the location - * client. - */ -public interface LocationListener { - - /** - * Called when the location has changed. - * - * @param location The updated location. - */ - public void onLocationChanged(Location location); -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/LocationServices.java b/play-services-location/src/main/java/com/google/android/gms/location/LocationServices.java deleted file mode 100644 index 839550f4..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/LocationServices.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import com.google.android.gms.common.api.Api; -import com.google.android.gms.common.api.GoogleApiClient.Builder; - -import org.microg.gms.location.FusedLocationProviderApiImpl; -import org.microg.gms.location.GeofencingApiImpl; -import org.microg.gms.location.LocationServicesApiBuilder; -import org.microg.gms.location.SettingsApiImpl; - -/** - * The main entry point for location services integration. - */ -public class LocationServices { - /** - * Token to pass to {@link Builder#addApi(Api)} to enable LocationServices. - */ - public static final Api API = new Api(new LocationServicesApiBuilder()); - - /** - * Entry point to the fused location APIs. - */ - public static final FusedLocationProviderApi FusedLocationApi = new FusedLocationProviderApiImpl(); - - /** - * Entry point to the geofencing APIs. - */ - public static final GeofencingApi GeofencingApi = new GeofencingApiImpl(); - - /** - * Entry point to the location settings-enabler dialog APIs. - */ - public static final SettingsApi SettingsApi = new SettingsApiImpl(); -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/LocationStatusCodes.java b/play-services-location/src/main/java/com/google/android/gms/location/LocationStatusCodes.java deleted file mode 100644 index 4e3f7d54..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/LocationStatusCodes.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -@Deprecated -public class LocationStatusCodes { - public static final int ERROR = 1; - public static final int GEOFENCE_NOT_AVAILABLE = 1000; - public static final int GEOFENCE_TOO_MANY_GEOFENCES = 1001; - public static final int GEOFENCE_TOO_MANY_PENDING_INTENTS = 1002; - public static final int SUCCESS = 0; -} diff --git a/play-services-location/src/main/java/com/google/android/gms/location/SettingsApi.java b/play-services-location/src/main/java/com/google/android/gms/location/SettingsApi.java deleted file mode 100644 index 708d7d02..00000000 --- a/play-services-location/src/main/java/com/google/android/gms/location/SettingsApi.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.location; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; - -/** - * The main entry point for interacting with the location settings-enabler APIs. - *

- * This API makes it easy for an app to ensure that the device's system settings are properly - * configured for the app's location needs. - */ -public interface SettingsApi { - /** - * Checks if the relevant system settings are enabled on the device to carry out the desired - * location requests. - * - * @param client an existing GoogleApiClient. It does not need to be connected - * at the time of this call, but the result will be delayed until - * the connection is complete. - * @param locationSettingsRequest an object that contains all the location requirements that the - * client is interested in. - * @return result containing the status of the request. - */ - PendingResult checkLocationSettings(GoogleApiClient client, LocationSettingsRequest locationSettingsRequest); -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionApiBuilder.java b/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionApiBuilder.java deleted file mode 100644 index f36ed0c0..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionApiBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.content.Context; -import android.os.Looper; - -import com.google.android.gms.common.api.AccountInfo; -import com.google.android.gms.common.api.Api; -import com.google.android.gms.common.api.GoogleApiClient; - -import org.microg.gms.common.api.ApiBuilder; -import org.microg.gms.common.api.ApiConnection; - -public class ActivityRecognitionApiBuilder implements ApiBuilder { - @Override - public ApiConnection build(Context context, Looper looper, Api.ApiOptions.NoOptions options, AccountInfo accountInfo, GoogleApiClient.ConnectionCallbacks callbacks, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { - return new ActivityRecognitionClientImpl(context, callbacks, connectionFailedListener); - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionApiImpl.java b/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionApiImpl.java deleted file mode 100644 index 5c09eefd..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionApiImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.app.PendingIntent; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.ActivityRecognition; -import com.google.android.gms.location.ActivityRecognitionApi; - -import org.microg.gms.common.GmsConnector; - -public class ActivityRecognitionApiImpl implements ActivityRecognitionApi { - private static final String TAG = "GmsActivityApiImpl"; - - @Override - public PendingResult removeActivityUpdates(GoogleApiClient client, final PendingIntent callbackIntent) { - return callVoid(client, new Runnable() { - @Override - public void run(ActivityRecognitionClientImpl client) throws RemoteException { - client.removeActivityUpdates(callbackIntent); - } - }); - } - - @Override - public PendingResult requestActivityUpdates(GoogleApiClient client, final long detectionIntervalMillis, final PendingIntent callbackIntent) { - return callVoid(client, new Runnable() { - @Override - public void run(ActivityRecognitionClientImpl client) throws RemoteException { - client.requestActivityUpdates(detectionIntervalMillis, callbackIntent); - } - }); - } - - private PendingResult callVoid(GoogleApiClient client, final Runnable runnable) { - return GmsConnector.call(client, ActivityRecognition.API, new GmsConnector.Callback() { - @Override - public void onClientAvailable(ActivityRecognitionClientImpl client, ResultProvider resultProvider) throws RemoteException { - runnable.run(client); - resultProvider.onResultAvailable(Status.SUCCESS); - } - }); - } - - private interface Runnable { - void run(ActivityRecognitionClientImpl client) throws RemoteException; - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionClientImpl.java b/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionClientImpl.java deleted file mode 100644 index cf065fc9..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/ActivityRecognitionClientImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.app.PendingIntent; -import android.content.Context; -import android.os.RemoteException; - -import com.google.android.gms.common.api.GoogleApiClient; - -public class ActivityRecognitionClientImpl extends GoogleLocationManagerClient { - public ActivityRecognitionClientImpl(Context context, GoogleApiClient.ConnectionCallbacks callbacks, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { - super(context, callbacks, connectionFailedListener); - } - - public void requestActivityUpdates(long detectionIntervalMillis, PendingIntent callbackIntent) throws RemoteException { - getServiceInterface().requestActivityUpdates(detectionIntervalMillis, true, callbackIntent); - } - - public void removeActivityUpdates(PendingIntent callbackIntent) throws RemoteException { - getServiceInterface().removeActivityUpdates(callbackIntent); - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/FusedLocationProviderApiImpl.java b/play-services-location/src/main/java/org/microg/gms/location/FusedLocationProviderApiImpl.java deleted file mode 100644 index 0069974c..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/FusedLocationProviderApiImpl.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.app.PendingIntent; -import android.location.Location; -import android.os.Looper; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.FusedLocationProviderApi; -import com.google.android.gms.location.LocationListener; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.LocationServices; - -import org.microg.gms.common.GmsConnector; -import org.microg.gms.common.api.ApiConnection; - -public class FusedLocationProviderApiImpl implements FusedLocationProviderApi { - private static final String TAG = "GmsFusedApiImpl"; - - @Override - public Location getLastLocation(GoogleApiClient client) { - try { - Log.d(TAG, "getLastLocation(" + client + ")"); - return LocationClientImpl.get(client).getLastLocation(); - } catch (RemoteException e) { - Log.w(TAG, e); - return null; - } - } - - @Override - public PendingResult requestLocationUpdates(GoogleApiClient client, - final LocationRequest request, final LocationListener listener) { - return callVoid(client, new Runnable() { - @Override - public void run(LocationClientImpl client) throws RemoteException { - client.requestLocationUpdates(request, listener); - } - }); - } - - @Override - public PendingResult requestLocationUpdates(GoogleApiClient client, - final LocationRequest request, final LocationListener listener, - final Looper looper) { - return callVoid(client, new Runnable() { - @Override - public void run(LocationClientImpl client) throws RemoteException { - client.requestLocationUpdates(request, listener, looper); - } - }); - } - - @Override - public PendingResult requestLocationUpdates(GoogleApiClient client, - final LocationRequest request, final PendingIntent callbackIntent) { - return callVoid(client, new Runnable() { - @Override - public void run(LocationClientImpl client) throws RemoteException { - client.requestLocationUpdates(request, callbackIntent); - } - }); - } - - @Override - public PendingResult removeLocationUpdates(GoogleApiClient client, - final LocationListener listener) { - return callVoid(client, new Runnable() { - @Override - public void run(LocationClientImpl client) throws RemoteException { - client.removeLocationUpdates(listener); - } - }); - } - - @Override - public PendingResult removeLocationUpdates(GoogleApiClient client, - final PendingIntent callbackIntent) { - return callVoid(client, new Runnable() { - @Override - public void run(LocationClientImpl client) throws RemoteException { - client.removeLocationUpdates(callbackIntent); - } - }); - } - - @Override - public PendingResult setMockMode(GoogleApiClient client, final boolean isMockMode) { - return callVoid(client, new Runnable() { - @Override - public void run(LocationClientImpl client) throws RemoteException { - client.setMockMode(isMockMode); - } - }); - } - - @Override - public PendingResult setMockLocation(GoogleApiClient client, final Location mockLocation) { - return callVoid(client, new Runnable() { - @Override - public void run(LocationClientImpl client) throws RemoteException { - client.setMockLocation(mockLocation); - } - }); - } - - private PendingResult callVoid(GoogleApiClient client, final Runnable runnable) { - return GmsConnector.call(client, LocationServices.API, new GmsConnector.Callback() { - @Override - public void onClientAvailable(LocationClientImpl client, ResultProvider resultProvider) throws RemoteException { - runnable.run(client); - resultProvider.onResultAvailable(Status.SUCCESS); - } - }); - } - - private interface Runnable { - void run(LocationClientImpl client) throws RemoteException; - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/GeofencingApiImpl.java b/play-services-location/src/main/java/org/microg/gms/location/GeofencingApiImpl.java deleted file mode 100644 index aed9276d..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/GeofencingApiImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.app.PendingIntent; -import android.os.RemoteException; -import android.support.annotation.NonNull; -import android.util.Log; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.Geofence; -import com.google.android.gms.location.GeofencingApi; -import com.google.android.gms.location.GeofencingRequest; -import com.google.android.gms.location.LocationServices; -import com.google.android.gms.location.internal.IGeofencerCallbacks; -import com.google.android.gms.location.internal.ParcelableGeofence; - -import org.microg.gms.common.GmsConnector; - -import java.util.ArrayList; -import java.util.List; - -public class GeofencingApiImpl implements GeofencingApi { - @Override - public PendingResult addGeofences(GoogleApiClient client, final GeofencingRequest geofencingRequest, final PendingIntent pendingIntent) { - return callGeofencer(client, new Runnable() { - @Override - public void run(LocationClientImpl client, IGeofencerCallbacks callbacks) throws RemoteException { - client.addGeofences(geofencingRequest, pendingIntent, callbacks); - } - }); - } - - @Override - public PendingResult addGeofences(GoogleApiClient client, final List geofences, final PendingIntent pendingIntent) { - final List geofenceList = new ArrayList(); - for (Geofence geofence : geofences) { - if (geofence instanceof ParcelableGeofence) geofenceList.add((ParcelableGeofence) geofence); - } - return callGeofencer(client, new Runnable() { - @Override - public void run(LocationClientImpl client, IGeofencerCallbacks callbacks) throws RemoteException { - client.addGeofences(geofenceList, pendingIntent, callbacks); - } - }); - } - - @Override - public PendingResult removeGeofences(GoogleApiClient client, final List geofenceRequestIds) { - return callGeofencer(client, new Runnable() { - @Override - public void run(LocationClientImpl client, IGeofencerCallbacks callbacks) throws RemoteException { - client.removeGeofences(geofenceRequestIds, callbacks); - } - }); - } - - @Override - public PendingResult removeGeofences(GoogleApiClient client, final PendingIntent pendingIntent) { - return callGeofencer(client, new Runnable() { - @Override - public void run(LocationClientImpl client, IGeofencerCallbacks callbacks) throws RemoteException { - client.removeGeofences(pendingIntent, callbacks); - } - }); - } - - @NonNull - private IGeofencerCallbacks.Stub createGeofencerCallbacks(final GmsConnector.Callback.ResultProvider resultProvider) { - return new IGeofencerCallbacks.Stub(){ - @Override - public void onAddGeofenceResult(int statusCode, String[] requestIds) throws RemoteException { - resultProvider.onResultAvailable(new Status(statusCode)); - } - - @Override - public void onRemoveGeofencesByRequestIdsResult(int statusCode, String[] requestIds) throws RemoteException { - resultProvider.onResultAvailable(new Status(statusCode)); - } - - @Override - public void onRemoveGeofencesByPendingIntentResult(int statusCode, PendingIntent pendingIntent) throws RemoteException { - resultProvider.onResultAvailable(new Status(statusCode)); - } - }; - } - - private PendingResult callGeofencer(GoogleApiClient client, final Runnable runnable) { - return GmsConnector.call(client, LocationServices.API, new GmsConnector.Callback() { - @Override - public void onClientAvailable(LocationClientImpl client, ResultProvider resultProvider) throws RemoteException { - runnable.run(client, createGeofencerCallbacks(resultProvider)); - } - }); - } - - private interface Runnable { - void run(LocationClientImpl client, IGeofencerCallbacks callbacks) throws RemoteException; - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/GoogleLocationManagerClient.java b/play-services-location/src/main/java/org/microg/gms/location/GoogleLocationManagerClient.java deleted file mode 100644 index 55d0fae9..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/GoogleLocationManagerClient.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.content.Context; -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.internal.IGmsServiceBroker; -import com.google.android.gms.location.internal.IGoogleLocationManagerService; - -import org.microg.gms.common.Constants; -import org.microg.gms.common.GmsClient; -import org.microg.gms.common.GmsService; - -public abstract class GoogleLocationManagerClient extends GmsClient { - public GoogleLocationManagerClient(Context context, GoogleApiClient.ConnectionCallbacks - callbacks, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { - super(context, callbacks, connectionFailedListener, GmsService.LOCATION_MANAGER.ACTION); - } - - @Override - protected IGoogleLocationManagerService interfaceFromBinder(IBinder binder) { - return IGoogleLocationManagerService.Stub.asInterface(binder); - } - - @Override - protected void onConnectedToBroker(IGmsServiceBroker broker, GmsCallbacks callbacks) - throws RemoteException { - Bundle bundle = new Bundle(); - bundle.putString("client_name", "locationServices"); - broker.getGoogleLocationManagerService(callbacks, Constants.MAX_REFERENCE_VERSION, - getContext().getPackageName(), bundle); - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/LocationClientImpl.java b/play-services-location/src/main/java/org/microg/gms/location/LocationClientImpl.java deleted file mode 100644 index bc161d13..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/LocationClientImpl.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.app.PendingIntent; -import android.content.Context; -import android.location.Location; -import android.os.Bundle; -import android.os.Looper; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.location.GeofencingRequest; -import com.google.android.gms.location.ILocationListener; -import com.google.android.gms.location.LocationListener; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.LocationServices; -import com.google.android.gms.location.internal.IGeofencerCallbacks; -import com.google.android.gms.location.internal.ParcelableGeofence; - -import org.microg.gms.common.api.GoogleApiClientImpl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class LocationClientImpl extends GoogleLocationManagerClient { - private static final String TAG = "GmsLocationClientImpl"; - private NativeLocationClientImpl nativeLocation = null; - private Map listenerMap = new HashMap(); - - - public LocationClientImpl(Context context, GoogleApiClient.ConnectionCallbacks callbacks, - GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { - super(context, callbacks, connectionFailedListener); - Log.d(TAG, ""); - } - - public static LocationClientImpl get(GoogleApiClient apiClient) { - if (apiClient instanceof GoogleApiClientImpl) { - return (LocationClientImpl) ((GoogleApiClientImpl) apiClient) - .getApiConnection(LocationServices.API); - } - return null; - } - - public void addGeofences(GeofencingRequest request, PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.addGeofences(request, pendingIntent, callbacks); - } else { - getServiceInterface().addGeofences(request, pendingIntent, callbacks); - } - } - - public void addGeofences(List request, PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.addGeofences(request, pendingIntent, callbacks); - } else { - getServiceInterface().addGeofencesList(request, pendingIntent, callbacks, getContext().getPackageName()); - } - } - - public void removeGeofences(List geofenceRequestIds, IGeofencerCallbacks callbacks) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.removeGeofences(geofenceRequestIds, callbacks); - } else { - getServiceInterface().removeGeofencesById(geofenceRequestIds.toArray(new String[geofenceRequestIds.size()]), callbacks, getContext().getPackageName()); - } - } - - public void removeGeofences(PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.removeGeofences(pendingIntent, callbacks); - } else { - getServiceInterface().removeGeofencesByIntent(pendingIntent, callbacks, getContext().getPackageName()); - } - } - - public Location getLastLocation() throws RemoteException { - Log.d(TAG, "getLastLocation()"); - if (nativeLocation != null) { - return nativeLocation.getLastLocation(); - } else { - return getServiceInterface().getLastLocation(); - } - } - - public void requestLocationUpdates(LocationRequest request, final LocationListener listener) - throws RemoteException { - if (nativeLocation != null) { - nativeLocation.requestLocationUpdates(request, listener); - } else { - if (!listenerMap.containsKey(listener)) { - listenerMap.put(listener, new ILocationListener.Stub() { - @Override - public void onLocationChanged(Location location) throws RemoteException { - listener.onLocationChanged(location); - } - }); - } - getServiceInterface().requestLocationUpdatesWithPackage(request, - listenerMap.get(listener), getContext().getPackageName()); - } - } - - public void requestLocationUpdates(LocationRequest request, PendingIntent pendingIntent) - throws RemoteException { - if (nativeLocation != null) { - nativeLocation.requestLocationUpdates(request, pendingIntent); - } else { - getServiceInterface().requestLocationUpdatesWithIntent(request, pendingIntent); - } - } - - public void requestLocationUpdates(LocationRequest request, LocationListener listener, - Looper looper) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.requestLocationUpdates(request, listener, looper); - } - requestLocationUpdates(request, listener); // TODO - } - - public void removeLocationUpdates(LocationListener listener) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.removeLocationUpdates(listener); - } else { - getServiceInterface().removeLocationUpdatesWithListener(listenerMap.get(listener)); - } - } - - public void removeLocationUpdates(PendingIntent pendingIntent) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.removeLocationUpdates(pendingIntent); - } else { - getServiceInterface().removeLocationUpdatesWithIntent(pendingIntent); - } - } - - public void setMockMode(boolean isMockMode) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.setMockMode(isMockMode); - } else { - getServiceInterface().setMockMode(isMockMode); - } - } - - public void setMockLocation(Location mockLocation) throws RemoteException { - if (nativeLocation != null) { - nativeLocation.setMockLocation(mockLocation); - } else { - getServiceInterface().setMockLocation(mockLocation); - } - } - - @Override - public void handleConnectionFailed() { - // DO NOT call super here, because fails are not really problems :) - nativeLocation = new NativeLocationClientImpl(this); - state = ConnectionState.PSEUDO_CONNECTED; - Bundle bundle = new Bundle(); - bundle.putBoolean("fallback_to_native_active", true); - callbacks.onConnected(bundle); - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/LocationServicesApiBuilder.java b/play-services-location/src/main/java/org/microg/gms/location/LocationServicesApiBuilder.java deleted file mode 100644 index 2e053a81..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/LocationServicesApiBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.content.Context; -import android.os.Looper; - -import com.google.android.gms.common.api.AccountInfo; -import com.google.android.gms.common.api.Api; -import com.google.android.gms.common.api.GoogleApiClient; - -import org.microg.gms.common.api.ApiBuilder; -import org.microg.gms.common.api.ApiConnection; - -public class LocationServicesApiBuilder implements ApiBuilder { - @Override - public ApiConnection build(Context context, Looper looper, - Api.ApiOptions.NoOptions options, - AccountInfo accountInfo, GoogleApiClient.ConnectionCallbacks callbacks, - GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { - return new LocationClientImpl(context, callbacks, connectionFailedListener); - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/NativeLocationClientImpl.java b/play-services-location/src/main/java/org/microg/gms/location/NativeLocationClientImpl.java deleted file mode 100644 index 17a017d9..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/NativeLocationClientImpl.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.location.Criteria; -import android.location.Location; -import android.location.LocationManager; -import android.os.Bundle; -import android.os.Looper; -import android.os.RemoteException; -import android.os.SystemClock; -import android.util.Log; - -import com.google.android.gms.common.api.CommonStatusCodes; -import com.google.android.gms.location.FusedLocationProviderApi; -import com.google.android.gms.location.Geofence; -import com.google.android.gms.location.GeofenceStatusCodes; -import com.google.android.gms.location.GeofencingEvent; -import com.google.android.gms.location.GeofencingRequest; -import com.google.android.gms.location.LocationListener; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.internal.IGeofencerCallbacks; -import com.google.android.gms.location.internal.ParcelableGeofence; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static android.location.LocationManager.KEY_LOCATION_CHANGED; -import static android.location.LocationManager.KEY_PROXIMITY_ENTERING; - -@SuppressWarnings("MissingPermission") -public class NativeLocationClientImpl { - private final static String TAG = "GmsToNativeLocClient"; - private final static Criteria DEFAULT_CRITERIA = new Criteria(); - private final static Map pendingCount = new HashMap(); - private final static Map nativePendingMap = new HashMap(); - private static final String EXTRA_PENDING_INTENT = "pending_intent"; - - private final Context context; - private final LocationManager locationManager; - private final Map nativeListenerMap = new HashMap(); - - public NativeLocationClientImpl(LocationClientImpl client) { - context = client.getContext(); - locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - } - - private static Criteria makeNativeCriteria(LocationRequest request) { - Criteria criteria = new Criteria(); - switch (request.getPriority()) { - case LocationRequest.PRIORITY_HIGH_ACCURACY: - criteria.setAccuracy(Criteria.ACCURACY_FINE); - criteria.setPowerRequirement(Criteria.POWER_HIGH); - break; - case LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY: - default: - criteria.setAccuracy(Criteria.ACCURACY_COARSE); - criteria.setPowerRequirement(Criteria.POWER_MEDIUM); - break; - case LocationRequest.PRIORITY_NO_POWER: - case LocationRequest.PRIORITY_LOW_POWER: - criteria.setAccuracy(Criteria.ACCURACY_COARSE); - criteria.setPowerRequirement(Criteria.POWER_LOW); - } - return criteria; - } - - public void addGeofences(GeofencingRequest geofencingRequest, PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { - Log.d(TAG, "addGeofences(GeofencingRequest)"); - callbacks.onAddGeofenceResult(GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE, new String[0]); - } - - public void addGeofences(List geofences, PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { - Log.d(TAG, "addGeofences(List)"); - Intent i = new Intent(context, NativePendingIntentForwarder.class); - Bundle bundle = new Bundle(); - bundle.putParcelable(EXTRA_PENDING_INTENT, pendingIntent); - i.putExtras(bundle); - nativePendingMap.put(pendingIntent, PendingIntent.getActivity(context, 0, i, 0)); - List requestIds = new ArrayList(); - for (ParcelableGeofence geofence : geofences) { - locationManager.addProximityAlert(geofence.latitude, geofence.longitude, geofence.radius, - geofence.expirationTime - SystemClock.elapsedRealtime(), nativePendingMap.get(pendingIntent)); - requestIds.add(geofence.getRequestId()); - } - callbacks.onAddGeofenceResult(CommonStatusCodes.SUCCESS, requestIds.toArray(new String[requestIds.size()])); - } - - public void removeGeofences(List requestIds, IGeofencerCallbacks callbacks) throws RemoteException { - Log.d(TAG, "removeGeofences(List)"); - callbacks.onRemoveGeofencesByRequestIdsResult(GeofenceStatusCodes.ERROR, requestIds.toArray(new String[requestIds.size()])); - } - - public void removeGeofences(PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { - Log.d(TAG, "removeGeofences(PendingIntent)"); - locationManager.removeProximityAlert(nativePendingMap.get(pendingIntent)); - nativePendingMap.remove(pendingIntent); - callbacks.onRemoveGeofencesByPendingIntentResult(CommonStatusCodes.SUCCESS, pendingIntent); - } - - public Location getLastLocation() { - Log.d(TAG, "getLastLocation()"); - return locationManager.getLastKnownLocation(locationManager.getBestProvider(DEFAULT_CRITERIA, true)); - } - - public void requestLocationUpdates(LocationRequest request, LocationListener listener) { - requestLocationUpdates(request, listener, Looper.getMainLooper()); - } - - public void requestLocationUpdates(LocationRequest request, PendingIntent pendingIntent) { - Log.d(TAG, "requestLocationUpdates()"); - Intent i = new Intent(context, NativePendingIntentForwarder.class); - Bundle bundle = new Bundle(); - bundle.putParcelable(EXTRA_PENDING_INTENT, pendingIntent); - i.putExtras(bundle); - pendingCount.put(pendingIntent, request.getNumUpdates()); - nativePendingMap.put(pendingIntent, PendingIntent.getActivity(context, 0, i, 0)); - locationManager.requestLocationUpdates(request.getInterval(), request.getSmallestDesplacement(), - makeNativeCriteria(request), nativePendingMap.get(pendingIntent)); - } - - public void requestLocationUpdates(LocationRequest request, LocationListener listener, Looper - looper) { - Log.d(TAG, "requestLocationUpdates()"); - if (nativeListenerMap.containsKey(listener)) { - removeLocationUpdates(listener); - } - nativeListenerMap.put(listener, new NativeListener(listener, request.getNumUpdates())); - locationManager.requestLocationUpdates(request.getInterval(), - request.getSmallestDesplacement(), makeNativeCriteria(request), - nativeListenerMap.get(listener), looper); - } - - public void removeLocationUpdates(LocationListener listener) { - Log.d(TAG, "removeLocationUpdates()"); - locationManager.removeUpdates(nativeListenerMap.get(listener)); - nativeListenerMap.remove(listener); - } - - public void removeLocationUpdates(PendingIntent pendingIntent) { - Log.d(TAG, "removeLocationUpdates()"); - locationManager.removeUpdates(nativePendingMap.get(pendingIntent)); - nativePendingMap.remove(pendingIntent); - pendingCount.remove(pendingIntent); - } - - public void setMockMode(boolean isMockMode) { - Log.d(TAG, "setMockMode()"); - // not yet supported - } - - public void setMockLocation(Location mockLocation) { - Log.d(TAG, "setMockLocation()"); - // not yet supported - } - - public static class NativePendingIntentForwarder extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - if (intent.hasExtra(KEY_PROXIMITY_ENTERING)) { - PendingIntent pendingIntent = intent.getExtras().getParcelable(EXTRA_PENDING_INTENT); - try { - intent.putExtra(GeofencingEvent.EXTRA_TRANSITION, intent.getBooleanExtra(KEY_PROXIMITY_ENTERING, false) ? Geofence.GEOFENCE_TRANSITION_ENTER : Geofence.GEOFENCE_TRANSITION_EXIT); - pendingIntent.send(context, 0, intent); - } catch (PendingIntent.CanceledException e) { - nativePendingMap.remove(pendingIntent); - } - } else if (intent.hasExtra(KEY_LOCATION_CHANGED)) { - PendingIntent pendingIntent = intent.getExtras().getParcelable(EXTRA_PENDING_INTENT); - try { - intent.putExtra(FusedLocationProviderApi.KEY_LOCATION_CHANGED, - intent.getParcelableExtra(KEY_LOCATION_CHANGED)); - pendingIntent.send(context, 0, intent); - pendingCount.put(pendingIntent, pendingCount.get(pendingIntent) - 1); - if (pendingCount.get(pendingIntent) == 0) { - ((LocationManager) context.getSystemService(Context.LOCATION_SERVICE)) - .removeUpdates(nativePendingMap.get(pendingIntent)); - nativePendingMap.remove(pendingIntent); - pendingCount.remove(pendingIntent); - } - } catch (PendingIntent.CanceledException e) { - ((LocationManager) context.getSystemService(Context.LOCATION_SERVICE)) - .removeUpdates(nativePendingMap.get(pendingIntent)); - nativePendingMap.remove(pendingIntent); - pendingCount.remove(pendingIntent); - } - } - } - } - - public class NativeListener implements android.location.LocationListener { - - private final LocationListener listener; - private int count; - - private NativeListener(LocationListener listener, int count) { - this.listener = listener; - this.count = count; - } - - @Override - public void onLocationChanged(Location location) { - listener.onLocationChanged(location); - count--; - if (count == 0) { - locationManager.removeUpdates(this); - nativeListenerMap.remove(listener); - } - } - - @Override - public void onStatusChanged(String provider, int status, Bundle extras) { - - } - - @Override - public void onProviderEnabled(String provider) { - - } - - @Override - public void onProviderDisabled(String provider) { - - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - NativeListener that = (NativeListener) o; - - if (!listener.equals(that.listener)) return false; - - return true; - } - - @Override - public int hashCode() { - return listener.hashCode(); - } - } -} diff --git a/play-services-location/src/main/java/org/microg/gms/location/SettingsApiImpl.java b/play-services-location/src/main/java/org/microg/gms/location/SettingsApiImpl.java deleted file mode 100644 index b8fe0ffe..00000000 --- a/play-services-location/src/main/java/org/microg/gms/location/SettingsApiImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.location; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.location.LocationSettingsRequest; -import com.google.android.gms.location.LocationSettingsResult; -import com.google.android.gms.location.SettingsApi; - -import org.microg.gms.common.api.InstantPendingResult; - -public class SettingsApiImpl implements SettingsApi { - @Override - public PendingResult checkLocationSettings(GoogleApiClient client, LocationSettingsRequest locationSettingsRequest) { - return new InstantPendingResult(new LocationSettingsResult(Status.CANCELED)); - } -} diff --git a/play-services-maps-core-mapbox/build.gradle b/play-services-maps-core-mapbox/build.gradle deleted file mode 100644 index 8ae75a48..00000000 --- a/play-services-maps-core-mapbox/build.gradle +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2013-2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -dependencies { - implementation project(':play-services-api') - implementation("com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.1") { - exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-accounts' - } - implementation("com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0") { - exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-accounts' - } - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" -} - -def execResult(...args) { - def stdout = new ByteArrayOutputStream() - exec { - commandLine args - standardOutput = stdout - } - return stdout.toString().trim() -} - -def mapboxKey() { - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - return properties.getProperty("mapbox.key", "invalid") -} - -android { - compileSdkVersion androidCompileSdk - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName version - minSdkVersion androidMinSdk - targetSdkVersion androidTargetSdk - buildConfigField "String", "MAPBOX_KEY", "\"${mapboxKey()}\"" - - ndk { - abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64" - } - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lintOptions { - disable 'GradleCompatible' - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -if (file('user.gradle').exists()) { - apply from: 'user.gradle' -} diff --git a/play-services-maps-core-mapbox/src/main/AndroidManifest.xml b/play-services-maps-core-mapbox/src/main/AndroidManifest.xml deleted file mode 100644 index eef94459..00000000 --- a/play-services-maps-core-mapbox/src/main/AndroidManifest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/play-services-maps-core-mapbox/src/main/java/com/google/android/gms/maps/internal/CreatorImpl.java b/play-services-maps-core-mapbox/src/main/java/com/google/android/gms/maps/internal/CreatorImpl.java deleted file mode 100644 index 905015ba..00000000 --- a/play-services-maps-core-mapbox/src/main/java/com/google/android/gms/maps/internal/CreatorImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.internal; - -import android.app.Activity; -import android.content.Context; -import android.content.res.Resources; -import android.os.Parcel; -import android.os.RemoteException; -import androidx.annotation.Keep; -import android.util.Log; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.GoogleMapOptions; -import com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate; - -import org.microg.gms.maps.mapbox.CameraUpdateFactoryImpl; -import org.microg.gms.maps.mapbox.MapFragmentImpl; -import org.microg.gms.maps.mapbox.MapViewImpl; -import org.microg.gms.maps.mapbox.model.BitmapDescriptorFactoryImpl; - -@Keep -public class CreatorImpl extends ICreator.Stub { - private static final String TAG = "GmsMapCreator"; - - @Override - public void init(IObjectWrapper resources) { - initV2(resources, 0); - } - - @Override - public IMapFragmentDelegate newMapFragmentDelegate(IObjectWrapper activity) { - return new MapFragmentImpl(ObjectWrapper.unwrapTyped(activity, Activity.class)); - } - - @Override - public IMapViewDelegate newMapViewDelegate(IObjectWrapper context, GoogleMapOptions options) { - return new MapViewImpl(ObjectWrapper.unwrapTyped(context, Context.class), options); - } - - @Override - public ICameraUpdateFactoryDelegate newCameraUpdateFactoryDelegate() { - return new CameraUpdateFactoryImpl(); - } - - @Override - public IBitmapDescriptorFactoryDelegate newBitmapDescriptorFactoryDelegate() { - return BitmapDescriptorFactoryImpl.INSTANCE; - } - - @Override - public void initV2(IObjectWrapper resources, int flags) { - BitmapDescriptorFactoryImpl.INSTANCE.initialize(ObjectWrapper.unwrapTyped(resources, Resources.class), null); - //ResourcesContainer.set((Resources) ObjectWrapper.unwrap(resources)); - Log.d(TAG, "initV2 " + flags); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-maps-core-mapbox/src/main/java/com/mapbox/android/accounts/v1/MapboxAccounts.java b/play-services-maps-core-mapbox/src/main/java/com/mapbox/android/accounts/v1/MapboxAccounts.java deleted file mode 100644 index 1319a19f..00000000 --- a/play-services-maps-core-mapbox/src/main/java/com/mapbox/android/accounts/v1/MapboxAccounts.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mapbox.android.accounts.v1; - -import java.util.UUID; - -/** - * This class is used from within the Mapbox library - */ -@SuppressWarnings("unused") -public class MapboxAccounts { - public final static String SKU_ID_MAPS_MAUS = "00"; - private final static String MAPS_SKU_PREFIX = "100"; - - /** - * Generates random UUID without hyphens - */ - public static String obtainEndUserId() { - String uuid = UUID.randomUUID().toString(); - return uuid.substring(0, 8) + uuid.substring(9, 13) + uuid.substring(14, 18) + uuid.substring(19, 23) + uuid.substring(24, 36); - } - - /** - * Generates a SKU which is the user id prefixed with 100 and base-36 encoded timestamp - */ - public static String obtainMapsSkuUserToken(String userId) { - String stamp = Long.toString(System.currentTimeMillis(), 36); - return MAPS_SKU_PREFIX + stamp + userId; - } -} diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraBoundsWithSizeUpdate.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraBoundsWithSizeUpdate.kt deleted file mode 100644 index eea4304f..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraBoundsWithSizeUpdate.kt +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox - -import android.util.Log -import com.mapbox.mapboxsdk.camera.CameraPosition -import com.mapbox.mapboxsdk.camera.CameraUpdate -import com.mapbox.mapboxsdk.geometry.LatLngBounds -import com.mapbox.mapboxsdk.maps.MapboxMap -import java.util.* - -internal class CameraBoundsWithSizeUpdate(val bounds: LatLngBounds, val width: Int, val height: Int, val padding: IntArray) : CameraUpdate { - - constructor(bounds: LatLngBounds, width: Int, height: Int, paddingLeft: Int, paddingTop: Int = paddingLeft, paddingRight: Int = paddingLeft, paddingBottom: Int = paddingTop) : this(bounds, width, height, intArrayOf(paddingLeft, paddingTop, paddingRight, paddingBottom)) {} - - override fun getCameraPosition(map: MapboxMap): CameraPosition? { - val padding = this.padding.clone() - val widthPad = ((map.width + map.padding[0] + map.padding[2] - width) / 2).toInt() - val heightPad = ((map.height + map.padding[1] + map.padding[3] - height) / 2).toInt() - padding[0] += widthPad - padding[1] += heightPad - padding[2] += widthPad - padding[3] += heightPad - Log.d(TAG, "map ${map.width} ${map.height}, set $width $height -> ${padding.map { it.toString() }.reduce { a, b -> "$a,$b"}}") - return map.getCameraForLatLngBounds(bounds, padding) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - if (other == null || other !is CameraBoundsWithSizeUpdate?) { - return false - } - - val that = other as CameraBoundsWithSizeUpdate? ?: return false - - if (bounds != that.bounds) { - return false - } - - if (Arrays.equals(padding, that.padding)) { - return false - } - - if (height != that.height || width != that.width) { - return false - } - - return true - } - - override fun hashCode(): Int { - var result = bounds.hashCode() - result = 31 * result + Arrays.hashCode(padding) - result = 31 * result + height.hashCode() - result = 31 * result + width.hashCode() - return result - } - - override fun toString(): String { - return ("CameraBoundsWithSizeUpdate{" - + "bounds=" + bounds - + ", padding=" + Arrays.toString(padding) - + '}'.toString()) - } - - companion object { - const val TAG = "GmsMapCameraBounds" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraUpdateFactory.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraUpdateFactory.kt deleted file mode 100644 index 675429b9..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraUpdateFactory.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox - -import android.graphics.Point -import android.os.Parcel -import android.util.Log -import com.google.android.gms.dynamic.IObjectWrapper -import com.google.android.gms.dynamic.ObjectWrapper -import com.google.android.gms.maps.internal.ICameraUpdateFactoryDelegate -import com.google.android.gms.maps.model.CameraPosition -import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.LatLngBounds -import com.mapbox.mapboxsdk.camera.CameraUpdate -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory -import com.mapbox.mapboxsdk.maps.MapboxMap -import org.microg.gms.maps.mapbox.utils.toMapbox - -class CameraUpdateFactoryImpl : ICameraUpdateFactoryDelegate.Stub() { - - override fun zoomIn(): IObjectWrapper = ObjectWrapper.wrap(CameraUpdateFactory.zoomIn()) - override fun zoomOut(): IObjectWrapper = ObjectWrapper.wrap(CameraUpdateFactory.zoomOut()) - - override fun zoomTo(zoom: Float): IObjectWrapper = - ObjectWrapper.wrap(CameraUpdateFactory.zoomTo(zoom.toDouble() - 1.0)) - - override fun zoomBy(zoomDelta: Float): IObjectWrapper = - ObjectWrapper.wrap(CameraUpdateFactory.zoomBy(zoomDelta.toDouble())) - - override fun zoomByWithFocus(zoomDelta: Float, x: Int, y: Int): IObjectWrapper = - ObjectWrapper.wrap(CameraUpdateFactory.zoomBy(zoomDelta.toDouble(), Point(x, y))) - - override fun newCameraPosition(cameraPosition: CameraPosition): IObjectWrapper = - ObjectWrapper.wrap(CameraUpdateFactory.newCameraPosition(cameraPosition.toMapbox())) - - override fun newLatLng(latLng: LatLng): IObjectWrapper = - ObjectWrapper.wrap(CameraUpdateFactory.newLatLng(latLng.toMapbox())) - - override fun newLatLngZoom(latLng: LatLng, zoom: Float): IObjectWrapper = - ObjectWrapper.wrap(CameraUpdateFactory.newLatLngZoom(latLng.toMapbox(), zoom.toDouble() - 1.0)) - - override fun newLatLngBounds(bounds: LatLngBounds, padding: Int): IObjectWrapper = - ObjectWrapper.wrap(CameraUpdateFactory.newLatLngBounds(bounds.toMapbox(), padding)) - - override fun scrollBy(x: Float, y: Float): IObjectWrapper { - Log.d(TAG, "unimplemented Method: scrollBy") - return ObjectWrapper.wrap(NoCameraUpdate()) - } - - override fun newLatLngBoundsWithSize(bounds: LatLngBounds, width: Int, height: Int, padding: Int): IObjectWrapper = - ObjectWrapper.wrap(CameraBoundsWithSizeUpdate(bounds.toMapbox(), width, height, padding)) - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } - - private inner class NoCameraUpdate : CameraUpdate { - override fun getCameraPosition(mapboxMap: MapboxMap): com.mapbox.mapboxsdk.camera.CameraPosition? = - mapboxMap.cameraPosition - } - - companion object { - private val TAG = "GmsCameraUpdate" - } -} - - diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt deleted file mode 100644 index ffc854b8..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt +++ /dev/null @@ -1,775 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox - -import android.annotation.SuppressLint -import android.app.Activity -import android.content.Context -import android.location.Location -import android.os.* -import androidx.annotation.IdRes -import androidx.annotation.Keep -import android.util.DisplayMetrics -import android.util.Log -import android.view.Gravity -import android.view.View -import android.widget.FrameLayout -import android.widget.RelativeLayout -import androidx.collection.LongSparseArray -import com.google.android.gms.dynamic.IObjectWrapper -import com.google.android.gms.maps.GoogleMapOptions -import com.google.android.gms.maps.internal.* -import com.google.android.gms.maps.model.* -import com.google.android.gms.maps.model.CircleOptions -import com.google.android.gms.maps.model.internal.* -import com.mapbox.mapboxsdk.LibraryLoader -import com.mapbox.mapboxsdk.Mapbox -import com.mapbox.mapboxsdk.R -import com.mapbox.mapboxsdk.camera.CameraUpdate -import com.mapbox.mapboxsdk.constants.MapboxConstants -import com.mapbox.mapboxsdk.maps.MapView -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.Style -import com.mapbox.mapboxsdk.plugins.annotation.* -import com.mapbox.mapboxsdk.plugins.annotation.Annotation -import com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_ROUND -import com.mapbox.mapboxsdk.utils.ColorUtils -import com.mapbox.mapboxsdk.utils.ThreadUtils -import org.microg.gms.kotlin.unwrap -import org.microg.gms.maps.MapsConstants.* -import org.microg.gms.maps.mapbox.model.* -import org.microg.gms.maps.mapbox.utils.MapContext -import org.microg.gms.maps.mapbox.utils.MultiArchLoader -import org.microg.gms.maps.mapbox.utils.toGms -import org.microg.gms.maps.mapbox.utils.toMapbox - -private fun LongSparseArray.values() = (0..size()).map { valueAt(it) }.mapNotNull { it } - -fun runOnMainLooper(method: () -> Unit) { - if (Looper.myLooper() == Looper.getMainLooper()) { - method() - } else { - Handler(Looper.getMainLooper()).post { - method() - } - } -} - -class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) : IGoogleMapDelegate.Stub() { - - val view: FrameLayout - var map: MapboxMap? = null - private set - val dpiFactor: Float - get() = context.resources.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT - - private var mapView: MapView? = null - private var created = false - private var initialized = false - private var loaded = false - private val mapLock = Object() - - private val initializedCallbackList = mutableListOf() - private var loadedCallback: IOnMapLoadedCallback? = null - private var cameraChangeListener: IOnCameraChangeListener? = null - private var cameraMoveListener: IOnCameraMoveListener? = null - private var cameraMoveCanceledListener: IOnCameraMoveCanceledListener? = null - private var cameraMoveStartedListener: IOnCameraMoveStartedListener? = null - private var cameraIdleListener: IOnCameraIdleListener? = null - private var mapClickListener: IOnMapClickListener? = null - private var mapLongClickListener: IOnMapLongClickListener? = null - private var markerClickListener: IOnMarkerClickListener? = null - private var markerDragListener: IOnMarkerDragListener? = null - - var lineManager: LineManager? = null - val pendingLines = mutableSetOf() - var lineId = 0L - - var fillManager: FillManager? = null - val pendingFills = mutableSetOf() - var fillId = 0L - - var circleManager: CircleManager? = null - val pendingCircles = mutableSetOf() - var circleId = 0L - - var symbolManager: SymbolManager? = null - val pendingMarkers = mutableSetOf() - val markers = mutableMapOf() - var markerId = 0L - - var storedMapType: Int = options.mapType - val waitingCameraUpdates = mutableListOf() - - init { - val mapContext = MapContext(context) - BitmapDescriptorFactoryImpl.initialize(mapContext.resources, context.resources) - LibraryLoader.setLibraryLoader(MultiArchLoader(mapContext, context)) - runOnMainLooper { - Mapbox.getInstance(mapContext, BuildConfig.MAPBOX_KEY) - } - - - val fakeWatermark = View(mapContext) - fakeWatermark.layoutParams = object : RelativeLayout.LayoutParams(0, 0) { - @SuppressLint("RtlHardcoded") - override fun addRule(verb: Int, subject: Int) { - super.addRule(verb, subject) - val rules = this.rules - var gravity = 0 - if (rules[RelativeLayout.ALIGN_PARENT_BOTTOM] == RelativeLayout.TRUE) gravity = gravity or Gravity.BOTTOM - if (rules[RelativeLayout.ALIGN_PARENT_TOP] == RelativeLayout.TRUE) gravity = gravity or Gravity.TOP - if (rules[RelativeLayout.ALIGN_PARENT_LEFT] == RelativeLayout.TRUE) gravity = gravity or Gravity.LEFT - if (rules[RelativeLayout.ALIGN_PARENT_RIGHT] == RelativeLayout.TRUE) gravity = gravity or Gravity.RIGHT - if (rules[RelativeLayout.ALIGN_PARENT_START] == RelativeLayout.TRUE) gravity = gravity or Gravity.START - if (rules[RelativeLayout.ALIGN_PARENT_END] == RelativeLayout.TRUE) gravity = gravity or Gravity.END - map?.uiSettings?.logoGravity = gravity - } - } - this.view = object : FrameLayout(mapContext) { - @Keep - fun findViewTraversal(@IdRes id: Int): T? { - return null - } - - @Keep - fun findViewWithTagTraversal(tag: Any): T? { - if ("GoogleWatermark" == tag) { - return try { - @Suppress("UNCHECKED_CAST") - fakeWatermark as T - } catch (e: ClassCastException) { - null - } - } - return null - } - } - } - - override fun getCameraPosition(): CameraPosition? = map?.cameraPosition?.toGms() - override fun getMaxZoomLevel(): Float = (map?.maxZoomLevel?.toFloat() ?: 20f) + 1f - override fun getMinZoomLevel(): Float = (map?.minZoomLevel?.toFloat() ?: 0f) + 1f - - override fun moveCamera(cameraUpdate: IObjectWrapper?) { - val update = cameraUpdate.unwrap() ?: return - synchronized(mapLock) { - if (initialized) { - this.map?.moveCamera(update) - } else { - waitingCameraUpdates.add(update) - } - } - } - - override fun animateCamera(cameraUpdate: IObjectWrapper?) { - val update = cameraUpdate.unwrap() ?: return - synchronized(mapLock) { - if (initialized) { - this.map?.animateCamera(update) - } else { - waitingCameraUpdates.add(update) - } - } - } - - fun afterInitialized(runnable: () -> Unit) { - initializedCallbackList.add(object : IOnMapReadyCallback { - override fun onMapReady(map: IGoogleMapDelegate?) { - runnable() - } - - override fun asBinder(): IBinder? = null - }) - } - - override fun animateCameraWithCallback(cameraUpdate: IObjectWrapper?, callback: ICancelableCallback?) { - val update = cameraUpdate.unwrap() ?: return - synchronized(mapLock) { - if (initialized) { - this.map?.animateCamera(update, callback?.toMapbox()) - } else { - waitingCameraUpdates.add(update) - afterInitialized { callback?.onFinish() } - } - } - } - - override fun animateCameraWithDurationAndCallback(cameraUpdate: IObjectWrapper?, duration: Int, callback: ICancelableCallback?) { - val update = cameraUpdate.unwrap() ?: return - synchronized(mapLock) { - if (initialized) { - this.map?.animateCamera(update, duration, callback?.toMapbox()) - } else { - waitingCameraUpdates.add(update) - afterInitialized { callback?.onFinish() } - } - } - } - - override fun stopAnimation() = map?.cancelTransitions() ?: Unit - - override fun setMinZoomPreference(minZoom: Float) { - map?.setMinZoomPreference(minZoom.toDouble() - 1) - } - - override fun setMaxZoomPreference(maxZoom: Float) { - map?.setMaxZoomPreference(maxZoom.toDouble() - 1) - } - - override fun resetMinMaxZoomPreference() { - map?.setMinZoomPreference(MapboxConstants.MINIMUM_ZOOM.toDouble()) - map?.setMaxZoomPreference(MapboxConstants.MAXIMUM_ZOOM.toDouble()) - } - - override fun setLatLngBoundsForCameraTarget(bounds: LatLngBounds?) { - map?.setLatLngBoundsForCameraTarget(bounds?.toMapbox()) - } - - override fun addPolyline(options: PolylineOptions): IPolylineDelegate? { - val line = PolylineImpl(this, "l${lineId++}", options) - synchronized(this) { - val lineManager = lineManager - if (lineManager == null) { - pendingLines.add(line) - } else { - line.update(lineManager) - } - } - return line - } - - - override fun addPolygon(options: PolygonOptions): IPolygonDelegate? { - val fill = PolygonImpl(this, "p${fillId++}", options) - synchronized(this) { - val fillManager = fillManager - if (fillManager == null) { - pendingFills.add(fill) - } else { - fill.update(fillManager) - } - } - return fill - } - - override fun addMarker(options: MarkerOptions): IMarkerDelegate? { - val marker = MarkerImpl(this, "m${markerId++}", options) - synchronized(this) { - val symbolManager = symbolManager - if (symbolManager == null) { - pendingMarkers.add(marker) - } else { - marker.update(symbolManager) - } - } - return marker - } - - override fun addGroundOverlay(options: GroundOverlayOptions): IGroundOverlayDelegate? { - Log.d(TAG, "unimplemented Method: addGroundOverlay") - return null - } - - override fun addTileOverlay(options: TileOverlayOptions): ITileOverlayDelegate? { - Log.d(TAG, "unimplemented Method: addTileOverlay") - return null - } - - override fun addCircle(options: CircleOptions): ICircleDelegate? { - val circle = CircleImpl(this, "c${circleId++}", options) - synchronized(this) { - val circleManager = circleManager - if (circleManager == null) { - pendingCircles.add(circle) - } else { - circle.update(circleManager) - } - } - return circle - } - - override fun clear() { - circleManager?.let { clear(it) } - lineManager?.let { clear(it) } - fillManager?.let { clear(it) } - symbolManager?.let { clear(it) } - } - - fun > clear(manager: AnnotationManager<*, T, *, *, *, *>) { - val annotations = manager.getAnnotations() - for (i in 0..annotations.size()) { - val key = annotations.keyAt(i) - val value = annotations[key]; - if (value is T) manager.delete(value) - } - } - - override fun getMapType(): Int { - return storedMapType - } - - override fun setMapType(type: Int) { - storedMapType = type - applyMapType() - } - - fun applyMapType() { - val circles = circleManager?.annotations?.values() - val lines = lineManager?.annotations?.values() - val fills = fillManager?.annotations?.values() - val symbols = symbolManager?.annotations?.values() - val update: (Style) -> Unit = { - circles?.let { runCatching { circleManager?.update(it) } } - lines?.let { runCatching { lineManager?.update(it) } } - fills?.let { runCatching { fillManager?.update(it) } } - symbols?.let { runCatching { symbolManager?.update(it) } } - } - - // TODO: Serve map styles locally - when (storedMapType) { - MAP_TYPE_SATELLITE -> map?.setStyle(Style.Builder().fromUrl("mapbox://styles/microg/cjxgloted25ap1ct4uex7m6hi"), update) - MAP_TYPE_TERRAIN -> map?.setStyle(Style.OUTDOORS, update) - MAP_TYPE_HYBRID -> map?.setStyle(Style.Builder().fromUrl("mapbox://styles/microg/cjxgloted25ap1ct4uex7m6hi"), update) - //MAP_TYPE_NONE, MAP_TYPE_NORMAL, - else -> map?.setStyle(Style.Builder().fromUrl("mapbox://styles/microg/cjui4020201oo1fmca7yuwbor"), update) - } - - map?.let { BitmapDescriptorFactoryImpl.registerMap(it) } - - } - - override fun setWatermarkEnabled(watermark: Boolean) { - map?.uiSettings?.isLogoEnabled = watermark - } - - override fun isTrafficEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isTrafficEnabled") - return false - } - - override fun setTrafficEnabled(traffic: Boolean) { - Log.d(TAG, "unimplemented Method: setTrafficEnabled") - - } - - override fun isIndoorEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isIndoorEnabled") - return false - } - - override fun setIndoorEnabled(indoor: Boolean) { - Log.d(TAG, "unimplemented Method: setIndoorEnabled") - - } - - override fun isMyLocationEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isMyLocationEnabled") - return false - } - - override fun setMyLocationEnabled(myLocation: Boolean) { - Log.d(TAG, "unimplemented Method: setMyLocationEnabled") - - } - - override fun getMyLocation(): Location? { - Log.d(TAG, "unimplemented Method: getMyLocation") - return null - } - - override fun setLocationSource(locationSource: ILocationSourceDelegate) { - Log.d(TAG, "unimplemented Method: setLocationSource") - } - - override fun setContentDescription(desc: String?) { - mapView?.contentDescription = desc - } - - override fun getUiSettings(): IUiSettingsDelegate? = map?.uiSettings?.let { UiSettingsImpl(it) } - - override fun getProjection(): IProjectionDelegate? = map?.projection?.let { - val experiment = try { - map?.cameraPosition?.tilt == 0.0 && map?.cameraPosition?.bearing == 0.0 - } catch (e: Exception) { - Log.w(TAG, e); false - } - ProjectionImpl(it, experiment) - } - - override fun setOnCameraChangeListener(listener: IOnCameraChangeListener?) { - cameraChangeListener = listener - } - - override fun setOnMapClickListener(listener: IOnMapClickListener?) { - mapClickListener = listener - } - - override fun setOnMapLongClickListener(listener: IOnMapLongClickListener?) { - mapLongClickListener = listener - } - - override fun setOnMarkerClickListener(listener: IOnMarkerClickListener?) { - markerClickListener = listener - } - - override fun setOnMarkerDragListener(listener: IOnMarkerDragListener?) { - markerDragListener = listener - } - - override fun setOnInfoWindowClickListener(listener: IOnInfoWindowClickListener?) { - Log.d(TAG, "unimplemented Method: setOnInfoWindowClickListener") - - } - - override fun setInfoWindowAdapter(adapter: IInfoWindowAdapter?) { - Log.d(TAG, "unimplemented Method: setInfoWindowAdapter") - - } - - override fun getTestingHelper(): IObjectWrapper? { - Log.d(TAG, "unimplemented Method: getTestingHelper") - return null - } - - override fun setOnMyLocationChangeListener(listener: IOnMyLocationChangeListener?) { - Log.d(TAG, "unimplemented Method: setOnMyLocationChangeListener") - - } - - override fun setOnMyLocationButtonClickListener(listener: IOnMyLocationButtonClickListener?) { - Log.d(TAG, "unimplemented Method: setOnMyLocationButtonClickListener") - - } - - override fun snapshot(callback: ISnapshotReadyCallback, bitmap: IObjectWrapper) { - Log.d(TAG, "unimplemented Method: snapshot") - - } - - override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) { - Log.d(TAG, "setPadding: $left $top $right $bottom") - map?.let { map -> - map.setPadding(left, top, right, bottom) - val fourDp = mapView?.context?.resources?.getDimension(R.dimen.mapbox_four_dp)?.toInt() - ?: 0 - val ninetyTwoDp = mapView?.context?.resources?.getDimension(R.dimen.mapbox_ninety_two_dp)?.toInt() - ?: 0 - map.uiSettings.setLogoMargins(left + fourDp, top + fourDp, right + fourDp, bottom + fourDp) - map.uiSettings.setCompassMargins(left + fourDp, top + fourDp, right + fourDp, bottom + fourDp) - map.uiSettings.setAttributionMargins(left + ninetyTwoDp, top + fourDp, right + fourDp, bottom + fourDp) - } - } - - override fun isBuildingsEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isBuildingsEnabled") - return false - } - - override fun setBuildingsEnabled(buildings: Boolean) { - Log.d(TAG, "unimplemented Method: setBuildingsEnabled") - - } - - override fun setOnMapLoadedCallback(callback: IOnMapLoadedCallback?) { - if (callback != null) { - synchronized(mapLock) { - if (loaded) { - Log.d(TAG, "Invoking callback instantly, as map is loaded") - try { - callback.onMapLoaded() - } catch (e: Exception) { - Log.w(TAG, e) - } - } else { - Log.d(TAG, "Delay callback invocation, as map is not yet loaded") - loadedCallback = callback - } - } - } else { - loadedCallback = null - } - } - - override fun setCameraMoveStartedListener(listener: IOnCameraMoveStartedListener?) { - cameraMoveStartedListener = listener - } - - override fun setCameraMoveListener(listener: IOnCameraMoveListener?) { - cameraMoveListener = listener - } - - override fun setCameraMoveCanceledListener(listener: IOnCameraMoveCanceledListener?) { - cameraMoveCanceledListener = listener - } - - override fun setCameraIdleListener(listener: IOnCameraIdleListener?) { - cameraIdleListener = listener - } - - override fun onCreate(savedInstanceState: Bundle?) { - if (!created) { - Log.d(TAG, "create"); - val mapView = MapView(MapContext(context)) - this.mapView = mapView - view.addView(mapView) - mapView.onCreate(savedInstanceState?.toMapbox()) - mapView.getMapAsync(this::initMap) - created = true - } - } - - private fun hasSymbolAt(latlng: com.mapbox.mapboxsdk.geometry.LatLng): Boolean { - val point = map?.projection?.toScreenLocation(latlng) ?: return false - val features = map?.queryRenderedFeatures(point, symbolManager?.layerId) - ?: return false - return features.isNotEmpty() - } - - private fun initMap(map: MapboxMap) { - if (this.map != null) return - this.map = map - - map.addOnCameraIdleListener { - try { - cameraChangeListener?.onCameraChange(map.cameraPosition.toGms()) - } catch (e: Exception) { - Log.w(TAG, e) - } - } - map.addOnCameraIdleListener { - try { - cameraIdleListener?.onCameraIdle() - } catch (e: Exception) { - Log.w(TAG, e) - } - } - map.addOnCameraMoveListener { - try { - cameraMoveListener?.onCameraMove() - } catch (e: Exception) { - Log.w(TAG, e) - } - } - map.addOnCameraMoveStartedListener { - try { - cameraMoveStartedListener?.onCameraMoveStarted(it) - } catch (e: Exception) { - Log.w(TAG, e) - } - } - map.addOnCameraMoveCancelListener { - try { - cameraMoveCanceledListener?.onCameraMoveCanceled() - } catch (e: Exception) { - Log.w(TAG, e) - } - } - map.addOnMapClickListener { latlng -> - try { - mapClickListener?.let { if (!hasSymbolAt(latlng)) it.onMapClick(latlng.toGms()); } - } catch (e: Exception) { - Log.w(TAG, e) - } - false - } - map.addOnMapLongClickListener { latlng -> - try { - mapLongClickListener?.let { if (!hasSymbolAt(latlng)) it.onMapLongClick(latlng.toGms()); } - } catch (e: Exception) { - Log.w(TAG, e) - } - false - } - - applyMapType() - options.minZoomPreference?.let { if (it != 0f) map.setMinZoomPreference(it.toDouble()) } - options.maxZoomPreference?.let { if (it != 0f) map.setMaxZoomPreference(it.toDouble()) } - options.latLngBoundsForCameraTarget?.let { map.setLatLngBoundsForCameraTarget(it.toMapbox()) } - options.compassEnabled?.let { map.uiSettings.isCompassEnabled = it } - options.rotateGesturesEnabled?.let { map.uiSettings.isRotateGesturesEnabled = it } - options.scrollGesturesEnabled?.let { map.uiSettings.isScrollGesturesEnabled = it } - options.tiltGesturesEnabled?.let { map.uiSettings.isTiltGesturesEnabled = it } - options.camera?.let { map.cameraPosition = it.toMapbox() } - - synchronized(mapLock) { - initialized = true - waitingCameraUpdates.forEach { map.moveCamera(it) } - val initializedCallbackList = ArrayList(initializedCallbackList) - Log.d(TAG, "Invoking ${initializedCallbackList.size} callbacks delayed, as map is initialized") - for (callback in initializedCallbackList) { - try { - callback.onMapReady(this) - } catch (e: Exception) { - Log.w(TAG, e) - } - } - } - - map.getStyle { - mapView?.let { view -> - if (loaded) return@let - val symbolManager: SymbolManager - val lineManager: LineManager - val circleManager: CircleManager - val fillManager: FillManager - - synchronized(mapLock) { - circleManager = CircleManager(view, map, it) - fillManager = FillManager(view, map, it) - symbolManager = SymbolManager(view, map, it) - lineManager = LineManager(view, map, it) - lineManager.lineCap = LINE_CAP_ROUND - - this.symbolManager = symbolManager - this.lineManager = lineManager - this.circleManager = circleManager - this.fillManager = fillManager - } - symbolManager.iconAllowOverlap = true - symbolManager.addClickListener { - try { - markers[it.id]?.let { markerClickListener?.onMarkerClick(it) } - } catch (e: Exception) { - Log.w(TAG, e) - } - } - symbolManager.addDragListener(object : OnSymbolDragListener { - override fun onAnnotationDragStarted(annotation: Symbol?) { - try { - markers[annotation?.id]?.let { markerDragListener?.onMarkerDragStart(it) } - } catch (e: Exception) { - Log.w(TAG, e) - } - } - - override fun onAnnotationDrag(annotation: Symbol?) { - try { - markers[annotation?.id]?.let { markerDragListener?.onMarkerDrag(it) } - } catch (e: Exception) { - Log.w(TAG, e) - } - } - - override fun onAnnotationDragFinished(annotation: Symbol?) { - try { - markers[annotation?.id]?.let { markerDragListener?.onMarkerDragEnd(it) } - } catch (e: Exception) { - Log.w(TAG, e) - } - } - }) - pendingCircles.forEach { it.update(circleManager) } - pendingCircles.clear() - pendingFills.forEach { it.update(fillManager) } - pendingFills.clear() - pendingLines.forEach { it.update(lineManager) } - pendingLines.clear() - pendingMarkers.forEach { it.update(symbolManager) } - pendingMarkers.clear() - - synchronized(mapLock) { - loaded = true - if (loadedCallback != null) { - Log.d(TAG, "Invoking callback delayed, as map is loaded") - loadedCallback?.onMapLoaded() - } - } - } - } - } - - override fun useViewLifecycleWhenInFragment(): Boolean { - Log.d(TAG, "unimplemented Method: useViewLifecycleWhenInFragment") - return false - } - - override fun onResume() = mapView?.onResume() ?: Unit - override fun onPause() = mapView?.onPause() ?: Unit - override fun onDestroy() { - Log.d(TAG, "destroy"); - circleManager?.onDestroy() - circleManager = null - lineManager?.onDestroy() - lineManager = null - fillManager?.onDestroy() - fillManager = null - symbolManager?.onDestroy() - symbolManager = null - pendingMarkers.clear() - markers.clear() - BitmapDescriptorFactoryImpl.unregisterMap(map) - view.removeView(mapView) - // TODO can crash? - mapView?.onDestroy() - mapView = null - map = null - created = false - initialized = false - loaded = false - } - - override fun onStart() { - mapView?.onStart() - } - - override fun onStop() { - mapView?.onStop() - } - - override fun onEnterAmbient(bundle: Bundle?) { - Log.d(TAG, "unimplemented Method: onEnterAmbient") - } - - override fun onExitAmbient() { - Log.d(TAG, "unimplemented Method: onExitAmbient") - } - - override fun onLowMemory() = mapView?.onLowMemory() ?: Unit - override fun onSaveInstanceState(outState: Bundle) { - val newBundle = Bundle() - mapView?.onSaveInstanceState(newBundle) - outState.putAll(newBundle.toGms()) - } - - fun getMapAsync(callback: IOnMapReadyCallback) { - synchronized(mapLock) { - if (initialized) { - Log.d(TAG, "Invoking callback instantly, as map is initialized") - try { - callback.onMapReady(this) - } catch (e: Exception) { - Log.w(TAG, e) - } - } else { - Log.d(TAG, "Delay callback invocation, as map is not yet initialized") - initializedCallbackList.add(callback) - } - } - } - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } - - companion object { - private val TAG = "GmsMap" - } -} diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/MapFragment.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/MapFragment.kt deleted file mode 100644 index daf4bfb9..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/MapFragment.kt +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox - -import android.app.Activity -import android.os.Bundle -import android.os.Parcel -import android.util.Base64 -import android.util.Log -import android.view.View -import android.view.ViewGroup -import com.google.android.gms.dynamic.IObjectWrapper -import com.google.android.gms.dynamic.ObjectWrapper -import com.google.android.gms.maps.GoogleMapOptions -import com.google.android.gms.maps.internal.IGoogleMapDelegate -import com.google.android.gms.maps.internal.IMapFragmentDelegate -import com.google.android.gms.maps.internal.IOnMapReadyCallback - -class MapFragmentImpl(private val activity: Activity) : IMapFragmentDelegate.Stub() { - - private var map: GoogleMapImpl? = null - private var options: GoogleMapOptions? = null - - override fun onInflate(activity: IObjectWrapper, options: GoogleMapOptions, savedInstanceState: Bundle?) { - this.options = options - map?.options = options - } - - override fun onCreate(savedInstanceState: Bundle?) { - if (options == null) { - options = savedInstanceState?.getParcelable("MapOptions") - } - if (options == null) { - options = GoogleMapOptions() - } - map = GoogleMapImpl(activity, options ?: GoogleMapOptions()) - } - - override fun onCreateView(layoutInflater: IObjectWrapper, container: IObjectWrapper, savedInstanceState: Bundle?): IObjectWrapper { - if (options == null) { - options = savedInstanceState?.getParcelable("MapOptions") - } - Log.d(TAG, "onCreateView: ${options?.camera?.target}") - if (map == null) { - map = GoogleMapImpl(activity, options ?: GoogleMapOptions()) - } - map!!.onCreate(savedInstanceState) - val view = map!!.view - val parent = view.parent as ViewGroup? - parent?.removeView(view) - return ObjectWrapper.wrap(view) - } - - override fun getMap(): IGoogleMapDelegate? = map - override fun onEnterAmbient(bundle: Bundle?) = map?.onEnterAmbient(bundle) ?: Unit - override fun onExitAmbient() = map?.onExitAmbient() ?: Unit - override fun onStart() = map?.onStart() ?: Unit - override fun onStop() = map?.onStop() ?: Unit - override fun onResume() = map?.onResume() ?: Unit - override fun onPause() = map?.onPause() ?: Unit - override fun onLowMemory() = map?.onLowMemory() ?: Unit - override fun isReady(): Boolean = this.map != null - override fun getMapAsync(callback: IOnMapReadyCallback) = map?.getMapAsync(callback) ?: Unit - - override fun onDestroyView() { - map?.onDestroy() - } - - override fun onDestroy() { - map?.onDestroy() - map = null - options = null - } - - override fun onSaveInstanceState(outState: Bundle) { - if (options != null) { - outState.putParcelable("MapOptions", options) - } - map?.onSaveInstanceState(outState) - } - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean { - if (super.onTransact(code, data, reply, flags)) { - return true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags") - return false - } - } - - companion object { - private val TAG = "GmsMapFragment" - } -} diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/MapView.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/MapView.kt deleted file mode 100644 index 8951aaf1..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/MapView.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox - -import android.content.Context -import android.os.Bundle -import android.os.Parcel -import android.util.Log -import com.google.android.gms.dynamic.IObjectWrapper -import com.google.android.gms.dynamic.ObjectWrapper -import com.google.android.gms.maps.GoogleMapOptions -import com.google.android.gms.maps.internal.IGoogleMapDelegate -import com.google.android.gms.maps.internal.IMapViewDelegate -import com.google.android.gms.maps.internal.IOnMapReadyCallback - -class MapViewImpl(private val context: Context, options: GoogleMapOptions?) : IMapViewDelegate.Stub() { - - private val options: GoogleMapOptions = options ?: GoogleMapOptions() - private var map: GoogleMapImpl? = null - - override fun onCreate(savedInstanceState: Bundle?) { - Log.d(TAG, "onCreate: ${options?.camera?.target}") - map = GoogleMapImpl(context, options) - map!!.onCreate(savedInstanceState) - } - - override fun getMap(): IGoogleMapDelegate? = map - override fun onEnterAmbient(bundle: Bundle?) = map?.onEnterAmbient(bundle) ?: Unit - override fun onExitAmbient() = map?.onExitAmbient() ?: Unit - override fun onStart() = map?.onStart() ?: Unit - override fun onStop() = map?.onStop() ?: Unit - override fun onResume() = map?.onResume() ?: Unit - override fun onPause() = map?.onPause() ?: Unit - override fun onDestroy() { - map?.onDestroy() - map = null - } - - override fun onLowMemory() = map?.onLowMemory() ?: Unit - override fun onSaveInstanceState(outState: Bundle) = map?.onSaveInstanceState(outState) ?: Unit - override fun getView(): IObjectWrapper = ObjectWrapper.wrap(map?.view) - override fun getMapAsync(callback: IOnMapReadyCallback) = map?.getMapAsync(callback) ?: Unit - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } - - companion object { - private val TAG = "GmsMapView" - } -} diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Projection.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Projection.kt deleted file mode 100644 index c36e57ed..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Projection.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox - -import android.graphics.Point -import android.graphics.PointF -import android.util.Log -import com.google.android.gms.dynamic.IObjectWrapper -import com.google.android.gms.dynamic.ObjectWrapper -import com.google.android.gms.maps.internal.IProjectionDelegate -import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.VisibleRegion -import com.mapbox.mapboxsdk.maps.Projection -import org.microg.gms.kotlin.unwrap -import org.microg.gms.maps.mapbox.utils.toGms -import org.microg.gms.maps.mapbox.utils.toMapbox -import kotlin.math.roundToInt - -// TODO: Do calculations using backed up locations instead of live (which requires UI thread) -class ProjectionImpl(private val projection: Projection, private val withoutTiltOrBearing: Boolean) : IProjectionDelegate.Stub() { - private val visibleRegion = projection.visibleRegion - private val farLeft = projection.toScreenLocation(visibleRegion.farLeft) - private val farRight = projection.toScreenLocation(visibleRegion.farRight) - private val nearLeft = projection.toScreenLocation(visibleRegion.nearLeft) - private val nearRight = projection.toScreenLocation(visibleRegion.nearRight) - - override fun fromScreenLocation(obj: IObjectWrapper?): LatLng? = try { - obj.unwrap()?.let { - if (withoutTiltOrBearing) { - val xPercent = (it.x.toFloat() - farLeft.x) / (farRight.x - farLeft.x) - val yPercent = (it.y.toFloat() - farLeft.y) / (nearLeft.y - farLeft.y) - val lon = visibleRegion.farLeft.longitude + xPercent * (visibleRegion.farRight.longitude - visibleRegion.farLeft.longitude) - val lat = visibleRegion.farLeft.latitude + yPercent * (visibleRegion.nearLeft.latitude - visibleRegion.farLeft.latitude) - LatLng(lat, lon) - } else { - projection.fromScreenLocation(PointF(it)).toGms() - } - } - } catch (e: Exception) { - Log.d(TAG, "fromScreenLocation() used from outside UI thread on map with tilt or bearing, expect bugs") - LatLng(0.0, 0.0) - } - - override fun toScreenLocation(latLng: LatLng?): IObjectWrapper = try { - ObjectWrapper.wrap(latLng?.toMapbox()?.let { - if (withoutTiltOrBearing) { - val xPercent = (it.longitude - visibleRegion.farLeft.longitude) / (visibleRegion.farRight.longitude - visibleRegion.farLeft.longitude) - val yPercent = (it.latitude - visibleRegion.farLeft.latitude) / (visibleRegion.nearLeft.latitude - visibleRegion.farLeft.latitude) - val x = farLeft.x + xPercent * (farRight.x - farLeft.x) - val y = farLeft.y + yPercent * (nearLeft.y - farLeft.y) - Point(x.roundToInt(), y.roundToInt()) - } else { - projection.toScreenLocation(it).let { Point(it.x.roundToInt(), it.y.roundToInt()) } - } - }) - } catch (e: Exception) { - Log.d(TAG, "toScreenLocation() used from outside UI thread on map with tilt or bearing, expect bugs") - ObjectWrapper.wrap(Point(0, 0)) - } - - override fun getVisibleRegion(): VisibleRegion = visibleRegion.toGms() - - companion object { - private val TAG = "GmsMapProjection" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/UiSettings.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/UiSettings.kt deleted file mode 100644 index 32320eb4..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/UiSettings.kt +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox - -import android.os.Parcel -import android.os.RemoteException -import android.util.Log - -import com.google.android.gms.maps.internal.IUiSettingsDelegate -import com.mapbox.mapboxsdk.maps.UiSettings - -class UiSettingsImpl(private val uiSettings: UiSettings) : IUiSettingsDelegate.Stub() { - - override fun setZoomControlsEnabled(zoom: Boolean) { - Log.d(TAG, "unimplemented Method: setZoomControlsEnabled") - } - - override fun setCompassEnabled(compass: Boolean) { - uiSettings.isCompassEnabled = compass - } - - override fun setMyLocationButtonEnabled(locationButton: Boolean) { - Log.d(TAG, "unimplemented Method: setMyLocationButtonEnabled") - - } - - override fun setScrollGesturesEnabled(scrollGestures: Boolean) { - uiSettings.isScrollGesturesEnabled = scrollGestures - } - - override fun setZoomGesturesEnabled(zoomGestures: Boolean) { - uiSettings.isZoomGesturesEnabled = zoomGestures - } - - override fun setTiltGesturesEnabled(tiltGestures: Boolean) { - uiSettings.isTiltGesturesEnabled = tiltGestures - } - - override fun setRotateGesturesEnabled(rotateGestures: Boolean) { - uiSettings.isRotateGesturesEnabled = rotateGestures - } - - override fun setAllGesturesEnabled(gestures: Boolean) { - uiSettings.setAllGesturesEnabled(gestures) - } - - override fun isZoomControlsEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isZoomControlsEnabled") - return false - } - - override fun isCompassEnabled(): Boolean = uiSettings.isCompassEnabled - - override fun isMyLocationButtonEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isMyLocationButtonEnabled") - return false - } - - override fun isScrollGesturesEnabled(): Boolean = uiSettings.isScrollGesturesEnabled - - override fun isZoomGesturesEnabled(): Boolean = uiSettings.isZoomGesturesEnabled - - override fun isTiltGesturesEnabled(): Boolean = uiSettings.isTiltGesturesEnabled - - override fun isRotateGesturesEnabled(): Boolean = uiSettings.isRotateGesturesEnabled - - override fun setIndoorLevelPickerEnabled(indoorLevelPicker: Boolean) { - Log.d(TAG, "unimplemented Method: setIndoorLevelPickerEnabled") - } - - override fun isIndoorLevelPickerEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isIndoorLevelPickerEnabled") - return false - } - - override fun setMapToolbarEnabled(mapToolbar: Boolean) { - Log.d(TAG, "unimplemented Method: setMapToolbarEnabled") - } - - override fun isMapToolbarEnabled(): Boolean { - Log.d(TAG, "unimplemented Method: isMapToolbarEnabled") - return false - } - - override fun setScrollGesturesEnabledDuringRotateOrZoom(scrollDuringZoom: Boolean) { - Log.d(TAG, "unimplemented Method: setScrollGesturesEnabledDuringRotateOrZoom") - } - - override fun isScrollGesturesEnabledDuringRotateOrZoom(): Boolean { - Log.d(TAG, "unimplemented Method: isScrollGesturesEnabledDuringRotateOrZoom") - return true - } - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } - - companion object { - private val TAG = "GmsMapsUi" - } -} diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/BitmapDescriptor.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/BitmapDescriptor.kt deleted file mode 100644 index e228387d..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/BitmapDescriptor.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.model - -import android.graphics.Color -import android.graphics.PointF -import android.util.Log -import com.mapbox.mapboxsdk.plugins.annotation.Symbol -import com.mapbox.mapboxsdk.plugins.annotation.SymbolOptions -import com.mapbox.mapboxsdk.style.layers.Property.ICON_ANCHOR_TOP_LEFT -import com.mapbox.mapboxsdk.utils.ColorUtils - -open class BitmapDescriptorImpl(private val id: String, private val size: FloatArray) { - open fun applyTo(options: SymbolOptions, anchor: FloatArray, dpiFactor: Float): SymbolOptions { - return options.withIconImage(id).withIconAnchor(ICON_ANCHOR_TOP_LEFT).withIconOffset(arrayOf(-anchor[0] * size[0] / dpiFactor, -anchor[1] * size[1] / dpiFactor)) - } - - open fun applyTo(symbol: Symbol, anchor: FloatArray, dpiFactor: Float) { - symbol.iconAnchor = ICON_ANCHOR_TOP_LEFT - symbol.iconOffset = PointF(-anchor[0] * size[0] / dpiFactor, -anchor[1] * size[1] / dpiFactor) - symbol.iconImage = id - } -} - -class ColorBitmapDescriptorImpl(id: String, size: FloatArray, val hue: Float) : BitmapDescriptorImpl(id, size) { - override fun applyTo(options: SymbolOptions, anchor: FloatArray, dpiFactor: Float): SymbolOptions = super.applyTo(options, anchor, dpiFactor).withIconColor(ColorUtils.colorToRgbaString(Color.HSVToColor(floatArrayOf(hue, 1.0f, 0.5f)))) - override fun applyTo(symbol: Symbol, anchor: FloatArray, dpiFactor: Float) { - super.applyTo(symbol, anchor, dpiFactor) - symbol.setIconColor(Color.HSVToColor(floatArrayOf(hue, 1.0f, 0.5f))) - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/BitmapDescriptorFactory.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/BitmapDescriptorFactory.kt deleted file mode 100644 index f4f51748..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/BitmapDescriptorFactory.kt +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.model - -import android.content.res.Resources -import android.graphics.* -import android.os.Handler -import android.os.Looper -import android.os.Parcel -import android.util.Log -import com.google.android.gms.dynamic.IObjectWrapper -import com.google.android.gms.dynamic.ObjectWrapper -import com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate -import com.mapbox.mapboxsdk.maps.MapboxMap -import org.microg.gms.maps.mapbox.R -import org.microg.gms.maps.mapbox.runOnMainLooper - - -object BitmapDescriptorFactoryImpl : IBitmapDescriptorFactoryDelegate.Stub() { - private val TAG = "GmsMapBitmap" - private var resources: Resources? = null - private var mapResources: Resources? = null - private val maps = hashSetOf() - private val bitmaps = hashMapOf() - - fun initialize(mapResources: Resources?, resources: Resources?) { - BitmapDescriptorFactoryImpl.mapResources = mapResources ?: resources - BitmapDescriptorFactoryImpl.resources = resources ?: mapResources - } - - fun registerMap(map: MapboxMap) { - Log.d(TAG, "registerMap") - map.getStyle { - synchronized(bitmaps) { - it.addImages(bitmaps) - } - } - maps.add(map) - } - - fun unregisterMap(map: MapboxMap?) { - maps.remove(map) - // TODO: cleanup bitmaps? - } - - fun bitmapSize(id: String): FloatArray = - bitmaps[id]?.let { floatArrayOf(it.width.toFloat(), it.height.toFloat()) } - ?: floatArrayOf(0f, 0f) - - private fun registerBitmap(id: String, bitmapCreator: () -> Bitmap?) { - val bitmap: Bitmap = synchronized(bitmaps) { - if (bitmaps.contains(id)) return - val bitmap = bitmapCreator() - if (bitmap == null) { - Log.w(TAG, "Failed to register bitmap $id, creator returned null") - return - } - bitmaps[id] = bitmap - bitmap - } - for (map in maps) { - map.getStyle { - runOnMainLooper { - it.addImage(id, bitmap) - } - } - } - } - - override fun fromResource(resourceId: Int): IObjectWrapper? { - val id = "resource-$resourceId" - registerBitmap(id) { - val bitmap = BitmapFactory.decodeResource(resources, resourceId) - if (bitmap == null) { - try { - Log.d(TAG, "Resource $resourceId not found in $resources (${resources?.getResourceName(resourceId)})") - } catch (e: Resources.NotFoundException) { - Log.d(TAG, "Resource $resourceId not found in $resources") - } - } - bitmap - } - return ObjectWrapper.wrap(BitmapDescriptorImpl(id, bitmapSize(id))) - } - - override fun fromAsset(assetName: String): IObjectWrapper? { - val id = "asset-$assetName" - registerBitmap(id) { resources?.assets?.open(assetName)?.let { BitmapFactory.decodeStream(it) } } - return ObjectWrapper.wrap(BitmapDescriptorImpl(id, bitmapSize(id))) - } - - override fun fromFile(fileName: String): IObjectWrapper? { - val id = "file-$fileName" - registerBitmap(id) { BitmapFactory.decodeFile(fileName) } - return ObjectWrapper.wrap(BitmapDescriptorImpl(id, bitmapSize(id))) - } - - override fun defaultMarker(): IObjectWrapper? { - val id = "marker" - registerBitmap(id) { BitmapFactory.decodeResource(mapResources, R.drawable.maps_default_marker) } - return ObjectWrapper.wrap(BitmapDescriptorImpl(id, bitmapSize(id))) - } - - private fun adjustHue(cm: ColorMatrix, value: Float) { - var value = value - value = cleanValue(value, 180f) / 180f * Math.PI.toFloat() - if (value == 0f) { - return - } - val cosVal = Math.cos(value.toDouble()).toFloat() - val sinVal = Math.sin(value.toDouble()).toFloat() - val lumR = 0.213f - val lumG = 0.715f - val lumB = 0.072f - val mat = floatArrayOf(lumR + cosVal * (1 - lumR) + sinVal * -lumR, lumG + cosVal * -lumG + sinVal * -lumG, lumB + cosVal * -lumB + sinVal * (1 - lumB), 0f, 0f, lumR + cosVal * -lumR + sinVal * 0.143f, lumG + cosVal * (1 - lumG) + sinVal * 0.140f, lumB + cosVal * -lumB + sinVal * -0.283f, 0f, 0f, lumR + cosVal * -lumR + sinVal * -(1 - lumR), lumG + cosVal * -lumG + sinVal * lumG, lumB + cosVal * (1 - lumB) + sinVal * lumB, 0f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 1f) - cm.postConcat(ColorMatrix(mat)) - } - - private fun cleanValue(p_val: Float, p_limit: Float): Float { - return Math.min(p_limit, Math.max(-p_limit, p_val)) - } - - override fun defaultMarkerWithHue(hue: Float): IObjectWrapper? { - val id = "marker-${hue.toInt()}" - registerBitmap(id) { - val bitmap = BitmapFactory.decodeResource(mapResources, R.drawable.maps_default_marker).copy(Bitmap.Config.ARGB_8888, true) - val paint = Paint() - val matrix = ColorMatrix() - val huex = hue % 360f - adjustHue(matrix, if (huex > 180f) huex - 360f else huex) - paint.setColorFilter(ColorMatrixColorFilter(matrix)) - - val canvas = Canvas(bitmap) - canvas.drawBitmap(bitmap, 0f, 0f, paint) - bitmap - } - return ObjectWrapper.wrap(ColorBitmapDescriptorImpl(id, bitmapSize(id), hue)) - } - - override fun fromBitmap(bitmap: Bitmap): IObjectWrapper? { - val id = "bitmap-${bitmap.hashCode()}" - registerBitmap(id) { bitmap } - return ObjectWrapper.wrap(BitmapDescriptorImpl(id, bitmapSize(id))) - } - - override fun fromPath(absolutePath: String): IObjectWrapper? { - val id = "path-$absolutePath" - registerBitmap(id) { BitmapFactory.decodeFile(absolutePath) } - return ObjectWrapper.wrap(BitmapDescriptorImpl(id, bitmapSize(id))) - } - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } -} diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt deleted file mode 100644 index aa016ea8..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.model - -import android.os.Parcel -import android.util.Log -import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.internal.ICircleDelegate -import com.mapbox.mapboxsdk.plugins.annotation.Circle -import com.mapbox.mapboxsdk.plugins.annotation.CircleOptions -import com.mapbox.mapboxsdk.utils.ColorUtils -import org.microg.gms.maps.mapbox.GoogleMapImpl -import org.microg.gms.maps.mapbox.utils.toMapbox -import com.google.android.gms.maps.model.CircleOptions as GmsCircleOptions - -class CircleImpl(private val map: GoogleMapImpl, private val id: String, options: GmsCircleOptions) : ICircleDelegate.Stub(), Markup { - private var center: LatLng = options.center - private var radius: Double = options.radius - private var strokeWidth: Float = options.strokeWidth - private var strokeColor: Int = options.strokeColor - private var fillColor: Int = options.fillColor - private var visible: Boolean = options.isVisible - - override var annotation: Circle? = null - override var removed: Boolean = false - override val annotationOptions: CircleOptions - get() = CircleOptions() - .withLatLng(center.toMapbox()) - .withCircleColor(ColorUtils.colorToRgbaString(fillColor)) - .withCircleRadius(radius.toFloat()) - .withCircleStrokeColor(ColorUtils.colorToRgbaString(strokeColor)) - .withCircleStrokeWidth(strokeWidth / map.dpiFactor) - .withCircleOpacity(if (visible) 1f else 0f) - .withCircleStrokeOpacity(if (visible) 1f else 0f) - - override fun remove() { - removed = true - map.circleManager?.let { update(it) } - } - - override fun getId(): String = id - - override fun setCenter(center: LatLng) { - this.center = center - annotation?.latLng = center.toMapbox() - map.circleManager?.let { update(it) } - } - - override fun getCenter(): LatLng = center - - override fun setRadius(radius: Double) { - this.radius = radius - annotation?.circleRadius = radius.toFloat() - map.circleManager?.let { update(it) } - } - - override fun getRadius(): Double = radius - - override fun setStrokeWidth(width: Float) { - this.strokeWidth = width - annotation?.circleStrokeWidth = width / map.dpiFactor - map.circleManager?.let { update(it) } - } - - override fun getStrokeWidth(): Float = strokeWidth - - override fun setStrokeColor(color: Int) { - this.strokeColor = color - annotation?.setCircleStrokeColor(color) - map.circleManager?.let { update(it) } - } - - override fun getStrokeColor(): Int = strokeColor - - override fun setFillColor(color: Int) { - this.fillColor = color - annotation?.setCircleColor(color) - map.circleManager?.let { update(it) } - } - - override fun getFillColor(): Int = fillColor - - override fun setZIndex(zIndex: Float) { - Log.d(TAG, "unimplemented Method: setZIndex") - } - - override fun getZIndex(): Float { - Log.d(TAG, "unimplemented Method: getZIndex") - return 0f - } - - override fun setVisible(visible: Boolean) { - this.visible = visible - annotation?.circleOpacity = if (visible) 1f else 0f - annotation?.circleStrokeOpacity = if (visible) 1f else 0f - map.circleManager?.let { update(it) } - } - - override fun isVisible(): Boolean = visible - - override fun equalsRemote(other: ICircleDelegate?): Boolean = equals(other) - - override fun hashCodeRemote(): Int = hashCode() - - override fun hashCode(): Int { - return id.hashCode() - } - - override fun toString(): String { - return id - } - - override fun equals(other: Any?): Boolean { - if (other is CircleImpl) { - return other.id == id - } - return false - } - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } - - companion object { - val TAG = "GmsMapCircle" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Marker.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Marker.kt deleted file mode 100644 index 981bc860..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Marker.kt +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.model - -import android.util.Log -import com.google.android.gms.dynamic.IObjectWrapper -import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.MarkerOptions -import com.google.android.gms.maps.model.internal.IMarkerDelegate -import com.mapbox.mapboxsdk.plugins.annotation.AnnotationManager -import com.mapbox.mapboxsdk.plugins.annotation.Symbol -import com.mapbox.mapboxsdk.plugins.annotation.SymbolOptions -import org.microg.gms.kotlin.unwrap -import org.microg.gms.maps.mapbox.GoogleMapImpl -import org.microg.gms.maps.mapbox.utils.toMapbox - -class MarkerImpl(private val map: GoogleMapImpl, private val id: String, options: MarkerOptions) : IMarkerDelegate.Stub(), Markup { - private var position: LatLng = options.position - private var visible: Boolean = options.isVisible - private var rotation: Float = options.rotation - private var anchor: FloatArray = floatArrayOf(options.anchorU, options.anchorV) - private var icon: BitmapDescriptorImpl? = options.icon?.remoteObject.unwrap() - private var alpha: Float = options.alpha - private var title: String? = options.title - private var snippet: String? = options.snippet - private var zIndex: Float = options.zIndex - private var draggable: Boolean = options.isDraggable - private var tag: IObjectWrapper? = null - - override var annotation: Symbol? = null - override var removed: Boolean = false - override val annotationOptions: SymbolOptions - get() { - val symbolOptions = SymbolOptions() - .withIconOpacity(if (visible) alpha else 0f) - .withIconRotate(rotation) - .withSymbolSortKey(zIndex) - .withDraggable(draggable) - - position.let { symbolOptions.withLatLng(it.toMapbox()) } - icon?.applyTo(symbolOptions, anchor, map.dpiFactor) - return symbolOptions - } - - override fun remove() { - removed = true - map.symbolManager?.let { update(it) } - } - - override fun update(manager: AnnotationManager<*, Symbol, SymbolOptions, *, *, *>) { - synchronized(this) { - val id = annotation?.id - if (removed && id != null) { - map.markers.remove(id) - } - super.update(manager) - val annotation = annotation - if (annotation != null && id == null) { - map.markers[annotation.id] = this - } - } - } - - override fun getId(): String = id - - override fun setPosition(position: LatLng?) { - this.position = position ?: return - annotation?.latLng = position.toMapbox() - map.symbolManager?.let { update(it) } - } - - override fun getPosition(): LatLng = position - - override fun setTitle(title: String?) { - this.title = title - } - - override fun getTitle(): String? = title - - override fun setSnippet(snippet: String?) { - this.snippet = snippet - } - - override fun getSnippet(): String? = snippet - - override fun setDraggable(draggable: Boolean) { - this.draggable = draggable - annotation?.isDraggable = draggable - map.symbolManager?.let { update(it) } - } - - override fun isDraggable(): Boolean = draggable - - override fun showInfoWindow() { - Log.d(TAG, "unimplemented Method: showInfoWindow") - } - - override fun hideInfoWindow() { - Log.d(TAG, "unimplemented Method: hideInfoWindow") - } - - override fun isInfoWindowShown(): Boolean { - Log.d(TAG, "unimplemented Method: isInfoWindowShow") - return false - } - - override fun setVisible(visible: Boolean) { - this.visible = visible - annotation?.iconOpacity = if (visible) alpha else 0f - map.symbolManager?.let { update(it) } - } - - override fun isVisible(): Boolean = visible - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other is IMarkerDelegate) return other.id == id - return false - } - - override fun equalsRemote(other: IMarkerDelegate?): Boolean = equals(other) - - override fun hashCode(): Int { - return id.hashCode() - } - - override fun toString(): String { - return "$id ($title)" - } - - override fun hashCodeRemote(): Int = hashCode() - - override fun setIcon(obj: IObjectWrapper?) { - obj.unwrap()?.let { icon -> - this.icon = icon - annotation?.let { icon.applyTo(it, anchor, map.dpiFactor) } - } - map.symbolManager?.let { update(it) } - } - - override fun setAnchor(x: Float, y: Float) { - anchor = floatArrayOf(x, y) - annotation?.let { icon?.applyTo(it, anchor, map.dpiFactor) } - map.symbolManager?.let { update(it) } - } - - override fun setFlat(flat: Boolean) { - Log.d(TAG, "unimplemented Method: setFlat") - } - - override fun isFlat(): Boolean { - Log.d(TAG, "unimplemented Method: isFlat") - return false - } - - override fun setRotation(rotation: Float) { - this.rotation = rotation - annotation?.iconRotate = rotation - map.symbolManager?.let { update(it) } - } - - override fun getRotation(): Float = rotation - - override fun setInfoWindowAnchor(x: Float, y: Float) { - Log.d(TAG, "unimplemented Method: setInfoWindowAnchor") - } - - override fun setAlpha(alpha: Float) { - this.alpha = alpha - annotation?.iconOpacity = if (visible) alpha else 0f - map.symbolManager?.let { update(it) } - } - - override fun getAlpha(): Float = alpha - - override fun setZIndex(zIndex: Float) { - this.zIndex = zIndex - annotation?.symbolSortKey = zIndex - map.symbolManager?.let { update(it) } - } - - override fun getZIndex(): Float = zIndex - - override fun setTag(obj: IObjectWrapper?) { - this.tag = obj - } - - override fun getTag(): IObjectWrapper? = tag - - companion object { - private val TAG = "GmsMapMarker" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Markup.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Markup.kt deleted file mode 100644 index c737afcc..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Markup.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.model - -import android.util.Log -import com.mapbox.mapboxsdk.plugins.annotation.Annotation -import com.mapbox.mapboxsdk.plugins.annotation.AnnotationManager -import com.mapbox.mapboxsdk.plugins.annotation.Options - -interface Markup, S : Options> { - var annotation: T? - val annotationOptions: S - val removed: Boolean - - fun update(manager: AnnotationManager<*, T, S, *, *, *>) { - synchronized(this) { - if (removed && annotation != null) { - manager.delete(annotation) - annotation = null - } else if (annotation != null) { - manager.update(annotation) - } else if (!removed) { - annotation = manager.create(annotationOptions) - } - } - } - - companion object { - private val TAG = "GmsMapMarkup" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polygon.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polygon.kt deleted file mode 100644 index e3d0d5ea..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polygon.kt +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.model - -import android.os.Parcel -import android.util.Log -import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.PolygonOptions -import com.google.android.gms.maps.model.PolylineOptions -import com.google.android.gms.maps.model.internal.IPolygonDelegate -import com.mapbox.mapboxsdk.plugins.annotation.AnnotationManager -import com.mapbox.mapboxsdk.plugins.annotation.Fill -import com.mapbox.mapboxsdk.plugins.annotation.FillOptions -import com.mapbox.mapboxsdk.utils.ColorUtils -import org.microg.gms.maps.mapbox.GoogleMapImpl -import org.microg.gms.maps.mapbox.utils.toMapbox - -class PolygonImpl(private val map: GoogleMapImpl, private val id: String, options: PolygonOptions) : IPolygonDelegate.Stub(), Markup { - private var points = ArrayList(options.points) - private var holes: List> = ArrayList(options.holes.map { ArrayList(it) }) - private var fillColor = options.fillColor - private var strokeColor = options.strokeColor - private var strokeWidth = options.strokeWidth - private var visible: Boolean = options.isVisible - - private var strokes = (listOf(PolylineImpl(map, "$id-stroke-main", PolylineOptions().color(strokeColor).width(strokeWidth).addAll(points))) - + holes.mapIndexed { idx, it -> PolylineImpl(map, "$id-stroke-hole-$idx", PolylineOptions().color(strokeColor).width(strokeWidth).addAll(it)) }).toMutableList() - - override var annotation: Fill? = null - override var removed: Boolean = false - override val annotationOptions: FillOptions - get() = FillOptions() - .withLatLngs(mutableListOf(points.map { it.toMapbox() }).plus(holes.map { it.map { it.toMapbox() } })) - .withFillColor(ColorUtils.colorToRgbaString(fillColor)) - .withFillOpacity(if (visible) 1f else 0f) - - override fun remove() { - removed = true - map.fillManager?.let { update(it) } - strokes.forEach { it.remove() } - } - - override fun update(manager: AnnotationManager<*, Fill, FillOptions, *, *, *>) { - super.update(manager) - map.lineManager?.let { lineManager -> strokes.forEach { it.update(lineManager) } } - } - - override fun getId(): String = id - - override fun setPoints(points: List) { - this.points = ArrayList(points) - annotation?.latLngs = mutableListOf(points.map { it.toMapbox() }).plus(holes.map { it.map { it.toMapbox() } }) - map.fillManager?.let { update(it) } - strokes[0].points = points - } - - override fun getPoints(): List = points - - override fun setHoles(holes: List?) { - this.holes = if (holes == null) emptyList() else ArrayList(holes.mapNotNull { if (it is List<*>) it.mapNotNull { if (it is LatLng) it else null }.let { if (it.isNotEmpty()) it else null } else null }) - annotation?.latLngs = mutableListOf(points.map { it.toMapbox() }).plus(this.holes.map { it.map { it.toMapbox() } }) - while (strokes.size > this.holes.size + 1) { - val last = strokes.last() - last.remove() - strokes.remove(last) - } - strokes.forEachIndexed { idx, it -> if (idx > 0) it.points = this.holes[idx - 1] } - if (this.holes.size + 1 > strokes.size) { - strokes.addAll(this.holes.subList(strokes.size, this.holes.size - 1).mapIndexed { idx, it -> PolylineImpl(map, "$id-stroke-hole-${strokes.size + idx}", PolylineOptions().color(strokeColor).width(strokeWidth).addAll(it)) }) - } - map.fillManager?.let { update(it) } - } - - override fun getHoles(): List = holes - - override fun setStrokeWidth(width: Float) { - this.strokeWidth = width - strokes.forEach { it.width = width } - } - - override fun getStrokeWidth(): Float = strokeWidth - - override fun setStrokeColor(color: Int) { - this.strokeColor = color - strokes.forEach { it.color = color } - } - - override fun getStrokeColor(): Int = strokeColor - - override fun setFillColor(color: Int) { - this.fillColor = color - annotation?.setFillColor(color) - map.fillManager?.let { update(it) } - } - - override fun getFillColor(): Int = fillColor - - override fun setZIndex(zIndex: Float) { - Log.d(TAG, "unimplemented Method: setZIndex") - } - - override fun getZIndex(): Float { - Log.d(TAG, "unimplemented Method: getZIndex") - return 0f - } - - override fun setVisible(visible: Boolean) { - this.visible = visible - annotation?.fillOpacity = if (visible) 1f else 0f - map.fillManager?.let { update(it) } - } - - override fun isVisible(): Boolean = visible - - override fun setGeodesic(geod: Boolean) { - Log.d(TAG, "unimplemented Method: setGeodesic") - } - - override fun isGeodesic(): Boolean { - Log.d(TAG, "unimplemented Method: isGeodesic") - return false - } - - override fun equalsRemote(other: IPolygonDelegate?): Boolean = equals(other) - - override fun hashCodeRemote(): Int = hashCode() - - override fun hashCode(): Int { - return id.hashCode() - } - - override fun toString(): String { - return id - } - - override fun equals(other: Any?): Boolean { - if (other is PolygonImpl) { - return other.id == id - } - return false - } - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } - - companion object { - private val TAG = "GmsMapPolygon" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polyline.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polyline.kt deleted file mode 100644 index f9a8f91b..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Polyline.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.model - -import android.os.Parcel -import android.util.Log -import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.internal.IPolylineDelegate -import com.mapbox.mapboxsdk.plugins.annotation.Line -import com.mapbox.mapboxsdk.plugins.annotation.LineOptions -import com.mapbox.mapboxsdk.utils.ColorUtils -import org.microg.gms.maps.mapbox.GoogleMapImpl -import org.microg.gms.maps.mapbox.utils.toMapbox -import com.google.android.gms.maps.model.PolylineOptions as GmsLineOptions - -class PolylineImpl(private val map: GoogleMapImpl, private val id: String, options: GmsLineOptions) : IPolylineDelegate.Stub(), Markup { - private var points = ArrayList(options.points) - private var width = options.width - private var color = options.color - private var visible: Boolean = options.isVisible - - override var annotation: Line? = null - override var removed: Boolean = false - override val annotationOptions: LineOptions - get() = LineOptions() - .withLatLngs(points.map { it.toMapbox() }) - .withLineWidth(width / map.dpiFactor) - .withLineColor(ColorUtils.colorToRgbaString(color)) - .withLineOpacity(if (visible) 1f else 0f) - - override fun remove() { - removed = true - map.lineManager?.let { update(it) } - } - - override fun getId(): String = id - - override fun setPoints(points: List) { - this.points = ArrayList(points) - annotation?.latLngs = points.map { it.toMapbox() } - map.lineManager?.let { update(it) } - } - - override fun getPoints(): List = points - - override fun setWidth(width: Float) { - this.width = width - annotation?.lineWidth = width / map.dpiFactor - map.lineManager?.let { update(it) } - } - - override fun getWidth(): Float = width - - override fun setColor(color: Int) { - this.color = color - annotation?.setLineColor(color) - map.lineManager?.let { update(it) } - } - - override fun getColor(): Int = color - - override fun setZIndex(zIndex: Float) { - Log.d(TAG, "unimplemented Method: setZIndex") - } - - override fun getZIndex(): Float { - Log.d(TAG, "unimplemented Method: getZIndex") - return 0f - } - - override fun setVisible(visible: Boolean) { - this.visible = visible - annotation?.lineOpacity = if (visible) 1f else 0f - map.lineManager?.let { update(it) } - } - - override fun isVisible(): Boolean = visible - - override fun setGeodesic(geod: Boolean) { - Log.d(TAG, "unimplemented Method: setGeodesic") - } - - override fun isGeodesic(): Boolean { - Log.d(TAG, "unimplemented Method: isGeodesic") - return false - } - - override fun equalsRemote(other: IPolylineDelegate?): Boolean = equals(other) - - override fun hashCodeRemote(): Int = hashCode() - - override fun hashCode(): Int { - return id.hashCode() - } - - override fun toString(): String { - return id - } - - override fun equals(other: Any?): Boolean { - if (other is PolylineImpl) { - return other.id == id - } - return false - } - - override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = - if (super.onTransact(code, data, reply, flags)) { - true - } else { - Log.d(TAG, "onTransact [unknown]: $code, $data, $flags"); false - } - - companion object { - private val TAG = "GmsMapPolyline" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/MapContext.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/MapContext.kt deleted file mode 100644 index 2b00202a..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/MapContext.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.utils - -import android.content.Context -import android.content.ContextWrapper -import android.content.Intent -import android.content.SharedPreferences -import android.view.LayoutInflater -import org.microg.gms.common.Constants -import java.io.File - -class MapContext(private val context: Context) : ContextWrapper(context.createPackageContext(Constants.GMS_PACKAGE_NAME, Context.CONTEXT_INCLUDE_CODE and Context.CONTEXT_IGNORE_SECURITY)) { - private var layoutInflater: LayoutInflater? = null - private val appContext: Context - get() = context.applicationContext ?: context - - override fun getApplicationContext(): Context { - return this - } - - override fun getCacheDir(): File { - val cacheDir = File(appContext.cacheDir, "com.google.android.gms") - cacheDir.mkdirs() - return cacheDir - } - - override fun getFilesDir(): File { - val filesDir = File(appContext.filesDir, "com.google.android.gms") - filesDir.mkdirs() - return filesDir - } - - override fun getPackageName(): String { - return appContext.packageName - } - - override fun getClassLoader(): ClassLoader { - return MapContext::class.java.classLoader!! - } - - override fun getSharedPreferences(name: String?, mode: Int): SharedPreferences { - return appContext.getSharedPreferences("com.google.android.gms_$name", mode) - } - - override fun getSystemService(name: String): Any? { - if (name == Context.LAYOUT_INFLATER_SERVICE) { - if (layoutInflater == null) { - layoutInflater = super.getSystemService(name) as LayoutInflater - layoutInflater?.cloneInContext(this)?.let { layoutInflater = it } - } - if (layoutInflater != null) { - return layoutInflater - } - } - return context.getSystemService(name) - } - - override fun startActivity(intent: Intent?) { - context.startActivity(intent) - } - - companion object { - val TAG = "GmsMapContext" - } -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/MultiArchLoader.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/MultiArchLoader.kt deleted file mode 100644 index 598860f0..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/MultiArchLoader.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.utils - -import android.annotation.SuppressLint -import android.content.Context -import android.content.pm.ApplicationInfo -import android.util.Log -import com.mapbox.mapboxsdk.LibraryLoader -import java.io.* -import java.util.zip.ZipFile - -class MultiArchLoader(private val mapContext: Context, private val appContext: Context) : LibraryLoader() { - @SuppressLint("UnsafeDynamicallyLoadedCode") - override fun load(name: String) { - try { - val otherAppInfo = mapContext.packageManager.getApplicationInfo(appContext.packageName, 0) - var primaryCpuAbi = ApplicationInfo::class.java.getField("primaryCpuAbi").get(otherAppInfo) as String? - if (primaryCpuAbi == "armeabi") { - primaryCpuAbi = "armeabi-v7a" - } - if (primaryCpuAbi != null) { - val path = "lib/$primaryCpuAbi/lib$name.so" - val cacheFile = File("${appContext.cacheDir.absolutePath}/.gmscore/$path") - cacheFile.parentFile.mkdirs() - val apkFile = File(mapContext.packageCodePath) - if (!cacheFile.exists() || cacheFile.lastModified() < apkFile.lastModified()) { - val zipFile = ZipFile(apkFile) - val entry = zipFile.getEntry(path) - if (entry != null) { - copyInputStream(zipFile.getInputStream(entry), FileOutputStream(cacheFile)) - } else { - Log.d(TAG, "Can't load native library: $path does not exist in $apkFile") - } - } - Log.d(TAG, "Loading $name from ${cacheFile.getPath()}") - System.load(cacheFile.absolutePath) - return - } - } catch (e: Exception) { - Log.w(TAG, e) - } - Log.d(TAG, "Loading native $name") - System.loadLibrary(name) - } - - @Throws(IOException::class) - private fun copyInputStream(inp: InputStream, out: OutputStream) { - val buffer = ByteArray(1024) - var len: Int = inp.read(buffer) - while (len >= 0) { - out.write(buffer, 0, len) - len = inp.read(buffer) - } - - inp.close() - out.close() - } - - companion object { - private val TAG = "GmsMultiArchLoader" - } - -} \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/typeConverter.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/typeConverter.kt deleted file mode 100644 index d49cef35..00000000 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/utils/typeConverter.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.mapbox.utils - -import android.os.Bundle -import com.google.android.gms.maps.internal.ICancelableCallback -import com.mapbox.mapboxsdk.camera.CameraPosition -import com.mapbox.mapboxsdk.geometry.LatLng -import com.mapbox.mapboxsdk.geometry.LatLngBounds -import com.mapbox.mapboxsdk.geometry.VisibleRegion -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.google.android.gms.maps.model.CameraPosition as GmsCameraPosition -import com.google.android.gms.maps.model.LatLng as GmsLatLng -import com.google.android.gms.maps.model.LatLngBounds as GmsLatLngBounds -import com.google.android.gms.maps.model.VisibleRegion as GmsVisibleRegion - -fun GmsLatLng.toMapbox(): LatLng = - LatLng(latitude, longitude) - -fun GmsLatLngBounds.toMapbox(): LatLngBounds = - LatLngBounds.from(this.northeast.latitude, this.northeast.longitude, this.southwest.latitude, this.southwest.longitude) - -fun GmsCameraPosition.toMapbox(): CameraPosition = - CameraPosition.Builder() - .target(target.toMapbox()) - .zoom(zoom.toDouble() - 1.0) - .tilt(tilt.toDouble()) - .bearing(bearing.toDouble()) - .build() - -fun ICancelableCallback.toMapbox(): MapboxMap.CancelableCallback = - object : MapboxMap.CancelableCallback { - override fun onFinish() = this@toMapbox.onFinish() - override fun onCancel() = this@toMapbox.onCancel() - } - - -fun Bundle.toMapbox(): Bundle { - val newBundle = Bundle(this) - for (key in newBundle.keySet()) { - val value = newBundle.get(key) - when (value) { - is GmsCameraPosition -> newBundle.putParcelable(key, value.toMapbox()) - is GmsLatLng -> newBundle.putParcelable(key, value.toMapbox()) - is GmsLatLngBounds -> newBundle.putParcelable(key, value.toMapbox()) - is Bundle -> newBundle.putBundle(key, value.toMapbox()) - } - } - return newBundle -} - -fun LatLng.toGms(): GmsLatLng = GmsLatLng(latitude, longitude) - -fun LatLngBounds.toGms(): GmsLatLngBounds = GmsLatLngBounds(southWest.toGms(), northEast.toGms()) - -fun CameraPosition.toGms(): GmsCameraPosition = - GmsCameraPosition(target.toGms(), zoom.toFloat() + 1.0f, tilt.toFloat(), bearing.toFloat()) - -fun Bundle.toGms(): Bundle { - val newBundle = Bundle(this) - for (key in newBundle.keySet()) { - val value = newBundle.get(key) - when (value) { - is CameraPosition -> newBundle.putParcelable(key, value.toGms()) - is LatLng -> newBundle.putParcelable(key, value.toGms()) - is LatLngBounds -> newBundle.putParcelable(key, value.toGms()) - is Bundle -> newBundle.putBundle(key, value.toGms()) - } - } - return newBundle -} - -fun VisibleRegion.toGms(): GmsVisibleRegion = - GmsVisibleRegion(nearLeft.toGms(), nearRight.toGms(), farLeft.toGms(), farRight.toGms(), latLngBounds.toGms()) \ No newline at end of file diff --git a/play-services-maps-core-mapbox/src/main/res/drawable-hdpi/maps_default_marker.png b/play-services-maps-core-mapbox/src/main/res/drawable-hdpi/maps_default_marker.png deleted file mode 100644 index 94c365a3..00000000 Binary files a/play-services-maps-core-mapbox/src/main/res/drawable-hdpi/maps_default_marker.png and /dev/null differ diff --git a/play-services-maps-core-mapbox/src/main/res/drawable-ldpi/maps_default_marker.png b/play-services-maps-core-mapbox/src/main/res/drawable-ldpi/maps_default_marker.png deleted file mode 100644 index a8ca2bf6..00000000 Binary files a/play-services-maps-core-mapbox/src/main/res/drawable-ldpi/maps_default_marker.png and /dev/null differ diff --git a/play-services-maps-core-mapbox/src/main/res/drawable-mdpi/maps_default_marker.png b/play-services-maps-core-mapbox/src/main/res/drawable-mdpi/maps_default_marker.png deleted file mode 100644 index c79736e7..00000000 Binary files a/play-services-maps-core-mapbox/src/main/res/drawable-mdpi/maps_default_marker.png and /dev/null differ diff --git a/play-services-maps-core-mapbox/src/main/res/drawable-xhdpi/maps_default_marker.png b/play-services-maps-core-mapbox/src/main/res/drawable-xhdpi/maps_default_marker.png deleted file mode 100644 index 0b1b1975..00000000 Binary files a/play-services-maps-core-mapbox/src/main/res/drawable-xhdpi/maps_default_marker.png and /dev/null differ diff --git a/play-services-maps-core-mapbox/src/main/res/drawable-xxhdpi/maps_default_marker.png b/play-services-maps-core-mapbox/src/main/res/drawable-xxhdpi/maps_default_marker.png deleted file mode 100644 index 709bf78d..00000000 Binary files a/play-services-maps-core-mapbox/src/main/res/drawable-xxhdpi/maps_default_marker.png and /dev/null differ diff --git a/play-services-maps-core-mapbox/src/main/res/drawable-xxxhdpi/maps_default_marker.png b/play-services-maps-core-mapbox/src/main/res/drawable-xxxhdpi/maps_default_marker.png deleted file mode 100644 index 0de5d255..00000000 Binary files a/play-services-maps-core-mapbox/src/main/res/drawable-xxxhdpi/maps_default_marker.png and /dev/null differ diff --git a/play-services-maps-core-vtm/build.gradle b/play-services-maps-core-vtm/build.gradle deleted file mode 100644 index 1a00c16e..00000000 --- a/play-services-maps-core-vtm/build.gradle +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2013-2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: "com.android.library" - -dependencies { - implementation project(":play-services-api") - - implementation "org.microg:vtm-android:0.9.1-mod" - implementation "org.microg:vtm-android:0.9.1-mod:natives-armeabi" - implementation "org.microg:vtm-android:0.9.1-mod:natives-armeabi-v7a" - implementation "org.microg:vtm-android:0.9.1-mod:natives-arm64-v8a" - implementation "org.microg:vtm-android:0.9.1-mod:natives-x86" - implementation "org.microg:vtm-android:0.9.1-mod:natives-x86_64" - implementation "org.microg:vtm-extras:0.9.1-mod" - implementation "org.microg:vtm-jts:0.9.1-mod" - implementation project(":play-services-maps-core-vtm:vtm-microg-theme") - - implementation "androidx.appcompat:appcompat:$appcompatVersion" -} - -def execResult(...args) { - def stdout = new ByteArrayOutputStream() - exec { - commandLine args - standardOutput = stdout - } - return stdout.toString().trim() -} - -android { - compileSdkVersion androidCompileSdk() - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName "temp" - versionCode 1 - - minSdkVersion androidMinSdk() - targetSdkVersion androidTargetSdk() - - ndk { - abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64" - } - } - - lintOptions { - disable "MissingTranslation", "InvalidPackage", "BatteryLife", "ImpliedQuantity", "MissingQuantity" - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -if (file("user.gradle").exists()) { - apply from: "user.gradle" -} diff --git a/play-services-maps-core-vtm/src/main/AndroidManifest.xml b/play-services-maps-core-vtm/src/main/AndroidManifest.xml deleted file mode 100644 index 31b554e4..00000000 --- a/play-services-maps-core-vtm/src/main/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/play-services-maps-core-vtm/src/main/java/com/google/android/gms/maps/internal/CreatorImpl.java b/play-services-maps-core-vtm/src/main/java/com/google/android/gms/maps/internal/CreatorImpl.java deleted file mode 100644 index 42e83ec3..00000000 --- a/play-services-maps-core-vtm/src/main/java/com/google/android/gms/maps/internal/CreatorImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.maps.internal; - -import android.app.Activity; -import android.content.Context; -import android.content.res.Resources; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -import androidx.annotation.Keep; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.GoogleMapOptions; -import com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate; - -import org.microg.gms.maps.vtm.MapFragmentImpl; -import org.microg.gms.maps.vtm.MapViewImpl; -import org.microg.gms.maps.vtm.ResourcesContainer; -import org.microg.gms.maps.vtm.bitmap.BitmapDescriptorFactoryImpl; -import org.microg.gms.maps.vtm.camera.CameraUpdateFactoryImpl; - -@Keep -public class CreatorImpl extends ICreator.Stub { - private static final String TAG = "GmsMapCreator"; - - @Override - public void init(IObjectWrapper resources) throws RemoteException { - initV2(resources, 0); - } - - @Override - public IMapFragmentDelegate newMapFragmentDelegate(IObjectWrapper activity) throws RemoteException { - return new MapFragmentImpl((Activity) ObjectWrapper.unwrap(activity)); - } - - @Override - public IMapViewDelegate newMapViewDelegate(IObjectWrapper context, GoogleMapOptions options) throws RemoteException { - return new MapViewImpl((Context) ObjectWrapper.unwrap(context), options); - } - - @Override - public ICameraUpdateFactoryDelegate newCameraUpdateFactoryDelegate() throws RemoteException { - return CameraUpdateFactoryImpl.get(); - } - - @Override - public IBitmapDescriptorFactoryDelegate newBitmapDescriptorFactoryDelegate() throws RemoteException { - return new BitmapDescriptorFactoryImpl(); - } - - @Override - public void initV2(IObjectWrapper resources, int flags) throws RemoteException { - ResourcesContainer.set((Resources) ObjectWrapper.unwrap(resources)); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ApplicationContextWrapper.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ApplicationContextWrapper.java deleted file mode 100644 index ebb6caa6..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ApplicationContextWrapper.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.content.Context; -import android.content.ContextWrapper; -import android.content.pm.PackageManager; - -import org.microg.gms.common.Constants; - -public class ApplicationContextWrapper extends ContextWrapper { - private Context applicationContext; - - public ApplicationContextWrapper(Context base, Context applicationContext) { - super(base); - this.applicationContext = applicationContext; - } - - public static ApplicationContextWrapper gmsContextWithAttachedApplicationContext(Context applicationContext) { - try { - Context context = applicationContext.createPackageContext(Constants.GMS_PACKAGE_NAME, CONTEXT_INCLUDE_CODE & CONTEXT_IGNORE_SECURITY); - return new ApplicationContextWrapper(context, applicationContext); - } catch (PackageManager.NameNotFoundException e) { - throw new RuntimeException(e); - } - } - - public static ApplicationContextWrapper matchingApplicationContext(Context context) { - return new ApplicationContextWrapper(context, context); - } - - @Override - public Context getApplicationContext() { - return applicationContext; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/BackendMap.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/BackendMap.java deleted file mode 100644 index 2a94e5fb..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/BackendMap.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.os.RemoteException; -import android.util.Log; -import android.view.View; - -import com.google.android.gms.maps.internal.ISnapshotReadyCallback; -import com.google.android.gms.maps.model.CameraPosition; - -import org.microg.gms.maps.vtm.camera.CameraUpdate; -import org.microg.gms.maps.vtm.markup.DrawableMarkup; -import org.microg.gms.maps.vtm.markup.MarkerItemMarkup; -import org.microg.gms.maps.vtm.markup.Markup; -import org.oscim.backend.GL; -import org.oscim.backend.GLAdapter; -import org.oscim.core.MapPosition; -import org.oscim.core.Point; -import org.oscim.event.Event; -import org.oscim.event.MotionEvent; -import org.oscim.layers.marker.ItemizedLayer; -import org.oscim.layers.marker.MarkerItem; -import org.oscim.layers.vector.geometries.Drawable; -import org.oscim.map.Viewport; - -import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.microedition.khronos.opengles.GL10; - -public class BackendMap implements ItemizedLayer.OnItemGestureListener, org.oscim.map.Map.InputListener, org.oscim.map.Map.UpdateListener { - private final static String TAG = "GmsMapBackend"; - - private final Context context; - private final BackendMapView mapView; - private final ContainerLayout container; - private final CameraUpdateListener cameraUpdateListener; - private final Map markupMap = new HashMap(); - private final List drawableMarkups = new ArrayList(); - private MarkerItemMarkup currentlyDraggedItem; - private float dragLastX = -1; - private float dragLastY = -1; - - public BackendMap(Context context, final CameraUpdateListener cameraUpdateListener) { - this.context = context; - this.cameraUpdateListener = cameraUpdateListener; - mapView = new BackendMapView(context); - mapView.items().setOnItemGestureListener(this); - mapView.map().input.bind(this); - mapView.map().events.bind(this); - container = new ContainerLayout(context); - container.addView(mapView); - } - - public Viewport getViewport() { - return mapView.map().viewport(); - } - - public void destroy() { - mapView.map().destroy(); - } - - public void onResume() { - mapView.onResume(); - } - - public void onPause() { - mapView.onPause(); - } - - public MapPosition getMapPosition() { - return mapView.map().getMapPosition(); - } - - public View getView() { - return container; - } - - public boolean hasBuilding() { - return mapView.map().layers().contains(mapView.buildings()); - } - - public void setBuildings(boolean buildingsEnabled) { - if (!hasBuilding() && buildingsEnabled) { - mapView.map().layers().add(mapView.buildings()); - } else if (hasBuilding() && !buildingsEnabled) { - mapView.map().layers().remove(mapView.buildings()); - } - redraw(); - } - - public void redraw() { - mapView.map().updateMap(true); - } - - public void applyCameraUpdate(CameraUpdate cameraUpdate) { - cameraUpdate.apply(mapView.map()); - } - - public void applyCameraUpdateAnimated(CameraUpdate cameraUpdate, int durationMs) { - cameraUpdate.applyAnimated(mapView.map(), durationMs); - } - - public void stopAnimation() { - mapView.map().animator().cancel(); - } - - public synchronized T add(T markup) { - if (markup == null) return null; - drawableMarkups.add(markup); - Collections.sort(drawableMarkups, new Comparator() { - @Override - public int compare(DrawableMarkup lhs, DrawableMarkup rhs) { - return Float.compare(lhs.getZIndex(), rhs.getZIndex()); - } - }); - updateDrawableLayer(); - redraw(); - return markup; - } - - private synchronized void updateDrawableLayer() { - mapView.drawables().clear(); - for (DrawableMarkup markup : drawableMarkups) { - Drawable drawable = markup.getDrawable(mapView.map()); - if (drawable != null) { - mapView.drawables().add(drawable); - } - } - } - - public synchronized T add(T markup) { - if (markup == null) return null; - markupMap.put(markup.getId(), markup); - MarkerItem item = markup.getMarkerItem(context); - mapView.items().addItem(item); - redraw(); - return markup; - } - - public synchronized void clear() { - markupMap.clear(); - mapView.items().removeAllItems(); - drawableMarkups.clear(); - mapView.drawables().clear(); - redraw(); - } - - public synchronized void remove(Markup markup) { - if (markup instanceof MarkerItemMarkup) { - markupMap.remove(markup.getId()); - MarkerItem toRemove = getByUid(markup.getId()); - if (toRemove != null) mapView.items().removeItem(toRemove); - } else if (markup instanceof DrawableMarkup) { - drawableMarkups.remove(markup); - updateDrawableLayer(); - mapView.drawables().update(); - } - redraw(); - } - - private MarkerItem getByUid(String uid) { - for (MarkerItem markerItem : mapView.items().getItemList()) { - if (markerItem.getUid().equals(uid)) { - return markerItem; - } - } - return null; - } - - public synchronized void update(Markup markup) { - if (markup == null) return; - if (markup instanceof MarkerItemMarkup) { - MarkerItem item = getByUid(markup.getId()); - if (item != null) { - mapView.items().removeItem(item); - } - item = ((MarkerItemMarkup) markup).getMarkerItem(context); - if (item != null) { - mapView.items().addItem(item); - } - } else if (markup instanceof DrawableMarkup) { - updateDrawableLayer(); - mapView.drawables().update(); - } - redraw(); - } - - @Override - public boolean onItemSingleTapUp(int index, MarkerItem item) { - Markup markup = markupMap.get(item.getUid()); - if (markup != null) { - if (markup.onClick()) return true; - } - return false; - } - - @Override - public boolean onItemLongPress(int index, MarkerItem item) { - Markup markup = markupMap.get(item.getUid()); - if (((MarkerItemMarkup) markup).isDraggable()) { - currentlyDraggedItem = (MarkerItemMarkup) markup; - currentlyDraggedItem.onDragStart(); - return false; - } else { - Log.d(TAG, "onItemLongPress: " + markup); - return false; - } - } - - @Override - public void onInputEvent(Event event, MotionEvent motionEvent) { - if ((motionEvent.getAction() == MotionEvent.ACTION_CANCEL || motionEvent.getAction() == MotionEvent.ACTION_UP) && currentlyDraggedItem != null) { - currentlyDraggedItem.onDragStop(); - currentlyDraggedItem = null; - } - if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { - dragLastX = motionEvent.getX(); - dragLastY = motionEvent.getY(); - } - if (motionEvent.getAction() == MotionEvent.ACTION_MOVE && currentlyDraggedItem != null) { - Point out = new Point(); - mapView.map().viewport().toScreenPoint(GmsMapsTypeHelper.fromLatLng(currentlyDraggedItem.getPosition()), out); - out.x += mapView.getWidth() / 2; - out.y += mapView.getHeight() / 2; - float mx = motionEvent.getX() - dragLastX; - float my = motionEvent.getY() - dragLastY; - currentlyDraggedItem.setPosition(GmsMapsTypeHelper.toLatLng(mapView.map().viewport().fromScreenPoint((float) out.getX() + mx, (float) out.getY() + my))); - currentlyDraggedItem.onDragProgress(); - dragLastX += mx; - dragLastY += my; - } - } - - public void snapshot(final Bitmap bitmap, final ISnapshotReadyCallback callback) { - mapView.queueEvent(new Runnable() { - @Override - public void run() { - Bitmap surface = createBitmapFromGLSurface(0, 0, mapView.getWidth(), mapView.getHeight(), GLAdapter.gl); - final Bitmap result; - if (bitmap != null) { - Canvas c = new Canvas(bitmap); - c.drawBitmap(surface, 0, 0, new Paint()); - result = bitmap; - } else { - result = surface; - } - mapView.getHandler().post(new Runnable() { - @Override - public void run() { - Log.d(TAG, "snapshot result: " + result); - try { - callback.onBitmapReady(result); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - }); - } - }); - } - - private Bitmap createBitmapFromGLSurface(int x, int y, int w, int h, GL gl) { - int bitmapBuffer[] = new int[w * h]; - int bitmapSource[] = new int[w * h]; - IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer); - intBuffer.position(0); - - try { - gl.readPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer); - int offset1, offset2; - for (int i = 0; i < h; i++) { - offset1 = i * w; - offset2 = (h - i - 1) * w; - for (int j = 0; j < w; j++) { - int texturePixel = bitmapBuffer[offset1 + j]; - int blue = (texturePixel >> 16) & 0xff; - int red = (texturePixel << 16) & 0x00ff0000; - int pixel = (texturePixel & 0xff00ff00) | red | blue; - bitmapSource[offset2 + j] = pixel; - } - } - } catch (Exception e) { - Log.e(TAG, "createBitmapFromGLSurface: " + e.getMessage(), e); - return null; - } - - return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888); - } - - public void setZoomGesturesEnabled(boolean enabled) { - mapView.map().getEventLayer().enableZoom(enabled); - } - - public void setScrollGesturesEnabled(boolean enabled) { - mapView.map().getEventLayer().enableMove(enabled); - } - - public void setRotateGesturesEnabled(boolean enabled) { - mapView.map().getEventLayer().enableRotation(enabled); - } - - public void setTiltGesturesEnabled(boolean enabled) { - mapView.map().getEventLayer().enableTilt(enabled); - } - - @Override - public void onMapEvent(Event event, MapPosition mapPosition) { - if (event == org.oscim.map.Map.ANIM_END || event == org.oscim.map.Map.POSITION_EVENT || event == org.oscim.map.Map.MOVE_EVENT) - cameraUpdateListener.onCameraUpdate(GmsMapsTypeHelper.toCameraPosition(mapPosition)); - } - - public interface CameraUpdateListener { - void onCameraUpdate(CameraPosition cameraPosition); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/BackendMapView.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/BackendMapView.java deleted file mode 100644 index 6af341e6..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/BackendMapView.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.content.Context; -import android.content.ContextWrapper; -import android.content.pm.ApplicationInfo; -import android.graphics.BitmapFactory; -import android.util.AttributeSet; -import android.util.Log; - -import org.microg.gms.maps.vtm.data.SharedTileCache; -import org.microg.gms.maps.vtm.markup.ClearableVectorLayer; -import org.microg.gms.maps.vtm.R; -import org.oscim.android.AndroidAssets; -import org.oscim.android.MapView; -import org.oscim.android.canvas.AndroidBitmap; -import org.oscim.layers.marker.ItemizedLayer; -import org.oscim.layers.marker.MarkerItem; -import org.oscim.layers.marker.MarkerSymbol; -import org.oscim.layers.tile.buildings.BuildingLayer; -import org.oscim.layers.tile.vector.VectorTileLayer; -import org.oscim.layers.tile.vector.labeling.LabelLayer; -import org.oscim.map.Layers; -import org.oscim.theme.MicrogThemes; -import org.oscim.tiling.ITileCache; -import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -public class BackendMapView extends MapView { - private static final String TAG = "GmsMapView"; - - private static boolean nativeLibLoaded = false; - private LabelLayer labels; - private BuildingLayer buildings; - private ItemizedLayer items; - private ClearableVectorLayer drawables; - - static synchronized Context loadNativeLib(Context context) { - try { - if (nativeLibLoaded) return context; - ApplicationInfo otherAppInfo = context.getPackageManager().getApplicationInfo(context.getApplicationContext().getPackageName(), 0); - - String primaryCpuAbi = (String) ApplicationInfo.class.getField("primaryCpuAbi").get(otherAppInfo); - if (primaryCpuAbi != null) { - String path = "lib/" + primaryCpuAbi + "/libvtm-jni.so"; - File cacheFile = new File(context.getApplicationContext().getCacheDir().getAbsolutePath() + "/.gmscore/" + path); - cacheFile.getParentFile().mkdirs(); - File apkFile = new File(context.getPackageCodePath()); - if (!cacheFile.exists() || cacheFile.lastModified() < apkFile.lastModified()) { - ZipFile zipFile = new ZipFile(apkFile); - ZipEntry entry = zipFile.getEntry(path); - if (entry != null) { - copyInputStream(zipFile.getInputStream(entry), new FileOutputStream(cacheFile)); - } else { - Log.d(TAG, "Can't load native library: " + path + " does not exist in " + apkFile); - } - } - Log.d(TAG, "Loading vtm-jni from " + cacheFile.getPath()); - System.load(cacheFile.getAbsolutePath()); - nativeLibLoaded = true; - } - } catch (Exception e) { - Log.w(TAG, e); - } - if (!nativeLibLoaded) { - Log.d(TAG, "Loading native vtm-jni"); - System.loadLibrary("vtm-jni"); - nativeLibLoaded = true; - } - return context; - } - - private static final void copyInputStream(InputStream in, OutputStream out) throws IOException { - byte[] buffer = new byte[1024]; - int len; - - while ((len = in.read(buffer)) >= 0) - out.write(buffer, 0, len); - - in.close(); - out.close(); - } - - @Override - public void onResume() { - super.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - } - - public BackendMapView(Context context) { - super(loadNativeLib(context)); - if (context instanceof ContextWrapper) { - AndroidAssets.init(ApplicationContextWrapper.matchingApplicationContext(((ContextWrapper) context).getBaseContext())); - } - initialize(); - } - - public BackendMapView(Context context, AttributeSet attributeSet) { - super(loadNativeLib(context), attributeSet); - initialize(); - } - - ItemizedLayer items() { - return items; - } - - BuildingLayer buildings() { - return buildings; - } - - ClearableVectorLayer drawables() { - return drawables; - } - - private void initialize() { - ITileCache cache = new SharedTileCache(getContext()); - cache.setCacheSize(512 * (1 << 10)); - OSciMap4TileSource tileSource = new OSciMap4TileSource(); - tileSource.setCache(cache); - VectorTileLayer baseLayer = map().setBaseMap(tileSource); - Layers layers = map().layers(); - layers.add(drawables = new ClearableVectorLayer(map())); - layers.add(labels = new LabelLayer(map(), baseLayer)); - layers.add(buildings = new BuildingLayer(map(), baseLayer)); - layers.add(items = new ItemizedLayer(map(), new MarkerSymbol( - new AndroidBitmap(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.nop)), 0.5F, 1))); - map().setTheme(MicrogThemes.DEFAULT); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ContainerLayout.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ContainerLayout.java deleted file mode 100644 index 468d38b4..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ContainerLayout.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.content.Context; -import android.widget.FrameLayout; - -import org.oscim.utils.ThreadUtils; - -public class ContainerLayout extends FrameLayout { - public ContainerLayout(Context context) { - super(context); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - ThreadUtils.init(); - super.onLayout(changed, left, top, right, bottom); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/GmsMapsTypeHelper.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/GmsMapsTypeHelper.java deleted file mode 100644 index c68b9460..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/GmsMapsTypeHelper.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -import org.oscim.core.BoundingBox; -import org.oscim.core.Box; -import org.oscim.core.GeoPoint; -import org.oscim.core.MapPosition; -import org.oscim.core.MercatorProjection; - -public class GmsMapsTypeHelper { - public static android.graphics.Point toPoint(org.oscim.core.Point in) { - return new android.graphics.Point((int) in.getX(), (int) in.getY()); - } - - public static GeoPoint fromLatLng(LatLng latLng) { - return new GeoPoint(latLng.latitude, latLng.longitude); - } - - public static LatLng toLatLng(GeoPoint geoPoint) { - return new LatLng(geoPoint.getLatitude(), geoPoint.getLongitude()); - } - - public static LatLngBounds toLatLngBounds(Box box) { - double minLon = MercatorProjection.toLongitude(box.xmin); - double maxLon = MercatorProjection.toLongitude(box.xmax); - double minLat = MercatorProjection.toLatitude(box.ymax); - double maxLat = MercatorProjection.toLatitude(box.ymin); - if (Double.isNaN(minLon) || Double.isNaN(maxLon) || Double.isNaN(minLat) || Double.isNaN(maxLat)) - minLon = maxLon = minLat = maxLat = 0; - return new LatLngBounds(new LatLng(minLat, minLon), new LatLng(maxLat, maxLon)); - } - - public static org.oscim.core.Point fromPoint(android.graphics.Point point) { - return new org.oscim.core.Point(point.x, point.y); - } - - public static CameraPosition toCameraPosition(MapPosition mapPosition) { - return new CameraPosition(new LatLng(mapPosition.getLatitude(), mapPosition.getLongitude()), - toZoom(mapPosition.getScale()), mapPosition.getTilt(), - toBearing(mapPosition.getBearing())); - } - - public static MapPosition fromCameraPosition(CameraPosition cameraPosition) { - MapPosition mapPosition = new MapPosition(cameraPosition.target.latitude, - cameraPosition.target.longitude, fromZoom(cameraPosition.zoom)); - mapPosition.setTilt(cameraPosition.tilt); - mapPosition.setBearing(fromBearing(cameraPosition.bearing)); - return mapPosition; - } - - public static BoundingBox fromLatLngBounds(LatLngBounds bounds) { - return new BoundingBox(bounds.southwest.latitude, bounds.southwest.longitude, - bounds.northeast.latitude, bounds.northeast.longitude); - } - - public static float fromBearing(float bearing) { - return -bearing; - } - - public static float toBearing(float bearing) { - return -bearing; - } - - public static double fromZoom(float zoom) { - return Math.pow(2, zoom); - } - - public static float toZoom(double scale) { - return (float) (Math.log(scale) / Math.log(2)); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/GoogleMapImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/GoogleMapImpl.java deleted file mode 100644 index f34c066e..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/GoogleMapImpl.java +++ /dev/null @@ -1,707 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.content.Context; -import android.graphics.Bitmap; -import android.location.Criteria; -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; -import android.view.View; - -import androidx.core.content.ContextCompat; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.GoogleMapOptions; -import com.google.android.gms.maps.internal.ICancelableCallback; -import com.google.android.gms.maps.internal.IGoogleMapDelegate; -import com.google.android.gms.maps.internal.IInfoWindowAdapter; -import com.google.android.gms.maps.internal.ILocationSourceDelegate; -import com.google.android.gms.maps.internal.IOnCameraChangeListener; -import com.google.android.gms.maps.internal.IOnCameraIdleListener; -import com.google.android.gms.maps.internal.IOnCameraMoveCanceledListener; -import com.google.android.gms.maps.internal.IOnCameraMoveListener; -import com.google.android.gms.maps.internal.IOnCameraMoveStartedListener; -import com.google.android.gms.maps.internal.IOnInfoWindowClickListener; -import com.google.android.gms.maps.internal.IOnMapClickListener; -import com.google.android.gms.maps.internal.IOnMapLoadedCallback; -import com.google.android.gms.maps.internal.IOnMapLongClickListener; -import com.google.android.gms.maps.internal.IOnMarkerClickListener; -import com.google.android.gms.maps.internal.IOnMarkerDragListener; -import com.google.android.gms.maps.internal.IOnMyLocationButtonClickListener; -import com.google.android.gms.maps.internal.IOnMyLocationChangeListener; -import com.google.android.gms.maps.internal.IProjectionDelegate; -import com.google.android.gms.maps.internal.ISnapshotReadyCallback; -import com.google.android.gms.maps.internal.IUiSettingsDelegate; -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.model.CircleOptions; -import com.google.android.gms.maps.model.GroundOverlayOptions; -import com.google.android.gms.maps.model.LatLngBounds; -import com.google.android.gms.maps.model.MarkerOptions; -import com.google.android.gms.maps.model.PolygonOptions; -import com.google.android.gms.maps.model.PolylineOptions; -import com.google.android.gms.maps.model.TileOverlayOptions; -import com.google.android.gms.maps.model.internal.ICircleDelegate; -import com.google.android.gms.maps.model.internal.IGroundOverlayDelegate; -import com.google.android.gms.maps.model.internal.IMarkerDelegate; -import com.google.android.gms.maps.model.internal.IPolygonDelegate; -import com.google.android.gms.maps.model.internal.IPolylineDelegate; -import com.google.android.gms.maps.model.internal.ITileOverlayDelegate; - -import org.microg.gms.maps.vtm.camera.CameraUpdate; -import org.microg.gms.maps.vtm.camera.MapPositionCameraUpdate; -import org.microg.gms.maps.vtm.markup.CircleImpl; -import org.microg.gms.maps.vtm.markup.GroundOverlayImpl; -import org.microg.gms.maps.vtm.markup.MarkerImpl; -import org.microg.gms.maps.vtm.markup.Markup; -import org.microg.gms.maps.vtm.markup.PolygonImpl; -import org.microg.gms.maps.vtm.markup.PolylineImpl; -import org.microg.gms.maps.vtm.markup.TileOverlayImpl; - -import static android.Manifest.permission.ACCESS_COARSE_LOCATION; -import static android.Manifest.permission.ACCESS_FINE_LOCATION; -import static android.content.pm.PackageManager.PERMISSION_GRANTED; - -public class GoogleMapImpl extends IGoogleMapDelegate.Stub - implements UiSettingsImpl.UiSettingsListener, Markup.MarkupListener, BackendMap.CameraUpdateListener { - private static final String TAG = "GmsMapImpl"; - - private final GoogleMapOptions options; - private final Context context; - private final BackendMap backendMap; - private final UiSettingsImpl uiSettings; - private final ProjectionImpl projection; - - private int markerCounter = 0; - private int circleCounter = 0; - private int polylineCounter = 0; - private int polygonCounter = 0; - - private IOnMarkerClickListener onMarkerClickListener; - private IOnMarkerDragListener onMarkerDragListener; - private IOnCameraChangeListener onCameraChangeListener; - private IOnMyLocationChangeListener onMyLocationChangeListener; - - private Criteria criteria; - private Location myLocation; - private LocationListener listener = new LocationListener() { - @Override - public void onLocationChanged(Location location) { - // TODO: Actually do my location overlay - myLocation = location; - if (onMyLocationChangeListener != null && location != null) { - try { - onMyLocationChangeListener.onMyLocationChanged(ObjectWrapper.wrap(location)); - } catch (RemoteException e) { - e.printStackTrace(); - } - } - } - - @Override - public void onStatusChanged(String provider, int status, Bundle extras) { - } - - @Override - public void onProviderEnabled(String provider) { - } - - @Override - public void onProviderDisabled(String provider) { - } - }; - - private GoogleMapImpl(Context context, GoogleMapOptions options) { - this.context = context; - Context appContext = context; - if (appContext.getApplicationContext() != null) - appContext = appContext.getApplicationContext(); - Context wrappedContext = ApplicationContextWrapper.gmsContextWithAttachedApplicationContext(appContext); - backendMap = new BackendMap(wrappedContext, this); - uiSettings = new UiSettingsImpl(this); - projection = new ProjectionImpl(backendMap.getViewport()); - this.options = options; - - criteria = new Criteria(); - criteria.setAccuracy(Criteria.ACCURACY_COARSE); - criteria.setPowerRequirement(Criteria.POWER_MEDIUM); - - if (options != null) initFromOptions(); - } - - public synchronized static GoogleMapImpl create(Context context, GoogleMapOptions options) { - return new GoogleMapImpl(context, options); - } - - private void initFromOptions() { - try { - uiSettings.setCompassEnabled(options.getCompassEnabled()); - uiSettings.setRotateGesturesEnabled(options.isRotateGesturesEnabled()); - uiSettings.setTiltGesturesEnabled(options.isTiltGesturesEnabled()); - uiSettings.setScrollGesturesEnabled(options.isScrollGesturesEnabled()); - uiSettings.setZoomControlsEnabled(options.isZoomControlsEnabled()); - uiSettings.setZoomGesturesEnabled(options.isZoomGesturesEnabled()); - if (options.getCamera() != null) { - backendMap.applyCameraUpdate(MapPositionCameraUpdate.directMapPosition(GmsMapsTypeHelper.fromCameraPosition(options.getCamera()))); - } - } catch (RemoteException e) { - // Never happens: not remote - } - } - - public void onDestroy() { - backendMap.destroy(); - } - - @Override - public void onLowMemory() throws RemoteException { - Log.d(TAG, "unimplemented Method: onLowMemory"); - - } - - @Override - public boolean useViewLifecycleWhenInFragment() throws RemoteException { - Log.d(TAG, "unimplemented Method: useViewLifecycleWhenInFragment"); - return false; - } - - @Override - public void onSaveInstanceState(Bundle outState) throws RemoteException { - Log.d(TAG, "unimplemented Method: onSaveInstanceState"); - - } - - @Override - public void setContentDescription(String desc) throws RemoteException { - Log.d(TAG, "unimplemented Method: setContentDescription"); - - } - - @Override - public void onEnterAmbient(Bundle bundle) throws RemoteException { - Log.d(TAG, "unimplemented Method: onEnterAmbient"); - - } - - @Override - public void onExitAmbient() throws RemoteException { - Log.d(TAG, "unimplemented Method: onExitAmbient"); - - } - - @Override - public void setMinZoomPreference(float minZoom) throws RemoteException { - Log.d(TAG, "unimplemented Method: setMinZoomPreference"); - - } - - @Override - public void setMaxZoomPreference(float maxZoom) throws RemoteException { - Log.d(TAG, "unimplemented Method: setMaxZoomPreference"); - - } - - @Override - public void resetMinMaxZoomPreference() throws RemoteException { - Log.d(TAG, "unimplemented Method: resetMinMaxZoomPreference"); - - } - - @Override - public void setLatLngBoundsForCameraTarget(LatLngBounds bounds) throws RemoteException { - Log.d(TAG, "unimplemented Method: setLatLngBoundsForCameraTarget"); - - } - - public void onResume() { - backendMap.onResume(); - } - - public void onPause() { - backendMap.onPause(); - } - - public View getView() { - return backendMap.getView(); - } - - private String getNextMarkerId() { - return "m" + markerCounter++; - } - - private String getNextCircleId() { - return "c" + circleCounter++; - } - - private String getNextPolylineId() { - return "l" + polylineCounter++; - } - - private String getNextPolygonId() { - return "p" + polygonCounter++; - } - - /* - Camera - */ - - @Override - public CameraPosition getCameraPosition() throws RemoteException { - return GmsMapsTypeHelper.toCameraPosition(backendMap.getMapPosition()); - } - - @Override - public float getMaxZoomLevel() throws RemoteException { - return (float) backendMap.getViewport().limitScale(Double.MIN_VALUE); - } - - @Override - public float getMinZoomLevel() throws RemoteException { - return (float) backendMap.getViewport().limitScale(Double.MAX_VALUE); - } - - @Override - public void moveCamera(IObjectWrapper cameraUpdate) throws RemoteException { - CameraUpdate camUpdate = (CameraUpdate) ObjectWrapper.unwrap(cameraUpdate); - backendMap.applyCameraUpdate(camUpdate); - } - - @Override - public void animateCamera(IObjectWrapper cameraUpdate) throws RemoteException { - CameraUpdate camUpdate = (CameraUpdate) ObjectWrapper.unwrap(cameraUpdate); - backendMap.applyCameraUpdateAnimated(camUpdate, 1000); - } - - @Override - public void animateCameraWithCallback(IObjectWrapper cameraUpdate, ICancelableCallback callback) - throws RemoteException { - CameraUpdate camUpdate = (CameraUpdate) ObjectWrapper.unwrap(cameraUpdate); - backendMap.applyCameraUpdateAnimated(camUpdate, 1000); - } - - @Override - public void animateCameraWithDurationAndCallback(IObjectWrapper cameraUpdate, int duration, - ICancelableCallback callback) throws RemoteException { - CameraUpdate camUpdate = (CameraUpdate) ObjectWrapper.unwrap(cameraUpdate); - backendMap.applyCameraUpdateAnimated(camUpdate, duration); - } - - @Override - public IProjectionDelegate getProjection() throws RemoteException { - return projection; - } - - @Override - public void stopAnimation() throws RemoteException { - backendMap.stopAnimation(); - } - - @Override - public void onCameraUpdate(CameraPosition cameraPosition) { - if (onCameraChangeListener != null) { - try { - onCameraChangeListener.onCameraChange(cameraPosition); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - } - - /* - Markers, polylines, polygons, overlays, etc - */ - - @Override - public ICircleDelegate addCircle(CircleOptions options) throws RemoteException { - return backendMap.add(new CircleImpl(getNextCircleId(), options, this)); - } - - @Override - public IPolylineDelegate addPolyline(PolylineOptions options) throws RemoteException { - return backendMap.add(new PolylineImpl(getNextPolylineId(), options, this)); - } - - @Override - public IPolygonDelegate addPolygon(PolygonOptions options) throws RemoteException { - return backendMap.add(new PolygonImpl(getNextPolygonId(), options, this)); - } - - @Override - public IMarkerDelegate addMarker(MarkerOptions options) throws RemoteException { - return backendMap.add(new MarkerImpl(getNextMarkerId(), options, this)); - } - - @Override - public IGroundOverlayDelegate addGroundOverlay(GroundOverlayOptions options) - throws RemoteException { - Log.d(TAG, "not yet usable: addGroundOverlay"); - return new GroundOverlayImpl(options); // TODO - } - - @Override - public ITileOverlayDelegate addTileOverlay(TileOverlayOptions options) throws RemoteException { - Log.d(TAG, "not yet usable: addTileOverlay"); - return new TileOverlayImpl(); // TODO - } - - @Override - public void setInfoWindowAdapter(IInfoWindowAdapter adapter) throws RemoteException { - Log.d(TAG, "not yet usable: setInfoWindowAdapter"); - } - - @Override - public void clear() throws RemoteException { - backendMap.clear(); - markerCounter = 0; - circleCounter = 0; - polylineCounter = 0; - polygonCounter = 0; - } - - @Override - public void update(Markup markup) { - backendMap.update(markup); - } - - @Override - public void remove(Markup markup) { - backendMap.remove(markup); - } - - @Override - public boolean onClick(Markup markup) { - if (markup instanceof IMarkerDelegate) { - if (onMarkerClickListener != null) { - try { - if (onMarkerClickListener.onMarkerClick((IMarkerDelegate) markup)) - return true; - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - // TODO: open InfoWindow - } - return false; - } - - @Override - public void onDragStart(Markup markup) { - backendMap.setScrollGesturesEnabled(false); - backendMap.setRotateGesturesEnabled(false); - backendMap.setTiltGesturesEnabled(false); - backendMap.setZoomGesturesEnabled(false); - if (markup instanceof IMarkerDelegate) { - if (onMarkerDragListener != null) { - try { - onMarkerDragListener.onMarkerDragStart((IMarkerDelegate) markup); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - } - } - - @Override - public void onDragStop(Markup markup) { - try { - backendMap.setScrollGesturesEnabled(uiSettings.isScrollGesturesEnabled()); - backendMap.setRotateGesturesEnabled(uiSettings.isRotateGesturesEnabled()); - backendMap.setTiltGesturesEnabled(uiSettings.isTiltGesturesEnabled()); - backendMap.setZoomGesturesEnabled(uiSettings.isZoomGesturesEnabled()); - } catch (RemoteException e) { - // Never happens, is local. - } - if (markup instanceof IMarkerDelegate) { - if (onMarkerDragListener != null) { - try { - onMarkerDragListener.onMarkerDragEnd((IMarkerDelegate) markup); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - } - } - - @Override - public void onDragProgress(Markup markup) { - if (markup instanceof IMarkerDelegate) { - if (onMarkerDragListener != null) { - try { - onMarkerDragListener.onMarkerDrag((IMarkerDelegate) markup); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - } - } - - /* - Map options - */ - - @Override - public int getMapType() throws RemoteException { - return 0; - } - - @Override - public void setMapType(int type) throws RemoteException { - - } - - @Override - public boolean isTrafficEnabled() throws RemoteException { - return false; - } - - @Override - public void setTrafficEnabled(boolean traffic) throws RemoteException { - Log.w(TAG, "Traffic not yet supported"); - } - - @Override - public boolean isIndoorEnabled() throws RemoteException { - return false; - } - - @Override - public void setIndoorEnabled(boolean indoor) throws RemoteException { - Log.w(TAG, "Indoor not yet supported"); - } - - @Override - public boolean isMyLocationEnabled() throws RemoteException { - return false; - } - - @Override - public void setMyLocationEnabled(boolean myLocation) throws RemoteException { - Log.w(TAG, "MyLocation not yet supported"); - boolean hasPermission = ContextCompat.checkSelfPermission(context, ACCESS_COARSE_LOCATION) == PERMISSION_GRANTED - || ContextCompat.checkSelfPermission(context, ACCESS_FINE_LOCATION) == PERMISSION_GRANTED; - if (!hasPermission) { - throw new SecurityException("Neither " + ACCESS_COARSE_LOCATION + " nor " + ACCESS_FINE_LOCATION + " granted."); - } - LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - if (myLocation) { - locationManager.requestLocationUpdates(5000, 10, criteria, listener, Looper.getMainLooper()); - } else { - locationManager.removeUpdates(listener); - } - } - - @Override - public boolean isBuildingsEnabled() throws RemoteException { - return backendMap.hasBuilding(); - } - - @Override - public void setBuildingsEnabled(boolean buildingsEnabled) throws RemoteException { - backendMap.setBuildings(buildingsEnabled); - } - - /* - Ui Settings - */ - - @Override - public IUiSettingsDelegate getUiSettings() throws RemoteException { - Log.d(TAG, "getUiSettings: " + uiSettings); - return uiSettings; - } - - @Override - public void onUiSettingsChanged(UiSettingsImpl settings) throws RemoteException { - if (settings.isCompassEnabled()) { - Log.w(TAG, "Compass not yet supported"); - } - if (settings.isMyLocationButtonEnabled()) { - Log.w(TAG, "MyLocationButton not yet supported"); - } - if (settings.isZoomControlsEnabled()) { - Log.w(TAG, "ZoomControls not yet supported"); - } - backendMap.setScrollGesturesEnabled(settings.isScrollGesturesEnabled()); - backendMap.setRotateGesturesEnabled(settings.isRotateGesturesEnabled()); - backendMap.setTiltGesturesEnabled(settings.isTiltGesturesEnabled()); - backendMap.setZoomGesturesEnabled(settings.isZoomGesturesEnabled()); - } - - /* - Listener and callback setters - */ - - @Override - public void setOnCameraChangeListener(IOnCameraChangeListener listener) throws RemoteException { - Log.d(TAG, "setOnCameraChangeListener"); - this.onCameraChangeListener = listener; - } - - @Override - public void setOnMapClickListener(IOnMapClickListener listener) throws RemoteException { - Log.d(TAG, "setOnMapClickListener: not supported"); - } - - @Override - public void setOnMapLongClickListener(IOnMapLongClickListener listener) throws RemoteException { - Log.d(TAG, "setOnMapLongClickListener: not supported"); - } - - @Override - public void setOnMarkerClickListener(IOnMarkerClickListener listener) throws RemoteException { - Log.d(TAG, "setOnMarkerClickListener"); - this.onMarkerClickListener = listener; - } - - @Override - public void setOnMarkerDragListener(IOnMarkerDragListener listener) throws RemoteException { - Log.d(TAG, "setOnMarkerDragListener"); - this.onMarkerDragListener = listener; - } - - @Override - public void setOnInfoWindowClickListener(IOnInfoWindowClickListener listener) - throws RemoteException { - Log.d(TAG, "setOnInfoWindowClickListener: not supported"); - } - - @Override - public void setOnMyLocationChangeListener(IOnMyLocationChangeListener listener) - throws RemoteException { - Log.d(TAG, "setOnMyLocationChangeListener"); - this.onMyLocationChangeListener = listener; - } - - @Override - public void setOnMyLocationButtonClickListener(IOnMyLocationButtonClickListener listener) - throws RemoteException { - Log.d(TAG, "setOnMyLocationButtonClickListener: not supported"); - } - - @Override - public void setOnMapLoadedCallback(final IOnMapLoadedCallback callback) throws RemoteException { - Log.d(TAG, "setOnMapLoadedCallback"); - new Handler(context.getMainLooper()).postDelayed(new Runnable() { - @Override - public void run() { - Log.d(TAG, "Announce map loaded"); - if (callback != null) { - try { - callback.onMapLoaded(); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - } - }, 5000); - } - - @Override - public void setWatermarkEnabled(boolean watermark) throws RemoteException { - Log.d(TAG, "unimplemented Method: setWatermarkEnabled"); - - } - - @Override - public void onCreate(Bundle savedInstanceState) throws RemoteException { - Log.d(TAG, "unimplemented Method: onCreate"); - - } - - @Override - public void setCameraMoveStartedListener(IOnCameraMoveStartedListener listener) throws RemoteException { - Log.d(TAG, "unimplemented Method: setCameraMoveStartedListener"); - - } - - @Override - public void setCameraMoveListener(IOnCameraMoveListener listener) throws RemoteException { - Log.d(TAG, "unimplemented Method: setCameraMoveListener"); - - } - - @Override - public void setCameraMoveCanceledListener(IOnCameraMoveCanceledListener listener) throws RemoteException { - Log.d(TAG, "unimplemented Method: setCameraMoveCanceledListener"); - - } - - @Override - public void setCameraIdleListener(IOnCameraIdleListener listener) throws RemoteException { - Log.d(TAG, "unimplemented Method: setCameraIdleListener"); - - } - - @Override - public void onStart() throws RemoteException { - Log.d(TAG, "unimplemented Method: onStart"); - - } - - @Override - public void onStop() throws RemoteException { - Log.d(TAG, "unimplemented Method: onStop"); - - } - - /* - Misc - */ - - @Override - public IObjectWrapper getTestingHelper() throws RemoteException { - return null; - } - - @Override - public void snapshot(ISnapshotReadyCallback callback, IObjectWrapper bitmap) - throws RemoteException { - Bitmap b = (Bitmap) ObjectWrapper.unwrap(bitmap); - Log.d(TAG, "snapshot!: " + b); - backendMap.snapshot(b, callback); - } - - @Override - public void setPadding(int left, int top, int right, int bottom) throws RemoteException { - getView().setPadding(left, top, right, bottom); - } - - @Override - public Location getMyLocation() throws RemoteException { - return myLocation; - } - - @Override - public void setLocationSource(ILocationSourceDelegate locationSource) throws RemoteException { - Log.d(TAG, "setLocationSource: " + locationSource); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/MapFragmentImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/MapFragmentImpl.java deleted file mode 100644 index 44521532..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/MapFragmentImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.GoogleMapOptions; -import com.google.android.gms.maps.internal.IGoogleMapDelegate; -import com.google.android.gms.maps.internal.IMapFragmentDelegate; -import com.google.android.gms.maps.internal.IOnMapReadyCallback; - -public class MapFragmentImpl extends IMapFragmentDelegate.Stub { - private static final String TAG = "GmsMapFragImpl"; - - private GoogleMapImpl map; - private GoogleMapOptions options; - private Activity activity; - - public MapFragmentImpl(Activity activity) { - this.activity = activity; - } - - private GoogleMapImpl myMap() { - if (map == null) { - Log.d(TAG, "GoogleMap instance created"); - LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - map = GoogleMapImpl.create(inflater.getContext(), options); - } - return map; - } - - @Override - public IGoogleMapDelegate getMap() throws RemoteException { - Log.d(TAG, "getMap"); - return myMap(); - } - - @Override - public void onInflate(IObjectWrapper activity, GoogleMapOptions options, - Bundle savedInstanceState) throws RemoteException { - if (options != null) this.options = options; - Log.d(TAG, "onInflate"); - } - - @Override - public void onCreate(Bundle savedInstanceState) throws RemoteException { - Log.d(TAG, "onCreate"); - //myMap().onCreate(savedInstanceState); - // TOOD: Certainly does not belong here and this way - Bundle mapState = savedInstanceState.getBundle("map_state"); - if (mapState != null) { - mapState.setClassLoader(GoogleMapOptions.class.getClassLoader()); - GoogleMapOptions options = mapState.getParcelable("MapOptions"); - if (options != null) this.options = options; - } - } - - @Override - public IObjectWrapper onCreateView(IObjectWrapper layoutInflater, IObjectWrapper container, - Bundle savedInstanceState) throws RemoteException { - Log.d(TAG, "onCreateView"); - if (map == null) { - LayoutInflater inflater = (LayoutInflater) ObjectWrapper.unwrap(layoutInflater); - map = GoogleMapImpl.create(inflater.getContext(), options); - //map.onCreate(savedInstanceState); - } else { - View view = map.getView(); - if (view.getParent() instanceof ViewGroup) { - ((ViewGroup) view.getParent()).removeView(view); - } - } - return ObjectWrapper.wrap(myMap().getView()); - } - - @Override - public void onResume() throws RemoteException { - Log.d(TAG, "onResume"); - myMap().onResume(); - } - - @Override - public void onPause() throws RemoteException { - Log.d(TAG, "onPause"); - myMap().onPause(); - } - - @Override - public void onDestroyView() throws RemoteException { - Log.d(TAG, "onDestroyView"); - } - - @Override - public void onDestroy() throws RemoteException { - Log.d(TAG, "onDestroy"); - myMap().onDestroy(); - } - - @Override - public void onLowMemory() throws RemoteException { - Log.d(TAG, "onLowMemory"); - } - - @Override - public void onEnterAmbient(Bundle bundle) throws RemoteException { - map.onEnterAmbient(bundle); - } - - @Override - public void onExitAmbient() throws RemoteException { - map.onExitAmbient(); - } - - @Override - public void onStart() throws RemoteException { - map.onStart(); - } - - @Override - public void onStop() throws RemoteException { - map.onStop(); - } - - @Override - public void onSaveInstanceState(Bundle outState) throws RemoteException { - Log.d(TAG, "onSaveInstanceState: " + outState); - //myMap().onSaveInstanceState(outState); - } - - @Override - public boolean isReady() throws RemoteException { - Log.d(TAG, "isReady"); - return map != null; - } - - @Override - public void getMapAsync(final IOnMapReadyCallback callback) throws RemoteException { - new Handler(activity.getMainLooper()).post(new Runnable() { - @Override - public void run() { - try { - callback.onMapReady(myMap()); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - }); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/MapViewImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/MapViewImpl.java deleted file mode 100644 index c24ea52e..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/MapViewImpl.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; -import android.view.LayoutInflater; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.GoogleMapOptions; -import com.google.android.gms.maps.internal.IGoogleMapDelegate; -import com.google.android.gms.maps.internal.IMapViewDelegate; -import com.google.android.gms.maps.internal.IOnMapReadyCallback; - -public class MapViewImpl extends IMapViewDelegate.Stub { - private static final String TAG = "GmsMapViewImpl"; - - private GoogleMapImpl map; - private GoogleMapOptions options; - private Context context; - private IOnMapReadyCallback readyCallback; - - public MapViewImpl(Context context, GoogleMapOptions options) { - this.context = context; - this.options = options; - } - - private GoogleMapImpl myMap() { - if (map == null) { - Log.d(TAG, "GoogleMap instance created"); - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - map = GoogleMapImpl.create(inflater.getContext(), options); - } - return map; - } - - @Override - public IGoogleMapDelegate getMap() throws RemoteException { - Log.d(TAG, "getMap"); - return myMap(); - } - - @Override - public void onCreate(Bundle savedInstanceState) throws RemoteException { - //myMap().onCreate(savedInstanceState); - Log.d(TAG, "onCreate"); - } - - @Override - public void onResume() throws RemoteException { - Log.d(TAG, "onResume"); - - myMap().onResume(); - if (readyCallback != null) { - try { - readyCallback.onMapReady(map); - readyCallback = null; - } catch (Exception e) { - Log.w(TAG, e); - } - } - } - - @Override - public void onPause() throws RemoteException { - Log.d(TAG, "onPause"); - myMap().onPause(); - } - - @Override - public void onDestroy() throws RemoteException { - Log.d(TAG, "onDestroy"); - myMap().onDestroy(); - } - - @Override - public void onLowMemory() throws RemoteException { - Log.d(TAG, "onLowMemory"); - } - - @Override - public void onSaveInstanceState(Bundle outState) throws RemoteException { - Log.d(TAG, "onSaveInstanceState: " + outState); - } - - @Override - public IObjectWrapper getView() throws RemoteException { - return ObjectWrapper.wrap(myMap().getView()); - } - - @Override - public void getMapAsync(final IOnMapReadyCallback callback) throws RemoteException { - Log.d(TAG, "getMapAsync"); - new Handler(context.getMainLooper()).post(new Runnable() { - @Override - public void run() { - try { - callback.onMapReady(myMap()); - } catch (RemoteException e) { - Log.w(TAG, e); - } - } - }); - } - - @Override - public void onEnterAmbient(Bundle bundle) throws RemoteException { - map.onEnterAmbient(bundle); - } - - @Override - public void onExitAmbient() throws RemoteException { - map.onExitAmbient(); - } - - @Override - public void onStart() throws RemoteException { - map.onStart(); - } - - @Override - public void onStop() throws RemoteException { - map.onStop(); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ProjectionImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ProjectionImpl.java deleted file mode 100644 index f6fa1954..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ProjectionImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.os.RemoteException; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.internal.IProjectionDelegate; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.VisibleRegion; - -import org.oscim.core.Point; -import org.oscim.map.Viewport; - -public class ProjectionImpl extends IProjectionDelegate.Stub { - private Viewport viewport; - private float[] extents = new float[8]; - - public ProjectionImpl(Viewport viewport) { - this.viewport = viewport; - } - - @Override - public LatLng fromScreenLocation(IObjectWrapper obj) throws RemoteException { - Point point = GmsMapsTypeHelper - .fromPoint((android.graphics.Point) ObjectWrapper.unwrap(obj)); - return GmsMapsTypeHelper - .toLatLng(viewport.fromScreenPoint((float) point.x, (float) point.y)); - } - - @Override - public IObjectWrapper toScreenLocation(LatLng latLng) throws RemoteException { - Point point = new Point(); - viewport.toScreenPoint(GmsMapsTypeHelper.fromLatLng(latLng), point); - return ObjectWrapper.wrap(GmsMapsTypeHelper.toPoint(point)); - } - - @Override - public VisibleRegion getVisibleRegion() throws RemoteException { - viewport.getMapExtents(extents, 0); - // TODO: Support non-flat map extents - return new VisibleRegion(GmsMapsTypeHelper.toLatLngBounds(viewport.getBBox(null, 0))); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ResourcesContainer.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ResourcesContainer.java deleted file mode 100644 index ab53e7e5..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/ResourcesContainer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.content.res.Resources; - -public class ResourcesContainer { - private static Resources resources; - - public static void set(Resources resources) { - ResourcesContainer.resources = resources; - } - - public static Resources get() { - if (resources == null) { - throw new IllegalStateException("Resources have not been initialized"); - } else { - return resources; - } - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/UiSettingsImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/UiSettingsImpl.java deleted file mode 100644 index cb24de3c..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/UiSettingsImpl.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm; - -import android.os.RemoteException; -import com.google.android.gms.maps.internal.IUiSettingsDelegate; - -public class UiSettingsImpl extends IUiSettingsDelegate.Stub { - private boolean zoomControlsEnabled; - private boolean compassEnabled; - private boolean myLocationButtonEnabled; - private boolean scrollGesturesEnabled = true; - private boolean zoomGesturesEnabled = true; - private boolean tiltGesturesEnabled = true; - private boolean rotateGesturesEnabled = true; - private boolean allGesturesEnabled = true; - private boolean indoorLevelPickerEnabled = false; - private boolean mapToolbarEnabled = false; - private boolean scrollGesturesEnabledDuringRotateOrZoom = true; - - private UiSettingsListener listener; - - public UiSettingsImpl() { - } - - public UiSettingsImpl(UiSettingsListener listener) { - this.listener = listener; - } - - public void setListener(UiSettingsListener listener) { - this.listener = listener; - } - - @Override - public void setZoomControlsEnabled(boolean zoomControlsEnabled) throws RemoteException { - this.zoomControlsEnabled = zoomControlsEnabled; - listener.onUiSettingsChanged(this); - } - - @Override - public void setCompassEnabled(boolean compassEnabled) throws RemoteException { - this.compassEnabled = compassEnabled; - listener.onUiSettingsChanged(this); - } - - @Override - public void setMyLocationButtonEnabled(boolean myLocationButtonEnabled) throws RemoteException { - this.myLocationButtonEnabled = myLocationButtonEnabled; - listener.onUiSettingsChanged(this); - } - - @Override - public void setScrollGesturesEnabled(boolean scrollGesturesEnabled) throws RemoteException { - this.scrollGesturesEnabled = scrollGesturesEnabled; - listener.onUiSettingsChanged(this); - } - - @Override - public void setZoomGesturesEnabled(boolean zoomGestures) throws RemoteException { - this.zoomGesturesEnabled = zoomGestures; - listener.onUiSettingsChanged(this); - } - - @Override - public void setTiltGesturesEnabled(boolean tiltGesturesEnabled) throws RemoteException { - this.tiltGesturesEnabled = tiltGesturesEnabled; - listener.onUiSettingsChanged(this); - } - - @Override - public void setRotateGesturesEnabled(boolean rotateGesturesEnabled) throws RemoteException { - this.rotateGesturesEnabled = rotateGesturesEnabled; - listener.onUiSettingsChanged(this); - } - - @Override - public void setAllGesturesEnabled(boolean gestures) throws RemoteException { - scrollGesturesEnabled = gestures; - zoomGesturesEnabled = gestures; - tiltGesturesEnabled = gestures; - rotateGesturesEnabled = gestures; - listener.onUiSettingsChanged(this); - } - - @Override - public boolean isZoomControlsEnabled() throws RemoteException { - return zoomControlsEnabled; - } - - @Override - public boolean isCompassEnabled() throws RemoteException { - return compassEnabled; - } - - @Override - public boolean isMyLocationButtonEnabled() throws RemoteException { - return myLocationButtonEnabled; - } - - @Override - public boolean isScrollGesturesEnabled() throws RemoteException { - return scrollGesturesEnabled; - } - - @Override - public boolean isZoomGesturesEnabled() throws RemoteException { - return zoomGesturesEnabled; - } - - @Override - public boolean isTiltGesturesEnabled() throws RemoteException { - return tiltGesturesEnabled; - } - - @Override - public boolean isRotateGesturesEnabled() throws RemoteException { - return rotateGesturesEnabled; - } - - @Override - public void setIndoorLevelPickerEnabled(boolean indoorLevelPicker) throws RemoteException { - this.indoorLevelPickerEnabled = indoorLevelPicker; - listener.onUiSettingsChanged(this); - } - - @Override - public boolean isIndoorLevelPickerEnabled() throws RemoteException { - return indoorLevelPickerEnabled; - } - - @Override - public void setMapToolbarEnabled(boolean mapToolbar) throws RemoteException { - this.mapToolbarEnabled = mapToolbar; - listener.onUiSettingsChanged(this); - } - - @Override - public boolean isMapToolbarEnabled() throws RemoteException { - return mapToolbarEnabled; - } - - @Override - public void setScrollGesturesEnabledDuringRotateOrZoom(boolean scrollDuringZoom) throws RemoteException { - this.scrollGesturesEnabledDuringRotateOrZoom = scrollDuringZoom; - listener.onUiSettingsChanged(this); - } - - @Override - public boolean isScrollGesturesEnabledDuringRotateOrZoom() throws RemoteException { - return scrollGesturesEnabledDuringRotateOrZoom; - } - - public static interface UiSettingsListener { - void onUiSettingsChanged(UiSettingsImpl settings) throws RemoteException; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/AbstractBitmapDescriptor.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/AbstractBitmapDescriptor.java deleted file mode 100644 index 92cee1c1..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/AbstractBitmapDescriptor.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.content.Context; -import android.graphics.Bitmap; - -public abstract class AbstractBitmapDescriptor { - - private Bitmap bitmap; - - protected abstract Bitmap generateBitmap(Context context); - - public Bitmap loadBitmap(Context context) { - if (bitmap == null) { - synchronized (this) { - if (bitmap == null) - bitmap = generateBitmap(context); - } - } - return bitmap; - } - - public Bitmap getBitmap() { - return bitmap; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/AssetBitmapDescriptor.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/AssetBitmapDescriptor.java deleted file mode 100644 index 80070321..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/AssetBitmapDescriptor.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - -import java.io.IOException; - -public class AssetBitmapDescriptor extends AbstractBitmapDescriptor { - private String assetName; - - public AssetBitmapDescriptor(String assetName) { - this.assetName = assetName; - } - - @Override - protected Bitmap generateBitmap(Context context) { - try { - return BitmapFactory.decodeStream(context.getAssets().open(assetName)); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapBitmapDescriptor.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapBitmapDescriptor.java deleted file mode 100644 index 6ccce321..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapBitmapDescriptor.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.content.Context; -import android.graphics.Bitmap; - -public class BitmapBitmapDescriptor extends AbstractBitmapDescriptor { - private Bitmap bitmap; - - public BitmapBitmapDescriptor(Bitmap bitmap) { - this.bitmap = bitmap; - } - - @Override - public Bitmap getBitmap() { - return bitmap; - } - - @Override - public Bitmap generateBitmap(Context context) { - return bitmap; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapDescriptorFactoryImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapDescriptorFactoryImpl.java deleted file mode 100644 index e5374a62..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapDescriptorFactoryImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.graphics.Bitmap; -import android.os.Parcel; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate; - -public class BitmapDescriptorFactoryImpl extends IBitmapDescriptorFactoryDelegate.Stub { - private static final String TAG = "GmsBitmapDescFactory"; - - @Override - public IObjectWrapper fromResource(int resourceId) throws RemoteException { - return ObjectWrapper.wrap(new ResourceBitmapDescriptor(resourceId)); - } - - @Override - public IObjectWrapper fromAsset(String assetName) throws RemoteException { - return ObjectWrapper.wrap(new AssetBitmapDescriptor(assetName)); - } - - @Override - public IObjectWrapper fromFile(String fileName) throws RemoteException { - return ObjectWrapper.wrap(new FileBitmapDescriptor(fileName)); - } - - @Override - public IObjectWrapper defaultMarker() throws RemoteException { - return ObjectWrapper.wrap(DefaultBitmapDescriptor.DEFAULT_DESCRIPTOR); - } - - @Override - public IObjectWrapper defaultMarkerWithHue(float hue) throws RemoteException { - return ObjectWrapper.wrap(new DefaultBitmapDescriptor(hue)); - } - - @Override - public IObjectWrapper fromBitmap(Bitmap bitmap) throws RemoteException { - return ObjectWrapper.wrap(new BitmapBitmapDescriptor(bitmap)); - } - - @Override - public IObjectWrapper fromPath(String absolutePath) throws RemoteException { - return ObjectWrapper.wrap(new PathBitmapDescriptor(absolutePath)); - } - - @Override - public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { - if (super.onTransact(code, data, reply, flags)) return true; - Log.d(TAG, "onTransact [unknown]: " + code + ", " + data + ", " + flags); - return false; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapDescriptorImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapDescriptorImpl.java deleted file mode 100644 index dc12072d..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/BitmapDescriptorImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.content.Context; -import android.graphics.Bitmap; -import android.util.Log; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.model.BitmapDescriptor; - -import java.util.HashSet; -import java.util.Set; - -public class BitmapDescriptorImpl { - private BitmapDescriptor descriptor; - private boolean loadStarted = false; - private Set waitingForLoad = new HashSet(); - - public BitmapDescriptorImpl(IObjectWrapper remoteObject) { - this(new BitmapDescriptor(remoteObject)); - } - - public BitmapDescriptorImpl(BitmapDescriptor descriptor) { - this.descriptor = descriptor; - } - - public BitmapDescriptorImpl() { - this(new ObjectWrapper(new DefaultBitmapDescriptor(0))); - } - - public AbstractBitmapDescriptor getDescriptor() { - if (descriptor.getRemoteObject() == null) - return null; - Object unwrap = ObjectWrapper.unwrap(descriptor.getRemoteObject()); - if (unwrap instanceof AbstractBitmapDescriptor) { - return ((AbstractBitmapDescriptor) unwrap); - } else { - return null; - } - } - - public Bitmap getBitmap() { - if (getDescriptor() != null) { - return getDescriptor().getBitmap(); - } - return null; - } - - public synchronized boolean loadBitmapAsync(final Context context, Runnable after) { - if (getBitmap() != null) { - return false; - } - waitingForLoad.add(after); - if (loadStarted) - return true; - loadStarted = true; - if (getDescriptor() != null) { - new Thread(new Runnable() { - @Override - public void run() { - Log.d("BitmapDescriptor", "Start loading " + getDescriptor()); - if (getDescriptor().loadBitmap(context) != null) { - Set waitingForLoad; - synchronized (BitmapDescriptorImpl.this) { - waitingForLoad = BitmapDescriptorImpl.this.waitingForLoad; - } - for (Runnable after : waitingForLoad) { - after.run(); - } - } - Log.d("BitmapDescriptor", "Done loading " + getDescriptor()); - } - }).start(); - } - return true; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/DefaultBitmapDescriptor.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/DefaultBitmapDescriptor.java deleted file mode 100644 index 340548c5..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/DefaultBitmapDescriptor.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.ColorMatrix; -import android.graphics.ColorMatrixColorFilter; -import android.graphics.Paint; - -import com.google.android.gms.dynamic.ObjectWrapper; - -import org.microg.gms.maps.vtm.ResourcesContainer; -import org.microg.gms.maps.vtm.R; - -public class DefaultBitmapDescriptor extends AbstractBitmapDescriptor { - public static final DefaultBitmapDescriptor DEFAULT_DESCRIPTOR = new DefaultBitmapDescriptor(0); - public static final BitmapDescriptorImpl DEFAULT_DESCRIPTOR_IMPL = new BitmapDescriptorImpl(ObjectWrapper.wrap(DEFAULT_DESCRIPTOR)); - public static final int DEGREES = 360; - - private final float hue; - - public DefaultBitmapDescriptor(float hue) { - this.hue = hue > 180 ? -DEGREES + hue : hue; - } - - @Override - public Bitmap generateBitmap(Context context) { - Bitmap source; - if (this == DEFAULT_DESCRIPTOR) { - source = BitmapFactory.decodeResource(ResourcesContainer.get(), R.drawable.maps_default_marker); - } else { - source = DEFAULT_DESCRIPTOR.loadBitmap(context); - } - if (hue % DEGREES == 0) return source; - Paint paint = new Paint(); - paint.setColorFilter(adjustHue(hue)); - Bitmap bitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(), source.getConfig()); - Canvas canvas = new Canvas(bitmap); - canvas.drawBitmap(source, 0, 0, paint); - return bitmap; - } - - /** - * Creates a HUE ajustment ColorFilter - *

- * see http://groups.google.com/group/android-developers/browse_thread/thread/9e215c83c3819953 - * see http://gskinner.com/blog/archives/2007/12/colormatrix_cla.html - * - * @param value degrees to shift the hue. - */ - public static ColorFilter adjustHue(float value) { - ColorMatrix cm = new ColorMatrix(); - adjustHue(cm, value); - return new ColorMatrixColorFilter(cm); - } - - /** - * see http://groups.google.com/group/android-developers/browse_thread/thread/9e215c83c3819953 - * see http://gskinner.com/blog/archives/2007/12/colormatrix_cla.html - */ - public static void adjustHue(ColorMatrix cm, float value) { - value = cleanValue(value, 180f) / 180f * (float) Math.PI; - if (value == 0) { - return; - } - float cosVal = (float) Math.cos(value); - float sinVal = (float) Math.sin(value); - float lumR = 0.213f; - float lumG = 0.715f; - float lumB = 0.072f; - float[] mat = new float[]{lumR + cosVal * (1 - lumR) + sinVal * (-lumR), - lumG + cosVal * (-lumG) + sinVal * (-lumG), - lumB + cosVal * (-lumB) + sinVal * (1 - lumB), 0, 0, - lumR + cosVal * (-lumR) + sinVal * (0.143f), - lumG + cosVal * (1 - lumG) + sinVal * (0.140f), - lumB + cosVal * (-lumB) + sinVal * (-0.283f), 0, 0, - lumR + cosVal * (-lumR) + sinVal * (-(1 - lumR)), - lumG + cosVal * (-lumG) + sinVal * (lumG), - lumB + cosVal * (1 - lumB) + sinVal * (lumB), - 0, 0, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 1f}; - cm.postConcat(new ColorMatrix(mat)); - } - - protected static float cleanValue(float p_val, float p_limit) { - return Math.min(p_limit, Math.max(-p_limit, p_val)); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/FileBitmapDescriptor.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/FileBitmapDescriptor.java deleted file mode 100644 index 6b109b50..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/FileBitmapDescriptor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - -public class FileBitmapDescriptor extends AbstractBitmapDescriptor { - private String fileName; - - public FileBitmapDescriptor(String fileName) { - this.fileName = fileName; - } - - @Override - public Bitmap generateBitmap(Context context) { - return BitmapFactory.decodeFile(fileName); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/PathBitmapDescriptor.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/PathBitmapDescriptor.java deleted file mode 100644 index 46ad1aa0..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/PathBitmapDescriptor.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -public class PathBitmapDescriptor { - public PathBitmapDescriptor(String absolutePath) { - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/ResourceBitmapDescriptor.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/ResourceBitmapDescriptor.java deleted file mode 100644 index d06f38a0..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/bitmap/ResourceBitmapDescriptor.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.bitmap; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; - -import androidx.core.content.ContextCompat; - -public class ResourceBitmapDescriptor extends AbstractBitmapDescriptor { - private int resourceId; - - public ResourceBitmapDescriptor(int resourceId) { - this.resourceId = resourceId; - } - - @Override - public Bitmap generateBitmap(Context context) { - return drawableToBitmap(context, ContextCompat.getDrawable(context.getApplicationContext(), resourceId)); - } - - public static Bitmap drawableToBitmap(Context context, Drawable drawable) { - if (drawable instanceof BitmapDrawable) { - return ((BitmapDrawable) drawable).getBitmap(); - } - - if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { - return DefaultBitmapDescriptor.DEFAULT_DESCRIPTOR.loadBitmap(context); - } - - Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - drawable.draw(canvas); - - return bitmap; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/CameraUpdate.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/CameraUpdate.java deleted file mode 100644 index 69639bcc..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/CameraUpdate.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.camera; - -import org.oscim.map.Map; - -public interface CameraUpdate { - void apply(Map map); - void applyAnimated(Map map, int duration); -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/CameraUpdateFactoryImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/CameraUpdateFactoryImpl.java deleted file mode 100644 index 17020a86..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/CameraUpdateFactoryImpl.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.camera; - -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.internal.ICameraUpdateFactoryDelegate; -import com.google.android.gms.maps.model.CameraPosition; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; - -import org.microg.gms.maps.vtm.GmsMapsTypeHelper; -import org.oscim.core.MapPosition; -import org.oscim.map.Map; - -public class CameraUpdateFactoryImpl extends ICameraUpdateFactoryDelegate.Stub { - private static final String TAG = "GmsMapCamUpdateFactory"; - - private CameraUpdateFactoryImpl() { - - } - - private static CameraUpdateFactoryImpl instance; - public static CameraUpdateFactoryImpl get() { - if (instance == null) { - instance = new CameraUpdateFactoryImpl(); - } - return instance; - } - - @Override - public IObjectWrapper zoomIn() throws RemoteException { - Log.d(TAG, "zoomIn"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setScale(GmsMapsTypeHelper.fromZoom( - GmsMapsTypeHelper.toZoom(mapPosition.getScale()) + 1)); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper zoomOut() throws RemoteException { - Log.d(TAG, "zoomOut"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setScale(GmsMapsTypeHelper.fromZoom( - GmsMapsTypeHelper.toZoom(mapPosition.getScale()) - 1)); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper scrollBy(final float x, final float y) throws RemoteException { - Log.d(TAG, "scrollBy"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setPosition(map.viewport() - .fromScreenPoint((float) (map.getWidth() / 2.0 + x), - (float) (map.getHeight() / 2.0 + y))); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper zoomTo(final float zoom) throws RemoteException { - Log.d(TAG, "zoomTo"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setScale(GmsMapsTypeHelper.fromZoom(zoom)); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper zoomBy(final float zoomDelta) throws RemoteException { - Log.d(TAG, "zoomBy"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setScale(GmsMapsTypeHelper.fromZoom( - GmsMapsTypeHelper.toZoom(mapPosition.getScale()) + zoomDelta)); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper zoomByWithFocus(final float zoomDelta, int x, int y) - throws RemoteException { - Log.d(TAG, "zoomByWithFocus"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setScale(GmsMapsTypeHelper.fromZoom( - GmsMapsTypeHelper.toZoom(mapPosition.getScale()) + zoomDelta)); - Log.w(TAG, "zoomBy with focus not yet supported"); // TODO - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper newCameraPosition(final CameraPosition cameraPosition) - throws RemoteException { - Log.d(TAG, "newCameraPosition"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - return GmsMapsTypeHelper.fromCameraPosition(cameraPosition); - } - }); - } - - @Override - public IObjectWrapper newLatLng(final LatLng latLng) throws RemoteException { - Log.d(TAG, "newLatLng"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setPosition(GmsMapsTypeHelper.fromLatLng(latLng)); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper newLatLngZoom(final LatLng latLng, final float zoom) - throws RemoteException { - Log.d(TAG, "newLatLngZoom"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setPosition(GmsMapsTypeHelper.fromLatLng(latLng)); - mapPosition.setScale(GmsMapsTypeHelper.fromZoom(zoom)); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper newLatLngBounds(final LatLngBounds bounds, int padding) throws RemoteException { - Log.d(TAG, "newLatLngBounds"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setByBoundingBox(GmsMapsTypeHelper.fromLatLngBounds(bounds), - map.getWidth(), map.getHeight()); - return mapPosition; - } - }); - } - - @Override - public IObjectWrapper newLatLngBoundsWithSize(final LatLngBounds bounds, final int width, final int height, int padding) - throws RemoteException { - Log.d(TAG, "newLatLngBoundsWithSize"); - return new ObjectWrapper(new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setByBoundingBox(GmsMapsTypeHelper.fromLatLngBounds(bounds), - width, height); - return mapPosition; - } - }); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/MapPositionCameraUpdate.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/MapPositionCameraUpdate.java deleted file mode 100644 index fa5ebce2..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/MapPositionCameraUpdate.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.camera; - -import org.oscim.core.MapPosition; -import org.oscim.map.Map; - -public abstract class MapPositionCameraUpdate implements CameraUpdate { - - abstract MapPosition getMapPosition(Map map); - - @Override - public void apply(Map map) { - map.setMapPosition(getMapPosition(map)); - } - - @Override - public void applyAnimated(Map map, int duration) { - map.animator().animateTo(duration, getMapPosition(map)); - } - - public static CameraUpdate directMapPosition(final MapPosition position) { - return new MapPositionCameraUpdate() { - @Override - MapPosition getMapPosition(Map map) { - return position; - } - }; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/NoCameraUpdate.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/NoCameraUpdate.java deleted file mode 100644 index a24a6d22..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/camera/NoCameraUpdate.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.camera; - -import org.oscim.map.Map; - -public class NoCameraUpdate implements CameraUpdate { - @Override - public void apply(Map map) { - - } - - @Override - public void applyAnimated(Map map, int duration) { - - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/data/SharedTileCache.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/data/SharedTileCache.java deleted file mode 100644 index 3cdd61eb..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/data/SharedTileCache.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.data; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; - -import org.oscim.core.Tile; -import org.oscim.tiling.ITileCache; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; - -public class SharedTileCache implements ITileCache { - private final ArrayList cacheBuffers; - private final Context context; - - public SharedTileCache(Context context) { - this.context = context; - this.cacheBuffers = new ArrayList(); - } - - @Override - public TileWriter writeTile(Tile tile) { - ByteArrayOutputStream os; - synchronized (this.cacheBuffers) { - if (this.cacheBuffers.isEmpty()) { - os = new ByteArrayOutputStream('耀'); - } else { - os = this.cacheBuffers.remove(this.cacheBuffers.size() - 1); - } - } - - return new CacheTileWriter(tile, os); - } - - public void saveTile(Tile tile, ByteArrayOutputStream data, boolean success) { - byte[] bytes = null; - if (success) { - bytes = data.toByteArray(); - } - - synchronized (this.cacheBuffers) { - data.reset(); - this.cacheBuffers.add(data); - } - - if (success) { - ContentValues values = new ContentValues(); - values.put("x", tile.tileX); - values.put("y", tile.tileY); - values.put("z", tile.zoomLevel); - values.put("time", 0); - values.put("last_access", 0); - values.put("data", bytes); - context.getContentResolver().insert(SharedTileProvider.PROVIDER_URI, values); - } - } - - @Override - public TileReader getTile(Tile tile) { - Cursor cursor = context.getContentResolver().query(SharedTileProvider.PROVIDER_URI, new String[]{"data"}, "z=? AND x=? AND y=?", new String[]{String.valueOf(tile.zoomLevel), String.valueOf(tile.tileX), String.valueOf(tile.tileY)}, null); - if (cursor != null) { - if (!cursor.moveToFirst()) { - cursor.close(); - return null; - } else { - ByteArrayInputStream in = new ByteArrayInputStream(cursor.getBlob(0)); - cursor.close(); - return new CacheTileReader(tile, in); - } - } - return null; - } - - @Override - public void setCacheSize(long l) { - - } - - class CacheTileWriter implements TileWriter { - final ByteArrayOutputStream os; - final Tile tile; - - CacheTileWriter(Tile tile, ByteArrayOutputStream os) { - this.tile = tile; - this.os = os; - } - - public Tile getTile() { - return tile; - } - - public OutputStream getOutputStream() { - return os; - } - - public void complete(boolean success) { - saveTile(tile, os, success); - } - } - - class CacheTileReader implements TileReader { - final InputStream is; - final Tile tile; - - public CacheTileReader(Tile tile, InputStream is) { - this.tile = tile; - this.is = is; - } - - public Tile getTile() { - return tile; - } - - public InputStream getInputStream() { - return is; - } - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/data/SharedTileProvider.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/data/SharedTileProvider.java deleted file mode 100644 index 3a322430..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/data/SharedTileProvider.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.data; - -import android.content.ContentProvider; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.net.Uri; - -/* - * TODO: Writing to cache should be protected, tiles should be downloaded by service instead of client app. - */ -public class SharedTileProvider extends ContentProvider { - private static final String DB_NAME = "tilecache.db"; - public static final String PROVIDER_NAME = "org.microg.gms.maps.vtm.tile"; - public static final Uri PROVIDER_URI = Uri.parse("content://" + PROVIDER_NAME); - - private SQLiteHelper sqLiteHelper; - - public SharedTileProvider() { - } - - @Override - public int delete(Uri uri, String selection, String[] selectionArgs) { - // Implement this to handle requests to delete one or more rows. - throw new UnsupportedOperationException("Not yet implemented"); - } - - @Override - public String getType(Uri uri) { - return "vnd.android.cursor.item/org.mgoogle.gms.map.tile"; - } - - @Override - public Uri insert(Uri uri, ContentValues values) { - sqLiteHelper.getWritableDatabase().insert("tiles", null, values); - return PROVIDER_URI; - } - - @Override - public boolean onCreate() { - sqLiteHelper = new SQLiteHelper(getContext(), DB_NAME); - return true; - } - - @Override - public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { - return sqLiteHelper.getReadableDatabase().query("tiles", projection, selection, selectionArgs, null, null, sortOrder); - } - - @Override - public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - return sqLiteHelper.getWritableDatabase().update("tiles", values, selection, selectionArgs); - } - - class SQLiteHelper extends SQLiteOpenHelper { - private static final int DATABASE_VERSION = 1; - private static final String TILE_SCHEMA = "CREATE TABLE tiles(x INTEGER NOT NULL,y INTEGER NOT NULL,z INTEGER NOT NULL,time LONG NOT NULL,last_access LONG NOT NULL,data BLOB,PRIMARY KEY(x,y,z));"; - - public SQLiteHelper(Context context, String dbName) { - super(context, dbName, null, DATABASE_VERSION); - } - - public void onCreate(SQLiteDatabase db) { - db.execSQL(TILE_SCHEMA); - } - - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - db.execSQL("DROP TABLE IF EXISTS tiles"); - this.onCreate(db); - } - - public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { - this.onUpgrade(db, oldVersion, newVersion); - } - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/CircleImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/CircleImpl.java deleted file mode 100644 index 18b4a999..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/CircleImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import android.os.RemoteException; - -import com.google.android.gms.maps.model.CircleOptions; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.internal.ICircleDelegate; - -import org.microg.gms.maps.vtm.GmsMapsTypeHelper; -import org.oscim.layers.vector.geometries.CircleDrawable; -import org.oscim.layers.vector.geometries.Drawable; -import org.oscim.layers.vector.geometries.Style; -import org.oscim.map.Map; - -public class CircleImpl extends ICircleDelegate.Stub implements DrawableMarkup { - - private final String id; - private final CircleOptions options; - private final MarkupListener listener; - private boolean removed = false; - - public CircleImpl(String id, CircleOptions options, MarkupListener listener) { - this.id = id; - this.listener = listener; - this.options = options == null ? new CircleOptions() : options; - } - - @Override - public void remove() throws RemoteException { - listener.remove(this); - removed = true; - } - - @Override - public String getId() { - return id; - } - - @Override - public void setCenter(LatLng center) throws RemoteException { - options.center(center); - listener.update(this); - } - - @Override - public LatLng getCenter() throws RemoteException { - return options.getCenter(); - } - - @Override - public void setRadius(double radius) throws RemoteException { - options.radius(radius); - listener.update(this); - } - - @Override - public double getRadius() throws RemoteException { - return options.getRadius(); - } - - @Override - public void setStrokeWidth(float width) throws RemoteException { - options.strokeWidth(width); - listener.update(this); - } - - @Override - public float getStrokeWidth() throws RemoteException { - return options.getStrokeWidth(); - } - - @Override - public void setStrokeColor(int color) throws RemoteException { - options.strokeColor(color); - listener.update(this); - } - - @Override - public int getStrokeColor() throws RemoteException { - return options.getStrokeColor(); - } - - @Override - public void setFillColor(int color) throws RemoteException { - options.fillColor(color); - listener.update(this); - } - - @Override - public int getFillColor() throws RemoteException { - return options.getFillColor(); - } - - @Override - public void setZIndex(float zIndex) throws RemoteException { - options.zIndex(zIndex); - listener.update(this); - } - - @Override - public float getZIndex() { - return options.getZIndex(); - } - - @Override - public void setVisible(boolean visible) throws RemoteException { - options.visible(visible); - listener.update(this); - } - - @Override - public boolean isVisible() { - return options.isVisible(); - } - - @Override - public boolean equalsRemote(ICircleDelegate other) throws RemoteException { - return other != null && other.getId().equals(getId()); - } - - @Override - public int hashCodeRemote() throws RemoteException { - return id.hashCode(); - } - - @Override - public boolean onClick() { - return listener.onClick(this); - } - - @Override - public void onDragStart() { - listener.onDragStart(this); - } - - @Override - public void onDragStop() { - listener.onDragStop(this); - } - - @Override - public void onDragProgress() { - listener.onDragProgress(this); - } - - @Override - public Drawable getDrawable(Map map) { - if (!isVisible() || removed) return null; - return new CircleDrawable( - GmsMapsTypeHelper.fromLatLng(options.getCenter()), - options.getRadius() / 1000.0, - Style.builder() - .strokeColor(options.getStrokeColor()) - .fillAlpha(1) - .fillColor(options.getFillColor()) - .strokeWidth(options.getStrokeWidth()).build()); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/ClearableVectorLayer.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/ClearableVectorLayer.java deleted file mode 100644 index 4dedd470..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/ClearableVectorLayer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import org.oscim.layers.vector.VectorLayer; -import org.oscim.map.Map; - -public class ClearableVectorLayer extends VectorLayer { - public ClearableVectorLayer(Map map) { - super(map); - } - - public void clear() { - mDrawables.clear(); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/DrawableMarkup.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/DrawableMarkup.java deleted file mode 100644 index c91dd8d6..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/DrawableMarkup.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import org.oscim.layers.vector.geometries.Drawable; -import org.oscim.map.Map; - -public interface DrawableMarkup extends Markup { - float getZIndex(); - - Drawable getDrawable(Map map); -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/GroundOverlayImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/GroundOverlayImpl.java deleted file mode 100644 index a577bd2e..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/GroundOverlayImpl.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import android.os.RemoteException; -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.maps.model.GroundOverlayOptions; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.LatLngBounds; -import com.google.android.gms.maps.model.internal.IGroundOverlayDelegate; - -public class GroundOverlayImpl extends IGroundOverlayDelegate.Stub { - private LatLng position; - private float transparency; - private float zIndex; - private boolean visible; - private String id; - private float width; - private float height; - private float bearing; - - public GroundOverlayImpl(GroundOverlayOptions options) { - - } - - @Override - public void remove() throws RemoteException { - - } - - @Override - public String getId() throws RemoteException { - return id; - } - - @Override - public void setPosition(LatLng pos) throws RemoteException { - this.position = pos; - } - - @Override - public LatLng getPosition() throws RemoteException { - return position; - } - - @Override - public void setDimension(float dimension) throws RemoteException { - setDimensions(dimension, dimension); - } - - @Override - public void setDimensions(float width, float height) throws RemoteException { - this.width = width; - this.height = height; - } - - @Override - public float getWidth() throws RemoteException { - return width; - } - - @Override - public float getHeight() throws RemoteException { - return height; - } - - @Override - public void setPositionFromBounds(LatLngBounds bounds) throws RemoteException { - - } - - @Override - public LatLngBounds getBounds() throws RemoteException { - return null; - } - - @Override - public void setBearing(float bearing) throws RemoteException { - this.bearing = bearing; - } - - @Override - public float getBearing() throws RemoteException { - return bearing; - } - - @Override - public void setZIndex(float zIndex) throws RemoteException { - this.zIndex = zIndex; - } - - @Override - public float getZIndex() throws RemoteException { - return zIndex; - } - - @Override - public void setVisible(boolean visible) throws RemoteException { - this.visible = visible; - } - - @Override - public boolean isVisible() throws RemoteException { - return visible; - } - - @Override - public void setTransparency(float transparency) throws RemoteException { - this.transparency = transparency; - } - - @Override - public float getTransparency() throws RemoteException { - return transparency; - } - - @Override - public boolean equalsRemote(IGroundOverlayDelegate other) throws RemoteException { - return other != null && other.getId().equals(getId()); - } - - @Override - public int hashCodeRemote() throws RemoteException { - return id.hashCode(); - } - - @Override - public void todo(IObjectWrapper obj) throws RemoteException { - - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/InfoWindow.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/InfoWindow.java deleted file mode 100644 index 95a72ae0..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/InfoWindow.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import android.content.Context; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.LinearLayout; -import android.widget.TextView; -import com.google.android.gms.maps.model.internal.IMarkerDelegate; -import org.microg.gms.maps.vtm.GoogleMapImpl; -import org.microg.gms.maps.vtm.ResourcesContainer; -import org.microg.gms.maps.vtm.R; - -import static android.os.Build.VERSION.SDK_INT; -import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1; - -public class InfoWindow { - private static final String TAG = InfoWindow.class.getName(); - private Context context; - private View window; - private GoogleMapImpl map; - private MarkerImpl marker; - - public InfoWindow(Context context, final GoogleMapImpl map, final MarkerImpl marker) { - super(); - this.context = context; - this.map = map; - this.marker = marker; - } - - public void setWindow(View view) { - window = view; - if (window != null) { - window.measure(0, 0); - } - } - - public boolean isComplete() { - return window != null; - } - - public void setContent(View view) { - if (view == null) - return; - setWindow(new DefaultWindow(view)); - } - - public void buildDefault() { - if (marker.getTitle() != null) - setContent(new DefaultContent()); - } - - public void destroy() { - if (window instanceof DefaultWindow) { - ((DefaultWindow) window).removeAllViews(); - } - } - - public IMarkerDelegate getMarker() { - return marker; - } - - /* - @Override - public void draw(Canvas canvas, MapView mapView, boolean shadow) { - if (window != null && marker.getHeight() != -1 && !shadow) { - try { - Log.d(TAG, "draw InfoWindow"); - window.measure(0, 0); - window.layout(0, 0, window.getMeasuredWidth(), window.getMeasuredHeight()); - //Point point = mapView.getProjection().toPixels(marker.getPosition().toGeoPoint(), null); - - // osmdroid 4.1 bugfix - Point zero = mapView.getProjection().toPixels(new GeoPoint(0, 0), null); - point.offset(-zero.x, -zero.y); - - - - point.offset(-window.getMeasuredWidth() / 2, -window.getMeasuredHeight() - marker.getHeight()); - Log.d(TAG, point.toString()); - canvas.save(); - canvas.translate(point.x, point.y); - window.draw(canvas); - canvas.restore(); - } catch (Exception e) { - // This is not remote... - } - } - } - - @Override - public boolean onTap(GeoPoint p, MapView mapView) { - try { - IOnInfoWindowClickListener listener = null; //map.getInfoWindowClickListener(); - if (listener != null) { - Point clickPoint = mapView.getProjection().toPixels(p, null); - Point markerPoint = mapView.getProjection().toPixels(marker.getPosition().toGeoPoint(), null); - Rect rect = new Rect(markerPoint.x - (window.getMeasuredWidth() / 2), - markerPoint.y - marker.getHeight() - window.getMeasuredHeight(), - markerPoint.x + (window.getMeasuredWidth() / 2), - markerPoint.y - marker.getHeight()); - if (rect.contains(clickPoint.x, clickPoint.y)) { - try { - listener.onInfoWindowClick(marker); - } catch (RemoteException e) { - Log.w(TAG, e); - } - return true; - } - - } - } catch (Exception e) { - // This is not remote... - } - return false; - } -*/ - - private class DefaultWindow extends FrameLayout { - @SuppressWarnings("deprecation") - public DefaultWindow(View view) { - super(context); - addView(view); - if (SDK_INT > ICE_CREAM_SANDWICH_MR1) { - setBackground(ResourcesContainer.get().getDrawable(R.drawable.maps_default_window)); - } else { - setBackgroundDrawable(ResourcesContainer.get().getDrawable(R.drawable.maps_default_window)); - } - } - } - - private class DefaultContent extends LinearLayout { - public DefaultContent() { - super(context); - setOrientation(LinearLayout.VERTICAL); - TextView title = new TextView(context); - title.setTextAppearance(context, - android.R.style.TextAppearance_DeviceDefault_Medium_Inverse); - title.setText(marker.getTitle()); - addView(title); - if (marker.getSnippet() != null) { - TextView snippet = new TextView(context); - snippet.setTextAppearance(context, - android.R.style.TextAppearance_DeviceDefault_Inverse); - snippet.setText(marker.getSnippet()); - addView(snippet); - } - } - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/MarkerImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/MarkerImpl.java deleted file mode 100644 index 83688e2e..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/MarkerImpl.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import android.content.Context; -import android.graphics.Bitmap; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.dynamic.IObjectWrapper; -import com.google.android.gms.dynamic.ObjectWrapper; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.MarkerOptions; -import com.google.android.gms.maps.model.internal.IMarkerDelegate; - -import org.microg.gms.maps.vtm.GmsMapsTypeHelper; -import org.microg.gms.maps.vtm.bitmap.BitmapDescriptorImpl; -import org.microg.gms.maps.vtm.bitmap.DefaultBitmapDescriptor; -import org.oscim.android.canvas.AndroidBitmap; -import org.oscim.layers.marker.MarkerItem; -import org.oscim.layers.marker.MarkerSymbol; - -public class MarkerImpl extends IMarkerDelegate.Stub implements MarkerItemMarkup { - private static final String TAG = "GmsMapMarkerImpl"; - - private final String id; - private final MarkerOptions options; - private final MarkupListener listener; - private BitmapDescriptorImpl icon; - private AndroidBitmap oldBitmap; - private boolean removed = false; - private IObjectWrapper tag = null; - - public MarkerImpl(String id, MarkerOptions options, MarkupListener listener) { - this.id = id; - this.listener = listener; - this.options = options == null ? new MarkerOptions() : options; - if (options.getPosition() == null) { - options.position(new LatLng(0, 0)); - } - icon = options.getIcon() == null ? null : new BitmapDescriptorImpl(options.getIcon()); - Log.d(TAG, "New marker " + id + " with title " + options.getTitle() + " @ " + - options.getPosition()); - } - - @Override - public void remove() { - listener.remove(this); - removed = true; - icon = null; - oldBitmap = null; - } - - @Override - public String getId() { - return id; - } - - @Override - public void setPosition(LatLng pos) { - options.position(pos); - listener.update(this); - } - - @Override - public LatLng getPosition() { - return options.getPosition(); - } - - @Override - public void setTitle(String title) { - options.title(title); - listener.update(this); - } - - @Override - public String getTitle() { - return options.getTitle(); - } - - @Override - public void setSnippet(String snippet) { - options.snippet(snippet); - } - - @Override - public String getSnippet() { - return options.getSnippet(); - } - - @Override - public void setDraggable(boolean drag) { - options.draggable(drag); - } - - @Override - public boolean isDraggable() { - return options.isDraggable(); - } - - @Override - public void showInfoWindow() { - - } - - @Override - public void hideInfoWindow() { - - } - - @Override - public boolean isInfoWindowShown() { - return false; - } - - @Override - public void setVisible(boolean visible) { - options.visible(visible); - } - - @Override - public boolean isVisible() { - return options.isVisible(); - } - - @Override - public boolean equalsRemote(IMarkerDelegate other) throws RemoteException { - return other != null && other.getId().equals(getId()); - } - - @Override - public int hashCodeRemote() { - return hashCode(); - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public void setIcon(IObjectWrapper obj) { - if (obj == null) { - icon = new BitmapDescriptorImpl(); - } else { - icon = new BitmapDescriptorImpl(obj); - } - listener.update(this); - } - - @Override - public void setAnchor(float x, float y) { - options.anchor(x, y); - listener.update(this); - } - - @Override - public void setFlat(boolean flat) { - options.flat(flat); - listener.update(this); - } - - @Override - public boolean isFlat() { - return options.isFlat(); - } - - @Override - public void setRotation(float rotation) { - options.rotation(rotation); - listener.update(this); - } - - @Override - public float getRotation() { - return options.getRotation(); - } - - @Override - public void setInfoWindowAnchor(float x, float y) { - options.infoWindowAnchor(x, y); - } - - @Override - public void setAlpha(float alpha) { - options.alpha(alpha); - listener.update(this); - } - - @Override - public float getAlpha() { - return options.getAlpha(); - } - - public int getHeight() { - Bitmap bitmap = icon.getBitmap(); - if (bitmap == null) - return -1; - return bitmap.getHeight(); - } - - @Override - public boolean onClick() { - return listener.onClick(this); - } - - @Override - public void onDragStart() { - listener.onDragStart(this); - } - - @Override - public void onDragStop() { - listener.onDragStop(this); - } - - @Override - public void onDragProgress() { - listener.onDragProgress(this); - } - - @Override - public MarkerItem getMarkerItem(Context context) { - if (removed) return null; - MarkerItem item = new MarkerItem(getId(), getTitle(), getSnippet(), - GmsMapsTypeHelper.fromLatLng(getPosition())); - BitmapDescriptorImpl icon = this.icon; - if (icon == null) - icon = DefaultBitmapDescriptor.DEFAULT_DESCRIPTOR_IMPL; - if (icon.getBitmap() != null) { - oldBitmap = new AndroidBitmap(icon.getBitmap()); - prepareMarkerIcon(item); - } else { - if (!icon.loadBitmapAsync(context, new Runnable() { - @Override - public void run() { - listener.update(MarkerImpl.this); - } - })) { - // Was loaded since last check... - oldBitmap = new AndroidBitmap(icon.getBitmap()); - prepareMarkerIcon(item); - } - // Keep old icon while loading new - if (oldBitmap != null) { - prepareMarkerIcon(item); - } - } - return item; - } - - private void prepareMarkerIcon(MarkerItem item) { - item.setMarker(new MarkerSymbol(oldBitmap, options.getAnchorU(), options.getAnchorV(), !options.isFlat())); - } - - @Override - public void setZIndex(float zIndex) { - options.zIndex(zIndex); - } - - @Override - public float getZIndex() { - return options.getZIndex(); - } - - @Override - public void setTag(IObjectWrapper obj) { - this.tag = obj; - } - - @Override - public IObjectWrapper getTag() { - return this.tag == null ? ObjectWrapper.wrap(null) : this.tag; - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/MarkerItemMarkup.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/MarkerItemMarkup.java deleted file mode 100644 index e243d88d..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/MarkerItemMarkup.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import android.content.Context; - -import com.google.android.gms.maps.model.LatLng; - -import org.oscim.layers.marker.MarkerItem; - -public interface MarkerItemMarkup extends Markup { - MarkerItem getMarkerItem(Context context); - - boolean isDraggable(); - - LatLng getPosition(); - - void setPosition(LatLng latLng); -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/Markup.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/Markup.java deleted file mode 100644 index 583343d8..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/Markup.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -public interface Markup { - String getId(); - - boolean onClick(); - - void onDragStart(); - void onDragStop(); - void onDragProgress(); - - interface MarkupListener { - void update(Markup markup); - - void remove(Markup markup); - - boolean onClick(Markup markup); - - void onDragStart(Markup markup); - - void onDragStop(Markup markup); - - void onDragProgress(Markup markup); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/PolygonImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/PolygonImpl.java deleted file mode 100644 index d17f647b..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/PolygonImpl.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import android.os.RemoteException; - -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.PolygonOptions; -import com.google.android.gms.maps.model.internal.IPolygonDelegate; - -import org.microg.gms.maps.vtm.GmsMapsTypeHelper; -import org.oscim.core.GeoPoint; -import org.oscim.layers.vector.geometries.Drawable; -import org.oscim.layers.vector.geometries.PolygonDrawable; -import org.oscim.layers.vector.geometries.Style; -import org.oscim.map.Map; - -import java.util.ArrayList; -import java.util.List; - -public class PolygonImpl extends IPolygonDelegate.Stub implements DrawableMarkup { - private static final String TAG = "GmsMapsPolygonImpl"; - - private final String id; - private final PolygonOptions options; - private final MarkupListener listener; - private boolean removed = false; - - public PolygonImpl(String id, PolygonOptions options, MarkupListener listener) { - this.id = id; - this.options = options; - this.listener = listener; - } - - @Override - public void remove() throws RemoteException { - listener.remove(this); - removed = true; - } - - @Override - public String getId() { - return id; - } - - @Override - public boolean onClick() { - return listener.onClick(this); - } - - @Override - public void onDragStart() { - listener.onDragStart(this); - } - - @Override - public void onDragStop() { - listener.onDragStop(this); - } - - @Override - public void onDragProgress() { - listener.onDragProgress(this); - } - - @Override - public void setPoints(List points) throws RemoteException { - options.getPoints().clear(); - options.getPoints().addAll(points); - listener.update(this); - } - - @Override - public List getPoints() throws RemoteException { - return options.getPoints(); - } - - @Override - public void setHoles(List holes) throws RemoteException { - options.getHoles().clear(); - options.getHoles().addAll(holes); - listener.update(this); - } - - @Override - public List getHoles() throws RemoteException { - return options.getHoles(); - } - - @Override - public void setStrokeWidth(float width) throws RemoteException { - options.strokeWidth(width); - listener.update(this); - } - - @Override - public float getStrokeWidth() { - return options.getStrokeWidth(); - } - - @Override - public void setStrokeColor(int color) throws RemoteException { - options.strokeColor(color); - listener.update(this); - } - - @Override - public int getStrokeColor() { - return options.getStrokeColor(); - } - - @Override - public void setFillColor(int color) throws RemoteException { - options.fillColor(color); - listener.update(this); - } - - @Override - public int getFillColor() { - return options.getFillColor(); - } - - @Override - public void setZIndex(float zIndex) throws RemoteException { - options.zIndex(zIndex); - listener.update(this); - } - - @Override - public float getZIndex() { - return options.getZIndex(); - } - - @Override - public Drawable getDrawable(Map map) { - if (!isVisible() || removed) return null; - List points = new ArrayList(); - for (LatLng point : options.getPoints()) { - points.add(GmsMapsTypeHelper.fromLatLng(point)); - } - if (points.size() < 3 || (points.size() == 3 && points.get(2).equals(points.get(0)))) { - // Need at least 3 distinguished points to draw a polygon - return null; - } - // TODO: holes - return new PolygonDrawable(points, Style.builder() - .fillAlpha(1) - .strokeColor(getStrokeColor()) - .strokeWidth(getStrokeWidth()) - .fillColor(getFillColor()) - .build()); - } - - @Override - public void setVisible(boolean visible) throws RemoteException { - options.visible(visible); - listener.update(this); - } - - @Override - public boolean isVisible() { - return options.isVisible(); - } - - @Override - public void setGeodesic(boolean geod) throws RemoteException { - options.geodesic(geod); - listener.update(this); - } - - @Override - public boolean isGeodesic() throws RemoteException { - return options.isGeodesic(); - } - - @Override - public boolean equalsRemote(IPolygonDelegate other) throws RemoteException { - return other != null && other.getId().equals(getId()); - } - - @Override - public int hashCodeRemote() throws RemoteException { - return id.hashCode(); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/PolylineImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/PolylineImpl.java deleted file mode 100644 index b2ff4c2f..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/PolylineImpl.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.PolylineOptions; -import com.google.android.gms.maps.model.internal.IPolylineDelegate; - -import org.microg.gms.maps.vtm.GmsMapsTypeHelper; -import org.oscim.core.GeoPoint; -import org.oscim.layers.vector.geometries.Drawable; -import org.oscim.layers.vector.geometries.LineDrawable; -import org.oscim.layers.vector.geometries.Style; -import org.oscim.map.Map; - -import java.util.ArrayList; -import java.util.List; - -public class PolylineImpl extends IPolylineDelegate.Stub implements DrawableMarkup { - private static final String TAG = "GmsMapsPolylineImpl"; - - private final String id; - private final PolylineOptions options; - private final MarkupListener listener; - private boolean removed = false; - - public PolylineImpl(String id, PolylineOptions options, MarkupListener listener) { - this.id = id; - this.options = options == null ? new PolylineOptions() : options; - this.listener = listener; - } - - @Override - public void remove() { - listener.remove(this); - removed = true; - } - - @Override - public String getId() { - return id; - } - - @Override - public boolean onClick() { - return listener.onClick(this); - } - - @Override - public void onDragStart() { - listener.onDragStart(this); - } - - @Override - public void onDragStop() { - listener.onDragStop(this); - } - - @Override - public void onDragProgress() { - listener.onDragProgress(this); - } - - @Override - public void setPoints(List points) { - options.getPoints().clear(); - options.getPoints().addAll(points); - listener.update(this); - } - - @Override - public List getPoints() { - return options.getPoints(); - } - - @Override - public void setWidth(float width) { - options.width(width); - listener.update(this); - } - - @Override - public float getWidth() { - return options.getWidth(); - } - - @Override - public void setColor(int color) { - this.options.color(color); - listener.update(this); - } - - @Override - public int getColor() { - return options.getColor(); - } - - @Override - public void setZIndex(float zIndex) { - options.zIndex(zIndex); - listener.update(this); - } - - @Override - public float getZIndex() { - return options.getZIndex(); - } - - @Override - public void setVisible(boolean visible) { - options.visible(visible); - listener.update(this); - } - - @Override - public boolean isVisible() { - return options.isVisible(); - } - - @Override - public void setGeodesic(boolean geod) { - options.geodesic(geod); - listener.update(this); - } - - @Override - public boolean isGeodesic() { - return options.isGeodesic(); - } - - @Override - public boolean equalsRemote(IPolylineDelegate other) throws RemoteException { - Log.d(TAG, "equalsRemote"); - return other != null && other.getId().equals(getId()); - } - - @Override - public int hashCodeRemote() { - Log.d(TAG, "hashcodeRemote"); - return id.hashCode(); - } - - @Override - public Drawable getDrawable(Map map) { - if (!isVisible() || removed) return null; - if (options.getPoints().size() < 2) { - // You hardly draw a line with less than two points - return null; - } - List points = new ArrayList(); - for (LatLng point : options.getPoints()) { - points.add(GmsMapsTypeHelper.fromLatLng(point)); - } - return new LineDrawable(points, Style.builder().strokeColor(getColor()).strokeWidth(getWidth()).build()); - } -} diff --git a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/TileOverlayImpl.java b/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/TileOverlayImpl.java deleted file mode 100644 index c13c0f6d..00000000 --- a/play-services-maps-core-vtm/src/main/java/org/microg/gms/maps/vtm/markup/TileOverlayImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.maps.vtm.markup; - -import com.google.android.gms.maps.model.internal.ITileOverlayDelegate; - -public class TileOverlayImpl extends ITileOverlayDelegate.Stub { -} diff --git a/play-services-maps-core-vtm/src/main/res/drawable/maps_default_marker.png b/play-services-maps-core-vtm/src/main/res/drawable/maps_default_marker.png deleted file mode 100644 index a963793a..00000000 Binary files a/play-services-maps-core-vtm/src/main/res/drawable/maps_default_marker.png and /dev/null differ diff --git a/play-services-maps-core-vtm/src/main/res/drawable/maps_default_window.9.png b/play-services-maps-core-vtm/src/main/res/drawable/maps_default_window.9.png deleted file mode 100644 index 57724d79..00000000 Binary files a/play-services-maps-core-vtm/src/main/res/drawable/maps_default_window.9.png and /dev/null differ diff --git a/play-services-maps-core-vtm/src/main/res/drawable/nop.png b/play-services-maps-core-vtm/src/main/res/drawable/nop.png deleted file mode 100644 index 0e676831..00000000 Binary files a/play-services-maps-core-vtm/src/main/res/drawable/nop.png and /dev/null differ diff --git a/play-services-maps-core-vtm/vtm-microg-theme/build.gradle b/play-services-maps-core-vtm/vtm-microg-theme/build.gradle deleted file mode 100644 index 3304c9a0..00000000 --- a/play-services-maps-core-vtm/vtm-microg-theme/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -apply plugin: 'java' -apply plugin: 'maven' - -dependencies { - compile "org.microg:vtm:0.9.1-mod" -} - -sourceSets { - main.java.srcDirs = ['src'] - main.resources.srcDirs = ['resources'] -} diff --git a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/styles/microg.xml b/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/styles/microg.xml deleted file mode 100644 index 4fd884f6..00000000 --- a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/styles/microg.xml +++ /dev/null @@ -1,546 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/dot_white.svg b/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/dot_white.svg deleted file mode 100644 index af547354..00000000 --- a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/dot_white.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/transit/train_station.svg b/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/transit/train_station.svg deleted file mode 100644 index 3c54c3f6..00000000 --- a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/transit/train_station.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/transit/train_station_small.svg b/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/transit/train_station_small.svg deleted file mode 100644 index 95d239d5..00000000 --- a/play-services-maps-core-vtm/vtm-microg-theme/resources/assets/symbols/transit/train_station_small.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/play-services-maps-core-vtm/vtm-microg-theme/src/org/oscim/theme/MicrogThemes.java b/play-services-maps-core-vtm/vtm-microg-theme/src/org/oscim/theme/MicrogThemes.java deleted file mode 100644 index 6da23247..00000000 --- a/play-services-maps-core-vtm/vtm-microg-theme/src/org/oscim/theme/MicrogThemes.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.oscim.theme; - -import org.oscim.backend.AssetAdapter; - -import java.io.InputStream; - -public enum MicrogThemes implements ThemeFile { - - DEFAULT("styles/microg.xml"); - // TODO: night theme - - private final String mPath; - - MicrogThemes(String path) { - mPath = path; - } - - @Override - public XmlRenderThemeMenuCallback getMenuCallback() { - return null; - } - - @Override - public String getRelativePathPrefix() { - return ""; - } - - @Override - public InputStream getRenderThemeAsStream() { - return AssetAdapter.readFileAsStream(mPath); - } - - @Override - public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) { - } - - @Override - public boolean isMapsforgeTheme() { - return false; - } -} diff --git a/play-services-wearable-api/build.gradle b/play-services-wearable-api/build.gradle deleted file mode 100644 index 7d1eb81f..00000000 --- a/play-services-wearable-api/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013-2015 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.library' - -android { - compileSdkVersion androidCompileSdk - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName version - minSdkVersion androidMinSdk - targetSdkVersion androidTargetSdk - } - - compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - } -} - -dependencies { - api project(':play-services-basement') -} diff --git a/play-services-wearable-api/gradle.properties b/play-services-wearable-api/gradle.properties deleted file mode 100644 index c771353e..00000000 --- a/play-services-wearable-api/gradle.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2013-2016 microG Project Team -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Play Services Internal Wearable API -POM_DESCRIPTION=Interfaces and objects for IPC between Play Services Library and Play Services Core - -POM_PACKAGING=aar - -POM_URL=https://github.com/microg/android_external_GmsApi - -POM_SCM_URL=https://github.com/microg/android_external_GmsApi -POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsApi.git - -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=mar-v-in -POM_DEVELOPER_NAME=Marvin W - diff --git a/play-services-wearable-api/src/main/AndroidManifest.xml b/play-services-wearable-api/src/main/AndroidManifest.xml deleted file mode 100644 index c0cf8869..00000000 --- a/play-services-wearable-api/src/main/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/Asset.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/Asset.aidl deleted file mode 100644 index 9cb94923..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/Asset.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable; - -parcelable Asset; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/ConnectionConfiguration.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/ConnectionConfiguration.aidl deleted file mode 100644 index 973008ad..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/ConnectionConfiguration.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable; - -parcelable ConnectionConfiguration; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AddListenerRequest.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AddListenerRequest.aidl deleted file mode 100644 index 21b8bba6..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AddListenerRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable AddListenerRequest; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AddLocalCapabilityResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AddLocalCapabilityResponse.aidl deleted file mode 100644 index 875512c6..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AddLocalCapabilityResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable AddLocalCapabilityResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AmsEntityUpdateParcelable.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AmsEntityUpdateParcelable.aidl deleted file mode 100644 index 79d95d43..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AmsEntityUpdateParcelable.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable AmsEntityUpdateParcelable; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AncsNotificationParcelable.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AncsNotificationParcelable.aidl deleted file mode 100644 index 8bdf1f78..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/AncsNotificationParcelable.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable AncsNotificationParcelable; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/CapabilityInfoParcelable.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/CapabilityInfoParcelable.aidl deleted file mode 100644 index 15742eed..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/CapabilityInfoParcelable.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable CapabilityInfoParcelable; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelEventParcelable.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelEventParcelable.aidl deleted file mode 100644 index 1f86443a..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelEventParcelable.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable ChannelEventParcelable; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelReceiveFileResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelReceiveFileResponse.aidl deleted file mode 100644 index 84d56ee9..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelReceiveFileResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable ChannelReceiveFileResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelSendFileResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelSendFileResponse.aidl deleted file mode 100644 index f1547ae0..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/ChannelSendFileResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable ChannelSendFileResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/CloseChannelResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/CloseChannelResponse.aidl deleted file mode 100644 index aceab124..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/CloseChannelResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable CloseChannelResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/DeleteDataItemsResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/DeleteDataItemsResponse.aidl deleted file mode 100644 index d5402cd6..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/DeleteDataItemsResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable DeleteDataItemsResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetAllCapabilitiesResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetAllCapabilitiesResponse.aidl deleted file mode 100644 index 610e5842..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetAllCapabilitiesResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetAllCapabilitiesResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCapabilityResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCapabilityResponse.aidl deleted file mode 100644 index 09e458fd..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCapabilityResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetCapabilityResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetChannelInputStreamResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetChannelInputStreamResponse.aidl deleted file mode 100644 index 141a6558..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetChannelInputStreamResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetChannelInputStreamResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetChannelOutputStreamResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetChannelOutputStreamResponse.aidl deleted file mode 100644 index b08cdca1..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetChannelOutputStreamResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetChannelOutputStreamResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncOptInOutDoneResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncOptInOutDoneResponse.aidl deleted file mode 100644 index 3dfd71ba..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncOptInOutDoneResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetCloudSyncOptInOutDoneResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncOptInStatusResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncOptInStatusResponse.aidl deleted file mode 100644 index 20bfb741..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncOptInStatusResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetCloudSyncOptInStatusResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncSettingResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncSettingResponse.aidl deleted file mode 100644 index 3ac2cc1c..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetCloudSyncSettingResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetCloudSyncSettingResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConfigResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConfigResponse.aidl deleted file mode 100644 index 14f6b6ee..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConfigResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetConfigResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConfigsResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConfigsResponse.aidl deleted file mode 100644 index 2cb7207a..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConfigsResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetConfigsResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConnectedNodesResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConnectedNodesResponse.aidl deleted file mode 100644 index 9c0706e7..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetConnectedNodesResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetConnectedNodesResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetDataItemResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetDataItemResponse.aidl deleted file mode 100644 index b523f669..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetDataItemResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetDataItemResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetFdForAssetResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetFdForAssetResponse.aidl deleted file mode 100644 index 662ccfb6..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetFdForAssetResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetFdForAssetResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetLocalNodeResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetLocalNodeResponse.aidl deleted file mode 100644 index 90178068..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/GetLocalNodeResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable GetLocalNodeResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IChannelStreamCallbacks.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IChannelStreamCallbacks.aidl deleted file mode 100644 index 1f08e373..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IChannelStreamCallbacks.aidl +++ /dev/null @@ -1,4 +0,0 @@ -package com.google.android.gms.wearable.internal; - -interface IChannelStreamCallbacks { -} diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableCallbacks.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableCallbacks.aidl deleted file mode 100644 index ffa91cb9..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableCallbacks.aidl +++ /dev/null @@ -1,65 +0,0 @@ -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.common.api.Status; -import com.google.android.gms.common.data.DataHolder; -import com.google.android.gms.wearable.internal.AddLocalCapabilityResponse; -import com.google.android.gms.wearable.internal.ChannelReceiveFileResponse; -import com.google.android.gms.wearable.internal.ChannelSendFileResponse; -import com.google.android.gms.wearable.internal.CloseChannelResponse; -import com.google.android.gms.wearable.internal.DeleteDataItemsResponse; -import com.google.android.gms.wearable.internal.GetAllCapabilitiesResponse; -import com.google.android.gms.wearable.internal.GetCapabilityResponse; -import com.google.android.gms.wearable.internal.GetChannelInputStreamResponse; -import com.google.android.gms.wearable.internal.GetChannelOutputStreamResponse; -import com.google.android.gms.wearable.internal.GetCloudSyncOptInOutDoneResponse; -import com.google.android.gms.wearable.internal.GetCloudSyncOptInStatusResponse; -import com.google.android.gms.wearable.internal.GetCloudSyncSettingResponse; -import com.google.android.gms.wearable.internal.GetConfigResponse; -import com.google.android.gms.wearable.internal.GetConfigsResponse; -import com.google.android.gms.wearable.internal.GetConnectedNodesResponse; -import com.google.android.gms.wearable.internal.GetDataItemResponse; -import com.google.android.gms.wearable.internal.GetFdForAssetResponse; -import com.google.android.gms.wearable.internal.GetLocalNodeResponse; -import com.google.android.gms.wearable.internal.OpenChannelResponse; -import com.google.android.gms.wearable.internal.PutDataResponse; -import com.google.android.gms.wearable.internal.RemoveLocalCapabilityResponse; -import com.google.android.gms.wearable.internal.SendMessageResponse; -import com.google.android.gms.wearable.internal.StorageInfoResponse; - -interface IWearableCallbacks { - // Config - void onGetConfigResponse(in GetConfigResponse response) = 1; - void onGetConfigsResponse(in GetConfigsResponse response) = 12; - - // Cloud Sync - void onGetCloudSyncOptInOutDoneResponse(in GetCloudSyncOptInOutDoneResponse response) = 27; - void onGetCloudSyncSettingResponse(in GetCloudSyncSettingResponse response) = 28; - void onGetCloudSyncOptInStatusResponse(in GetCloudSyncOptInStatusResponse response) = 29; - - // Data - void onPutDataResponse(in PutDataResponse response) = 2; - void onGetDataItemResponse(in GetDataItemResponse response) = 3; - void onDataItemChanged(in DataHolder dataHolder) = 4; - void onDeleteDataItemsResponse(in DeleteDataItemsResponse response) = 5; - void onSendMessageResponse(in SendMessageResponse response) = 6; - void onGetFdForAssetResponse(in GetFdForAssetResponse response) = 7; - void onGetLocalNodeResponse(in GetLocalNodeResponse response) = 8; - void onGetConnectedNodesResponse(in GetConnectedNodesResponse response) = 9; - - // Channels - void onOpenChannelResponse(in OpenChannelResponse response) = 13; - void onCloseChannelResponse(in CloseChannelResponse response) = 14; - void onGetChannelInputStreamResponse(in GetChannelInputStreamResponse response) = 16; - void onGetChannelOutputStreamResponse(in GetChannelOutputStreamResponse response) = 17; - void onChannelReceiveFileResponse(in ChannelReceiveFileResponse response) = 18; - void onChannelSendFileResponse(in ChannelSendFileResponse response) = 19; - - void onStatus(in Status status) = 10; - void onStorageInfoResponse(in StorageInfoResponse response) = 11; - - // Capabilities - void onGetCapabilityResponse(in GetCapabilityResponse response) = 21; - void onGetAllCapabilitiesResponse(in GetAllCapabilitiesResponse response) = 22; - void onAddLocalCapabilityResponse(in AddLocalCapabilityResponse response) = 25; - void onRemoveLocalCapabilityResponse(in RemoveLocalCapabilityResponse response) = 26; -} diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableListener.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableListener.aidl deleted file mode 100644 index 521f1166..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableListener.aidl +++ /dev/null @@ -1,21 +0,0 @@ -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.common.data.DataHolder; -import com.google.android.gms.wearable.internal.AmsEntityUpdateParcelable; -import com.google.android.gms.wearable.internal.AncsNotificationParcelable; -import com.google.android.gms.wearable.internal.CapabilityInfoParcelable; -import com.google.android.gms.wearable.internal.ChannelEventParcelable; -import com.google.android.gms.wearable.internal.MessageEventParcelable; -import com.google.android.gms.wearable.internal.NodeParcelable; - -interface IWearableListener { - void onDataChanged(in DataHolder data) = 0; - void onMessageReceived(in MessageEventParcelable messageEvent) = 1; - void onPeerConnected(in NodeParcelable node) = 2; - void onPeerDisconnected(in NodeParcelable node) = 3; - void onConnectedNodes(in List nodes) = 4; - void onNotificationReceived(in AncsNotificationParcelable notification) = 5; - void onChannelEvent(in ChannelEventParcelable channelEvent) = 6; - void onConnectedCapabilityChanged(in CapabilityInfoParcelable capabilityInfo) = 7; - void onEntityUpdate(in AmsEntityUpdateParcelable update) = 8; -} diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableService.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableService.aidl deleted file mode 100644 index 193937e7..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/IWearableService.aidl +++ /dev/null @@ -1,82 +0,0 @@ -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.ConnectionConfiguration; -import com.google.android.gms.wearable.internal.AddListenerRequest; -import com.google.android.gms.wearable.internal.AncsNotificationParcelable; -import com.google.android.gms.wearable.internal.PutDataRequest; -import com.google.android.gms.wearable.internal.RemoveListenerRequest; -import com.google.android.gms.wearable.internal.IChannelStreamCallbacks; -import com.google.android.gms.wearable.internal.IWearableCallbacks; -import com.google.android.gms.wearable.internal.IWearableService; - -interface IWearableService { - // Configs - void putConfig(IWearableCallbacks callbacks, in ConnectionConfiguration config) = 19; - void deleteConfig(IWearableCallbacks callbacks, String name) = 20; - void getConfigs(IWearableCallbacks callbacks) = 21; - void enableConfig(IWearableCallbacks callbacks, String name) = 22; - void disableConfig(IWearableCallbacks callbacks, String name) = 23; - - // DataItems - void putData(IWearableCallbacks callbacks, in PutDataRequest request) = 5; - void getDataItem(IWearableCallbacks callbacks, in Uri uri) = 6; - void getDataItems(IWearableCallbacks callbacks) = 7; - void getDataItemsByUri(IWearableCallbacks callbacks, in Uri uri) = 8; - void getDataItemsByUriWithFilter(IWearableCallbacks callbacks, in Uri uri, int typeFilter) = 39; - void deleteDataItems(IWearableCallbacks callbacks, in Uri uri) = 10; - void deleteDataItemsWithFilter(IWearableCallbacks callbacks, in Uri uri, int typeFilter) = 40; - - void sendMessage(IWearableCallbacks callbacks, String targetNodeId, String path, in byte[] data) = 11; - void getFdForAsset(IWearableCallbacks callbacks, in Asset asset) = 12; - - void getLocalNode(IWearableCallbacks callbacks) = 13; - void getConnectedNodes(IWearableCallbacks callbacks) = 14; - - // Capabilties - void getConnectedCapability(IWearableCallbacks callbacks, String capability, int nodeFilter) = 41; - void getConnectedCapaibilties(IWearableCallbacks callbacks, int nodeFilter) = 42; - void addLocalCapability(IWearableCallbacks callbacks, String capability) = 45; - void removeLocalCapability(IWearableCallbacks callbacks, String capability) = 46; - - void addListener(IWearableCallbacks callbacks, in AddListenerRequest request) = 15; - void removeListener(IWearableCallbacks callbacks, in RemoveListenerRequest request) = 16; - - void getStorageInformation(IWearableCallbacks callbacks) = 17; - void clearStorage(IWearableCallbacks callbacks) = 18; - - void endCall(IWearableCallbacks callbacks) = 24; - void acceptRingingCall(IWearableCallbacks callbacks) = 25; - void silenceRinger(IWearableCallbacks callbacks) = 29; - - // Apple Notification Center Service - void injectAncsNotificationForTesting(IWearableCallbacks callbacks, in AncsNotificationParcelable notification) = 26; - void doAncsPositiveAction(IWearableCallbacks callbacks, int i) = 27; - void doAncsNegativeAction(IWearableCallbacks callbacks, int i) = 28; - - // Channels - void openChannel(IWearableCallbacks callbacks, String s1, String s2) = 30; - void closeChannel(IWearableCallbacks callbacks, String s) = 31; - void closeChannelWithError(IWearableCallbacks callbacks, String s, int errorCode) = 32; - void getChannelInputStream(IWearableCallbacks callbacks, IChannelStreamCallbacks channelCallbacks, String s) = 33; - void getChannelOutputStream(IWearableCallbacks callbacks, IChannelStreamCallbacks channelCallbacks, String s) = 34; - void writeChannelInputToFd(IWearableCallbacks callbacks, String s, in ParcelFileDescriptor fd) = 37; - void readChannelOutputFromFd(IWearableCallbacks callbacks, String s, in ParcelFileDescriptor fd, long l1, long l2) = 38; - - void syncWifiCredentials(IWearableCallbacks callbacks) = 36; - - // Cloud Sync - void optInCloudSync(IWearableCallbacks callbacks, boolean enable) = 47; - void getCloudSyncOptInDone(IWearableCallbacks callbacks) = 48; // deprecated - void setCloudSyncSetting(IWearableCallbacks callbacks, boolean enable) = 49; - void getCloudSyncSetting(IWearableCallbacks callbacks) = 50; - void getCloudSyncOptInStatus(IWearableCallbacks callbacks) = 51; - - void sendRemoteCommand(IWearableCallbacks callbacks, byte b) = 52; - - // deprecated Connection - void putConnection(IWearableCallbacks callbacks, in ConnectionConfiguration config) = 1; - void getConnection(IWearableCallbacks callbacks) = 2; - void enableConnection(IWearableCallbacks callbacks) = 3; - void disableConnection(IWearableCallbacks callbacks) = 4; -} diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/MessageEventParcelable.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/MessageEventParcelable.aidl deleted file mode 100644 index a3968f06..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/MessageEventParcelable.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable MessageEventParcelable; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/NodeParcelable.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/NodeParcelable.aidl deleted file mode 100644 index f10069df..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/NodeParcelable.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable NodeParcelable; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/OpenChannelResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/OpenChannelResponse.aidl deleted file mode 100644 index 4bc17769..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/OpenChannelResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable OpenChannelResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/PutDataRequest.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/PutDataRequest.aidl deleted file mode 100644 index 7fe2a19b..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/PutDataRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable PutDataRequest; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/PutDataResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/PutDataResponse.aidl deleted file mode 100644 index 6f6f23e0..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/PutDataResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable PutDataResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/RemoveListenerRequest.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/RemoveListenerRequest.aidl deleted file mode 100644 index bf28d18f..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/RemoveListenerRequest.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable RemoveListenerRequest; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/RemoveLocalCapabilityResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/RemoveLocalCapabilityResponse.aidl deleted file mode 100644 index dc358804..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/RemoveLocalCapabilityResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable RemoveLocalCapabilityResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/SendMessageResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/SendMessageResponse.aidl deleted file mode 100644 index 3c83498f..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/SendMessageResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable SendMessageResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/StorageInfoResponse.aidl b/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/StorageInfoResponse.aidl deleted file mode 100644 index ea1ab215..00000000 --- a/play-services-wearable-api/src/main/aidl/com/google/android/gms/wearable/internal/StorageInfoResponse.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package com.google.android.gms.wearable.internal; - -parcelable StorageInfoResponse; \ No newline at end of file diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/AmsEntityUpdate.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/AmsEntityUpdate.java deleted file mode 100644 index 768f4d52..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/AmsEntityUpdate.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -public interface AmsEntityUpdate { -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/AncsNotification.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/AncsNotification.java deleted file mode 100644 index eec6647c..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/AncsNotification.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -public interface AncsNotification { -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/Asset.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/Asset.java deleted file mode 100644 index c9e22edf..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/Asset.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.net.Uri; -import android.os.ParcelFileDescriptor; - -import com.google.android.gms.wearable.internal.PutDataRequest; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.Arrays; - -/** - * An asset is a binary blob shared between data items that is replicated across the wearable - * network on demand. - *

- * It may represent an asset not yet added with the Android Wear network. DataItemAssets - * are representations of an asset after it has been added to the network through a - * {@link PutDataRequest}. - */ -@PublicApi -public class Asset extends AutoSafeParcelable { - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - @PublicApi(exclude = true) - public byte[] data; - @SafeParceled(3) - private String digest; - @SafeParceled(4) - private ParcelFileDescriptor fd; - @SafeParceled(5) - private Uri uri; - - private Asset() { - } - - private Asset(byte[] data, String digest, ParcelFileDescriptor fd, Uri uri) { - this.data = data; - this.digest = digest; - this.fd = fd; - this.uri = uri; - } - - /** - * Creates an Asset using a byte array. - */ - public static Asset createFromBytes(byte[] assetData) { - return null; - } - - /** - * Creates an Asset using a file descriptor. The FD should be closed after being successfully - * sent in a putDataItem request. - */ - public static Asset createFromFd(ParcelFileDescriptor fd) { - if (fd == null) { - throw new IllegalArgumentException("Asset fd cannot be null"); - } - return new Asset(null, null, fd, null); - } - - /** - * Create an Asset using an existing Asset's digest. - */ - public static Asset createFromRef(String digest) { - if (digest == null) { - throw new IllegalArgumentException("Asset digest cannot be null"); - } - return new Asset(null, digest, null, null); - } - - /** - * Creates an Asset using a content URI. Google Play services must have permission to read this - * Uri. - */ - public static Asset createFromUri(Uri uri) { - return null; - } - - /** - * @return the digest associated with the asset data. A digest is a content identifier used to - * identify the asset across devices. - */ - public String getDigest() { - return digest; - } - - /** - * @return the file descriptor referencing the asset. - */ - public ParcelFileDescriptor getFd() { - return fd; - } - - /** - * @return the uri referencing the asset data. - */ - public Uri getUri() { - return uri; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Asset asset = (Asset) o; - - if (!Arrays.equals(data, asset.data)) return false; - if (digest != null ? !digest.equals(asset.digest) : asset.digest != null) return false; - if (fd != null ? !fd.equals(asset.fd) : asset.fd != null) return false; - return !(uri != null ? !uri.equals(asset.uri) : asset.uri != null); - - } - - @Override - public int hashCode() { - return Arrays.hashCode(new Object[]{data, digest, fd, uri}); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("Asset[@") - .append(Integer.toHexString(hashCode())) - .append(", ") - .append(digest != null ? digest : "nodigest"); - if (this.data != null) sb.append(", size=").append(data.length); - if (this.fd != null) sb.append(", fd=").append(fd); - if (this.uri != null) sb.append(", uri=").append(uri); - return sb.append("]").toString(); - } - - public static final Creator CREATOR = new AutoCreator(Asset.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/CapabilityInfo.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/CapabilityInfo.java deleted file mode 100644 index 6c9dd1ab..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/CapabilityInfo.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import java.util.Set; - -/** - * Information about a Capability on the network and where it is available. - */ -public interface CapabilityInfo { - /** - * Returns the name of the capability. - */ - String getName(); - - /** - * Returns the set of nodes for the capability. Disconnected nodes may or may not be included in the set. - */ - Set getNodes(); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/ConnectionConfiguration.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/ConnectionConfiguration.java deleted file mode 100644 index 214481da..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/ConnectionConfiguration.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class ConnectionConfiguration extends AutoSafeParcelable { - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final String name; - @SafeParceled(3) - public final String address; - @SafeParceled(4) - public final int type; - @SafeParceled(5) - public final int role; - @SafeParceled(6) - public final boolean enabled; - @SafeParceled(7) - public boolean connected = false; - @SafeParceled(8) - public String peerNodeId; - @SafeParceled(9) - public boolean btlePriority = true; - @SafeParceled(10) - public String nodeId; - - private ConnectionConfiguration() { - name = address = null; - type = role = 0; - enabled = false; - } - - public ConnectionConfiguration(String name, String address, int type, int role, boolean enabled) { - this.name = name; - this.address = address; - this.type = type; - this.role = role; - this.enabled = enabled; - } - - public ConnectionConfiguration(String name, String address, int type, int role, boolean enabled, String nodeId) { - this.name = name; - this.address = address; - this.type = type; - this.role = role; - this.enabled = enabled; - this.nodeId = nodeId; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("ConnectionConfiguration{"); - sb.append("name='").append(name).append('\''); - sb.append(", address='").append(address).append('\''); - sb.append(", type=").append(type); - sb.append(", role=").append(role); - sb.append(", enabled=").append(enabled); - sb.append(", connected=").append(connected); - sb.append(", peerNodeId='").append(peerNodeId).append('\''); - sb.append(", btlePriority=").append(btlePriority); - sb.append(", nodeId='").append(nodeId).append('\''); - sb.append('}'); - return sb.toString(); - } - - public static final Creator CREATOR = new AutoCreator(ConnectionConfiguration.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/DataItem.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/DataItem.java deleted file mode 100644 index 56a30823..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/DataItem.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.net.Uri; - -import com.google.android.gms.common.data.Freezable; - -import org.microg.gms.common.PublicApi; - -import java.util.Map; - -/** - * The base object of data stored in the Android Wear network. {@link DataItem} are replicated - * across all devices in the network. It contains a small blob of data and associated assets. - *

- * A {@link DataItem} is identified by its Uri, which contains its creator and a path. - */ -@PublicApi -public interface DataItem extends Freezable { - /** - * A map of assets associated with this data item. - */ - Map getAssets(); - - /** - * An array of data stored at the specified {@link Uri}. - */ - byte[] getData(); - - /** - * Returns the DataItem's Uri. {@link Uri#getHost()} returns the id of the node that created it. - */ - Uri getUri(); - - /** - * Sets the data in a data item. - *

- * The current maximum data item size limit is approximately 100k. Data items should generally be much smaller than this limit. - */ - DataItem setData(byte[] data); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/DataItemAsset.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/DataItemAsset.java deleted file mode 100644 index c4392155..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/DataItemAsset.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.data.Freezable; - -/** - * A reference to an asset stored in a data item. Used to fetch file descriptors using - * DataApi#getFdForAsset(GoogleApiClient, DataItemAsset). - */ -public interface DataItemAsset extends Freezable { - /** - * @return the identifier used to address this asset in the context of an existing - * {@link DataItem}. - */ - String getDataItemKey(); - - /** - * @return the Android Wear-wide unique identifier for a particular asset. - */ - String getId(); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/MessageEvent.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/MessageEvent.java deleted file mode 100644 index 17f44c13..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/MessageEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import org.microg.gms.common.PublicApi; - -@PublicApi -public interface MessageEvent { - /** - * @return the data passed by the message. - */ - byte[] getData(); - - /** - * @return the path the message is being delivered to - */ - String getPath(); - - /** - * @return the request id of the message, generated by the sender - */ - int getRequestId(); - - /** - * @return the node ID of the sender. - */ - String getSourceNodeId(); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/Node.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/Node.java deleted file mode 100644 index 6cef4ec0..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/Node.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import org.microg.gms.common.PublicApi; - -/** - * Information about a particular node in the Android Wear network. - */ -@PublicApi -public interface Node { - /** - * Returns a human readable description of the node. Sometimes generated from the Bluetooth - * device name - */ - String getDisplayName(); - - /** - * Returns an opaque string that represents a node in the Android Wear network. - */ - String getId(); - - /** - * Indicates that this node can be considered geographically nearby the local node. - */ - boolean isNearby(); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/WearableStatusCodes.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/WearableStatusCodes.java deleted file mode 100644 index dc3bc64e..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/WearableStatusCodes.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.api.CommonStatusCodes; - -import org.microg.gms.common.PublicApi; - -/** - * Error codes for wearable API failures. These values may be returned by APIs to indicate the - * success or failure of a request. - */ -@PublicApi -public class WearableStatusCodes extends CommonStatusCodes { - /** - * Indicates that the targeted node is not accessible in the wearable network. - */ - public static final int TARGET_NODE_NOT_CONNECTED = 4000; - /** - * Indicates that the specified listener is already registered. - */ - public static final int DUPLICATE_LISTENER = 4001; - /** - * Indicates that the specified listener is not recognized. - */ - public static final int UNKNOWN_LISTENER = 4002; - /** - * Indicates that the data item was too large to set. - */ - public static final int DATA_ITEM_TOO_LARGE = 4003; - /** - * Indicates that the targeted node is not a valid node in the wearable network. - */ - public static final int INVALID_TARGET_NODE = 4004; - /** - * Indicates that the requested asset is unavailable. - */ - public static final int ASSET_UNAVAILABLE = 4005; - /** - * Indicates that the specified capability already exists. - */ - public static final int DUPLICATE_CAPABILITY = 4006; - /** - * Indicates that the specified capability is not recognized. - */ - public static final int UNKNOWN_CAPABILITY = 4007; - /** - * Indicates that the WiFi credential sync no credential fetched. - */ - public static final int WIFI_CREDENTIAL_SYNC_NO_CREDENTIAL_FETCHED = 4008; -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AddListenerRequest.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AddListenerRequest.java deleted file mode 100644 index 62dcf75e..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AddListenerRequest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import android.content.IntentFilter; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class AddListenerRequest extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final IWearableListener listener; - @SafeParceled(3) - public final IntentFilter[] intentFilters; - @SafeParceled(4) - public final String channelTokenString; - - private AddListenerRequest() { - listener = null; - intentFilters = null; - channelTokenString = null; - } - - public AddListenerRequest(IWearableListener listener, IntentFilter[] intentFilters, String channelTokenString) { - this.listener = listener; - this.intentFilters = intentFilters; - this.channelTokenString = channelTokenString; - } - - public static final Creator CREATOR = new AutoCreator(AddListenerRequest.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AddLocalCapabilityResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AddLocalCapabilityResponse.java deleted file mode 100644 index 8446da2c..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AddLocalCapabilityResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class AddLocalCapabilityResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private int status = 0; - - private AddLocalCapabilityResponse() { - } - - public AddLocalCapabilityResponse(int status) { - this.status = status; - } - - public static final Creator CREATOR = new AutoCreator(AddLocalCapabilityResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AmsEntityUpdateParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AmsEntityUpdateParcelable.java deleted file mode 100644 index f496ce59..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AmsEntityUpdateParcelable.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.AmsEntityUpdate; - -import org.microg.safeparcel.AutoSafeParcelable; - -public class AmsEntityUpdateParcelable extends AutoSafeParcelable implements AmsEntityUpdate { - public static final Creator CREATOR = new AutoCreator(AmsEntityUpdateParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AncsNotificationParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AncsNotificationParcelable.java deleted file mode 100644 index 652e1d13..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/AncsNotificationParcelable.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.AncsNotification; - -import org.microg.safeparcel.AutoSafeParcelable; - -public class AncsNotificationParcelable extends AutoSafeParcelable implements AncsNotification { - public static final Creator CREATOR = new AutoCreator(AncsNotificationParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/CapabilityInfoParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/CapabilityInfoParcelable.java deleted file mode 100644 index 49daaba5..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/CapabilityInfoParcelable.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.CapabilityInfo; -import com.google.android.gms.wearable.Node; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class CapabilityInfoParcelable extends AutoSafeParcelable implements CapabilityInfo { - @SafeParceled(1) - private int versionCode = 1; - - @SafeParceled(2) - private String name; - - @SafeParceled(value = 3, subClass = NodeParcelable.class) - private List nodeParcelables; - - private Set nodes; - private Object lock = new Object(); - - private CapabilityInfoParcelable() { - } - - public CapabilityInfoParcelable(String name, List nodeParcelables) { - this.name = name; - this.nodeParcelables = nodeParcelables; - } - - @Override - public String getName() { - return name; - } - - @Override - public synchronized Set getNodes() { - if (nodes == null) { - nodes = new HashSet(nodeParcelables); - } - return nodes; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - if (other == null || getClass() != other.getClass()) return false; - - CapabilityInfoParcelable that = (CapabilityInfoParcelable) other; - - if (versionCode != that.versionCode) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - return nodeParcelables != null ? nodeParcelables.equals(that.nodeParcelables) : that.nodeParcelables == null; - } - - @Override - public int hashCode() { - int result = versionCode; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (nodeParcelables != null ? nodeParcelables.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "CapabilityInfo{" + name + ", " + nodeParcelables + "}"; - } - - public static final Creator CREATOR = new AutoCreator(CapabilityInfoParcelable.class); - -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelEventParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelEventParcelable.java deleted file mode 100644 index 39dedeeb..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelEventParcelable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class ChannelEventParcelable extends AutoSafeParcelable { - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public ChannelParcelable channel; - @SafeParceled(3) - public int eventType; - @SafeParceled(4) - public int closeReason; - @SafeParceled(5) - public int appSpecificErrorCode; - - public static final Creator CREATOR = new AutoCreator(ChannelEventParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelParcelable.java deleted file mode 100644 index 79ffb070..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelParcelable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class ChannelParcelable extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public String token; - @SafeParceled(3) - public String nodeId; - @SafeParceled(4) - public String path; - - private ChannelParcelable() { - } - - public ChannelParcelable(String token, String nodeId, String path) { - this.token = token; - this.nodeId = nodeId; - this.path = path; - } - - public static final Creator CREATOR = new AutoCreator(ChannelParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelReceiveFileResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelReceiveFileResponse.java deleted file mode 100644 index 9a6a05fe..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelReceiveFileResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class ChannelReceiveFileResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(ChannelReceiveFileResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelSendFileResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelSendFileResponse.java deleted file mode 100644 index 09a2cb19..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/ChannelSendFileResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class ChannelSendFileResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(ChannelSendFileResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/CloseChannelResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/CloseChannelResponse.java deleted file mode 100644 index 3520593b..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/CloseChannelResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class CloseChannelResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(CloseChannelResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DataItemAssetParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DataItemAssetParcelable.java deleted file mode 100644 index 76957360..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DataItemAssetParcelable.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.DataItemAsset; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class DataItemAssetParcelable extends AutoSafeParcelable implements DataItemAsset { - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private String id; - @SafeParceled(3) - private String key; - - private DataItemAssetParcelable() { - } - - public DataItemAssetParcelable(String id, String key) { - this.id = id; - this.key = key; - } - - @Override - public String getDataItemKey() { - return key; - } - - @Override - public String getId() { - return id; - } - - @Override - public DataItemAsset freeze() { - return this; - } - - @Override - public boolean isDataValid() { - return true; - } - - public static final Creator CREATOR = new AutoCreator(DataItemAssetParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DataItemParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DataItemParcelable.java deleted file mode 100644 index 837b5fa9..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DataItemParcelable.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import android.net.Uri; -import android.os.Bundle; - -import com.google.android.gms.wearable.DataItem; -import com.google.android.gms.wearable.DataItemAsset; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.HashMap; -import java.util.Map; - -public class DataItemParcelable extends AutoSafeParcelable implements DataItem { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private Uri uri; - @SafeParceled(4) - private Bundle assets = new Bundle(); - @SafeParceled(5) - public byte[] data; - - private DataItemParcelable() { - } - - public DataItemParcelable(Uri uri) { - this(uri, new HashMap()); - } - - public DataItemParcelable(Uri uri, Map assets) { - this.uri = uri; - for (String key : assets.keySet()) { - this.assets.putParcelable(key, assets.get(key)); - } - data = null; - } - - public Map getAssets() { - Map assets = new HashMap(); - this.assets.setClassLoader(DataItemAssetParcelable.class.getClassLoader()); - for (String key : this.assets.keySet()) { - assets.put(key, (DataItemAssetParcelable) this.assets.getParcelable(key)); - } - return assets; - } - - @Override - public byte[] getData() { - return data; - } - - @Override - public Uri getUri() { - return uri; - } - - @Override - public DataItem setData(byte[] data) { - this.data = data; - return this; - } - - @Override - public DataItem freeze() { - return this; - } - - @Override - public boolean isDataValid() { - return true; - } - - public static final Creator CREATOR = new AutoCreator(DataItemParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DeleteDataItemsResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DeleteDataItemsResponse.java deleted file mode 100644 index 01985c2d..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/DeleteDataItemsResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class DeleteDataItemsResponse extends AutoSafeParcelable { - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private int status; - @SafeParceled(3) - private int count; - - private DeleteDataItemsResponse() { - } - - public DeleteDataItemsResponse(int status, int count) { - this.status = status; - this.count = count; - } - - public static final Creator CREATOR = new AutoCreator(DeleteDataItemsResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetAllCapabilitiesResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetAllCapabilitiesResponse.java deleted file mode 100644 index a807ec29..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetAllCapabilitiesResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetAllCapabilitiesResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(GetAllCapabilitiesResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCapabilityResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCapabilityResponse.java deleted file mode 100644 index be7a5565..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCapabilityResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetCapabilityResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private int status; - @SafeParceled(3) - private CapabilityInfoParcelable capabilityInfo; - - private GetCapabilityResponse() { - } - - public GetCapabilityResponse(int status, CapabilityInfoParcelable capabilityInfo) { - this.status = status; - this.capabilityInfo = capabilityInfo; - } - - public static final Creator CREATOR = new AutoCreator(GetCapabilityResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetChannelInputStreamResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetChannelInputStreamResponse.java deleted file mode 100644 index b5460a43..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetChannelInputStreamResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetChannelInputStreamResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(GetChannelInputStreamResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetChannelOutputStreamResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetChannelOutputStreamResponse.java deleted file mode 100644 index 71e024e2..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetChannelOutputStreamResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetChannelOutputStreamResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(GetChannelOutputStreamResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncOptInOutDoneResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncOptInOutDoneResponse.java deleted file mode 100644 index 1c3c63ec..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncOptInOutDoneResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetCloudSyncOptInOutDoneResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(GetCloudSyncOptInOutDoneResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncOptInStatusResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncOptInStatusResponse.java deleted file mode 100644 index da213312..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncOptInStatusResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetCloudSyncOptInStatusResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(GetCloudSyncOptInStatusResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncSettingResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncSettingResponse.java deleted file mode 100644 index 97fd9cb7..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetCloudSyncSettingResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetCloudSyncSettingResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public int statusCode; - @SafeParceled(3) - public boolean cloudSyncEnabled; - - private GetCloudSyncSettingResponse() {} - - public GetCloudSyncSettingResponse(int statusCode, boolean cloudSyncEnabled) { - this.statusCode = statusCode; - this.cloudSyncEnabled = cloudSyncEnabled; - } - - public static final Creator CREATOR = new AutoCreator(GetCloudSyncSettingResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConfigResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConfigResponse.java deleted file mode 100644 index bb637358..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConfigResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.ConnectionConfiguration; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetConfigResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final int statusCode; - @SafeParceled(3) - public final ConnectionConfiguration connectionConfiguration; - - private GetConfigResponse() { - statusCode = 0; - connectionConfiguration = null; - } - - public GetConfigResponse(int statusCode, ConnectionConfiguration connectionConfiguration) { - this.statusCode = statusCode; - this.connectionConfiguration = connectionConfiguration; - } - - public static final Creator CREATOR = new AutoCreator(GetConfigResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConfigsResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConfigsResponse.java deleted file mode 100644 index 5c0cc2cf..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConfigsResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.ConnectionConfiguration; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetConfigsResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final int statusCode; - @SafeParceled(3) - public final ConnectionConfiguration[] configurations; - - private GetConfigsResponse() { - statusCode = 0; - configurations = null; - } - - public GetConfigsResponse(int statusCode, ConnectionConfiguration[] configurations) { - this.statusCode = statusCode; - this.configurations = configurations; - } - - public static final Creator CREATOR = new AutoCreator(GetConfigsResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConnectedNodesResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConnectedNodesResponse.java deleted file mode 100644 index b43c2df1..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetConnectedNodesResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.List; - -public class GetConnectedNodesResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final int statusCode; - @SafeParceled(value = 3, subClass = NodeParcelable.class) - public final List nodes; - - private GetConnectedNodesResponse() { - statusCode = 0; - nodes = null; - } - - public GetConnectedNodesResponse(int statusCode, List nodes) { - this.statusCode = statusCode; - this.nodes = nodes; - } - - public static final Creator CREATOR = new AutoCreator(GetConnectedNodesResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetDataItemResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetDataItemResponse.java deleted file mode 100644 index aeec53a1..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetDataItemResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetDataItemResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final int statusCode; - @SafeParceled(3) - public final DataItemParcelable dataItem; - - private GetDataItemResponse() { - statusCode = 0; - dataItem = null; - } - - public GetDataItemResponse(int statusCode, DataItemParcelable dataItem) { - this.statusCode = statusCode; - this.dataItem = dataItem; - } - - public static final Creator CREATOR = new AutoCreator(GetDataItemResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetFdForAssetResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetFdForAssetResponse.java deleted file mode 100644 index 7c34414d..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetFdForAssetResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import android.os.ParcelFileDescriptor; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetFdForAssetResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - - @SafeParceled(2) - public int statusCode; - - @SafeParceled(3) - public ParcelFileDescriptor pfd; - - private GetFdForAssetResponse() { - } - - public GetFdForAssetResponse(int statusCode, ParcelFileDescriptor pfd) { - this.statusCode = statusCode; - this.pfd = pfd; - } - - public static final Creator CREATOR = new AutoCreator(GetFdForAssetResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetLocalNodeResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetLocalNodeResponse.java deleted file mode 100644 index 1acbaaf0..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/GetLocalNodeResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class GetLocalNodeResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final int statusCode; - @SafeParceled(3) - public final NodeParcelable node; - - private GetLocalNodeResponse() { - statusCode = 0; - node = null; - } - - public GetLocalNodeResponse(int statusCode, NodeParcelable node) { - this.statusCode = statusCode; - this.node = node; - } - - public static final Creator CREATOR = new AutoCreator(GetLocalNodeResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/MessageEventParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/MessageEventParcelable.java deleted file mode 100644 index 1eb95c32..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/MessageEventParcelable.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.MessageEvent; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class MessageEventParcelable extends AutoSafeParcelable implements MessageEvent { - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public int requestId; - @SafeParceled(3) - public String path; - @SafeParceled(4) - public byte[] data; - @SafeParceled(5) - public String sourceNodeId; - - @Override - public byte[] getData() { - return data; - } - - @Override - public String getPath() { - return path; - } - - @Override - public int getRequestId() { - return requestId; - } - - @Override - public String getSourceNodeId() { - return sourceNodeId; - } - - @Override - public String toString() { - return "MessageEventParcelable{" + - "requestId=" + requestId + - ", path='" + path + '\'' + - ", dataSize=" + (data != null ? data.length : -1) + - ", sourceNodeId='" + sourceNodeId + '\'' + - '}'; - } - - public static final Creator CREATOR = new AutoCreator(MessageEventParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/NodeParcelable.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/NodeParcelable.java deleted file mode 100644 index 1c8af18b..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/NodeParcelable.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import com.google.android.gms.wearable.Node; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -/** - * Parcelable implementation of the {@link com.google.android.gms.wearable.Node} interface. - */ -public class NodeParcelable extends AutoSafeParcelable implements Node { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private final String nodeId; - @SafeParceled(3) - private final String displayName; - @SafeParceled(4) - private final int hops; - @SafeParceled(5) - private final boolean isNearby; - - private NodeParcelable() { - nodeId = displayName = null; - hops = 0; - isNearby = false; - } - - public NodeParcelable(String nodeId, String displayName, int hops, boolean isNearby) { - this.nodeId = nodeId; - this.displayName = displayName; - this.hops = hops; - this.isNearby = isNearby; - } - - public NodeParcelable(String nodeId, String displayName) { - this(nodeId, displayName, 0, false); - } - - public NodeParcelable(Node node) { - this(node.getId(), node.getDisplayName(), 0, node.isNearby()); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - NodeParcelable that = (NodeParcelable) o; - - if (!nodeId.equals(that.nodeId)) return false; - if (!displayName.equals(that.displayName)) return false; - - return true; - } - - @Override - public String getDisplayName() { - return displayName; - } - - @Override - public String getId() { - return nodeId; - } - - @Override - public boolean isNearby() { - return isNearby; - } - - @Override - public int hashCode() { - return nodeId.hashCode(); - } - - @Override - public String toString() { - return "NodeParcelable{" + displayName + ", id=" + displayName + ", hops=" + hops + ", isNearby=" + isNearby + "}"; - } - - public static final Creator CREATOR = new AutoCreator(NodeParcelable.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/OpenChannelResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/OpenChannelResponse.java deleted file mode 100644 index fcd97a22..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/OpenChannelResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class OpenChannelResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - public static final Creator CREATOR = new AutoCreator(OpenChannelResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java deleted file mode 100644 index ec9d6b2f..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import android.net.Uri; -import android.os.Bundle; -import android.text.TextUtils; -import android.util.Base64; - -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.DataItem; - -import org.microg.gms.common.PublicApi; -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -import java.util.HashMap; -import java.util.Map; - -/** - * {@link PutDataRequest} is used to create new data items in the Android Wear network. - */ -@PublicApi -public class PutDataRequest extends AutoSafeParcelable { - public static final String WEAR_URI_SCHEME = "wear"; - private static final int DEFAULT_SYNC_DEADLINE = 30 * 60 * 1000; - - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - final Uri uri; - @SafeParceled(4) - private final Bundle assets; - @SafeParceled(5) - byte[] data; - @SafeParceled(6) - long syncDeadline = DEFAULT_SYNC_DEADLINE; - - private PutDataRequest() { - uri = null; - assets = new Bundle(); - } - - private PutDataRequest(Uri uri) { - this.uri = uri; - assets = new Bundle(); - } - - public static PutDataRequest create(Uri uri) { - return new PutDataRequest(uri); - } - - public static PutDataRequest create(String path) { - if (TextUtils.isEmpty(path)) { - throw new IllegalArgumentException("An empty path was supplied."); - } else if (!path.startsWith("/")) { - throw new IllegalArgumentException("A path must start with a single / ."); - } else if (path.startsWith("//")) { - throw new IllegalArgumentException("A path must start with a single / ."); - } else { - return create((new Uri.Builder()).scheme(WEAR_URI_SCHEME).path(path).build()); - } - } - - public static PutDataRequest createFromDataItem(DataItem source) { - PutDataRequest dataRequest = new PutDataRequest(source.getUri()); - dataRequest.data = source.getData(); - // TODO: assets - return dataRequest; - } - - public static PutDataRequest createWithAutoAppendedId(String pathPrefix) { - return new PutDataRequest(null); - } - - public Asset getAsset(String key) { - return assets.getParcelable(key); - } - - public Map getAssets() { - Map map = new HashMap(); - assets.setClassLoader(DataItemAssetParcelable.class.getClassLoader()); - for (String key : assets.keySet()) { - map.put(key, (Asset) assets.getParcelable(key)); - } - return map; - } - - public byte[] getData() { - return data; - } - - public Uri getUri() { - return uri; - } - - public boolean hasAsset(String key) { - return assets.containsKey(key); - } - - public PutDataRequest putAsset(String key, Asset value) { - assets.putParcelable(key, value); - return this; - } - - public PutDataRequest removeAsset(String key) { - assets.remove(key); - return this; - } - - public PutDataRequest setData(byte[] data) { - this.data = data; - return this; - } - - @Override - public String toString() { - return toString(false); - } - - public String toString(boolean verbose) { - StringBuilder sb = new StringBuilder(); - sb.append("PutDataRequest[uri=").append(uri) - .append(", data=").append(data == null ? "null" : Base64.encodeToString(data, Base64.NO_WRAP)) - .append(", numAssets=").append(getAssets().size()); - if (verbose && !getAssets().isEmpty()) { - sb.append(", assets=["); - for (String key : getAssets().keySet()) { - sb.append(key).append('=').append(getAsset(key)).append(", "); - } - sb.delete(sb.length() - 2, sb.length()).append(']'); - } - sb.append("]"); - return sb.toString(); - } - - public static final Creator CREATOR = new AutoCreator(PutDataRequest.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/PutDataResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/PutDataResponse.java deleted file mode 100644 index aa7d12d8..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/PutDataResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class PutDataResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final int statusCode; - @SafeParceled(3) - public final DataItemParcelable dataItem; - - private PutDataResponse() { - statusCode = 0; - dataItem = null; - } - - public PutDataResponse(int statusCode, DataItemParcelable dataItem) { - this.statusCode = statusCode; - this.dataItem = dataItem; - } - - public static final Creator CREATOR = new AutoCreator(PutDataResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/RemoveListenerRequest.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/RemoveListenerRequest.java deleted file mode 100644 index c28c74b0..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/RemoveListenerRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class RemoveListenerRequest extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - public final IWearableListener listener; - - private RemoveListenerRequest() { - listener = null; - } - - public RemoveListenerRequest(IWearableListener listener) { - this.listener = listener; - } - - public static final Creator CREATOR = new AutoCreator(RemoveListenerRequest.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/RemoveLocalCapabilityResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/RemoveLocalCapabilityResponse.java deleted file mode 100644 index 516ebee5..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/RemoveLocalCapabilityResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2019 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class RemoveLocalCapabilityResponse extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private int status = 0; - - private RemoveLocalCapabilityResponse() { - } - - public RemoveLocalCapabilityResponse(int status) { - this.status = status; - } - - public static final Creator CREATOR = new AutoCreator(RemoveLocalCapabilityResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/SendMessageResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/SendMessageResponse.java deleted file mode 100644 index 8390d333..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/SendMessageResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; -import org.microg.safeparcel.SafeParceled; - -public class SendMessageResponse extends AutoSafeParcelable { - - @SafeParceled(1) - private int versionCode = 1; - - @SafeParceled(2) - public int statusCode; - - @SafeParceled(3) - public int requestId = -1; - - public static final Creator CREATOR = new AutoCreator(SendMessageResponse.class); -} diff --git a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/StorageInfoResponse.java b/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/StorageInfoResponse.java deleted file mode 100644 index 53738b20..00000000 --- a/play-services-wearable-api/src/main/java/com/google/android/gms/wearable/internal/StorageInfoResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable.internal; - -import org.microg.safeparcel.AutoSafeParcelable; - -public class StorageInfoResponse extends AutoSafeParcelable { - public static final Creator CREATOR = new AutoCreator(StorageInfoResponse.class); -} diff --git a/play-services-wearable/build.gradle b/play-services-wearable/build.gradle deleted file mode 100644 index d8d70777..00000000 --- a/play-services-wearable/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2015 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.library' - -android { - compileSdkVersion androidCompileSdk - buildToolsVersion "$androidBuildVersionTools" - - defaultConfig { - versionName version - minSdkVersion androidMinSdk - targetSdkVersion androidTargetSdk - } - - sourceSets { - main { - java.srcDirs += 'src/main/protos-java' - } - } - - compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - } - - lintOptions { - disable 'InvalidPackage' - } -} - -dependencies { - api project(':play-services-base') - api project(':play-services-wearable-api') - implementation 'com.squareup.wire:wire-runtime:1.6.1' -} diff --git a/play-services-wearable/gradle.properties b/play-services-wearable/gradle.properties deleted file mode 100644 index 036604f2..00000000 --- a/play-services-wearable/gradle.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2013-2016 microG Project Team -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Play Services Wearable Library -POM_DESCRIPTION=The Play Services Library module to access the Wearable API - -POM_PACKAGING=aar - -POM_URL=https://github.com/microg/android_external_GmsLib - -POM_SCM_URL=https://github.com/microg/android_external_GmsLib -POM_SCM_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:microg/android_external_GmsLib.git - -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=mar-v-in -POM_DEVELOPER_NAME=Marvin W - diff --git a/play-services-wearable/src/main/AndroidManifest.xml b/play-services-wearable/src/main/AndroidManifest.xml deleted file mode 100644 index c5f892ff..00000000 --- a/play-services-wearable/src/main/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/CapabilityApi.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/CapabilityApi.java deleted file mode 100644 index fe320159..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/CapabilityApi.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.net.Uri; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.GoogleApiClient.Builder; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; - -import org.microg.gms.common.PublicApi; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.util.Map; - -/** - * Exposes an API to learn about capabilities provided by nodes on the Wear network. - *

- * Capabilities are local to an application. - */ -@PublicApi -public interface CapabilityApi { - /** - * Capability changed action for use in manifest-based listener filters. - *

- * Capability events do not support filtering by host, but can be filtered by path. - * - * @see WearableListenerService - */ - String ACTION_CAPABILITY_CHANGED = "com.google.android.gms.wearable.CAPABILITY_CHANGED"; - - /** - * Filter type for {@link #getCapability(GoogleApiClient, String, int)}, {@link #getAllCapabilities(GoogleApiClient, int)}: - * If this filter is set then the full set of nodes that declare the given capability will be - * included in the capability's CapabilityInfo. - */ - int FILTER_ALL = 0; - - /** - * Filter type for {@link #addListener(GoogleApiClient, CapabilityListener, Uri, int)}, if this - * filter is set, the given URI will be taken as a literal path, and the operation will apply - * to the matching capability only. - */ - int FILTER_LITERAL = 0; - - /** - * Filter type for {@link #addListener(GoogleApiClient, CapabilityListener, Uri, int)}, if this - * filter is set, the given URI will be taken as a path prefix, and the operation will apply - * to all matching capabilities. - */ - int FILTER_PREFIX = 1; - - /** - * Filter type for {@link #getCapability(GoogleApiClient, String, int)}, {@link #getAllCapabilities(GoogleApiClient, int): - * If this filter is set then only reachable nodes that declare the given capability will be - * included in the capability's CapabilityInfo. - */ - int FILTER_REACHABLE = 1; - - /** - * Registers a listener to be notified of a specific capability being added to or removed from - * the Wear network. Calls to this method should be balanced with {@link #removeCapabilityListener(GoogleApiClient, CapabilityListener, String)} - * to avoid leaking resources. - *

- * Listener events will be called on the main thread, or the handler specified on {@code client} - * when it was built (using {@link Builder#setHandler(Handler)}). - *

- * Callers wishing to be notified of events in the background should use {@link WearableListenerService}. - */ - PendingResult addCapabilityListener(GoogleApiClient client, CapabilityListener listener, String capability); - - /** - * Registers a listener to be notified of capabilities being added to or removed from the Wear - * network. Calls to this method should be balanced with {@link #removeListener(GoogleApiClient, CapabilityListener)} - * to avoid leaking resources. - *

- * {@code uri} and {@code filterType} can be used to filter the capability changes sent to the - * listener. For example, if {@code uri} and {@code filterType} create a prefix filter, then - * only capabilities matching that prefix will be notified. The {@code uri} follows the rules - * of the {@code } element of {@code }. The path is ignored if a URI host - * is not specified. To match capabilities by name or name prefix, the host must be {@code *}. i.e: - *

- *

wear://* /
- * Listener events will be called on the main thread, or the handler specified on {@code client} - * when it was built (using {@link Builder#setHandler(Handler)}). - * - * Callers wishing to be notified of events in the background should use WearableListenerService. - */ - PendingResult addListener(GoogleApiClient client, CapabilityListener listener, Uri uri, @CapabilityFilterType int filterType); - - /** - * Announces that a capability has become available on the local node. - */ - PendingResult addLocalCapability(GoogleApiClient client, String capability); - - /** - * Returns information about all capabilities, including the nodes that declare those - * capabilities. The filter parameter controls whether all nodes are returned, {@link #FILTER_ALL}, - * or only those that are currently reachable by this node, {@link #FILTER_REACHABLE}. - *

- * The local node will never be returned in the set of nodes. - */ - PendingResult getAllCapabilities(GoogleApiClient client, @NodeFilterType int nodeFilter); - - /** - * Returns information about a capabilities, including the nodes that declare this capability. - * The filter parameter controls whether all nodes are returned, {@link #FILTER_ALL}, or only - * those that are currently reachable by this node, {@link #FILTER_REACHABLE}. - *

- * The local node will never be returned in the set of nodes. - */ - PendingResult getCapability(GoogleApiClient client, String capability, @NodeFilterType int nodeFilter); - - /** - * Removes a listener which was previously added through {@link #addCapabilityListener(GoogleApiClient, CapabilityListener, String)}. - * The listener is only removed from listening for the capability provided and will continue to - * receive messages for any other capabilities it was previously registered for that have not - * also been removed. - */ - PendingResult removeCapabilityListener(GoogleApiClient client, CapabilityListener listener, String capability); - - /** - * Removes a listener which was previously added through {@link #addListener(GoogleApiClient, CapabilityListener, Uri, int)}. - * The listener is only removed from listening for the capability provided and will continue to - * receive messages for any other capabilities it was previously registered for that have not - * also been removed. - */ - PendingResult removeListener(GoogleApiClient client, CapabilityListener listener); - - /** - * Announces that a capability is no longer available on the local node. Note: this will not - * remove any capabilities announced in the Manifest for an app. - */ - PendingResult removeLocalCapability(GoogleApiClient client, String capability); - - /** - * Result returned from {@link #addLocalCapability(GoogleApiClient, String)} - */ - interface AddLocalCapabilityResult extends Result { - } - - @Retention(RetentionPolicy.SOURCE) - @interface CapabilityFilterType { - } - - /** - * Listener for changes in the reachable nodes providing a capability. - */ - interface CapabilityListener { - void onCapabilityChanged(CapabilityInfo capabilityInfo); - } - - /** - * Result returned from {@link #getAllCapabilities(GoogleApiClient, int)} - */ - interface GetAllCapabilitiesResult extends Result { - Map getAllCapabilities(); - } - - /** - * Result returned from {@link #getCapability(GoogleApiClient, String, int)} - */ - interface GetCapabilityResult extends Result { - CapabilityInfo getCapability(); - } - - @Retention(RetentionPolicy.SOURCE) - @interface NodeFilterType { - } - - /** - * Result returned from {@link #removeLocalCapability(GoogleApiClient, String)} - */ - interface RemoveLocalCapabilityResult extends Result { - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/Channel.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/Channel.java deleted file mode 100644 index d6d01288..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/Channel.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.net.Uri; -import android.os.Parcelable; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Releasable; -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * A channel created through {@link ChannelApi#openChannel(GoogleApiClient, String, String)}. - *

- * The implementation of this interface is parcelable and immutable, and implements reasonable {@link #equals(Object)} - * and {@link #hashCode()} methods, so can be used in collections. - */ -public interface Channel extends Parcelable { - - PendingResult addListener(GoogleApiClient client, ChannelApi.ChannelListener listener); - - PendingResult close(GoogleApiClient client, int errorCode); - - PendingResult close(GoogleApiClient client); - - PendingResult getInputStream(GoogleApiClient client); - - PendingResult getOutputStream(GoogleApiClient client); - - String getPath(); - - PendingResult receiveFile(GoogleApiClient client, Uri uri, boolean append); - - PendingResult removeListener(GoogleApiClient client, ChannelApi.ChannelListener listener); - - PendingResult sendFile(GoogleApiClient client, Uri uri); - - PendingResult sendFile(GoogleApiClient client, Uri uri, long startOffset, long length); - - interface GetInputStreamResult extends Releasable, Result { - /** - * Returns an input stream which can read data from the remote node. The stream should be - * closed when no longer needed. This method will only return {@code null} if this result's - * {@linkplain #getStatus() status} was not {@linkplain Status#isSuccess() success}. - *

- * The returned stream will throw {@link IOException} on read if any connection errors - * occur. This exception might be a {@link ChannelIOException}. - *

- * Since data for this stream comes over the network, reads may block for a long time. - *

- * Multiple calls to this method will return the same instance. - */ - InputStream getInputStream(); - } - - interface GetOutputStreamResult extends Releasable, Result { - /** - * Returns an output stream which can send data to a remote node. The stream should be - * closed when no longer needed. This method will only return {@code null} if this result's - * {@linkplain #getStatus() status} was not {@linkplain Status#isSuccess() success}. - *

- * The returned stream will throw {@link IOException} on read if any connection errors - * occur. This exception might be a {@link ChannelIOException}. - *

- * Since data for this stream comes over the network, reads may block for a long time. - *

- * Data written to this stream is buffered. If you wish to send the current data without - * waiting for the buffer to fill up, {@linkplain OutputStream#flush() flush} the stream. - *

- * Multiple calls to this method will return the same instance. - */ - OutputStream getOutputStream(); - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/ChannelApi.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/ChannelApi.java deleted file mode 100644 index fcd62b7c..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/ChannelApi.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.GoogleApiClient.Builder; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Client interface for Wearable Channel API. Allows apps on a wearable device to send and receive - * data from other wearable nodes. - *

- * Channels are bidirectional. Each side, both the initiator and the receiver may both read and - * write to the channel by using {@link Channel#getOutputStream(GoogleApiClient)} and {@link Channel#getInputStream(GoogleApiClient)}. - * Once a channel is established, the API for the initiator and receiver are identical. - *

- * Channels are only available when the wearable nodes are connected. When the remote node - * disconnects, all existing channels will be closed. Any listeners (added through {@link #addListener(GoogleApiClient, ChannelListener)} - * and any installed {@link WearableListenerService}) will be notified of the channel closing. - */ -public interface ChannelApi { - /** - * Channel action for use in listener filters. - * - * @see WearableListenerService - */ - String ACTION_CHANNEL_EVENT = "com.google.android.gms.wearable.CHANNEL_EVENT"; - - /** - * Registers a listener to be notified of channel events. Calls to this method should be - * balanced with calls to {@link #removeListener(GoogleApiClient, ChannelListener)} to avoid - * leaking resources. - *

- * Listener events will be called on the main thread, or the handler specified on {@code client} - * when it was built (using {@link Builder#setHandler(Handler)}). - *

- * Callers wishing to be notified of events in the background should use {@link WearableListenerService}. - * - * @param client a connected client - * @param listener a listener which will be notified of changes to any channel - */ - PendingResult addListener(GoogleApiClient client, ChannelListener listener); - - /** - * Opens a channel to exchange data with a remote node. - *

- * Channel which are no longer needed should be closed using {@link Channel#close(GoogleApiClient)}. - *

- * This call involves a network round trip, so may be long running. {@code client} must remain - * connected during that time, or the request will be cancelled (like any other Play Services - * API calls). - * - * @param client a connected client - * @param nodeId the node ID of a wearable node, as returned from {@link NodeApi#getConnectedNodes(GoogleApiClient)} - * @param path an app-specific identifier for the channel - */ - PendingResult openChannel(GoogleApiClient client, String nodeId, String path); - - /** - * Removes a listener which was previously added through {@link #addListener(GoogleApiClient, ChannelListener)}. - * - * @param client a connected client - * @param listener a listener which was added using {@link #addListener(GoogleApiClient, ChannelListener)} - */ - PendingResult removeListener(GoogleApiClient client, ChannelListener listener); - - /** - * A listener which will be notified on changes to channels. - */ - interface ChannelListener { - /** - * Value passed to {@link #onChannelClosed(Channel, int, int)}, {@link #onInputClosed(Channel, int, int)} - * and {@link #onOutputClosed(Channel, int, int)} when the closing is due to a remote node - * being disconnected. - */ - int CLOSE_REASON_DISCONNECTED = 1; - - /** - * Value passed to {@link #onChannelClosed(Channel, int, int)}, {@link #onInputClosed(Channel, int, int)} - * and {@link #onOutputClosed(Channel, int, int)} when the stream is closed due to the - * local node calling {@link Channel#close(GoogleApiClient)} or {@link Channel#close(GoogleApiClient, int)}. - */ - int CLOSE_REASON_LOCAL_CLOSE = 3; - - /** - * Value passed to {@link #onInputClosed(Channel, int, int)} or {@link #onOutputClosed(Channel, int, int)} - * (but not {@link #onChannelClosed(Channel, int, int)}), when the stream was closed under - * normal conditions, e.g the whole file was read, or the OutputStream on the remote node - * was closed normally. - */ - int CLOSE_REASON_NORMAL = 0; - - /** - * Value passed to {@link #onChannelClosed(Channel, int, int)}, {@link #onInputClosed(Channel, int, int)} - * and {@link #onOutputClosed(Channel, int, int)} when the stream is closed due to the - * remote node calling {@link Channel#close(GoogleApiClient)} or {@link Channel#close(GoogleApiClient, int)}. - */ - int CLOSE_REASON_REMOTE_CLOSE = 2; - - /** - * Called when a channel is closed. This can happen through an explicit call to {@link Channel#close(GoogleApiClient)} - * or {@link #close(GoogleApiClient, int)} on either side of the connection, or due to - * disconnecting from the remote node. - * - * @param closeReason the reason for the channel closing. One of {@link #CLOSE_REASON_DISCONNECTED}, - * {@link #CLOSE_REASON_REMOTE_CLOSE}, or {@link #CLOSE_REASON_LOCAL_CLOSE}. - * @param appSpecificErrorCode the error code specified on {@link Channel#close(GoogleApiClient, int)}, - * or 0 if closeReason is {@link #CLOSE_REASON_DISCONNECTED}. - */ - void onChannelClosed(Channel channel, int closeReason, int appSpecificErrorCode); - - /** - * Called when a new channel is opened by a remote node. - */ - void onChannelOpened(Channel channel); - - /** - * Called when the input side of a channel is closed. - * - * @param closeReason the reason for the channel closing. One of {@link #CLOSE_REASON_DISCONNECTED}, - * {@link #CLOSE_REASON_REMOTE_CLOSE}, {@link #CLOSE_REASON_LOCAL_CLOSE} - * or {@link #CLOSE_REASON_NORMAL}. - * @param appSpecificErrorCode the error code specified on {@link Channel#close(GoogleApiClient, int)}, - * or 0 if closeReason is {@link #CLOSE_REASON_DISCONNECTED} or - * {@link #CLOSE_REASON_NORMAL}. - */ - void onInputClosed(Channel channel, @CloseReason int closeReason, int appSpecificErrorCode); - - /** - * Called when the output side of a channel is closed. - * - * @param closeReason the reason for the channel closing. One of {@link #CLOSE_REASON_DISCONNECTED}, - * {@link #CLOSE_REASON_REMOTE_CLOSE}, {@link #CLOSE_REASON_LOCAL_CLOSE} - * or {@link #CLOSE_REASON_NORMAL}. - * @param appSpecificErrorCode the error code specified on {@link Channel#close(GoogleApiClient, int)}, - * or 0 if closeReason is {@link #CLOSE_REASON_DISCONNECTED} or - * {@link #CLOSE_REASON_NORMAL}. - */ - void onOutputClosed(Channel channel, @CloseReason int closeReason, int appSpecificErrorCode); - } - - /** - * An annotation for values passed to {@link ChannelListener#onChannelClosed(Channel, int, int)}, - * and other methods on the {@link ChannelListener} interface. Annotated method parameters will - * always take one of the following values: - *

    - *
  • {@link ChannelListener#CLOSE_REASON_DISCONNECTED}
  • - *
  • {@link ChannelListener#CLOSE_REASON_NORMAL}
  • - *
  • {@link ChannelListener#CLOSE_REASON_LOCAL_CLOSE}
  • - *
  • {@link ChannelListener#CLOSE_REASON_REMOTE_CLOSE}
  • - *
- */ - @Retention(RetentionPolicy.SOURCE) - @interface CloseReason { - } - - /** - * Result of {@link #openChannel(GoogleApiClient, String, String)}. - */ - interface OpenChannelResult extends Result { - /** - * Returns the newly created channel, or {@code null}, if the connection couldn't be opened. - */ - Channel getChannel(); - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/ChannelIOException.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/ChannelIOException.java deleted file mode 100644 index f6143cdd..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/ChannelIOException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.wearable.ChannelApi.ChannelListener; - -import java.io.IOException; - -/** - * A subclass of {@link IOException} which can be thrown from the streams returned by - * {@link Channel#getInputStream(GoogleApiClient)} and {@link Channel#getOutputStream(GoogleApiClient)}. - */ -public class ChannelIOException extends IOException { - - private int closeReason; - private int appSpecificErrorCode; - - public ChannelIOException(String message, int closeReason, int appSpecificErrorCode) { - super(message); - this.closeReason = closeReason; - this.appSpecificErrorCode = appSpecificErrorCode; - } - - /** - * Returns the app-specific error code passed to {@link Channel#close(GoogleApiClient, int)} if - * that's the reason for the stream closing, or {@code 0} otherwise. - */ - public int getAppSpecificErrorCode() { - return appSpecificErrorCode; - } - - /** - * Returns one of {@link ChannelListener#CLOSE_REASON_NORMAL}, {@link ChannelListener#CLOSE_REASON_DISCONNECTED}, - * {@link ChannelListener#CLOSE_REASON_REMOTE_CLOSE}, or {@link ChannelListener#CLOSE_REASON_LOCAL_CLOSE}, - * to indicate the reason for the stream closing. - */ - public int getCloseReason() { - return closeReason; - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataApi.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataApi.java deleted file mode 100644 index 4327b6c2..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataApi.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.net.Uri; -import android.os.ParcelFileDescriptor; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.common.data.Freezable; -import com.google.android.gms.wearable.internal.PutDataRequest; - -import org.microg.gms.common.PublicApi; - -import java.io.InputStream; - -/** - * Exposes an API for components to read or write data items and assets. - *

- * A {@link DataItem} is synchronized across all devices in an Android Wear network. It is possible - * to set data items while not connected to any nodes. Those data items will be synchronized when - * the nodes eventually come online. - *

- * Data items are private to the application that created them, and are only accessible by that - * application on other nodes. They should generally be small in size, relying on assets for the - * transfer of larger, more persistent data objects such as images. - *

- * Each data item is identified by a URI, accessible with {@link DataItem#getUri()}, that indicates - * the item's creator and path. Fully specified URIs follow the following format: - * {@code wear:///}, where is the node ID of the wearable node that - * created the data item, and is an application-defined path. This means that given a data - * item's URI, calling {@link Uri#getHost()} will return the creator's node ID. - *

- * In some of the methods below (such as {@link #getDataItems(GoogleApiClient, Uri)}), it is - * possible to omit the node ID from the URI, and only leave a path. In that case, the URI may - * refer to multiple data items, since multiple nodes may create data items with the same path. - * Partially specified data item URIs follow the following format: - * {@ocde wear:/} - * Note the single / after wear:. - */ -@PublicApi -public interface DataApi { - /** - * Registers a listener to receive data item changed and deleted events. This call should be - * balanced with a call to {@link #removeListener(GoogleApiClient, DataListener)}, to avoid - * leaking resources. - *

- * The listener will be notified of changes initiated by this node. - */ - PendingResult addListener(GoogleApiClient client, DataListener listener); - - /** - * Removes all specified data items from the Android Wear network. - *

- * If uri is fully specified, this method will delete at most one data item. If {@code uri} - * contains no host, multiple data items may be deleted, since different nodes may create data - * items with the same path. See {@link DataApi} for details of the URI format. - */ - PendingResult deleteDataItems(GoogleApiClient client, Uri uri); - - /** - * Retrieves a single {@link DataItem} from the Android Wear network. A fully qualified URI - * must be specified. The URI's host must be the ID of the node that created the item. - *

- * See {@link DataApi} for details of the URI format. - */ - PendingResult getDataItem(GoogleApiClient client, Uri uri); - - /** - * Retrieves all data items from the Android Wear network. - *

- * Callers must call {@link DataItemBuffer#release()} on the returned buffer when finished - * processing results. - */ - PendingResult getDataItems(GoogleApiClient client); - - /** - * Retrieves all data items matching the provided URI, from the Android Wear network. - *

- * The URI must contain a path. If {@code uri} is fully specified, at most one data item will - * be returned. If uri contains no host, multiple data items may be returned, since different - * nodes may create data items with the same path. See {@link DataApi} for details of the URI - * format. - *

- * Callers must call {@link DataItemBuffer#release()} on the returned buffer when finished - * processing results. - */ - PendingResult getDataItems(GoogleApiClient client, Uri uri); - - /** - * Retrieves a {@link ParcelFileDescriptor} pointing at the bytes of an asset. Only assets - * previously stored in a {@link DataItem} may be retrieved. - */ - PendingResult getFdForAsset(GoogleApiClient client, DataItemAsset asset); - - /** - * Retrieves a {@link ParcelFileDescriptor} pointing at the bytes of an asset. Only assets - * previously stored in a {@link DataItem} may be retrieved. - */ - PendingResult getFdForAsset(GoogleApiClient client, Asset asset); - - /** - * Adds a {@link DataItem} to the Android Wear network. The updated item is synchronized across - * all devices. - */ - PendingResult putDataItem(GoogleApiClient client, PutDataRequest request); - - /** - * Removes a data listener which was previously added through - * {@link #addListener(GoogleApiClient, DataListener)}. - */ - PendingResult removeListener(GoogleApiClient client, DataListener listener); - - interface DataItemResult extends Result { - /** - * @return data item, or {@code null} if the item does not exit. - */ - DataItem getDataItem(); - } - - interface DataListener { - /** - * Notification that a set of data items have been changed or deleted. The data buffer is - * released upon completion of this method. If a caller wishes to use the events outside - * this callback, they should be sure to {@link Freezable#freeze()} the DataEvent objects - * they wish to use. - */ - void onDataChanged(DataEventBuffer dataEvents); - } - - interface DeleteDataItemsResult extends Result { - /** - * @return the number of items deleted by - * {@link DataApi#deleteDataItems(GoogleApiClient, Uri)}. - */ - int getNumDeleted(); - } - - interface GetFdForAssetResult extends Result { - /** - * @return a file descriptor for the requested asset. - */ - ParcelFileDescriptor getFd(); - - /** - * @return an input stream wrapping the file descriptor. When this input stream is closed, the file descriptor is, as well. - */ - InputStream getInputStream(); - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataEvent.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataEvent.java deleted file mode 100644 index 51e86397..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.data.Freezable; - -import org.microg.gms.common.PublicApi; - -/** - * Data interface for data events. - */ -@PublicApi -public interface DataEvent extends Freezable { - - /** - * Indicates that the enclosing {@link DataEvent} was triggered by a data item being added or - * changed. - */ - int TYPE_CHANGED = 1; - - /** - * Indicates that the enclosing {@link DataEvent} was triggered by a data item being deleted. - */ - int TYPE_DELETED = 2; - - /** - * @return the data item modified in this event. An event of {@link #TYPE_DELETED} will only - * have its {@link DataItem#getUri} populated. - */ - DataItem getDataItem(); - - /** - * @return the type of event this is. One of {@link #TYPE_CHANGED}, {@link #TYPE_DELETED}. - */ - int getType(); -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataEventBuffer.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataEventBuffer.java deleted file mode 100644 index 1c6c98e0..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataEventBuffer.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.common.data.DataBuffer; -import com.google.android.gms.common.data.DataHolder; - -import org.microg.gms.common.PublicApi; - -/** - * Data structure holding references to a set of events. - */ -@PublicApi -public class DataEventBuffer extends DataBuffer implements Result { - private Status status; - - @PublicApi(exclude = true) - public DataEventBuffer(DataHolder dataHolder) { - super(dataHolder); - status = new Status(dataHolder.getStatusCode()); - } - - @Override - public DataEvent get(int position) { - return null; - } - - @Override - public Status getStatus() { - return null; - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataItemBuffer.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataItemBuffer.java deleted file mode 100644 index 703d7ae3..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataItemBuffer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.common.data.DataBuffer; -import com.google.android.gms.common.data.DataHolder; - -import org.microg.gms.common.PublicApi; - -@PublicApi -public class DataItemBuffer extends DataBuffer implements Result { - private Status status; - - @PublicApi(exclude = true) - public DataItemBuffer(DataHolder dataHolder) { - super(dataHolder); - status = new Status(dataHolder.getStatusCode()); - } - - @Override - public DataItem get(int position) { - return null; - } - - @Override - public Status getStatus() { - return null; - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataMap.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataMap.java deleted file mode 100644 index f46c4920..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataMap.java +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.os.Bundle; - -import org.microg.gms.common.PublicApi; -import org.microg.gms.wearable.databundle.DataBundleUtil; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import static org.microg.gms.wearable.databundle.DataBundleUtil.ASSET_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.BOOLEAN_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.BYTE_ARRAY_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.BYTE_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.DATAMAP_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.DOUBLE_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.FLOAT_ARRAY_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.FLOAT_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.INTEGER_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.LIST_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.LONG_ARRAY_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.LONG_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.STRING_ARRAY_TYPE_CODE; -import static org.microg.gms.wearable.databundle.DataBundleUtil.STRING_TYPE_CODE; - -/** - * A map of data supported by {@link PutDataMapRequest} and {@link DataMapItem}s. DataMap may - * convert to and from Bundles, but will drop any types not explicitly supported by DataMap in the - * conversion process. - */ -@PublicApi -public class DataMap { - public static String TAG = "GmsDataMap"; - - private Map data = new HashMap(); - private Map types = new HashMap(); - - public DataMap() { - - } - - /** - * @return an ArrayList of DataMaps from an ArrayList of Bundles. Any elements in the Bundles not supported by DataMap will be dropped. - */ - public static ArrayList arrayListFromBundleArrayList(ArrayList bundleArrayList) { - ArrayList res = new ArrayList(); - for (Bundle bundle : bundleArrayList) { - res.add(fromBundle(bundle)); - } - return res; - } - - /** - * Removes all elements from the mapping of this DataMap. - */ - public void clear() { - data.clear(); - } - - /** - * @return true if the given key is contained in the mapping of this DataMap. - */ - public boolean containsKey(String key) { - return data.containsKey(key); - } - - /** - * @return true if the given Object is a DataMap equivalent to this one. - */ - @Override - public boolean equals(Object o) { - return o instanceof DataMap && data.equals(((DataMap) o).data); - } - - public StoredType getType(String key) { - return types.get(key); - } - - @PublicApi(exclude = true) - public enum StoredType { - Asset(ASSET_TYPE_CODE), Boolean(BOOLEAN_TYPE_CODE), Byte(BYTE_TYPE_CODE), - ByteArray(BYTE_ARRAY_TYPE_CODE), DataMap(DATAMAP_TYPE_CODE), DataMapArrayList(DataMap), - Double(DOUBLE_TYPE_CODE), Float(FLOAT_TYPE_CODE), FloatArray(FLOAT_ARRAY_TYPE_CODE), - Integer(INTEGER_TYPE_CODE), IntegerArrayList(Integer), Long(LONG_TYPE_CODE), - LongArray(LONG_ARRAY_TYPE_CODE), String(STRING_TYPE_CODE), - StringArray(STRING_ARRAY_TYPE_CODE), StringArrayList(String); - - private int typeCode; - private StoredType listType; - - StoredType(int typeCode) { - this.typeCode = typeCode; - } - - StoredType(StoredType listType) { - this.typeCode = LIST_TYPE_CODE; - this.listType = listType; - } - - public int getTypeCode() { - return typeCode; - } - - public StoredType getListType() { - return listType; - } - } - - /** - * @return a DataMap from a Bundle. The input Bundle is expected to contain only elements - * supported by DataMap. Any elements in the Bundle not supported by DataMap will be dropped. - */ - public static DataMap fromBundle(Bundle bundle) { - DataMap res = new DataMap(); - if (bundle != null) { - for (String key : bundle.keySet()) { - Object val = bundle.get(key); - if (val instanceof Asset) { - res.putAsset(key, (Asset) val); - } else if (val instanceof Boolean) { - res.putBoolean(key, (Boolean) val); - } else if (val instanceof Byte) { - res.putByte(key, (Byte) val); - } else if (val instanceof byte[]) { - res.putByteArray(key, (byte[]) val); - } else if (val instanceof Bundle) { - res.putDataMap(key, DataMap.fromBundle((Bundle) val)); - } else if (val instanceof Double) { - res.putDouble(key, (Double) val); - } else if (val instanceof Float) { - res.putFloat(key, (Float) val); - } else if (val instanceof float[]) { - res.putFloatArray(key, (float[]) val); - } else if (val instanceof Integer) { - res.putInt(key, (Integer) val); - } else if (val instanceof Long) { - res.putLong(key, (Long) val); - } else if (val instanceof long[]) { - res.putLongArray(key, (long[]) val); - } else if (val instanceof String) { - res.putString(key, (String) val); - } else if (val instanceof String[]) { - res.putStringArray(key, (String[]) val); - } else if (val instanceof ArrayList) { - if (((ArrayList) val).isEmpty() || ((ArrayList) val).get(0) instanceof String) { - res.putStringArrayList(key, (ArrayList) val); - } else if (((ArrayList) val).get(0) instanceof Bundle) { - ArrayList dataMaps = new ArrayList(); - for (Bundle b : ((ArrayList) val)) { - dataMaps.add(DataMap.fromBundle(b)); - } - res.putDataMapArrayList(key, dataMaps); - } else if (((ArrayList) val).get(0) instanceof Integer) { - res.putIntegerArrayList(key, (ArrayList) val); - } - } - } - } - return res; - } - - /** - * @return a DataMap from a byte[]. - */ - public static DataMap fromByteArray(byte[] bytes) { - return DataBundleUtil.readDataMap(bytes, Collections.emptyList()); - } - - /** - * @return the entry with the given key as an object, or null - */ - public T get(String key) { - return (T) data.get(key); - } - - public Asset getAsset(String key) { - return types.get(key) == StoredType.Asset ? (Asset) data.get(key) : null; - } - - public boolean getBoolean(String key) { - return getBoolean(key, false); - } - - public boolean getBoolean(String key, boolean defaultValue) { - return types.get(key) == StoredType.Boolean ? (Boolean) data.get(key) : defaultValue; - } - - public byte getByte(String key) { - return getByte(key, (byte) 0); - } - - public byte getByte(String key, byte defaultValue) { - return types.get(key) == StoredType.Byte ? (Byte) data.get(key) : defaultValue; - } - - public byte[] getByteArray(String key) { - return types.get(key) == StoredType.ByteArray ? (byte[]) data.get(key) : null; - } - - public DataMap getDataMap(String key) { - return types.get(key) == StoredType.DataMap ? (DataMap) data.get(key) : null; - } - - public ArrayList getDataMapArrayList(String key) { - return types.get(key) == StoredType.DataMapArrayList ? (ArrayList) data.get(key) : null; - } - - public double getDouble(String key) { - return getDouble(key, 0.0); - } - - public double getDouble(String key, double defaultValue) { - return types.get(key) == StoredType.Double ? (Double) data.get(key) : defaultValue; - } - - public float getFloat(String key) { - return getFloat(key, 0.0f); - } - - public float getFloat(String key, float defaultValue) { - return types.get(key) == StoredType.Float ? (Float) data.get(key) : defaultValue; - } - - public float[] getFloatArray(String key) { - return types.get(key) == StoredType.FloatArray ? (float[]) data.get(key) : null; - } - - public int getInt(String key) { - return getInt(key, 0); - } - - public int getInt(String key, int defaultValue) { - return types.get(key) == StoredType.Integer ? (Integer) data.get(key) : defaultValue; - } - - public ArrayList getIntegerArrayList(String key) { - return types.get(key) == StoredType.IntegerArrayList ? (ArrayList) data.get(key) : null; - } - - public long getLong(String key) { - return getLong(key, 0L); - } - - public long getLong(String key, long defaultValue) { - return types.get(key) == StoredType.Long ? (Long) data.get(key) : defaultValue; - } - - public long[] getLongArray(String key) { - return types.get(key) == StoredType.LongArray ? (long[]) data.get(key) : null; - } - - public String getString(String key) { - return getString(key, null); - } - - public String getString(String key, String defaultValue) { - return types.get(key) == StoredType.String ? (String) data.get(key) : defaultValue; - } - - public String[] getStringArray(String key) { - return types.get(key) == StoredType.StringArray ? (String[]) data.get(key) : null; - } - - public ArrayList getStringArrayList(String key) { - return types.get(key) == StoredType.StringArrayList ? (ArrayList) data.get(key) : null; - } - - public int hashCode() { - return data.hashCode(); - } - - public boolean isEmpty() { - return data.isEmpty(); - } - - public Set keySet() { - return data.keySet(); - } - - public void putAll(DataMap dataMap) { - for (String key : dataMap.keySet()) { - data.put(key, dataMap.data.get(key)); - types.put(key, dataMap.types.get(key)); - } - } - - public void putAsset(String key, Asset value) { - data.put(key, value); - types.put(key, StoredType.Asset); - } - - public void putBoolean(String key, boolean value) { - data.put(key, value); - types.put(key, StoredType.Boolean); - } - - public void putByte(String key, byte value) { - data.put(key, value); - types.put(key, StoredType.Byte); - } - - public void putByteArray(String key, byte[] value) { - data.put(key, value); - types.put(key, StoredType.ByteArray); - } - - public void putDataMap(String key, DataMap value) { - data.put(key, value); - types.put(key, StoredType.DataMap); - } - - public void putDataMapArrayList(String key, ArrayList value) { - data.put(key, value); - types.put(key, StoredType.DataMapArrayList); - } - - public void putDouble(String key, double value) { - data.put(key, value); - types.put(key, StoredType.Double); - } - - public void putFloat(String key, float value) { - data.put(key, value); - types.put(key, StoredType.Float); - } - - public void putFloatArray(String key, float[] value) { - data.put(key, value); - types.put(key, StoredType.FloatArray); - } - - public void putInt(String key, int value) { - data.put(key, value); - types.put(key, StoredType.Integer); - } - - public void putIntegerArrayList(String key, ArrayList value) { - data.put(key, value); - types.put(key, StoredType.IntegerArrayList); - } - - public void putLong(String key, long value) { - data.put(key, value); - types.put(key, StoredType.Long); - } - - public void putLongArray(String key, long[] value) { - data.put(key, value); - types.put(key, StoredType.LongArray); - } - - public void putString(String key, String value) { - data.put(key, value); - types.put(key, StoredType.String); - } - - public void putStringArray(String key, String[] value) { - data.put(key, value); - types.put(key, StoredType.StringArray); - } - - public void putStringArrayList(String key, ArrayList value) { - data.put(key, value); - types.put(key, StoredType.StringArrayList); - } - - public Object remove(String key) { - types.remove(key); - return data.remove(key); - } - - public int size() { - return data.size(); - } - - public Bundle toBundle() { - Bundle bundle = new Bundle(); - for (String key : data.keySet()) { - switch (types.get(key)) { - case Asset: - bundle.putParcelable(key, (Asset) data.get(key)); - break; - case Boolean: - bundle.putBoolean(key, (Boolean) data.get(key)); - break; - case Byte: - bundle.putByte(key, (Byte) data.get(key)); - break; - case ByteArray: - bundle.putByteArray(key, (byte[]) data.get(key)); - break; - case DataMap: - bundle.putBundle(key, ((DataMap) data.get(key)).toBundle()); - break; - case DataMapArrayList: - ArrayList bundles = new ArrayList(); - for (DataMap dataMap : ((ArrayList) data.get(key))) { - bundles.add(dataMap.toBundle()); - } - bundle.putParcelableArrayList(key, bundles); - break; - case Double: - bundle.putDouble(key, (Double) data.get(key)); - break; - case Float: - bundle.putFloat(key, (Float) data.get(key)); - break; - case FloatArray: - bundle.putFloatArray(key, (float[]) data.get(key)); - break; - case Integer: - bundle.putInt(key, (Integer) data.get(key)); - break; - case IntegerArrayList: - bundle.putIntegerArrayList(key, (ArrayList) data.get(key)); - break; - case Long: - bundle.putLong(key, (Long) data.get(key)); - break; - case LongArray: - bundle.putLongArray(key, (long[]) data.get(key)); - break; - case String: - bundle.putString(key, (String) data.get(key)); - break; - case StringArray: - bundle.putStringArray(key, (String[]) data.get(key)); - break; - case StringArrayList: - bundle.putStringArrayList(key, (ArrayList) data.get(key)); - break; - } - } - return bundle; - } - - public byte[] toByteArray() { - return DataBundleUtil.createBytes(this); - } - - public String toString() { - return "DataMap{size=" + size() + "}"; - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataMapItem.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataMapItem.java deleted file mode 100644 index 670260d4..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/DataMapItem.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.net.Uri; - -import org.microg.gms.common.PublicApi; - -/** - * Creates a new dataItem-like object containing structured and serializable data. - */ -@PublicApi -public class DataMapItem { - /** - * Provides a {@link DataMapItem} wrapping a dataItem. - * - * @param dataItem the base for the wrapped {@link DataMapItem}. {@code dataItem} should not - * be modified after wrapping it. - */ - public static DataMapItem fromDataItem(DataItem dataItem) { - return null; - } - - public DataMap getDataMap() { - return null; - } - - public Uri getUri() { - return null; - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/MessageApi.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/MessageApi.java deleted file mode 100644 index 1e68ad1d..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/MessageApi.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; - -import org.microg.gms.common.PublicApi; - -@PublicApi -public interface MessageApi { - - /** - * A value returned by {@link SendMessageResult#getRequestId()} when - * {@link #sendMessage(GoogleApiClient, String, String, byte[])} fails. - */ - int UNKNOWN_REQUEST_ID = -1; - - /** - * Registers a listener to be notified of received messages. Calls to this method should - * balanced with {@link #removeListener(GoogleApiClient, MessageListener)} to avoid leaking - * resources. - *

- * Callers wishing to be notified of events in the background should use {@link WearableListenerService}. - */ - PendingResult addListener(GoogleApiClient client, MessageListener listener); - - /** - * Removes a message listener which was previously added through - * {@link #addListener(GoogleApiClient, MessageListener)}. - */ - PendingResult removeListener(GoogleApiClient client, MessageListener listener); - - /** - * Sends {@code byte[]} data to the specified node. - * - * @param nodeId identifier for a particular node on the Android Wear network. Valid targets - * may be obtained through {@link NodeApi#getConnectedNodes(GoogleApiClient)} - * or from the host in {@link DataItem#getUri()}. - * @param path identifier used to specify a particular endpoint at the receiving node - * @param data small array of information to pass to the target node. Generally not larger - * than 100k - */ - PendingResult sendMessage(GoogleApiClient client, String nodeId, - String path, byte[] data); - - /** - * Used with {@link MessageApi#addListener(GoogleApiClient, MessageListener)} to receive - * message events. - *

- * Callers wishing to be notified of events in the background should use - * {@link WearableListenerService}. - */ - interface MessageListener { - /** - * Notification that a message has been received. - */ - void onMessageReceived(MessageEvent messageEvent); - } - - /** - * Contains the request id assigned to the message. On failure, the id will be - * {@link MessageApi#UNKNOWN_REQUEST_ID} and the status will be unsuccessful. - */ - interface SendMessageResult extends Result { - /** - * @return an ID used to identify the sent message. If {@link #getStatus()} is not - * successful, this value will be {@link MessageApi#UNKNOWN_REQUEST_ID}. - */ - int getRequestId(); - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/NodeApi.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/NodeApi.java deleted file mode 100644 index 6c6a188f..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/NodeApi.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Result; -import com.google.android.gms.common.api.Status; - -import org.microg.gms.common.PublicApi; - -import java.util.List; - -/** - * Exposes an API for to learn about local or connected Nodes. - *

- * Node events are delivered to all applications on a device. - */ -@PublicApi -public interface NodeApi { - - /** - * Registers a listener to receive all node events. Calls to this method should balanced with - * {@link #removeListener(GoogleApiClient, NodeListener)}, to avoid leaking resources. - *

- * Callers wishing to be notified of node events in the background should use WearableListenerService. - */ - PendingResult addListener(GoogleApiClient client, NodeListener listener); - - /** - * Gets a list of nodes to which this device is currently connected. - *

- * The returned list will not include the {@link #getLocalNode(GoogleApiClient) local node}. - */ - PendingResult getConnectedNodes(GoogleApiClient client); - - /** - * Gets the {@link Node} that refers to this device. The information in the returned Node - * can be passed to other devices using the {@link MessageApi}, for example. - */ - PendingResult getLocalNode(GoogleApiClient client); - - /** - * Removes a listener which was previously added through - * {@link #addListener(GoogleApiClient, NodeListener)}. - */ - PendingResult removeListener(GoogleApiClient client, NodeListener listener); - - - /** - * Contains a list of connected nodes. - */ - interface GetConnectedNodesResult extends Result { - /** - * @return a list of connected nodes. This list doesn't include the local node. - */ - List getNodes(); - } - - /** - * Contains the name and id that represents this device. - */ - interface GetLocalNodeResult extends Result { - /** - * @return a {@link Node} object which represents this device. - */ - Node getNode(); - } - - /** - * Used with {@link NodeApi#addListener(GoogleApiClient, NodeListener)} to receive node events. - */ - interface NodeListener { - /** - * Notification that a peer has been connected. - */ - void onPeerConnected(Node peer); - - /** - * Notification that a peer has been disconnected. - */ - void onPeerDisconnected(Node peer); - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/PutDataMapRequest.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/PutDataMapRequest.java deleted file mode 100644 index d92167cc..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/PutDataMapRequest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.net.Uri; - -import com.google.android.gms.wearable.internal.PutDataRequest; - -import org.microg.gms.common.PublicApi; - -/** - * PutDataMapRequest is a DataMap-aware version of {@link PutDataRequest}. - */ -@PublicApi -public class PutDataMapRequest { - - private DataMapItem dataMapItem; - - private PutDataMapRequest(DataMapItem dataMapItem) { - this.dataMapItem = dataMapItem; - } - - /** - * Creates a {@link PutDataRequest} containing the data and assets in this - * {@link PutDataMapRequest}. - */ - public PutDataRequest asPutDataRequest() { - // TODO - return PutDataRequest.create((Uri) null); - } - - /** - * Creates a {@link PutDataMapRequest} with the provided, complete, path. - */ - public static PutDataMapRequest create(String path) { - // TODO - return new PutDataMapRequest(null); - } - - /** - * Creates a {@link PutDataMapRequest} from a {@link DataMapItem} using the provided source. - */ - public static PutDataMapRequest createFromDataMapItem(DataMapItem source) { - return new PutDataMapRequest(source); - } - - /** - * Creates a {@link PutDataMapRequest} with a randomly generated id prefixed with the provided - * path. - */ - public static PutDataMapRequest createWithAutoAppendedId(String pathPrefix) { - // TODO - return new PutDataMapRequest(null); - } - - /** - * @return the structured data associated with this data item. - */ - public DataMap getDataMap() { - return dataMapItem.getDataMap(); - } - - /** - * @return a {@link Uri} for the pending data item. If this is a modification of an existing - * data item, {@link Uri#getHost()} will return the id of the node that originally created it. - * Otherwise, a new data item will be created with the requesting device's node. - */ - public Uri getUri() { - return dataMapItem.getUri(); - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/Wearable.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/Wearable.java deleted file mode 100644 index 88899989..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/Wearable.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import com.google.android.gms.common.api.Api; -import com.google.android.gms.common.api.GoogleApiClient; - -import org.microg.gms.common.PublicApi; -import org.microg.gms.wearable.DataApiImpl; -import org.microg.gms.wearable.MessageApiImpl; -import org.microg.gms.wearable.NodeApiImpl; -import org.microg.gms.wearable.WearableApiBuilder; - -/** - * An API for the Android Wear platform. - */ -@PublicApi -public class Wearable { - /** - * Token to pass to {@link GoogleApiClient.Builder#addApi(Api)} to enable the Wearable features. - */ - public static final Api API = new Api(new WearableApiBuilder()); - - public static final DataApi DataApi = new DataApiImpl(); - public static final MessageApi MessageApi = new MessageApiImpl(); - public static final NodeApi NodeApi = new NodeApiImpl(); - - public static class WearableOptions implements Api.ApiOptions.Optional { - /** - * Special option for microG to allow implementation of a FOSS first party Android Wear app - */ - @PublicApi(exclude = true) - public boolean firstPartyMode = false; - - public static class Builder { - public WearableOptions build() { - return new WearableOptions(); - } - } - } -} diff --git a/play-services-wearable/src/main/java/com/google/android/gms/wearable/WearableListenerService.java b/play-services-wearable/src/main/java/com/google/android/gms/wearable/WearableListenerService.java deleted file mode 100644 index 8aa5b091..00000000 --- a/play-services-wearable/src/main/java/com/google/android/gms/wearable/WearableListenerService.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.gms.wearable; - -import android.app.Service; -import android.content.Intent; -import android.os.Binder; -import android.os.Handler; -import android.os.HandlerThread; -import android.os.IBinder; -import android.os.Looper; -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.common.data.DataHolder; -import com.google.android.gms.wearable.internal.AmsEntityUpdateParcelable; -import com.google.android.gms.wearable.internal.AncsNotificationParcelable; -import com.google.android.gms.wearable.internal.CapabilityInfoParcelable; -import com.google.android.gms.wearable.internal.ChannelEventParcelable; -import com.google.android.gms.wearable.internal.IWearableListener; -import com.google.android.gms.wearable.internal.MessageEventParcelable; -import com.google.android.gms.wearable.internal.NodeParcelable; - -import org.microg.gms.common.PublicApi; -import org.microg.gms.wearable.ChannelImpl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME; - -@PublicApi -public abstract class WearableListenerService extends Service implements CapabilityApi.CapabilityListener, ChannelApi.ChannelListener, DataApi.DataListener, MessageApi.MessageListener, NodeApi.NodeListener { - private static final String BIND_LISTENER_INTENT_ACTION = "com.google.android.gms.wearable.BIND_LISTENER"; - private static final String TAG = "GmsWearListenerSvc"; - - private HandlerThread handlerThread; - private IWearableListener listener; - private ServiceHandler serviceHandler; - private Object lock = new Object(); - private boolean disconnected = false; - - @Override - public IBinder onBind(Intent intent) { - if (BIND_LISTENER_INTENT_ACTION.equals(intent.getAction())) { - return listener.asBinder(); - } - return null; - } - - @Override - public void onCapabilityChanged(CapabilityInfo capabilityInfo) { - } - - public void onConnectedNodes(List connectedNodes) { - } - - @Override - public void onChannelClosed(Channel channel, int closeReason, int appSpecificErrorCode) { - } - - @Override - public void onChannelOpened(Channel channel) { - } - - @Override - public void onCreate() { - super.onCreate(); - handlerThread = new HandlerThread("WearableListenerService"); - handlerThread.start(); - serviceHandler = new ServiceHandler(handlerThread.getLooper()); - listener = new Listener(); - } - - @Override - public void onDataChanged(DataEventBuffer dataEvents) { - } - - @Override - public void onDestroy() { - synchronized (lock) { - if (serviceHandler == null) { - throw new IllegalStateException("serviceHandler not set, did you override onCreate() but forget to call super.onCreate()?"); - } - serviceHandler.getLooper().quit(); - } - super.onDestroy(); - } - - @PublicApi(exclude = true) - public void onEntityUpdate(AmsEntityUpdate entityUpdate) { - } - - @Override - public void onInputClosed(Channel channel, @ChannelApi.CloseReason int closeReason, int appSpecificErrorCode) { - } - - @Override - public void onMessageReceived(MessageEvent messageEvent) { - } - - @PublicApi(exclude = true) - public void onNotificationReceived(AncsNotification notification) { - } - - @Override - public void onOutputClosed(Channel channel, @ChannelApi.CloseReason int closeReason, int appSpecificErrorCode) { - } - - @Override - public void onPeerConnected(Node peer) { - } - - @Override - public void onPeerDisconnected(Node peer) { - } - - private class Listener extends IWearableListener.Stub { - private int knownGoodUid = -1; - - private boolean post(Runnable runnable) { - int callingUid = Binder.getCallingUid(); - if (callingUid != knownGoodUid) { - // TODO: Verify Gms is calling - String[] packagesForUid = getPackageManager().getPackagesForUid(callingUid); - if (packagesForUid != null) { - if (Arrays.asList(packagesForUid).contains(GMS_PACKAGE_NAME)) { - knownGoodUid = callingUid; - } else { - throw new SecurityException("Caller is not Services Core"); - } - } - } - synchronized (lock) { - if (disconnected) { - return false; - } - serviceHandler.post(runnable); - return true; - } - } - - @Override - public void onDataChanged(final DataHolder data) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onDataChanged(new DataEventBuffer(data)); - } - }); - } - - @Override - public void onMessageReceived(final MessageEventParcelable messageEvent) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onMessageReceived(messageEvent); - } - }); - } - - @Override - public void onPeerConnected(final NodeParcelable node) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onPeerConnected(node); - } - }); - } - - @Override - public void onPeerDisconnected(final NodeParcelable node) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onPeerDisconnected(node); - } - }); - } - - @Override - public void onConnectedNodes(final List nodes) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onConnectedNodes(new ArrayList(nodes)); - } - }); - } - - @Override - public void onConnectedCapabilityChanged(final CapabilityInfoParcelable capabilityInfo) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onCapabilityChanged(capabilityInfo); - } - }); - } - - @Override - public void onNotificationReceived(final AncsNotificationParcelable notification) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onNotificationReceived(notification); - } - }); - } - - @Override - public void onEntityUpdate(final AmsEntityUpdateParcelable update) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - WearableListenerService.this.onEntityUpdate(update); - } - }); - } - - @Override - public void onChannelEvent(final ChannelEventParcelable channelEvent) throws RemoteException { - post(new Runnable() { - @Override - public void run() { - switch (channelEvent.eventType) { - case 1: - WearableListenerService.this.onChannelOpened(new ChannelImpl(channelEvent.channel)); - break; - case 2: - WearableListenerService.this.onChannelClosed(new ChannelImpl(channelEvent.channel), channelEvent.closeReason, channelEvent.appSpecificErrorCode); - break; - case 3: - WearableListenerService.this.onInputClosed(new ChannelImpl(channelEvent.channel), channelEvent.closeReason, channelEvent.appSpecificErrorCode); - break; - case 4: - WearableListenerService.this.onOutputClosed(new ChannelImpl(channelEvent.channel), channelEvent.closeReason, channelEvent.appSpecificErrorCode); - break; - default: - Log.w(TAG, "Unknown ChannelEvent.eventType"); - } - } - }); - } - } - - private class ServiceHandler extends Handler { - public ServiceHandler(Looper looper) { - super(looper); - } - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/BaseWearableCallbacks.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/BaseWearableCallbacks.java deleted file mode 100644 index 14778527..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/BaseWearableCallbacks.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.os.RemoteException; -import android.util.Log; - -import com.google.android.gms.common.api.Status; -import com.google.android.gms.common.data.DataHolder; -import com.google.android.gms.wearable.internal.AddLocalCapabilityResponse; -import com.google.android.gms.wearable.internal.ChannelReceiveFileResponse; -import com.google.android.gms.wearable.internal.ChannelSendFileResponse; -import com.google.android.gms.wearable.internal.CloseChannelResponse; -import com.google.android.gms.wearable.internal.DeleteDataItemsResponse; -import com.google.android.gms.wearable.internal.GetAllCapabilitiesResponse; -import com.google.android.gms.wearable.internal.GetCapabilityResponse; -import com.google.android.gms.wearable.internal.GetChannelInputStreamResponse; -import com.google.android.gms.wearable.internal.GetChannelOutputStreamResponse; -import com.google.android.gms.wearable.internal.GetCloudSyncOptInOutDoneResponse; -import com.google.android.gms.wearable.internal.GetCloudSyncOptInStatusResponse; -import com.google.android.gms.wearable.internal.GetCloudSyncSettingResponse; -import com.google.android.gms.wearable.internal.GetConfigResponse; -import com.google.android.gms.wearable.internal.GetConfigsResponse; -import com.google.android.gms.wearable.internal.GetConnectedNodesResponse; -import com.google.android.gms.wearable.internal.GetDataItemResponse; -import com.google.android.gms.wearable.internal.GetFdForAssetResponse; -import com.google.android.gms.wearable.internal.GetLocalNodeResponse; -import com.google.android.gms.wearable.internal.IWearableCallbacks; -import com.google.android.gms.wearable.internal.OpenChannelResponse; -import com.google.android.gms.wearable.internal.PutDataResponse; -import com.google.android.gms.wearable.internal.RemoveLocalCapabilityResponse; -import com.google.android.gms.wearable.internal.SendMessageResponse; -import com.google.android.gms.wearable.internal.StorageInfoResponse; - -public class BaseWearableCallbacks extends IWearableCallbacks.Stub { - private static final String TAG = "GmsWearBaseCallback"; - - @Override - public void onGetConfigResponse(GetConfigResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetConfigResponse"); - - } - - @Override - public void onPutDataResponse(PutDataResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onPutDataResponse"); - - } - - @Override - public void onGetDataItemResponse(GetDataItemResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetDataItemResponse"); - - } - - @Override - public void onDataItemChanged(DataHolder dataHolder) throws RemoteException { - Log.d(TAG, "unimplemented Method: onDataItemChanged"); - - } - - @Override - public void onDeleteDataItemsResponse(DeleteDataItemsResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onDeleteDataItemsResponse"); - - } - - @Override - public void onSendMessageResponse(SendMessageResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onSendMessageResponse"); - - } - - @Override - public void onGetFdForAssetResponse(GetFdForAssetResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetFdForAssetResponse"); - - } - - @Override - public void onGetLocalNodeResponse(GetLocalNodeResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetLocalNodeResponse"); - - } - - @Override - public void onGetConnectedNodesResponse(GetConnectedNodesResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetConnectedNodesResponse"); - - } - - @Override - public void onOpenChannelResponse(OpenChannelResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onOpenChannelResponse"); - - } - - @Override - public void onCloseChannelResponse(CloseChannelResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onCloseChannelResponse"); - - } - - @Override - public void onGetChannelInputStreamResponse(GetChannelInputStreamResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetChannelInputStreamResponse"); - - } - - @Override - public void onGetChannelOutputStreamResponse(GetChannelOutputStreamResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetChannelOutputStreamResponse"); - - } - - @Override - public void onChannelReceiveFileResponse(ChannelReceiveFileResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onChannelReceiveFileResponse"); - - } - - @Override - public void onChannelSendFileResponse(ChannelSendFileResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onChannelSendFileResponse"); - - } - - @Override - public void onStatus(Status status) throws RemoteException { - Log.d(TAG, "unimplemented Method: onStatus"); - - } - - @Override - public void onStorageInfoResponse(StorageInfoResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onStorageInfoResponse"); - - } - - @Override - public void onGetCapabilityResponse(GetCapabilityResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetCapabilityResponse"); - - } - - @Override - public void onGetAllCapabilitiesResponse(GetAllCapabilitiesResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetAllCapabilitiesResponse"); - - } - - @Override - public void onAddLocalCapabilityResponse(AddLocalCapabilityResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onAddLocalCapabilityResponse"); - - } - - @Override - public void onRemoveLocalCapabilityResponse(RemoveLocalCapabilityResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onRemoveLocalCapabilityResponse"); - - } - - @Override - public void onGetConfigsResponse(GetConfigsResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetConfigsResponse"); - - } - - @Override - public void onGetCloudSyncOptInOutDoneResponse(GetCloudSyncOptInOutDoneResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetCloudSyncOptInOutDoneResponse"); - - } - - @Override - public void onGetCloudSyncSettingResponse(GetCloudSyncSettingResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetCloudSyncSettingResponse"); - - } - - @Override - public void onGetCloudSyncOptInStatusResponse(GetCloudSyncOptInStatusResponse response) throws RemoteException { - Log.d(TAG, "unimplemented Method: onGetCloudSyncOptInStatusResponse"); - - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/ChannelImpl.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/ChannelImpl.java deleted file mode 100644 index ddf4fff5..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/ChannelImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.net.Uri; -import android.util.Log; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.wearable.Channel; -import com.google.android.gms.wearable.ChannelApi; -import com.google.android.gms.wearable.internal.ChannelParcelable; - -public class ChannelImpl extends ChannelParcelable implements Channel { - private static final String TAG = "GmsWearChannelImpl"; - - public ChannelImpl(String token, String nodeId, String path) { - super(token, nodeId, path); - } - - public ChannelImpl(ChannelParcelable wrapped) { - this(wrapped.token, wrapped.nodeId, wrapped.path); - } - - - @Override - public PendingResult addListener(GoogleApiClient client, ChannelApi.ChannelListener listener) { - Log.d(TAG, "unimplemented Method: addListener"); - return null; - } - - @Override - public PendingResult close(GoogleApiClient client, int errorCode) { - Log.d(TAG, "unimplemented Method: close"); - return null; - } - - @Override - public PendingResult close(GoogleApiClient client) { - Log.d(TAG, "unimplemented Method: close"); - return null; - } - - @Override - public PendingResult getInputStream(GoogleApiClient client) { - Log.d(TAG, "unimplemented Method: getInputStream"); - return null; - } - - @Override - public PendingResult getOutputStream(GoogleApiClient client) { - Log.d(TAG, "unimplemented Method: getOutputStream"); - return null; - } - - public String getNodeId() { - return nodeId; - } - - @Override - public String getPath() { - return path; - } - - public String getToken() { - return token; - } - - @Override - public PendingResult receiveFile(GoogleApiClient client, Uri uri, boolean append) { - Log.d(TAG, "unimplemented Method: receiveFile"); - return null; - } - - @Override - public PendingResult removeListener(GoogleApiClient client, ChannelApi.ChannelListener listener) { - Log.d(TAG, "unimplemented Method: removeListener"); - return null; - } - - @Override - public PendingResult sendFile(GoogleApiClient client, Uri uri) { - Log.d(TAG, "unimplemented Method: sendFile"); - return null; - } - - @Override - public PendingResult sendFile(GoogleApiClient client, Uri uri, long startOffset, long length) { - Log.d(TAG, "unimplemented Method: sendFile"); - return null; - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/DataApiImpl.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/DataApiImpl.java deleted file mode 100644 index 25b9c835..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/DataApiImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.net.Uri; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.DataApi; -import com.google.android.gms.wearable.DataItemAsset; -import com.google.android.gms.wearable.DataItemBuffer; -import com.google.android.gms.wearable.internal.PutDataRequest; - -public class DataApiImpl implements DataApi { - @Override - public PendingResult addListener(GoogleApiClient client, DataListener listener) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult deleteDataItems(GoogleApiClient client, Uri uri) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult getDataItem(GoogleApiClient client, Uri uri) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult getDataItems(GoogleApiClient client) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult getDataItems(GoogleApiClient client, Uri uri) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult getFdForAsset(GoogleApiClient client, DataItemAsset asset) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult getFdForAsset(GoogleApiClient client, Asset asset) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult putDataItem(GoogleApiClient client, PutDataRequest request) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult removeListener(GoogleApiClient client, DataListener listener) { - throw new UnsupportedOperationException(); - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/MessageApiImpl.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/MessageApiImpl.java deleted file mode 100644 index 7f9d5fc1..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/MessageApiImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.os.RemoteException; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.wearable.MessageApi; -import com.google.android.gms.wearable.Wearable; -import com.google.android.gms.wearable.internal.SendMessageResponse; - -import org.microg.gms.common.GmsConnector; - -public class MessageApiImpl implements MessageApi { - @Override - public PendingResult addListener(GoogleApiClient client, MessageListener listener) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult removeListener(GoogleApiClient client, MessageListener listener) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult sendMessage(GoogleApiClient client, final String nodeId, final String path, final byte[] data) { - return GmsConnector.call(client, Wearable.API, new GmsConnector.Callback() { - @Override - public void onClientAvailable(WearableClientImpl client, final ResultProvider resultProvider) throws RemoteException { - client.getServiceInterface().sendMessage(new BaseWearableCallbacks() { - @Override - public void onSendMessageResponse(SendMessageResponse response) throws RemoteException { - resultProvider.onResultAvailable(new SendMessageResultImpl(response)); - } - }, nodeId, path, data); - } - }); - } - - public static class SendMessageResultImpl implements SendMessageResult { - private SendMessageResponse response; - - public SendMessageResultImpl(SendMessageResponse response) { - this.response = response; - } - - @Override - public int getRequestId() { - return response.requestId; - } - - @Override - public Status getStatus() { - return new Status(response.statusCode); - } - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/NodeApiImpl.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/NodeApiImpl.java deleted file mode 100644 index 197b6e81..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/NodeApiImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.common.api.PendingResult; -import com.google.android.gms.common.api.Status; -import com.google.android.gms.wearable.NodeApi; - -public class NodeApiImpl implements NodeApi { - @Override - public PendingResult addListener(GoogleApiClient client, NodeListener listener) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult getConnectedNodes(GoogleApiClient client) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult getLocalNode(GoogleApiClient client) { - throw new UnsupportedOperationException(); - } - - @Override - public PendingResult removeListener(GoogleApiClient client, NodeListener listener) { - throw new UnsupportedOperationException(); - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/WearableApiBuilder.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/WearableApiBuilder.java deleted file mode 100644 index 3c20481b..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/WearableApiBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.Context; -import android.os.Looper; - -import com.google.android.gms.common.api.AccountInfo; -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.wearable.Wearable; - -import org.microg.gms.common.api.ApiBuilder; -import org.microg.gms.common.api.ApiConnection; - -public class WearableApiBuilder implements ApiBuilder { - private static final String TAG = "GmsWearableApi"; - - @Override - public ApiConnection build(Context context, Looper looper, Wearable.WearableOptions options, - AccountInfo accountInfo, GoogleApiClient.ConnectionCallbacks callbacks, - GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { - return new WearableClientImpl(context, options, callbacks, connectionFailedListener); - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/WearableClientImpl.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/WearableClientImpl.java deleted file mode 100644 index 5a667f58..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/WearableClientImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable; - -import android.content.Context; -import android.os.IBinder; -import android.util.Log; - -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.wearable.Wearable; -import com.google.android.gms.wearable.internal.IWearableService; - -import org.microg.gms.common.GmsClient; -import org.microg.gms.common.GmsService; -import org.microg.gms.common.api.GoogleApiClientImpl; - -public class WearableClientImpl extends GmsClient { - private static final String TAG = "GmsWearClient"; - - public WearableClientImpl(Context context, Wearable.WearableOptions options, GoogleApiClient.ConnectionCallbacks callbacks, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { - super(context, callbacks, connectionFailedListener, GmsService.WEARABLE.ACTION); - serviceId = GmsService.WEARABLE.SERVICE_ID; - if (options != null && options.firstPartyMode) - extras.putBoolean("firstPartyMode", true); - Log.d(TAG, ""); - } - - @Override - protected IWearableService interfaceFromBinder(IBinder binder) { - return IWearableService.Stub.asInterface(binder); - } - - public static WearableClientImpl get(GoogleApiClient apiClient) { - if (apiClient instanceof GoogleApiClientImpl) { - return (WearableClientImpl) ((GoogleApiClientImpl) apiClient).getApiConnection(Wearable.API); - } - return null; - } -} diff --git a/play-services-wearable/src/main/java/org/microg/gms/wearable/databundle/DataBundleUtil.java b/play-services-wearable/src/main/java/org/microg/gms/wearable/databundle/DataBundleUtil.java deleted file mode 100644 index 10975f9d..00000000 --- a/play-services-wearable/src/main/java/org/microg/gms/wearable/databundle/DataBundleUtil.java +++ /dev/null @@ -1,658 +0,0 @@ -/* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.gms.wearable.databundle; - -import android.util.SparseArray; - -import com.google.android.gms.wearable.Asset; -import com.google.android.gms.wearable.DataMap; -import com.squareup.wire.Wire; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import okio.ByteString; - -public class DataBundleUtil { - - public static DataMap readDataMap(byte[] bytes, List assets) { - try { - return readDataMap(new Wire().parseFrom(bytes, DataBundle.class), assets); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static DataMap readDataMap(DataBundle dataBundle, List assets) { - return readDataMap(dataBundle.entries, assets); - } - - public static DataMap readDataMap(List entries, List assets) { - DataMap dataMap = new DataMap(); - for (DataBundleEntry entry : entries) { - readAndStore(dataMap, entry.key, entry.typedValue, assets); - } - return dataMap; - } - - public static byte[] createBytes(DataMap dataMap) { - AssetAnnotatedDataBundle dataBundle = createDataBundle(dataMap); - if (!dataBundle.getAssets().isEmpty()) { - throw new UnsupportedOperationException(); - } - return dataBundle.getData(); - } - - public static AssetAnnotatedDataBundle createDataBundle(DataMap dataMap) { - AssetAnnotatedDataBundle dataBundle = new AssetAnnotatedDataBundle(); - dataBundle.assets = new ArrayList(); - dataBundle.dataBundle = new DataBundle(createEntryList(dataMap, dataBundle.assets)); - return dataBundle; - } - - private static List createEntryList(DataMap dataMap, List assets) { - List entries = new ArrayList(); - for (String key : dataMap.keySet()) { - entries.add(getTypeHelper(dataMap.getType(key)).loadAndCreateEntry(dataMap, key, assets)); - } - return entries; - } - - private static void readAndStore(DataMap dataMap, String key, DataBundleTypedValue value, List assets) { - if (value.type == null) return; - getTypeHelper(value.type).readAndStore(dataMap, key, value, assets); - } - - - private static SparseArray typeHelperByCode; - - private static void rememberTypeReader(TypeHelper typeHelper) { - typeHelperByCode.put(typeHelper.type, typeHelper); - } - - static TypeHelper getTypeHelper(int type) { - if (typeHelperByCode.get(type) != null) { - return typeHelperByCode.get(type); - } else { - throw new IllegalArgumentException(); - } - } - - static TypeHelper getTypeHelper(DataMap.StoredType type) { - return getTypeHelper(type.getTypeCode()); - } - - static TypeHelper getListInnerTypeHelper(DataMap.StoredType type) { - return getTypeHelper(type.getListType()); - } - - public static final int BYTE_ARRAY_TYPE_CODE = 1; - static TypeHelper BYTEARRAY = new TypeHelper(BYTE_ARRAY_TYPE_CODE) { - @Override - byte[] read(DataBundleValue value, List assets) { - return value.byteArray.toByteArray(); - } - - @Override - DataBundleValue create(byte[] value, List assets) { - return new DataBundleValue.Builder().byteArray(ByteString.of(value)).build(); - } - - @Override - void store(DataMap dataMap, String key, byte[] value) { - dataMap.putByteArray(key, value); - } - - @Override - byte[] load(DataMap dataMap, String key) { - return dataMap.getByteArray(key); - } - }; - - public static final int STRING_TYPE_CODE = 2; - static TypeHelper STRING = new TypeHelper(STRING_TYPE_CODE) { - @Override - String read(DataBundleValue value, List assets) { - return value.stringVal; - } - - @Override - DataBundleValue create(String value, List assets) { - return new DataBundleValue.Builder().stringVal(value).build(); - } - - @Override - void store(DataMap dataMap, String key, String value) { - if (value != null) dataMap.putString(key, value); - } - - @Override - void storeList(DataMap dataMap, String key, ArrayList valueList) { - dataMap.putStringArrayList(key, valueList); - } - - @Override - String load(DataMap dataMap, String key) { - return dataMap.getString(key); - } - - @Override - AnnotatedArrayList loadList(DataMap dataMap, String key) { - AnnotatedArrayList list = new AnnotatedArrayList(this); - list.addAll(dataMap.getStringArrayList(key)); - return list; - } - }; - - public static final int DOUBLE_TYPE_CODE = 3; - static TypeHelper DOUBLE = new TypeHelper(DOUBLE_TYPE_CODE) { - @Override - Double read(DataBundleValue value, List assets) { - return value.doubleVal; - } - - @Override - DataBundleValue create(Double value, List assets) { - return new DataBundleValue.Builder().doubleVal(value).build(); - } - - @Override - void store(DataMap dataMap, String key, Double value) { - if (value != null) dataMap.putDouble(key, value); - } - - @Override - Double load(DataMap dataMap, String key) { - return dataMap.getDouble(key); - } - }; - - public static final int FLOAT_TYPE_CODE = 4; - static TypeHelper FLOAT = new TypeHelper(FLOAT_TYPE_CODE) { - @Override - Float read(DataBundleValue value, List assets) { - return value.floatVal; - } - - @Override - DataBundleValue create(Float value, List assets) { - return new DataBundleValue.Builder().floatVal(value).build(); - } - - @Override - void store(DataMap dataMap, String key, Float value) { - if (value != null) dataMap.putFloat(key, value); - } - - @Override - Float load(DataMap dataMap, String key) { - return dataMap.getFloat(key); - } - }; - - public static final int LONG_TYPE_CODE = 5; - static TypeHelper LONG = new TypeHelper(LONG_TYPE_CODE) { - @Override - Long read(DataBundleValue value, List assets) { - return value.longVal; - } - - @Override - DataBundleValue create(Long value, List assets) { - return new DataBundleValue.Builder().longVal(value).build(); - } - - @Override - void store(DataMap dataMap, String key, Long value) { - if (value != null) dataMap.putLong(key, value); - } - - @Override - Long load(DataMap dataMap, String key) { - return dataMap.getLong(key); - } - }; - - public static final int INTEGER_TYPE_CODE = 6; - static TypeHelper INTEGER = new TypeHelper(INTEGER_TYPE_CODE) { - @Override - Integer read(DataBundleValue value, List assets) { - return value.intVal; - } - - @Override - DataBundleValue create(Integer value, List assets) { - return new DataBundleValue.Builder().intVal(value).build(); - } - - @Override - void store(DataMap dataMap, String key, Integer value) { - if (value != null) dataMap.putInt(key, value); - } - - @Override - void storeList(DataMap dataMap, String key, ArrayList valueList) { - dataMap.putIntegerArrayList(key, valueList); - } - - @Override - Integer load(DataMap dataMap, String key) { - return dataMap.getInt(key); - } - - @Override - AnnotatedArrayList loadList(DataMap dataMap, String key) { - AnnotatedArrayList list = new AnnotatedArrayList(this); - list.addAll(dataMap.getIntegerArrayList(key)); - return list; - } - }; - - public static final int BYTE_TYPE_CODE = 7; - static TypeHelper BYTE = new TypeHelper(BYTE_TYPE_CODE) { - @Override - Byte read(DataBundleValue value, List assets) { - return (byte) (int) value.byteVal; - } - - @Override - DataBundleValue create(Byte value, List assets) { - return new DataBundleValue.Builder().byteVal((int) (byte) value).build(); - } - - @Override - void store(DataMap dataMap, String key, Byte value) { - if (value != null) dataMap.putByte(key, value); - } - - @Override - Byte load(DataMap dataMap, String key) { - return dataMap.getByte(key); - } - }; - - public static final int BOOLEAN_TYPE_CODE = 8; - static TypeHelper BOOLEAN = new TypeHelper(BOOLEAN_TYPE_CODE) { - @Override - Boolean read(DataBundleValue value, List assets) { - return value.booleanVal; - } - - @Override - DataBundleValue create(Boolean value, List assets) { - return new DataBundleValue.Builder().booleanVal(value).build(); - } - - @Override - void store(DataMap dataMap, String key, Boolean value) { - if (value != null) dataMap.putBoolean(key, value); - } - - @Override - Boolean load(DataMap dataMap, String key) { - return dataMap.getBoolean(key); - } - }; - - public static final int DATAMAP_TYPE_CODE = 9; - static TypeHelper DATAMAP = new TypeHelper(DATAMAP_TYPE_CODE) { - @Override - DataMap read(DataBundleValue value, List assets) { - return readDataMap(value.map, assets); - } - - @Override - DataBundleValue create(DataMap value, List assets) { - return new DataBundleValue.Builder().map(createEntryList(value, assets)).build(); - } - - @Override - void store(DataMap dataMap, String key, DataMap value) { - dataMap.putDataMap(key, value); - } - - @Override - void storeList(DataMap dataMap, String key, ArrayList valueList) { - dataMap.putDataMapArrayList(key, valueList); - } - - @Override - DataMap load(DataMap dataMap, String key) { - return dataMap.getDataMap(key); - } - - @Override - AnnotatedArrayList loadList(DataMap dataMap, String key) { - AnnotatedArrayList list = new AnnotatedArrayList(this); - list.addAll(dataMap.getDataMapArrayList(key)); - return list; - } - }; - - public static final int LIST_TYPE_CODE = 10; - static TypeHelper> ARRAYLIST = new TypeHelper>(LIST_TYPE_CODE) { - @Override - AnnotatedArrayList read(DataBundleValue value, List assets) { - TypeHelper innerTypeHelper = NULL; - for (DataBundleTypedValue typedValue : value.list) { - if (innerTypeHelper == NULL) { - innerTypeHelper = getTypeHelper(typedValue.type); - } else if (typedValue.type != innerTypeHelper.type && typedValue.type != NULL.type) { - throw new IllegalArgumentException("List has elements of different types: " + innerTypeHelper.type + " and " + typedValue.type); - } - } - return innerTypeHelper.readList(value.list, assets); - } - - @Override - DataBundleValue create(AnnotatedArrayList value, List assets) { - return new DataBundleValue.Builder().list(value.createList(assets)).build(); - } - - @Override - void store(DataMap dataMap, String key, AnnotatedArrayList value) { - value.store(dataMap, key); - } - - @Override - AnnotatedArrayList load(DataMap dataMap, String key) { - return getListInnerTypeHelper(dataMap.getType(key)).loadList(dataMap, key); - } - }; - - public static final int STRING_ARRAY_TYPE_CODE = 11; - static TypeHelper STRINGARRAY = new TypeHelper(STRING_ARRAY_TYPE_CODE) { - @Override - String[] read(DataBundleValue value, List assets) { - return value.stringArray.toArray(new String[value.stringArray.size()]); - } - - @Override - DataBundleValue create(String[] value, List assets) { - return new DataBundleValue.Builder().stringArray(Arrays.asList(value)).build(); - } - - @Override - void store(DataMap dataMap, String key, String[] value) { - dataMap.putStringArray(key, value); - } - - @Override - String[] load(DataMap dataMap, String key) { - return dataMap.getStringArray(key); - } - }; - - public static final int LONG_ARRAY_TYPE_CODE = 12; - static TypeHelper LONGARRAY = new TypeHelper(LONG_ARRAY_TYPE_CODE) { - @Override - long[] read(DataBundleValue value, List assets) { - long[] longArr = new long[value.longArray.size()]; - for (int i = 0; i < value.longArray.size(); i++) { - longArr[i] = value.longArray.get(i); - } - return longArr; - } - - @Override - DataBundleValue create(long[] value, List assets) { - List longList = new ArrayList(value.length); - for (long l : value) { - longList.add(l); - } - return new DataBundleValue.Builder().longArray(longList).build(); - } - - @Override - void store(DataMap dataMap, String key, long[] value) { - dataMap.putLongArray(key, value); - } - - @Override - long[] load(DataMap dataMap, String key) { - return dataMap.getLongArray(key); - } - }; - - public static final int ASSET_TYPE_CODE = 13; - static TypeHelper ASSET = new TypeHelper(ASSET_TYPE_CODE) { - @Override - Asset read(DataBundleValue value, List assets) { - return assets.get(value.assetIndex); - } - - @Override - DataBundleValue create(Asset value, List assets) { - int index; - if (assets.contains(value)) { - index = assets.indexOf(value); - } else { - index = assets.size(); - assets.add(value); - } - return new DataBundleValue.Builder().assetIndex(index).build(); - } - - @Override - void store(DataMap dataMap, String key, Asset value) { - dataMap.putAsset(key, value); - } - - @Override - Asset load(DataMap dataMap, String key) { - return dataMap.getAsset(key); - } - }; - - public static final int NULL_TYPE_CODE = 14; - static TypeHelper NULL = new TypeHelper(NULL_TYPE_CODE) { - @Override - String read(DataBundleValue value, List assets) { - return null; - } - - @Override - DataBundleValue create(String value, List assets) { - return new DataBundleValue.Builder().build(); - } - - @Override - void store(DataMap dataMap, String key, String value) { - dataMap.putString(key, value); - } - - @Override - void storeList(DataMap dataMap, String key, ArrayList valueList) { - dataMap.putStringArrayList(key, valueList); - } - - @Override - String load(DataMap dataMap, String key) { - return null; - } - - @Override - AnnotatedArrayList loadList(DataMap dataMap, String key) { - AnnotatedArrayList list = new AnnotatedArrayList(this); - list.addAll(dataMap.getStringArrayList(key)); - return list; - } - }; - - public static final int FLOAT_ARRAY_TYPE_CODE = 15; - static TypeHelper FLOATARRAY = new TypeHelper(FLOAT_ARRAY_TYPE_CODE) { - @Override - float[] read(DataBundleValue value, List assets) { - float[] floatArr = new float[value.floatArray.size()]; - for (int i = 0; i < value.floatArray.size(); i++) { - floatArr[i] = value.floatArray.get(i); - } - return floatArr; - } - - @Override - DataBundleValue create(float[] value, List assets) { - List floatList = new ArrayList(value.length); - for (float f : value) { - floatList.add(f); - } - return new DataBundleValue.Builder().floatArray(floatList).build(); - } - - @Override - void store(DataMap dataMap, String key, float[] value) { - dataMap.putFloatArray(key, value); - } - - @Override - float[] load(DataMap dataMap, String key) { - return dataMap.getFloatArray(key); - } - }; - - static { - typeHelperByCode = new SparseArray(); - rememberTypeReader(BYTEARRAY); - rememberTypeReader(STRING); - rememberTypeReader(DOUBLE); - rememberTypeReader(FLOAT); - rememberTypeReader(LONG); - rememberTypeReader(INTEGER); - rememberTypeReader(BYTE); - rememberTypeReader(BOOLEAN); - rememberTypeReader(DATAMAP); - rememberTypeReader(ARRAYLIST); - rememberTypeReader(STRINGARRAY); - rememberTypeReader(LONGARRAY); - rememberTypeReader(ASSET); - rememberTypeReader(NULL); - rememberTypeReader(FLOATARRAY); - } - - static class AssetAnnotatedDataBundle { - private DataBundle dataBundle; - private List assets; - - public List getAssets() { - return assets; - } - - public byte[] getData() { - return dataBundle.toByteArray(); - } - } - - static class AnnotatedArrayList extends ArrayList { - private TypeHelper innerType; - - public AnnotatedArrayList(TypeHelper innerType) { - this.innerType = innerType; - } - - void store(DataMap dataMap, String key) { - innerType.storeList(dataMap, key, this); - } - - public List createList(List assets) { - return innerType.createList(this, assets); - } - } - - static abstract class TypeHelper { - private int type; - - public TypeHelper(int type) { - this.type = type; - } - - abstract T read(DataBundleValue value, List assets); - - abstract DataBundleValue create(T value, List assets); - - T read(DataBundleTypedValue value, List assets) { - if (value.type == NULL_TYPE_CODE) { - return null; - } else if (value.type == type) { - return read(value.value, assets); - } else { - throw new IllegalArgumentException(); - } - } - - abstract void store(DataMap dataMap, String key, T value); - - void storeList(DataMap dataMap, String key, ArrayList valueList) { - throw new UnsupportedOperationException(); - } - - abstract T load(DataMap dataMap, String key); - - AnnotatedArrayList loadList(DataMap dataMap, String key) { - throw new UnsupportedOperationException(); - } - - void readAndStore(DataMap dataMap, String key, DataBundleValue value, List assets) { - store(dataMap, key, read(value, assets)); - } - - void readAndStore(DataMap dataMap, String key, DataBundleTypedValue value, List assets) { - store(dataMap, key, read(value, assets)); - } - - void readAndStore(DataMap dataMap, DataBundleEntry entry, List assets) { - readAndStore(dataMap, entry.key, entry.typedValue, assets); - } - - AnnotatedArrayList readList(List values, List assets) { - AnnotatedArrayList list = new AnnotatedArrayList(this); - for (DataBundleTypedValue value : values) { - list.add(read(value, assets)); - } - return list; - } - - List createList(AnnotatedArrayList value, List assets) { - List list = new ArrayList(); - for (T val : value) { - list.add(createTyped(val, assets)); - } - return list; - } - - void readAndStore(DataMap dataMap, String key, List values, List assets) { - storeList(dataMap, key, readList(values, assets)); - } - - DataBundleTypedValue createTyped(T value, List assets) { - return new DataBundleTypedValue(type, create(value, assets)); - } - - DataBundleValue loadAndCreate(DataMap dataMap, String key, List assets) { - return create(load(dataMap, key), assets); - } - - DataBundleTypedValue loadAndCreateTyped(DataMap dataMap, String key, List assets) { - return createTyped(load(dataMap, key), assets); - } - - DataBundleEntry loadAndCreateEntry(DataMap dataMap, String key, List assets) { - return new DataBundleEntry(key, loadAndCreateTyped(dataMap, key, assets)); - } - } -} diff --git a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundle.java b/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundle.java deleted file mode 100644 index ba388652..00000000 --- a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundle.java +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/databundle.proto -package org.microg.gms.wearable.databundle; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; -import java.util.Collections; -import java.util.List; - -import static com.squareup.wire.Message.Label.REPEATED; - -public final class DataBundle extends Message { - - public static final List DEFAULT_ENTRIES = Collections.emptyList(); - - @ProtoField(tag = 1, label = REPEATED, messageType = DataBundleEntry.class) - public final List entries; - - public DataBundle(List entries) { - this.entries = immutableCopyOf(entries); - } - - private DataBundle(Builder builder) { - this(builder.entries); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof DataBundle)) return false; - return equals(entries, ((DataBundle) other).entries); - } - - @Override - public int hashCode() { - int result = hashCode; - return result != 0 ? result : (hashCode = entries != null ? entries.hashCode() : 1); - } - - public static final class Builder extends Message.Builder { - - public List entries; - - public Builder() { - } - - public Builder(DataBundle message) { - super(message); - if (message == null) return; - this.entries = copyOf(message.entries); - } - - public Builder entries(List entries) { - this.entries = checkForNulls(entries); - return this; - } - - @Override - public DataBundle build() { - return new DataBundle(this); - } - } -} diff --git a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleEntry.java b/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleEntry.java deleted file mode 100644 index a5f52d38..00000000 --- a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleEntry.java +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/databundle.proto -package org.microg.gms.wearable.databundle; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; - -import static com.squareup.wire.Message.Datatype.STRING; - -public final class DataBundleEntry extends Message { - - public static final String DEFAULT_KEY = ""; - - @ProtoField(tag = 1, type = STRING) - public final String key; - - @ProtoField(tag = 2) - public final DataBundleTypedValue typedValue; - - public DataBundleEntry(String key, DataBundleTypedValue typedValue) { - this.key = key; - this.typedValue = typedValue; - } - - private DataBundleEntry(Builder builder) { - this(builder.key, builder.typedValue); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof DataBundleEntry)) return false; - DataBundleEntry o = (DataBundleEntry) other; - return equals(key, o.key) - && equals(typedValue, o.typedValue); - } - - @Override - public int hashCode() { - int result = hashCode; - if (result == 0) { - result = key != null ? key.hashCode() : 0; - result = result * 37 + (typedValue != null ? typedValue.hashCode() : 0); - hashCode = result; - } - return result; - } - - public static final class Builder extends Message.Builder { - - public String key; - public DataBundleTypedValue typedValue; - - public Builder() { - } - - public Builder(DataBundleEntry message) { - super(message); - if (message == null) return; - this.key = message.key; - this.typedValue = message.typedValue; - } - - public Builder key(String key) { - this.key = key; - return this; - } - - public Builder typedValue(DataBundleTypedValue typedValue) { - this.typedValue = typedValue; - return this; - } - - @Override - public DataBundleEntry build() { - return new DataBundleEntry(this); - } - } -} diff --git a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleTypedValue.java b/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleTypedValue.java deleted file mode 100644 index 9a7d08f6..00000000 --- a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleTypedValue.java +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/databundle.proto -package org.microg.gms.wearable.databundle; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; - -import static com.squareup.wire.Message.Datatype.INT32; - -public final class DataBundleTypedValue extends Message { - - public static final Integer DEFAULT_TYPE = 0; - - @ProtoField(tag = 1, type = INT32) - public final Integer type; - - @ProtoField(tag = 2) - public final DataBundleValue value; - - public DataBundleTypedValue(Integer type, DataBundleValue value) { - this.type = type; - this.value = value; - } - - private DataBundleTypedValue(Builder builder) { - this(builder.type, builder.value); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof DataBundleTypedValue)) return false; - DataBundleTypedValue o = (DataBundleTypedValue) other; - return equals(type, o.type) - && equals(value, o.value); - } - - @Override - public int hashCode() { - int result = hashCode; - if (result == 0) { - result = type != null ? type.hashCode() : 0; - result = result * 37 + (value != null ? value.hashCode() : 0); - hashCode = result; - } - return result; - } - - public static final class Builder extends Message.Builder { - - public Integer type; - public DataBundleValue value; - - public Builder() { - } - - public Builder(DataBundleTypedValue message) { - super(message); - if (message == null) return; - this.type = message.type; - this.value = message.value; - } - - public Builder type(Integer type) { - this.type = type; - return this; - } - - public Builder value(DataBundleValue value) { - this.value = value; - return this; - } - - @Override - public DataBundleTypedValue build() { - return new DataBundleTypedValue(this); - } - } -} diff --git a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleValue.java b/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleValue.java deleted file mode 100644 index 4b9a120a..00000000 --- a/play-services-wearable/src/main/protos-java/org/microg/gms/wearable/databundle/DataBundleValue.java +++ /dev/null @@ -1,259 +0,0 @@ -// Code generated by Wire protocol buffer compiler, do not edit. -// Source file: protos-repo/databundle.proto -package org.microg.gms.wearable.databundle; - -import com.squareup.wire.Message; -import com.squareup.wire.ProtoField; -import java.util.Collections; -import java.util.List; -import okio.ByteString; - -import static com.squareup.wire.Message.Datatype.BOOL; -import static com.squareup.wire.Message.Datatype.BYTES; -import static com.squareup.wire.Message.Datatype.DOUBLE; -import static com.squareup.wire.Message.Datatype.FLOAT; -import static com.squareup.wire.Message.Datatype.INT32; -import static com.squareup.wire.Message.Datatype.INT64; -import static com.squareup.wire.Message.Datatype.STRING; -import static com.squareup.wire.Message.Label.REPEATED; - -public final class DataBundleValue extends Message { - - public static final ByteString DEFAULT_BYTEARRAY = ByteString.EMPTY; - public static final String DEFAULT_STRINGVAL = ""; - public static final Double DEFAULT_DOUBLEVAL = 0D; - public static final Float DEFAULT_FLOATVAL = 0F; - public static final Long DEFAULT_LONGVAL = 0L; - public static final Integer DEFAULT_INTVAL = 0; - public static final Integer DEFAULT_BYTEVAL = 0; - public static final Boolean DEFAULT_BOOLEANVAL = false; - public static final List DEFAULT_MAP = Collections.emptyList(); - public static final List DEFAULT_LIST = Collections.emptyList(); - public static final List DEFAULT_STRINGARRAY = Collections.emptyList(); - public static final List DEFAULT_LONGARRAY = Collections.emptyList(); - public static final Integer DEFAULT_ASSETINDEX = 0; - public static final List DEFAULT_FLOATARRAY = Collections.emptyList(); - - @ProtoField(tag = 1, type = BYTES) - public final ByteString byteArray; - - @ProtoField(tag = 2, type = STRING) - public final String stringVal; - - @ProtoField(tag = 3, type = DOUBLE) - public final Double doubleVal; - - @ProtoField(tag = 4, type = FLOAT) - public final Float floatVal; - - @ProtoField(tag = 5, type = INT64) - public final Long longVal; - - @ProtoField(tag = 6, type = INT32) - public final Integer intVal; - - @ProtoField(tag = 7, type = INT32) - public final Integer byteVal; - - @ProtoField(tag = 8, type = BOOL) - public final Boolean booleanVal; - - @ProtoField(tag = 9, label = REPEATED, messageType = DataBundleEntry.class) - public final List map; - - @ProtoField(tag = 10, label = REPEATED, messageType = DataBundleTypedValue.class) - public final List list; - - @ProtoField(tag = 11, type = STRING, label = REPEATED) - public final List stringArray; - - @ProtoField(tag = 12, type = INT64, label = REPEATED) - public final List longArray; - - @ProtoField(tag = 13, type = INT32) - public final Integer assetIndex; - - @ProtoField(tag = 14, type = FLOAT, label = REPEATED) - public final List floatArray; - - public DataBundleValue(ByteString byteArray, String stringVal, Double doubleVal, Float floatVal, Long longVal, Integer intVal, Integer byteVal, Boolean booleanVal, List map, List list, List stringArray, List longArray, Integer assetIndex, List floatArray) { - this.byteArray = byteArray; - this.stringVal = stringVal; - this.doubleVal = doubleVal; - this.floatVal = floatVal; - this.longVal = longVal; - this.intVal = intVal; - this.byteVal = byteVal; - this.booleanVal = booleanVal; - this.map = immutableCopyOf(map); - this.list = immutableCopyOf(list); - this.stringArray = immutableCopyOf(stringArray); - this.longArray = immutableCopyOf(longArray); - this.assetIndex = assetIndex; - this.floatArray = immutableCopyOf(floatArray); - } - - private DataBundleValue(Builder builder) { - this(builder.byteArray, builder.stringVal, builder.doubleVal, builder.floatVal, builder.longVal, builder.intVal, builder.byteVal, builder.booleanVal, builder.map, builder.list, builder.stringArray, builder.longArray, builder.assetIndex, builder.floatArray); - setBuilder(builder); - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof DataBundleValue)) return false; - DataBundleValue o = (DataBundleValue) other; - return equals(byteArray, o.byteArray) - && equals(stringVal, o.stringVal) - && equals(doubleVal, o.doubleVal) - && equals(floatVal, o.floatVal) - && equals(longVal, o.longVal) - && equals(intVal, o.intVal) - && equals(byteVal, o.byteVal) - && equals(booleanVal, o.booleanVal) - && equals(map, o.map) - && equals(list, o.list) - && equals(stringArray, o.stringArray) - && equals(longArray, o.longArray) - && equals(assetIndex, o.assetIndex) - && equals(floatArray, o.floatArray); - } - - @Override - public int hashCode() { - int result = hashCode; - if (result == 0) { - result = byteArray != null ? byteArray.hashCode() : 0; - result = result * 37 + (stringVal != null ? stringVal.hashCode() : 0); - result = result * 37 + (doubleVal != null ? doubleVal.hashCode() : 0); - result = result * 37 + (floatVal != null ? floatVal.hashCode() : 0); - result = result * 37 + (longVal != null ? longVal.hashCode() : 0); - result = result * 37 + (intVal != null ? intVal.hashCode() : 0); - result = result * 37 + (byteVal != null ? byteVal.hashCode() : 0); - result = result * 37 + (booleanVal != null ? booleanVal.hashCode() : 0); - result = result * 37 + (map != null ? map.hashCode() : 1); - result = result * 37 + (list != null ? list.hashCode() : 1); - result = result * 37 + (stringArray != null ? stringArray.hashCode() : 1); - result = result * 37 + (longArray != null ? longArray.hashCode() : 1); - result = result * 37 + (assetIndex != null ? assetIndex.hashCode() : 0); - result = result * 37 + (floatArray != null ? floatArray.hashCode() : 1); - hashCode = result; - } - return result; - } - - public static final class Builder extends Message.Builder { - - public ByteString byteArray; - public String stringVal; - public Double doubleVal; - public Float floatVal; - public Long longVal; - public Integer intVal; - public Integer byteVal; - public Boolean booleanVal; - public List map; - public List list; - public List stringArray; - public List longArray; - public Integer assetIndex; - public List floatArray; - - public Builder() { - } - - public Builder(DataBundleValue message) { - super(message); - if (message == null) return; - this.byteArray = message.byteArray; - this.stringVal = message.stringVal; - this.doubleVal = message.doubleVal; - this.floatVal = message.floatVal; - this.longVal = message.longVal; - this.intVal = message.intVal; - this.byteVal = message.byteVal; - this.booleanVal = message.booleanVal; - this.map = copyOf(message.map); - this.list = copyOf(message.list); - this.stringArray = copyOf(message.stringArray); - this.longArray = copyOf(message.longArray); - this.assetIndex = message.assetIndex; - this.floatArray = copyOf(message.floatArray); - } - - public Builder byteArray(ByteString byteArray) { - this.byteArray = byteArray; - return this; - } - - public Builder stringVal(String stringVal) { - this.stringVal = stringVal; - return this; - } - - public Builder doubleVal(Double doubleVal) { - this.doubleVal = doubleVal; - return this; - } - - public Builder floatVal(Float floatVal) { - this.floatVal = floatVal; - return this; - } - - public Builder longVal(Long longVal) { - this.longVal = longVal; - return this; - } - - public Builder intVal(Integer intVal) { - this.intVal = intVal; - return this; - } - - public Builder byteVal(Integer byteVal) { - this.byteVal = byteVal; - return this; - } - - public Builder booleanVal(Boolean booleanVal) { - this.booleanVal = booleanVal; - return this; - } - - public Builder map(List map) { - this.map = checkForNulls(map); - return this; - } - - public Builder list(List list) { - this.list = checkForNulls(list); - return this; - } - - public Builder stringArray(List stringArray) { - this.stringArray = checkForNulls(stringArray); - return this; - } - - public Builder longArray(List longArray) { - this.longArray = checkForNulls(longArray); - return this; - } - - public Builder assetIndex(Integer assetIndex) { - this.assetIndex = assetIndex; - return this; - } - - public Builder floatArray(List floatArray) { - this.floatArray = checkForNulls(floatArray); - return this; - } - - @Override - public DataBundleValue build() { - return new DataBundleValue(this); - } - } -} diff --git a/play-services-wearable/src/main/protos-repo/databundle.proto b/play-services-wearable/src/main/protos-repo/databundle.proto deleted file mode 100644 index bc8cb317..00000000 --- a/play-services-wearable/src/main/protos-repo/databundle.proto +++ /dev/null @@ -1,33 +0,0 @@ -option java_package = "org.microg.gms.wearable.databundle"; -option java_outer_classname = "DataBundleProto"; - -message DataBundle { - repeated DataBundleEntry entries = 1; -} - -message DataBundleEntry { - optional string key = 1; - optional DataBundleTypedValue typedValue = 2; -} - -message DataBundleTypedValue { - optional int32 type = 1; - optional DataBundleValue value = 2; -} - -message DataBundleValue { - optional bytes byteArray = 1; - optional string stringVal = 2; - optional double doubleVal = 3; - optional float floatVal = 4; - optional int64 longVal = 5; - optional int32 intVal = 6; - optional int32 byteVal = 7; - optional bool booleanVal = 8; - repeated DataBundleEntry map = 9; - repeated DataBundleTypedValue list = 10; - repeated string stringArray = 11; - repeated int64 longArray = 12; - optional int32 assetIndex = 13; - repeated float floatArray = 14; -} diff --git a/proguard.flags b/proguard.flags index 1b6700d5..17f1d2ea 100644 --- a/proguard.flags +++ b/proguard.flags @@ -20,9 +20,7 @@ -keep public class com.google.android.gms.maps.internal.CreatorImpl { public *; } -keep public class com.google.android.gms.common.security.ProviderInstallerImpl { public *; } -keep public class com.google.android.gms.plus.plusone.PlusOneButtonCreatorImpl { public *; } --keep public class com.google.android.gms.dynamic.IObjectWrapper { public *; } -keep public class com.google.android.gms.chimera.container.DynamiteLoaderImpl { public *; } --keep public class com.google.android.gms.dynamite.descriptors.** { public *; } -keep public class com.google.android.gms.cast.framework.internal.CastDynamiteModuleImpl { public *; } # Keep AutoSafeParcelables @@ -37,7 +35,6 @@ # Keep our stuff -keep class org.microg.** { *; } --keep class com.google.android.gms.** { *; } # Keep asInterface method cause it's accessed from SafeParcel -keepattributes InnerClasses diff --git a/settings.gradle b/settings.gradle index 72474e43..1d4a1b0d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,23 +1,14 @@ -include ':wearable-lib' - include ':play-services-basement' include ':play-services-api' include ':play-services-cast-api' include ':play-services-cast-framework-api' include ':play-services-iid-api' -include ':play-services-location-api' -include ':play-services-wearable-api' include ':play-services-base' include ':play-services-tasks' -include ':play-services-wearable' include ':play-services-base-core' -include ':play-services-location-core' -include ':play-services-maps-core-mapbox' -include ':play-services-maps-core-vtm' -include ':play-services-maps-core-vtm:vtm-microg-theme' include ':play-services-core' include ':play-services-core:microg-ui-tools'