[android-auto] Fix PendingIntent crash

Signed-off-by: Andrew Shkrob <andrew.shkrob.social@yandex.by>
This commit is contained in:
Andrew Shkrob 2023-10-07 09:08:26 +02:00 committed by Viktor Govako
parent e54a4a7f22
commit baa15f3390
3 changed files with 24 additions and 11 deletions

View file

@ -34,7 +34,8 @@ public class MapPlaceholderActivity extends BaseMwmFragmentActivity implements D
public void onDisplayChangedToDevice(@NonNull Runnable onTaskFinishedCallback)
{
mRemoveDisplayListener = false;
startActivity(new Intent(this, MwmActivity.class));
startActivity(new Intent(this, MwmActivity.class)
.putExtra(MwmActivity.EXTRA_UPDATE_THEME, true));
finish();
onTaskFinishedCallback.run();
}

View file

@ -143,6 +143,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
public static final String EXTRA_CATEGORY_ID = "category_id";
public static final String EXTRA_BOOKMARK_ID = "bookmark_id";
public static final String EXTRA_TRACK_ID = "track_id";
public static final String EXTRA_UPDATE_THEME = "update_theme";
private static final String EXTRA_CONSUMED = "mwm.extra.intent.processed";
private static final String[] DOCKED_FRAGMENTS = { SearchFragment.class.getName(),
@ -487,14 +488,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
mSearchController.getToolbar()
.getViewTreeObserver();
mDisplayManager = DisplayManager.from(this);
mDisplayManager.addListener(DisplayType.Device, this);
final Intent intent = getIntent();
boolean isLaunchByDeepLink = intent != null && !intent.hasCategory(Intent.CATEGORY_LAUNCHER);
initViews(isLaunchByDeepLink);
updateViewsInsets();
// Note: You must call registerForActivityResult() before the fragment or activity is created.
mLocationPermissionRequest = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(),
this::onLocationPermissionsResult);
@ -502,6 +495,24 @@ public class MwmActivity extends BaseMwmFragmentActivity
this::onLocationResolutionResult);
mPostNotificationPermissionRequest = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
this::onPostNotificationPermissionResult);
mDisplayManager = DisplayManager.from(this);
if (mDisplayManager.isCarDisplayUsed())
{
mRemoveDisplayListener = false;
startActivity(new Intent(this, MapPlaceholderActivity.class));
finish();
return;
}
mDisplayManager.addListener(DisplayType.Device, this);
final Intent intent = getIntent();
final boolean isLaunchByDeepLink = intent != null && !intent.hasCategory(Intent.CATEGORY_LAUNCHER);
initViews(isLaunchByDeepLink);
updateViewsInsets();
if (getIntent().getBooleanExtra(EXTRA_UPDATE_THEME, false))
ThemeSwitcher.INSTANCE.restart(isMapRendererActive());
}
private void refreshLightStatusBar()

View file

@ -37,6 +37,7 @@ import app.organicmaps.location.LocationState;
import app.organicmaps.location.SensorHelper;
import app.organicmaps.location.SensorListener;
import app.organicmaps.routing.RoutingController;
import app.organicmaps.util.Config;
import app.organicmaps.util.LocationUtils;
import app.organicmaps.util.log.Logger;
import app.organicmaps.widget.placepage.PlacePageData;
@ -173,7 +174,7 @@ public final class CarAppSession extends Session implements DefaultLifecycleObse
mInitFailed = false;
try
{
MwmApplication.from(getCarContext()).init(() -> {});
MwmApplication.from(getCarContext()).init(() -> Config.setFirstStartDialogSeen(getCarContext()));
} catch (IOException e)
{
mInitFailed = true;
@ -197,7 +198,7 @@ public final class CarAppSession extends Session implements DefaultLifecycleObse
public void onCompassUpdated(double north)
{
Map.onCompassUpdated(north, false);
Map.onCompassUpdated(north, true);
}
@Override