提交 115cb979 编写于 作者: M momoxiangbei

添加新四地图定位模拟

上级 3a6b1309
......@@ -160,6 +160,8 @@ dependencies {
implementation rootProject.ext.dependencies["okhttp_v3"]
implementation rootProject.ext.dependencies["okgo"]
implementation rootProject.ext.dependencies["glide"]
implementation rootProject.ext.dependencies["dmap"]
// implementation rootProject.ext.dependencies["glide_okhttp3"]
kapt rootProject.ext.dependencies["glide_compiler"]
implementation rootProject.ext.dependencies["picasso"]
......
......@@ -8,9 +8,10 @@ if (runType == 0) {
debugImplementation project(":dokit")
debugImplementation project(":dokit-mc")
debugImplementation project(":dokit-ft")
debugImplementation project(":dokit-weex")
// debugImplementation project(":dokit-weex")
// debugImplementation project(":dokit-rpc")
// debugImplementation project(":dokit-rpc-mc")
debugImplementation project(":dokit-dmap") // todo xueying
releaseImplementation project(":dokit-no-op")
}
} else if (runType == 1) {
......
......@@ -14,7 +14,7 @@ buildscript {
maven {
url "https://oss.sonatype.org/content/groups/public"
}
// maven { url 'https://artifactory.intra.xiaojukeji.com/artifactory/public' }
maven { url 'https://artifactory.intra.xiaojukeji.com/artifactory/public' } // todo xueying
// maven {
// //本地插件地址
// url uri('/Users/didi/project/dokit_repo')
......@@ -44,7 +44,7 @@ allprojects {
maven {
url "https://oss.sonatype.org/content/groups/public"
}
// maven { url 'https://artifactory.intra.xiaojukeji.com/artifactory/public' }
maven { url 'https://artifactory.intra.xiaojukeji.com/artifactory/public' } // todo xueying
// maven {
// //本地插件地址
// url uri('/Users/didi/project/dokit_repo')
......
......@@ -228,7 +228,19 @@ class CommClassTransformer : AbsClassTransformer() {
}
}
// // 插入新四地图相关字节码
// if (className == "com.didichuxing.bigdata.dp.locsdk.DIDILocationManager") {
// // 持续定位和单次定位
// klass.methods?.filter {
// it.name == "requestLocationUpdateOnce" || it.name == "requestLocationUpdates"
// }?.forEach { methodNode ->
// "${context.projectDir.lastPath()}->hook didi map succeed: ${className}_${methodNode?.name}_${methodNode?.desc}".println()
// methodNode?.instructions?.insert(createDMapLocationListenerInsnList())
// }
//
// // 反注册监听器
// // todo xueying
// }
}
......@@ -996,6 +1008,31 @@ class CommClassTransformer : AbsClassTransformer() {
}
/**
* 创建新四地图代码指令
*/
// private fun createDMapLocationListenerInsnList(): InsnList {
// return with(InsnList()) {
// //在DIDILocationManager的requestLocationUpdateOnce方法之中插入自定义代理回调类
// add(TypeInsnNode(NEW, "com/didichuxing/doraemonkit/aop/map/DMapLocationListenerProxy"))
// add(InsnNode(DUP))
// //访问第一个参数
// add(VarInsnNode(ALOAD, 1))
// add(
// MethodInsnNode(
// INVOKESPECIAL,
// "com/didichuxing/doraemonkit/aop/map/DMapLocationListenerProxy",
// "<init>",
// "(Lcom/didichuxing/bigdata/dp/locsdk/DIDILocationListener;)V",
// false
// )
// )
// //对第一个参数进行重新赋值
// add(VarInsnNode(ASTORE, 1))
// this
// }
// }
/**
* 创建OkhttpClient一个数构造函数指令
......
......@@ -129,6 +129,8 @@ ext {
"amap_map3d" : 'com.amap.api:map3d:latest.integration',
"amap_search" : 'com.amap.api:search:latest.integration',
"amap_navi" : 'com.amap.api:navi-3dmap:latest.integration',
//新四地图
"dmap" : 'com.didichuxing.bigdata.dp:didilocsdk:2.8.201',
//腾讯地图定位
"tencent_location" : 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.2.5',
"tencent_map" : 'com.tencent.map:tencent-map-vector-sdk:4.4.0',
......
/build
\ No newline at end of file
plugins {
id 'com.android.library'
}
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion_16"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
lintOptions {
abortOnError false
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
// compileOnly rootProject.ext.dependencies["dmap"]
implementation project(path: ':dokit')
compileOnly 'com.didichuxing.bigdata.dp:didilocsdk:2.8.201'
}
\ No newline at end of file
ARTIFACT_ID=dokitx-dmap
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.didichuxing.doraemonkit.dmap">
</manifest>
\ No newline at end of file
package com.didichuxing.doraemonkit.aop.map;
import android.location.Location;
import androidx.annotation.NonNull;
import com.didichuxing.bigdata.dp.locsdk.DIDILocation;
import com.didichuxing.bigdata.dp.locsdk.DIDILocationListener;
import com.didichuxing.bigdata.dp.locsdk.ErrInfo;
import com.didichuxing.bigdata.dp.locsdk.trace.data.ETraceSource;
import com.didichuxing.doraemonkit.kit.gpsmock.GpsMockProxyManager;
/**
* Created by mmxb on 2021/9/13.
*/
public class DMapLocationListenerProxy implements DIDILocationListener, DMapLocationListener {
public DIDILocationListener didiLocationListener;
public DMapLocationListenerProxy(DIDILocationListener didiLocationListener) {
this.didiLocationListener = didiLocationListener;
GpsMockProxyManager.INSTANCE.addDMapLocationListenerProxy(this);
}
@Override
public void onLocationChanged(DIDILocation didiLocation) {
}
@Override
public void onLocationError(int i, ErrInfo errInfo) {
}
@Override
public void onStatusUpdate(String s, int i, String s1) {
}
@NonNull
@Override
public Object getDMapLocation() {
return didiLocationListener;
}
@Override
public void onLocationChange(Location location) {
DIDILocation didiLocation = new DIDILocation();
DIDILocation.loadFromSystemLoc(location, ETraceSource.cache, 0);
// didiLocation.getLatitude();
// this.onLocationChanged();
}
}
......@@ -228,7 +228,19 @@ class CommClassTransformer : AbsClassTransformer() {
}
}
// // 插入滴滴地图相关字节码
// if (className == "com.didichuxing.bigdata.dp.locsdk.DIDILocationManager") {
// // 持续定位和单次定位
// klass.methods?.filter {
// it.name == "requestLocationUpdateOnce" || it.name == "requestLocationUpdates"
// }?.forEach { methodNode ->
// "${context.projectDir.lastPath()}->hook didi map succeed: ${className}_${methodNode?.name}_${methodNode?.desc}".println()
// methodNode?.instructions?.insert(createDMapLocationListenerInsnList())
// }
//
// // 反注册监听器
// // todo xueying
// }
}
......@@ -996,6 +1008,31 @@ class CommClassTransformer : AbsClassTransformer() {
}
/**
* 创建滴滴地图代码指令
*/
private fun createDMapLocationListenerInsnList(): InsnList {
return with(InsnList()) {
//在DIDILocationManager的requestLocationUpdateOnce方法之中插入自定义代理回调类
add(TypeInsnNode(NEW, "com/didichuxing/doraemonkit/aop/map/DMapLocationListenerProxy"))
add(InsnNode(DUP))
//访问第一个参数
add(VarInsnNode(ALOAD, 1))
add(
MethodInsnNode(
INVOKESPECIAL,
"com/didichuxing/doraemonkit/aop/map/DMapLocationListenerProxy",
"<init>",
"(Lcom/didichuxing/bigdata/dp/locsdk/DIDILocationListener;)V",
false
)
)
//对第一个参数进行重新赋值
add(VarInsnNode(ASTORE, 1))
this
}
}
/**
* 创建OkhttpClient一个数构造函数指令
......
package com.didichuxing.doraemonkit.aop.map
import android.location.Location
/**
* Created by mmxb on 2021/9/16.
*/
interface DMapLocationListener {
fun getDMapLocation(): Any
fun onLocationChange(location: Location?)
}
\ No newline at end of file
......@@ -39,6 +39,10 @@ public class ThirdMapLocationListenerUtil {
GpsMockProxyManager.INSTANCE.removeBDAbsLocationListener(locationListener);
}
public static void unRegisterDMapLocationListener(DMapLocationListener locationListener){
GpsMockProxyManager.INSTANCE.removeDMapLocationListener(locationListener);
}
public static void unRegisterLocationListener(LocationListener locationListener) {
GpsMockProxyManager.INSTANCE.removeLocationListener(locationListener);
}
......
......@@ -13,4 +13,5 @@ enum class DoKitModule {
MODULE_FT,
MODULE_MC,
MODULE_RPC_MC,
MODULE_DMAP
}
\ No newline at end of file
......@@ -10,7 +10,6 @@ import com.didichuxing.doraemonkit.aop.map.*
import com.didichuxing.doraemonkit.kit.gpsmock.LocationHooker.LocationListenerProxy
import com.tencent.map.geolocation.TencentLocation
import com.tencent.map.geolocation.TencentLocationListener
import java.util.*
/**
* 三方地图管理类
......@@ -25,6 +24,7 @@ object GpsMockProxyManager {
private val mBDLocationListenerProxies: MutableList<BDLocationListenerProxy?> = ArrayList()
private val mTencentLocationListenerProxies: MutableList<TencentLocationListenerProxy?> =
ArrayList()
private val mDMapLocationListenerProxies: MutableList<DMapLocationListener> = ArrayList()
private val mLocationListenerProxies: MutableList<LocationListenerProxy> = ArrayList()
......@@ -52,6 +52,10 @@ object GpsMockProxyManager {
mTencentLocationListenerProxies.add(tencentLocationListenerProxy)
}
fun addDMapLocationListenerProxy(locationListenerProxy: DMapLocationListener) {
mDMapLocationListenerProxies.add(locationListenerProxy)
}
fun addLocationListenerProxy(locationListenerProxy: LocationListenerProxy) {
mLocationListenerProxies.add(locationListenerProxy)
}
......@@ -116,6 +120,16 @@ object GpsMockProxyManager {
}
}
fun removeDMapLocationListener(listener: DMapLocationListener) {
val it = mDMapLocationListenerProxies.iterator()
while (it.hasNext()) {
val proxy = it.next()
if (proxy.getDMapLocation() === listener) {
it.remove()
}
}
}
fun clearProxy() {
mAMapLocationListenerProxies.clear()
mBDAbsLocationListenerProxies.clear()
......@@ -126,7 +140,7 @@ object GpsMockProxyManager {
fun mockLocationWithNotify(location: Location?) {
if (location == null) return
try {
notifyLocationListenerProxy(location)
} catch (e: Exception) {
......@@ -153,7 +167,11 @@ object GpsMockProxyManager {
} catch (e: Exception) {
e.printStackTrace()
}
try {
notifyDMapLocationListenerProxy(location)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifyAMapLocationListenerProxy(location: Location?) {
......@@ -217,5 +235,11 @@ object GpsMockProxyManager {
}
}
private fun notifyDMapLocationListenerProxy(location: Location?) {
if (location != null) {
for (dMapLocationListener in mDMapLocationListenerProxies){
dMapLocationListener.onLocationChange(location)
}
}
}
}
\ No newline at end of file
......@@ -11,3 +11,4 @@ include ':dokit-no-op'
include ':dokit-plugin'
//include ':dokit-rpc'
//include ':dokit-rpc-mc'
include ':dokit-dmap' // todo xueying
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册