1
- using Newtonsoft . Json ;
2
- using SteamAuth ;
3
- using System ;
1
+ using System ;
4
2
using System . Collections . Generic ;
5
3
using System . Diagnostics ;
6
- using System . Linq ;
7
- using System . Text ;
8
- using System . Threading ;
9
- using System . Threading . Tasks ;
10
4
using System . IO ;
5
+ using System . Linq ;
11
6
using System . Text . RegularExpressions ;
7
+ using System . Threading ;
8
+ using Newtonsoft . Json ;
9
+ using SteamAuth ;
12
10
13
11
namespace Steam_Desktop_Authenticator
14
12
{
@@ -20,6 +18,8 @@ public class PhoneBridge
20
18
private Process console ;
21
19
private ManualResetEvent mreOutput = new ManualResetEvent ( false ) ;
22
20
21
+ private int adbVersion ;
22
+
23
23
public delegate void BridgeOutput ( string msg ) ;
24
24
public event BridgeOutput PhoneBridgeError ;
25
25
public event BridgeOutput OutputLog ;
@@ -76,6 +76,8 @@ public SteamGuardAccount ExtractSteamGuardAccount(string id = "*", bool skipChec
76
76
if ( ! skipChecks ) AppendToLog ( "" ) ;
77
77
InitConsole ( ) ; // Init the console
78
78
79
+ GetAdbVersion ( ) ;
80
+
79
81
if ( ! skipChecks )
80
82
{
81
83
OnOutputLog ( "Checking requirements..." ) ;
@@ -154,7 +156,7 @@ private string GetDeviceID(bool root)
154
156
console . OutputDataReceived += f1 ;
155
157
156
158
if ( root )
157
- ExecuteCommand ( $ "adb shell su -c 'sed -n 3p /data/data/$STEAMAPP/shared_prefs/steam.uuid.xml' & echo Done") ;
159
+ ExecuteCommand ( "adb shell su -c 'sed -n 3p /data/data/$STEAMAPP/shared_prefs/steam.uuid.xml' & echo Done" ) ;
158
160
else
159
161
ExecuteCommand ( "adb shell \" cat /sdcard/steamauth/apps/$STEAMAPP/sp/steam.uuid.xml\" & echo Done" ) ;
160
162
mre . Wait ( ) ;
@@ -366,7 +368,12 @@ private bool SteamAppInstalled()
366
368
367
369
console . OutputDataReceived += f1 ;
368
370
369
- ExecuteCommand ( "adb shell \" su -c 'cd /data/data/com.valvesoftware.android.steam.community && echo Yes'\" " ) ;
371
+ if ( UseLegacyAdbMethod ( ) ) {
372
+ ExecuteCommand ( "adb shell \" su -c 'cd /data/data/com.valvesoftware.android.steam.community && echo Yes'\" " ) ;
373
+ }
374
+ else {
375
+ ExecuteCommand ( "adb shell -n \" su -c 'cd /data/data/com.valvesoftware.android.steam.community && echo Yes'\" " ) ;
376
+ }
370
377
mre . Wait ( ) ;
371
378
372
379
console . OutputDataReceived -= f1 ;
@@ -389,13 +396,52 @@ private bool IsRooted()
389
396
390
397
console . OutputDataReceived += f1 ;
391
398
392
- ExecuteCommand ( "adb shell su -c 'echo Yes'" ) ;
399
+ if ( UseLegacyAdbMethod ( ) ) {
400
+ ExecuteCommand ( "adb shell su -c 'echo Yes'" ) ;
401
+ }
402
+ else {
403
+ ExecuteCommand ( "adb shell -n su -c 'echo Yes'" ) ;
404
+ }
405
+
393
406
mre . Wait ( ) ;
394
407
395
408
console . OutputDataReceived -= f1 ;
396
409
397
410
return root ;
398
411
}
412
+
413
+ private void GetAdbVersion ( )
414
+ {
415
+ OnOutputLog ( "Checking ADB version" ) ;
416
+ string versionString = "" ;
417
+ ManualResetEventSlim mre = new ManualResetEventSlim ( ) ;
418
+ DataReceivedEventHandler f1 = ( sender , e ) =>
419
+ {
420
+ if ( e . Data . Contains ( ">@" ) || e . Data == "" || e . Data . Contains ( "Revision" ) ) return ;
421
+
422
+ versionString = new string ( e . Data . ToCharArray ( ) . Where ( char . IsDigit ) . ToArray ( ) ) ;
423
+ mre . Set ( ) ;
424
+ } ;
425
+
426
+ console . OutputDataReceived += f1 ;
427
+
428
+ ExecuteCommand ( "adb version" ) ;
429
+ mre . Wait ( ) ;
430
+
431
+ console . OutputDataReceived -= f1 ;
432
+
433
+ try {
434
+ adbVersion = int . Parse ( versionString ) ;
435
+ OnOutputLog ( "ADB version: " + adbVersion ) ;
436
+ }
437
+ catch ( Exception exception ) {
438
+ OnOutputLog ( "Error getting ADB version" ) ;
439
+ }
440
+ }
441
+
442
+ private bool UseLegacyAdbMethod ( ) {
443
+ return adbVersion < 1036 ;
444
+ }
399
445
400
446
401
447
public delegate void AccountsDelegate ( List < string > accounts ) ;
0 commit comments