android: Replace usage of deprecated Handler() constructor

This commit is contained in:
Tobias Brunner 2021-07-12 15:38:22 +02:00
parent 93c494e295
commit dc351a30e1
3 changed files with 7 additions and 4 deletions

View File

@ -192,7 +192,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
mAppDir = getFilesDir().getAbsolutePath();
/* handler used to do changes in the main UI thread */
mHandler = new Handler();
mHandler = new Handler(getMainLooper());
mDataSource = new VpnProfileDataSource(this);
mDataSource.open();

View File

@ -22,6 +22,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
@ -107,7 +108,7 @@ public class VpnStateService extends Service
{
/* this handler allows us to notify listeners from the UI thread and
* not from the threads that actually report any state changes */
mHandler = new RetryHandler(this);
mHandler = new RetryHandler(getMainLooper(), this);
}
@Override
@ -536,8 +537,9 @@ public class VpnStateService extends Service
private static class RetryHandler extends Handler {
WeakReference<VpnStateService> mService;
public RetryHandler(VpnStateService service)
public RetryHandler(Looper looper, VpnStateService service)
{
super(looper);
mService = new WeakReference<>(service);
}

View File

@ -19,6 +19,7 @@ import android.content.Context;
import android.os.Bundle;
import android.os.FileObserver;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -55,7 +56,7 @@ public class LogFragment extends Fragment
mLogFilePath = getActivity().getFilesDir() + File.separator + CharonVpnService.LOG_FILE;
mLogHandler = new Handler();
mLogHandler = new Handler(Looper.getMainLooper());
mDirectoryObserver = new LogDirectoryObserver(getActivity().getFilesDir().getAbsolutePath());
}