yashsingh1/xdaforums huggingface dataset:
[Galaxy Ace S5830 Android Development] eryst:
Re: [DEV][OFFICIAL][2.3.8] CyanMobile eXpirience [BUILD 3]

Ok it was because of that adw laucher (which is clusterf***) , runnin smooth right after installement of Holo Laucher. Also do someone know how to turn out sound in bootanim.
[Galaxy Ace S5830 Android Development] SuperAce609:
I didn't mind the lag. I uninstalled because of the fact that I couldn't answer phone calls.

---------- Post added at 10:06 PM ---------- Previous post was at 10:05 PM ----------

I use ADW launcher in every rom I install and it never fails me. I'm using it right now and it's as fluid as it can be. The problem is NOT the launcher.
[Android Software/Hacking General [Developers Only]] QuantumCipher:
Thanks for the feedback everyone (Y) ....

Not sure if everyone has no idea what C# is or Just like using developer stuff..
[Android Software/Hacking General [Developers Only]] Saravanashines:
Thanks....

Thanks Man.. i was looking for the same... :cowboy: Can you give me tutorials for rooting and other aspects...:o Im wating for you....
[Android Software/Hacking General [Developers Only]] regaw_leinad:
Also, you could show them how to integrate my AndroidLib .NET library into it to handle all of the adb stuff :)
[Android Software/Hacking General [Developers Only]] jonahly:
Nice!! Reserved below :( Also!! I don't have experience with C# but I can learn by mistakes!
[Android Software/Hacking General [Developers Only]] Miniqpa:
Very nice tutorial!

As long it is a nexus device the rooting and flash cwm thing is the same thing except you're using fastboot commands.

kind regards
[Android Software/Hacking General [Developers Only]] menglim:
How can I get output text from cmd.exe? For example, if I have another textbox, and I want to display text. Text can be

Waiting for device ......(in case device not found)

Adb server start......depend on cmd.exe output.
[Android Software/Hacking General [Developers Only]] OmarBizreh:
+1 on that, it's the shortest way and it was the reason behind Droid Manger existence, thus this tutorial shows what goes inside your lib and it's useful for those who are learning C# for the first time, or never interacted with a process in their app :good:

OP keep up the good work :cowboy:

[MENTION=3551831]menglim[/MENTION]:

To get out put from a process, here is an example:

Process process = new System.Diagnostics.Process();
ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
startInfo.FileName = "cmd.exe";
process = Process.Start(startInfo);
process.StandardInput.WriteLine(Command_You_Want_To_Give_To_Your_Process);
outputTextBox.Text = process.StandardOutput.ReadToEnd();

Hope this helps :)
[Android Software/Hacking General [Developers Only]] menglim:
yes, it works but there is cmd.exe window pop up....after I close this window, then I can get the output. it is not in real time...thanks
[Android Software/Hacking General [Developers Only]] squabbi:
Thanks for sharing this code! :)

Is it possible for the output to show as it appears on cmd?

Thanks :)
[Android Software/Hacking General [Developers Only]] 0lzi:
Saw this last week, never programmed with C# but thought what the hell i have already done C++ at uni, some java for making an android app

so i downloaded VS2012 opened up google and went nuts, i now have a toolkit so far, downloads the sdk, extracts the sdk ( yea i know i could just pack the adb .dll's and .exe but while learning the language i might as well learn other stuff.) and i have backup/restore options for /sdcard/ and /dcim/ folders and a folder picker for backing up, contacts backup/restore ( looking to create something that will export it as a CSV or something)

so a big thanks for shedding some light on where to get started on this, now i cant stop and want to make a toolkit will loads of features lol :victory:
[Android Software/Hacking General [Developers Only]] QuantumCipher:
Thanks very much for the kind remarks everybody, it's extremely nice to know that this tutorial has helped you get into C# and this exact comment you made is what is going to get me back into this scene :good:

I will start looking into rooting devices and how I can incorporate them into ADB programs and maybe other things.
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Hey all together,

1st THX for this great thread!

-

I have some problems to get the "fastboot" output in my c# programm...

i tired it with adb and some other cmd tools all give me an output but fastboot not :(

Here my cmd launcher:

//Launch silent CMD

private string run_silent_cmd(string args, bool w = true, bool o = true)

{

string request = "";

Process process = new System.Diagnostics.Process();

ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();

startInfo.CreateNoWindow = true;

startInfo.RedirectStandardInput = true;

startInfo.RedirectStandardOutput = true;

startInfo.RedirectStandardError = true;

startInfo.UseShellExecute = false;

startInfo.FileName = "cmd.exe";

startInfo.Arguments = "/Q/C" + args;

process = Process.Start(startInfo);

if (o)

{

request = process.StandardOutput.ReadToEnd();

}

if (w)

{

process.WaitForExit();

}

return request;

}

can some1 gimme a kick in the right direction?

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] QuantumCipher:
Have you added the Fastboot.exe to your resources - for the program your making?
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Nope, its just in an subfolder so that the user can upgrade the version if a new 1 comes out ;)

