• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[DEV] AndroidCtrl.dll [7.1.46.0] (ADB/Fastboot/(apk/zip) Signer - Framework)

Search This thread

[email protected]

Senior Member
Apr 21, 2016
288
238
Mumbai
kpstvhub.com
Thank you sir..

---------- Post added at 06:37 PM ---------- Previous post was at 06:13 PM ----------

Sorry to disturb you again... Sir

But how this actually works.. Means since i am new to this.. Can u bit give am example on it.. For eg i wanna set a prop value in a label4.text which is ro.product.model so how could i do it..
For eg label4.Text = Adb.Instance....???

Also i want to run some shell cmd commands like gzip and all.. So how can we do that...

Thank you in Advance
 

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
Heyho,
Thank you sir..

---------- Post added at 06:37 PM ---------- Previous post was at 06:13 PM ----------

Sorry to disturb you again... Sir

But how this actually works.. Means since i am new to this.. Can u bit give am example on it.. For eg i wanna set a prop value in a label4.text which is ro.product.model so how could i do it..
For eg label4.Text = Adb.Instance....???

Also i want to run some shell cmd commands like gzip and all.. So how can we do that...

Thank you in Advance

i don't know how fit u are on using an external dll. But i'll try my best to provide u a really basic sample. To set up the 1st use of the dll u have to act like:
Code:
...
using System.Linq
using AndroidCtrl;
using AndroidCtrl.ADB;
...
namespace ....
...
        private ADB myDevice = null;
...
        public void InitDLL()
        {
            // check if we have adb rdy
            if (ADB.IntegrityCheck() == false)
            {
                // if not
                if (ADB.IsStarted)
                {
                    ADB.Stop();
                }
                Deploy.ADB();
            }

            // check if adb is already running
            if (ADB.IsStarted == false)
            {
                ADB.Start();
            }

            // check if we have a device connected
            IEnumerable<DataModelDevicesItem> res = ADB.Devices();
            if (res != null && res.Any())
            {
                // Set up the device
                myDevice = ADB.Instance(res.ElementAt(0).Serial);

                 // to select the device dll wide u can act like
                 ADB.SelectDevice(res.ElementAt(0));
            }
            else
            {
                throw new Exception("No device found!");
            }
        }

        public void DoSomething()
        {
            if (myDevice != null)
            {
                // get the data - here we don't need to care about NULL
                // because BuildProperties.Get() will return
                // an string.Empty if there is nothing to get
                MyTextBox.Text = myDevice.Device.BuildProperties.Get("ro.product.model");

                // if u have the device selected u can now act like
                MyTextBox.Text = ADB.Instance().Device.BuildProperties.Get("ro.product.model");
                // so u don't need the myDevice field and u can easily switch between devices
                // via ADB.SelectDevice()
            }
        }
}

Hope this helps u to understand how u have to act ;)

EDIT:
There was a little error in the sample, i fixed it ;)
res.ElementAt(0).Device must be res.ElementAt(0).Serial

Regards,
Sebastian
 
Last edited:

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
Heyho,
Thank you sir.. You are great... Your work is really a good contribute to devs really.. Why don't you spread it along other forums also make youtube videos on it.. Or a docs would be great.... Really a great.. Work.. World must know your great contribution :cowboy:

THX mate! - About the documentation, here is a little how-to, when i'm done with the refactoring i'll extent the how-to. ;)

Regards,
Sebastian
 
  • Like
Reactions: [email protected]

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
I like the class, I will write my personal android toolkit with this ;)
Just a question, have you tried to port it to work on mono too?

Heyho,
currently there is no mono build, because i use some p/invokes, for example, the icon extraction and the unzip functionality. If i have time, i'll have a look for equivalents in mono. Maybe i can get it work without major changes, but the AndroidCtrlUI.dll might never work on mono because so far i have read (never read deep into it), mono doesn't support WPF and the AndroidCtrlUI.dll is based on WPF and the MVVM pattern. So in this case i have to create a complete new dll only for Win Forms that mono can render the UI items.

Hope i could help u ;)

Regards,
Sebastian
 

amoamare

Senior Member
Jul 17, 2006
476
318
[*]Multi-Device compatible, u can manage unlimited devices at the same time with this dll. Each device gets it's own instance. (Thread-Safe, the dll uses "[MethodImpl(MethodImplOptions.Synchronized)]" i dun use "lock()" coz, it's not safe!)

The attribute [MethodImpl(MethodImplOptions.Synchronized)] is similar to calling lock(this) which can cause deadlocks and has a known bug for x64 static classes sense it locks as lock(typeof(class)) as noted here https://connect.microsoft.com/Visua...ckexception-when-used-on-static-method-on-x64

As well as https://stackoverflow.com/questions/2223656/what-does-methodimploptions-synchronized-do

Best practice is to lock on a private read only object.

Overall nice project and work.

Code:
internal class Foo
{
    private readonly object SyncRoot = new object();

    public void Bar() 
    {
        lock(SyncRoot)
        {
        }
    }
}
 

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
The attribute [MethodImpl(MethodImplOptions.Synchronized)] is similar to calling lock(this) which can cause deadlocks and has a known bug for x64 static classes sense it locks as lock(typeof(class)) as noted here https://connect.microsoft.com/Visua...ckexception-when-used-on-static-method-on-x64

As well as https://stackoverflow.com/questions/2223656/what-does-methodimploptions-synchronized-do

Best practice is to lock on a private read only object.

Overall nice project and work.

Code:
internal class Foo
{
    private readonly object SyncRoot = new object();

