1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Fix ClassCastException in SyncthingService onCreate (fixes #1150)

This commit is contained in:
Catfriend1 2018-06-17 23:01:54 +02:00 committed by Audrius Butkevicius
parent b93da522e1
commit eb1266508f
5 changed files with 15 additions and 9 deletions

View file

@ -32,6 +32,7 @@ import com.google.common.collect.Sets;
import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.SyncthingApp;
import com.nutomic.syncthingandroid.service.SyncthingService;
import com.nutomic.syncthingandroid.service.SyncthingServiceBinder;
import com.nutomic.syncthingandroid.util.Util;
import java.io.File;
@ -156,7 +157,8 @@ public class FolderPickerActivity extends SyncthingActivity
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
super.onServiceConnected(componentName, iBinder);
getService().registerOnServiceStateChangeListener(this);
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
syncthingServiceBinder.getService().registerOnServiceStateChangeListener(this);
}
@Override

View file

@ -51,6 +51,7 @@ import com.nutomic.syncthingandroid.fragments.DrawerFragment;
import com.nutomic.syncthingandroid.fragments.FolderListFragment;
import com.nutomic.syncthingandroid.model.Options;
import com.nutomic.syncthingandroid.service.SyncthingService;
import com.nutomic.syncthingandroid.service.SyncthingServiceBinder;
import com.nutomic.syncthingandroid.util.Util;
import java.util.Date;
@ -286,9 +287,11 @@ public class MainActivity extends StateDialogActivity
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
super.onServiceConnected(componentName, iBinder);
getService().registerOnServiceStateChangeListener(this);
getService().registerOnServiceStateChangeListener(mFolderListFragment);
getService().registerOnServiceStateChangeListener(mDeviceListFragment);
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
SyncthingService syncthingService = syncthingServiceBinder.getService();
syncthingService.registerOnServiceStateChangeListener(this);
syncthingService.registerOnServiceStateChangeListener(mFolderListFragment);
syncthingService.registerOnServiceStateChangeListener(mDeviceListFragment);
}
/**

View file

@ -69,8 +69,8 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
SyncthingServiceBinder binder = (SyncthingServiceBinder) iBinder;
mSyncthingService = binder.getService();
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
mSyncthingService = syncthingServiceBinder.getService();
Stream.of(mServiceConnectedListeners).forEach(OnServiceConnectedListener::onServiceConnected);
mServiceConnectedListeners.clear();
}

View file

@ -23,6 +23,7 @@ import android.webkit.WebViewClient;
import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.service.Constants;
import com.nutomic.syncthingandroid.service.SyncthingService;
import com.nutomic.syncthingandroid.service.SyncthingServiceBinder;
import com.nutomic.syncthingandroid.util.ConfigXml;
import java.io.File;
@ -149,7 +150,8 @@ public class WebGuiActivity extends StateDialogActivity
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
super.onServiceConnected(componentName, iBinder);
getService().registerOnServiceStateChangeListener(this);
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
syncthingServiceBinder.getService().registerOnServiceStateChangeListener(this);
}
@Override

View file

@ -7,7 +7,6 @@ import android.content.SharedPreferences;
import android.Manifest;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.Log;
@ -388,7 +387,7 @@ public class SyncthingService extends Service {
}
@Override
public IBinder onBind(Intent intent) {
public SyncthingServiceBinder onBind(Intent intent) {
return mBinder;
}