i call the function like run_silent_cmd(KIT + "adb\\fastboot.exe some commands")
[Android Software/Hacking General [Developers Only]] OmarBizreh:
[MENTION=3753223]k1ll3r8e[/MENTION]

Your variable "args" should include the path for Fastboot.exe or your code should be like this (I'm using an example path in this example, you must replace it with your own path):

startInfo.Arguments = "/Q/C " + @"C:\AdbTools\fastboo.exe " + args;

OR

startInfo.Arguments = String.Join(" ", "/Q/C", Path.Combine("C:","AdbTools","fastboot.exe"), args);

(The first parameter passed in String.Join refers to separator string)

-------------------------------------------------------

[MENTION=3551831]menglim[/MENTION]

try this, enter it after you define ProcessStartInfo (let's say you named it just like in the code snippet I gave)

startInfo.CreateNoWindow = true;

now window should disappear.

if not, remove this line and keep the one I gave you in this comment: startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

-------------------------------------------------------

[MENTION=4752144]squabbi[/MENTION]

it's possible but a bit tricky, you can start by making the "Label" / "TextBlock" / "TextBox" or whatever UIElement you are using and set it's background to black and it's foreground to white, then choose "Console" font family, this should get you "Close enough" to the same output style :)

Note for anyone passing by this page:

When dealing with Directories in C#, ALWAYS use this code snippet, I will explain why at the end of this comment:

Path.Combine("Root Dir","SubDir1","SubDir2","File_You_Want_To_Use");

Where: Root Dir could be any logical partition you have on your HDD or the root dir of your application.

in my case in Droid Manager I have an internal variable (called: ExecutablePath) that saves the path of Droid Manager after installation, so in my case when I want to call an Init.d script example I use the following code snippet:

Path.Combine(ExecutablePath,"Initd_Scripts", "File_Name");

When wanting to add multiple strings together use this following code snippet:

String.Join(Separator String, params string Arguments);

Those ensure the best result, by that I mean be sure system will read them they way they are intended to be read, if you use "+" or "\\" or "@" there might be some misunderstanding by the system which happened to me when I started learning programming 7 years ago.

Good Luck :)
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Thx for the info ;)

but... "Path.Combine" tells me only 2 strings can be combined so its useless for me coz i get the path via "Application.StartupPath" and i have 2 subfolder this means i have 3 strings to combine^^

thats why i set some vars in my form...

//KIT Vars

private static string KIT = Application.StartupPath + "\\";

private static string ADB = KIT + "adb\\adb.exe";

private static string FBT = KIT + "adb\\fastboot.exe";

also fastboot will not output anything :(

i googled a bit and found some threads... in this threads they say fastboot dun use the "flush" command (!?) this will mean the output is not grab able...

i think they are right^^ coz adb or cmd it self will output something via my function only fastboot returns nothing...
[Android Software/Hacking General [Developers Only]] OmarBizreh:
Nope not true, Path.Combine takes more than two args. I've passed to it 4 args in Droid Manager, here is a screenshot about it:

Also be sure that you remove this:

using System.Windows.Shapes;

and replace it with:

using System.IO;

so that the correct "Path" class is being called. if it's not there then no need to do anything just be sure System.IO is added.

Also "Flush" command means the same as in the image below:

Fastboot does show output but on certain commands, for example when you type: Fastboot devices

you will get an output IF AND ONLY IF you have a connected device in Fastboot mode.

Or when you unlock a Sony Xperia bootloader you will get output.
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Thx for the fast reply ;)