    public void Bar() 
    {
        lock(SyncRoot)
        {
        }
    }
}

Heyho,
thx for the "hint" but u should also read a bit deeper. Because as i mentioned here the lock() examples are not safe... Because, with Monitor.Exit(Foo); ur lock statement is useless^^ - Also i don't got any error or deadlocks as mentioned, so i'll not change it to insecure lock(). If i get some proofs that there is a crash which will appear ever and ever again i would do that but i got no reports in that direction.

Edit:
Just had another look at this case and found that: MSDN... This proofs my concept :p - Because "lock()" is likely "Monitor.something".

Regards,
Sebastian
 
Last edited:

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
Update/News

Heyho,
today i release the version 0.0.2.4 of my AndroidCtrl.dll & AndroidCtrlUI.dll. Both got heavy refactored but i tried my best to provide the old "structure"! The most changes are done inside the internal logic's, so the "method" & "property" changes are minimal.
-
For example i splitted the "DataModels" and moved them to their desired "namespaces", this should not make that much work to add the needed "using" directives to ur code when u update to the new version. The same happened to the "enums".

Example:
All DataModels where previously stored in the main "namespace" (AndroidCtrl).
The following DataModels changed:
Code:
DataModelDumpBadging_XXX
DataModelDumpResources_XXX

to: AndroidCtrl.AAPT

DataModelDeviceInfo
DataModelDumpsysBattery
DataModelDumpsysMeminfo_XXX
DataModelFileSystemItem
DataModelKeyEvent
DataModelLogCat
DataModelPackageManager_XXX
DataModelUptime

to: AndroidCtrl.ADB.Device

DataModelContacts_XXX

to: AndroidCtrl.ADB.Device.Providers

The same "schema" is used for the "enums"... All ADB "enums" have been moved to ADB and all fastboot "enums" have been moved to Fastboot...
-
I'll not update the changelog because i had a data loss on my Dev-Environment a few weeks ago and that also wiped my notes... So u can see this as a "new" version, this is also the reason for the jump from 1.2 to 2.4.
-
The How-To on my website gets updated in a few hours! - Done!

If u have any questions about specific changes, feel free to ask! ;)

Edit:
For the users which use the directory parser callback, here is a short explain about the change to it.
The "property/eventhandler" "AndroidCtrl.ADB.Device.Directories().CallBack" is completely removed and replaced by:
Code:
(void) AndroidCtrl.ADB.Device.Directories().GetDirectories(CallbackDirectoryParser callback)
(void) AndroidCtrl.ADB.Device.Directories().GetFiles(CallbackDirectoryParser callback)
(void) AndroidCtrl.ADB.Device.Directories().Parse(CallbackDirectoryParser callback)
The "delegate" itself, is still the same!


Regards,
Sebastian
 
Last edited:

stydent21rus

Member
Aug 30, 2015
5
0
This (C# .NET 4) dll is a kind of AAPT/ADB/Fastboot/(apk/zip) Signer - Framework, it provides a lot of predefined .NET functions to communicate with an Android device. It's designed to work in 1st case with any non-root device but u can also use it with any rooted device (A few functions requires root access).

U can use it in all of ur projects for free

The following (N)amespaces & (C)lasses are currently available:

(N) AAPT
(C) AAPT
(C) Dump


(N) ADB
(C) ADB (Includes nearly all adb.exe commands)
(N) Device
(C) Device
(C) ActivityManager
(C) BuildProperties
(N) BusyBox
(C) BusyBox
(C) Find
(C) Tar

(C) Daemon (Manage the daemon on the device)
(C) Directories (Similar to .NET Directory/-Info)
(C) Dumpsys
(C) Files (Similar to .NET File/-Info)
(C) FileSystem (Returns all mount-points (df / df -Pakh))
(C) Forensics (ALFA-State)
(C) Input
(C) Logcat
(C) MediaScanner (Manage the Android MediaScanner, useful after some file-transfers via ADB)
(C) Mount (Requires Root and manage the mounts)
(C) OpenRecoveryScript (Manage the OpenRecoveryScript)
(C) PackageManager
(C) Phone (Start a call, dial a number, add a contact or send a sms)
(N) Providers
(C) Contacts
(C) Providers
(C) Telephony

(N) SQLite
(C) Options
(C) QueryTools
(C) SQLite3

(C) Screen
(C) Su
(C) Wipe

(C) Monitor


(N) Fastboot
(C) Fastboot (Includes nearly all fastboot.exe commands)
(C) Monitor
(C) OEM
(C) Wipe



(N) ProcessModels
(C) General (Includes some predefined process models)
(C) IRealTimeBG (Is an interface)
(C) RealTimeBGExe (Starts a real time process with in/-output ability based on IRealTimeBG)
(C) RealTimeBGExeV2 (Starts a real time process with in/-output ability based on IRealTimeBG)


(N) Signer
(C) Signer (signapk.jar Interface)


(N) Tools
(C) CRC
(C) Deploy (Deploy the AAPT/ADB/Fastboot/Signer files needed by this dll)
(C) Hash
(C) Hex
(C) ToolBox
(C) UPath (U(nix)Path - Similar to .NET System.IO.Path )
(C) Update




Special
Ready-To-GoMVVM's for WPF, XAML via my AndroidCtrlUI.dll
Multi-Device compatible, u can manage unlimited devices at the same time with this dll. Each device gets it's own instance. (Thread-Safe, the dll use lock() for critical sections)
UTF8-File/Folder Transfer u can transfer files/folders with containing special chars (ü, ö, ä, €, @,

---------- Post added at 08:44 PM ---------- Previous post was at 08:40 PM ----------

Heyho,
today i release the version 0.0.2.4 of my AndroidCtrl.dll & AndroidCtrlUI.dll. Both got heavy refactored but i tried my best to provide the old "structure"! The most changes are done inside the internal logic's, so the "method" & "property" changes are minimal.
-
For example i splitted the "DataModels" and moved them to their desired "namespaces", this should not make that much work to add the needed "using" directives to ur code when u update to the new version. The same happened to the "enums".

Example:
All DataModels where previously stored in the main "namespace" (AndroidCtrl).
The following DataModels changed:


The same "schema" is used for the "enums"... All ADB "enums" have been moved to ADB and all fastboot "enums" have been moved to Fastboot...
-
I'll not update the changelog because i had a data loss on my Dev-Environment a few weeks ago and that also wiped my notes... So u can see this as a "new" version, this is also the reason for the jump from 1.2 to 2.4.
-
The How-To on my website gets updated in a few hours! - Done!

If u have any questions about specific changes, feel free to ask! ;)

Edit:
For the users which use the directory parser callback, here is a short explain about the change to it.
The "property/eventhandler" "AndroidCtrl.ADB.Device.Directories().CallBack" is completely removed and replaced by:

The "delegate" itself, is still the same!


Regards,
Sebastian
Hi!!!)))Wanted to know if it is possible to build aapt for 8 for mobile apk tool????
 

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
Hi!!!)))Wanted to know if it is possible to build aapt for 8 for mobile apk tool????

Heyho,
- 1st, pls never quote the 1st post, use "@UserName" instead -

About ur question, if i understand u right, u looking for the source of "AAPT"?
I don't have it, nor the source of the "Apk-Tool".

----
Little Update
The announced "ADBridge" is now ready and works so far really great. With this "bridge" u can switch between "adb.exe - AndroidCtrl.ADB" and my own ADB protocol implementation "AndroidCtrl.ADBSocket" on the fly. Otherwise, u can use it as an "instanced" version of those "ADB - statics".
-
The other new feature is access to the "FrameBuffer - /dev/graphics/fb0", so u can get "raw-screenshots" from the device.
(As u can imagine, the speed/frame-rate depends on the connection to the device. Also, this feature is currently only via "ADBSocket" available, and currently not a part of the "ADBridge". - It's now also working for the adb.exe)
-
I added also a few new "events" where u can subscribe to, to get some info's whats going on.
--
Release of the new build should be the next weekend.

Regards,
Sebastian
 
Last edited:
  • Like
Reactions: squabbi

franTW

Member
Jan 24, 2015
34
33
20
franco28.github.io
Hi! im using your amazing dll, but i decided to update to the latest one, and now im having troubles like this one! can you help me please!

Here is the part of the code

Code:
List<String> getdevicecodename = (List<string>)await Task.Run(() => ADB.Instance().ShellCmd("/system/bin/getprop ro.product.device"));
List<String> getcarrier = (List<string>)await Task.Run(() => ADB.Instance().ShellCmd("/system/bin/getprop ro.carrier"));
getdevicecodename.ToString();
getcarrier.ToString();
var result = String.Join("", getdevicecodename.ToArray());
var result2 = String.Join("", getcarrier.ToArray());

Another question

How can i get the device state like a device? because always detect the devices as UNKNOWN! so i made this on device monitor

Code:
 if (state == DeviceState.UNKNOWN)
{
state = DeviceState.DEVICE;
DeviceConnected(state.ToString());
}
 

Attachments

  • null.png
    null.png
    134.8 KB · Views: 65
Last edited:
  • Like
Reactions: k1ll3r8e

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
Hi! im using your amazing dll, but i decided to update to the latest one, and now im having troubles like this one! can you help me please!

Here is the part of the code

Code:
List<String> getdevicecodename = (List<string>)await Task.Run(() => ADB.Instance().ShellCmd("/system/bin/getprop ro.product.device"));
List<String> getcarrier = (List<string>)await Task.Run(() => ADB.Instance().ShellCmd("/system/bin/getprop ro.carrier"));
getdevicecodename.ToString();
getcarrier.ToString();
var result = String.Join("", getdevicecodename.ToArray());
var result2 = String.Join("", getcarrier.ToArray());

Another question

How can i get the device state like a device? because always detect the devices as UNKNOWN! so i made this on device monitor

Code:
 if (state == DeviceState.UNKNOWN)
{
state = DeviceState.DEVICE;
DeviceConnected(state.ToString());
}
Heyho,
THX for the feedback and sorry for the late reply!

The problem i see so far, depends really on the changes I introduced! First of all, i removed the "default" instance, which causes this problem. To avoid this, you simply need to call "ADB.Devices()" and select the returned device like "ADB.Select(Your_Device_Info)" or you need to request the instance like "ADB.Instance(Your_Device_Info)".

Also, there are now lots of REAL async overloads, so you can do like:
Code:
List<String> getdevicecodename = (List<string>)await ADB.Instance().ShellCmdAsync("/system/bin/getprop ro.product.device").ConfigureAwait(false);
List<String> getcarrier = (List<string>)await ADB.Instance().ShellCmdAsync("/system/bin/getprop ro.carrier").ConfigureAwait(false);

Edit:
About the DeviceState, you could also use:
Code:
(DeviceState) Tools.ToolBox.CheckDeviceState(string deviceID);
(DeviceState) Tools.ToolBox.CheckDeviceState(IDeviceInfo device);

Edit 1:
Here are a few async overloads you should use instead of Task.Run() or Task.Factory.StartNew():
Code:
Task<IEnumerable<string>> ShellCmdAsync(string cmd, int timeout = 0);
Task<IEnumerable<string>> ShellCmdAsync(string cmd, CancellationToken cancellationToken, int timeout = 0);
Task<IEnumerable<string>> ShellCmdAsync(string cmd, ShellDataEventHandler shellDataEventHandler, int timeout = 0);
Task<IEnumerable<string>> ShellCmdAsync(string cmd, ShellDataEventHandler shellDataEventHandler, CancellationToken cancellationToken, int timeout = 0);

Task<int> ShellCmdHResAsync(string cmd, int timeout = 0);
Task<int> ShellCmdHResAsync(string cmd, CancellationToken cancellationToken, int timeout = 0);
Task<int> ShellCmdHResAsync(string cmd, ShellDataEventHandler shellDataEventHandler, int timeout = 0);
Task<int> ShellCmdHResAsync(string cmd, ShellDataEventHandler shellDataEventHandler, CancellationToken cancellationToken, int timeout = 0);

Task<IEnumerable<string>> ShellCmdStackAsync(IEnumerable<string> cmdStack, int timeout = 0);
Task<IEnumerable<string>> ShellCmdStackAsync(IEnumerable<string> cmdStack, CancellationToken cancellationToken, int timeout = 0);
Task<IEnumerable<string>> ShellCmdStackAsync(IEnumerable<string> cmdStack, ShellDataEventHandler shellDataEventHandler, int timeout = 0);
Task<IEnumerable<string>> ShellCmdStackAsync(IEnumerable<string> cmdStack, ShellDataEventHandler shellDataEventHandler, CancellationToken cancellationToken, int timeout = 0);
These are available under (IADBClient)ADB.Instance(), (Su)ADB.Instance().Device.Su and (BusyBox)ADB.Instance().Device.BusyBox

These are also available via the IADBClient:
Code:
Task<bool> InstallAsync(string localPath);
Task<bool> InstallAsync(string localPath, PackageInstallArgs args);
Task<bool> InstallAsync(IEnumerable<string> localPaths);
Task<bool> InstallAsync(IEnumerable<string> localPaths, PackageInstallArgs args);

Task<bool> UninstallAsync(string package, bool keepData = false);

Task<bool> PullAsync(string remotePath, string localPath);
Task<bool> PullAsync(string remotePath, string localPath, FileTransferEventHandler transferEventHandler);
Task<bool> PullAsync(string remotePath, string localPath, FileTransferEventHandler transferEventHandler, CancellationToken cancellationToken);

Task<bool> PushAsync(string localPath, string remotePath);
Task<bool> PushAsync(string localPath, string remotePath, FileTransferEventHandler transferEventHandler);
Task<bool> PushAsync(string localPath, string remotePath, FileTransferEventHandler transferEventHandler, CancellationToken cancellationToken);

Hope i could help you ;)

