diff --git a/.idea/misc.xml b/.idea/misc.xml index 47f1a4e1d4..2db9aab721 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ - + diff --git a/modules/mogo-module-service/src/main/AndroidManifest.xml b/modules/mogo-module-service/src/main/AndroidManifest.xml index 8eb5a9dd2c..5ff3cff7d9 100644 --- a/modules/mogo-module-service/src/main/AndroidManifest.xml +++ b/modules/mogo-module-service/src/main/AndroidManifest.xml @@ -1,6 +1,9 @@ + + + { MogoServices.getInstance().init( AbsMogoApplication.getApp() ); diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java new file mode 100644 index 0000000000..9087fc2698 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/location/MogoRTKLocation.java @@ -0,0 +1,90 @@ +package com.mogo.module.service.location; + +import android.content.Context; +import android.location.Criteria; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; + +import com.mogo.commons.AbsMogoApplication; +import com.mogo.utils.logger.Logger; + +public class MogoRTKLocation { + + private static final String TAG = "MogoRTKLocation"; + private LocationManager locationManager; + + public static MogoRTKLocation getInstance() { + return RTKHolder.rtkLoc; + } + + private static class RTKHolder { + private static final MogoRTKLocation rtkLoc = new MogoRTKLocation(); + } + + private MogoRTKLocation() { + + } + + public void init() { + locationManager = (LocationManager) AbsMogoApplication.getApp().getApplicationContext().getSystemService(Context.LOCATION_SERVICE); + String provider = locationManager.getBestProvider(getCriteria(), true); + Logger.d(TAG, "init provider : " + provider); + if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + try { + locationManager.requestLocationUpdates(provider, 0, 0, locationListener); + Location location = locationManager.getLastKnownLocation(provider); + if (location != null) { + Logger.i(TAG, "location : " + location.toString()); + } + } catch (Exception e) { + e.printStackTrace(); + Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage()); + } + } else { + Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable"); + } + } + + private Criteria getCriteria() { + Criteria criteria = new Criteria(); + criteria.setAccuracy(Criteria.ACCURACY_FINE); //高精 + criteria.setAltitudeRequired(false); + criteria.setBearingRequired(true); + criteria.setSpeedRequired(true); + criteria.setPowerRequirement(Criteria.POWER_LOW); + return criteria; + } + + private LocationListener locationListener = new LocationListener() { + @Override + public void onLocationChanged(Location location) { + Logger.d(TAG, "onLocationChanged : " + location.toString()); + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + Logger.d(TAG, "onStatusChanged status: " + status); + } + + @Override + public void onProviderEnabled(String provider) { + Logger.d(TAG, "onProviderEnabled"); + } + + @Override + public void onProviderDisabled(String provider) { + Logger.d(TAG, "onProviderEnabled"); + } + }; + + public void stop() { + Logger.d(TAG, "stop RTK Location"); + if (locationManager != null && locationListener != null) { + locationManager.removeUpdates(locationListener); + } else { + Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null"); + } + } +} diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java index 3dd0dc1cf6..146c3280ce 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java @@ -37,6 +37,7 @@ public class V2XConst { */ public static final String BROADCAST_TEST_PANEL_CONTROL_ACTION = "com.v2x.com.v2x.test_panel_control"; public static final String BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY = "TextPanelOpenStatus"; + public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "TextPanelOpenType"; public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast"; diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/receiver/TestPanelBroadcastReceiver.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/receiver/TestPanelBroadcastReceiver.java index 7123176fba..bb19973358 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/receiver/TestPanelBroadcastReceiver.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/receiver/TestPanelBroadcastReceiver.java @@ -21,15 +21,17 @@ public class TestPanelBroadcastReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { try { boolean textPanelOpenStatus = intent.getBooleanExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY, false); + int textPanelOpenType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0); Logger.d(TAG, "textPanelOpenStatus:" + textPanelOpenStatus); + Logger.d(TAG, "textPanelOpenType:" + textPanelOpenType); if (textPanelOpenStatus) { V2XServiceManager .getIMogoWindowManager() - .addView(V2XTestConsoleWindow.getInstance(context), 0, 0, false); + .addView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType), 0, 0, false); } else { V2XServiceManager .getIMogoWindowManager() - .removeView(V2XTestConsoleWindow.getInstance(context)); + .removeView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType)); } } catch (Exception e) { e.printStackTrace(); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java index bc5fa627bd..355fb04449 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java @@ -6,6 +6,7 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; +import android.widget.LinearLayout; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @@ -39,7 +40,10 @@ import static android.text.style.TtsSpan.GENDER_MALE; public class V2XTestConsoleWindow extends ConstraintLayout { private static V2XTestConsoleWindow mV2XTestConsoleWindow; - private FlexboxLayout mFlTestPanel; + private LinearLayout mFlTestPanel; + private FlexboxLayout flTestPanelShunNormal; + private FlexboxLayout flTestPanelShunYi; + private FlexboxLayout flTestPanelVR; private Button mBtnTriggerOpen; private Button mBtnTriggerRoadEvent; private Button mBtnClearRoadEvent; @@ -61,17 +65,22 @@ public class V2XTestConsoleWindow extends ConstraintLayout { btnTriggerCongestedRouteRecommendation, btnTriggerDoubleFlash; - public static V2XTestConsoleWindow getInstance(Context context) { + public static V2XTestConsoleWindow getInstance(Context context, int showType) { if (mV2XTestConsoleWindow == null) { synchronized (V2XTestConsoleWindow.class) { if (mV2XTestConsoleWindow == null) { - mV2XTestConsoleWindow = new V2XTestConsoleWindow(context); + mV2XTestConsoleWindow = new V2XTestConsoleWindow(context, showType); } } } return mV2XTestConsoleWindow; } + public V2XTestConsoleWindow(Context context, int showType) { + super(context); + initView(context, showType); + } + public V2XTestConsoleWindow(Context context) { this(context, null); } @@ -82,13 +91,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout { public V2XTestConsoleWindow(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initView(context); + initView(context, 0); } - private void initView(Context context) { + private void initView(Context context, int showType) { LayoutInflater.from(context).inflate(R.layout.window_test_console, this); mFlTestPanel = findViewById(R.id.flTestPanel); + flTestPanelShunNormal = findViewById(R.id.flTestPanelShunNormal); + flTestPanelShunYi = findViewById(R.id.flTestPanelShunYi); + flTestPanelVR = findViewById(R.id.flTestPanelVR); mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen); mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent); mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent); @@ -111,6 +123,24 @@ public class V2XTestConsoleWindow extends ConstraintLayout { btnTriggerDoubleFlash = findViewById(R.id.btnTriggerDoubleFlash); + switch (showType) { + case 0: + flTestPanelShunNormal.setVisibility(View.VISIBLE); + flTestPanelShunYi.setVisibility(View.VISIBLE); + flTestPanelVR.setVisibility(View.VISIBLE); + break; + case 1: + flTestPanelShunNormal.setVisibility(View.VISIBLE); + break; + case 2: + flTestPanelShunYi.setVisibility(View.VISIBLE); + break; + case 3: + flTestPanelVR.setVisibility(View.VISIBLE); + break; + } + + mBtnTriggerCallUserInfo.setOnClickListener(v -> { MogoDriverInfo mogoDriverInfo = new MogoDriverInfo(); mogoDriverInfo.setAge(24); @@ -124,7 +154,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout { mBtnTriggerOpen.setOnClickListener(v -> V2XServiceManager .getIMogoWindowManager() - .removeView(V2XTestConsoleWindow.getInstance(context)) + .removeView(V2XTestConsoleWindow.getInstance(context, showType)) ); mBtnClearRoadEvent.setOnClickListener(v -> { diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml index 7b52dcf96f..bfcf5addec 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml @@ -6,336 +6,390 @@ android:orientation="horizontal" android:paddingStart="@dimen/module_main_v2x_animation_width"> - + android:paddingEnd="@dimen/dp_100"> -