My doc beginning is

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;

using System.Diagnostics;

using System.Reflection;

but see img below ;)

the thing with the streamwriter i dun understand^^ - tried it yesterday a few times but with no luck :(

Finally i think im too dumb... coz "adb.exe version" give me an output and "adb start-server" brings my proggy to hangup^^
[Android Software/Hacking General [Developers Only]] OmarBizreh:
Hmmm... Windows Form, to be honest the last time I worked with Windows Form application was two years ago, since 2011 I program WPF projects, which Microsoft is focusing on + it is more flexible when it comes to App UI and data bindings, that's why I use it.

There are differences between Windows Form and WPF unfortunately :-/

By the way if you consider switching to WPF you need to also learn XAML language (not XML, it's XAML) so you can play with the UI the way you want.

Good luck :)
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
OK...

so, ill recode my app in WPF.

hope u can help me again in a few days ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] OmarBizreh:
If i'm not mistaken most of your currently written code should work on a WPF app, so I don't think lots of time will need to make it a WPF project :D
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Hey there,

i got the same issue like menglim, the output is not in real-time the cmd call waits for end of the started process... Thats why my proggy hang up if i start adb via "silent cmd" coz adb starts as service "this process will never stop from alone".

info

------

process.StandardOutput.ReadToEnd(); = waits until the end of the programm is reached then it returns the full output in 1 step.

So i penetrated Google ;) - i found some things about "backgroundworker" but this could also not solve the problem, only thing i got is a hang up cmd in background^^

Here is what i found: Link

...is there any way to get an "real-time" stream output from an running process/programm/task?
[Android Software/Hacking General [Developers Only]] OmarBizreh:
Here is what you are looking for: Get realtime output from process -- StackOverFlow

Good luck :)

Edit:

I tested the code in the link on a WPF application, I made it create a tar file from a 500MB sized folder, and it gave me instant output of each file being added to the archive :)

So yup it's fully working but YOU MUST NOT execute such thing on the main thread because if your command takes time to finish executing your UI will freeze, create a different thread and execute your code ;)
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
THX THX THX :D great thats what im looking for ;)

But now im stuck again.. its the textbox which make me cry...

here a bit of my code so far...

/// <summary>

/// Launch silent CMD

/// </summary>

private void run_silent_cmd(string args)

{

ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", String.Join(" ", "/Q/C", args));

procStartInfo.RedirectStandardOutput = true;

procStartInfo.UseShellExecute = false;

procStartInfo.CreateNoWindow = true;

var proc = new System.Diagnostics.Process();

proc.OutputDataReceived += (s, e) => { LOG.Dispatcher.Invoke(new msgCallback(this.msg), new object[] { e.Data }); };

proc.StartInfo = procStartInfo;

proc.Start();

proc.BeginOutputReadLine();

}

/// <summary>

/// Print msg

/// </summary>

private void msg(string msg)

{

LOG.AppendText(String.Join("", "\n", msg));

LOG.ScrollToEnd();

}

public delegate void msgCallback(string msg);

Is there a way to get my textbox filled from another window? the markup tells me the whole time when i set the method to static that i have to set a object referencing for LOG (the textbox)... how can i make a textbox static?

i tried...

public static RichTextBox LOG = new RichTextbox();

but this dun show a box, i think there is a hidden box coz i get no errors but no outputs too...

i dun understand how to set the textbox programmatically in the UI on my whished position...

can i set the XAML box...

<RichTextBox x:Name="LOG" HorizontalAlignment="Left" Height="68.671" VerticalAlignment="Top" Width="432.238" IsReadOnly="True" IsEnabled="True" ScrollViewer.VerticalScrollBarVisibility="Auto" IsDocumentEnabled="True" UndoLimit="0">

<RichTextBox.Resources>

<Style TargetType="{x:Type Paragraph}">

<Setter Property="Margin" Value="0"/>

</Style>

</RichTextBox.Resources>

</RichTextBox>

to static?

My thought is, to set 1 textbox in the main window where all sub windows do thier output, like a log history. so the user can see what he/the tool have done.
[Android Software/Hacking General [Developers Only]] OmarBizreh:
[MENTION=3753223]k1ll3r8e[/MENTION] it's not recomended to make a UI object as a static object. You can't always guarantee that it's going to be referenced to the real object.

