Reducing service reloads by package installations.

This might help with instabilities reported in #20
This commit is contained in:
mar-v-in 2015-01-30 14:58:01 +01:00
parent c9700b7389
commit 8a2c05cf4a
2 changed files with 13 additions and 7 deletions

View file

@ -17,8 +17,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microg.nlp"
android:versionName="1.2.2"
android:versionCode="1202">
android:versionName="1.2.3"
android:versionCode="1203">
<uses-sdk
android:minSdkVersion="9"
@ -106,7 +106,6 @@
<receiver android:name="org.microg.nlp.PackageReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_UPGRADED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />

View file

@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import org.microg.nlp.geocode.AbstractGeocodeService;
import org.microg.nlp.location.AbstractLocationService;
@ -29,9 +30,15 @@ public class PackageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Intent received: " + intent);
Log.d(TAG, "Reloading location service...");
AbstractLocationService.reloadLocationService(context);
Log.d(TAG, "Reloading geocoding service...");
AbstractGeocodeService.reloadLocationService(context);
String packageName = intent.getData().getSchemeSpecificPart();
Preferences preferences = new Preferences(context);
if (preferences.getLocationBackends().contains(packageName)) {
Log.d(TAG, "Reloading location service for " + packageName);
AbstractLocationService.reloadLocationService(context);
}
if (preferences.getGeocoderBackends().contains(packageName)) {
Log.d(TAG, "Reloading geocoding service for " + packageName);
AbstractGeocodeService.reloadLocationService(context);
}
}
}