Synchronization works, at least basically
This commit is contained in:
parent
7fe7ee42fc
commit
2a17bbe34b
@ -13,7 +13,7 @@ import android.os.Bundle;
|
|||||||
*/
|
*/
|
||||||
public class Authenticator extends AbstractAccountAuthenticator {
|
public class Authenticator extends AbstractAccountAuthenticator {
|
||||||
public static final String ACCOUNT_NAME = "Bitmessage";
|
public static final String ACCOUNT_NAME = "Bitmessage";
|
||||||
public static final String ACCOUNT_TYPE = "bitmessage.dissem.ch";
|
public static final String ACCOUNT_TYPE = "ch.dissem.bitmessage";
|
||||||
|
|
||||||
// Simple constructor
|
// Simple constructor
|
||||||
public Authenticator(Context context) {
|
public Authenticator(Context context) {
|
||||||
|
@ -37,9 +37,12 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
|
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
|
||||||
LOG.info("Synchronizing Bitmessage");
|
|
||||||
// If the Bitmessage context acts as a full node, synchronization isn't necessary
|
// If the Bitmessage context acts as a full node, synchronization isn't necessary
|
||||||
if (bmc.isRunning()) return;
|
if (bmc.isRunning()) {
|
||||||
|
LOG.info("Synchronization skipped, Abit is acting as a full node");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG.info("Synchronizing Bitmessage");
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
@ -63,7 +66,7 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter {
|
|||||||
} else {
|
} else {
|
||||||
port = 8444;
|
port = 8444;
|
||||||
}
|
}
|
||||||
long timeoutInSeconds = preferences.getInt("sync_timeout", 120);
|
long timeoutInSeconds = Long.parseLong(preferences.getString("sync_timeout", "120"));
|
||||||
try {
|
try {
|
||||||
LOG.info("Synchronization started");
|
LOG.info("Synchronization started");
|
||||||
bmc.synchronize(InetAddress.getByName(trustedNode), port, timeoutInSeconds, true);
|
bmc.synchronize(InetAddress.getByName(trustedNode), port, timeoutInSeconds, true);
|
||||||
|
@ -4,6 +4,9 @@ import android.app.Service;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ch.dissem.apps.abit.listener.MessageListener;
|
import ch.dissem.apps.abit.listener.MessageListener;
|
||||||
import ch.dissem.apps.abit.notification.NetworkNotification;
|
import ch.dissem.apps.abit.notification.NetworkNotification;
|
||||||
import ch.dissem.apps.abit.repository.AndroidInventory;
|
import ch.dissem.apps.abit.repository.AndroidInventory;
|
||||||
@ -22,6 +25,7 @@ import static ch.dissem.apps.abit.notification.NetworkNotification.ONGOING_NOTIF
|
|||||||
* onPerformSync().
|
* onPerformSync().
|
||||||
*/
|
*/
|
||||||
public class SyncService extends Service {
|
public class SyncService extends Service {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(SyncService.class);
|
||||||
// Storage for an instance of the sync adapter
|
// Storage for an instance of the sync adapter
|
||||||
private static SyncAdapter syncAdapter = null;
|
private static SyncAdapter syncAdapter = null;
|
||||||
// Object to use as a thread-safe lock
|
// Object to use as a thread-safe lock
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
|
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:accountType="bitmessage.dissem.ch"
|
android:accountType="ch.dissem.bitmessage"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:smallIcon="@mipmap/ic_launcher" />
|
android:smallIcon="@mipmap/ic_launcher" />
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<sync-adapter
|
<sync-adapter
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:contentAuthority="ch.dissem.bitmessage.provider"
|
android:contentAuthority="ch.dissem.apps.abit.provider"
|
||||||
android:accountType="ch.dissem.bitmessage"
|
android:accountType="ch.dissem.bitmessage"
|
||||||
android:userVisible="true"
|
android:userVisible="true"
|
||||||
android:supportsUploading="true"
|
android:supportsUploading="true"
|
||||||
|
Loading…
Reference in New Issue
Block a user