android: Replace usage of deprecated Handler() constructor
This commit is contained in:
+1
-1
@@ -192,7 +192,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
mAppDir = getFilesDir().getAbsolutePath();
|
mAppDir = getFilesDir().getAbsolutePath();
|
||||||
|
|
||||||
/* handler used to do changes in the main UI thread */
|
/* handler used to do changes in the main UI thread */
|
||||||
mHandler = new Handler();
|
mHandler = new Handler(getMainLooper());
|
||||||
|
|
||||||
mDataSource = new VpnProfileDataSource(this);
|
mDataSource = new VpnProfileDataSource(this);
|
||||||
mDataSource.open();
|
mDataSource.open();
|
||||||
|
|||||||
+4
-2
@@ -22,6 +22,7 @@ import android.os.Binder;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemClock;
|
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
|
/* this handler allows us to notify listeners from the UI thread and
|
||||||
* not from the threads that actually report any state changes */
|
* not from the threads that actually report any state changes */
|
||||||
mHandler = new RetryHandler(this);
|
mHandler = new RetryHandler(getMainLooper(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -536,8 +537,9 @@ public class VpnStateService extends Service
|
|||||||
private static class RetryHandler extends Handler {
|
private static class RetryHandler extends Handler {
|
||||||
WeakReference<VpnStateService> mService;
|
WeakReference<VpnStateService> mService;
|
||||||
|
|
||||||
public RetryHandler(VpnStateService service)
|
public RetryHandler(Looper looper, VpnStateService service)
|
||||||
{
|
{
|
||||||
|
super(looper);
|
||||||
mService = new WeakReference<>(service);
|
mService = new WeakReference<>(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.FileObserver;
|
import android.os.FileObserver;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -55,7 +56,7 @@ public class LogFragment extends Fragment
|
|||||||
|
|
||||||
mLogFilePath = getActivity().getFilesDir() + File.separator + CharonVpnService.LOG_FILE;
|
mLogFilePath = getActivity().getFilesDir() + File.separator + CharonVpnService.LOG_FILE;
|
||||||
|
|
||||||
mLogHandler = new Handler();
|
mLogHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
mDirectoryObserver = new LogDirectoryObserver(getActivity().getFilesDir().getAbsolutePath());
|
mDirectoryObserver = new LogDirectoryObserver(getActivity().getFilesDir().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user