Regards,
Sebastian
 
Last edited:

squabbi

Senior Member
Jul 20, 2012
1,744
1,600
Sydney
Hey! It's been a while! How have you been?

I was just looking at my old toolkit project I left unfinished, and encountered this error after setting a different path to deploy ADB.

Code:
Deploy.ADB("./ToolkitData/platform-tools");

When `ADB.Start()` is called it throws an IO.FileNotFoundException; saying "The provided file couldn't be found.", as it attempts to execute the adb.exe from the 'platform-tools' folder, rather than where it was extracted by the above line.

If the functionality has been depreicated or removed that's fine too! :) Just wasn't sure if it was a bug or not.
 

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
Hey! It's been a while! How have you been?

I was just looking at my old toolkit project I left unfinished, and encountered this error after setting a different path to deploy ADB.

Code:
Deploy.ADB("./ToolkitData/platform-tools");

When `ADB.Start()` is called it throws an IO.FileNotFoundException; saying "The provided file couldn't be found.", as it attempts to execute the adb.exe from the 'platform-tools' folder, rather than where it was extracted by the above line.

If the functionality has been depreicated or removed that's fine too! :) Just wasn't sure if it was a bug or not.

Heyho,
i'm fine, hope you too?

The method, requires an absolute path like "c:\path\to\your\destination". Also, you have to set the path for "ADB.PATH_EXE = c:\path\to\your\destination\adb.exe" and "Fastboot.PATH_EXE = c:\path\to\your\destination\fastboot.exe".

Hope i could help you ;)

Edit:
The next version will support "sendrecv_v2" and the "Brotli" compression for file transfers.

Edit 1:
The next version is written for .NET 5.0!
This dll (AndroidCtrl) is then compatible with linux-x64, osx-64, win-x64 and win-x86. The AndroidCtrlUI is for the next few builds still bound to windows, because it uses too many P/Invokes.

Regards,
Sebastian
 
Last edited:

quantemplation

Senior Member
Feb 28, 2013
117
60
Richmond, VA
Hi @k1ll3r8e.
I've been slowly adapting a couple of my projects to using this over the past 6 months or so, and I'm curious if you've considered open sourcing the project to allow contributions and directed questions/issues.
Myself, for one, would be interested in making some contributions and perhaps engaging in some dialogue about various implementation choices therein.
I'd be interested in hearing your stance.
 

k1ll3r8e

Senior Member
Mar 4, 2011
725
671
Delmenhorst
HTC Sensation
HTC One (M9)
Hi @k1ll3r8e.
I've been slowly adapting a couple of my projects to using this over the past 6 months or so, and I'm curious if you've considered open sourcing the project to allow contributions and directed questions/issues.
Myself, for one, would be interested in making some contributions and perhaps engaging in some dialogue about various implementation choices therein.
I'd be interested in hearing your stance.

