Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.android.gms.maps.StreetViewPanoramaOptions;
import com.google.android.gms.maps.model.internal.IBitmapDescriptorFactoryDelegate;

import com.huawei.hms.maps.MapsInitializer;
import org.microg.gms.maps.hms.CameraUpdateFactoryImpl;
import org.microg.gms.maps.hms.MapFragmentImpl;
import org.microg.gms.maps.hms.MapViewImpl;
Expand All @@ -30,6 +29,7 @@
@Keep
public class CreatorImpl extends ICreator.Stub {
private static final String TAG = "GmsMapCreator";
public static volatile int VERSION = Integer.MAX_VALUE;

@Override
public void init(IObjectWrapper resources) {
Expand Down Expand Up @@ -59,6 +59,7 @@ public IBitmapDescriptorFactoryDelegate newBitmapDescriptorFactoryDelegate() {
@Override
public void initV2(IObjectWrapper resources, int flags) {
BitmapDescriptorFactoryImpl.INSTANCE.initialize(ObjectWrapper.unwrapTyped(resources, Resources.class));
VERSION = flags;
//ResourcesContainer.set((Resources) ObjectWrapper.unwrap(resources));
Log.d(TAG, "initV2 " + flags);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.annotation.IdRes
import androidx.annotation.Keep
import androidx.collection.LongSparseArray
import com.google.android.gms.dynamic.IObjectWrapper
import com.google.android.gms.dynamic.ObjectWrapper
import com.google.android.gms.dynamic.unwrap
import com.google.android.gms.maps.GoogleMap.MAP_TYPE_TERRAIN
import com.google.android.gms.maps.GoogleMapOptions
Expand Down Expand Up @@ -588,10 +589,18 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
}

override fun snapshot(callback: ISnapshotReadyCallback, bitmap: IObjectWrapper?) = afterInitialize {
Log.d(TAG, "snapshot")
val hmsBitmap = bitmap.unwrap<Bitmap>() ?: return@afterInitialize
Comment thread
mar-v-in marked this conversation as resolved.
val hmsCallback = HuaweiMap.SnapshotReadyCallback { p0 -> callback.onBitmapReady(p0) }
it.snapshot(hmsCallback, hmsBitmap)
Log.d(TAG, "taking snapshot now")
val hmsBitmap = bitmap.unwrap<Bitmap>()
Log.d(TAG, "provided bitmap. $hmsBitmap")
val hmsCallback = HuaweiMap.SnapshotReadyCallback { result ->
runOnMainLooper {
Log.d(TAG, "take snapshot end. $result")
if (CreatorImpl.VERSION < SNAPSHOT_OLD_VERSION_CODE) {
callback.onBitmapReady(result)
} else callback.onBitmapWrappedReady(ObjectWrapper.wrap(result))
}
}
if (hmsBitmap != null) it.snapshot(hmsCallback, hmsBitmap) else it.snapshot(hmsCallback)
}

override fun snapshotForTest(callback: ISnapshotReadyCallback) = afterInitialize {
Expand Down Expand Up @@ -984,6 +993,7 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)

companion object {
private const val TAG = "GmsGoogleMap"
private const val SNAPSHOT_OLD_VERSION_CODE = 4000000

private const val TAG_LOGO = "fakeWatermark"
private const val ON_MAP_CALLBACK_DELAY = 300L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ 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.huawei.hms.maps.HuaweiMap
import com.huawei.hms.maps.model.BitmapDescriptorFactory


object BitmapDescriptorFactoryImpl : IBitmapDescriptorFactoryDelegate.Stub() {
private val TAG = "GmsMapBitmap"
private var resources: Resources? = null
Expand Down