[Beta] Win86emu: Running x86 apps on WinRT devices - Windows RT Development and Hacking

The project is abandoned.
As I no longer own a Windows RT device and I'm not willing to use Windows RT anymore, unless Microsoft would make it more open (at least to run your own desktop apps) - I've decided to stop working on this project.
As usual I'm publishing complete sources of this tool. Feel free to use them in your own projects or to continue developing this one - only leave my copyrights somewhere.
Don't ask me how to build the sources or to explain anything in them. Figure that out yourself.
The project is abandoned. Sorry.
I'm presenting a tool that allows running a set of x86 Windows applications on Windows RT (ARM) tablets. Its goal is to support all apps except for those that:
- require much CPU power,
- use complex features that were cut out from WinRT like D3D9 extensions or OpenGL,
- require drivers or specific services,
- make heavy use of COM interfaces,
- use undocumented windows internals,
- apps that use .NET framework,
- x86 Metro apps,
- 16 or 64 bit Windows programs,
- buggy apps that require special workarounds.
The tool is currently on a beta stage, so don't expect much from it. It is far from being complete, but at least it runs something.
Current version: 0.061
Just a minor update. The project is not dead, I just had no time to continue the development.
Attached the fixed ntdll.nt.dll that works under Windows RT 8.1 (Microsoft removed some NTDLL exports, so I had to add more stubs). This fix is not needed on RT 8.0.
To install it: extract the attached 0.061-ntdll.nt.dll.zip to c:\x86node\windows\SystemNT\ overwriting the existing file.
Autostarting x86 programs does not work on RT 8.1 ("can't install CreateProcessInternal hook"). I'll look on this later.
Don't ask on jailbreaking the 8.1 beta in this thread - there is a good progress on it, more info would be on release (in october or when WZOR would leak the RTM).
Current version: 0.06
Seems that archive is too big to be attached, so I've uploaded it to google drive and here
Installation: extract the archive on your unlocked Windows RT device, run the MSI file and follow the instructions.
Note: Uninstall the previous version before installing a new one.
List of compatible apps is in this post: http://forum.xda-developers.com/showthread.php?p=40924456
Trademarks
Windows is a registered trademark of Microsoft Corporation. ReactOS is a registered trademark or a trademark of ReactOS Foundation. All other trademarks are the property of their respective owners.
Disclaimer
This software is provided "as is". Use it on your own risk. I make no warranties as to performance, merchantability, fitness for a particular purpose, or any other warranties whether expressed or implied. No oral or electronic communication with me shall create a warranty of any kind. Under no circumstances should I be liable for direct, indirect, special, incidental, or consequential damages resulting from the use, misuse, or inability to use this software, even if I has been advised of the possibility of such damages.
I'm trying my best to make the software working, but I can't guarantee that it is free from defects.
All beta versions of this tool would be freeware. You may freely use it for your own, embed it into your tool, but you can't use it commercially without my confirmation. You can disassemble, analyze or modify this tool for yourself - later I'll provide SDK and document its internals. The only thing that is prohibited is changing embedded copyright notices. I reserve the right of making the project commercial, but this does not mean that this would ever happen.
This software contains unmodified binaries from the ReactOS project: a registry editor, cmd.exe, ole32.dll to name the few. Those binaries are left unmodified and are covered by LGPL license. Future versions may contain redistributable binaries provided by Microsoft and/or other companies.
Some more information may be found in my blog. If you want to support development - use the link or press the button on the left side of the post.

Changes:
15 may 2013: DInput and DInput8 changes for Fallout2 keyboard compatibility.
12 may 2013: A minor update. Fallout 2 now works, tested on Russian version from 1C.
01 may 2013: Added the ability to automatically launch x86 applications. Added the shell32 interfaces - so that installers now work (at least NSIS and InstallShield installers are known to be working).
05 apr 2013: Fixed a few bugs.
04 apr 2013: Uploaded a new build after a long delay. Now emulator supports 256-color modes. But due to a limitation on an updated Nvidia driver - 640x480 and 800x600 display modes are no longer supported on Windows RT. You'll see the black lines to the right and bottom of the screen if the program tries to set such mode.
25 feb 2013: The tool now outputs its version to log. Now one x86 program may launch another - so some of the installers and, for example, 7Z GUI frontend can now run under emulation. Added ~80 DLLs. Some of them are stubs (like D3D9.DLL), others are mostly untested. I have not done all that I've planned for this build, publishing it just as an update to show that the work is going on. Do not expect it to run much more than the previous build.
13 feb 2013: more informative errors from launcher. Emulator now supports program paths with spaces. EXE files with relocations are now processed correctly. Some bugfixes in kernel32 and advapi32.
11 feb 2013: fixed a typo in winmm.dll emulation, now pinball has sound. Also updated the launcher.
10 feb 2013: now the program reached the beta stage.
Known problems
No D3D and most of COM interfaces. Lots of programs would crash, don't run or have different issues.
Notes:
The program keeps its settings in the HKCU\Software\x86node\Settings registry key. Supported REG_SZ (string) values are:
DosboxCore: "dynamic", "simple" or "normal". Dynamic is the default as it is the fastest, but the most buggy core.
LogFile: path to the log file. If not present - log file is %temp%\win86emu.log
Supported REG_DWORD values:
LogLevel: 0=no log (default), 4=max logging
added 13 feb 2013: now default log level is 2: warnings+errors, so you don't need to edit registry
There are several compatibility hacks that may be useful. Compatibility settings are stored in HKCU\Software\x86node\Compatibility\[filename.exe] key. "filename.exe" - a name of the emulated EXE file without path. All values are DWORD:
SetProcessAffinityMask = bitmask. Specify which CPUs to use for running a program, read SetProcessAffinityMask description in MSDN. 0 or unset == run on all cores.
NoRaiseException = 1. RaiseException would just return. Now exceptions are emulated correctly, so this hack is no longer needed.
UseDirectRegistry = 1. Do not redirect emulated registry keys to HKCU\Software\x86node. Be careful when using it.
MaxProcessorFeaturePresent = max processor feature number that is "supported". See the IsProcessorFeaturePresent function in MSDN. All requests for the value above specified would return 0. Default: 0 (IsProcessorFeaturePresent always returns 0).
SimulateAdminRights = 1. Lie to installers that call OpenSCManager function to determine that it is running as administrator, allowing these programs to run without elevation. Redirect the "common start menu" and similar folders to the per-user folders.
You can fake the OS version to a running program. Default XP SP3:
OSVersionLo=dword:00000001
OSVersionHi=dword:00000005
OSVersionBuild=dword:00000a28
OSServicepackLo=dword:00000000
OSServicepackHi=dword:00000003
Some information on the project internals may appear in my blog: http://mamaich-eng.blogspot.ru, but this thread on XDA would be the main discussion place.

I may be missing something...but this won't run for me. The exe just tells me it can't be run like normal exe does. I am jailbroken and can run arm compiled exe.

That is very impressive, mamaich.

lucas.scott said:
I may be missing something...but this won't run for me. The exe just tells me it can't be run like normal exe does. I am jailbroken and can run arm compiled exe.
Click to expand...
Click to collapse
Reread the directions ?

I don't have an ARM tablet to test this on, but this type of development is what will get me onto an ARM tablet for the next go-round. I love my S7S, but I really hated paying the price.

dan-htc-touch said:
Reread the directions ?
Click to expand...
Click to collapse
ugh...embarassed.
Great work mamaich. Thank you!

Notepad from Windows 95 seems to run too.

wow,this is an awesome project!

Amazing! Thank you!!!!!!!

Would you mind giving a technical explanation?

mamaich said:
I'm presenting a prototype of a tool that allows running Windows programs compiled for a desktop PC (x86) on an unlocked Windows RT (arm) tablet. The tool emulates x86 instructions and passes Windows API calls to WinRT kernel with necessary modifications.
This build is an early alpha version. It can run only very simple apps that use rather small subset of Win32 API that I've already implemented. Archive contains clock.exe from NT4 distribution as an example of such app. As I'll continue work on the project - the list of supported applications would grow up.
This tool would support only 32-bit windows native applications. It would not allow running drivers or .NET apps that were written for old .NET versions nor Win16 or DOS apps. And current version supports emulation only of EXE files that contain relocations section (this would be fixed later).
Instructions:
1. Unlock your device with this tool: http://forum.xda-developers.com/showthread.php?t=2092158
2. Unzip the archive to any directory
3. Run _start_clock.cmd
This would execute the clock.exe from NT4 in the emulation mode.
This post would be updated as I'll make more progress.
Note: This is an early alpha version, and do not expect that it would run anything except the provided file. Do not ask me what programs would be supported and when the next builds would appear - I don't know, as I work on this project only on spare time. I would not publish the complete sources of the tool, but it would be extensible by users, and some plugins (at least bochs/dosbox emulation engines and some of the API wrappers) would be opensource.
"Yact" in the file names stands for "yet another code translator", it was the original name of the project.
Edited 13.01.2012:
- added a few ARM WinAPI workarounds, added calc.exe as a second example (run _start_calc.cmd).
Click to expand...
Click to collapse
heh, is this a port of the app you showed off back in the CE days? -awesome getting that ported over

This is great, really opens up a lot more things and means that we don't need to recompile everything either.

heh, is this a port of the app you showed off back in the CE days? -awesome getting that ported over
Click to expand...
Click to collapse
Not exactly a port, it is a clean remake based on the old ideas.
clrokr said:
Would you mind giving a technical explanation?
Click to expand...
Click to collapse
The idea is very simple:
- a PE file loader (load files, process relocs, run TLS callbacks in an emulation mode). Support import loops (DLL A imports B while B imports A), ordinals, etc.
- a set of wrapper x86 DLLs (kernel32_stub.dll and so on) that "look like" the corresponding Win API functions for an emulated program:
Code:
#define DEFINE_FUNC1(name) \
static const ModuleDef str_##name={DLL_NAME,#name}; \
EXTERN_C DW STUB_EXPORT stub_##name(DW p1) \
{ \
DW *p=&p1; \
__asm { mov eax,p } \
__asm { jmp f1 } \
__asm { mov eax,offset str_##name } \
f1: __asm { in eax,0xe5 } \
__asm { mov p,eax } \
return (DW)p; \
}
.....
#define DEFINE_FUNC3(name) \
static const ModuleDef str_##name={DLL_NAME,#name}; \
EXTERN_C DW STUB_EXPORT stub_##name(DW p1,DW p2,DW p3) \
{ \
DW *p=&p1; \
__asm { mov eax,p } \
__asm { jmp f1 } \
__asm { mov eax,offset str_##name } \
f1: __asm { in eax,0xe5 } \
__asm { mov p,eax } \
return (DW)p; \
}
....
DEFINE_FUNC1(AddAtomA)
DEFINE_FUNC1(AddAtomW)
DEFINE_FUNC7(CreateFileA) -- number in macro == number of parameters to a __stdcall WinAPI function.
Compiler automatically generates "ret N*4" at the end of such function.
I've decided to use such c+asm approach instead of making a tiny assebler stub,
as I can easily implement some of such functions in C directly in a stub DLL plus it
simplifies debugging. And the functions have a usual C prologue/epilogue, so that
the emulated program may even patch them in runtime, for example for hooks.
...
- a 32-bit x86 emulation engine (currently 2 engines: from bochs and from dosbox, planning on adding my own) that intercepts the command "in eax,0xe5", determines which API is needed by a program and passes it to a handler.
- native (arm) API handler DLLs (kernel32_yact.dll and so on). They are mostly autogenerated too:
Code:
#define DEFINE_FUNC1(name) \
EXTERN_C DW STUB_IMPORT name(DW); \ -- this behaves like a function prototype to compiler
EXTERN_C DW STUB_EXPORT yact_##name(DW *R) \ -- R - pointer to the x86 stack
{ \
DW r=name(p1); \ // call the func passing it paramers from the emulated stack, p1==R[0], p2==R[1] and so on
LEAVE(1); \ // empty macro, as the stack is unwinded in x86 stub DLL now
return r; \
}
...
#define DEFINE_FUNC3(name) \
EXTERN_C DW STUB_IMPORT name(DW,DW,DW); \
EXTERN_C DW STUB_EXPORT yact_##name(DW *R) \
{ \
DW r=name(p1,p2,p3); \
LEAVE(3); \
return r; \
}
...
DEFINE_FUNC1(AddAtomA)
DEFINE_FUNC1(AddAtomW)
DEFINE_FUNC7(CreateFileA) // as you see - implementation part is identical to an x86 stub, so I can use the same stub-generator tool
Some of the functions require complex emulation due to their absence in ARM or due to the callbacks to x86 code:
Code:
static DWORD WINAPI ThreadProc(
LPVOID lpParameter // [0] == orig func, [1] == orig param
)
{
__EXCEPTION_REGISTRATION_RECORD R;
DWORD *Parm=(DWORD*)lpParameter;
DWORD *TEB=(DWORD*)PeLdrGetCurrentTeb();
R.Next=(__EXCEPTION_REGISTRATION_RECORD*)-1;
R.Handler=(void*)CbReturnToHost();
TEB[0]=(DWORD)&R; // in case of unhandled exception - just return
PeLdrNotifyNewThread(NULL,DLL_THREAD_ATTACH);
DWORD Ret=EmuExecute(Parm[0],1,Parm[1]); // 1 == number of parameters to the emulated function
delete Parm;
return Ret;
}
EXTERN_C DW STUB_EXPORT yact_CreateThread(DW *R)
{
DWORD* Parm=new DWORD[2];
Parm[0]=p3; // TODO: no out-of-memory checking for now
Parm[1]=p4;
DWORD StackSize=p2;
if(StackSize)
StackSize+=1024*1024; // I reserve some space for my own needs (debugging)
else
StackSize=2*1024*1024; // TODO: I don't support autogrow stacks, so reserve 2 Mb
DWORD t=(DWORD)CreateThread((LPSECURITY_ATTRIBUTES)p1,StackSize,ThreadProc,Parm,p5,(LPDWORD)p6);
LEAVE(6);
return t;
}
Some of the COM interfaces are already implemented, for example DirectDraw and DirectSound, though not heavily debugged. On a desktop emulator build I can already run "Heroes of might and magic 3" and old WinRAR, but there are several RT-specific OS limitations I need to bypass before making them run on ARM. Current work in progress is: overcoming the RT limitations, manually implementing the API functions that callback to a program code (like CreateThread, RegisterClassA and so on), adding stubs for other system DLLs/COM objects.
Manually thrown SEH exceptions are fully supported, but access violation, int3 and similar OS-generated exceptions would cause program to crash. Some of the TEB fields (TLS and the fields required by the Borland compilers) are implemented too.
I don't make pointer translation in an emulated code nor make parameter checks passed to API. As a side-effect - the emulated program may trash the emulator in memory, but this greatly increases speed.
Most of the x86 EXE files don't contain relocations section and need to be loaded on the specific addresses (typically 0x400000). This is not a problem on a desktop, as I can rebase my emulator's EXE to any address I need, and free the corresponding RAM addrs for emulated program, but on ARM - this is a main problem. So currently only EXEs with relocs are supported for emulation, but there are ways to overcome this problem. And some EXEs produced by old Borland compilers contain "broken" relocs, this is a small problem too.

HI mamaich, sorry for disturbing you, may i know how do you compile visual studio project for arm ?, i already change windowsarmdesktop to true. But i can't find arm options in build settings. Any suggestion ?

rheza02 said:
HI mamaich, sorry for disturbing you, may i know how do you compile visual studio project for arm ?, i already change windowsarmdesktop to true. But i can't find arm options in build settings. Any suggestion ?
Click to expand...
Click to collapse
This is completely unrelated to the topic and has been covered in at least 3 threads, multiple times in each, in the past couple days. Use the search function.

netham45 said:
This is completely unrelated to the topic and has been covered in at least 3 threads, multiple times in each, in the past couple days. Use the search function.
Click to expand...
Click to collapse
Yes, and I've answered it here: http://forum.xda-developers.com/showpost.php?p=36644799&postcount=131

Wow, this is awesome work! While recompiling (for native speed, lower memory footprint, launch time, lower battery usage, script transparency, etc.) is still obviously preferred, this finally offers a way to run closed-source or otherwise un-recompilable legacy apps. Well done; I'll be watching this closely.
A thought for making it easier to run the apps (including the aforementioned script transparency): Windows (at least on x86 and x64, and I'm pretty sure on ARM too) supports specifying executable names that, when they would be executed, are instead passed as a parameter to another executable. This is usually used for testing or debugging purposes (for example, always load a given app under a debugger or have Application Verifier hook into it at launch) but it can be used for other purposes too. One, which would be fantastic here, is to always run a program through a compatibility layer... I've never before seen it used for a full instruction set translation compatibility layer, but why not?
Create the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<IMAGE FILE NAME>
i.e. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\starcraft.exe
Then create a REG_SZ (String) value under that key called "Debugger" and set the value to the full path of the program you want to host the executable.
i.e. C:\Program Files\x86_peldr\peldr.exe
Source: http://support.microsoft.com/kb/824344
I can't promise that this will work for executable images that wouldn't be loadable normally, but it's probably worth a shot. Another, slightly less seamless option: change the extension of the executables (for example, starcraft.ex86) and register your app as the handler for that file type.

GoodDayToDie said:
Wow, this is awesome work! While recompiling (for native speed, lower memory footprint, launch time, lower battery usage, script transparency, etc.) is still obviously preferred, this finally offers a way to run closed-source or otherwise un-recompilable legacy apps. Well done; I'll be watching this closely.
A thought for making it easier to run the apps (including the aforementioned script transparency): Windows (at least on x86 and x64, and I'm pretty sure on ARM too) supports specifying executable names that, when they would be executed, are instead passed as a parameter to another executable. This is usually used for testing or debugging purposes (for example, always load a given app under a debugger or have Application Verifier hook into it at launch) but it can be used for other purposes too. One, which would be fantastic here, is to always run a program through a compatibility layer... I've never before seen it used for a full instruction set translation compatibility layer, but why not?
Create the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<IMAGE FILE NAME>
i.e. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\starcraft.exe
Then create a REG_SZ (String) value under that key called "Debugger" and set the value to the full path of the program you want to host the executable.
i.e. C:\Program Files\x86_peldr\peldr.exe
Source: http://support.microsoft.com/kb/824344
I can't promise that this will work for executable images that wouldn't be loadable normally, but it's probably worth a shot. Another, slightly less seamless option: change the extension of the executables (for example, starcraft.ex86) and register your app as the handler for that file type.
Click to expand...
Click to collapse
What I was thinking of for doing that was hooking the 'This doesn't run on this PC' error that explorer gives and making it call this instead of the error.

Nice... but that doesn't cover things like launching a program from the command line (script or manually), or one program launching another, or launching Windows services (although I'm not sure you'd want to emulate those anyhow... the battery hit would suck), or so on. Still an interesting goal.
One other thought for the "it'd-be-awesome" list (not even really a wish-list): support doing this for DLLs loaded into other processes (i.e. somehow get between LoadLibrary and the x86 binary, and interpose your translator). Why, you ask? Plugins. Browser plugins, media codecs (which are DLLs, whatever their extension), Control Panel files, COM objects in general, etc.

Related

running multiple instances of a software

Hello all.
I use Windows mobile 6.1.
I would really like to be able to run mobipocket reader (and some other software) concurrently. Running multiple instances of a program at once is really useful as we dont have to close something just to open another document.
Can anybody tell me if there is a way to do this?
It depends on the software itself. The original Pocket PC methodology as published by MS was that only one copy of a program should be in memory at one time, and that it should only open one document at a time. If you create a shell C++ application in VS Studio, it contains the following code in the InitInstance function.
Code:
//If it is already running, then focus on the window
hWnd = FindWindow(szWindowClass, NULL);
if (hWnd)
{
// set focus to foremost child window
// The "| 0x01" is used to bring any owned windows to the foreground and
// activate them.
SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
return 0;
}
The comments are inserted by the VS code wizard.
Basically the application looks for another instance of itself in memory. If it finds one, it activates that copy before terminating itself.
By starting a second copy of the program, you merely reactivate the first one.
WinCE has a 32 process limit but this is set to change with WinCE 6.0. we will probably have to wait until at least WinMo 7 for this to filter through.
thanx stephj
do you know if anyone has created such a shell already?
I have heard of js hexmaster but couldn't find it anywhere, besides it's for application developers
TIA
Haali Reader is an ebook reader I use (and prefer over mobipocket) that supports multiple instances.
thanks noidtluom, I knew that, but i'm in too deep with mobipocket.
Do you know any other good ebook readers that can open prc format created by mobipocket?
Would really be great if there were...
cheerz
any updates on hacks to run multiple instances of the same program at the same time?
you seem to be able to do this on PC:
http://www.makeuseof.com/tag/how-to-run-multiple-versions-of-the-same-program-on-your-pc/
and here:
http://filesharefreak.com/2008/08/08/how-to-run-multiple-instances-of-utorrent-v177-v18/

[GUIDE] How To Install and Use Android SDK

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
*If you find this Guide Thread helpful, feel free to hit the "thanks" button below!​
What is Android SDK?
Everyone wants to program on Android; unfortunately, not everyone knows quite how to get started with their development environment. Google has put out both the Android SDK and the Android ADT in order to help developers integrate Android into their dev environment as well as facilitate more Android development. In this guide, we’ll take a look at how to set up a development environment for Android so you can start creating projects. Android SDK and Android ADT are essentials that you will need to include in your Android Developer Toolbox for use with many things, and can be a very powerful set of components from the simple, to the complicated. When it comes to Android modding, most novice users are confused or left wondering by reference over reference to a certain “adb”. This is specially true when you are looking up something on modding your device, or root it in particular. ADB is the wonder toy of Android and everyone seems to love it, so lets have a look at understanding what it is and why you need it, and how you can get it.​
What is ADT?
ADT (Android Developer Tools) is a plugin for Eclipse that provides a suite of tools that are integrated with the Eclipse IDE. It offers you access to many features that help you develop Android applications quickly. ADT provides GUI access to many of the command line SDK tools as well as a UI design tool for rapid prototyping, designing, and building of your application's user interface. Because ADT is a plugin for Eclipse, you get the functionality of a well-established IDE, along with Android-specific features that are bundled with ADT. The following describes important features of Eclipse and ADT:
Integrated Android project creation, building, packaging, installation, and debugging
ADT integrates many development workflow tasks into Eclipse, making it easy for you to rapidly develop and test your Android applications.
SDK Tools integration
Many of the SDK tools are integrated into Eclipse's menus, perspectives, or as a part of background processes ran by ADT.
Java programming language and XML editors
The Java programming language editor contains common IDE features such as compile time syntax checking, auto-completion, and integrated documentation for the Android framework APIs. ADT also provides custom XML editors that let you edit Android-specific XML files in a form-based UI. A graphical layout editor lets you design user interfaces with a drag and drop interface.
Integrated documentation for Android framework APIs
You can access documentation by hovering over classes, methods, or variables. ​
What is ADB?
ADB stands for Android Debug Bridge. It comes as a part of the standard Android SDK, which you can grab here in this guide. Basically, it provides a terminal-based interface for interacting with your phone’s file system. Since Android platform is based on Linux, command-line is sometimes the only way to obtain and manipulate root access often required to perform certain advanced operations on your device using root access. While these things can be done directly on the device itself using some terminal emulator, it will be rather difficult to execute complex commands on such a small screen. ADB provides the bridge between your machine and your computer.​
Preface: Dev Environment Notes:
Just a general rule to reduce headaches, if you're serious about Android development, your development machine should primarily be a development machine, as installation of other various programs may clutter it up and produce unexpected errors or other bizarre happenings. While this is rare, it’s not uncommon, and an exclusive development machine is recommended. If an extra machine is not available, a virtual machine used as a development machine works very well also. If this isn't an option either, you can always install Ubuntu 12.04 on your Windows PC and select whichever operating system you'd like at boot/reboot. The latter is my setup, since I run Windows 7 primarily, and Ubuntu for selected other functions -namely Android SDK. It's all your preference here, but keep in mind that if you start getting too deep in the rabbit hole with your Android development, you may want to consider a dedicated dev machine, or re-partition your Ubuntu setup to allow for more capabilities within it.​
Step 1: Install the JDK
Most of you probably have the Java JRE installed, but Android requires the JDK “Java Development Kit” to compile Java programs. The JDK is available on Oracle’s Java webpage. Install the version of the JDK appropriate for your OS; the Java EE 6 bundle is recommended, but you can install any bundle you like so long as it contains the JDK.
(Getting started on Ubuntu, see THIS PAGE)
Getting started on Windows:
Your download package is an executable file that starts an installer. The installer checks your machine for required tools, such as the proper Java SE Development Kit (JDK) and installs it if necessary. The installer then saves the Android SDK Tools into a default location (or you can specify the location). Make a note of the name and location of the SDK directory on your system—you will need to refer to the SDK directory later, when setting up the ADT plugin and when using the SDK tools from the command line. Once the tools are installed, the installer offers to start the Android SDK Manager. Start it and continue with the installation guide by clicking the Next link on the right. The Android SDK requires JDK version 5 or version 6. If you already have one of those installed, skip to the next step. In particular, Mac OS X comes with the JDK version 5 already installed, and many Linux distributions include a JDK. If the JDK is not installed, go to http://java.sun.com/javase/downloads and you'll see a list of Java products to download.
Linux users: Many Linux distributions come with an open source variant of the JDK, like OpenJDK or IcedTea. While you may be tempted to use these in support of open-source or for whatever reason, for maximum compatibility install the official Oracle JDK. You may choose to ignore this warning, but you may end up encountering obscure, strange errors because of it; if you do, most likely it’s some minor difference in the two JDKs.​
Step 2: Install Your IDE of Choice
You can by all means code straight up in Emacs or Vi; if you prefer doing that, this guide is not for you. For the rest of us, install a Java IDE; Eclipse is recommended as it is the IDE that the Android developers use and the IDE with official plugin support from Google. The rest of this guide will assume Eclipse is the IDE you’re using, but NetBeans has Android plugin support for it as well. When you download Eclipse, make sure to download Eclipse Classic or Eclipse for Java EE developers; there are quite a few flavors of Eclipse for download on their page, and you don’t want to end up with the C++ or PHP versions of Eclipse.
Obtain Eclipse
These alternatives may be available to obtain a copy of Eclipse for installation:
Download a current stable build of Eclipse from the Eclipse Web Site; note that the installation file is large (over 120 MB)
For the recommended package to download and install, click the link Eclipse IDE for Java EE Developers on the Eclipse Packages page. For the reason why this is the recommendation, see the following bullets:
There are a number of downloadable packages available, each a different "flavor" of Eclipse, which can be compared and contrasted from the Compared Eclipse Packages page. The recommended Eclipse package is the Eclipse IDE for Java EE Developers. This recommendation is made for those who develop in other languages / on other platforms as well, for the following reasons:
The "slimmer" Eclipse IDE for Java Developers lacks data tools, testing support, and parts of the Web Standard Tookit useful to all Java web application developers
The Eclipse Classic seems like it ought to be "slimmer" but in fact it is a larger download than the JEE package. Downloading and installing this package, then picking and choosing among additional packages described on the Eclipse Classic page is a viable alternative, but requires each developer to spend time researching the contents and utility of the multiple options.
Install Eclipse
There is no installer (executable program) used to install Eclipse. The process described below involves un-archiving (unzipping) a directory tree of files and placing it in an appropriate location on your hard disk. It is very strongly recommended that you locate the eclipse\ directory at the root of your computer's hard drive; or, minimally, on a directory path with no spaces in its name (e.g., C:\mystuff\eclipse\. It is worth noting that Eclipse does not write entries to the Windows registry; therefore, you can simply delete (or move) the installed files, shortcuts, and/or the workspace: there is no executable uninstaller either.
Unzip (or copy/unjar/check-out) the software into an appropriate location on your hard disk (e.g., C:\eclipse).
These instructions are written assuming that you are running eclipse from C:\eclipse; if you are using a different path, adjust accordingly.
Once the unzipped (copied/unjarred/checked-out) files are located on your filesystem, get started using Eclipse:
Run Eclipse by running C:\eclipse\eclipse.exe
The first time you run Eclipse, you will be prompted to identify a location for your Eclipse workspace. This is where local copies of your projects (files you check in and/or out of code repositories) will live on your file system. Do not create the workspace in a directory path that has spaces in it - i.e., not in the default C:\Documents and Settings\... directory presented by default on the first startup of Eclipse. Instead, it is recommended that your workspace be located at the root of your machine's hard disk, e.g., C:\workspace.
It is advisable to pass JVM arguments to Eclipse at startup to reserve a larger memory space for the IDE than the default. To, specify recommended JVM arguments, create a shortcut (probably on your desktop) with the following target (modified if you're using different directories):
Code:
C:\eclipse\eclipse.exe -jvmargs -Xms128m -Xmx512m -XX:MaxPermSize=128m
Step 3: Install the Android SDK
Now it’s time to install the Android SDK. You can grab it from the Android Developer website at:
http://developer.android.com/sdk/index.html​
Download the installer for your particular operating system, and open it up when you’re done:
Android SDK Manager
The Android SDK Manager is modular, meaning that you download the initial package and then download separate packages within the framework in order to provide more functionality. This lets the SDK be more flexible, as you don’t need to keep downloading entire packages every time a new version comes out; you can simply download the latest module and pop it into the SDK. You can pick and choose which modules to install, but if you’ve got the hard drive space I recommend installing all of the different flavors of Android; it will help later when debugging apps, especially on older Android OSes.​
Step 4: Install the Android ADT for Eclipse
NOTE: if you’re using NetBeans, you want the nbandroid plugin, found here:
http://kenai.com/projects/nbandroid/pages/install​
Now that the SDK is installed, you should install the Android ADT plugin. It’s not strictly necessary to do so, but the ADT offers powerful integration with many of the Android tools, including the SDK Manager, the AVD Manager, and DDMS, or dynamic debugging. All of these are extremely useful to have when creating an Android application, and if you want to skip them you should do so at your own peril!​
Eclipse ADT Plugin
To install the ADT, you’re going to have to add a custom software package to Eclipse. To do so, head over to the “Help” button on Eclipse’s menu and click the “Install New Software” button. Click “Available Software”, click “Add Remote Site”, and pop in this URL:
https://dl-ssl.google.com/android/eclipse/​
Eclipse ADT Install
Occasionally, for whatever reason, some people have trouble downloading the ADT from that secure site. If you’re having issues downloading the ADT, simply remove the “s” off the end of the “https”, and the download should work as intended. Once that’s done, head back over to the Available Software tab and check the boxes for Developer Tools, Android DDMS, and Android Development Tools; again, none of these are mandatory, but they’re all going to be very useful later on. The packages will take a bit to download; once they’re done, restart Eclipse!​
Step 5: Create an Android Virtual Device (or AVD)
Like the previous step, this step isn’t entirely necessary; you could do all your debugging and development work on an actual Android handset. Creating AVDs is a great way to see how your application might work across different operating systems and handset types, as AVDs can mimic not only different Android OSes but also different hardware; you can change such settings as heap size, display type, and maximum memory, making it useful to try and figure out where bugs are happening when you don’t own a multitude of different handsets to test on! To create an AVD, you can open the Android AVD manager from Eclipse from the “Window” button on the top bar, and go to “Virtual Devices”. From there, you can add, configure and delete them:
Android Virtual Device (AVD) Manager
NOTE: This isn’t IDE specific. For those of you running a different IDE, the AVD Manager can be accessed in the same manner as the Android SDK is accessed outside of Eclipse; this is just a very easy shortcut for those with the Android ADT installed. Need More Help? Try this 30-minute video put together by Guy Cole, that walks you through the complete step-by-step setup.​
So, You've Installed Android SDK, Now What?
The Android platform provides support for both speech recognition and speech synthesis. In this tutorial, we will create a simple Android app which allows the user to speak, attempts to recognize what they say, and then repeats what was recognized back to them using the Text To Speech engine.
Step 1: Start an Android Project​
Create a new Android project in Eclipse. Alternatively, if you want to implement the speech recognition functionality in an existing app, open it instead. For this tutorial we have a minimum SDK version of 8, and you do not need to make any particular additions to your Manifest file, the default contents should suffice.
Step 2: Define the User Interface​
Let’s start by defining the user interface. When the app launches, the user will be presented with a button. On pressing the button, the app will prompt them to speak, listening for their voice input. When the speech recognition utility processes the speech input, the app will present a list of suggested words to the user. As you’ll know if you’ve tried speech recognition as a user, the recognizer is not always accurate, so this list is essential. When the user selects an item from the list, the app will speak it back to them using the TTS engine. The TTS part of the application is optional, so you can omit it if you prefer.
The app is going to use a few text Strings as part of the interface, so define them by opening the “res/values/strings.xml” file and entering the following content:
Code:
<resources>
<string name="intro">Press the button to speak!</string>
<string name="app_name">SpeechRepeat</string>
<string name="speech">Speak now!</string>
<string name="word_intro">Suggested words…</string>
</resources>
Of course, you can alter the String content in any way you like.
Open your “res/layout/main.xml” file to create the main app layout. Switch to the XML editor if the graphical editor is displayed by default. Enter a Linear Layout as the main layout for the app’s launch Activity:
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
androidrientation="vertical"
android:background="#ff330066"
androidaddingBottom="5dp" >
</LinearLayout>
The Linear Layout contains various style declarations including a background color. Inside the Linear Layout, first enter an informative Text View:
Code:
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/intro"
androidadding="5dp"
android:textStyle="bold"
android:textSize="16dp"
android:gravity="center"
android:textColor="#ffffff33" />
Notice that the Text View refers to one of the Strings we defined. It also sets various display properties which you can alter if you wish. After the Text View, add a button:
Code:
<Button android:id="@+id/speech_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/speech" />
The user will press this button in order to speak. We give the button an ID so that we can identify it in the Java code and display one of the Strings we defined on it. After the button, add another informative Text View, which will precede the list of suggested words:
Code:
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidadding="5dp"
android:text="@string/word_intro"
android:textStyle="italic" />
Again, this Text View uses a String resource and contains style properties. The last item in our main.xml Linear Layout is the list of suggested words:
Code:
<ListView android:id="@+id/word_list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
androidaddingLeft="10dp"
androidaddingTop="3dp"
androidaddingRight="10dp"
androidaddingBottom="3dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/words_bg" />
The List View will be populated with data when the app runs, so we give it an ID for identification in Java. The element also refers to a drawable resource, which you should add to each of the drawables folders in your app’s “res” directory, saving it as “words_bg.xml” and entering the following content:
Code:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true">
<gradient
android:startColor="#ff000000"
android:endColor="#ff000000"
android:centerColor="#00000000"
android:angle="180" />
<corners android:radius="10dp" />
<stroke
android:width="2dp"
android:color="#66ffffff" />
</shape>
This is a simple shape drawable to display behind the List View. You can of course alter this and the List View style properties if you wish. The only remaining user interface item we need to define now is the layout for a single item within the list, each of which will display a word suggestion. Create a new file in “res/layout” named “word.xml”and then enter the following code:
Code:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
androidadding="5dp"
android:textColor="#ffffffff"
android:textSize="16dp" >
</TextView>
Each item in the list will be a simple Text View. That’s our interface design complete. This is how the app appears on initial launch:
Step 3: Setup Speech Recognition​
Now we can implement our Java code. Open your app’s main Activity and add the following import statements at the top:
Code:
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.TextView;
You may not need all of these if you do not implement the TTS functionality – Eclipse should highlight imports you have not used so check them when you finish coding. Extend your opening class declaration line as follows, altering the Activity name to suit your own:
Code:
public class SpeechRepeatActivity extends Activity implements OnClickListener, OnInitListener {
The “OnInitListener” is only required for the TTS function. Add the following instance variables inside your class declaration, before the “onCreate” method:
Code:
//voice recognition and general variables
//variable for checking Voice Recognition support on user device
private static final int VR_REQUEST = 999;
//ListView for displaying suggested words
private ListView wordList;
//Log tag for output information
private final String LOG_TAG = "SpeechRepeatActivity";//***enter your own tag here***
//TTS variables
//variable for checking TTS engine data on user device
private int MY_DATA_CHECK_CODE = 0;
//Text To Speech instance
private TextToSpeech repeatTTS;
Inside your “onCreate” method, your class should already be calling the superclass method and setting your main layout. If not, it should begin like this:
Code:
//call superclass
super.onCreate(savedInstanceState);
//set content view
setContentView(R.layout.main);
Next, still inside your “onCreate” method, retrieve a reference to the speech button and list we created, using their ID values:
Code:
//gain reference to speak button
Button speechBtn = (Button) findViewById(R.id.speech_btn);
//gain reference to word list
wordList = (ListView) findViewById(R.id.word_list);
The List View is an instance variable, accessible throughout the class. Now we need to find out whether the user device has speech recognition support:
Code:
//find out whether speech recognition is supported
PackageManager packManager = getPackageManager();
List<ResolveInfo> intActivities = packManager.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if (intActivities.size() != 0) {
//speech recognition is supported - detect user button clicks
speechBtn.setOnClickListener(this);
}
else
{
//speech recognition not supported, disable button and output message
speechBtn.setEnabled(false);
Toast.makeText(this, "Oops - Speech recognition not supported!", Toast.LENGTH_LONG).show();
}
We query the environment to see if the Recognizer Intent is present. If it is, we instruct the app to listen for the user pressing the speech button. If speech recognition is not supported, we simply disable the button and output an informative message to the user.
Step 4: Listen for Speech Input​
Let’s setup the click listener for the speech button we’ve instructed the app to detect clicks for. Outside the “onCreate” method, but inside your Activity class declaration, add an “onClick” method as follows:
Code:
/**
* Called when the user presses the speak button
*/
public void onClick(View v) {
if (v.getId() == R.id.speech_btn) {
//listen for results
listenToSpeech();
}
}
Now implement the method we’ve called here after the “onClick” method:
Code:
/**
* Instruct the app to listen for user speech input
*/
private void listenToSpeech() {
//start the speech recognition intent passing required data
Intent listenIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//indicate package
listenIntent.putExtra(RecognizerIntent.EXTRA_CALLI NG_PACKAGE, getClass().getPackage().getName());
//message to display while listening
listenIntent.putExtra(RecognizerIntent.EXTRA_PROMP T, "Say a word!");
//set speech model
listenIntent.putExtra(RecognizerIntent.EXTRA_LANGU AGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//specify number of results to retrieve
listenIntent.putExtra(RecognizerIntent.EXTRA_MAX_R ESULTS, 10);
//start listening
startActivityForResult(listenIntent, VR_REQUEST);
}
Some of this code is standard for setting up the speech recognition listening functionality. Areas to pay particular attention to include the line in which we specify the “EXTRA_PROMPT” – you can alter this to include text you want to appear for prompting the user to speak. Also notice the “EXTRA_MAX_RESULTS” line, in which we specify how many suggestions we want the recognizer to return when the user speaks. Since we are calling the “startActivityForResult” method, we will handle the recognizer results in the “onActivityResult” method.
When the app is listening for user speech, it will appear as follows:
Step 5: Present Word Suggestions​
Implement the “onActivityResult” method inside your class declaration as follows:
Code:
/**
* onActivityResults handles:
* - retrieving results of speech recognition listening
* - retrieving result of TTS data check
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//check speech recognition result
if (requestCode == VR_REQUEST && resultCode == RESULT_OK)
{
//store the returned word list as an ArrayList
ArrayList<String> suggestedWords = data.getStringArrayListExtra(RecognizerIntent.EXTR A_RESULTS);
//set the retrieved list to display in the ListView using an ArrayAdapter
wordList.setAdapter(new ArrayAdapter<String> (this, R.layout.word, suggestedWords));
}
//tss code here
//call superclass method
super.onActivityResult(requestCode, resultCode, data);
}
Here we retrieve the result of the speech recognition process. Notice that the “if” statement checks to see if the request code is the variable we passed when calling “startActivityForResult”, in which case we know this method is being called as a result of the listening Intent. The recognizer returns the list of 10 suggested words, which we store as an Array List. We then populate the List View with these words, by setting an Array Adapter object as Adapter for the View. Now each of the items in the List View will display one of the suggested words.
If the app successfully recognizes the user input speech and returns the list of words, it will appear as follows:
Alternatively, if the app does not recognize the user speech input, the following screen will appear:
Step 6: Detect User Word Choices​
We want to detect the user selecting words from the list, so let’s implement a click listener for the list items. Back in your “onCreate” method, after the existing code, set the listener for each item in the list as follows:
Code:
//detect user clicks of suggested words
wordList.setOnItemClickListener(new OnItemClickListener() {
//click listener for items within list
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//cast the view
TextView wordView = (TextView)view;
//retrieve the chosen word
String wordChosen = (String) wordView.getText();
//output for debugging
Log.v(LOG_TAG, "chosen: "+wordChosen);
//output Toast message
Toast.makeText(SpeechRepeatActivity.this, "You said: "+wordChosen, Toast.LENGTH_SHORT).show();//**alter for your Activity name***
}
});
We use the “setOnItemClickListener” method to assign a listener to each item in the list. Inside the new “OnItemClickListener”, we implement the “onItemClick” method to respond to these clicks – this method will fire when the user selects a suggested word from the list. First, we cast the View that has been clicked to a Text View, then we retrieve the text from it. This text is the word the user has selected. We write the chosen word out to the Log for testing and output it back to the user as a Toast message. Depending on the needs of your own application, you may wish to carry out further processing on the chosen word – this code is purely for demonstration.
The user can press the touchscreen or use a trackball to select words in the list.
When the user selects a word, the Toast message appears confirming it.
Step 7: Setup TTS Functionality​
If you do not want to implement the Text To Speech functionality, you can stop now and test your app. We only require a little more processing to make our app repeat the user’s chosen word. First, to set up the TTS engine, add the following code to the section in your “onCreate” method where you queried the system for speech recognition support. Inside the “if” statement, after “speechBtn.setOnClickListener(this);”:
Code:
//prepare the TTS to repeat chosen words
Intent checkTTSIntent = new Intent();
//check TTS data
checkTTSIntent.setAction(TextToSpeech.Engine.ACTIO N_CHECK_TTS_DATA);
//start the checking Intent - will retrieve result in onActivityResult
startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE);
Like the speech listening process, we will receive the result of this code checking for TTS data in the “onActivityResult” method. In that method, before the line in which we call the superclass “onActivityResult” method, add the following:
Code:
//returned from TTS data check
if (requestCode == MY_DATA_CHECK_CODE)
{
//we have the data - create a TTS instance
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
repeatTTS = new TextToSpeech(this, this);
//data not installed, prompt the user to install it
else
{
//intent will take user to TTS download page in Google Play
Intent installTTSIntent = new Intent();
installTTSIntent.setAction(TextToSpeech.Engine.ACT ION_INSTALL_TTS_DATA);
startActivity(installTTSIntent);
}
}
Here we initialize the TTS if the data is already installed, otherwise we prompt the user to install it. For additional guidance on using the TTS engine, see the Android SDK: Using the Text to Speech Engine tutorial.
To complete TTS setup, add the “onInit” method to your class declaration, handling initialization of the TTS as follows:
Code:
/**
* onInit fires when TTS initializes
*/
public void onInit(int initStatus) {
//if successful, set locale
if (initStatus == TextToSpeech.SUCCESS)
repeatTTS.setLanguage(Locale.UK);//***choose your own locale here***
}
Here we simply set the Locale for the TTS, but you can carry out other setup tasks if you like.
Step 8: Repeat the User Choice​
Finally, we can repeat the user’s chosen word. Back in your “onCreate” method, inside the “OnItemClickListener” “onItemClick” method, after the line in which we output a Toast message, add the following:
Code:
//speak the word using the TTS
repeatTTS.speak("You said: "+wordChosen, TextToSpeech.QUEUE_FLUSH, null);
This will cause the app to repeat the user’s chosen word as part of a simple phrase. This will occur at the same time the Toast message appears.
Conclusion
That’s our complete Speak and Repeat app. Test it on an Android device with speech recognition and TTS support – the emulator does not support speech recognition so you need to test this functionality on an actual device. The source code is attached, so you can check if you have everything in the right place. Of course, your own apps may implement speech recognition as part of other processing, but this tutorial should have equipped you with the essentials of supporting speech input.​
Android SDK Commands & Explanations
Adb has many built in commands. Some are interactive (meaning they keep running until you stop them) and some just perform a simple task. Below is a list of the commands in the 1.0 SDK version of adb.​
Android Debug Bridge version 1.0.20
Code:
-d - directs command to the only connected USB device
returns an error if more than one USB device is present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
-s <serial number> - directs command to the USB device or emulator with
the given serial number
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> <local> - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] <file> - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-product - prints: <product-id>
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PDP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition
is updated.
Common Use:​
Some of the more common commands in adb are push, pull, shell, install, remount, and logcat.
Push sends a file from your desktop computer to your Android device:
Code:
adb push test.txt /sdcard/test.txt
Pull pulls a file from your Android device to your desktop computer:
Code:
adb pull /sdcard/test.txt test.txt
Shell lets you run an interactive shell (command prompt) on the Android device:
Code:
adb shell
Install lets you install an android APK file to your Android device:
Code:
adb install myapp.apk
Remount remounts the /system partition as writable (or readonly if it is already writeable):
Code:
adb remount
Logcat lets you view the devices debug logs in real time (must press control+c to exit):
Code:
adb logcat
Further Notes On This Subject
It's great to see guides like these. I think every device forum should have these stickied in their general section. We all have/had to start somewhere. Having nice guides with accurate up-to-date information is only going to benefit everyone, and makes learning and understanding much easier. Fact is, we're all here for the same reason, to capitalize on the potential our devices have, and enjoy them. So, thanks for putting this together. It might seem trivial to a lot of the more experienced people, but those who aren't will definitely appreciate it.
Thanks. This is helpful.
Sent from my MB865
Hey Apex great job on the guide
I just wish this was here the first time I installed the the android sdk
I'm sure it will be useful to alot of members
41rw4lk said:
I think every device forum should have these stickied in their general section.
Click to expand...
Click to collapse
+1
Sticky?
Speak only when it improves on your silence.
Sorry for OT, this is not for Atrix 2 but I have question :
I want to extract included kernel in CM9 Rom, it is inside boot.img file. I've used Android Kitchen for extracting, it's ok now. I had zImage file.
So now how can I build flash-able zip file for CWM ? Tried UpdateZipCreator program but it showed error (7) when flashing.
I just wanna test many difference kernels and then come back to original but no flashable CM9 kernel here on xda.
vinamilk said:
Sorry for OT, this is not for Atrix 2 but I have question :
I want to extract included kernel in CM9 Rom, it is inside boot.img file. I've used Android Kitchen for extracting, it's ok now. I had zImage file.
So now how can I build flash-able zip file for CWM ? Tried UpdateZipCreator program but it showed error (7) when flashing.
I just wanna test many difference kernels and then come back to original but no flashable CM9 kernel here on xda.
Click to expand...
Click to collapse
Okay, Jim will probably be the one to ask on this. I don't recall which device you have currently (viewing from my phone) but he's the one who wrote the kernel for CM9 on the SGS3. I'm assuming you want to run the CM9 rom with 'experimental' kernels, so I'd PM him and ask (Sorry Jim, lol) but I'm not the expert on kernels or Android Kitchen, least not as knowledgeable as I should be to give a suitable answer...
Sent from my SAMSUNG-SGH-I747 using xda premium
oh! thanks a lot! I am very happy to find this!
long long ago! I start to find this resourse :cyclops:
EXCELLENT! I don't know i didn't see this before. Maybe because i didn't have this phone in August i think.
But great, tomorrow i will see if i can combine one of my designs with this, and try to make an alpha app.
Good guide
Hit thnx for every help
I just wanted to obtain logcat but where to type adb logcat...I get this in sdk
luvk1412 said:
I just wanted to obtain logcat but where to type adb logcat...I get this in sdk
Click to expand...
Click to collapse
With the sdk.. go to android-sdk/tools/ folder and double-click monitor.bat - easiest/nicest way to watch the logs..
To set up adb to be used from the command prompt or terminal, make sure you set your environment variables (or your .bashrc in Linux) to the path of adb in the sdk (it's in platform-tools)..
For Windows (Win7 example): Go to Start> right-click Computer>Properties>Advanced System Settings>Environment Variables...
Look under System Variables to see if you somehow have the path to C:\android-sdk\platform-tools in there already (or your specific location - just don't use spaces in the folder names in your path). If not, click on PATH under System Variables and Edit it..
Add your path to adb.exe (C:\android-sdk\platform-tools, for exapmle) to the end of the string of paths there. You can also add the path to \android-sdk\tools for good measure..
Click OK.. "Revenge of the Fern" - inside joke...
For Linux (Ubuntu 12.04, for example): Go to your home folder, hit Ctrl+H, open the .bashrc, and add this (or your specific path) to the bottom:
Code:
# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
Then you should be able to open the command prompt or terminal and type: adb devices - and hopefully get your device id..
Then: adb logcat - for logcat (or just use the monitor.bat as mentioned above, it has a much nicer interface)
See my "Guide" on getting started in the Themes&Apps section for more adb stuff too..
Other alternatives for logcat directly on your phone are through Terminal Emulator (type su.. then logcat), or apps available on the Play Store (aLogcat, for example).
Hey I am just getting started with android dev. Have done just a few tutorials from the developers.android.com, so basically a noob at this. But I saw that Google recently launched the android studio for app developement. I was just getting started with eclipse, but the android studio looks more intuitive because of its better GUI. I'm bad at xml editing too So I think the interface of Android Studio would suit better. Is there anyone here who has tried both and knows the cons of abandoning eclipse IDE and going for Android Studio?
help
Hay friend i have downloaded Java JDK 6.0.45 & 6.0.07 & Java JRE 6,7 to But when i open eclips it shows me this error can you help me to get it solve
http://forum.xda-developers.com/showthread.php?t=2276871
http://forum.xda-developers.com/showthread.php?t=2227376&page=14
Do you know what path i use to upack the adt bundle i have unpacked it in almost every location on my computer and still nothing eclipes wont work nothing works plz let me know if you can help i really dont want to smash my new laptop that will be no2 in amonth if i do plz help

A few command line utilities for RT

So not to clutter up an 'apps' list, I am putting together pieces to enable my surface rt to have more functionality available for on device scripting and a put together a few utilities to fill some areas I think (?) were missing. I might use these from scripts, nodejs, powershell or anywhere else I might launch processes.
So for starters I made :
csnotify - A utility to simulate the toast notification banners (like what you see for weather or new mail alerts). Unfortunately the api used to actual system notifications are c++ sdk binaries which i can't use, so this is as close a clone as i could make. The options are many and explained in a readme file in the zip.
naudiocon - a simple console mp3 file player which i might use for sound effects but it plays a song just as well. There are many pieces to the open source NAudio library which could be useful for future audio media players.
wget - a simple way to download a file from a url via command line. not a true clone of wget but you can enter wget {url} or wget {url} newfilename. run without any params to see that usage syntax.
cryptocli - a simple command line file encryption and hashing utility. Possibly useful for email or sending between computers which has this utility installed. like most ports this runs on arm or intel windows.
speak - a simple text to speech utility to read text either from command line itself or from file specified in command line.
wscon - command line web server. spin up server on -p port and -d directory from command line or put shortcut to this app in 'shell:sendto' to send a -directory- to it (using default port or 8080)
The files are already signed, but if you download directly to your device you should probably right click the downloaded zip(s) and 'unblock' them on the file 'properties' page. This seems to be required when downloading to NTFS partitions, as it will flag the download as 'coming from an unsafe domain' (internet). If you save the file to non-ntfs sdcard/usb/nas you should not have to unblock.
nazoraios said:
So not to clutter up an 'apps' list, I am putting together pieces to enable my surface rt to have more functionality available for on device scripting and a put together a few utilities to fill some areas I think (?) were missing. I might use these from scripts, nodejs, powershell or anywhere else I might launch processes.
So for starters I made :
csnotify - A utility to simulate the toast notification banners (like what you see for weather or new mail alerts). Unfortunately the api used to actual system notifications are c++ sdk binaries which i can't use, so this is as close a clone as i could make. The options are many and explained in a readme file in the zip.
naudiocon - a simple console mp3 file player which i might use for sound effects but it plays a song just as well. There are many pieces to the open source NAudio library which could be useful for future audio media players.
wget - a simple way to download a file from a url via command line. not a true clone of wget but you can enter wget {url} or wget {url} newfilename. run without any params to see that usage syntax.
cryptocli - a simple command line file encryption utility. Possibly useful for email or sending between computers which has this utility installed. like most ports this runs on arm or intel windows.
The files are already signed, but if you download directly to your device you should probably right click the downloaded zip(s) and 'unblock' them on the file 'properties' page. This seems to be required when downloading to NTFS partitions, as it will flag the download as 'coming from an unsafe domain' (internet). If you save the file to non-ntfs sdcard/usb/nas you should not have to unblock.
Click to expand...
Click to collapse
Thanks definitely going to be using wget. If only we could make a port of bash...
Sent from my SGH-M919 using XDA Free mobile app
Qiangong2 said:
Thanks definitely going to be using wget. If only we could make a port of bash...
Sent from my SGH-M919 using XDA Free mobile app
Click to expand...
Click to collapse
Bash shell would be great, git-bash would be even better.
There's a lot of c++ projects that I haven't been able to set up visual studio to compile for arm. vs2013 and 2015 haven't been playing very well so far, I think mamaich successfully did some arm ports with vs2012. Then there's Win10 iot efforts which Microsoft may be more inclined to support officially. They seem to support console c++ apps on win10arm using vs2015 here :
http://ms-iot.github.io/content/en-US/win10/samples/ConsoleApp.htm
I have not even begun trying to set up MinGW/Cygwin which I believe is the toolchain required for cross compiling Linux source projects for win/arm.
nazoraios said:
Bash shell would be great, git-bash would be even better.
There's a lot of c++ projects that I haven't been able to set up visual studio to compile for arm. vs2013 and 2015 haven't been playing very well so far, I think mamaich successfully did some arm ports with vs2012. Then there's Win10 iot efforts which Microsoft may be more inclined to support officially. They seem to support console c++ apps on win10arm using vs2015 here :
http://ms-iot.github.io/content/en-US/win10/samples/ConsoleApp.htm
I have not even begun trying to set up MinGW/Cygwin which I believe is the toolchain required for cross compiling Linux source projects for win/arm.
Click to expand...
Click to collapse
Windows RT was probably coded using vs2012, that's why it's better to use vs2012. Also, Microsoft removed and changed lots of stuff in vs2013 and even more in vs2015 from vs2012. Vs2013 and 15 probably don't have the right commands built in
Sent from my SGH-M919 using XDA Free mobile app
hey i made batch file with sample commands for csnotify
p.s save the file with .bat
p.p.s i seek a bug, the -m text dont support long words
roxas22 said:
hey i made batch file with sample commands for csnotify
p.s save the file with .bat
p.p.s i seek a bug, the -m text dont support long words
Click to expand...
Click to collapse
since your parameter has spaces in it you should wrap it in quotes like :
Code:
csnotify -t "hi xda!!!" -m "i love xda!!!"
nazoraios said:
since your parameter has spaces in it you should wrap it in quotes like :
Code:
csnotify -t "hi xda!!!" -m "i love xda!!!"
Click to expand...
Click to collapse
Thanks, i have some problems with usising batch language
Well I finally figured out how to tap into speech libraries on windows rt, so I created a command line utility.
You can use it to speak some generic text by using this command line :
Code:
speak -t "hello world this is text to speech on windows rt"
Or you can pass in a filename :
Code:
speak "c:\some path to\filename.txt"
Or you can type "shell:sendto" into the address bar of windows explorer and create a shortcut to speak.exe in there and then you can then send text files to it and it will read them.
File should be attached for download.
I added a command line version of simplewebserver, which is called 'wscon' (webserver console).
bundled readme :
This is a console/parameter based version using much of the same code as SimpleWebServer program, but created for command line/script invocation.
The use case for this app is when you frequently change hosting directories and just want to spin up a server on some port and directory.
You can specify port and directory with -p and -d command line options or you can create a shortcut to this wscon program in your shell:sendto folder and right click a directory and 'send to' it.
If you use sendto it will use the default port set in wscon_settings.xml file, which is automatically generated in same folder as executable. Once this file exists you can override the default port of 8080 to be something else if you want.
If you launch from console with just -d option it will use default port in wscon_settings.xml also.
By default this application serves up only to local machine (localhost), if you run it as admin it will be visible to other computers (provided firewall allows).
Click to expand...
Click to collapse

## PRO-TIPS for your (non-pro) Windows RT ##

Well I guess this is more of a 'list of utilities, commands, and features' that might be buried so deeply into windows rt that you didn't know it was there. I don't know about other surface/winrt users but I have gotten more advanced configuring my surface rt than I ever did on an x86. Now I usually end up needing to configure my x86 devices to provide the same functionality I expect on my tablets.
So I don't think we have a list like this and I'm sure a lot of you have your own 'pro-tips', so maybe we can compile a list of hidden gems we can use with windows rt into this thread so that we collectively can reference or individually don't forget
So here is a short list to start off :
Utilities -- Many more utilities can be found by browsing c:\ProgramData\Microsoft\Windows\Start Menu\Programs
WF.msc (type at command prompt or Win-R key run window) : (Windows Firewall with Advanced Security) although they removed the control panel applet it seems they left in this mmc plugin.
gpedit.msc : group policy editor... somewhat hidden but they left this in
resmon (Resource Monitor)
msconfig (System Configuration)
msinfo32 (System Information)
steps (Steps Recorder) : this is a utility that will capture your activity as screenshots to play back or upload for others to see.
Modify whether links or html files open in Desktop or Metro versions of Internet Explorer :
Open desktop Internet Explorer, click on gear icon and choose Internet options. Now click on 'Programs' tab and select your preference from the 'Opening Internet Explorer' section dropdown.
Keyboard Shortcuts :
Metro snap via keyboard : Hold Windows and tap . (period) Keep holding down windows key and tap left, right, up, or down
Win-Tab : While alt-tab lets you cycle 'desktop' programs, Windows key + Tab cycles through 'metro' app list
Win-X : Show advanced start menu (same as right clicking start menu)
Win-D : Show/Hide desktop
Win-P : Pick from various multi-monitor configurations (duplicate/extend/pc only/external monitor only)
Console Commands
'HELP' : Show a list of all commands you can get more help on.
'WHERE' : Type where wf.msc (for example) and it will tell you where that program/file exists if it is in any of your PATH'ed folders.
'WMIC' : a very deep well of information, type WMIC /? to see list of all modules
wmic volume list brief (shows all mounted drives/volumes)
wmic qfe list brief (shows all installed windows updates)
'SYSTEMINFO' : another system info command, sort of a command line version of msinfo32
'TREE' : show an 'ascii-art' tree of sub-folders for the folder you are in.
'ASSOC' : command line ability to set file associations
'CERTUTIL' : can be used (among other things) for computing file hashes
certutil -hashfile [filename] [MD5|SHA1|SHA256] so for example :
certutil -hashfile myfile.zip sha1
Associations / Context menu / 'Send To' programs :
Create a shortcut to control.exe /name Microsoft.DefaultPrograms to quickly go to this control panel applet.
Use command line ASSOC to set file associations
Manage 'Send To' folder by opening 'windows' explorer, typing shell:sendto into the location bar to be taken to a folder showing all your 'send to' programs'. You can drop shortcuts to other programs (provided those programs accept command line arguments). Now you can right click a file in windows explorer and 'send to' programs like 7-Zip, Paint.NET, notepad++, etc.
Add an "Open with Notepad++" or other top level context menu for all files :
Open registry editor and browse to : HKEY_CLASSES_ROOT\*\shell.
Right-click on “shell” and choose to create a new key, calling it “Open with Notepad++”
Create a new key below that one called “command”
Double-click on the (Default) value in the right-hand pane and enter "c:\path_to_npp\notepad++.exe" $1
To have the menu item show the notepad++ icon do these extra steps :
Right click the "Open with Notepad++" key (which you created) and add a new string value called "icon"
Double click new "icon" value and set its string value to "c:\path_to_npp\notepad++.exe"
In all steps above make sure you enter the path to notepad++ on your machine instead of the path entered.
http://www.howtogeek.com/howto/wind...th-notepad-to-the-context-menu-for-all-files/
Make 'command prompt here' context menu when right clicking folder in windows explorer : http://www.howtogeek.com/howto/wind...-always-display-for-folders-in-windows-vista/
Enable 7-Zip Context Menu :
Run regedit (Registry Editor), and drill into / expand HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers.
Now right click on 'ContextMenuHandlers' and choose 'permissions'.
Click 'Advanced' button.
On advanced Security Settings screen (at the top) choose Change (owner) link.
When selecting a user or group screen comes up click 'Advanced', then 'Find Now', and in search results choose 'Administrators' (may need to widen column to distinguish from singular 'Administrator').
After highlighting Administrators, click OK button to go back to Advanced Security Settings screen.
Now you are able to click on 'Administrators' and click 'Edit' and select 'Full Control' and click ok to apply permission.
Keep clicking ok on dialogs till you are back at registry editor.
Now run 7-Zip as administrator, go into tools menu and select options.
Then on 7-Zip tab choose 'Integrate 7-Zip to shell context menu' and click ok to close dialog.
Context menu should now appear when right clicking on files in windows explorer.
Disabling Connected Standby :
This is only a good idea if your tablet will always be left on a charger or 'shut down' when not in use. If you turn off connected standby and set your display to turn off after... say 5 minutes, then after 5 minutes your display will really power off (backlight as well) but any desktop programs will continue to run. You might want to do this if you are running a web server or some other process in background. When you disable connected standby, many other options appear in your power options 'advanced power settings' page. If you do this I recommend you 'Create a power plan' on the 'Choose or customize a power plan screen first'.
To toggle connected standby feature on or off, modify the :
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\CsEnabled key, setting to 0 for 'off' or 1 for 'on' and reboot to take effect.
Node Chakracore :
This is really an undocumented bonus 'add-on', made by Microsoft which you can run even on windows rt devices which are not in test-signing mode. For those who are not familiar, NodeJS is a console-based javascript scripting environment. Standard Node.js uses v8 javascript engine (same as google chrome), however this 'node-chakracore' version uses the chakra javascript engine (which is the latest version used in edge browsers). Microsoft is providing this for raspberry pi users running Windows 10 on ARM but they also work on Windows RT.
I made a utility here if you prefer to try an automated means of installing
Install Node.JS (node-chakracore) :
Download the latest ARM release from : https://github.com/nodejs/node-chakracore/releases
Extract that archive to (for example) c:\nodejs
Add that directory (which you extracted to) to your path environment variable.
(Optional) Install/Setup NPM (lets you install packages from npm repository) :
Download https://github.com/npm/npm/archive/master.zip, save somewhere.
Extract it to (for example) c:\npm.
Open windows explorer and type %AppData% into the address bar and hit enter.
Within your AppData directory, create an "npm" directory.
Double click on npm folder you just created from windows explorer
Click into the address bar to see the full path and remember (or copy) this path for next step and later.
Save the following to file named "npm.bat" and save into the directory you just created/copied
Code:
@node c:\npm\npm-master\cli.js %*
(If you extracted npm elsewhere, update the batch file to reflect actual location)
Create an etc directory under this appdata npm folder
Create an separate etc directory under your node folder (c:\nodejs if you used suggested default)
Copy .npmrc file from c:\npm\npm-master to c:\node
Rename and get rid of the '.' from the filename so the filename is just npmrc
edit that npmrc file In notepad and add the following lines :
Code:
globalconfig=c:\users\username\appdata\roaming\npm\etc\npmrc
prefix=c:\users\username\appdata\roaming\npm
(make sure to substitute your username in the above this base folder is the folder I told you to remember/copy in previous steps)
Having saved those changes to npmrc under c:\node\etc, copy that file to your appdata\npm\etc directory as well.
Add the path of your appdata\npm directory your path environment variable. If you install global packages they will install commands/batch files into this folder. If it is pathed you can exec them as native commands. This path is also where we put the npm.bat so it can be run from anywhere.
A useful demonstration if you have configured the both npm and node correctly is to install cash (an implementation of unix shell commands) by typing from a command prompt :
Code:
npm install -g cash
That should take a several minutes to complete (hopefully successfully). When done you can run 'cash' or just '$' at a command prompt to bring up simulated Linux prompt from which you can type 'help' to see supported commands. These commands interop with windows commands as well so you can mix (see cash link above).​
(Thanks to @black_blob for discovering this node/npm)
I will add more info or cleanup as needed, feel free to post your own, if needed I can compile it into first post to work towards a guide if anyone wanted to make one.
I modded the Windows 10 Chakra(non-core) to run on 8.1 as a part of my earlier NodeJS port. By the way, I also had Microsoft Edge running with it at a time.(EdgeHTML)
I wonder if I should continue my backports from Win10
You mean other programs/frameworks? You have brought over some great stuff, so yes absolutely! Anything you have in mind?
nazoraios said:
You mean other programs/frameworks? You have brought over some great stuff, so yes absolutely! Anything you have in mind?
Click to expand...
Click to collapse
I have in mind to backport the UWP framework, or maybe even a FrankenKernel(10 kernel, 8.1 userspace). Microsoft Edge works without needing UWP, as you can use edgehtml like mshtml for embedding
You would definitely be my hero if you could bring over Edge, preferably with somewhat recent (EdgeHTML? rendering) and Chakra javascript engine.
Not sure how FrankenKernel and UWP support could work out but both could potentially be awesome... guess its the details which I'm sure you have a better idea than me. So do you think we would be able to run (open source?) Windows 10 apps and would the 'developer mode' be brought over with the kernel or is that 8.1 userspace which would require 8.1 developer license signing (and renewing every 6 months)? Or would the UWP part just be for console or node-chakracore like it is on IOT?
nazoraios said:
You would definitely be my hero if you could bring over Edge, preferably with somewhat recent (EdgeHTML? rendering) and Chakra javascript engine.
Not sure how FrankenKernel and UWP support could work out but both could potentially be awesome... guess its the details which I'm sure you have a better idea than me. So do you think we would be able to run (open source?) Windows 10 apps and would the 'developer mode' be brought over with the kernel or is that 8.1 userspace which would require 8.1 developer license signing (and renewing every 6 months)? Or would the UWP part just be for console or node-chakracore like it is on IOT?
Click to expand...
Click to collapse
Windows 10 kernel & system, Windows 8.1 explorer.exe, dwm and other tiny GUI bits
I have a Windows Server ARM64 build, but that's not 32-bit
Yea that sounds daring... Don't brick your device please Too bad no 32bit gui bits to borrow. I doubt they would bring the Ubuntu for Windows 10 subsystem to arm, but technically i'm sure they could since Ubuntu has arm and pi2 image.... still would be neat. Also I think they added ssh server to pi2 but not sure if it would be easy to 'extract' and borrow.
We will be watching you commander...
nazoraios said:
Yea that sounds daring... Don't brick your device please Too bad no 32bit gui bits to borrow. I doubt they would bring the Ubuntu for Windows 10 subsystem to arm, but technically i'm sure they could since Ubuntu has arm and pi2 image.... still would be neat. Also I think they added ssh server to pi2 but not sure if it would be easy to 'extract' and borrow.
We will be watching you commander...
Click to expand...
Click to collapse
The Ubuntu support uses the Linux binary compatibility SubSystem, also known as Astoria
black_blob said:
I have in mind to backport the UWP framework, or maybe even a FrankenKernel(10 kernel, 8.1 userspace). Microsoft Edge works without needing UWP, as you can use edgehtml like mshtml for embedding
Click to expand...
Click to collapse
That would be even more amazing than a running build of Windows 10 Mobile. So you'd have a "full" OS with the befinits of running UWP. That would def. insure the future of Windows RT.
It would be even better if astoria would work on it too. So you'd even able to run android apps.
I need help for the nodejs and the npm instructions. Can you explain it out in details for morons?
Sorry late reply... which steps are you getting confused at (for node/npm install) ? So for starters :
- if you open a command prompt and type "node -v" does it tell you the version of node your running? If so, what version does it say?
- if you type "npm -v" does it tell you the version of npm you are running or give an error? Tell version or error.
So i'll start with that to make sure your paths are set up.
I created an installer utility to install node-chakracore along with NPM. Hopefully this will make it easier for other or myself to install or upgrade as new versions of node-chakracore and npm come out.
The final step in the process (updating the system PATH environment variable) requires admin permissions so right click executable and run 'As Administrator'. If you prefer to set the environment variables yourself, this step will tell you the paths it would add.
9/13/16 : Updated default node chakracore download link to new 7.0.0-pre9 release, added a 'Complete' tab with links to further resources and made UI fix

[TOOL] ADB-Overlay [2.2.2.0 - .Net 6]

Heyho together,
after my P9-Lite and P10-Lite toolkit i thought, it's time to build a more generic version. Here it is, the ADB-Overlay!
The main point of this project is to serve a GUI for ADB. Currently, there is a File-Explorer, Remote-Desktop, Shell interface and APK installer implemented. You can also READ the contacts if your device is rooted and has sqlite3 installed. But a picture tells more as 1000 words... So here is a preview of what you'll get.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
But anyways, i'm not responsible for any damage done to your device! For example, if you delete some files/folders on root lvl etc.
Component Info
Remote-Desktop:
Left-Click = Touch
Right-Click = Swipe with duration
The keyboard is nearly fully supported, i have written a kind of WPF -> Android key-mapper. So even combos like SHIFT+A-Z, SHIFT+0-9, ALT+A-Z and ALT+0-9 should work. The base for the key-mapping is a 102 keys keyboard with en-GB or de-DE layout. If you have another setup, some keys may on other positions.
The screenshots will be created under "ADB-Overlay\Screenshots\Screenshot.yyyy-MM-dd_HHmmss.(bmp | gif | jpg | png | tiff | wmp)".
-
If the device is booted in the recovery, the Remote-Desktop is only a viewer, because the recoveries doesn't support "input tap x y" nor "input keyevent XXX".
Shell:
The input box supports CTRL-A-Z, so you'll have the ability to send for example CTRL+C to stop a remote process. If you want use Copy & Paste onto the input box, use the Right-Click menu.
Tested OS
Win 7 | 8 | 8.1 | 10 | 11 (32Bit/64Bit in VM-Ware)
Win 7 | 8 | 8.1 | 10 | 11 (64Bit Native)
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)
Huawei Mate 9 (THX to @Tecalote)
Huawei Mate 10 Lite (THX to @Chisetdel31260)
Huawei P9 (EVA-al10) (THX to @reynard1)
Sony Xperia X (THX to @FoxTheLegend)
Pixel 4 (THX to @squabbi)
Requirements
Android: min. 2.x
Platform: x86/x64 (Windows)
Frameworks: min. .NET 6 / .NET 6 Desktop Runtime x86/x64
(Installed ADB/Fastboot driver)
Download
Mirror: See attachments
Mirror #1: My FTP [USR/PW=ADB-Overlay]
Mirror #2: GoogleDrive
Mirror #3: Dropbox
Mirror #4: Mega
DO NOT MIRROR MY FILES! DO NOT COPY MY THREADS!
Bug-Tracker
If you can't use the SDK-Updater or the Version is 0.0, just close the ADB-Overlay delete the "platform-tools" directory and restart the ADB-Overlay.
If the device won't connect via W-/Lan, check which version of android you are running... the latest version "SP2A.220505.002, May 2022" seems to break "Developer settings -> USB-Debugging -> Debug over W-/Lan"... To get it working anyways, just open a cmd prompt in the "platform-tools" folder, connect your device via USB and execute the following command: "adb tcpip 12345" (or some other port). After that, you should be able to connect your device via W-/Lan.
App Freeze
If the ADB-Overlay freezes during startup or by connecting a rooted device, the solution is to update the su binary. I encountered this problem yesterday on an older device running Android N. After an update to Magisk Canary [build 21005] the problem was solved.
Changelog
DD.MM.YYYY | (A) = Added | (C) = Changed | (D) = Deleted | (F) = Fixed | (R) = Recoded | (U) Updated
----------------------------------------------------------------------------------------------------------------------------------------------------
30.04.2022 [2.2.2.0]
(F) The SDK updater.
27.04.2022 [2.2.1.0]
(F) A freeze which occured on some FTP-Servers which doesn't implement RFC 959 properly.
11.04.2022 [2.2.0.0]
(U) General improvements in terms of speed and connectivity.
(U) The FTP config is now AES-256 encrypted for better security.
29.11.2021 [2.1.0.0]
(U) To .Net 6
(U) General improvements in terms of speed and connectivity.
25.07.2021 [2.0.2.0]
(A) ADB-Sideload
(U) ADB and Fastboot binaries.
(F) Some transfer issues (Binary <-> Socket)
(F) The platform-tools updater.
12.01.2021 [2.0.1.0]
(F) All freezes on the Tree-/ListView.
(A) ColumnHeader sorting on the Explorer and Apk-Manager ListView.
(A) Sort options for all header not only Name, Size, Date and Type.
(C) Sorting happens now in the background (So no more freezes here too.).
.-Older changes-.
12.12.2020 [2.0.0.0 - .Net 5]
Switched to .Net 5.0
(F) FTP-Updater timeout issue
(C) Brotli compression to .Net native
17.09.2020 [1.18.46.0]
(A) sendrecv_v2 for Android 11
(A) Brotli compression for file transfers on Android 11
29.03.2020 [1.17.46.0]
(A) Cut (via Context-Menu and "Ctrl+X")
(A) Copy (by default and via Drag'n'Drop by holding "Ctrl" during drop)
(A) Move (via Drag'n'Drop by holding "Shift" during drop)
(NOTE: Move is now enabled for on-device, device-to-device, local-to-device and device-to-local transfers.)
(C) The copy window, it will now display "Copy" or "Move" depending on the current operation.
16.03.2020 [1.16.46.2]
(F) The updater buttons, now they are also disabled during an download/check.
15.03.2020 [1.16.46.1]
(F) File/Folder interaction with those which contains "\s _ - ' , * & ~ | < > ( ) [ ] { }" in their names.
07.03.2020 [1.16.46.0]
(C) The synchronous IO to fully asynchronous IO.
(A) The Edit-Window, this will temporary download the file and open it locally in an application defined for this file type or with the "OpenAs" dialog.
(C) The UI, buttons which can't be used are now "grayed out".
12.02.2020 [1.15.46.1]
(F) The re-connection bug on the FTP-View. (Which also caused the updater to fail.)
(F) The (2 sec) freezes after copy/delete/tar.
(C) The info bar, added the modify date.
31.01.2020 [1.14.46.0]
(F/A) The timestamps for access, changed, modify.
(C) The "Properties Window", added the mentioned fields and resized the height a bit.
(A) Create File on the FTP-View.
30.12.2019 [1.13.46.0]
(F) The FTP TLS/SSL problem, now all procedures (implicit/explicit) should work without problems. (I tested this the last days with multiple servers, also the proxy's socks4/a|5 should now work with TLS/SSL.)
(U) All 3 explorers, they relay now on an shared generic base explorer which implements most of the features for all 3 views. So it's guaranteed that all views will behave the same.
(U) All 3 explorer views, changed the spacing's and the "edit textbox" (on rename) a bit, so that they look a bit more like the default explorer.
(A) IComparable<T> and IEquatable<T> to all List-/TreeViewItems so you get a pre-sort during item parsing. (I thought it would work a bit nicer, but hey, now it's implemented^^)
(R) Optimized the item (file/folder) parser for both Android & FTP.
18.12.2019 [1.12.46.1]
(F) The broken SDK-Updater, where you saw in the log file a "BindingException".
(F) The "SocketException" on app close. Reason for this was, that i disposed the "DeviceMonitor" after i killed the adb-server, but the monitor tried to check in some cases (10 sec refresh rate) for changes, after the server was already down.
(A) The "remount" option for mounts to the properties window. (You'll get also a little warning, each time you attempt to remount a mount point.)
(C) Resized the properties and the updater windows a bit.
17.12.2019 [1.11.46.0]
(F) The remote desktop for 16-Bit devices.
(R) Root detection
(R) Mount detection (added support for Android 2.x)
(R) The properties view, as mentioned, there is now a more valuable overview.
14.12.2019 [1.10.46.0]
(A) A version banner to the title bar.
(R) Nearly the whole caching logic inside the local ,Android and FTP explorer.
(R) The mount ([Device]) overview, now you'll see all mounts returned from "mount" and the assigned "df" data, if available. (The next build will include a more valuable overview in the PropertiesWindow. Like the mount options etc.)
(R) The remote desktop, i moved the "color correction" inside the pixel-buffer copy process. This will save a lot of time and boost the FPS in my TWRP up to 80++ per sec.. (That was so much, that .Net even couldn't dispose the sockets so fast as i requested a new one... This ended in an waiting queue overflow... So i decided to limit the FPS to 30-40 this is enough to have a clean view.) - Also NOTE: BOOTED IN ANDROID, WILL DECREASE THE FPS TO 2-3 DEPENDING ON THE RESOLUTION OF YOUR DEVICE! THE ONLY SOLUTION FOR THIS IS, START ADB WITH ROOT RIGHTS. (I added a internal switch, which will detect if adb runs as root, if so, i don't relay on the frame-buffer-service of adb. Instead, i use the bare metal (/sys/class/graphics/fb0/) to get the correct buffer values and then i read directly from "/dev/graphics/fb0".) AGAIN, NOTE: THIS WILL NOT RAISE THE FPS UP TO 80++, BUT THE FPS WILL INCREASE UP TO 15-25.
11.12.2019 [1.9.46.1] (HotFix)
(A) The mistakenly removed overwrite protection on item rename. (Android)
(R) The Copy & Delete view, the media-scanner, if activated, will now only run once at the end of an copy or delete action.
(R) Sym-/Directory/File detection, there was in rare cases a wrong detection where a SymDirectory was treated as an SymFile.
(F) The "Create New Textfile" action. (Android)
10.12.2019 [1.9.46.0]
(F) An ArgumentNullException which was raised during "mount" parsing. (On the "device" view.)
(F) The renaming issue, where you got, "The element couldn't be renamed!", if the name hasn't changed.
(A) Windows shortcuts to the TreeView of the Windows explorer. (Even the original one hasn't that feature )
(A) Hiding the ".lnk" extension on any Windows shortcut.
(A) Internal auto updates to the remote explorers (Android/FTP). So you have a kind of "pseudo" FileSystemWatcher.
(A) The re-sorting of the items after an rename action.
(D) Some code duplication. (Saved all together ~12 kb)
(R) Unnecessary refreshes and replaced them with internal cache logic's.
02.12.2019 [1.8.46.0]
(F) An ObjectDisposedException which was sometimes raised after symlink parsing and/or file transfers.
(C) The channeling on the ADBSocket, from an ConcurrentDictionary to an simple array with locks, this increased the transfer speed.
(U) The dlls to the latest versions.
24.07.2019 [1.7.46.0]
(R) The config files, both, the config.xml and the config.ftp.xml got an structure update. The old/current config files will be migrated to the latest version. So there should be no data loss in any way.
(A) A version banner to the Android and FTP view
(C) The adb directory from "ADB-Overlay\adb" to "ADB-Overlay\platform-tools"
(A) The SDK-Updater
(A) Auto-SDK-Update - If activated, this will check once every 24h for an update, but only on startup of the ADB-Overlay. (NO Tasks or something)
Info
The updater will only check "https://dl.google.com/android/repository/repository-11.xml". This XML gets downloaded and parsed, if the "platform-tools" version is newer as the used one, you'll get an popup which offers the download for the latest version.
The Auto-SDK-Update is by default disabled.
28.06.2019 [1.6.46.0]
(F) A memory leak which occurred by removing a device (Android View -> Closing an tab)
(F) A memory leak which occurred by removing a server (FTP View -> Closing an tab)
(R) Improved the directory parsing speed
(A) A progress bar to the copy window (green during transfer and on completion | red on failure or cancellation)
04.06.2019 [1.5.46.0]
(C) The versioning:
1 = Major
5 = Minor
46 = Framework Version (4.6)
0 = Hotfix
(A) A few speed improvements to the Remote-Desktop.
(A) The updater/-menu
(A) Auto-Update - If activated, this will check once every 24h for an update, but only on startup of the ADB-Overlay. (NO Tasks or something)
Info
The updater will only check my FTP for a ".version" file. This gets downloaded and parsed, if the version is newer as the used one, you'll get an popup which offers the download for the latest version. (NO logs and NO telemetry!)
The Auto-Update is by default disabled.
28.05.2019 [0.0.0.5]
(A) The "APK Manager" to the Android -> Tools menu
(A) {<-} & {->} buttons to the addressbar
(A) The "Install" option to the remote explorer -> ListViewItem context menu (only shown if the item is a apk)
(R) Added the missing options to the APK Installer (e.g. Downgrade, Test-Package, etc.)
(R) Optimized the "symlink" parsing
01.05.2019 [0.0.0.4]
(F) An exception which was raised after you tried to open any "Tool" on an disconnected device.
(A) A Battery Monitor to the Android -> Tools menu
29.04.2019 [0.0.0.3]
(A) Remote-Viewer when booted in the recovery
(A) A screenshot format selector (bmp | gif | jpg | png | tiff | wmp) to the Remote-Desktop
(A) A color correction switch to the Remote-Desktop
(A) Links to the German forum post
20.04.2019 [0.0.0.2]
(F) An issue during item renaming - Reason was maybe the switch from .NET 4 to .NET 4.6, seems the UI updates on textboxes are no longer only on focus got/lost, instead they are now after any change.
(A) Contextmenu (Listview) -> New -> Text Document
(A) Replacements for "New Directory", "Group (New)", "Server (New)" to the german language, so you get now after such an action the correct "Neuer Ordner", "Neue Gruppe", "Neuer Server".
(C) The FTP Copy/Delete action, you can now close the control connection and leave only those windows open until they are done. Both, the Copy and Delete action using now their own connection which is no longer bound to the control connection.
(C) Moved the "Keep Alive" checkbox (FTP -> Servermanager -> Account) to FTP -> Servermanager -> Connection
13.04.2019 [0.0.0.1]
Initial release
Great job. my huawei mate 10 lite is recognized. currently my smartphone is on rom original stock rne - l21c432b340 emui 8.0 not rooted. and my PC is a windows 7 64.
Works for my Xperia X - and thanks for your help!
I'm flattered to be in your contacts screenshot I was still using your prototype you had sent to me years ago!
Works very well on my Pixel 4!
squabbi said:
I'm flattered to be in your contacts screenshot I was still using your prototype you had sent to me years ago!
Works very well on my Pixel 4!
Click to expand...
Click to collapse
Hey Bro
long time not seen. Hehe yeah the good old Multi-Explorer ;p - Still using it my self, it's more or less my playground before i implement things in this tool.
If you want and have some spare time we can modify this beauty. I also reworked nearly the whole AndroidCtrl.dll, there you have now solid filestreams, strongly typed FilesystemInfos (Like the one from the .NET fw) and lots of other handy stuff. Like framebuffer access in Android and recovery mode. I also implemented a ADBridge class which is an instanced wrapper for the 2 static ADB classes (binary/socket).
Best Regards,
Sebastian
this is what im looking for a while
Thank you very much
here is some suggestion
1.better ui
2.edit build prop in the realtime
btw my phone is Huawei P9(eva-al10) rooted android 8.0 work very well
k1ll3r8e said:
Hey Bro
long time not seen. Hehe yeah the good old Multi-Explorer ;p - Still using it my self, it's more or less my playground before i implement things in this tool.
If you want and have some spare time we can modify this beauty. I also reworked nearly the whole AndroidCtrl.dll, there you have now solid filestreams, strongly typed FilesystemInfos (Like the one from the .NET fw) and lots of other handy stuff. Like framebuffer access in Android and recovery mode. I also implemented a ADBridge class which is an instanced wrapper for the 2 static ADB classes (binary/socket).
Best Regards,
Sebastian
Click to expand...
Click to collapse
Sounds great! I'm looking to get back into toolkit making later this year, I'm keen to see the improvments to your library! :good:
Great job. we can navigate and copy files efficiently.
Only one thing is missing. Why not keep file timestamp for last access and modifie dates? or let us choose the option to keep it or not.
skyrail01 said:
Great job. we can navigate and copy files efficiently.
Only one thing is missing. Why not keep file timestamp for last access and modifie dates? or let us choose the option to keep it or not.
Click to expand...
Click to collapse
Heyho,
which Android version are you using and on which action (pull/push) does the timestamps get lost?
Normally i preserve the timestamps but on some Android versions the "timestamp" field in the ADB-Protocol is ignored.
Maybe i can set the timestamps on an other way, but therefore i need to know the version.
Regards,
Sebastian
PS:
Some code where i set the timestamps
Upload
Code:
public void Close(DateTime fileCreationTime)
{
if (_ch?.IsConnected ?? false)
{
if (CanWrite)
{
int o = 0, w;
byte[] d = new byte[8];
d.SetUInt32LE((UInt32)SyncCmd.DONE, 0);
d.SetUInt32LE(ToUnixTime(fileCreationTime), 4);
//...
}
_ch.Close();
}
}
Download
Code:
//...
using (FileStream dfs = destination.Open(FileMode.Create, FileAccess.Write))
{
using (AFileStream sfs = OpenRead())
{
sfs.CopyTo(dfs, DMAX, msg, cancellationToken);
ct = sfs.CreationTime;
}
}
//...
if (msg.State == TransferState.Done)
{
destination.CreationTime = ct;
transferEventHandler?.Invoke(Client.ID, new FileTransferEventArgs(Client.ID, msg));
return true;
}
//...
Thank you really great program keep it up
Hey,
I am operating under lineageOS 16 on Galaxy S5 (klte), using adb 1.0.39 on windows 10 64-bits, either via wifi or usb connect.
I check file dates under Windows, in console mode with far manager (M: last write time, C: creation time, A: last access time).
I am using linux command ls -l under adb shell from Windows command line to list files pushed to Android.
When pushing files from Windows to Android, only M is preserved, with a 2 hours offset (ES file explorer tells it is modified date) Maybe daylight issue or bad timezone.
When pulling files from Android, only C is preserved
When I pull back to Windows, files pushed to Android, all original date is lost.
But I am pretty sure we can preserve last access, modified and creation date as I could see Adbexplorer (another project) pull files keeping M and A (adb pull -a).
Hope I give you enough details.
k1ll3r8e said:
Heyho,
which Android version are you using and on which action (pull/push) does the timestamps get lost?
Normally i preserve the timestamps but on some Android versions the "timestamp" field in the ADB-Protocol is ignored.
Maybe i can set the timestamps on an other way, but therefore i need to know the version.
Regards,
Sebastian
PS:
Some code where i set the timestamps
Upload
Code:
public void Close(DateTime fileCreationTime)
{
if (_ch?.IsConnected ?? false)
{
if (CanWrite)
{
int o = 0, w;
byte[] d = new byte[8];
d.SetUInt32LE((UInt32)SyncCmd.DONE, 0);
d.SetUInt32LE(ToUnixTime(fileCreationTime), 4);
//...
}
_ch.Close();
}
}
Download
Code:
//...
using (FileStream dfs = destination.Open(FileMode.Create, FileAccess.Write))
{
using (AFileStream sfs = OpenRead())
{
sfs.CopyTo(dfs, DMAX, msg, cancellationToken);
ct = sfs.CreationTime;
}
}
//...
if (msg.State == TransferState.Done)
{
destination.CreationTime = ct;
transferEventHandler?.Invoke(Client.ID, new FileTransferEventArgs(Client.ID, msg));
return true;
}
//...
Click to expand...
Click to collapse
skyrail01 said:
Hey,
I am operating under lineageOS 16 on Galaxy S5 (klte), using adb 1.0.39 on windows 10 64-bits, either via wifi or usb connect.
I check file dates under Windows, in console mode with far manager (M: last write time, C: creation time, A: last access time).
I am using linux command ls -l under adb shell from Windows command line to list files pushed to Android.
When pushing files from Windows to Android, only M is preserved, with a 2 hours offset (ES file explorer tells it is modified date) Maybe daylight issue or bad timezone.
When pulling files from Android, only C is preserved
When I pull back to Windows, files pushed to Android, all original date is lost.
But I am pretty sure we can preserve last access, modified and creation date as I could see Adbexplorer (another project) pull files keeping M and A (adb pull -a).
Hope I give you enough details.
Click to expand...
Click to collapse
Heyho,
THX for that info, i'll check the "adbd" source which LOS uses, maybe there is the prob. According to "adb pull -a" i'll also have a look at the adb source, because i think they do some "touch" stuff. Because the ADB-Protocol it self only supports creation/last modified time. In the source is a another "struct" for "STA2" (stat 2) command. But i have never seen a adb binary which supports this. (All binaries use the "STAT" command.)
EDIT 1:
Just checked the adb source again, seems they changed it a bit...
(This is the current STAT (v1) header)
Code:
# cmd name STAT or STA2 // 4 bytes
st->st_mode = msg.stat_v1.mode; // 4 bytes
st->st_size = msg.stat_v1.size; // 4 bytes
st->st_ctime = msg.stat_v1.mtime; // 4 bytes
st->st_mtime = msg.stat_v1.mtime; // 4 bytes
My HTC-One M9, Sensation, VM-Ware (Kitkat - Nougat) none of them has a 20 byte header. ALL of them return a 16 byte header.
Code:
CMD // 4 bytes
Mode // 4 bytes
Size // 4 bytes
CTime // 4 bytes
So it seems the protocol is highly inconsistent... I'll check how much time gets lost by calling touch on each file, because, currently i open a sync channel via an smart-socket, transfer the file and read all data provided by the protocol header. This is really fast, but if i have to spin up each time another channel to get a shell for the touch, this will increase the time each copy needs. Because, a shell depending on the version (v1, v2), has a lot checks you need to perform, specially the shell_v2 because it's like a ssh protocol.
EDIT 2:
Just for completeness, i'm pretty sure your device also sends only a 16 byte header for the stat v1 command, because:
(This is a cut of my implemented "Stat(byte[] bytes)" class)
Code:
if (c == (uint)SyncCmd.STA2 && bytes.Length >= 72)
{
ID = SyncCmd.STA2;
Error = bytes.GetUInt32LE(4);
Dev = bytes.GetUInt64LE(8);
INode = bytes.GetUInt64LE(16);
Mode = bytes.GetUInt32LE(24);
NLink = bytes.GetUInt32LE(28);
UID = bytes.GetUInt32LE(32);
GID = bytes.GetUInt32LE(36);
Size = bytes.GetUInt64LE(40);
ATime = bytes.GetInt64LE(48);
MTime = bytes.GetInt64LE(56);
CTime = bytes.GetInt64LE(64);
}
else if (c == (uint)SyncCmd.STAT && bytes.Length == 16)
{
ID = SyncCmd.STAT;
Mode = bytes.GetUInt32LE(4);
Size = bytes.GetUInt32LE(8);
CTime = bytes.GetUInt32LE(12);
}
As you can see, the both structures differ in there field order, if your device would send a 20 byte header, the test (bytes.Length == 16) wouldn't match. And you couldn't download a file.
EDIT 3:
After playing a while with "stat" and "touch" on some Android versions, i decided to rely on those functions. The next build should restore and write the correct timestamps.
EDIT 4:
Well, setting timestamps on the SD-Card doesn't work, also, setting timestamps on the "internal" SD-Card doesn't work either. Seems that it's related to the underlying FS. If i try to set the timestamp on an ext4 partition, it works. So it doesn't make sense to rewrite the push/pull functions because the return of touch for 99% of the time will be "touch: '/sdcard/TWRP/test.pdf': Operation not permitted". So it's simply a time waste during the copy procedure. BUT, i'll implement it at least for the download, so u'll get the correct timestamps on Windows.
EDIT 5:
Added a screenshot of the new "Properties Window" which also proves that the download timestamps are now correct.
(Btw. C doesn't mean created - it means changed)
Code:
stat /sdcard
File: `/sdcard' -> `/storage/self/primary'
Size: 21 Blocks: 0 IO Blocks: 512 symbolic link
Device: 1h/1d Inode: 4432 Links: 1
Access: (777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 1970-01-01 01:00:00.000000000
Modify: 1970-01-01 01:00:00.000000000
Change: 1970-01-01 01:00:00.360063176
Little update about the "creation time". After a bit research i found this post on Stack Exchange, there is explained that the so called "birth time" is stored since ext4 as part of the INode field. But it seems you need a special version of "stat" to read this info, it's called "statx". But so far i could see, Android doesn't support this feature, maybe some kernel does but it seems that it's more the rare case.
Regards,
Sebastian
Thanks for the update!
I was wondering what could be causing a small delay in copying files over, once the progress finishes, the transfer dialog remains frozen for a 1-2 seconds. I'm copying over a photo, so around 2MB.
squabbi said:
Thanks for the update!
I was wondering what could be causing a small delay in copying files over, once the progress finishes, the transfer dialog remains frozen for a 1-2 seconds. I'm copying over a photo, so around 2MB.
Click to expand...
Click to collapse
Heyho ,
yup i still working on it. It seems that the "Task.Delay()" isn't performed inside the Task itself, instead it's executed on the main thread. The reason for the freeze is, that i try to show the last result, otherwise the copy window would close immediately after the last element and you couldn't see if it's transferred or not. So i keep it like windows, wait 1,5-2,5 sec before closing the window.
The delay you might feel extremely is the "Media-Scanner". It runs on the end of each copy/delete action, the reason for this is, that files pushed/copied by adb are not reported to the MTP interface. So you couldn't see those files if you connect your device after such an adb copy via MTP. Also files/folders deleted by adb are also not reported to the MTP interface. So you will see those elements via MTP if you don't perform manually the "Media-Scanner" lookup. - But if you work only with adb for example, you could turn the "Media-Scanner" off. All device based explorers and of course adb will see those files/folders at any times. (But if you need those files/folders for exchange you should keep the "Media-Scanner" on )
EDIT:
This is executed for every file which is copied/pushed/deleted.
Code:
_adb.Device.Manager.ActivityManager.Broadcast("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "-a", string.Concat("-d 'file://", remotePath, "' > /dev/null"));
EDIT 2 (a bit off-topic):
You could also simply use the "Media-Scanner" with my AndroidCtrl.dll. The calls are:
Code:
//"_adb" is a instance of "ADBClient"
_adb.Device.IO.MediaScanner.CreateScanList(string remoteDirectory, MediaScanMode mode);
_adb.Device.IO.MediaScanner.CreateScanList(string remoteDirectory, MediaScanMode mode, CancellationToken cancellationToken);
_adb.Device.IO.MediaScanner.CreateScanList(string remoteDirectory, IList<string> files, MediaScanMode mode, CancellationToken cancellationToken);
_adb.Device.IO.MediaScanner.ScanDirectory(string remotePath, MediaScanMode mode);
_adb.Device.IO.MediaScanner.ScanDirectory(string remotePath, MediaScanMode mode, CancellationToken cancellationToken);
_adb.Device.IO.MediaScanner.ScanDirectory(IEnumerable<string> remotePaths, MediaScanMode mode);
_adb.Device.IO.MediaScanner.ScanDirectory(IEnumerable<string> remotePaths, MediaScanMode mode, CancellationToken cancellationToken);
_adb.Device.IO.MediaScanner.ScanFile(string remotePath, MediaScanMode mode);
_adb.Device.IO.MediaScanner.ScanFile(IEnumerable<string> remotePaths, MediaScanMode mode);
_adb.Device.IO.MediaScanner.ScanFile(IEnumerable<string> remotePaths, MediaScanMode mode, CancellationToken cancellationToken);
_adb.Device.IO.MediaScanner.ScanObject(ITransferMessage message, MediaScanMode mode);
EDIT 3:
Found the bad boy, seems "Task.Delay()" only works when used in "async" context. Now the "freeze" is gone, you can move the window until it vanishes. So, in the next update those "freezes" are gone.
---
Little Update:
@squabbi
The next update includes a little editor as suggested by @reynard1. A screenshot can be found as attachment.
Regards,
Sebastian
k1ll3r8e said:
**snip**
EDIT 3:
Found the bad boy, seems "Task.Delay()" only works when used in "async" context. Now the "freeze" is gone, you can move the window until it vanishes. So, in the next update those "freezes" are gone.
---
Little Update:
@squabbi
The next update includes a little editor as suggested by @reynard1. A screenshot can be found as attachment.
Regards,
Sebastian
Click to expand...
Click to collapse
Woohoo! Thanks for digging into it! I'm glad you found the culprit haha.
Looking forward to that editor feature! Do you know if it's possible to integrate with Windows Explorer? It's probably a little harder, but something like how WinSCP can drag files from the remote to a local Explorer window.
If that's a little difficult, would this be possible to implement? If I drag and drop a folder/file onto the local pane, it will change directory (and highlight the file if a file was dragged onto the local pane). Just to make it easier to work with folders I have already open.
Still using Windows 7?
squabbi said:
Woohoo! Thanks for digging into it! I'm glad you found the culprit haha.
Looking forward to that editor feature! Do you know if it's possible to integrate with Windows Explorer? It's probably a little harder, but something like how WinSCP can drag files from the remote to a local Explorer window.
If that's a little difficult, would this be possible to implement? If I drag and drop a folder/file onto the local pane, it will change directory (and highlight the file if a file was dragged onto the local pane). Just to make it easier to work with folders I have already open.
Still using Windows 7?
Click to expand...
Click to collapse
Heyho
Yes its definatly possible, we need to use the so called "VirtualFileDataObject". I tried to implement it some time ago, but doesn't worked as expected. But i'll give it another try.
-
Yup, i still use Win 7 as my main system, but i have some VMs running, like my Debian server which serves the documentation and some test sites for my php projects, a few Android x86 Versions and of course a legit Win10 installation to test If everything works.
*Never change a running system! - Currently my main hdd has a uptime of 2689 days with 216 restarts, i think that tells a lot *
---
Little Update:
As the screenshot shows, the editor is working fine so far. (Added also a few more controls.) The only problem i still have is, that if ADB doesn't run as root you can't edit for example the "build.prop". Because ADB can't write the file directly back, so i need to build a kind of "tmp" file. The next problem will be, that you (the user) have to remount the mount point, before you start editing those "root" and "write protected" files. There is also a problem with "binary" files, because the "RichTextBox" screws up when it gets "binary to ASCII/UTF8" transformed data, which ends in an app freeze... So i have to check on some way if the stream contains really text-data, the file extension doesn't help here much because, you know, linux uses also a lot of txt files without any extension.
Update 2:
Just got the "binary" files running... With a super BIG drawback, 248 kb (4069 rows) text results in 269,364 mb memory utilization by the "RichTextBox". - The prob here is, that the ADB filestream doesn't support seek, so i need to load the whole doc in one, which is quiet to much for the "RichTextBox"...
Update 3:
Soo, i wrote a kind of paging for the "RichTextBox" which works so far really nice, at least when it comes to the memory (even during scrolling, with free running wheel, only 15 - 27 mb increase), there is now a fixed amount of rows (40) which will be shown, all other rows are hidden from the "RichTextBox". This opens a few new issues^^ - Currently there is no selection possible which goes beyond the 40 rows. Also insert and delete are a little challenge because, i need to "overwrite" the default behavior with the some "PreviewKeyDown/etc." events... - Looks all a bit hacky, but lets see if it works in the end.
Update 4:
Well, the "RichTextBox" is out of the race^^ - It triggers events more or less random instead when you expect it, it removes blank lines (for example you have 3x "\n", this gets wrapped to 1x "\n") and the best, you remove "\r" during stream reading and the RTB adds it again, also random (some paragraphs get an "\r" some not). Editing text in a solid way without losing something isn't possible with this thing... So i'll try the "TextBox".
Last Update before release:
So, after testing the "RichTextBox" and "TextBox" i ask myself why those controls are there^^. Both can't edit text with more than a few hundert lines, the "TextBox" is at least much better as the "RichTextBox" but it also screws up when i comes to more as 250 kb text. So the "Editor" will be one of your installed applications. I add a little tool window, which offers the temporary download to the windows temp folder, after that i launch the windows "OpenAs" dialog that you can choose the editor you want. Also, i'll attach a "FileSystemWatcher" to the file that the upload automatically happens when you press save in your editor.
Little Info:
It take a few more days for the "edit" update, because i started also to implement the TAP pattern, this increased for example the download speed by factor 6. But to implement it the right way, i have to rewrite a lot of code in the AndroidCtrl.dll and AndroidCtrlUI.dll.
Regards,
Sebastian
k1ll3r8e said:
Heyho
Yes its definatly possible, we need to use the so called "VirtualFileDataObject". I tried to implement it some time ago, but doesn't worked as expected. But i'll give it another try.
-
Yup, i still use Win 7 as my main system, but i have some VMs running, like my Debian server which serves the documentation and some test sites for my php projects, a few Android x86 Versions and of course a legit Win10 installation to test If everything works.
*Never change a running system! - Currently my main hdd has a uptime of 2689 days with 216 restarts, i think that tells a lot *
** snip **
Click to expand...
Click to collapse
That'll be great to see haha, and that does make sense keeping your system as is, if it works, it works.
Thanks for your hard work in checking out what's best for the new edit function. Maybe there's a library out there that can implement a text viewer better? I'm not familiar with WPF libraries, or how many there are.
squabbi said:
That'll be great to see haha, and that does make sense keeping your system as is, if it works, it works.
Thanks for your hard work in checking out what's best for the new edit function. Maybe there's a library out there that can implement a text viewer better? I'm not familiar with WPF libraries, or how many there are.
Click to expand...
Click to collapse
Heyho,
i have had a look on Avalon Texteditor but on StackOverflow is also a discussion about how to open a file bigger than 20 mb. It seems WPF is not that great for such things. I found also another one, written by a lonely dev like me , but it's not maintained since 7 years. So the best way might be, open a installed App which is well designed for that purpose.
A bit off-topic
I nearly finished the TAP implementation for the AndroidCtrl.dll, so far it brought a great speed increase. Also, it consumes less CPU time, for example the remote desktop uses only 3-7% on an Intel I5 with 32 GB memory (but up to 36% on an single-core Intel Pentium M with 1,5 Ghz and 1 GB memory - my old well working Laptop, also with Win7 ). So you might be happy to see all the new "real async" overloads in the lib. (I implemented all from scratch, so there is NO Task.Run() or Task.StartNew() in those functions.)
Edit:
Soo, after a few horrible days, the TAP pattern is now fully integrated! But there is still a little issue with the Remote-Desktop recovery viewer. It seems that everything got a speed boost except the recovery viewer, the viewer is currently nearly 4x slower as before... After i fixed this last problem, i'll release the new asynchronous version.
Regards,
Sebastian

Categories

Resources