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

@mczernek/app loader migration #8438

Merged
merged 11 commits into from May 28, 2020
5 changes: 5 additions & 0 deletions android/expoview/src/main/AndroidManifest.xml
Expand Up @@ -106,6 +106,11 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>

<meta-data
tools:replace="android:value"
mczernek marked this conversation as resolved.
Show resolved Hide resolved
android:name="org.unimodules.core.AppLoader#react-native-headless"
android:value="host.exp.exponent.taskManager.ExpoHeadlessAppLoader"/>
</application>

</manifest>
Expand Up @@ -53,16 +53,14 @@ public void onCreate() {
if (!Constants.isStandaloneApp()) {
KernelConstants.MAIN_ACTIVITY_CLASS = LauncherActivity.class;
}

AppLoaderProvider.registerLoader(this, "react-native-headless", ExpoHeadlessAppLoader.class);
KernelProvider.setFactory(new KernelProvider.KernelFactory() {
@Override
public KernelInterface create() {
return new Kernel();
}
});

ExponentKernelModuleProvider.setFactory(reactContext -> new ExponentKernelModule(reactContext));
ExponentKernelModuleProvider.setFactory(ExponentKernelModule::new);

Exponent.initialize(this, this);
NativeModuleDepsProvider.getInstance().add(Kernel.class, KernelProvider.getInstance());
Expand Down
Expand Up @@ -26,7 +26,6 @@ public class ReactAdapterPackage extends BasePackage {

@Override
public List<InternalModule> createInternalModules(Context context) {
AppLoaderProvider.registerLoader(context, "react-native-headless", RNHeadlessAppLoader.class);
// We can force-cast here, because this package will only be used in React Native context.
ReactContext reactContext = (ReactContext) context;
return Arrays.asList(
Expand Down
@@ -1,5 +1,11 @@
<manifest package="org.unimodules.adapters.react"
xmlns:android="http://schemas.android.com/apk/res/android">

<manifest package="org.unimodules.adapters.react">
<application>
<meta-data
android:name="org.unimodules.core.AppLoader#react-native-headless"
mczernek marked this conversation as resolved.
Show resolved Hide resolved
android:value="org.unimodules.adapters.react.apploader.RNHeadlessAppLoader"/>
</application>

</manifest>

Expand Up @@ -26,7 +26,6 @@ public class ReactAdapterPackage extends BasePackage {

@Override
public List<InternalModule> createInternalModules(Context context) {
AppLoaderProvider.registerLoader(context, "react-native-headless", RNHeadlessAppLoader.class);
// We can force-cast here, because this package will only be used in React Native context.
ReactContext reactContext = (ReactContext) context;
return Arrays.asList(
Expand Down
4 changes: 1 addition & 3 deletions packages/expo-background-fetch/CHANGELOG.md
Expand Up @@ -8,6 +8,4 @@

### 🐛 Bug fixes

## 8.2.0 — 2020-05-27

*This version does not introduce any user-facing changes.*
- Upgrading an application does not cause `BackgroundFetch` tasks to unregister. ([#8348](https://github.com/expo/expo/pull/8438) by [@mczernek](https://github.com/mczernek))
Expand Up @@ -39,8 +39,8 @@ public String taskType() {
@Override
public boolean canReceiveCustomBroadcast(String action) {
// Let the TaskService know that we want to receive custom broadcasts
// having "android.intent.action.BOOT_COMPLETED" action.
return Intent.ACTION_BOOT_COMPLETED.equals(action);
// having "android.intent.action.BOOT_COMPLETED" or "Intent.ACTION_MY_PACKAGE_REPLACED" action.
return Intent.ACTION_BOOT_COMPLETED.equals(action) || Intent.ACTION_MY_PACKAGE_REPLACED.equals(action);
}

@Override
Expand All @@ -65,13 +65,16 @@ public void didReceiveBroadcast(Intent intent) {
String action = intent.getAction();

if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
// Device has just been booted up - restore an alarm if "startOnBoot" option is enabled.
// Device has just been booted up, so we need restore an alarm if "startOnBoot" option is enabled.
Map<String, Object> options = mTask.getOptions();
boolean startOnBoot = options.containsKey("startOnBoot") && (boolean) options.get("startOnBoot");

if (startOnBoot) {
startAlarm();
}
} else if(Intent.ACTION_MY_PACKAGE_REPLACED.equals(action)) {
// App has just been reinstalled, so we need restore an alarm.
startAlarm();
} else {
Context context = getContext();
TaskManagerUtilsInterface taskManagerUtils = getTaskManagerUtils();
Expand Down
4 changes: 1 addition & 3 deletions packages/expo-task-manager/CHANGELOG.md
Expand Up @@ -8,6 +8,4 @@

### 🐛 Bug fixes

## 8.2.0 — 2020-05-27

*This version does not introduce any user-facing changes.*
- Upgrading an application does not cause `BackgroundFetch` tasks to unregister. ([#8348](https://github.com/expo/expo/pull/8438) by [@mczernek](https://github.com/mczernek))
Expand Up @@ -8,12 +8,15 @@
<intent-filter>
<action android:name="expo.modules.taskManager.TaskBroadcastReceiver.INTENT_ACTION" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
mczernek marked this conversation as resolved.
Show resolved Hide resolved
</intent-filter>
</receiver>
<service
android:name=".TaskJobService"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />

<meta-data android:name="expo.modules.taskManager.oneAppId" android:value="true"/>
</application>
</manifest>