yashsingh1/xdaforums huggingface dataset:
[Android Software Development] DVS_Sokar:
in the Call Stack it just points to and nothing else.

AndroidLib.dll!RegawMOD.Command.HandleOutput.Anony mousMethod__1(object sender, System.Diagnostic.DataReceivedEventArgs e) Line 86 Command.cs
[Android Software Development] IceDragon59:
Even more timeouts we need to update. I'm going to find and edit all references to forming and executing commands to try to resolve this issue.
[Android Software Development] DVS_Sokar:
Same Error for Line 79 in Command.Cs now.
[Android Software Development] .torrented:
Mod Delete
[Android Software Development] the_b00gyman:
not working for 4.4?

is this project suitable for Android 4.4?

I upgrated my Samsung S3 to a custom 4.4 ROM and the example project seems to have it troubles as it only throws exceptions!

I wanted it to use to sync files between PC and Android Device. Is there a workaround for it or another similar project like this? Or should I wait a couple of months and it might be included then?

cheers,

the_b00geyman
[Android Software Development] regaw_leinad:
I have set the default timeout now to -1, which implies infinite time. Now all processes will go on until finished (may be infinite) unless a timeout is specified.
[Android Software Development] IceDragon59:
Your GitHub hasn't been updated with timeout changes yet, so I was wondering if you you had implemented the timeout into the other Command methods that I recommended? I'm pretty sure I got that part down. I was working on implementing an optional timeout parameter for every method which calls any of the multitude of Execute and Form commands, but haven't had time to test all of them yet. There are a lot of scenarios to account for, and not enough time in the day between sleep, work, family, etc.
[Android Software Development] DVS_Sokar:
You shouldn't have any problems with 4.4 this is specific to a Android Version because it's just doing ADB and Fastboot commands via Class execution.
[Android Software Development] regaw_leinad:
Sorry, posted before I committed and still working on a few things. Trying not to break the public interface lol
[Android Software Development] IceDragon59:
lol. I understand exactly where you're coming from. It's precisely why I haven't submitted any commits yet.
[Android Software Development] regaw_leinad:
Alright, how does that look to you? Don't think I broke any public interfaces :p

https://github.com/regaw-leinad/AndroidLib/commit/1b460b5af359647fb3a25d871f5d2bb3a37439e4
[Android Software Development] regaw_leinad:
I'm thinking about removing the embedded adb/fastboot binaries and having the client handle pointing to the sdk platform tools (where those binaries reside). This change (and quite a few others regarding OS handling) can make AndroidLib OS independent, if one chooses to use the Mono framework.

Thoughts?

EDIT: Also looking into passing commands via TCP (aka no binaries)
[Android Software Development] DVS_Sokar:
Implementing a Timeout in RunProcessWriteInput resolved my issue with the Program freezing.

internal static void RunProcessWriteInput(string executable, string arguments, params string[] input)
{
using (Process p = new Process())
{
p.StartInfo.FileName = executable;
p.StartInfo.Arguments = arguments;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardInput = true;

p.Start();

using (StreamWriter w = p.StandardInput)
for (int i = 0; i < input.Length; i++)
w.WriteLine(input[i]);

p.WaitForExit(1000);
}
}

---------- Post added at 03:33 PM ---------- Previous post was at 03:31 PM ----------

I actually love the fact that you did include the binaries. It helps my program by not needing to include adb/fastboot or relie on searching for them before my program can execute the commands. Noob users don't install them in the same place all the time. I dumped my ADB/Fastboot commands in Windows\System32 to make it system wide.
[Android Software Development] regaw_leinad:
About to update my repo with the latest timeout changes. Go ahead and pull those changes when I post again here.
[Android Software Development] regaw_leinad:
Pushed new timeout changes to the repo. Deprecated some internal methods as well.
[Android Software Development] DVS_Sokar:
Ok I will keep an eye on it.
[Android Software Development] regaw_leinad:
In case you missed my last post, I just pushed the changes
[Android Software Development] DVS_Sokar:
Ok going to pull it now.
[Android Software Development] IceDragon59:
I may be crazy, but it seems that the timeout you implemented in the methods in the Device class doesn't actually affect anything when issuing a command. It's an optional parameter, but it won't do anything if you do opt to use it. Example:

public bool PullFile(string fileOnDevice, string destinationDirectory, int timeout = Command.DEFAULT_TIMEOUT)
{
AdbCommand adbCmd = Adb.FormAdbCommand(this, "pull", "\"" + fileOnDevice + "\"", "\"" + destinationDirectory + "\"");
return (Adb.ExecuteAdbCommandReturnExitCode(adbCmd) == 0);
}

Should include the "WithTimeOut" parameter similarly as such:

public bool PullFile(string fileOnDevice, string destinationDirectory, int timeout = Command.DEFAULT_TIMEOUT)
{
AdbCommand adbCmd = Adb.FormAdbCommand(this, "pull", "\"" + fileOnDevice + "\"", "\"" + destinationDirectory + "\"").WithTimeOut(timeout);
return (Adb.ExecuteAdbCommandReturnExitCode(adbCmd) == 0);
}

All the methods that you altered in the Device class seem to be lacking that option.

Also, while I was attempting to make the modifications you posted today, I noticed that Command.RunProcessOutputContains has no references to it, and it's in a private class which users can't invoke, therefore it either need not exist, or we need to create an ADB/Fastboot command which references it, such as ExecuteAdbCommandReturnContains or ExecuteFastbootCommandReturnContains. It does appear as though the Device.InstallAPK method effectively uses it, but doesn't utilize the method created for it. Perhaps you could look into that.

And just nitpicking, but you misspelled "default" in the "DEFAULT_TIMEOUT" definition which displays every time you hover over it, and every time I hover over it (which seems to be a lot for some reason), it irks me.

Other than that, it looks great! Thanks for making time for that. I was getting close to that end with my own modifications, but you beat me to it. You never did specify whether you wanted overloaded methods or optional parameters, so I was doing both and was going to post and see which you liked better.

I'm going to make a pull request with the changes that I noticed immediately, and will update on the status of the library when I've gotten more time with it. Thanks again!
[Android Software Development] regaw_leinad:
All amazing feedback, thank you. I ended up writing the changes before you submitted your pull request, so I'm probably going to just push mine (no hard feelings :p ). Basically the same as yours except where the .WithTimeout() was placed. You'll see. Made too long of a line in the editor for me haha. Also, I wanted the Command class to be at a lower level than Adb, so calling a Command method in the Device class doesn't seem right to me. I just removed the method ...ContainsOutput... since the client code can handle the contains functionality. Not sure why I implemented that in the first place, since the command class should just be about executing and returning the output of the processes, not any logic.

Oh and I normally use overloads, but I figured since default param values are part of C#, I might as well use them, and not expand all the source files with 49834534 more lines of code lol.
[Android Software Development] IceDragon59:
That's fine. As long as everything gets in there, it doesn't matter if it comes directly from my code.
[Android Software Development] DVS_Sokar:
Lol well I guess I should pull it again. I didn't find any issues with my program other then changing the Obsolete code to the new classes which was to be expected.
[Android Software Development] .torrented:
Compiled latest from source and my end seems to be doing better handling the commands and such.
[Android Software Development] regaw_leinad:
:D
[Android Software Development] .torrented:
Pull Request Sent! https://github.com/regaw-leinad/AndroidLib/pull/14/files

Running my new change and everything is going smooth now!

edit2* what I've noticed is that even though the device comes online it still cant access the shell until sometime after the boot is near finished

PS C:\Users\Ryan> adb shell dumpsys battery
Can't find service: battery
[Android Software Development] V8Mike:
Before I spend too much more time looking at this library I wanted to make sure it would do what I wanted.

As a noob Android developer as I understand it you have to create a TCP/Socket connection within the USB connection to enable an Android app to communicate with a C# app. I have an app someone else has developed running on Android and that connects to a Java server running adb.

I'm hoping I can use this library to do what the Java server does, including the passing of data to the client app on Android.

Am I in the right place with this library? and what in the docs is it I'm looking for?

I saw in the first forum page the mention of sockets, but that was a while ago and I guess the library has moved on somewhat since then.

I've already downloaded the test/demo app and had it working, which is great, so if the library will help me do what I need then I'll be a happy bunny.

Thanks...
[Android Software Development] .torrented:
I had another idea for the BatteryInfo.cs fix. Instead of running a normal shell command how about just a normal adb command using the "wait-for-device" param

Adb wait-for-device shell dumpsys battery <-as the command instead of what I sent in my pull request. I'll test this in the morning after I get up and have my coffee.

=====================================================================================================================

Played around with my idea and it didn't work the way I expected, so for now I am leaving in my "fix" as it is the only way I can get it to function the way I want it to.
[Android Software Development] Rain_Saeid:
fastboot command

how to use Fastboot Command in vb.net :confused:

pls Help me..
[Android Software Development] IceDragon59:
Fastboot.ExecuteFastbootCommand(Fastboot.FormFastbootCommand(command,[params]))

Example!

Fastboot.ExecuteFastbootCommand(Fastboot.FormFastbootCommand("devices"))
[Android Software Development] DVS_Sokar:
Hi Guys,

I am trying to implement a real time monitor thread for the device state so I can determine what state the device is in prior to executing commands.

I have created a backgroundworker thread that basically checks to see if android.HasConnectedDevices(); and then running that through a loop to exit only when a variable bool pendingClose is detected as true. OnFormClosing looks for the variable and kills the background process.

It's working but I am worried about the loop on starting and stopping the adb server over and over. Is this ok or should I look for an alternative?

I am thinking about modifying the code simply to android.UpdateDeviceList() instead of starting and stopping a instance over and over again.
[Android Software Development] .torrented:
you could run an "adb status-window" in a background thread and look for it to become "Unknown" in another instance of the server

