FORUMS
Remove All Ads from XDA

 View Poll Results: What does u want in the next version?

Ability to read/write the device contacts?
 
1 Vote(s)
50.00%
Ability to read/write device sms/mms?
 
1 Vote(s)
50.00%

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

700 posts
Thanks Meter: 650
 
By k1ll3r8e, Senior Member on 4th June 2014, 01:50 PM
Post Reply Email Thread
Announcement from k1ll3r8e: You need an UI for some functions of this dll? Have a look at my AndroidCtrlUI.dll!
This (C# .NET 4) 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 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 latest build 0.0.5.2 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 (Implementation of IADB)
      • (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
      • (N) IO
        • (C) Directories (Similar to .NET Directory/-Info)
        • (C) Files (Similar to .NET File/-Info)
        • (C) FileSystem (Returns all mount-points (df / df -Pakh))
        • (C) FileSystemItem
        • (I) IFileSystemItem
        • (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) TransferMessage
        • (C) UPath
      • (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) Shared
      • (C) Monitor (Implementation of IMonitor)
    • (N) Socket (This is the IP based implementation of ADB - Here is NO binary/exe required)
      • (C) ADB (Implementation of IADB)
      • (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) IADB (Interface for nearly all ADB commands)
    • (I) IChannel (Interface of an RAW data channel)
  • (N) Fastboot
    • (C) Backdoor (Some backdoor commands)
    • (C) Fastboot (Includes nearly all fastboot.exe commands)
    • (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) RealTimeBGExe (Old implementation of RealTimeBG)
    • (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) ToolBox
  • (C) Cleanup (Delete the files/folders which were created by this dll)
  • (C) Config
  • (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, 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 (ü, ö, ä, €, @, à, è, 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 ur program get's an info if an device is connected or removed.
  • Most parser return a DataModel or interface, for example: DataModelDumpBadging, IFileSystemItem, etc.)
  • All Android key-events as (int)enum and the ability to send them as single or stack.

Hint
  • U can use all ADB methods/commands via USB or W-Lan/Lan, if ur Rom supports ADB via W-Lan/Lan (Settings/Developer Settings)
  • If u want to use all sub-classes of IADB with BusyBox instead of the Shell, u have to set ADB.Instance().UseBusyBox to true. This will tell the IADB 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 u 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 u use for example null, both classes will load it's base instance (internally called AndroidCtrl). This is an instance which don't take care on the connected devices and use NO DeviceID to communicate with ADB. This will mean, the 1st or even a random device get the delivered commands. This is in nearly any case unacceptable! - The only situation is eventually, if u have only one device connected... - So, in any case, before u call ADB/Fastboot.Instance(). Check with ADB/Fastboot.Devices() if u have a connected device. If so, use the IDeviceInfo object to start ur device instance or simply pass the serial to the Instance(). All instances which u have created on this way will be hold inside an Dictionary<string, ADB>, so u can configure each device instance to it's needs and call it when ever u need it. This is also the point where i say it's multi-device and multi-thread safe. Because, if u always use ADB/Fastboot.Instance() u can't reach the wrong device. Also, all classes using lock() for critical sections, because [MethodImpl(MethodImplOptions.Synchronized)] is not longer available under .NET Core [I](Currently, the dll is NOT compatible with .NET Core...)

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

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 u 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)

Requirements
Android: min. 2.x
Platform: x86/x64 (Windows)
Frameworks: min. .NET 4 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 VisualStudio)

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

Source
N/A (If u 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: 0.0.5.2
Stable Release Date: 2019-04-10

Created 2016-07-24
Last Updated 2019-04-17
The Following 30 Users Say Thank You to k1ll3r8e For This Useful Post: [ View ] Gift k1ll3r8e Ad-Free
 
 
4th June 2014, 01:50 PM |#2  
k1ll3r8e's Avatar
OP Senior Member
Flag Delmenhorst
Thanks Meter: 650
 
Donate to Me
More
How - To
0. Complete How-To
1. Getting Started (General)
2. Config & Deploy
3. Individual Call (ADB/Fastboot/Signer)
4. Start/Stop (ADB/Fastboot)
5. Reboot (ADB/Fastboot)
6. DeviceConnectionMonitor
7. Device state check
8. Send KeyEvents (ADB)
9. Directory Reading/Parsing (ADB)
The Following 3 Users Say Thank You to k1ll3r8e For This Useful Post: [ View ] Gift k1ll3r8e Ad-Free
4th June 2014, 01:51 PM |#3  
k1ll3r8e's Avatar
OP Senior Member
Flag Delmenhorst
Thanks Meter: 650
 
Donate to Me
More
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.)
The Following 6 Users Say Thank You to k1ll3r8e For This Useful Post: [ View ] Gift k1ll3r8e Ad-Free
4th June 2014, 01:51 PM |#4  
k1ll3r8e's Avatar
OP Senior Member
Flag Delmenhorst
Thanks Meter: 650
 
Donate to Me
More
Changelog
DD.MM.YYYY | (A) = Added | (C) = Changed | (D) = Deleted | (F) = Fixed | (R) = Recoded | (U) Updated
----------------------------------------------------------------------------------------------------------------------------------------------------
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

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.

Older Changes:

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...
The Following 3 Users Say Thank You to k1ll3r8e For This Useful Post: [ View ] Gift k1ll3r8e Ad-Free
4th June 2014, 01:51 PM |#5  
k1ll3r8e's Avatar
OP Senior Member
Flag Delmenhorst
Thanks Meter: 650
 
Donate to Me
More
Showcase
ADB-Overlay made by me
ADB-Overlay
The XDA-Thread and Download can be found here

P10 Lite Toolkit made by me
P10 Lite Toolkit
The XDA-Thread and Download can be found here

P9 Lite Toolkit made by me
P10 Lite Toolkit
The XDA-Thread and Download can be found here


HTC One Toolkit from our Member @squabbi
HTC One Toolkit
The XDA-Thread and Download can be found here


--
U use this dll in ur project?

Send me a PM with:
  • Project Name
  • Small image
  • Short description
  • Download link
then i'll link it here.
The Following 2 Users Say Thank You to k1ll3r8e For This Useful Post: [ View ] Gift k1ll3r8e Ad-Free
5th June 2014, 07:43 AM |#6  
OmarBizreh's Avatar
Recognized Developer
Flag Damascus
Thanks Meter: 3,503
 
Donate to Me
More
An interesting library, time to change Droid Manager code base to use this one ^__^
Thanks for your hard work
The Following User Says Thank You to OmarBizreh For This Useful Post: [ View ]
15th June 2014, 08:42 AM |#7  
squabbi's Avatar
Senior Member
Flag Sydney
Thanks Meter: 1,592
 
Donate to Me
More
Could you put an example of how to use the adb and fastboot commands?

such as adb reboot

and fastboot reboot
The Following User Says Thank You to squabbi For This Useful Post: [ View ] Gift squabbi Ad-Free
15th June 2014, 06:48 PM |#8  
k1ll3r8e's Avatar
OP Senior Member
Flag Delmenhorst
Thanks Meter: 650
 
Donate to Me
More
Quote:
Originally Posted by squabbi

Could you put an example of how to use the adb and fastboot commands?

such as adb reboot

and fastboot reboot

Yup i'll do it right now

#EDIT:
Added:
Start/Stop ADB/Fastboot
Check if ADB/Fastboot is running
Device Reboot ADB/Fastboot
Sending KeyEvents ADB
The Following 2 Users Say Thank You to k1ll3r8e For This Useful Post: [ View ] Gift k1ll3r8e Ad-Free
16th June 2014, 09:22 AM |#9  
squabbi's Avatar
Senior Member
Flag Sydney
Thanks Meter: 1,592
 
Donate to Me
More
Hey another question. How would I use for example:

Code:
Fastboot.Instance().OEM.ReadCid();
I would presume there would need to be a 'string' for it to save to.

Code:
private string _cid
??

EDIT: So i deciced to try this:

Code:
MessageBox.Show("cid: " + Fastboot.Instance().OEM.ReadCid());
When I press the button it shows:



Thanks!
16th June 2014, 11:09 AM |#10  
k1ll3r8e's Avatar
OP Senior Member
Flag Delmenhorst
Thanks Meter: 650
 
Donate to Me
More
Quote:
Originally Posted by squabbi

Hey another question. How would I use for example:

Code:
Fastboot.Instance().OEM.ReadCid();
I would presume there would need to be a 'string' for it to save to.

Code:
private string _cid
??

EDIT: So i deciced to try this:

Code:
MessageBox.Show("cid: " + Fastboot.Instance().OEM.ReadCid());
When I press the button it shows:

Thanks!

Hey there

Methods/functions like "ReadCid()" returns a "List<string>" so u can do like:

Code:
string cid = string.Join(" ", Fastboot.Instance().OEM.ReadCid().ToArray());

// or

// The return are 3 lines, so we need to get the 2cnd
string cid = Fastboot.Instance().OEM.ReadCid()[1];
NOTE
I return there a "List<string> (the raw output)" coz i dun know if the output will be the same on each device.
In this case u have filter the right line ur self

Hope this helps
The Following User Says Thank You to k1ll3r8e For This Useful Post: [ View ] Gift k1ll3r8e Ad-Free
16th June 2014, 11:53 AM |#11  
squabbi's Avatar
Senior Member
Flag Sydney
Thanks Meter: 1,592
 
Donate to Me
More
Quote:
Originally Posted by k1ll3r8e

Hey there

Methods/functions like "ReadCid()" returns a "List<string>" so u can do like:

Code:
string cid = string.Join(" ", Fastboot.Instance().OEM.ReadCid().ToArray());

// or

// The return are 3 lines, so we need to get the 2cnd
string cid = Fastboot.Instance().OEM.ReadCid()[1];
NOTE
I return there a "List<string> (the raw output)" coz i dun know if the output will be the same on each device.
In this case u have filter the right line ur self

Hope this helps

Thanks again!

It worked perfectly! Another question. I'm now using a textbox to show the output like this:

Code:
MainWindow mainWin = (MainWindow)App.Current.MainWindow;
                mainWin.tBOutput.AppendText(String.Join("", "\n", Fastboot.Instance().OEM.ReadCid()[1]));
                mainWin.tBOutput.ScrollToEnd();
How can I do this but in a seperate window? Like one that is seperate from the MainWindow.

Thanks!
Post Reply Subscribe to Thread

Tags
adb, androidctrl.dll, dll, fastboot, framework

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes