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

Check for SkParagraph enable status, and pass it to the created engine #939

Open
wants to merge 3 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
5 changes: 5 additions & 0 deletions audio_service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.18.6

* Add SkParagraph enable flag to the created engine
by (AudioServicePlugin) on Android (@limitless-brain).

## 0.18.5

* Add AudioServiceFragmentActivity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
Expand Down Expand Up @@ -36,6 +38,7 @@
import java.util.concurrent.Executors;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.loader.FlutterLoader;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
Expand Down Expand Up @@ -67,10 +70,35 @@ public static String getFlutterEngineId() {
}
public static synchronized FlutterEngine getFlutterEngine(Context context) {
FlutterEngine flutterEngine = FlutterEngineCache.getInstance().get(flutterEngineId);

// Since flutter 3 offer disabling SKParagraph
// And it has a bug that effected most of android flutter apps
// Check for the flag if it's available in manifest file

ApplicationInfo applicationInfo =
null;
String[] args = new String[1];
try {
applicationInfo = context
.getPackageManager()
.getApplicationInfo(
context.getPackageName(), PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}

if (applicationInfo != null) {
Bundle metaData = applicationInfo.metaData;
if (metaData != null) {
final String skEnabled = metaData.getBoolean("io.flutter.embedding.android.EnableSkParagraph", true) ? "true" : "false";
args[0] = ("--enable-skparagraph=".concat(skEnabled));
}
}

if (flutterEngine == null) {
// XXX: The constructor triggers onAttachedToEngine so this variable doesn't help us.
// Maybe need a boolean flag to tell us we're currently loading the main flutter engine.
flutterEngine = new FlutterEngine(context.getApplicationContext());
flutterEngine = new FlutterEngine(context.getApplicationContext(), args);
String initialRoute = null;
if (context instanceof FlutterActivity) {
final FlutterActivity activity = (FlutterActivity)context;
Expand Down
2 changes: 1 addition & 1 deletion 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.5
version: 0.18.6
homepage: https://github.com/ryanheise/audio_service/tree/master/audio_service

environment:
Expand Down