That's why you pass it to other window or place where you want to gain access to the object.

For example let's say in your application you created a class that handles all ADB commands, so if you initialize the class in window1 and want to use it in window2, initialization the class again will create two instances of the same class which means more memory usage and a bad coding experience.

So what you do in this case is one of the following solutions (there are more, but that's the I consider solving the same issue you are talking about):

1. If your text box is on the main window (if you open App.xaml, and "Startup URI" refers to that window, then it's the main window of your application) then you add the following code:

MainWindow mainWin = (MainWindow) App.Current.MainWindow;

mainWindow.LogTextBox.Text = "Some Text";

That will only work if the text box you want is on the main window of the application.

2. in the constructor of any window, make it require a "TextBox logTextBox" so that when you call any window, you pass your LogTextbox to any window you are calling.

Maybe my explanation is not that clear but my point of what I said:

Even if you can visually access the object you are calling, it doesn't mean you can access it from other window by coding and typing:

"logTextBox.Text"

You must refer to the parent that is currently loaded and not to a new instance of the parent (I call it parent, you might call it "container" of the textbox)

Also it's no recommended to interact with objects from other threads, you might encounter errors along the way. The best practice is to define a global property (could be defined in a class that is called from any window you have in your app) and pass that class instance to any window you want.

As for me in Droid Manager I define one instance of the class responsible of Adb server and executing adb / adb shell commands. I define it on the startup window that opens, then pass the instance to Droid Manager window to avoid having to start multiple adb server instances.

I hope this gives you the answer you want :)
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
[MENTION=4313825]DeepUnknown[/MENTION]

Thx for this really usefull infos and yes it solved my problem ;)

i wrote my own adb class too, i instance it with...

adb adbi = adb.Instance; <== in each window i open

in the class it self i have a singelton construct which handels all requests to 1 instance so far so nice ;)

but i have 1 problem, coz i write adb in realtime in my log box and if i execute 2 - 5 or more commands in a row they will not handelt in the sequence i called them...

how can i wait inside my class for handel each command until it ends and get an realtime output also? ^^

i tried some things like...

while (process.hasexited == true)

{

is_end = true;

}

but the true trigger is not called :(

if i try

while (process.hasexited == false)

{

}

if(process.hasexited == true)

{

is_end = true;

}

it will work but no output until the while is end :(

what can i do to solve this prob?

regards,

Sebastian

# Edit:

I tried now also to set the...

process.WaitForExit();

but this will freeze the ui until the program is exited, if i launch it in another thread it will stop the realtime output and returns the output after program exited.

# Edit 2:

i tried now to call cmd.exe in my process launcher, chain the commands for adb and send them via process.Arguments = args; to the cmd process this will bring the whished effect.

if there is a better way pls tell me ;)

btw. is there any length limitation for cmd command chains?
[Android Software/Hacking General [Developers Only]] squabbi:
In your second edit, does you cmd window stay opened?
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Hey there,

no i initiate the window with the param "StartInfo.CreateNoWindow = true;" so there is no open window ;)

but actual i have it again rewritten and work in threads ;) thats more better then cmd chains coz i get the output, thread for thread and launch the commands, cmd after cmd with realtime output also ;)

so now i got what i want ;)

actual script work is:

1. set all commands we need to a list

2. call run() in a own thread

3. run() walk through the array and creates for each cmd a new thread

4. in each thread i wait for end of the thread

5. while thread isAlive show sended command + realtime output
[Android Software/Hacking General [Developers Only]] squabbi:
I see.. Is there a way to get the output from the adb shell ? Or from multiple cmd windows?
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Sure, thats what i tried the last days ;)

Here a bit code... this is the thread launcher and the process launcher.

if u have some questions about this example let me know ;) i try my best to share what i have found out ;)

Regards,

Sebastian

