diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs index 1685a27..598da93 100644 --- a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs +++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs @@ -138,28 +138,31 @@ public async Task DumpScreenWinRTAsyncTest() public async Task ClickAsyncTest() { DummyAdbClient client = new(); - client.Commands["shell:input tap 100 100"] = @"java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission - at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)"; + client.Commands["shell:input tap 100 100"] = + """ + java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission + at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) + at android.os.Parcel.createException(Parcel.java:2357) + at android.os.Parcel.readException(Parcel.java:2340) + at android.os.Parcel.readException(Parcel.java:2282) + at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) + at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) + at com.android.commands.input.Input.injectMotionEvent(Input.java:397) + at com.android.commands.input.Input.access$200(Input.java:41) + at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) + at com.android.commands.input.Input$InputTap.run(Input.java:217) + at com.android.commands.input.Input.onRun(Input.java:107) + at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) + at com.android.commands.input.Input.main(Input.java:71) + at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) + at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) + Caused by: android.os.RemoteException: Remote stack trace: + at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) + at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) + at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) + at android.os.Binder.execTransactInternal(Binder.java:1165) + at android.os.Binder.execTransact(Binder.java:1134) + """; JavaException exception = await Assert.ThrowsAsync(() => new DeviceClient(client, Device).ClickAsync(100, 100)); @@ -168,27 +171,30 @@ at android.os.Binder.execTransactInternal(Binder.java:1165) Assert.Equal("SecurityException", exception.JavaName); Assert.Equal("Injecting to another application requires INJECT_EVENTS permission", exception.Message); - Assert.Equal(@" at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)", exception.JavaStackTrace, ignoreLineEndingDifferences: true); + Assert.Equal( + """ + at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) + at android.os.Parcel.createException(Parcel.java:2357) + at android.os.Parcel.readException(Parcel.java:2340) + at android.os.Parcel.readException(Parcel.java:2282) + at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) + at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) + at com.android.commands.input.Input.injectMotionEvent(Input.java:397) + at com.android.commands.input.Input.access$200(Input.java:41) + at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) + at com.android.commands.input.Input$InputTap.run(Input.java:217) + at com.android.commands.input.Input.onRun(Input.java:107) + at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) + at com.android.commands.input.Input.main(Input.java:71) + at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) + at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) + Caused by: android.os.RemoteException: Remote stack trace: + at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) + at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) + at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) + at android.os.Binder.execTransactInternal(Binder.java:1165) + at android.os.Binder.execTransact(Binder.java:1134) + """, exception.JavaStackTrace, ignoreLineEndingDifferences: true); } /// @@ -285,8 +291,11 @@ public async Task IsAppRunningAsyncTest(string response, bool expected) public async Task IsAppInForegroundAsyncTest(string packageName, bool expected) { DummyAdbClient client = new(); - client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = @" mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} - mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5}"; + client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = + """ + mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} + mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5} + """; bool result = await new DeviceClient(client, Device).IsAppInForegroundAsync(packageName); @@ -305,8 +314,11 @@ public async Task IsAppInForegroundAsyncTest(string packageName, bool expected) public async Task GetAppStatusAsyncTest(string packageName, string response, AppStatus expected) { DummyAdbClient client = new(); - client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = @" mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} - mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5}"; + client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = + """ + mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} + mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5} + """; client.Commands[$"shell:pidof {packageName}"] = response; AppStatus result = await new DeviceClient(client, Device).GetAppStatusAsync(packageName); @@ -327,8 +339,11 @@ public async Task GetAppStatusAsyncTest(string packageName, string response, App public async Task GetAppStatusForegroundAsyncTest(string packageName, AppStatus expected) { DummyAdbClient client = new(); - client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = @" mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} - mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5}"; + client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = + """ + mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} + mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5} + """; AppStatus result = await new DeviceClient(client, Device).GetAppStatusAsync(packageName); diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs index 953ae08..23cb8b5 100644 --- a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs +++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs @@ -224,28 +224,31 @@ public void DumpScreenWinRTTest() public void ClickTest() { DummyAdbClient client = new(); - client.Commands["shell:input tap 100 100"] = @"java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission - at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)"; + client.Commands["shell:input tap 100 100"] = + """ + java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission + at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) + at android.os.Parcel.createException(Parcel.java:2357) + at android.os.Parcel.readException(Parcel.java:2340) + at android.os.Parcel.readException(Parcel.java:2282) + at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) + at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) + at com.android.commands.input.Input.injectMotionEvent(Input.java:397) + at com.android.commands.input.Input.access$200(Input.java:41) + at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) + at com.android.commands.input.Input$InputTap.run(Input.java:217) + at com.android.commands.input.Input.onRun(Input.java:107) + at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) + at com.android.commands.input.Input.main(Input.java:71) + at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) + at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) + Caused by: android.os.RemoteException: Remote stack trace: + at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) + at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) + at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) + at android.os.Binder.execTransactInternal(Binder.java:1165) + at android.os.Binder.execTransact(Binder.java:1134) + """; JavaException exception = Assert.Throws(() => new DeviceClient(client, Device).Click(100, 100)); @@ -254,27 +257,30 @@ at android.os.Binder.execTransactInternal(Binder.java:1165) Assert.Equal("SecurityException", exception.JavaName); Assert.Equal("Injecting to another application requires INJECT_EVENTS permission", exception.Message); - Assert.Equal(@" at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) - at android.os.Parcel.createException(Parcel.java:2357) - at android.os.Parcel.readException(Parcel.java:2340) - at android.os.Parcel.readException(Parcel.java:2282) - at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) - at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) - at com.android.commands.input.Input.injectMotionEvent(Input.java:397) - at com.android.commands.input.Input.access$200(Input.java:41) - at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) - at com.android.commands.input.Input$InputTap.run(Input.java:217) - at com.android.commands.input.Input.onRun(Input.java:107) - at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) - at com.android.commands.input.Input.main(Input.java:71) - at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) - at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) -Caused by: android.os.RemoteException: Remote stack trace: - at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) - at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) - at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) - at android.os.Binder.execTransactInternal(Binder.java:1165) - at android.os.Binder.execTransact(Binder.java:1134)", exception.JavaStackTrace, ignoreLineEndingDifferences: true); + Assert.Equal( + """ + at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) + at android.os.Parcel.createException(Parcel.java:2357) + at android.os.Parcel.readException(Parcel.java:2340) + at android.os.Parcel.readException(Parcel.java:2282) + at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:946) + at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907) + at com.android.commands.input.Input.injectMotionEvent(Input.java:397) + at com.android.commands.input.Input.access$200(Input.java:41) + at com.android.commands.input.Input$InputTap.sendTap(Input.java:223) + at com.android.commands.input.Input$InputTap.run(Input.java:217) + at com.android.commands.input.Input.onRun(Input.java:107) + at com.android.internal.os.BaseCommand.run(BaseCommand.java:60) + at com.android.commands.input.Input.main(Input.java:71) + at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) + at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:438) + Caused by: android.os.RemoteException: Remote stack trace: + at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:677) + at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:651) + at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:430) + at android.os.Binder.execTransactInternal(Binder.java:1165) + at android.os.Binder.execTransact(Binder.java:1134) + """, exception.JavaStackTrace, ignoreLineEndingDifferences: true); } /// @@ -371,8 +377,11 @@ public void IsAppRunningTest(string response, bool expected) public void IsAppInForegroundTest(string packageName, bool expected) { DummyAdbClient client = new(); - client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = @" mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} - mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5}"; + client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = + """ + mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} + mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5} + """; bool result = new DeviceClient(client, Device).IsAppInForeground(packageName); @@ -391,8 +400,11 @@ public void IsAppInForegroundTest(string packageName, bool expected) public void GetAppStatusTest(string packageName, string response, AppStatus expected) { DummyAdbClient client = new(); - client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = @" mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} - mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5}"; + client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = + """ + mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} + mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5} + """; client.Commands[$"shell:pidof {packageName}"] = response; AppStatus result = new DeviceClient(client, Device).GetAppStatus(packageName); @@ -413,8 +425,11 @@ public void GetAppStatusTest(string packageName, string response, AppStatus expe public void GetAppStatusForegroundTest(string packageName, AppStatus expected) { DummyAdbClient client = new(); - client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = @" mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} - mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5}"; + client.Commands["shell:dumpsys activity activities | grep mResumedActivity"] = + """ + mResumedActivity: ActivityRecord{1f5309a u0 com.android.settings/.homepage.SettingsHomepageActivity t61029} + mResumedActivity: ActivityRecord{896cc3 u0 app.lawnchair/.LawnchairLauncher t5} + """; AppStatus result = new DeviceClient(client, Device).GetAppStatus(packageName); diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.Async.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.Async.cs index 49dd392..0851b39 100644 --- a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.Async.cs +++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.Async.cs @@ -214,232 +214,241 @@ public async Task UninstallPackageAsyncTests() /// Tests the method. /// [Theory] - [InlineData(@"Activity Resolver Table: - Non-Data Actions: - com.android.providers.contacts.DUMP_DATABASE: - 310a0bd8 com.android.providers.contacts/.debug.ContactsDumpActivity - -Receiver Resolver Table: - Schemes: - package: - 31f30b31 com.android.providers.contacts/.PackageIntentReceiver (4 filters) - -Registered ContentProviders: - com.android.providers.contacts/.debug.DumpFileProvider: - Provider{2b000d84 com.android.providers.contacts/.debug.DumpFileProvider} - -ContentProvider Authorities: - [com.android.voicemail]: - Provider{316ea633 com.android.providers.contacts/.VoicemailContentProvider} - applicationInfo=ApplicationInfo{1327df0 com.android.providers.contacts} - -Key Set Manager: - [com.android.providers.contacts] - Signing KeySets: 3 - -Packages: - Package [com.android.providers.contacts] (3d5205d5): - versionCode=22 targetSdk=22 - versionName=5.1-eng.buildbot.20151117.204057 - splits=[base] - -Shared users: - SharedUser [android.uid.shared] (3341dee): - userId=10002 gids=[3003, 1028, 1015] - grantedPermissions: - android.permission.WRITE_SETTINGS", 22, "5.1-eng.buildbot.20151117.204057", "com.example")] - [InlineData(@"Activity Resolver Table: - Schemes: - package: - 423fa100 jp.co.cyberagent.stf/.IconActivity filter 427ae628 - - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_IDENTIFY: - 423fa4d8 jp.co.cyberagent.stf/.IdentityActivity filter 427c76a8 - -Service Resolver Table: - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_STOP: - 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 - jp.co.cyberagent.stf.ACTION_START: - 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 - -Packages: - Package [jp.co.cyberagent.stf] (428c8c10): - userId=10153 gids=[3003, 1015, 1023, 1028] - sharedUser=null - pkg=Package{42884220 jp.co.cyberagent.stf} - codePath=/data/app/jp.co.cyberagent.stf-1.apk - resourcePath=/data/app/jp.co.cyberagent.stf-1.apk - nativeLibraryPath=/data/app-lib/jp.co.cyberagent.stf-1 - versionCode=4 - applicationInfo=ApplicationInfo{4287f2e0 jp.co.cyberagent.stf} - flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - versionName=2.1.0 - dataDir=/data/data/jp.co.cyberagent.stf - targetSdk=22 - supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] - timeStamp=2017-09-08 15:52:21 - firstInstallTime=2017-09-08 15:52:21 - lastUpdateTime=2017-09-08 15:52:21 - signatures=PackageSignatures{419a7e60 [41bb3628]} - permissionsFixed=true haveGids=true installStatus=1 - pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - packageOnlyForOwnerUser: false - componentsOnlyForOwerUser: - User 0: installed=true stopped=true notLaunched=true enabled=0 - grantedPermissions: - android.permission.READ_EXTERNAL_STORAGE - android.permission.READ_PHONE_STATE - android.permission.DISABLE_KEYGUARD - android.permission.WRITE_EXTERNAL_STORAGE - android.permission.INTERNET - android.permission.CHANGE_WIFI_STATE - android.permission.MANAGE_ACCOUNTS - android.permission.ACCESS_WIFI_STATE - android.permission.GET_ACCOUNTS - android.permission.ACCESS_NETWORK_STATE - android.permission.WAKE_LOCK -mPackagesOnlyForOwnerUser: - package : com.android.mms - package : com.android.phone - package : com.sec.knox.containeragent -mComponentsOnlyForOwnerUser: - package : com.android.contacts - cmp : com.android.contacts.activities.DialtactsActivity - -mEnforceCopyingLibPackages: - -mSkippingApks: - -mSettings.mPackages: -the number of packages is 223 -mPackages: -the number of packages is 223 -End!!!!", 4, "2.1.0", "jp.co.cyberagent.stf")] - [InlineData(@"Activity Resolver Table: - Schemes: - package: - de681a8 jp.co.cyberagent.stf/.IconActivity filter 2863eca - Action: ""jp.co.cyberagent.stf.ACTION_ICON"" - Category: ""android.intent.category.DEFAULT"" - Scheme: ""package"" - - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_IDENTIFY: - 69694c1 jp.co.cyberagent.stf/.IdentityActivity filter 30bda35 - Action: ""jp.co.cyberagent.stf.ACTION_IDENTIFY"" - Category: ""android.intent.category.DEFAULT"" - -Service Resolver Table: - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_STOP: - db65466 jp.co.cyberagent.stf/.Service filter 7c0646c - Action: ""jp.co.cyberagent.stf.ACTION_START"" - Action: ""jp.co.cyberagent.stf.ACTION_STOP"" - Category: ""android.intent.category.DEFAULT"" - jp.co.cyberagent.stf.ACTION_START: - db65466 jp.co.cyberagent.stf/.Service filter 7c0646c - Action: ""jp.co.cyberagent.stf.ACTION_START"" - Action: ""jp.co.cyberagent.stf.ACTION_STOP"" - Category: ""android.intent.category.DEFAULT"" - -Key Set Manager: - [jp.co.cyberagent.stf] - Signing KeySets: 57 - -Packages: - Package [jp.co.cyberagent.stf] (13d33a7): - userId=11261 - pkg=Package{6f61054 jp.co.cyberagent.stf} - codePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== - resourcePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== - legacyNativeLibraryDir=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/lib - primaryCpuAbi=null - secondaryCpuAbi=null - versionCode=4 minSdk=9 targetSdk=22 - versionName=2.1.0 - splits=[base] - apkSigningVersion=2 - applicationInfo=ApplicationInfo{4b6bbfd jp.co.cyberagent.stf} - flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - dataDir=/data/user/0/jp.co.cyberagent.stf - supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] - timeStamp=2017-09-08 22:06:05 - firstInstallTime=2017-09-08 22:06:07 - lastUpdateTime=2017-09-08 22:06:07 - signatures=PackageSignatures{1c350f2 [37b7ecb5]} - installPermissionsFixed=true installStatus=1 - pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - requested permissions: - android.permission.DISABLE_KEYGUARD - android.permission.READ_PHONE_STATE - android.permission.WAKE_LOCK - android.permission.INTERNET - android.permission.ACCESS_NETWORK_STATE - android.permission.WRITE_EXTERNAL_STORAGE - android.permission.GET_ACCOUNTS - android.permission.MANAGE_ACCOUNTS - android.permission.CHANGE_WIFI_STATE - android.permission.ACCESS_WIFI_STATE - android.permission.READ_EXTERNAL_STORAGE - install permissions: - android.permission.MANAGE_ACCOUNTS: granted=true - android.permission.INTERNET: granted=true - android.permission.READ_EXTERNAL_STORAGE: granted=true - android.permission.READ_PHONE_STATE: granted=true - android.permission.CHANGE_WIFI_STATE: granted=true - android.permission.ACCESS_NETWORK_STATE: granted=true - android.permission.DISABLE_KEYGUARD: granted=true - android.permission.GET_ACCOUNTS: granted=true - android.permission.WRITE_EXTERNAL_STORAGE: granted=true - android.permission.ACCESS_WIFI_STATE: granted=true - android.permission.WAKE_LOCK: granted=true - User 0: ceDataInode=409220 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false - gids=[3003] - runtime permissions: - User 10: ceDataInode=0 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false - gids=[3003] - runtime permissions: - -Package Changes: - Sequence number=45 - User 0: - seq=6, package=com.google.android.gms - seq=9, package=be.brusselsairport.appyflight - seq=11, package=com.android.vending - seq=13, package=app.qrcode - seq=15, package=com.android.chrome - seq=16, package=com.google.android.apps.docs - seq=17, package=com.google.android.inputmethod.latin - seq=18, package=com.google.android.music - seq=20, package=com.google.android.apps.walletnfcrel - seq=21, package=com.google.android.youtube - seq=22, package=com.google.android.calendar - seq=44, package=jp.co.cyberagent.stf - User 10: - seq=10, package=com.android.vending - seq=14, package=com.google.android.apps.walletnfcrel - seq=15, package=com.android.chrome - seq=16, package=com.google.android.apps.docs - seq=17, package=com.google.android.inputmethod.latin - seq=18, package=com.google.android.music - seq=19, package=com.google.android.youtube - seq=22, package=com.google.android.calendar - seq=44, package=jp.co.cyberagent.stf - - -Dexopt state: - [jp.co.cyberagent.stf] - Instruction Set: arm64 - path: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/base.apk - status: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/oat/arm64/base.odex[status=kOatUpToDate, compilati - on_filter=quicken] - - -Compiler stats: - [jp.co.cyberagent.stf] - base.apk - 1084", 4, "2.1.0", "jp.co.cyberagent.stf")] + [InlineData( + """ + Activity Resolver Table: + Non-Data Actions: + com.android.providers.contacts.DUMP_DATABASE: + 310a0bd8 com.android.providers.contacts/.debug.ContactsDumpActivity + + Receiver Resolver Table: + Schemes: + package: + 31f30b31 com.android.providers.contacts/.PackageIntentReceiver (4 filters) + + Registered ContentProviders: + com.android.providers.contacts/.debug.DumpFileProvider: + Provider{2b000d84 com.android.providers.contacts/.debug.DumpFileProvider} + + ContentProvider Authorities: + [com.android.voicemail]: + Provider{316ea633 com.android.providers.contacts/.VoicemailContentProvider} + applicationInfo=ApplicationInfo{1327df0 com.android.providers.contacts} + + Key Set Manager: + [com.android.providers.contacts] + Signing KeySets: 3 + + Packages: + Package [com.android.providers.contacts] (3d5205d5): + versionCode=22 targetSdk=22 + versionName=5.1-eng.buildbot.20151117.204057 + splits=[base] + + Shared users: + SharedUser [android.uid.shared] (3341dee): + userId=10002 gids=[3003, 1028, 1015] + grantedPermissions: + android.permission.WRITE_SETTINGS + """, 22, "5.1-eng.buildbot.20151117.204057", "com.example")] + [InlineData( + """ + Activity Resolver Table: + Schemes: + package: + 423fa100 jp.co.cyberagent.stf/.IconActivity filter 427ae628 + + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_IDENTIFY: + 423fa4d8 jp.co.cyberagent.stf/.IdentityActivity filter 427c76a8 + + Service Resolver Table: + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_STOP: + 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 + jp.co.cyberagent.stf.ACTION_START: + 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 + + Packages: + Package [jp.co.cyberagent.stf] (428c8c10): + userId=10153 gids=[3003, 1015, 1023, 1028] + sharedUser=null + pkg=Package{42884220 jp.co.cyberagent.stf} + codePath=/data/app/jp.co.cyberagent.stf-1.apk + resourcePath=/data/app/jp.co.cyberagent.stf-1.apk + nativeLibraryPath=/data/app-lib/jp.co.cyberagent.stf-1 + versionCode=4 + applicationInfo=ApplicationInfo{4287f2e0 jp.co.cyberagent.stf} + flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + versionName=2.1.0 + dataDir=/data/data/jp.co.cyberagent.stf + targetSdk=22 + supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] + timeStamp=2017-09-08 15:52:21 + firstInstallTime=2017-09-08 15:52:21 + lastUpdateTime=2017-09-08 15:52:21 + signatures=PackageSignatures{419a7e60 [41bb3628]} + permissionsFixed=true haveGids=true installStatus=1 + pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + packageOnlyForOwnerUser: false + componentsOnlyForOwerUser: + User 0: installed=true stopped=true notLaunched=true enabled=0 + grantedPermissions: + android.permission.READ_EXTERNAL_STORAGE + android.permission.READ_PHONE_STATE + android.permission.DISABLE_KEYGUARD + android.permission.WRITE_EXTERNAL_STORAGE + android.permission.INTERNET + android.permission.CHANGE_WIFI_STATE + android.permission.MANAGE_ACCOUNTS + android.permission.ACCESS_WIFI_STATE + android.permission.GET_ACCOUNTS + android.permission.ACCESS_NETWORK_STATE + android.permission.WAKE_LOCK + mPackagesOnlyForOwnerUser: + package : com.android.mms + package : com.android.phone + package : com.sec.knox.containeragent + mComponentsOnlyForOwnerUser: + package : com.android.contacts + cmp : com.android.contacts.activities.DialtactsActivity + + mEnforceCopyingLibPackages: + + mSkippingApks: + + mSettings.mPackages: + the number of packages is 223 + mPackages: + the number of packages is 223 + End!!!! + """, 4, "2.1.0", "jp.co.cyberagent.stf")] + [InlineData( + """ + Activity Resolver Table: + Schemes: + package: + de681a8 jp.co.cyberagent.stf/.IconActivity filter 2863eca + Action: "jp.co.cyberagent.stf.ACTION_ICON" + Category: "android.intent.category.DEFAULT" + Scheme: "package" + + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_IDENTIFY: + 69694c1 jp.co.cyberagent.stf/.IdentityActivity filter 30bda35 + Action: "jp.co.cyberagent.stf.ACTION_IDENTIFY" + Category: "android.intent.category.DEFAULT" + + Service Resolver Table: + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_STOP: + db65466 jp.co.cyberagent.stf/.Service filter 7c0646c + Action: "jp.co.cyberagent.stf.ACTION_START" + Action: "jp.co.cyberagent.stf.ACTION_STOP" + Category: "android.intent.category.DEFAULT" + jp.co.cyberagent.stf.ACTION_START: + db65466 jp.co.cyberagent.stf/.Service filter 7c0646c + Action: "jp.co.cyberagent.stf.ACTION_START" + Action: "jp.co.cyberagent.stf.ACTION_STOP" + Category: "android.intent.category.DEFAULT" + + Key Set Manager: + [jp.co.cyberagent.stf] + Signing KeySets: 57 + + Packages: + Package [jp.co.cyberagent.stf] (13d33a7): + userId=11261 + pkg=Package{6f61054 jp.co.cyberagent.stf} + codePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== + resourcePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== + legacyNativeLibraryDir=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/lib + primaryCpuAbi=null + secondaryCpuAbi=null + versionCode=4 minSdk=9 targetSdk=22 + versionName=2.1.0 + splits=[base] + apkSigningVersion=2 + applicationInfo=ApplicationInfo{4b6bbfd jp.co.cyberagent.stf} + flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + dataDir=/data/user/0/jp.co.cyberagent.stf + supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] + timeStamp=2017-09-08 22:06:05 + firstInstallTime=2017-09-08 22:06:07 + lastUpdateTime=2017-09-08 22:06:07 + signatures=PackageSignatures{1c350f2 [37b7ecb5]} + installPermissionsFixed=true installStatus=1 + pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + requested permissions: + android.permission.DISABLE_KEYGUARD + android.permission.READ_PHONE_STATE + android.permission.WAKE_LOCK + android.permission.INTERNET + android.permission.ACCESS_NETWORK_STATE + android.permission.WRITE_EXTERNAL_STORAGE + android.permission.GET_ACCOUNTS + android.permission.MANAGE_ACCOUNTS + android.permission.CHANGE_WIFI_STATE + android.permission.ACCESS_WIFI_STATE + android.permission.READ_EXTERNAL_STORAGE + install permissions: + android.permission.MANAGE_ACCOUNTS: granted=true + android.permission.INTERNET: granted=true + android.permission.READ_EXTERNAL_STORAGE: granted=true + android.permission.READ_PHONE_STATE: granted=true + android.permission.CHANGE_WIFI_STATE: granted=true + android.permission.ACCESS_NETWORK_STATE: granted=true + android.permission.DISABLE_KEYGUARD: granted=true + android.permission.GET_ACCOUNTS: granted=true + android.permission.WRITE_EXTERNAL_STORAGE: granted=true + android.permission.ACCESS_WIFI_STATE: granted=true + android.permission.WAKE_LOCK: granted=true + User 0: ceDataInode=409220 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false + gids=[3003] + runtime permissions: + User 10: ceDataInode=0 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false + gids=[3003] + runtime permissions: + + Package Changes: + Sequence number=45 + User 0: + seq=6, package=com.google.android.gms + seq=9, package=be.brusselsairport.appyflight + seq=11, package=com.android.vending + seq=13, package=app.qrcode + seq=15, package=com.android.chrome + seq=16, package=com.google.android.apps.docs + seq=17, package=com.google.android.inputmethod.latin + seq=18, package=com.google.android.music + seq=20, package=com.google.android.apps.walletnfcrel + seq=21, package=com.google.android.youtube + seq=22, package=com.google.android.calendar + seq=44, package=jp.co.cyberagent.stf + User 10: + seq=10, package=com.android.vending + seq=14, package=com.google.android.apps.walletnfcrel + seq=15, package=com.android.chrome + seq=16, package=com.google.android.apps.docs + seq=17, package=com.google.android.inputmethod.latin + seq=18, package=com.google.android.music + seq=19, package=com.google.android.youtube + seq=22, package=com.google.android.calendar + seq=44, package=jp.co.cyberagent.stf + + + Dexopt state: + [jp.co.cyberagent.stf] + Instruction Set: arm64 + path: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/base.apk + status: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/oat/arm64/base.odex[status=kOatUpToDate, compilati + on_filter=quicken] + + + Compiler stats: + [jp.co.cyberagent.stf] + base.apk - 1084 + """, 4, "2.1.0", "jp.co.cyberagent.stf")] public async Task GetPackageVersionAsyncTest(string command, int versionCode, string versionName, string packageName) { DummyAdbClient adbClient = new(); @@ -463,29 +472,28 @@ public async Task ListProcessesAsyncTest() { DummyAdbClient adbClient = new(); - adbClient.Commands[@"shell:SDK=""$(/system/bin/getprop ro.build.version.sdk)"" -if [ $SDK -lt 24 ] -then - /system/bin/ls /proc/ -else - /system/bin/ls -1 /proc/ -fi".Replace("\r\n", "\n")] = -@"1 -2 -3 -acpi -asound"; + adbClient.Commands["shell:SDK=\"$(/system/bin/getprop ro.build.version.sdk)\"\nif [ $SDK -lt 24 ]; then\n/system/bin/ls /proc/\nelse\n/system/bin/ls -1 /proc/\nfi"] = + """ + 1 + 2 + 3 + acpi + asound + """; adbClient.Commands["shell:cat /proc/1/stat /proc/2/stat /proc/3/stat"] = -@"1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 -2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + """ + 1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 + 2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + """; adbClient.Commands["shell:cat /proc/1/cmdline /proc/1/stat /proc/2/cmdline /proc/2/stat /proc/3/cmdline /proc/3/stat"] = -@" -1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 + """ + 1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 -2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + 3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + """; List processes = await adbClient.ListProcessesAsync(Device); diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs index 5e33655..d435585 100644 --- a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs +++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceExtensionsTests.cs @@ -184,232 +184,241 @@ public void UninstallPackageTests() /// Tests the method. /// [Theory] - [InlineData(@"Activity Resolver Table: - Non-Data Actions: - com.android.providers.contacts.DUMP_DATABASE: - 310a0bd8 com.android.providers.contacts/.debug.ContactsDumpActivity - -Receiver Resolver Table: - Schemes: - package: - 31f30b31 com.android.providers.contacts/.PackageIntentReceiver (4 filters) - -Registered ContentProviders: - com.android.providers.contacts/.debug.DumpFileProvider: - Provider{2b000d84 com.android.providers.contacts/.debug.DumpFileProvider} - -ContentProvider Authorities: - [com.android.voicemail]: - Provider{316ea633 com.android.providers.contacts/.VoicemailContentProvider} - applicationInfo=ApplicationInfo{1327df0 com.android.providers.contacts} - -Key Set Manager: - [com.android.providers.contacts] - Signing KeySets: 3 - -Packages: - Package [com.android.providers.contacts] (3d5205d5): - versionCode=22 targetSdk=22 - versionName=5.1-eng.buildbot.20151117.204057 - splits=[base] - -Shared users: - SharedUser [android.uid.shared] (3341dee): - userId=10002 gids=[3003, 1028, 1015] - grantedPermissions: - android.permission.WRITE_SETTINGS", 22, "5.1-eng.buildbot.20151117.204057", "com.example")] - [InlineData(@"Activity Resolver Table: - Schemes: - package: - 423fa100 jp.co.cyberagent.stf/.IconActivity filter 427ae628 - - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_IDENTIFY: - 423fa4d8 jp.co.cyberagent.stf/.IdentityActivity filter 427c76a8 - -Service Resolver Table: - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_STOP: - 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 - jp.co.cyberagent.stf.ACTION_START: - 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 - -Packages: - Package [jp.co.cyberagent.stf] (428c8c10): - userId=10153 gids=[3003, 1015, 1023, 1028] - sharedUser=null - pkg=Package{42884220 jp.co.cyberagent.stf} - codePath=/data/app/jp.co.cyberagent.stf-1.apk - resourcePath=/data/app/jp.co.cyberagent.stf-1.apk - nativeLibraryPath=/data/app-lib/jp.co.cyberagent.stf-1 - versionCode=4 - applicationInfo=ApplicationInfo{4287f2e0 jp.co.cyberagent.stf} - flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - versionName=2.1.0 - dataDir=/data/data/jp.co.cyberagent.stf - targetSdk=22 - supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] - timeStamp=2017-09-08 15:52:21 - firstInstallTime=2017-09-08 15:52:21 - lastUpdateTime=2017-09-08 15:52:21 - signatures=PackageSignatures{419a7e60 [41bb3628]} - permissionsFixed=true haveGids=true installStatus=1 - pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - packageOnlyForOwnerUser: false - componentsOnlyForOwerUser: - User 0: installed=true stopped=true notLaunched=true enabled=0 - grantedPermissions: - android.permission.READ_EXTERNAL_STORAGE - android.permission.READ_PHONE_STATE - android.permission.DISABLE_KEYGUARD - android.permission.WRITE_EXTERNAL_STORAGE - android.permission.INTERNET - android.permission.CHANGE_WIFI_STATE - android.permission.MANAGE_ACCOUNTS - android.permission.ACCESS_WIFI_STATE - android.permission.GET_ACCOUNTS - android.permission.ACCESS_NETWORK_STATE - android.permission.WAKE_LOCK -mPackagesOnlyForOwnerUser: - package : com.android.mms - package : com.android.phone - package : com.sec.knox.containeragent -mComponentsOnlyForOwnerUser: - package : com.android.contacts - cmp : com.android.contacts.activities.DialtactsActivity - -mEnforceCopyingLibPackages: - -mSkippingApks: - -mSettings.mPackages: -the number of packages is 223 -mPackages: -the number of packages is 223 -End!!!!", 4, "2.1.0", "jp.co.cyberagent.stf")] - [InlineData(@"Activity Resolver Table: - Schemes: - package: - de681a8 jp.co.cyberagent.stf/.IconActivity filter 2863eca - Action: ""jp.co.cyberagent.stf.ACTION_ICON"" - Category: ""android.intent.category.DEFAULT"" - Scheme: ""package"" - - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_IDENTIFY: - 69694c1 jp.co.cyberagent.stf/.IdentityActivity filter 30bda35 - Action: ""jp.co.cyberagent.stf.ACTION_IDENTIFY"" - Category: ""android.intent.category.DEFAULT"" - -Service Resolver Table: - Non-Data Actions: - jp.co.cyberagent.stf.ACTION_STOP: - db65466 jp.co.cyberagent.stf/.Service filter 7c0646c - Action: ""jp.co.cyberagent.stf.ACTION_START"" - Action: ""jp.co.cyberagent.stf.ACTION_STOP"" - Category: ""android.intent.category.DEFAULT"" - jp.co.cyberagent.stf.ACTION_START: - db65466 jp.co.cyberagent.stf/.Service filter 7c0646c - Action: ""jp.co.cyberagent.stf.ACTION_START"" - Action: ""jp.co.cyberagent.stf.ACTION_STOP"" - Category: ""android.intent.category.DEFAULT"" - -Key Set Manager: - [jp.co.cyberagent.stf] - Signing KeySets: 57 - -Packages: - Package [jp.co.cyberagent.stf] (13d33a7): - userId=11261 - pkg=Package{6f61054 jp.co.cyberagent.stf} - codePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== - resourcePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== - legacyNativeLibraryDir=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/lib - primaryCpuAbi=null - secondaryCpuAbi=null - versionCode=4 minSdk=9 targetSdk=22 - versionName=2.1.0 - splits=[base] - apkSigningVersion=2 - applicationInfo=ApplicationInfo{4b6bbfd jp.co.cyberagent.stf} - flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - dataDir=/data/user/0/jp.co.cyberagent.stf - supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] - timeStamp=2017-09-08 22:06:05 - firstInstallTime=2017-09-08 22:06:07 - lastUpdateTime=2017-09-08 22:06:07 - signatures=PackageSignatures{1c350f2 [37b7ecb5]} - installPermissionsFixed=true installStatus=1 - pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] - requested permissions: - android.permission.DISABLE_KEYGUARD - android.permission.READ_PHONE_STATE - android.permission.WAKE_LOCK - android.permission.INTERNET - android.permission.ACCESS_NETWORK_STATE - android.permission.WRITE_EXTERNAL_STORAGE - android.permission.GET_ACCOUNTS - android.permission.MANAGE_ACCOUNTS - android.permission.CHANGE_WIFI_STATE - android.permission.ACCESS_WIFI_STATE - android.permission.READ_EXTERNAL_STORAGE - install permissions: - android.permission.MANAGE_ACCOUNTS: granted=true - android.permission.INTERNET: granted=true - android.permission.READ_EXTERNAL_STORAGE: granted=true - android.permission.READ_PHONE_STATE: granted=true - android.permission.CHANGE_WIFI_STATE: granted=true - android.permission.ACCESS_NETWORK_STATE: granted=true - android.permission.DISABLE_KEYGUARD: granted=true - android.permission.GET_ACCOUNTS: granted=true - android.permission.WRITE_EXTERNAL_STORAGE: granted=true - android.permission.ACCESS_WIFI_STATE: granted=true - android.permission.WAKE_LOCK: granted=true - User 0: ceDataInode=409220 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false - gids=[3003] - runtime permissions: - User 10: ceDataInode=0 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false - gids=[3003] - runtime permissions: - -Package Changes: - Sequence number=45 - User 0: - seq=6, package=com.google.android.gms - seq=9, package=be.brusselsairport.appyflight - seq=11, package=com.android.vending - seq=13, package=app.qrcode - seq=15, package=com.android.chrome - seq=16, package=com.google.android.apps.docs - seq=17, package=com.google.android.inputmethod.latin - seq=18, package=com.google.android.music - seq=20, package=com.google.android.apps.walletnfcrel - seq=21, package=com.google.android.youtube - seq=22, package=com.google.android.calendar - seq=44, package=jp.co.cyberagent.stf - User 10: - seq=10, package=com.android.vending - seq=14, package=com.google.android.apps.walletnfcrel - seq=15, package=com.android.chrome - seq=16, package=com.google.android.apps.docs - seq=17, package=com.google.android.inputmethod.latin - seq=18, package=com.google.android.music - seq=19, package=com.google.android.youtube - seq=22, package=com.google.android.calendar - seq=44, package=jp.co.cyberagent.stf - - -Dexopt state: - [jp.co.cyberagent.stf] - Instruction Set: arm64 - path: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/base.apk - status: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/oat/arm64/base.odex[status=kOatUpToDate, compilati - on_filter=quicken] - - -Compiler stats: - [jp.co.cyberagent.stf] - base.apk - 1084", 4, "2.1.0", "jp.co.cyberagent.stf")] + [InlineData( + """ + Activity Resolver Table: + Non-Data Actions: + com.android.providers.contacts.DUMP_DATABASE: + 310a0bd8 com.android.providers.contacts/.debug.ContactsDumpActivity + + Receiver Resolver Table: + Schemes: + package: + 31f30b31 com.android.providers.contacts/.PackageIntentReceiver (4 filters) + + Registered ContentProviders: + com.android.providers.contacts/.debug.DumpFileProvider: + Provider{2b000d84 com.android.providers.contacts/.debug.DumpFileProvider} + + ContentProvider Authorities: + [com.android.voicemail]: + Provider{316ea633 com.android.providers.contacts/.VoicemailContentProvider} + applicationInfo=ApplicationInfo{1327df0 com.android.providers.contacts} + + Key Set Manager: + [com.android.providers.contacts] + Signing KeySets: 3 + + Packages: + Package [com.android.providers.contacts] (3d5205d5): + versionCode=22 targetSdk=22 + versionName=5.1-eng.buildbot.20151117.204057 + splits=[base] + + Shared users: + SharedUser [android.uid.shared] (3341dee): + userId=10002 gids=[3003, 1028, 1015] + grantedPermissions: + android.permission.WRITE_SETTINGS + """, 22, "5.1-eng.buildbot.20151117.204057", "com.example")] + [InlineData( + """ + Activity Resolver Table: + Schemes: + package: + 423fa100 jp.co.cyberagent.stf/.IconActivity filter 427ae628 + + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_IDENTIFY: + 423fa4d8 jp.co.cyberagent.stf/.IdentityActivity filter 427c76a8 + + Service Resolver Table: + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_STOP: + 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 + jp.co.cyberagent.stf.ACTION_START: + 423fc3d8 jp.co.cyberagent.stf/.Service filter 427e4ca8 + + Packages: + Package [jp.co.cyberagent.stf] (428c8c10): + userId=10153 gids=[3003, 1015, 1023, 1028] + sharedUser=null + pkg=Package{42884220 jp.co.cyberagent.stf} + codePath=/data/app/jp.co.cyberagent.stf-1.apk + resourcePath=/data/app/jp.co.cyberagent.stf-1.apk + nativeLibraryPath=/data/app-lib/jp.co.cyberagent.stf-1 + versionCode=4 + applicationInfo=ApplicationInfo{4287f2e0 jp.co.cyberagent.stf} + flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + versionName=2.1.0 + dataDir=/data/data/jp.co.cyberagent.stf + targetSdk=22 + supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] + timeStamp=2017-09-08 15:52:21 + firstInstallTime=2017-09-08 15:52:21 + lastUpdateTime=2017-09-08 15:52:21 + signatures=PackageSignatures{419a7e60 [41bb3628]} + permissionsFixed=true haveGids=true installStatus=1 + pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + packageOnlyForOwnerUser: false + componentsOnlyForOwerUser: + User 0: installed=true stopped=true notLaunched=true enabled=0 + grantedPermissions: + android.permission.READ_EXTERNAL_STORAGE + android.permission.READ_PHONE_STATE + android.permission.DISABLE_KEYGUARD + android.permission.WRITE_EXTERNAL_STORAGE + android.permission.INTERNET + android.permission.CHANGE_WIFI_STATE + android.permission.MANAGE_ACCOUNTS + android.permission.ACCESS_WIFI_STATE + android.permission.GET_ACCOUNTS + android.permission.ACCESS_NETWORK_STATE + android.permission.WAKE_LOCK + mPackagesOnlyForOwnerUser: + package : com.android.mms + package : com.android.phone + package : com.sec.knox.containeragent + mComponentsOnlyForOwnerUser: + package : com.android.contacts + cmp : com.android.contacts.activities.DialtactsActivity + + mEnforceCopyingLibPackages: + + mSkippingApks: + + mSettings.mPackages: + the number of packages is 223 + mPackages: + the number of packages is 223 + End!!!! + """, 4, "2.1.0", "jp.co.cyberagent.stf")] + [InlineData( + """ + Activity Resolver Table: + Schemes: + package: + de681a8 jp.co.cyberagent.stf/.IconActivity filter 2863eca + Action: "jp.co.cyberagent.stf.ACTION_ICON" + Category: "android.intent.category.DEFAULT" + Scheme: "package" + + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_IDENTIFY: + 69694c1 jp.co.cyberagent.stf/.IdentityActivity filter 30bda35 + Action: "jp.co.cyberagent.stf.ACTION_IDENTIFY" + Category: "android.intent.category.DEFAULT" + + Service Resolver Table: + Non-Data Actions: + jp.co.cyberagent.stf.ACTION_STOP: + db65466 jp.co.cyberagent.stf/.Service filter 7c0646c + Action: "jp.co.cyberagent.stf.ACTION_START" + Action: "jp.co.cyberagent.stf.ACTION_STOP" + Category: "android.intent.category.DEFAULT" + jp.co.cyberagent.stf.ACTION_START: + db65466 jp.co.cyberagent.stf/.Service filter 7c0646c + Action: "jp.co.cyberagent.stf.ACTION_START" + Action: "jp.co.cyberagent.stf.ACTION_STOP" + Category: "android.intent.category.DEFAULT" + + Key Set Manager: + [jp.co.cyberagent.stf] + Signing KeySets: 57 + + Packages: + Package [jp.co.cyberagent.stf] (13d33a7): + userId=11261 + pkg=Package{6f61054 jp.co.cyberagent.stf} + codePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== + resourcePath=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg== + legacyNativeLibraryDir=/data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/lib + primaryCpuAbi=null + secondaryCpuAbi=null + versionCode=4 minSdk=9 targetSdk=22 + versionName=2.1.0 + splits=[base] + apkSigningVersion=2 + applicationInfo=ApplicationInfo{4b6bbfd jp.co.cyberagent.stf} + flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + dataDir=/data/user/0/jp.co.cyberagent.stf + supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] + timeStamp=2017-09-08 22:06:05 + firstInstallTime=2017-09-08 22:06:07 + lastUpdateTime=2017-09-08 22:06:07 + signatures=PackageSignatures{1c350f2 [37b7ecb5]} + installPermissionsFixed=true installStatus=1 + pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] + requested permissions: + android.permission.DISABLE_KEYGUARD + android.permission.READ_PHONE_STATE + android.permission.WAKE_LOCK + android.permission.INTERNET + android.permission.ACCESS_NETWORK_STATE + android.permission.WRITE_EXTERNAL_STORAGE + android.permission.GET_ACCOUNTS + android.permission.MANAGE_ACCOUNTS + android.permission.CHANGE_WIFI_STATE + android.permission.ACCESS_WIFI_STATE + android.permission.READ_EXTERNAL_STORAGE + install permissions: + android.permission.MANAGE_ACCOUNTS: granted=true + android.permission.INTERNET: granted=true + android.permission.READ_EXTERNAL_STORAGE: granted=true + android.permission.READ_PHONE_STATE: granted=true + android.permission.CHANGE_WIFI_STATE: granted=true + android.permission.ACCESS_NETWORK_STATE: granted=true + android.permission.DISABLE_KEYGUARD: granted=true + android.permission.GET_ACCOUNTS: granted=true + android.permission.WRITE_EXTERNAL_STORAGE: granted=true + android.permission.ACCESS_WIFI_STATE: granted=true + android.permission.WAKE_LOCK: granted=true + User 0: ceDataInode=409220 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false + gids=[3003] + runtime permissions: + User 10: ceDataInode=0 installed=true hidden=false suspended=false stopped=true notLaunched=true enabled=0 instant=false + gids=[3003] + runtime permissions: + + Package Changes: + Sequence number=45 + User 0: + seq=6, package=com.google.android.gms + seq=9, package=be.brusselsairport.appyflight + seq=11, package=com.android.vending + seq=13, package=app.qrcode + seq=15, package=com.android.chrome + seq=16, package=com.google.android.apps.docs + seq=17, package=com.google.android.inputmethod.latin + seq=18, package=com.google.android.music + seq=20, package=com.google.android.apps.walletnfcrel + seq=21, package=com.google.android.youtube + seq=22, package=com.google.android.calendar + seq=44, package=jp.co.cyberagent.stf + User 10: + seq=10, package=com.android.vending + seq=14, package=com.google.android.apps.walletnfcrel + seq=15, package=com.android.chrome + seq=16, package=com.google.android.apps.docs + seq=17, package=com.google.android.inputmethod.latin + seq=18, package=com.google.android.music + seq=19, package=com.google.android.youtube + seq=22, package=com.google.android.calendar + seq=44, package=jp.co.cyberagent.stf + + + Dexopt state: + [jp.co.cyberagent.stf] + Instruction Set: arm64 + path: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/base.apk + status: /data/app/jp.co.cyberagent.stf-Q3jXaNJMy6AIVndbPuclbg==/oat/arm64/base.odex[status=kOatUpToDate, compilati + on_filter=quicken] + + + Compiler stats: + [jp.co.cyberagent.stf] + base.apk - 1084 + """, 4, "2.1.0", "jp.co.cyberagent.stf")] public void GetPackageVersionTest(string command, int versionCode, string versionName, string packageName) { DummyAdbClient adbClient = new(); @@ -433,29 +442,28 @@ public void ListProcessesTest() { DummyAdbClient adbClient = new(); - adbClient.Commands[@"shell:SDK=""$(/system/bin/getprop ro.build.version.sdk)"" -if [ $SDK -lt 24 ] -then - /system/bin/ls /proc/ -else - /system/bin/ls -1 /proc/ -fi".Replace("\r\n", "\n")] = -@"1 -2 -3 -acpi -asound"; + adbClient.Commands["shell:SDK=\"$(/system/bin/getprop ro.build.version.sdk)\"\nif [ $SDK -lt 24 ]; then\n/system/bin/ls /proc/\nelse\n/system/bin/ls -1 /proc/\nfi"] = + """ + 1 + 2 + 3 + acpi + asound + """; adbClient.Commands["shell:cat /proc/1/stat /proc/2/stat /proc/3/stat"] = -@"1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 -2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + """ + 1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 + 2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + """; adbClient.Commands["shell:cat /proc/1/cmdline /proc/1/stat /proc/2/cmdline /proc/2/stat /proc/3/cmdline /proc/3/stat"] = -@" -1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 + """ + 1 (init) S 0 0 0 0 -1 1077944576 2680 83280 0 179 0 67 16 39 20 0 1 0 2 17735680 143 18446744073709551615 134512640 135145076 4288071392 4288070744 134658736 0 0 0 65536 18446744071580117077 0 0 17 1 0 0 0 0 0 135152736 135165080 142131200 4288073690 4288073696 4288073696 4288073714 0 -2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 2 (kthreadd) S 0 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 2 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579254310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + 3 (ksoftirqd/0) S 2 0 0 0 -1 69238848 0 0 0 0 0 23 0 0 20 0 1 0 7 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744071579284070 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + """; List processes = adbClient.ListProcesses(Device); diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/AndroidProcessTests.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/AndroidProcessTests.cs index 17cb901..9adb61c 100644 --- a/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/AndroidProcessTests.cs +++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/AndroidProcessTests.cs @@ -20,7 +20,7 @@ public class AndroidProcessTests [Fact] public void ParseTest() { - string line = @"1 (init) S 0 0 0 0 -1 1077936384 1467 168323 0 38 12 141 863 249 20 0 1 0 4 2535424 245 4294967295 1 1 0 0 0 0 0 0 65536 4294967295 0 0 17 3 0 0 0 0 0 0 0 0 0 0 0 0 0"; + string line = "1 (init) S 0 0 0 0 -1 1077936384 1467 168323 0 38 12 141 863 249 20 0 1 0 4 2535424 245 4294967295 1 1 0 0 0 0 0 0 65536 4294967295 0 0 17 3 0 0 0 0 0 0 0 0 0 0 0 0 0"; AndroidProcess process = AndroidProcess.Parse(line); @@ -61,7 +61,7 @@ public void ParseTooFewPartsTest() => [Fact] public void ParseWithSpaceTest() { - string line = @"194(irq/432-mdm sta) S 2 0 0 0 - 1 2130240 0 0 0 0 0 1 0 0 - 51 0 1 0 172 0 0 4294967295 0 0 0 0 0 0 0 2147483647 0 4294967295 0 0 17 1 50 1 0 0 0 0 0 0 0 0 0 0 0"; + string line = "194(irq/432-mdm sta) S 2 0 0 0 - 1 2130240 0 0 0 0 0 1 0 0 - 51 0 1 0 172 0 0 4294967295 0 0 0 0 0 0 0 2147483647 0 4294967295 0 0 17 1 50 1 0 0 0 0 0 0 0 0 0 0 0"; AndroidProcess process = AndroidProcess.Parse(line); diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs index 3798d82..7463316 100644 --- a/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs +++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs @@ -14,9 +14,12 @@ public void ListPropertiesTest() }; DummyAdbClient client = new(); - client.Commands["shell:/system/bin/getprop"] = @"[init.svc.BGW]: [running] -[init.svc.MtkCodecService]: [running] -[init.svc.bootanim]: [stopped]"; + client.Commands["shell:/system/bin/getprop"] = + """ + [init.svc.BGW]: [running] + [init.svc.MtkCodecService]: [running] + [init.svc.bootanim]: [stopped] + """; Dictionary properties = client.GetProperties(device); Assert.NotNull(properties); diff --git a/AdvancedSharpAdbClient.Tests/Exceptions/JavaExceptionTests.cs b/AdvancedSharpAdbClient.Tests/Exceptions/JavaExceptionTests.cs index a449deb..7e21407 100644 --- a/AdvancedSharpAdbClient.Tests/Exceptions/JavaExceptionTests.cs +++ b/AdvancedSharpAdbClient.Tests/Exceptions/JavaExceptionTests.cs @@ -25,79 +25,91 @@ public void SerializationConstructorTest() => [Fact] public void ParseLineTest() { - string line = @"java.lang.SecurityException: Caller has no access to session 936013062 - at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) - at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) - at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) - at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) - at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) - at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) - at android.os.ShellCommand.exec(ShellCommand.java:44) - at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) - at android.os.Binder.shellCommand(Binder.java:940) - at android.os.Binder.onTransact(Binder.java:824) - at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) - at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) - at android.os.Binder.execTransactInternal(Binder.java:1170) - at android.os.Binder.execTransact(Binder.java:1134)"; + string line = + """ + java.lang.SecurityException: Caller has no access to session 936013062 + at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) + at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) + at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) + at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) + at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) + at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) + at android.os.ShellCommand.exec(ShellCommand.java:44) + at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) + at android.os.Binder.shellCommand(Binder.java:940) + at android.os.Binder.onTransact(Binder.java:824) + at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) + at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) + at android.os.Binder.execTransactInternal(Binder.java:1170) + at android.os.Binder.execTransact(Binder.java:1134) + """; JavaException javaException = JavaException.Parse(line); Assert.Equal("SecurityException", javaException.JavaName); Assert.Equal("Caller has no access to session 936013062", javaException.Message); - Assert.Equal(@" at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) - at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) - at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) - at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) - at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) - at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) - at android.os.ShellCommand.exec(ShellCommand.java:44) - at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) - at android.os.Binder.shellCommand(Binder.java:940) - at android.os.Binder.onTransact(Binder.java:824) - at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) - at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) - at android.os.Binder.execTransactInternal(Binder.java:1170) - at android.os.Binder.execTransact(Binder.java:1134)", javaException.JavaStackTrace, ignoreLineEndingDifferences: true); + Assert.Equal( + """ + at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) + at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) + at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) + at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) + at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) + at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) + at android.os.ShellCommand.exec(ShellCommand.java:44) + at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) + at android.os.Binder.shellCommand(Binder.java:940) + at android.os.Binder.onTransact(Binder.java:824) + at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) + at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) + at android.os.Binder.execTransactInternal(Binder.java:1170) + at android.os.Binder.execTransact(Binder.java:1134) + """, javaException.JavaStackTrace, ignoreLineEndingDifferences: true); } [Fact] public void ParseLinesTest() { - string[] lines = @"java.lang.SecurityException: Caller has no access to session 936013062 - at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) - at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) - at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) - at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) - at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) - at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) - at android.os.ShellCommand.exec(ShellCommand.java:44) - at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) - at android.os.Binder.shellCommand(Binder.java:940) - at android.os.Binder.onTransact(Binder.java:824) - at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) - at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) - at android.os.Binder.execTransactInternal(Binder.java:1170) - at android.os.Binder.execTransact(Binder.java:1134)".Split(Extensions.NewLineSeparator); + string[] lines = + """ + java.lang.SecurityException: Caller has no access to session 936013062 + at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) + at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) + at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) + at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) + at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) + at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) + at android.os.ShellCommand.exec(ShellCommand.java:44) + at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) + at android.os.Binder.shellCommand(Binder.java:940) + at android.os.Binder.onTransact(Binder.java:824) + at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) + at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) + at android.os.Binder.execTransactInternal(Binder.java:1170) + at android.os.Binder.execTransact(Binder.java:1134) + """.Split(Extensions.NewLineSeparator); JavaException javaException = JavaException.Parse(lines); Assert.Equal("SecurityException", javaException.JavaName); Assert.Equal("Caller has no access to session 936013062", javaException.Message); - Assert.Equal(@" at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) - at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) - at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) - at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) - at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) - at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) - at android.os.ShellCommand.exec(ShellCommand.java:44) - at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) - at android.os.Binder.shellCommand(Binder.java:940) - at android.os.Binder.onTransact(Binder.java:824) - at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) - at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) - at android.os.Binder.execTransactInternal(Binder.java:1170) - at android.os.Binder.execTransact(Binder.java:1134)", javaException.JavaStackTrace, ignoreLineEndingDifferences: true); + Assert.Equal( + """ + at com.android.server.pm.PackageInstallerService.openSessionInternal(PackageInstallerService.java:849) + at com.android.server.pm.PackageInstallerService.openSession(PackageInstallerService.java:839) + at com.android.server.pm.PackageManagerShellCommand.doWriteSplit(PackageManagerShellCommand.java:3270) + at com.android.server.pm.PackageManagerShellCommand.runInstallWrite(PackageManagerShellCommand.java:1450) + at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:202) + at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) + at android.os.ShellCommand.exec(ShellCommand.java:44) + at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22344) + at android.os.Binder.shellCommand(Binder.java:940) + at android.os.Binder.onTransact(Binder.java:824) + at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4644) + at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4513) + at android.os.Binder.execTransactInternal(Binder.java:1170) + at android.os.Binder.execTransact(Binder.java:1134) + """, javaException.JavaStackTrace, ignoreLineEndingDifferences: true); } } } diff --git a/AdvancedSharpAdbClient.Tests/Models/AdbCommandLineStatusTests.cs b/AdvancedSharpAdbClient.Tests/Models/AdbCommandLineStatusTests.cs index 98773a6..3d2fc85 100644 --- a/AdvancedSharpAdbClient.Tests/Models/AdbCommandLineStatusTests.cs +++ b/AdvancedSharpAdbClient.Tests/Models/AdbCommandLineStatusTests.cs @@ -27,9 +27,12 @@ public void GetVersionFromOutputTest() public void ToStringTest() { AdbCommandLineStatus status = new(new Version(1, 0, 41), "34.0.4-android-tools", "/data/data/com.termux/files/usr/bin/adb"); - Assert.Equal(@"Android Debug Bridge version 1.0.41 -Version 34.0.4-android-tools -Installed as /data/data/com.termux/files/usr/bin/adb", status.ToString(), ignoreLineEndingDifferences: true); + Assert.Equal( + """ + Android Debug Bridge version 1.0.41 + Version 34.0.4-android-tools + Installed as /data/data/com.termux/files/usr/bin/adb + """, status.ToString(), ignoreLineEndingDifferences: true); } } } diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs index 603a9d3..5454d5e 100644 --- a/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs +++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs @@ -458,14 +458,14 @@ public virtual bool Equals(DeviceClient? other) => #endif #if NET7_0_OR_GREATER - [GeneratedRegex("<\\?xml(.?)*")] + [GeneratedRegex(@"<\?xml(.?)*")] private static partial Regex GetXmlRegex(); #else /// /// Gets a for parsing the xml. /// /// The for parsing the xml. - private static Regex GetXmlRegex() => new("<\\?xml(.?)*"); + private static Regex GetXmlRegex() => new(@"<\?xml(.?)*"); #endif } } diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs index 85068a4..f530785 100644 --- a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs +++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs @@ -598,13 +598,11 @@ public static async Task> ListProcessesAsync(this IAdbClien // on the API level. We do the branching on the device (inside a shell script) to avoid roundtrips. // This if/then/else syntax was tested on Android 2.x, 4.x and 7 ConsoleOutputReceiver receiver = new(); - await client.ExecuteShellCommandAsync(device, @"SDK=""$(/system/bin/getprop ro.build.version.sdk)"" -if [ $SDK -lt 24 ] -then - /system/bin/ls /proc/ -else - /system/bin/ls -1 /proc/ -fi".Replace("\r\n", "\n"), receiver, cancellationToken).ConfigureAwait(false); + await client.ExecuteShellCommandAsync( + device, + "SDK=\"$(/system/bin/getprop ro.build.version.sdk)\"\nif [ $SDK -lt 24 ]; then\n/system/bin/ls /proc/\nelse\n/system/bin/ls -1 /proc/\nfi", + receiver, + cancellationToken).ConfigureAwait(false); List pids = []; diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs index efe07b7..842cdba 100644 --- a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs +++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs @@ -517,13 +517,10 @@ public static List ListProcesses(this IAdbClient client, DeviceD // on the API level. We do the branching on the device (inside a shell script) to avoid roundtrips. // This if/then/else syntax was tested on Android 2.x, 4.x and 7 ConsoleOutputReceiver receiver = new(); - client.ExecuteShellCommand(device, @"SDK=""$(/system/bin/getprop ro.build.version.sdk)"" -if [ $SDK -lt 24 ] -then - /system/bin/ls /proc/ -else - /system/bin/ls -1 /proc/ -fi".Replace("\r\n", "\n"), receiver); + client.ExecuteShellCommand( + device, + "SDK=\"$(/system/bin/getprop ro.build.version.sdk)\"\nif [ $SDK -lt 24 ]; then\n/system/bin/ls /proc/\nelse\n/system/bin/ls -1 /proc/\nfi", + receiver); List pids = []; diff --git a/AdvancedSharpAdbClient/DeviceCommands/LinuxPath.cs b/AdvancedSharpAdbClient/DeviceCommands/LinuxPath.cs index 035d7db..1368f40 100644 --- a/AdvancedSharpAdbClient/DeviceCommands/LinuxPath.cs +++ b/AdvancedSharpAdbClient/DeviceCommands/LinuxPath.cs @@ -24,7 +24,7 @@ public static partial class LinuxPath /// /// Pattern to escape filenames for shell command consumption. /// - private const string EscapePattern = "([\\\\()*+?\"'#/\\s])"; + private const string EscapePattern = """([\\()*+?"'#/\s])"""; /// /// The of s which are invalid in a path. @@ -193,7 +193,7 @@ public static bool IsPathRooted(string path) /// /// The path. /// The entry name. - public static string Escape(string path) => EscapeRegex().Replace(path, new MatchEvaluator(m => m.Result("\\\\$1"))); + public static string Escape(string path) => EscapeRegex().Replace(path, new MatchEvaluator(m => m.Result(@"\\$1"))); /// /// Quotes the specified path. diff --git a/AdvancedSharpAdbClient/DeviceCommands/Receivers/GetPropReceiver.cs b/AdvancedSharpAdbClient/DeviceCommands/Receivers/GetPropReceiver.cs index 6b0cc72..0484bac 100644 --- a/AdvancedSharpAdbClient/DeviceCommands/Receivers/GetPropReceiver.cs +++ b/AdvancedSharpAdbClient/DeviceCommands/Receivers/GetPropReceiver.cs @@ -23,7 +23,7 @@ public sealed partial class GetPropReceiver : ShellOutputReceiver /// /// A regular expression which can be used to parse the getprop output. /// - private const string GetPropPattern = "^\\[([^]]+)\\]\\:\\s*\\[(.*)\\]$"; + private const string GetPropPattern = @"^\[([^]]+)\]\:\s*\[(.*)\]$"; /// /// The cached by .