Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing "firebase + audio_service: application launched when it should not" by @yanivshaked hack #1011

Open
wants to merge 6 commits into
base: minor
Choose a base branch
from
Open
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 @@ -10,6 +10,7 @@
public class AudioServiceActivity extends FlutterActivity {
@Override
public FlutterEngine provideFlutterEngine(@NonNull Context context) {
AudioServicePlugin.setArmStartup(true);
return AudioServicePlugin.getFlutterEngine(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
* AudioservicePlugin
*/
public class AudioServicePlugin implements FlutterPlugin, ActivityAware {
private static boolean armStartup = false;
public static synchronized void setArmStartup(boolean enabled) {
armStartup = enabled;
}
private static String flutterEngineId = "audio_service_engine";
/** Must be called BEFORE any FlutterEngine is created. e.g. in Application class. */
public static void setFlutterEngineId(String id) {
Expand All @@ -65,7 +69,11 @@ public static void setFlutterEngineId(String id) {
public static String getFlutterEngineId() {
return flutterEngineId;
}

public static synchronized FlutterEngine getFlutterEngine(Context context) {
if (armStartup == false) {
return null;
}
FlutterEngine flutterEngine = FlutterEngineCache.getInstance().get(flutterEngineId);
if (flutterEngine == null) {
// XXX: The constructor triggers onAttachedToEngine so this variable doesn't help us.
Expand Down
4 changes: 2 additions & 2 deletions audio_service/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: audio_service
description: Flutter plugin to play audio in the background while the screen is off.
version: 0.18.9
version: 0.18.12
homepage: https://github.com/ryanheise/audio_service/tree/master/audio_service

environment:
Expand Down Expand Up @@ -58,4 +58,4 @@ flutter:
macos:
pluginClass: AudioServicePlugin
web:
default_package: audio_service_web
default_package: audio_service_web