Skip to content

Commit

Permalink
Refactor the onStartCommand method to use switch statement for action…
Browse files Browse the repository at this point in the history
… handling and improve readability.
  • Loading branch information
Epic-R-R authored and markpash committed Jun 15, 2024
1 parent 9e764c3 commit f8b4ea1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/src/main/java/org/bepass/oblivion/OblivionVpnService.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,18 @@ public synchronized int onStartCommand(Intent intent, int flags, int startId) {
return START_NOT_STICKY;
}

if (action.equals(FLAG_VPN_START)) {
start();
return START_STICKY;
}
switch (action) {
case FLAG_VPN_START:
start();
return START_STICKY;

if (action.equals(FLAG_VPN_STOP)) {
onRevoke();
return START_NOT_STICKY;
case FLAG_VPN_STOP:
onRevoke();
return START_NOT_STICKY;

default:
return START_NOT_STICKY;
}
return START_NOT_STICKY;
}

@Override
Expand Down

0 comments on commit f8b4ea1

Please sign in to comment.