[Q] Interacting with ADB programatically - Android Software Development

Hello
I'm planning to write a program that will interact with an active Android phone (Leo specifically). I plan to do this using ADB (since it fulfills exactly what I need to do), but I'm not comfortable having to open a program shell every time, it's not really an efficient and fail-safe method of doing things.
I noticed that the ADB files in the SDK come with two dll files called adbWinApi and AdbWinUsbApi, but I couldn't import them to Visual Studio, so I'm guessing they can't be used as external resources (or they can and I'm just too ignorant). Anyway, I found no resources on how to use them, so I'm guessing adb.exe uses them, and unless someone can reverse engineer them for me and found the references I need to use, they're useless.
Does anyone have an idea how to interface with an Android device programatically? Using C# preferably, but any open 'handle' I can use would be helpful.
Thanks in advance.

This looks like it might be what you're after:
http://madb.codeplex.com/
This is a Managed port of the Android Debug Bridge to allow communication from .NET applications to Android devices. This wraps the same methods that the ddms uses to directly communicate with ADB. This gives more flexibility to the developer then launching an adb process and executing one of its build in commands.
Click to expand...
Click to collapse

Wow, looks interesting, I'll look into it.
Thanks for the great find!
Sent from my Android HTC HD2 using XDA App

Ambious said:
Anyway, I found no resources on how to use them, so I'm guessing adb.exe uses them, and unless someone can reverse engineer them for me and found the references I need to use, they're useless.
Click to expand...
Click to collapse
And why to reverse engineer a part of an open source project? Android is open, you know ;-)
http://android.git.kernel.org/?p=platform/system/core.git;a=tree;f=adb

Brut.all said:
And why to reverse engineer a part of an open source project? Android is open, you know ;-)
http://android.git.kernel.org/?p=platform/system/core.git;a=tree;f=adb
Click to expand...
Click to collapse
LOL, true. But is the SDK?
Sent from my Android HTC HD2 using XDA App

Ambious said:
LOL, true. But is the SDK?
Click to expand...
Click to collapse
I think so, I have linked ADB sources above. Maybe these sources are for adbd daemon on a phone only, but even if, then you have docs about adb protocol in OVERVIEW.TXT and SERVICES.txt files.

True, and I also noticed the ADB client emulates TCP anyway, so it shouldn't be too hard to replicate and 'hook in'. Thanks for the tip
Sent from my Android HTC HD2 using XDA App

Related

.net 2005

http://lab.msdn.microsoft.com/vs2005/welcome/default.aspx
have anybody tried messing with the beta's to make pocketpc applications ?
Rudegar said:
http://lab.msdn.microsoft.com/vs2005/welcome/default.aspx
have anybody tried messing with the beta's to make pocketpc applications ?
Click to expand...
Click to collapse
I'm a MSDN subscriber and haven't received it yet. As soon as i get it will try to publish it somewhere in the net...
Cheers
well the link i gave will let you download the beta even if you dont subscriber to msdn
it does require a passport though
havent dl'd it myself though
infolink
Rudegar said:
well the link i gave will let you download the beta even if you dont subscriber to msdn
it does require a passport though
havent dl'd it myself though
Click to expand...
Click to collapse
I'm on my i-mate now & can't find any download links on that page. It is not even published at http://msdn.microsoft.com/downloads/recent.aspx download center.
Can you post a link to a pre-DL passport auth page?
http://lab.msdn.microsoft.com/express/visualc/
https://login.passport.net/ppsecure/uisecure.srf?id=42814
me
I'm using Visual Web Developer 2005 beta.
Completely new to web development.
HTML tags were completely beyond me as was data driving asp stuff.
BUT......
VWD is a dream to use.
I now have an asp site that lets XDA equiped engineers interface with our back office systems. The database integration is simple (tho there are a few bugs) and controls autosize for the target device.
Give it a go
well the only stuff relevant for me is c++ and maybe a bit of c# so i dont end up like some creepy dinosaur like those people who started coding Cobol back in the 70's and are still at it!
suppose one have to keep a bit up with the trend
VS 2005
Hi, there:
I'm using VS2005beta1, and I think its cool except a stupid bug on device application development. I attached some screen shots here. hope these information helpful.
Unlike evc+sdk developer tool set, vs2005 includes all stuff needed to build device applications, and it supports the latest emulator which running native ARM code on an emulated arm920 device, it's much faster than the legacy emulator, the legacy i486 emulator is still suported, check the attached platforms.jpg for supported platforms, notice wince 5.0 device is in the list. :lol:
now we can program in vb.net, c#, or c/c++. the attached screen shots show these different types of projects. convenient enough hur.
well, a big problem arised when develop in c/c++, i did not try vb.net and c# coz I don't like'em. when you create a new project, two platform configurations are created, one for device and the other for emulator. I mentioned the new emulator before, remember? its cpu is an arm920, check the screen shot. this emulator is used when deploy and debug for the project's emulator configuration. but unfortunately, under the emulator configuration, the compile and linker will generate x86 executable which cannot be run on the target emulator. what is worse is that you cannot change to use legacy i486 emulator, you can not even connect to the legacy emulator, the problem may related to the virtual machine network service driver installed by the emulator installation file. I'm still checking it. until this problem is solved can we finally debug on emulator, otherwise we had the only choice to debug on the device, btw I can debug on device with no problem, it can even attach to a running process on the device
at the predicatable future, vs2005 will certainly supercede evc+sdk to become the unified development platform.
why the screen shots appear in a reverse order of my attaching? I think it should be a list instead of a stack. :roll:
Well, I think I´ll have a look at it soon. Could you check if there are any project types for deployment? Means a "setup projekt" for devices?
yeah, I forgot this one, check the shot, it support device cab project.

Opinions needed - windows adb wrapper in the works

Thanks for taking a look at it. Hopefully soon I'll have much more going on in it.
v0.1a
adb cmd shell integration
ability to script adb commands
ability to save and edit scripts
local adb, no need to download the sdk
requires:
windows xp+
.net framework 3.5
instructions:
unzip
plug in phone
run adbwin.exe
that's it, not much more to it
any ideas, thoughts, constructive criticism would be great
again, thanks for taking a look
in the future I'd like to implement possibly a drag-drop interface for adb shell ls / push / pull, etc like a file manager
Us Linux guys never get any love.. hmm
Love the idea though, keep it up.
Excellent work, can't wait to see what else is in store for this... Posted a link on the AC forum...
i've been trying to do something like this for linux users, i am just afraid that if we release a nice little GUI for any of the operating systems in order to use adb we'll have more people with messed up phones. personally i prefer to work in the terminal, i set mine to green on black to remember the old days(before my time).
tubaking182 said:
i've been trying to do something like this for linux users, i am just afraid that if we release a nice little GUI for any of the operating systems in order to use adb we'll have more people with messed up phones. personally i prefer to work in the terminal, i set mine to green on black to remember the old days(before my time).
Click to expand...
Click to collapse
True I think terminal is just easy to use for everything.
tubaking182 said:
i've been trying to do something like this for linux users, i am just afraid that if we release a nice little GUI for any of the operating systems in order to use adb we'll have more people with messed up phones. personally i prefer to work in the terminal, i set mine to green on black to remember the old days(before my time).
Click to expand...
Click to collapse
yeah, but a properly built GUI would save a lot of time on daily chores like typing adb push path path. could have programmed a java version, but I am not sure if I would spend more time drawing the window or implementing the logic...
This is a great idea. I'd pay for a license.

[DEV] AndroidLib - .NET Android Device Communication and Management Library 01.20.13

Description:
AndroidLib is a .NET assembly written in C# (C-Sharp) that easily handles communication between a connected Android device and your program. Currently, there is a large amount of automated controls, eliminating thousands of lines of code the programmer has to write themselves. The class AndroidController is a semi-wrapper of the ADB (Android Debug Bridge) binary. The other class you will be working with the most is the Device class. This class contains useful information about the device (for example: software/hardware info, memory info, battery stats, mount points for partitions, root status, busybox information, and much more), as well as exposes many instance methods to control your phone such as Rebooting, Mounting Filesystems, Push/Pull/Install Files, and much more to come. AndroidLib contains all of the Android binaries necessary to work properly. AndroidLib also assumes that the phone's USB drivers are already installed correctly on the target machine, or that your program will take care of it on it's own.
This is perfect for any developer who would like to create, for example, an auto-rooter or any other application that needs to connect with Android devices through a .NET application. AndroidLib provides all the methods needed to communicate with the Android device. This will cut back on the code you have to come up with and write yourself by a HUGE amount!
What it does:
Provides easy-to-use code for communicating with Android devices in .NET
Provides easy access to information about the connected Android devices
Has a large list (and growing...!) of methods that control connected Android devices
Please credit the work here by me in your own projects; not only to give thanks to me and the many hours I am putting in to this project, but so others know where to find it if they need to!
Usage:
Add a reference to AndroidLib.dll in your .NET project and begin using this great API. Please refer to the "Getting Started.txt" guide and full documentation included in the zip.
Requirements:
.NET 3.5 or Higher
Changelog (Only most recent version displayed, full Changelog in download)
Version 1.5.1.0 | 01.21.13
Fixed Device.InstallApk() bug
Download Latest Release
GitHub
Online Documentation
Sample Solutions Using AndroidLib:
C# (C Sharp)
Visual Basic (VB)
AndroidLib Featured Projects by XDA Users:
RegawMOD Evo 4G LTE Rooter - XDA
RegawMOD CDMA Hero Rooter - XDA
RegawMOD Rebooter - XDA
Droid Manager by DeepUnknown - XDA - Google
Android SMS - XDA - Home Page
Quick ADB Pusher by Goatshocker - XDA
reserved just in case
It's very useful, thank you very much, im planning to code a Filemanager like qtadb, because qtadb is sucking too often
In the process of completely redesigning the library (due to coding stupidity), basically from the base class up. I should have a beta1 out by this weekend for testing. All that are interested in beta testing this library for their Android .NET projects, post here and I'll add you to the list of testers!
It would be great!
Can you add something like adb forward? So we can connect to an android service without using ADB, that as we all know sucks!
Mrc527 said:
It would be great!
Can you add something like adb forward? So we can connect to an android service without using ADB, that as we all know sucks!
Click to expand...
Click to collapse
Yeah, I'll throw in a method to create a port forward. What I have now uses the bridge, which is included in the assembly, but handles all of it silently and very well. I should have a build out soon (most likely this weekend). As long as you don't dispose the AndroidController object, that port forward will be good, so you can use your own Socket code
regaw_leinad said:
Yeah, I'll throw in a method to create a port forward. What I have now uses the bridge, which is included in the assembly, but handles all of it silently and very well. I should have a build out soon (most likely this weekend). As long as you don't dispose the AndroidController object, that port forward will be good, so you can use your own Socket code
Click to expand...
Click to collapse
Great work! really, great idea!
You can change the .NET to 3.5? I too code in .NET, and I try to keep the .NEt version as low as possible!
SimranSingh said:
You can change the .NET to 3.5? I too code in .NET, and I try to keep the .NEt version as low as possible!
Click to expand...
Click to collapse
Yeah, I actually did that a few days ago, forgot to update the OP.
Where is it possible to download?
Mrc527 said:
Where is it possible to download?
Click to expand...
Click to collapse
I'm just writing the documentation for this. I'm pretty sure I'll have it done today.
Yeah! Just a joke. When finished I'm sure will be a success!
Inviato dal mio Galaxy Nexus usando Tapatalk
Making some last minute changes to the Device class, then I'm going to finish the documentation and release it. Just keeping you updated.
Ok everyone, the new documentation is up (Online) (Offline). For the beginning of this product, I would like developers to pm me, or reply here in the thread if they would like to try the library out for their project, and I'll send it to them. It's still under development, and there will be updates coming out regularly. Shoot me a pm or post here and I'll send you a link right away.
regaw_leinad said:
Ok everyone, the new documentation is up (Online) (Offline). For the beginning of this product, I would like developers to pm me, or reply here in the thread if they would like to try the library out for their project, and I'll send it to them. It's still under development, and there will be updates coming out regularly. Shoot me a pm or post here and I'll send you a link right away.
Click to expand...
Click to collapse
Meeeeeeeeeeeeeeeeeeeeee!!
Hi,
I'm C# developer and i would like to try your lib, can you send it please?
Thanks in advance, and great work.
Hey guys, check the first post to download the library. It is in a zip which includes the dll, "Getting Started.txt" and the documentation. Please read the getting started guide before diving into it! And please give me feedback on it. That would be much appreciated in order for me to deliver a better product.
Dan
Great work!
It works without any problem to me!
Next update will have these features internally implemented:
Package Manager (inside the phone's shell)
Ability to install/uninstall apks
Ability to freeze/unfreeze apks
Ability to backup/restore apks
A class that will handle signing of update zips
More internal information about connected device (cpu, environment, etc)
Possible wrapper of AAPT
That seems like a good amount for the next update. Please post anything you wish to share about the library after using it for these few days.

[HELP] Analysis tools that detect common bugs in Android app development

I am looking for analysis tools specific for Android app development!
I have found many tools online that are not specific for Android, only for Java, either free or commercial, like the famous FindBugs but it is not interprocedural so for example it loses several bad NullPointerExceptions that may occur at runtime! Other tools (like CheckStyle) perform just a syntax check that sometimes is not so powerful, and other tools are not suitable for Android app development
What are, among the available tools, those that you prefer and really use?
What kind of properties do these tools check?
What kind of bugs do these tools detect and remove (among the most common errors that an Android developer may do)?
Please help me with sharing your experiences and suggestions, thanks!
Nobody uses any tool for detecting bugs?
What kind of bugs are you specifically looking for? Solving NullPointers is hard to do automatically, it'll probably just show you where the error is and what it is.
And the emulator/logcat does that, too...
bassie1995 said:
What kind of bugs are you specifically looking for? Solving NullPointers is hard to do automatically, it'll probably just show you where the error is and what it is.
And the emulator/logcat does that, too...
Click to expand...
Click to collapse
I would like to detect the most common errors that may happen during Android app development, like NullPointerExceptions, ClassCastExceptions, OutOfMemory Errors, and so on... but with tools like FindBugs that don't need to execute the app first.
subtask said:
I would like to detect the most common errors that may happen during Android app development, like NullPointerExceptions, ClassCastExceptions, OutOfMemory Errors, and so on... but with tools like FindBugs that don't need to execute the app first.
Click to expand...
Click to collapse
I don't think that's really possible, it would have to be able to reason about and come up with the behaviour of your code like a human... Computers need to run it. The easiest thing you'll get right now is an explanation of what went wrong where, I think...
bassie1995 said:
I don't think that's really possible, it would have to be able to reason about and come up with the behaviour of your code like a human... Computers need to run it. The easiest thing you'll get right now is an explanation of what went wrong where, I think...
Click to expand...
Click to collapse
If you run FindBugs in your source code, it is able to detect many things, like potential NullPointerExceptions, before running your app...but unfortunately it is not powerful enough to detect interprocedural NullPointerExceptions...that's the reason I am looking for something different...
subtask said:
If you run FindBugs in your source code, it is able to detect many things, like potential NullPointerExceptions, before running your app...but unfortunately it is not powerful enough to detect interprocedural NullPointerExceptions...that's the reason I am looking for something different...
Click to expand...
Click to collapse
Yep, that's what I meant. Anyhow, I don't know about anything like it .
The Android SDK provides some API for automatic testing.
You will need to create a test project which checks the functions you want to achieve.
This can be used to ensure that your app is still working correctly after adding new features.
Hi
"static analysis tools" is probably the term you want to be using when looking for these sort of tools, the wikipedia page give a good selection to be going on with http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis
Although I would add that if you're getting a lot of these sort of errors then you probably need to work on your own code writing skills and take the time to understand how and when these sort of issues occur rather than just relying on a plethora of tools which keep you dumb to what's going on! You'll benefit from it in the long run
One thing you might give a try is JetBrains Android Studio. It seems to have a decent static analysis tool which is the same used for ReSharper with Visual Studio.
Try Lint, it comes with ADT,
with Eclipse you can right click your project, ans under android tools you will see something like check lint errors
It will create lots of errors, which are just recomendations, you can simply delete those errors.
Tapatalked... just Tapatalked...
If you're mainly looking for a way to detect NPEs then IntelliJ/Android Studio comes with NPE (and other exceptions) detection. It's based on a new set of annotations implemented in the latest SDK and is very accurate, much better than Eclipse's code analysis.
But honestly, the best tool to find bugs remains Logcat imo, it's verbose enough to find-out the origin of most bugs.

[Q] Do I need to write drivers?

I have fair number of years of programming behind me. But I haven't tried anything for Android, as I dislike Java.
But I want to try. I want to make something that works at low level, say, like a firewall. It acts as a filter between two communicating parties/devices.
To write anything like that, can someone suggest which is the best approach - code in Java (if it can perform such a feast) or code driver in C?
Thanks much!
Regards,
Nayan
Sent from my Micromax A117 using xda app-developers app
The interesting thing in such low level projects is the entry point: So for a firewall you only have to acces iptables because android has linux kernel. So no C-part, no drivers, only plain java. See AFWall, it's an open source firewall.
EmptinessFiller said:
The interesting thing in such low level projects is the entry point: So for a firewall you only have to acces iptables because android has linux kernel. So no C-part, no drivers, only plain java. See AFWall, it's an open source firewall.
Click to expand...
Click to collapse
Excellent! I would certainly study AFWall. Thanks for the reference.
But actually, my quest doesn't stop here. I am exploring Android, and Google's restriction of "UI to be built only via Java". (I am not interested in scripting and widgets for now, unless they are absolutely needed.)
I want to know the answers for same question (driver or app) for the following:
* Network Filter [EmptinessFiller, you already answered this as Java]
* Disk (SD cards) (for many various purposes) - file system should not block the intention, hopefully.
* USB filter
* SMS filter
I am still thinking of other categories. Will write more later.
Please suggest and refer. Thanks again!
General answer: Your app is always built in java. (It's UI components, it's LifeCycle (Activity, Service, Broadcastreceiver))
You may include native code, but that does not have more possibilities. It's only a little bit quicker.
Forgotten: If you have root, you may want to change some binaries, because you can't change things in an app. There you need native code of course.
EmptinessFiller said:
You may include native code, but that does not have more possibilities. It's only a little bit quicker.
Click to expand...
Click to collapse
Shame, isn't it? Too much power in Java's hand
EmptinessFiller said:
Forgotten: If you have root, you may want to change some binaries, because you can't change things in an app. There you need native code of course.
Click to expand...
Click to collapse
My point exactly! Low level stuff is best written in native code.
But right now, I am learning how to.
cnayan said:
Shame, isn't it? Too much power in Java's hand
My point exactly! Low level stuff is best written in native code.
But right now, I am learning how to.
Click to expand...
Click to collapse
Have a look at the Android NDK and this guide about the development of root apps.
nikwen said:
Have a look at the Android NDK and this guide about the development of root apps.
Click to expand...
Click to collapse
Thanks for the link. Good stuff, but won't help in my targets... unless an example is seen.

Categories

Resources