class adb
{

...

private static bool is_exited = true;
private static bool is_done = true;
private static List<string> command = new List<string>();

...

///<summary>
/// Start the thread work and execute all given commands
///</summary>
public void Run()
{
if (is_done)
{
Thread run_processes = new Thread(DoJobs);
run_processes.Start();
}
}

///<summary>
/// Launch hidden thread to run all commands in given sequence
///</summary>
private void DoJobs()
{
is_done = false;
string[] commands = command.ToArray();
int steps = command.Count();
int stepv = 100 / steps;
stepv = Convert.ToInt32(Math.Round(Convert.ToDecimal(stepv)));
foreach(string cmd in commands)
{
if (is_exited)
{
if (IsRun() == false && cmd.CompareTo("start-server") != 0)
{
RunCMD("start-server");
while (is_exited == false)
{

}
Thread.Sleep(500);
}
is_exited = false;
RunCMD(cmd);
while (is_exited == false)
{

}
Thread.Sleep(500);
}
}
command = new List<string>();
Thread.Sleep(1000);
is_done = true;
}

///<summary>
/// Launch hidden CMD and pass given commands to it
///</summary>
///<param name="cmd">Command to execute</param>
private void RunCMD(string cmd)
{
ProcessStartInfo StartInfo = new System.Diagnostics.ProcessStartInfo();
StartInfo.FileName = Main.ADB;
StartInfo.Arguments = cmd;
StartInfo.CreateNoWindow = true;
StartInfo.RedirectStandardOutput = true;
StartInfo.RedirectStandardError = true;
StartInfo.UseShellExecute = false;

System.Windows.Application.Current.Dispatcher.Invoke(new info.msgCallback(info.msg), new object[] { String.Join(" ", "adb", cmd) });

Process proc = new System.Diagnostics.Process();
proc.OutputDataReceived += (s, e) =>
{
if (String.IsNullOrEmpty(e.Data) == false)
{
System.Windows.Application.Current.Dispatcher.Invoke(new YOUR_CALLBACK(Your "(wite in a textbox or something)"), new object[] { e.Data });
}
};
proc.StartInfo = StartInfo;
proc.Start();
proc.BeginOutputReadLine();
while (proc.HasExited == false)
{

}
if (proc.HasExited)
{
is_exited = true;
}
}

///<summary>
/// Add a command to the instance command list
///</summary>
public void WaitForCMDs()
{
while (is_done == false)
{

}
}

///<summary>
/// Add a command to the instance command list
///</summary>
///<param name="cmd">Command to add to list</param>
private void AddCMD(string cmd)
{
if (is_done && String.IsNullOrEmpty(cmd) == false)
{
command.Add(cmd);
}
}

///<summary>
/// Check if ADB process is running
///</summary>
public bool IsRun()
{
if (Process.GetProcessesByName("adb").Length > 0)
{
return true;
}
return false;
}

///<summary>
/// Get ADB version
///</summary>
public void Version()
{
AddCMD("version");
}

......
}
[Android Software/Hacking General [Developers Only]] squabbi:
Thanks for the code. I'll try implement this in my project.

Would you say this is much different from vb?

---------- Post added at 11:35 AM ---------- Previous post was at 11:16 AM ----------

Thanks for all your help! I was wondering if you knew how to do something like thiis..

http://xdaforums.com/showthread.php?t=1800335

Its near the bottom after all the CLI apps.

There is a GUI for windows, and i would like to replicate the CMD he has at the bottom. Any ideas? :confused:

:fingers-crossed:
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
[MENTION=4752144]squabbi[/MENTION]

i have my output close to your example designed^^

Link

i use the class i showed u to set and get all adb stuff but u can also handel it with 2 textboxes^^

just call

...

StartInfo.FileName = "cmd.exe";

StartInfo.Arguments = String.Join(" ", "/Q/C", "YOUR COMMAND or TEXTBOX VALUE");;

...

instead of

...

StartInfo.FileName = Main.ADB;

StartInfo.Arguments = cmd;

...

and print in the richtextbox (output box) something like String.Join(" ", "c:> YOUR.KIT >", "GIVEN COMMAND");

and in the OutputDataReceived handler you set String.Join(" ", "c:> YOUR.KIT >", "GIVEN OUTPUT");

now u have your virtual cmd console ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
I like you design! :)

I got what you meant with the console and I love it!

Since you have an HTC device, how do you get the identifier token to show up?

The log out put only shows the command given "13:08:32 fastboot oem get_identifier_token" but does not give the token.. :confused:

Or how would I get the token window to stay open?

Btw, here is my design: :fingers-crossed:

I need the output from the ADB Shell but I'm still puzzled! :eek: C# isn't my strongest language.. but visual basic (.net) is :)

Thanks for the help!