Skip to content

Commit 87c627d

Browse files
authored
Merge pull request #52 from ivpn/GAA-48
[GAA-48] Fix notification issue after log out
2 parents cb4b993 + a560cee commit 87c627d

6 files changed

Lines changed: 15 additions & 20 deletions

File tree

app/src/main/java/net/ivpn/client/common/session/SessionController.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ class SessionController @Inject constructor(
157157
}
158158
if ((it.status == Responses.SESSION_NOT_FOUND)) {
159159
clearData()
160-
ViewModelCleaner()
161160
}
162161
}
163162
onUpdateError(null, errorResponse)

app/src/main/java/net/ivpn/client/common/utils/ComponentUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
along with the IVPN Android app. If not, see <https://www.gnu.org/licenses/>.
2323
*/
2424

25-
import android.content.Context;
2625
import android.util.Log;
2726

2827
import androidx.appcompat.app.AppCompatDelegate;
28+
import androidx.core.app.NotificationManagerCompat;
2929

3030
import net.ivpn.client.BuildConfig;
3131
import net.ivpn.client.IVPNApplication;
@@ -97,11 +97,13 @@ public void performBaseComponentsInit() {
9797
}
9898

9999
public void resetComponents() {
100+
networkController.finishAll();
100101
preference.removeAll();
101102
globalBehaviorController.finishAll();
102-
networkController.finishAll();
103103
updatesJobServiceUtil.clearUpdateJob(IVPNApplication.getApplication());
104104
updateHelper.skipUpdate();
105+
106+
NotificationManagerCompat.from(IVPNApplication.getApplication()).cancelAll();
105107
}
106108

107109
private void initProfile() {

app/src/main/java/net/ivpn/client/v2/killswitch/KillSwitchFragment.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ class KillSwitchFragment : Fragment(), KillSwitchViewModel.KillSwitchNavigator {
9090
}
9191
}
9292

93-
override fun onPause() {
94-
super.onPause()
95-
killSwitch.navigator = null
96-
}
97-
9893
private fun initToolbar() {
9994
val navController = findNavController()
10095
val appBarConfiguration = AppBarConfiguration(navController.graph)

app/src/main/java/net/ivpn/client/v2/network/NetworkViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ class NetworkViewModel @Inject internal constructor(
218218
}
219219

220220
override fun onNetworkSourceChanged(source: NetworkSource?) {
221-
Log.d("NetworkController", "onNetworkSourceChanged: source = $source")
221+
LOGGER.info("onNetworkSourceChanged: source = $source")
222222
if (source == null) {
223223
return
224224
}
225225
if (source == NetworkSource.WIFI) {
226-
Log.d("NetworkController", "onNetworkSourceChanged: ssid = " + source.ssid)
226+
LOGGER.info("NetworkController", "onNetworkSourceChanged: ssid = " + source.ssid)
227227
}
228228
networkSource.set(source)
229229
networkState.set(source.finalState)

app/src/main/java/net/ivpn/client/vpn/local/KillSwitchService.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
*/
2424

2525
import android.app.Notification;
26-
import android.app.NotificationManager;
2726
import android.app.PendingIntent;
28-
import android.content.Context;
2927
import android.content.Intent;
3028
import android.content.pm.PackageManager;
3129
import android.net.VpnService;
3230
import android.os.Build;
3331
import android.os.ParcelFileDescriptor;
32+
3433
import androidx.core.app.NotificationCompat;
34+
import androidx.core.app.NotificationManagerCompat;
3535
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
3636

3737
import net.ivpn.client.R;
@@ -51,7 +51,7 @@ public class KillSwitchService extends VpnService implements ServiceConstants {
5151
public static AtomicBoolean isRunning = new AtomicBoolean(false);
5252

5353
private ParcelFileDescriptor tun;
54-
private NotificationManager notificationManager;
54+
private NotificationManagerCompat notificationManager;
5555

5656
private int notificationId;
5757

@@ -65,7 +65,7 @@ public void onRevoke() {
6565
public void onCreate() {
6666
LOGGER.info("onCreate");
6767
super.onCreate();
68-
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
68+
notificationManager = NotificationManagerCompat.from(this);
6969
notificationId = ServiceConstants.KILL_SWITCH_CHANNEL.hashCode();
7070
}
7171

@@ -114,13 +114,12 @@ private int startKillSwitch() {
114114

115115
private int endService() {
116116
LOGGER.info("endService");
117-
notificationManager.cancelAll();
117+
notificationManager.cancel(notificationId);
118118
closeTun();
119119
stopForeground(true);
120120
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
121121
stopSelf(STOP_FOREGROUND_REMOVE);
122122
} else {
123-
notificationManager.cancel(notificationId);
124123
stopSelf();
125124
}
126125
return START_NOT_STICKY;

app/src/main/java/net/ivpn/client/vpn/local/WifiWatcherService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424

2525
import android.app.Notification;
26-
import android.app.NotificationManager;
2726
import android.app.PendingIntent;
2827
import android.app.Service;
2928
import android.content.BroadcastReceiver;
@@ -36,6 +35,7 @@
3635

3736
import androidx.annotation.Nullable;
3837
import androidx.core.app.NotificationCompat;
38+
import androidx.core.app.NotificationManagerCompat;
3939
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
4040

4141
import net.ivpn.client.IVPNApplication;
@@ -57,7 +57,7 @@ public class WifiWatcherService extends Service implements ServiceConstants {
5757
public static AtomicBoolean isRunning = new AtomicBoolean(false);
5858

5959
private WifiBroadcastReceiver receiver;
60-
private NotificationManager notificationManager;
60+
private NotificationManagerCompat notificationManager;
6161

6262
private int notificationId;
6363

@@ -74,7 +74,7 @@ public IBinder onBind(Intent intent) {
7474
public void onCreate() {
7575
LOGGER.info("onCreate");
7676
super.onCreate();
77-
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
77+
notificationManager = NotificationManagerCompat.from(this);
7878
notificationId = ServiceConstants.WIFI_WATCHER_CHANNEL.hashCode();
7979
}
8080

@@ -117,10 +117,10 @@ public void onDestroy() {
117117
private int endService() {
118118
LOGGER.info("endService");
119119
stopForeground(true);
120+
notificationManager.cancel(notificationId);
120121
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
121122
stopSelf(STOP_FOREGROUND_REMOVE);
122123
} else {
123-
notificationManager.cancel(notificationId);
124124
stopSelf();
125125
}
126126
return START_NOT_STICKY;

0 commit comments

Comments
 (0)