Heyho,
sounds great!

Funny thing, from the next version on, the AndroidCtrl.dll and the AndroidCtrlUI.dll will be licensed under the Apache 2.0-License. Seems you just got the right moment.
(But, I haven't decided where I upload the source. My thoughts are GitHub or my own Debian server.)

I'll send you later this day a "preview" of the source via PM.

Hope I could help you so far ;)

Regards,
Sebastian
 

quantemplation

Senior Member
Feb 28, 2013
117
60
Richmond, VA
Heyho,
sounds great!

Funny thing, from the next version on, the AndroidCtrl.dll and the AndroidCtrlUI.dll will be licensed under the Apache 2.0-License. Seems you just got the right moment.
(But, I haven't decided where I upload the source. My thoughts are GitHub or my own Debian server.)

I'll send you later this day a "preview" of the source via PM.

Hope I could help you so far ;)

Regards,
Sebastian

Awesome! Once I finish this pressing project at work, I have a few ideas to send your way.
As for where to upload the source, my recommendation goes to GitHub/GitLab :good:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 30
    This (C# .NET 4.6|4.7|4.8) dll is a kind of ADB/Fastboot/(apk/zip) Signer - Framework, it provides a lot of predefined .NET functions to communicate with an Android device. It's designed to work in 1st case with any non-root device but you can also use it with any rooted device (A few functions requires root access).

    License
    This project is licensed under the Apache License Version 2.0.

    The latest build 7.1.46.0 is currently only via FTP, GoogleDrive or Dropbox available, the DevDB has currently some upload issues!

    The following (N)amespaces, (C)lasses & (I)nterfaces are currently available:

    • (N) ADB
      • (N) Binary (This is the binary/exe implementation of ADB)
        • (C) ADB (static Management Class for the ADBClient's)
        • (C) ADBClient (Implementation of IADBClient)
        • (C) Channel (Implementation of IChannel)
      • (N) Device
        • (N) BusyBox
          • (C) BusyBox
          • (C) Find
          • (C) Tar
        • (N) Dumpsys
          • (C) Battery
          • (C) Dumpsys
          • (I) IBattery
        • (N) Input
          • (I) IKeyEvent
          • (C) Input
          • (C) InputExtensions
          • (C) KeyEvent (Implementation of IKeyEvent)
        • (N) IO
          • (NS) Compression
            • (NS) BrotliSharp (Only available in .NET 4.6|4.7|4.8 - In .NET Standard >= 2.1 you have to use the native .NET implementation)
          • (C) ADirectoryInfo (Similar to .NET Directory/-Info)
          • (C) AFileInfo (Similar to .NET File/-Info)
          • (C) AFileStream (Similar to .NET FileStream)
          • (C) AFileSystemInfo (Similar to .NET FileSystemInfo, it's the abstract base for ADirectoryInfo & AFileInfo)
          • (C) AMountPointInfo (Similar to ADirectoryInfo & AFileInfo but only for mounts)
          • (C) FileSystemCache (A cache object for ADirectoryInfo & AFileInfo)
          • (I) IFileSystemCache (Interface for FileSystemCache)
          • (C) IO
          • (I) ITransferMessage
          • (C) MediaScanner (Manage the Android MediaScanner, useful after some file-transfers via ADB)
          • (C) Mount (Requires Root and manage the mounts)
          • (C) Stat (stat class for the ADB-Protocol)
          • (C) SyncStream (Base implementation of the ADB sync service. Utilized by AFileStream)
          • (C) TransferMessage
          • (C) UPath (Similar to .Net Path but for unix paths)
        • (N) Logcat
          • (I) ILogEntry
          • (C) Logcat
          • (C) LogEntry
        • (N) Manager
          • (C) ActivityManager
          • (I) IInstrumentation
          • (C) Instrumentation
          • (I) IPackage
          • (I) IPermission
          • (C) Manager
          • (C) Package
          • (C) PackageManager
          • (C) Permission
        • (N) Provider
          • (C) Contacts (Contacts provider)
          • (C) ContactsDataField
          • (C) ContactsEmail
          • (C) ContactsEvent
          • (C) ContactsGroup
          • (C) ContactsIdentity
          • (C) ContactsIM
          • (C) ContactsName
          • (C) ContactsNickname
          • (C) ContactsNote
          • (C) ContactsOrganization
          • (C) ContactsPhone
          • (C) ContactsPhoto
          • (C) ContactsPostalAddress
          • (C) ContactsRelation
          • (C) ContactsSipAddress
          • (C) ContactsWebsite
          • (I) IContactsDataField
          • (C) Provider
          • (C) Telephony (Telephony provider)
        • (N) Screen
          • (C) Framebuffer (Implementation of IFramebuffer)
          • (C) FramebufferInfo
          • (I) IFramebuffer (Interface of an RAW framebuffer)
          • (I) IFramebufferInfo
          • (I) IScreenDimension
          • (I) IScreenFocus
          • (C) Screen
          • (C) ScreenDimension
          • (C) ScreenFocus
        • (N) Shell
          • (I) IShell (Interface of an shell with in-/output abilities)
          • (C) Shell (Implementation of IShell)
        • (N) SQLite
          • (C) Options
          • (C) QueryTools
          • (C) SQLite3 (SQLite3 database connector)
        • (C) BuildProperties
        • (C) Daemon (Manage the daemon on the device)
        • (C) Device
        • (C) Forensics (ALFA-State)
        • (I) IUptime
        • (C) OpenRecoveryScript (Manage the OpenRecoveryScript)
        • (C) Phone (Start a call, dial a number, add a contact or send a sms)
        • (C) Su
        • (C) Uptime
        • (C) Wipe
      • (N) Shares
        • (C) Monitor (Implementation of IMonitor)
      • (N) Socket (This is the IP based implementation of ADB - Here is NO binary/exe required)
        • (C) ADB (static Management Class for the ADBClient's)
        • (C) ADBClient (Implementation of IADBClient)
        • (C) ADBSocket (IP based connector - Mimics the ADB-Server)
        • (C) Channel (Implementation of IChannel)
      • (C) ADBridge (Unified access to Binary.ADB and Socket.ADB)
      • (I) IADBClient (Interface for nearly all ADB commands)
      • (I) IChannel (Interface of an RAW data channel)
    • (N) Fastboot
      • (C) Backdoor (Some backdoor commands)
      • (C) Fastboot (static Management Class for the FastbootClient's)
      • (C) FastbootClient (Includes nearly all fastboot.exe commands)
      • (I) IFastbootClient (Interface for FastbootClient)
      • (C) Monitor (Implementation of IMonitor)
      • (C) OEM (Some OEM commands)
      • (C) Wipe
    • (N) ProcessModels
      • (C) General (Includes some predefined process models)
      • (I) IRealTimeBG (Interface of an background process with in-/output abilities)
      • (C) RealTimeBGExeV2 (Implementation of IRealTimeBG)
    • (N) Signer
      • (C) Signer (signapk.jar Interface)
    • (N) Tools
      • (C) CRC
      • (C) Deploy (Deploy the AAPT/ADB/Fastboot/Signer files needed by this dll)
      • (C) Hash
      • (C) Hex
      • (C) IMEI (Some helper to verify and rebuild a valid IMEI)
      • (C) ToolBox
    • (C) Cleanup (Delete the files/folders which were created by this dll)
    • (C) Config
    • (C) DeviceInfo (Basic device info, the return from "(Binary/Socket).ADB.Devices()" and "Fastboot.Devices()")
    • (I) IDeviceInfo (Interface for DeviceInfo)
    • (I) IMonitor (Interface for the ADB.Binary, ADB.Socket and Fastboot.Fastboot monitor)

    Special
    • Ready-To-Go MVVM's for WPF, XAML via my AndroidCtrlUI.dll
    • Multi-Device compatible, you can manage unlimited devices at the same time with this dll. Each device gets it's own instance. (Thread-Safe, the dll use lock() for critical sections)
    • UTF8-File/Folder Transfer you can transfer files/folders with containing special chars (ü, ö, ä, €, @, à, è, etc.)
    • On-the-fly Device to Device copy (Binary <-> Binary | Binary <-> Socket | Socket <-> Socket)
    • Device-Monitor, if activated, it will check every 10 sec. ADB & Fastboot for new connected devices and call an defined callback, if something changed. So your program get's an info if an device is connected or removed.
    • All Android key-events as (int)enum and the ability to send them as single or stack.

    Hint
    • You can use all ADB methods/commands via USB or W-Lan/Lan, if your Rom supports ADB via W-Lan/Lan (Settings/Developer Settings)
    • If you want to use all sub-classes of IADBClient with BusyBox instead of the Shell, you have to set IADBClient.UseBusyBox to true. This will tell the instance to use the BusyBox commands inside each method, if the device has BusyBox installed.

    Referenced .NET assembly's
    System
    System.Numerics
    System.XML

    Used Code-analysis rules:
    Basic & Advanced Microsoft-Rules for Accuracy
    Microsoft-managed minimum & recommended rules
    Microsoft Security Rules

    About the usage, the namespaces (ADB, Fastboot, Signer) have one basic instance. For example, ADB.Instance(), Fastboot.Instance(), Signer.Instance. As you can see ADB.Instance() and Fastboot.Instance() can have a parameter. This parameter is in both cases an (string) DeviceID, an IDeviceInfo or null, if you use for example null, both classes will return it's Selected client. If you use the DeviceID or the IDeviceInfo the return is a fresh instance of the client or the already created instance. So, in any case, before you call ADB/Fastboot.Instance(). Check with ADB/Fastboot.Devices() if you have a connected device. If so, use the IDeviceInfo object to start your device instance or simply pass the serial to the Instance(). All instances which you have created on this way, will be hold inside an Dictionary<string, ADBClient>, so you can configure each device instance to it's needs and call it when ever you need it. This is also the point where i say it's multi-device and multi-thread safe. Because, if you always use ADB/Fastboot.Instance() you can't reach the wrong device. Also, all classes using lock() for critical sections, because [MethodImpl(MethodImplOptions.Synchronized)] is not longer available under .NET Standard.

    If you have any wishes like new features, how-to's or something else, let me know! :cyclops:

    Tested OS
    Win Vista | 7 | 8 | 8.1 | 10 (32Bit/64Bit in VM-Ware)
    Win 7 | 8 | 8.1 | 10 (64Bit Native)
    Win XP is not longer supported by ADB! (But, if you have a old ADB binary, the dll will do it's job)

    Tested Devices
    Android Emulator some Versions (min. 2.x) in AVD
    Android x86
    HTC Sensation -/ XE (non-/rooted)
    HTC One M9 (non-/rooted)
    Huawei P9 Lite (VNS-L21,22,23,31,etc.) (non-/rooted)
    Huawei P10 Lite (WAS-LX1A,etc.) (non-/rooted)
    Samsung Galaxy 2-5 (non-/rooted)
    Samsung Galaxy S Plus (non-rooted)
    A few Samsung Tabs (non-/rooted)
    Google Pixel 4 (Android 11) (non-/rooted)

    Requirements
    Android: min. 2.x
    Platform: x86/x64 (Windows)
    Frameworks: min. .NET 4.6 and JRE (only for the Signer)
    (Installed ADB/Fastboot device driver)

    Download
    Mirror: XDA-DevDB (since 29.01.2019 no uploads possible)
    Mirror #1: My FTP (Build archiv)
    Mirror #2: GoogleDrive
    Mirror #3: Dropbox
    Each zip-archiv contains the AndroidCtrl.dll, its markup file AndroidCtrl.xml and the program debug database AndroidCtrl.pdb for .NET 4.6|4.7|4.8 and .NET Standard 2.1 (beta)

    Examples (Updated to dll version 7.1.46.0) (Updated in the next 24 h)
    Mirror: My FTP
    Mirror #1: GoogleDrive
    Mirror #2: Dropbox
    (Contains a simple exe and its source written in C# WPF)

    Source
    N/A (If you want to have a look at it, send me a PM or simply decompile it.)

    DO NOT MIRROR MY FILES! DO NOT COPY MY THREADS!

    XDA:DevDB Information
    AndroidCtrl.dll, Tool/Utility for the Android General

    Contributors
    k1ll3r8e, squabbi, Krystanos

    Version Information
    Status: Stable
    Current Stable Version: 7.1.46.0
    Stable Release Date: 2020-09-19

    Created 2016-07-24
    Last Updated 2020-09-19
    6
    Problems & Solutions

    1. Windows 8.x | 10.x

    NOTE
    If u use any callback functions, u have to invoke any UI-/ variable-interaction from an dispatcher like the following example:
    Code:
    public void Monitor(Added|Changed|Removed)EventHandler(object sender, Monitor(Added|Changed|Removed)EventArgs e)
    {
         App.Current.Dispatcher.Invoke((Action)delegate
         {
              // IDeviceInfo[] e.Devices
              // Here u can interact with an UI-Element or an variable in ur program code
         });
    }
    if u do it without dispatcher, u'll get an "Thread Exception".


    More examples coming soon...
    (If u need a specific example, just let me know, i'll try my best to provide one.)
    3
    Changelog

    DD.MM.YYYY | (A) = Added | (C) = Changed | (D) = Deleted | (F) = Fixed | (R) = Recoded | (U) Updated
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    26.07.2020 [7.0.46.0]
    (A) Some new Async overloads to the AFileInfo, AFileSystemInfo, ADirectoryInfo and AMountpointInfo.
    (F) A few little bugs

    01.02.2020 [6.7.46.0]
    (A) ADB.IADBClient{} (The old IADB interface)

    (A) ADB.Binary.ADB{} (The old ADB class - only the statics)
    (A) ADB.Binary.ADBClient{} (The old ADB class - without any statics)

    (A) ADB.Socket.ADB{} (The old ADB class - only the statics)
    (A) ADB.Socket.ADBClient{} (The old ADB class - without any statics)

    (A) ADB.Device.ADirectoryInfo{}
    (A) ADB.Device.AFileInfo{}
    (A) ADB.Device.AFileStream{}
    (A) ADB.Device.AMountPointInfo{}
    (A) ADB.Device.FileSystemCache{}
    (A) ADB.Device.IFileSystemCache{}

    (D) ADB.Device.Directories{}
    (D) ADB.Device.Files{}
    (D) ADB.Device.FileSystem{}
    (D) ADB.Device.FileSystemItem{}
    (D) ADB.Device.IFileSystemItem{}
    And everything related to those classes... Directories has been replaced with ADirectoryInfo, Files has been replaced with AFileInfo and FileSystem has been replaced with AMountPointInfo.

    31.05.2019 [6.0.46.0]
    (C) The Framework Version from 4.0 to 4.6
    (C) The versioning:
    6 = Major
    0 = Minor
    46 = Framework Version (4.6)
    0 = Hotfix

    (A) (int) ADB.Instance().Device.Screen.GetAutoBrightness()
    (A) (int) ADB.Instance().Device.Screen.GetBrightness()
    (A) (ScreenBrightnessMode) ADB.Instance().Device.Screen.GetBrightnessMode()
    (A) (ScreenRotation) ADB.Instance().Device.Screen.GetRotation()
    (A) (ScreenRotationMode) ADB.Instance().Device.Screen.GetRotationMode()
    (A) (bool) ADB.Instance().Device.Screen.SetBrightness(int brightness)
    (A) (bool) ADB.Instance().Device.Screen.SetBrightnessMode(ScreenBrightnessMode mode)
    (A) (bool) ADB.Instance().Device.Screen.SetRotation(ScreenRotation rotation)
    (A) (bool) ADB.Instance().Device.Screen.SetRotationMode(ScreenRotationMode mode)

    (D) ASDK (enum)
    (C From) (ASDK) ADB.Instance().Device.GetSDK()
    (C To) (int) ADB.Instance().Device. GetSDK()


    10.04.2019 [0.0.5.2]
    (A) A workaround for older SU binaries
    Code:
    // (Source ADB.Device.Su {})
    ///<summary>
    /// Enables an (W)ork(A)round for older SU binaries, which needs the command as an single argument.
    ///<para/>For example, the latest SU binaries support a syntax like [su -c id -u] where older binaries need [su -c "id -u"]
    ///<para/>If u deactivate this workaround by enabled <see cref="IADB.UseSu"/>, <see cref="IADB.UseSu"/> gets also disabled!
    ///<para/>This workaround is by default disabled
    ///<para/>Affected Methods:
    ///<para/><see cref="ShellCmd(string, int)"/>, <see cref="ShellCmd(string, CancellationToken, int)"/>, <see cref="ShellCmd(string, ShellDataEventHandler, int)"/>, <see cref="ShellCmd(string, ShellDataEventHandler, CancellationToken, int)"/>
    ///<para/><see cref="ShellCmdHRes(string, int)"/>, <see cref="ShellCmdHRes(string, CancellationToken, int)"/>, <see cref="ShellCmdHRes(string, ShellDataEventHandler, int)"/>, <see cref="ShellCmdHRes(string, ShellDataEventHandler, CancellationToken, int)"/>
    ///</summary>
    public bool WA_SingleArgument

    (A) A fix for unresponsive interactive shells. This happened to me on Lineage on my HTC Sensation, where the device sends an "resize" request... Sending a command in this state caused the command getting cut at the 1st byte, for example, u send "id -u" the delivered command was "d -u".

    (A) Added "feature" detection for Binary.ADB, now u can get the "features" of the device like: cmd, stat, stat_v2, shell, shell_v2, etc. in the "IChannel.Features".

    (R) Removed the last bit of code duplication and optimized some internal logic's. For example, the "Socket.IChannel" got a speed boost from ~1.920.000 bytes during an transfer of 14.400.000 bytes.


    06.03.2019 [0.0.5.1]
    (C) ADB.Device structure (see 1st post)
    (R) ADB.Device.Provider (Decreased the loading time of the contacts and their data)
    (D) AAPT completely

    Older Changes:

    16.02.2019 [0.0.4.2]
    (A) DNS lookup for ADB.Socket
    (R) Reduced code duplication

    07.02.2019 [0.0.4.1]
    (F) An issue inside the ADB.Binary, the problem was that "ADB.Devices()" returned nothing, if more than one device was connected. Reason for the issue was the "(int)IChannel.ReadHexLength()" function, there i read an Int16 but it was an UInt16 which caused an overflow.


    29.01.2019 [0.0.4.0]
    (U) AAPT, ADB, Fastboot binaries and the required dlls to the latest version (1.0.40)

    (A) ADB.ADBridge - Unified access to ADB.Binary and ADB.Socket
    (A) ADB.IADB - Interface for ADB-/Socket with nearly all ADB commands
    (A) ADB.IChannel - Interface of an ADB-/Socket RAW-data channel
    (A) ADB.IFramebuffer - Interface for the ADB-/Socket framebuffer
    (A) ADB.IShell - Interface for the ADB-/Socket Shell v1 & v2
    (A) IMonitor - Interface for the ADB-/Socket and Fastboot device-monitor

    (A) On-the-fly device to device copy (ADB.Binary <-> ADB.Binary | ADB.Binary <-> ADB.Socket | ADB.Socket <-> ADB.Socket)

    Reordered the ADB namespace... The old layout was:
    ADB - Binary based ADB
    ADB.Device - Device helper
    ADBSocket - Socket based ADB

    The new layout is:
    ADB - Main ADB
    ADB.Binary - Binary based ADB
    ADB.Device - Device helper
    ADB.Shared - Shared helper, extensions for ADB.Binary and ADB.Socket
    ADB.Socket - Socket based ADB

    Implemented the framebuffer for ADB.Binary and ADB.Socket (A ready-to-go Remote-Desktop is available via my AndroidCtrlUI.dll)

    09.04.2018 [0.0.3.1]
    This is a complete new version!
    -
    I added a lot of new stuff like the "CancellationToken" overload, the "MediaScanner" class and also some fine tunes to the "Screen" class, there u can now also get the Screen dimensions. Also a lot models like the old MemDumpxxx_4xx have been removed (we are now 4 versions higher and the outputs are not longer available or have changed to much).

    15.02.2018 [0.0.2.5]
    (F) A problem where a NULL exception was raised during directory parsing
    (F) A few UI freezes and applied a few tweaks to some logic's.

    (D) Tools.Icons {}
    (D) Tools.TrayNotify {}
    Reason for this is the upcoming compatibility to .NET Core. BUT, the functions are not lost, i added those not .NET Core compatible calls to the AndroidCtrlUI.dll... Because the UI dll will be never migrated to .NET Core.

    03.11.2017 [0.0.2.4]
    Nearly full new build
    -
    Sadly my notes are lost, based on a data loss on my Dev Environment...
    3
    Contacts & MMS/SMS

    Hey all together,

    this is only an status update!

    The next build includes:

    1. SQLite3 database connector | ADB.Instance().Device.SQLite3{}
    2. Contacts viewer (The writer will take a bit more time and a few testers, coz the table structure is different between each ROM...)
    3. MMS/SMS viewer (For the writer goes here the same as for the contacts, the tables are different between each ROM...)
    4. A few fixes, mainly on ProcessModels.General{}, coz there is a bug inside the ExecuteBGStack() method.

    ------------------------------------------------------------------------------------------------------------------------------------------
    New build is out!

    About the sms/mms & contact reader, all classes require root access on the device!
    -
    About the writer, i have currently a very alfa-state writer which i test currently on some AVD's... Hopefully the next version will include it!

    And as always, if u find some bugs pls report them! ;)

    Regards,
    Sebastian