11using System . Collections . Generic ;
22using System . IO ;
33using Android . Webkit ;
4+ using AndroidX . Work ;
45using ComputerUtils . Android ;
56using QuestAppVersionSwitcher . Core ;
67
@@ -12,6 +13,7 @@ public class QAVSWebViewClient : WebViewClient
1213 CoreService . coreVars . serverPort + "/inject.js';document.head.appendChild(tag)" ;
1314
1415 public string injectedJs = "" ;
16+ private bool isLoggingOut = false ;
1517
1618 // Grab token
1719 public override void OnPageFinished ( WebView view , string url )
@@ -27,10 +29,45 @@ public override void OnPageFinished(WebView view, string url)
2729 view . EvaluateJavascript ( injectedJs . Replace ( "{0}" , CoreService . coreVars . serverPort . ToString ( ) ) , null ) ;
2830 }
2931
32+
33+ if ( ! url . ToLower ( ) . Contains ( "logout" ) )
34+ {
35+ string cookie = CookieManager . Instance . GetCookie ( url ) ;
36+ // extract cookie oc_ac_at
37+ if ( cookie != null )
38+ {
39+ string [ ] cookies = cookie . Split ( ';' ) ;
40+ foreach ( string c in cookies )
41+ {
42+ if ( c . Contains ( "oc_ac_at" ) )
43+ {
44+ string token = c . Split ( '=' ) [ 1 ] ;
45+ if ( token . Length > 15 )
46+ {
47+ CoreService . browser . LoadUrl ( "http://127.0.0.1:" + CoreService . coreVars . serverPort + "?token=" + token ) ;
48+ }
49+ break ;
50+ }
51+ }
52+ }
53+ }
54+ else
55+ {
56+ isLoggingOut = true ;
57+ }
58+
59+ if ( url . Contains ( "auth.meta.com" ) && isLoggingOut )
60+ {
61+ // go to QAVS UI once logged out
62+ CoreService . browser . LoadUrl ( "http://127.0.0.1:" + CoreService . coreVars . serverPort ) ;
63+ isLoggingOut = false ;
64+ }
65+
66+
3067 if ( url . ToLower ( ) . StartsWith ( "https://auth.meta.com/settings" ) )
3168 {
3269 // redirect to oculus page
33- view . LoadUrl ( "https://oculus.com/experiences/quest " ) ;
70+ view . LoadUrl ( "https://developer. oculus.com/manage " ) ;
3471 }
3572 }
3673
0 commit comments