←[2J←[2HAndroid Debug Bridge
State: device
←[2J←[2HAndroid Debug Bridge
State: [COLOR="Red"]unknown[/COLOR]
[Android Software Development] DVS_Sokar:
Only problem is that my program is reporting the state to the status bar

I.E. Fastboot, Recovery and ONLINE (for a normal boot) this is for my program to execute the appropriate commands at the correct time.

I try to make my applications as userproof as possible.

Right now my application does the following:

1. Checks for HTC Driver installation - Not it tells the user to install it. (I might automate a install later)

2. Checks for .Net 4.5 or 4.5.1 installation - Not it tells the user to install it. (I might automate a install later)

3. Checks to see if the device is connected - Not tells user to connect device on usb

4. Monitors the USB state of ADB to determin the bootmode (ONLINE, RECOVERY, FASTBOOT or OFFLINE) (This is the backgroundworker thread I was talking about)

5. Once confirming all those it then pulls the Build.Prop of the device to gather Carrier, Model, Software Version, Hboot Version to determine what Settings are enabled for the UI.

I am new to C# programming and programming in General (2 months) but I pick things up quick with samples and examples of code. I need to learn how to parse strings next for a Build.Prop. Comparison table as many users Build.Props vary by Rom.
[Android Software Development] .torrented:
My code my be a little messy but if you want to look at what I have for my application to get some ideas from you can view it on github, it might help you it may not.

https://github.com/torrented/AFU/blob/master/MainForm.cs <- this is where the main code is (also open sourced)

[MENTION=2326081]regaw_leinad[/MENTION] if you want to take a look as well and see if I have anything that would be better suited a different way that would be nice :)
[Android Software Development] DVS_Sokar:
Ok Nice.. give me a nice Reference Points.

I haven't tried putting up my source on GIT.

I tried to compile your source but it's crashing while trying to pull device info. UpdateDeviceList is failing. I think it's my desktop copy of adb though.
[Android Software Development] .torrented:
Make sure you are using my precompiled DLL or my source won't work if you need too get the DLL source from my github and compile it

Adb is packed into the DLL as it won't interfere with any adb that is installed on your machine

Changed my MainForm.cs again, added a few fixes!
[Android Software Development] Rain_Saeid:
No answer

tnx IceDragon59

But.. No answer your example.. (fastboot command)

are u have other example?

or more Help?
[Android Software Development] .torrented:
Fastboot.ExecuteFastbootCommand(Fastboot.FormFastbootCommand("devices"))

FastbootCommand myCmd = Fastboot.FormFastbootCommand("reboot-bootloader");
Fastboot.ExecuteFastbootCommand(myCmd);

these are the same thing, maybe this will help (i used "reboot-bootloader" rather than "devices")

Maybe you could explain what you are trying to achieve?

You want to declare an object of FastbootCommand and set that to the fastboot.formfastbootcommand(" --Place what command you want fastboot to execute-- "); ***(you do not need to include the word "fastboot" into the string as it will already do this)***

then you will want to execute your command by using the Fastboot.executeFastbootCommand(this is the object of FastbootCommand); ***(This will execute the fastboot command in the string from that last method)***

So in my example when I call "fastboot.executefastbootcommand(myCmd); it will essentially execute "fastboot reboot-bootloader" and reboot the bootloader if there was a device connected
[Android Software Development] alonsoch:
someone can upload just the .dll file??
[Android Software Development] regaw_leinad:
Download the source from Github. Open in Visual Studio. Press F6. Project Directory -> bin -> Debug -> AndroidLib.dll
[Android Software Development] DVS_Sokar:
This.. and just ignore the error about no executable.
[Android Software Development] Rapscallion16:
Is there a way to check the progress of certain commands? I want to implement a progress bar while some commands are running, but I can't find an accurate way to do so.
[Android Software Development] regaw_leinad:
Since they are blocking commands, you can't really get the progress of them. You CAN, however, use a continuous progressbar while the process is running, and stop it afterwards.
[Android Software Development] .torrented:
Or something like this:

**this is example code from my program**

//Logcat background worker
private void logcatWorker_DoWork(object sender, DoWorkEventArgs e)
{
AdbCommand logcat = Adb.FormAdbCommand("logcat", "-d",level);
string logcatOutput = Adb.ExecuteAdbCommand(logcat);

[COLOR="Red"][B]for (int i = 0; i < 100; i++)
{
this.logcatWorker.ReportProgress(i + 1);
Thread.Sleep(5);
}[/B][/COLOR]

e.Result = logcatOutput;
}
private void logcatWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
[COLOR="red"][B]this.progressBar.Value = e.ProgressPercentage;[/B][/COLOR]
}
private void logcatWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
}

The RED section is what I am emphasizing on.
[Android Software Development] regaw_leinad:
Yeah, technically that fakes progress, because it will only update the progress bar AFTER the process has finished anyways. Also, make sure .ReportsProgress is set to true if you do that.
[Android Software Development] hoseyni-:
problem in use android lib

hi.i have problem in use android lib .. i cant execute fastboot command in my program ..can anyone help me by example program ???
[Android Software Development] _Logie:
Absolutely fantastic development mate. Really really good work you've done there.

If I ever jump back to C# for an Android app I will most definitely incorporate your library.
[Android Software Development] regaw_leinad:
Updated to v1.0.0.1, minor nightly bug fix. Stay tuned in for v1.0.1.0. If developing right now with 1.0.0.0, you should update the dll right away, due to some issues with certain phones and how I coded the Process class.
[Android Software Development] Strict:
Nice, I'll going to try it in a few minutes.

Thanks for the update :)

Edit: I'm getting this error - Requested value 'TY' was not found.
[Android Software Development] broodplank1337:
Hi, this dll is awesome! The options it has are perfect for my Galaxy S Plus Configurator. Very nice development which will help loads of people programming their android related application. The only thing is that I'm not experienced with calling dll's at all, I use AutoIT v3 as programming language, it's a pretty easy language but has a large amount of functions. Luckily it allows you to call dlls, the help reference says this:

Here is a link to the full reference: DllCall()

DllCall ( "dll", "return type", "function" [, type1, param1 [, type n, param n]] )

