import android.net.VpnService;
import android.os.Build;
import android.os.Bundle;
+import android.os.Handler;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.security.KeyChain;
private volatile boolean mTerminate;
private volatile boolean mIsDisconnecting;
private volatile boolean mShowNotification;
+ private Handler mHandler;
private VpnStateService mService;
private final Object mServiceLock = new Object();
private final ServiceConnection mServiceConnection = new ServiceConnection() {
mLogFile = getFilesDir().getAbsolutePath() + File.separator + LOG_FILE;
mAppDir = getFilesDir().getAbsolutePath();
+ /* handler used to do changes in the main UI thread */
+ mHandler = new Handler();
+
mDataSource = new VpnProfileDataSource(this);
mDataSource.open();
/* use a separate thread as main thread for charon */
*/
private void addNotification()
{
- mShowNotification = true;
- startForeground(VPN_STATE_NOTIFICATION_ID, buildNotification(false));
+ mHandler.post(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ mShowNotification = true;
+ startForeground(VPN_STATE_NOTIFICATION_ID, buildNotification(false));
+ }
+ });
}
/**
*/
private void removeNotification()
{
- mShowNotification = false;
- stopForeground(true);
+ mHandler.post(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ mShowNotification = false;
+ stopForeground(true);
+ }
+ });
}
/**