This commit is contained in:
wangcongtao
2021-03-01 20:44:27 +08:00
parent cc5313d64d
commit 4db21e57da
6 changed files with 124 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -8,6 +8,7 @@ import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@@ -31,6 +32,7 @@ import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.realtime.entity.MogoSnapshotSetData;
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
import com.mogo.service.adas.entity.ADASCarStateInfo;
@@ -44,9 +46,11 @@ import com.mogo.utils.storage.SharedPrefsMgr;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -549,6 +553,10 @@ public class MockIntentHandler implements IntentHandler {
String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}";
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ), false );
break;
case 47:
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
break;
}
}
@@ -572,15 +580,85 @@ public class MockIntentHandler implements IntentHandler {
}
}
private Handler mLocationMockHandler = new Handler(WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper()){
private Handler mLocationMockHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( msg.what == 1 ) {
try {
if ( !handleMockLocationIntent() ) {
br.close();
br = null;
}
} catch ( Exception e ) {
try {
br.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br = null;
}
} else if ( msg.what == 2 ) {
try {
handleMockSnapshotIntent();
} catch ( Exception e ) {
try {
br2.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br2 = null;
}
}
}
};
private void handleMockLocationIntent(){
private BufferedReader br;
private boolean handleMockLocationIntent() throws Exception {
if ( br == null ) {
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc.txt" ) ) );
}
String line = br.readLine();
if ( line == null ) {
throw new Exception( "end of file." );
}
JSONObject jo = new JSONObject( line );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
return true;
}
private BufferedReader br2;
private int count = 1;
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot.txt" ) ) );
}
String line = br2.readLine();
if ( line == null ) {
throw new Exception( "end of file 2." );
}
MogoSnapshotSetData data = new MogoSnapshotSetData();
List< CloudRoadData > allList = new ArrayList<>();
if ( ++count % 300 != 0 ) {
CloudRoadData cloudRoadData = GsonUtil.objectFromJson( line, CloudRoadData.class );
if ( cloudRoadData == null ) {
return false;
}
double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
cloudRoadData.setLon( coor[0] );
cloudRoadData.setLat( coor[1] );
allList.add( cloudRoadData );
}
data.setAllList( allList );
final long start = System.currentTimeMillis();
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
Log.i("mock-snapshot-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
return true;
}
}