Ok so for example, I tried calling the device status (don't laugh at me) with this command:

$open = DllOpen(@ScriptDir&"\AndroidLib.dll")
DllCall($open, "get", "DeviceState", "get")
ConsoleWrite(@error)

Returns "4", which means: "bad number of parameters"

I know the real developers are laughing at me right now but I have no clue on how to continue that line, I tried allot of things but can't figure it out, is there someone who can tell me how you can call the dll correctly using this syntax?:

DllCall ( "dll", "return type", "function" [, type1, param1 [, type n, param n]] )

So basically I need to know which "return type" i need to use and how I call a function in the dll correctly.

Thanks in advance, this dll is great! +1 to dev
[Android Software Development] regaw_leinad:
:( Unfortunately, AutoIt is not able to make calls to .NET dlls. .NET dlls are not compiled the same ways as normal Win32 executables, and don't have an export table for use like this. Even if they did, I'm not sure it would work with AutoIt anyways, because the way I programmed it, the main class AndroidController handles all of the Devices which in turn handles all of the device's information. There are no static methods/properties to call regarding any device data :( Sorry I can't help out with that! BUT, I can show you to this website, which I used years ago when I started learning Visual Basic/C#. Go HERE, and I highly recommend either the Visual Basic .NET for Beginners or C# for Beginners, they cost around $8 for each pdf, but they are both around 450 pages and really do give you exactly what you need to start out, and towards the end get a little more advanced. They are exactly what I used to start with VB and C# back in the day, and are updated now to VS2010. PM me if you want any more help!
[Android Software Development] broodplank1337:
Oh that's a pity, really wanted to use it with AutoIT. Thanks for the link I will take a look there. I currently have C# lessons at school, so could give it a shot in C# I guess. This could be an option, I think of it like this:

Creating a C# application which includes all functions from the dll, which is available to call it with a parameter, like this:

Run AndroidLib.exe "DeviceStatus"

and in the C# application the parameter that is given (%1) is returning the function, could read it out with STDREAD or so. but still I think this isn't a great solution to be honest.

Thanks anyway, good luck with your awesome dll :D
[Android Software Development] EYESTRA1N:
Wew!

im also having problem on calling it on dot net :'(

while im still reading driveInfo Class

hope someone here could make it more easy for me to call it

TIA

regrds
[Android Software Development] regaw_leinad:
What are you trying to do, be more specific. You should not have to use the DriveInfo class to use my dll... Did you read the included "Getting Started.txt"?
[Android Software Development] EYESTRA1N:
i just read now,

okey now i understand a lil bit.

i know i can figure this out.

anyway thank you so much for this thing

its a big help for us

i really appreciate it
[Android Software Development] regaw_leinad:
Once I finish updating this and a rebuild of my HTC Hero Rooter using this library, I will write a sample windows forms application using AndroidLib, and give out the source of that sample project, so you can see how I would do it.
[Android Software Development] drcell:
May i get an example about getting connected device like "adb devices" in Visual Basic 2010? For example when i click a button, connected device's serial no can appear in the text box. If no device connected an error appear in the same text box.

I am not an expert but i need a small app for connecting to android device and getting if its connected.

Thanks...
[Android Software Development] regaw_leinad:
See post #2 in this thread. I added a post of sample Visual Studio solutions so you can see how to use AndroidLib the way I intended it to be used. More to come as I update them
[Android Software Development] regaw_leinad:
Also, if you use this and/or find it useful to anyone, PLEASE hit the "Submit Thread as News Tip" button at the top of the thread! That might get this library on the front page of xda, which in turn lets many more developers see it!
[Android Software Development] regaw_leinad:
Updated to 1.0.0.2:

Fixed FileSystem bug w/ Xperia X10

Now updates internal device list on separate thread to reduce "freezing" in Windows Forms

Added Device.PullFile()
[Android Software Development] Mrc527:
Sorry man,

1.0.0.2 wont recognize any phone..... :D

And...is it possible to manage the phone through a Bluetooth connection? Would be really cool! :D
[Android Software Development] regaw_leinad:
Recognizes all fine for me, what exactly do you mean? When you call android.ConnectedDevices, it's always empty? check android.HasConnectedDevices, that'll tell you if there are any connected.
[Android Software Development] Mrc527:
Yep.

This simply tells me every time "No phone connected". And in "android.ConnectedDevice" there is nothing.

Device device;
AndroidController android = new AndroidController();
if (android.ConnectedDevices.Count < 1)
{
MessageBox.Show("No phone detected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (android.ConnectedDevices.Count > 1)
{
//TODO: Select phone
}

device = android.ConnectedDevices[0];

Console.WriteLine("Connected Device - {0}", device.SerialNumber);
Adb.ExecuteAdbCommandNoReturn(android, Adb.FormAdbCommand("forward tcp:" + adb_port + " tcp:" + adb_port, ""));

using the same code with the 1.0.0.1 release is working.

I'm testing with a Galaxy Nexus, a Desire Z and an LG Optimus One.