This thread is a WIP and will be updated as I have time to include and write more info.
With this guide you will be able to launch games and emulated games much more "seemlessly".
Requirements:
Keyboard ( although you could manually add everything to the launchers.xml config )
ADB
A rooted OUYA http://forum.xda-developers.com/showthread.php?t=2387507
( NOTE: Technically most arg's being passed could be done without root... More info in 3rd post. )
XBMC installed ( official or spmc... I haven't tried with a gotham build )
Advanced Launcher plugin for XBMC http://forum.xbmc.org/showthread.php?tid=85724
OR
Rom Collection Browser ( see second post )
A reasonable text editor ( If on windows - Notepad++ )
ADVANCED LAUNCHER
{
"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"
}
1.) Install Advanced Launcher
Copy over the Advanced Launcher plugin to the OUYA and install it ( You can install it by going to Settings -> Add-Ons -> Install From Zip File )
2.) Create a new category
Load the addon and with a keyboard press "c", which will open a popup. Choose "Create New Category" and call it "Emulation".
3.) Create a "launcher"
Open the newly created category which should prompt you to create a new launcher. Select "Files Launcher" and go through the menus ( select the launcher application [ su or am... read 3rd post ], select files path [ where the games are stored ] and set file extensions [ look at the example it gives ] )
At "Application Arguments" leave it as default ( due to a scroll limit you can't see what to type... we will modify this later )
Continue with the setup ( Set title of launcher [ typically label of system ], select platform [ which system you are emulating ], set thumbnails path and set fanart path )
4.) Adding the correct arguments
Pull launchers.xml from:
Code:
/sdcard/Android/data/com.semperpax.spmc/files/.xbmc/userdata/addon_data/plugin.program.advanced.launcher/launchers.xml
( change the "com.semperpax.spmc" to whatever version of xbmc you have installed )
Open launchers.xml and under "launchers" look for the emulator you added ( this would be the name you chose when you set the title of the launcher ) and you should see the following line:
Code:
<args>"%rom%"</args>
Change it to represent one of the arguments found in the 3rd post. for example purposes here's what the line would look like if I were setting up the Reicast:
Code:
<args>start -n com.reicast.emulator/.GL2JNIActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"</args>
Save it and push it back to the location it was pulled from.
5.) Reload XBMC ( or just the script )
Once you reload you should be able to add games... to add games hit the "c" key on your keyboard with the emulator highlighted and select "Add items". Select any game(s) you wish to add.
Afterwards you should be able to launch the games from Advanced Launcher
ROM COLLECTION BROWSER
Install RCB like you would any addon.
In order to get RCB to work there's a few changes that have to be made... 2 files to be specific.
1.) applaunch.sh
located at:
Code:
/sdcard/Android/data/com.semperpax.spmc/files/.xbmc/userdata/addon_data/script.games.rom.collection.browser/scriptfiles/applaunch.sh
or
Code:
/sdcard/Android/data/org.xbmc.xbmc/files/.xbmc/addons/script.games.rom.collection.browser/resources/scriptfiles/applaunch.sh
( change the "com.semperpax.spmc" to whatever version of xbmc you have installed )
You'll need to comment out the following lines:
Code:
case "$(uname -s)" in
Darwin)
XBMC_PID=$(ps -A | grep XBMC.app | grep -v Helper | grep -v grep | awk '{print $1}')
XBMC_BIN=$(ps -A | grep XBMC.app | grep -v Helper | grep -v grep | awk '{print $5}')
;;
Linux)
XBMC_PID=$(pidof xbmc.bin)
XBMC_BIN="xbmc"
;;
*)
echo "I don't support this OS!"
exit 1
;;
esac
Save it and push it back to the same location we pulled it from.
2.) launcher.py
located at:
Code:
/sdcard/Android/data/com.semperpax.spmc/files/.xbmc/addons/script.games.rom.collection.browser/resources/lib/launcher.py
( change the "com.semperpax.spmc" to whatever version of xbmc you have installed )
Comment out:
Code:
if(isFullScreen):
Logutil.log("Toggle to Windowed mode", util.LOG_LEVEL_INFO)
#this minimizes xbmc some apps seems to need it
try:
xbmc.executehttpapi("Action(199)")
except:
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Input.ExecuteAction","params":{"action":"togglefullscreen"},"id":"1"}')
toggledScreenMode = True
Code:
pre launch command
if(precmd.strip() != '' and precmd.strip() != 'call'):
Logutil.log("Got to PRE", util.LOG_LEVEL_INFO)
os.system(precmd.encode(sys.getfilesystemencoding()))
preDelay = settings.getSetting(SETTING_RCB_PRELAUNCHDELAY)
if(preDelay != ''):
preDelay = int(float(preDelay))
xbmc.sleep(preDelay)
Modify:
Code:
if(romCollection.usePopen):
import subprocess
subprocess.Popen(cmd.encode(sys.getfilesystemencoding()), shell=True)
else:
os.system(cmd.encode(sys.getfilesystemencoding()))
to this:
Code:
if(romCollection.usePopen):
import subprocess
subprocess.Popen(cmd.encode('utf-8'), shell=True)
else:
os.system(cmd.encode('utf-8'))
Comment out:
Code:
postDelay = settings.getSetting(SETTING_RCB_POSTLAUNCHDELAY)
if(postDelay != ''):
postDelay = int(float(postDelay))
xbmc.sleep(postDelay)
post launch command
if(postcmd.strip() != '' and postcmd.strip() != 'call'):
Logutil.log("Got to POST: " + postcmd.strip(), util.LOG_LEVEL_INFO)
os.system(postcmd.encode(sys.getfilesystemencoding()))
Save it and push it back to the same location we pulled it from.
3.) Create a "Rom Collection"
Hit the "U" button ( or "C" key on a keyboard ) on your OUYA controller, this will open a menu... select "Add Rom Collection".
Fill out all the info ( how you want to select info/artwork, what console, location of emulator ( su or am... read 3rd post )
On the "Emulator params" just select the default for now... we will modify this afterward.
Continue on in the setup... ( path to the roms, what file mask [ in otherwords which extensions to look for... look at the example it gives ] and lastly select a location for the artwork )
4.) Adding the correct emulator arguments
Pull config.xml from:
Code:
/sdcard/Android/data/com.semperpax.spmc/files/.xbmc/userdata/addon_data/script.games.rom.collection.browser/config.xml
( change the "com.semperpax.spmc" to whatever version of xbmc you have installed )
Open config.xml and under the rom collection you created... look for the following line:
Code:
<emulatorParams>"%ROM%"</emulatorParams>
Change it to represent one of the arguments found in the 3rd post. for example purposes here's what the line would look like if I were setting up the SNES:
Code:
<emulatorParams>start -n com.explusalpha.Snes9xPlus/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%ROM%"</emulatorParams>
Save it and push it back to the same location we pulled it from.
5.) Reload XBMC ( or just the script )
After you reload you should be able to launch the games without a problem.
There are some arguments that will require root and others that do NOT require root... If theres a root/nonroot option I will list both.
If the argument is non-root required, for the "application" use /system/bin/am
If the argument is root required, use /system/xbin/su for the "application"
-=Emulator Arguments=-
2600.EMU:
non-root:
start -n com.explusalpha.A2600Emu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
Ataroid:
non-root:
start -n com.androidemu.atari/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
C64.EMU:
non-root:
start -n com.explusalpha.C64Emu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
DraStic:
non-root:
start -n com.dsemu.drastic/.DraSticActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -e GAMEPATH "%rom%"
ePSXe:
non-root:
start -n com.epsxe.ePSXe/.ePSXe -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -e com.epsxe.ePSXe.isoName "%rom%"
FPSE: ( NOTE: can be rather....buggy... also will only work in nobios mode )
non-root:
start -n com.emulator.fpse/.Main -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -e path "%rom%"
GameBoid:
non-root:
start -n com.androidemu.gba/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
GBA.EMU:
non-root:
start -n com.explusalpha.GbaEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
GBC.EMU:
non-root:
start -n com.explusalpha.GbcEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
GBCoid:
non-root:
start -n com.androidemu.gbc/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
Gearoid:
non-root:
start -n com.androidemu.gg/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
Gensoid:
non-root:
start -n com.androidemu.gens/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
MD.EMU:
non-root:
start -n com.explusalpha.MdEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
MSX.EMU:
non-root:
start -n com.explusalpha.MsxEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
Mupen64Plus AE Free 2.4.4: ( playstore )
non-root: ( will load the emulator menu with the correct rom selected )
start -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
root: ( will first load the emulator with the correct rom and then reload to the play menu to either resume where you last left off on your game or restart the emu so the game is at first boot )
-c 'am start -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%" && am start -S -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.PlayMenuActivity'
Mupen64Plus AE 2.4.4: ( playstore )
non-root: ( will load the emulator menu with the correct rom selected )
start -n paulscode.android.mupen64plus/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
root: ( will first load the emulator with the correct rom and then reload to the play menu to either resume where you last left off on your game or restart the emu so the game is at first boot )
-c 'am start -n paulscode.android.mupen64plus/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%" && am start -S -n paulscode.android.mupen64plus/paulscode.android.mupen64plusae.PlayMenuActivity'
Mupen64Plus AE: ( ouya discovery )
non-root: ( will load the emulator menu with the correct rom selected )
start -n paulscode.android.mupen64plusae/.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
root: ( will first load the emulator with the correct rom and then reload to the play menu to either resume where you last left off on your game or restart the emu so the game is at first boot )
-c 'am start -n paulscode.android.mupen64plusae/.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%" && am start -S -n paulscode.android.mupen64plusae/.PlayMenuActivity'
N64oid:
non-root:
start -n com.androidemu.n64/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
NEO.EMU:
non-root:
start -n com.explusalpha.NeoEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
NES.EMU:
non-root:
start -n com.explusalpha.NesEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
NESoid:
non-root:
start -n com.androidemu.nes/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
NGP.EMU:
non-root:
start -n com.explusalpha.NgpEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
PCE.EMU:
non-root:
start -n com.PceEmu/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
PPSSPP:
non-root:
start -n org.ppsspp.ppsspp/.PpssppActivity -e org.ppsspp.ppsspp.Shortcuts "%rom%"
Reicast:
non-root:
start -n com.reicast.emulator/.GL2JNIActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
RetroArch: ( example using PS1 )
non-root:
start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -e ROM "%rom%" -e LIBRETRO /data/data/com.retroarch/cores/pcsx_rearmed_libretro_neon_android.so -e CONFIGFILE /data/data/com.retroarch/retroarch.cfg -e IME tv.ouya.console.ime.keyboard/.OUYAKeyboard -n com.retroarch/.browser.retroactivity.RetroActivityFuture
( for the other emulator cores just point to the appropriate libretro*.so )
Snes9x EX+:
non-root:
start -n com.explusalpha.Snes9xPlus/com.imagine.BaseActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
SNesoid:
non-root:
start -n com.androidemu.snes/.EmulatorActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
SuperGNES lite:
non-root:
start -n com.bubblezapgames.supergnes_lite/.SuperGNES -a android.intent.action.VIEW -eu Uri "file://%rom%"
SuperGNES:
non-root:
start -n com.bubblezapgames.supergnes/.SuperGNES -a android.intent.action.VIEW -eu Uri "file://%rom%"
-=Game Arguments=-
coming soon...
man, thanks to the reference to ouyaforum, I've seen the link to the latest/cheapest BT+IR controller that honestly will work both my TV/LCD and the Ouya at the same time - http://www.amazon.com/Media-Blu-ray-Remote-Control-Playstation-3/dp/B0050SX9I2/. ordered and gonna give it a try.
I got a Rii bluetooth off spamazon a while back but it is not performing up to snuff.
Just curious since I don't know what all the currently most used ( or user preferred ) emulators these days are.... but if people here could start listing emulators they use or would like to see the args and setup for please do post here and I'll get to adding it into the second post.
Sega Saturn and Atari Jaguar would be cool! :good:
I just wanted to say that this looks really awesome and can't wait to try it out!
Speechless
I cant believe I never found this thread until today. This is amazing, I cant thank you enough. This makes the Ouya a 1000x better. :good::good::good:
This needs to be put in more places. Is it okay if I post a link to this thread on a couple of forums(gwenael, xbmc.org, freaktab, xbmchub, xunitytalk, and so on)? Many people are curios about launching games through xbmc on android.
This is just.........I can't even put it into words.
You just made my month.
Thank you.Thank you. Thank you.Thank you. Thank you.Thank you. Thank you.Thank you. Thank you.Thank you.
---------- Post added at 07:47 AM ---------- Previous post was at 07:38 AM ----------
IncognitoMan said:
Just curious since I don't know what all the currently most used ( or user preferred ) emulators these days are.... but if people here could start listing emulators they use or would like to see the args and setup for please do post here and I'll get to adding it into the second post.
Click to expand...
Click to collapse
ppsspp(side-loaded) is the only one I dont see that id like to know for the ouya(Retroarch/libretro along with Mupen64plus pretty much handle everything else for me)
So how do you figure these arguments out in the first place?
1995mkw said:
I cant believe I never found this thread until today. This is amazing, I cant thank you enough. This makes the Ouya a 1000x better. :good::good::good:
This needs to be put in more places. Is it okay if I post a link to this thread on a couple of forums(gwenael, xbmc.org, freaktab, xbmchub, xunitytalk, and so on)? Many people are curios about launching games through xbmc on android.
This is just.........I can't even put it into words.
You just made my month.
Thank you.Thank you. Thank you.Thank you. Thank you.Thank you. Thank you.Thank you. Thank you.Thank you.
---------- Post added at 07:47 AM ---------- Previous post was at 07:38 AM ----------
ppsspp(side-loaded) is the only one I dont see that id like to know for the ouya(Retroarch/libretro along with Mupen64plus pretty much handle everything else for me)
So how do you figure these arguments out in the first place?
Click to expand...
Click to collapse
I was meaning to right a bit more in the guide in regards to how to figure out the args ( or in this case what intents are being called upon ) but to basically sum it up you can logcat and see how the apps intents are being passed and whats being called for ( you can also do the same thing by decompiling and looking at the source but for 90% of it you *should* be able to get away with using just logcat )
So far I haven't been able to get ppsspp to work due to it missing intents we need... so until the author adds intents that we can use to call for we cant use ppsspp with this other than to load the emulator.
Also I'll be massively updating ( and cleaning ) this thread *soon* to include RCB support ( Rom Collection Browser )
Yesterday between me and EldonMcGuinness we figured out what was causing the issues with it not wanting to work on android... lucky for us the changes were small and very little had to be done to make it work ( and it basically works the same way as Advanced Launcher )... The benefit of being able to use RCB is quite nice since not only is RCB included in the main repo of plugins ( thus this works not only on frodo but gotham too! ) but also because some skins actually have RCB support as a widget... so for instance my last 10 played games are shown on the home screen...
As for posting this at other forums I'm fine with that as long as it links back here so I can answer questions or maybe take requests on which games/apps they'd like to see added to the list.
--edit:
In fact you should start seeing the changes today ( I'll probably be moving posts around and refining more throughout the day )
IncognitoMan said:
I was meaning to right a bit more in the guide in regards to how to figure out the args ( or in this case what intents are being called upon ) but to basically sum it up you can logcat and see how the apps intents are being passed and whats being called for ( you can also do the same thing by decompiling and looking at the source but for 90% of it you *should* be able to get away with using just logcat )
So far I haven't been able to get ppsspp to work due to it missing intents we need... so until the author adds intents that we can use to call for we cant use ppsspp with this other than to load the emulator.
Also I'll be massively updating ( and cleaning ) this thread *soon* to include RCB support ( Rom Collection Browser )
Yesterday between me and EldonMcGuinness we figured out what was causing the issues with it not wanting to work on android... lucky for us the changes were small and very little had to be done to make it work ( and it basically works the same way as Advanced Launcher )... The benefit of being able to use RCB is quite nice since not only is RCB included in the main repo of plugins ( thus this works not only on frodo but gotham too! ) but also because some skins actually have RCB support as a widget... so for instance my last 10 played games are shown on the home screen...
As for posting this at other forums I'm fine with that as long as it links back here so I can answer questions or maybe take requests on which games/apps they'd like to see added to the list.
Click to expand...
Click to collapse
Its a shame ppsspp wont work. However the fact that RCB is on the verge of working is quite nice(RCB is what Im using on my HTPC).
I'll try fiddling around with logcat later(Its all always good to know how to do things yourself.)
One of the things I noticed about this thread is the lack of activity(posts/veiws) despite its significance(I believe this is due to the lack of traffic in the Ouya section of xda). Im sure a lot of people are interested in this but just haven't had the opportunity to see the thread(Ive been looking for something like this since just after Christmas and only found it just now). This is is useful to more than just people with an Ouya. Anyone running an android device attached to their TV can benefit from this guide(Though the Ouya makes the most sense since it is operated with a gamepad).
So I figured posting links to this thread on the places I was originally looking(Mainly xbmc and advanced launcher related resouses/fourums. I just never thought about looking in a device specific forum despite it being the device I wanted this for in the first place) would help people find this easier.
1995mkw said:
Its a shame ppsspp wont work. However the fact that RCB is on the verge of working is quite nice(RCB is what Im using on my HTPC).
I'll try fiddling around with logcat later(Its all always good to know how to do things yourself.)
One of the things I noticed about this thread is the lack of activity(posts/veiws) despite its significance(I believe this is due to the lack of traffic in the Ouya section of xda). Im sure a lot of people are interested in this but just haven't had the opportunity to see the thread(Ive been looking for something like this since just after Christmas and only found it just now). This is is useful to more than just people with an Ouya. Anyone running an android device attached to their TV can benefit from this guide(Though the Ouya makes the most sense since it is operated with a gamepad).
So I figured posting links to this thread on the places I was originally looking(Mainly xbmc and advanced launcher related resouses/fourums. I just never thought about looking in a device specific forum despite it being the device I wanted this for in the first place) would help people find this easier.
Click to expand...
Click to collapse
I've been thinking about posting this into a more generic section once the guide is a little more... finished. As yes you are correct, the guide applies to all devices that are plugged into a tv and use xbmc ( very little of the guide has to be changed... only retroarch's IME selection and location of su is about it )
As for RCB I updated the second post so far to include what has to be changed to get it to work on android... the rest of it works similar to Advanced Launcher but I need to fill the rest out for that.
This is an amazing thread and its opened up a whole new world for me and my JXD S7800. I just figured out how to get RCB to launch Android games. It requires using nfo files as ROM files, and the %GAMECMD% param to parse the right info to the command line. GAMECMD can be entered manually within RCB but its easier to put it in the nfo file your going to use as a ROM file and then set one of your scrapers as LocalNFO.
For the file located
Code:
/addons/script.games.rom.collection.browser/resources/lib/dbupdate.py
Replace:
Code:
region = self.resolveParseResult(gamedescription, 'Region')
With:
Code:
gameCmd = self.resolveParseResult(gamedescription, 'GameCmd')
region = self.resolveParseResult(gamedescription, 'Region')
and Replace:
Code:
gameId = self.insertGame(gamename, plot, romCollection.id, publisherId, developerId, reviewerId, yearId,
With:
Code:
gameId = self.insertGame(gamename, plot, gameCmd, romCollection.id, publisherId, developerId, reviewerId, yearId,
and Replace:
Code:
def insertGame(self, gameName, description, romCollectionId, publisherId, developerId, reviewerId, yearId,
With:
Code:
def insertGame(self, gameName, description, gameCmd, romCollectionId, publisherId, developerId, reviewerId, yearId,
and Replace:
Code:
Game(self.gdb).insert((gameName, description, None, None, romCollectionId, publisherId, developerId, reviewerId, yearId,
With:
Code:
Game(self.gdb).insert((gameName, description, gameCmd, None, romCollectionId, publisherId, developerId, reviewerId, yearId,
and Replace:
Code:
Game(self.gdb).update(('name', 'description', 'romCollectionId', 'publisherId', 'developerId', 'reviewerId', 'yearId', 'maxPlayers', 'rating', 'numVotes',
'url', 'region', 'media', 'perspective', 'controllerType', 'originalTitle', 'alternateTitle', 'translatedBy', 'version', 'isFavorite', 'launchCount'),
(gameName, description, romCollectionId, publisherId, developerId, reviewerId, yearId, players, rating, votes, url, region, media, perspective, controller,
originalTitle, alternateTitle, translatedBy, version, int(isFavorite), int(launchCount)),
gameId, allowOverwriteWithNullvalues)
With:
Code:
Game(self.gdb).update(('name', 'description', 'gameCmd', 'romCollectionId', 'publisherId', 'developerId', 'reviewerId', 'yearId', 'maxPlayers', 'rating', 'numVotes',
'url', 'region', 'media', 'perspective', 'controllerType', 'originalTitle', 'alternateTitle', 'translatedBy', 'version', 'isFavorite', 'launchCount'),
(gameName, description, gameCmd, romCollectionId, publisherId, developerId, reviewerId, yearId, players, rating, votes, url, region, media, perspective, controller,
originalTitle, alternateTitle, translatedBy, version, int(isFavorite), int(launchCount)),
gameId, allowOverwriteWithNullvalues)
Then for the file located
Code:
/addons/script.games.rom.collection.browser/resources/scraper/00 - local nfo.xml
Replace:
Code:
<Game>title</Game>
With:
Code:
<Game>title</Game>
<GameCmd>gameCmd</GameCmd>
Now set your "Emulator Cmd" to:
Code:
/system/xbin/su
and your "Emulator Params" to
Code:
-c 'am start -n %GAMECMD%'
and your "Rom Fie Mask" to
Code:
*.nfo
and one of your scrapers need to be set to "local nfo"
Now set the "Rom Path" to any empty folder on your SD card. Then create text files in this folder and change their extensions to nfo. The name of the nfo is not important but inside it you need:
Code:
<game>
<gameCmd>PackageName/ActivityName</gameCmd>
<game>
An example is the following to run Punch Quest
Code:
<game>
<gameCmd>com.noodlecake.punchquest.humble/com.noodlecake.punchquest.punchquest</gameCmd>
<game>
And that's it. This setup has it working for me.
Ignore this post.
I'm having some problems with Mupen64Plus AE. I've used the root command, haven't tried the one with am. I think there's some problems with the parameters, because I've tried running the command in terminal it says that the MainActivity doesn't exist.
I checked Mupen64Plus AE on Github, and it seems like they don't use the MainActivity any longer, but I don't know what command to use instead. Oh, and I'm using an Android stick, not an Ouya, but that shouldn't matter in this case - should it? I'm still using SPMC.
Any help, please?
Cheers
sindrefyrn said:
I'm having some problems with Mupen64Plus AE. I've used the root command, haven't tried the one with am. I think there's some problems with the parameters, because I've tried running the command in terminal it says that the MainActivity doesn't exist.
I checked Mupen64Plus AE on Github, and it seems like they don't use the MainActivity any longer, but I don't know what command to use instead. Oh, and I'm using an Android stick, not an Ouya, but that shouldn't matter in this case - should it? I'm still using SPMC.
Any help, please?
Cheers
Click to expand...
Click to collapse
I'll check it out sometime today... ATM I'm using my ouya for test flashing cm10.2/cm11 builds so I haven't had much time to see if they've changed ( I did find out that retroarch changed and have fixed the args accordingly ).
IncognitoMan said:
I'll check it out sometime today... ATM I'm using my ouya for test flashing cm10.2/cm11 builds so I haven't had much time to see if they've changed ( I did find out that retroarch changed and have fixed the args accordingly ).
Click to expand...
Click to collapse
That's awesome - thanks.
sindrefyrn said:
That's awesome - thanks.
Click to expand...
Click to collapse
I'm guessing you are using the free version from the google play store...
If so then there's a *slight* change to the command... heres the command set for people wanting to use the one on the playstore. ( as of 2.4.4 )
Mupen64Plus AE Free 2.4.4:
non-root: ( will load the emulator menu with the correct rom selected )
start -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
root: ( will first load the emulator with the correct rom and then reload to the play menu to either resume where you last left off on your game or restart the emu so the game is at first boot )
-c 'am start -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%" && am start -S -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.PlayMenuActivity'
-----
*sigh* this is why I wish I would have a more vanilla android device to test this with...
Anyway thanks for the heads up sindrefyrn... if you run across any others that have problems let me know and I'll see about checking it out.
IncognitoMan said:
I'm guessing you are using the free version from the google play store...
If so then there's a *slight* change to the command... heres the command set for people wanting to use the one on the playstore. ( as of 2.4.4 )
Mupen64Plus AE Free 2.4.4:
non-root: ( will load the emulator menu with the correct rom selected )
start -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%"
root: ( will first load the emulator with the correct rom and then reload to the play menu to either resume where you last left off on your game or restart the emu so the game is at first boot )
-c 'am start -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.MainActivity -a android.intent.action.VIEW -eu Uri "file://%rom%" && am start -S -n paulscode.android.mupen64plus.free/paulscode.android.mupen64plusae.PlayMenuActivity'
-----
*sigh* this is why I wish I would have a more vanilla android device to test this with...
Anyway thanks for the heads up sindrefyrn... if you run across any others that have problems let me know and I'll see about checking it out.
Click to expand...
Click to collapse
THANK YOU!!! :laugh:
This is amazing. I'm actually using the paid version, but even I could figure out what to do with the command.
Roms on NFS mount
First I would like to thank you for all of the work that has been put to get things working!!!!
My question is around XMBC and NFS mounts. In XMBC / Rom Collection Browser I am able to map an nfs share to my roms. When I click on a rom to play it comes up to the menu for Snes9x EX+. Is this the expected behavior? I know when I launch Snes9x that it only sees the local file system so I am guessing that is the reason that it does not play the game but wanted to check because of going through XBMC. If that is the case is there a way to mount an nfs mount to the system when the system is rooted ?
Thank you
Techhead33 said:
First I would like to thank you for all of the work that has been put to get things working!!!!
My question is around XMBC and NFS mounts. In XMBC / Rom Collection Browser I am able to map an nfs share to my roms. When I click on a rom to play it comes up to the menu for Snes9x EX+. Is this the expected behavior? I know when I launch Snes9x that it only sees the local file system so I am guessing that is the reason that it does not play the game but wanted to check because of going through XBMC. If that is the case is there a way to mount an nfs mount to the system when the system is rooted ?
Thank you
Click to expand...
Click to collapse
Should work as long as the command is passed correctly... sounds like its not finding the rom...
could you tell me where you are pointing your the roms folder? ( maybe paste the config for snes? )
Related
Hello all,
Just got my first android phone. I need to port a tiny C application I have to my phone. It worked when I compiled a static binary but now I'm trying to compile a dynamic one, but before that, I'm trying to run a native hello world on it but not having much luck. When I run it on the emulator, it prints "Hello world" and then segfaults after that. When I run it on the phone, it doesn't even get that far. It says link_image[1995] CANNOT LINK EXECUTABLE.
These are my test files
test.c
Code:
#include <stdio.h>
int main (int argc, char *argv[])
{
printf ("Hello world!\n");
return 0;
}
Makefile
Code:
APP := test
ROOT:=$(HOME)/Projects/Android
NDK_PLATFORM_VER := 8
INSTALL_DIR := /data/tmp
ANDROID_NDK_ROOT:=$(ROOT)/android-ndk-r5b
ANDROID_NDK_HOST:=linux-x86
ANDROID_SDK_ROOT:=$(ROOT)/android-sdk-linux_x86
PREBUILD:=$(ANDROID_NDK_ROOT)/toolchains/arm-eabi-4.4.0/prebuilt/$(ANDROID_NDK_HOST)
BIN := $(PREBUILD)/bin
CPP := $(BIN)/arm-eabi-g++
CC := $(BIN)/arm-eabi-gcc
CFLAGS := -I$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/include -fno-short-enums
LDFLAGS := -Wl,--entry=main,-rpath-link=$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib,-dynamic-linker=/system/bin/linker -L$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib
LDFLAGS += -nostdlib -lc -disable-multilib
all: $(APP)
OBJS += $(APP).o
$(APP): $(OBJS)
$(CPP) $(LDFLAGS) -o [email protected] $^
%.o: %.c
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o [email protected]
install: $(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb push $(APP) $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell chmod 777 $(INSTALL_DIR)/$(APP)
shell:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell
run:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell $(INSTALL_DIR)/$(APP)
r: $(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb push $(APP) $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell chmod 777 $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell $(INSTALL_DIR)/$(APP)
clean:
@echo "Cleaning up..."
rm -f $(APP).o $(APP)
Output:
Code:
[[email protected] app]$ make run
/home/hacker/Projects/Android/android-sdk-linux_x86/platform-tools/adb shell /data/tmp/test
Hello world!
[1] Segmentation fault /data/tmp/test
[[email protected] app]$
Output (on the phone):
Code:
# /data/local/test
link_image[1995]: failed to link /data/local/test
CANNOT LINK EXECUTABLE
#
What am I doing wrong?
I've never been successful with dynamic executables using a plain Makefile. I've always had to use the JNI approach with an appropriate Android.mk configuration. To do this, make an empty directory for your project. Within this directory, make a dir called "jni" and cd to it and copy your "hello.c" source file there. Add an Andriod.mk file that looks like this:
Code:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello
LOCAL_SRC_FILES := hello.c
include $(BUILD_EXECUTABLE)
Then, with the ndk path set appropriately (ie, on my system):
Code:
export PATH=${PATH}:/usr/src/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/
just run the ndk-build script (again, modify to point to your ndk installation):
Code:
/usr/src/android-ndk-r4b/ndk-build
This will produce two additional directories in the dir above "jni": "obj" and "libs". In the libs/armeabi/ dir, you'll find your (non-stripped) executable.
Just curious, where'd you get the Makefile? It looks like it should work, but I can't really see where it is getting it's libc.so.
I got the Makefile from http://betelco.blogspot.com/2010/01/buildingdebugging-android-native-c.html
It's for Cygwin so I made a few changes. The last comment says I should link it against crtend_android.o to prevent the segfaults but that didn't work for me. Maybe I did something wrong. I'm not really a C programmer and the only experience I have is with writing extremely basic apps so, honestly, I don't know much about linking but I'm trying to let that not discourage me from trying. It usually takes me days to get something simple done but it feels great once I manage to get my app to work.
I'll try your approach in a few hours and post back.
Oh, and I thought I should mention my phone is running Froyo at the moment.
Since I'm completely new to writing code on the phone, I thought I should ask if it is a bad idea to push the app to the phone and run it directly or should I really be using the emulator instead (since I'm not an experienced programmer)? I've got a very old PC and the emulator is slow as hell on it so it'll be great if i can avoid that.
I visited that site and read over their comments and modified the makefile at the end to match my system (gentoo linux) and it works fine on my phone (HTC Inspire 4G). I didn't do the "make run" thing, but just "make" and then pushed it to my phone manually and ran it from an adb shell. Worked fine. I'm using the r4b plaform ndk so that might be something. I'll D/L the r5b ndk and check it out.
I tried what you suggested and it works perfectly. Thanks!
Gene Poole said:
I visited that site and read over their comments and modified the makefile at the end to match my system (gentoo linux) and it works fine on my phone (HTC Inspire 4G). I didn't do the "make run" thing, but just "make" and then pushed it to my phone manually and ran it from an adb shell. Worked fine. I'm using the r4b plaform ndk so that might be something. I'll D/L the r5b ndk and check it out.
Click to expand...
Click to collapse
I still do have a segmentation fault... I stated all what I did here :
http://stackoverflow.com/questions/20936770/android-command-line-executable
Any good idea would be appreciated !
Thx
Some of you have replacement Settings.apk that allow more options.
If you still have the stock Settings.apk you can access some interesting ones.
Just run one of the following commands in the ADB shell.
Code:
am start -n com.android.settings/.AppWidgetPickActivity
am start -n com.android.settings/.BandMode
am start -n com.android.settings/.battery_history.BatteryHistory
am start -n com.android.settings/.BatteryInfo
am start -n com.android.settings/.ChooseLockPin
am start -n com.android.settings/.ChooseLockPinExample
am start -n com.android.settings/.ChooseLockPinTutorial
am start -n com.android.settings/.ConfirmLockPin
am start -n com.android.settings/.DebugIntentSender
am start -n com.android.settings/.DevelopmentSettings
am start -n com.android.settings/.deviceinfo.Memory
am start -n com.android.settings/.Display
am start -n com.android.settings/.fuelgauge.PowerUsageDetail
am start -n com.android.settings/.fuelgauge.PowerUsageSummary
am start -n com.android.settings/.InstalledAppDetails
am start -n com.android.settings/.LauncherAppWidgetBinder
am start -n com.android.settings/.ManageApplications
am start -n com.android.settings/.MasterClear
am start -n com.android.settings/.MediaFormat
am start -n com.android.settings/.ProxySelector
am start -n com.android.settings/.RadioInfo
am start -n com.android.settings/.RunningServices
am start -n com.android.settings/.SdCardSettings
am start -n com.android.settings/.Settings_About
am start -n com.android.settings/.Settings_DateTime
am start -n com.android.settings/.Settings_Legal
am start -n com.android.settings/.Settings_Quick
am start -n com.android.settings/.Settings_Reset
am start -n com.android.settings/.Settings_Root
am start -n com.android.settings/.Settings_Screen
am start -n com.android.settings/.Settings_Sdcard
am start -n com.android.settings/.Settings_System
am start -n com.android.settings/.Settings_TimeZone_Oobe
am start -n com.android.settings/.Settings_TimeZone_Settings
am start -n com.android.settings/.TestingSettings
am start -n com.android.settings/.UsageStats
am start -n com.android.settings/.widget.WidgetTest
am start -n com.android.settings/.wifi.Settings_Wifi_Dialog
am start -n com.android.settings/.wifi.Settings_Wifi_Oobe
am start -n com.android.settings/.wifi.Settings_Wifi_Settings
am start -n com.android.settings/.wifi.WifiRedirectLogin
Some of these may not even be directly accessible in the replacement Settings.apk
ProxySelector might be useful for somebody.
ChooseLockPin works.
can LockPin be disabled?
It seems to me that since I've set up a lockpin the battery is draining much faster (it might be something else causing it though),
do you know how to disable it? I couldn't find anything.
I haven't looked into this (or even tried proxy).
The best way would be to use the Android stock settings.apk.
Proxy is (I don't know) under advanced WiFi settings.
If not, you could modifiy settings.apk
The only problem being is that you would have to sign it with the system signature.
But of course you have already resigned your entire system with your own signature?
You could write a very simple app to send an intent.
Renate NST,
I have to agree that stock settings.apk is rough .
And where I can find modfied settings apk?
AFAIK using adb on NTS (I have back-white, not colour) requires PC box and isn't very convenient...
Could you add some short description to your open post what each commad do?
Happy New Year BTW
jkjacek said:
And where I can find modfied settings apk?
Click to expand...
Click to collapse
Oops, sorry I missed this.
I use the Settings.apk and SettingsProvider.apk out of the Android SDK emulator.
The problem with this is that you have to resign it with the system signature.
That means you have to resign your whole system.
I looked a bit into the structure of Settings.apk.
You could change the structure of the top level menus in the B&N versions but that would require resigning anyway.
Just a short shellscript I find useful from times to times (xpost from my blog):
Code:
#!/bin/bash
# Get the clipboard contents and trim it
url=`xclip -o | xargs`
# Don't bother with anything that doesn't start with http
[[ $url = *http* ]] && {
# If we are reasonably sure we have a url, push it to the device
adb shell am start -a android.intent.action.VIEW -d $url
}
Ha, great! That's actually quicker than using Pusbullet from the browser. Not it only needs device to device support
The Clarity Ensemble phone is an Android-based captioning land-line phone. The newest model has an 8" touchscreen. Older model has 7" touchscreen. It comes with an app that runs at startup and keeps you from gaining access to the Android home screen or any other Android apps or settings. While booting up you momentarily see the time and can pull down to touch on Settings and bring up the regular Android settings but very soon as the boot process continues the splash screen and later the ThorB app will take over the screen.
In order to telnet to the device, you first need to start telnetd running on the Ensemble. This can be done by configuring your computer to appear to the Ensemble to be the update server. I directly connected the phone to a laptop Ethernet port. On the laptop, I installed a DHCP server, a DNS server, and a web server. I am running Windows and I used "DHCP Server for Windows" version 2.5.1, ApateDNS, and WWebserver with PHP 5.4.45. I set the laptop to a static IP of 8.8.4.4 since Wireshark revealed that the Ensemble was using that as the DNS server. I set ApateDNS server to return 8.8.4.4 as the IP address for all queries.
In my htdocs folder, I created a directory called thorbfota and inside that a directory called purple_prod. Inside purple_prod I created three files, download_file.php, query_site.php, and query_versions.php.
Code:
<?php
//download_file.php
ignore_user_abort(true);
set_time_limit(0);
//Replace with actual path to your files
$path = "C:/Users/User/Documents/ClarityEnsembleFiles/";
$dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\).]|[\.]{2,})", '', $_GET['filename']);
$dl_file = filter_var($dl_file, FILTER_SANITIZE_URL);
$fullPath = $path.$dl_file;
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\"");
break;
case "bin":
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\"");
break;
case "zip":
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\"");
break;
case "apk":
header("Content-type: application/vnd.android.package-archive");
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\"");
break;
//Add more headers for other content types here
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
break;
}
header("Content-length: $fsize");
header("Cache-control: private");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
Code:
<?php
//query_site.php
//This forum would not allow me to post links since this is my first post.
//Feel free to move the "h" below right up against the "ttp..."
echo "h" . "ttp://clarityengineering.us/thorbfota/purple_prod/";
?>
Code:
<?php
//query_versions.php
//Replace with actual path to your files
$path = "C:/Users/User/Documents/ClarityEnsembleFiles/";
//Replace file versions with your current version numbers
//To cause phone to update a file, use a number larger that the current version
$file = "ThorB.apk";
$file_ver = "2.63";
$fullPath = $path.$file;
echo $file . "=" . $file_ver . "," . strtoupper(md5_file($fullPath)) . "|\r";
$file = "thorb-ota.zip";
$file_ver = "20150305.182516";
$fullPath = $path.$file;
echo $file . "=" . $file_ver . "," . strtoupper(md5_file($fullPath)) . "|\r";
$file = "dcx.bin";
$file_ver = "b033";
$fullPath = $path.$file;
echo $file . "=" . $file_ver . "," . strtoupper(md5_file($fullPath)) . "|\r";
$file = "eep.bin";
$file_ver = "be25";
$fullPath = $path.$file;
echo $file . "=" . $file_ver . "," . strtoupper(md5_file($fullPath)) . "|\n";
echo "survey=0,0|";
?>
I found that eep.bin was actually just a shell script that is downloaded to the device and run as root. I put my update files in "C:\Users\User\Documents\ClarityEnsembleFiles" but you can put them anywhere you like, just make sure to update the php files above to reflect their location. So far I have only used eep.bin but to keep my php script happy I also created placeholder files, dcx.bin, thorb-ota.zip, and ThorB.apk and placed them with eep.bin in my ClarityEnsembleFiles folder. Below is my eep.bin that starts telnet and simulates pressing the Home button. Just touch "Home Sample" when the "Complete action using" window pops up on the Ensemble. The semicolon at the end of the line avoids having the carriage return kill the command. Alternatively, you could run dos2unix on the eep.bin file and not need the semicolon at the line end.
Code:
#eep.bin
telnetd -l /system/bin/sh;am start -a android.intent.action.MAIN -c android.intent.category.HOME;
Every time you change the eep.bin file and want to run it on the phone make sure to close the Software upgrade screen and touch "Check now" button and then "Upgrade" button.
To install apps on the phone, first download the apk file to the phone with wget and then run "pm install -r YourApp.apk".
I have not found a physical Home, Back or Menu button on the phone so one of the first things you may want to install is a software solution for those. I installed "To Home" and it didn't work when configured with the root option for "Floating Buttons". It works fine when configured with the non-root option for "Floating Buttons". I have not tried any of the several other soft button apps available.
There is a 14 pin connector on the underside of the phone that presumably is used in the factory to connect to a dock for programming. I have not investigated the function of any of the pins but I suspect USB is there as well as possibly serial port(s) and maybe JTAG.
Before connecting the phone to the internet, you probably will want to either disable/uninstall the ThorB.apk app or create a firewall on the phone or on your router to keep it from being able to automatically update and from being able to report back to it's maker.
Besides being available for purchase, the phone is also available from ClearCaptions at no charge if you provide them with a 3rd party certification of being hard of hearing.
As far as using the phone, "Federal law prohibits anyone but registered users with hearing loss from using this device with the captions on." So if your hearing it fine, make sure to turn captions off or don't turn them on.
Telnet is great but I wanted a more secure connection to the phone so I set up an Android cross-compiler and compiled the latest version of dropbear (dropbear-2016.73). I don't have a 64-bit computer so in order to use the latest version of the Android toolchain, I had to boot into Windows and install Cygwin.
Thanks to serasihay for patches to an earlier version of dropbear. I adapted them to work with the latest version of dropbear. The patch can be found by searching dropbear-2016.73-android-20160427.patch on pastebin. Most of the warnings generated during compile were from pre-patched dropbear code and can be viewed on pastebin by searching for "Compile warnings for compiling dropbear-2016.73.android"
After setting up the toolchain, dropbear can be compiled with the following commands:
Code:
tar jxf dropbear-2016.73.tar.bz2
cd dropbear-2016.73
patch -p1 < /path/to/patch/dropbear-2016.73-android-20160426.patch
./configure --build=x86-windows --host=arm-linux-androideabi --disable-zlib --disable-largefile --disable-loginfunc --disable-shadow --disable-utmp --disable-utmpx --disable-wtmp --disable-wtmpx --disable-pututline --disable-pututxline --disable-lastlog
make MULTI=1 SCPPROGRESS=1 PROGRAMS="dropbear dropbearkey scp dbclient"
arm-linux-androideabi-strip.exe dropbearmulti
This generates a single binary file, dropbearmulti which you will want to copy to the phone to /system/xbin/dropbearmulti. Next, you will want to create symbolic links like this:
Code:
cd /system/xbin
ln -s dropbearmulti dbclient
ln -s dropbearmulti dropbear
ln -s dropbearmulti dropbearkey
ln -s dropbearmulti scp
I should probably redo the patch to enable the -R option to create the host keys but for now you can do it with:
Code:
mkdir /etc/dropbear
dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key
dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
To start dropbear every time the phone boots, I put my startup command in /system/etc/install-recovery.sh since it is called by init.rc. I would have put it straight in init.rc but init.rc is recreated from boot.img every boot and I didn't feel like getting into changing boot.img yet. Just make sure to make install-recovery.sh executable. The following line is what I use to start dropbear:
Code:
dropbear -A -N root -R /data/.ssh/authorized_keys -U 0 -G 0
Next you will need to copy your public key(s) into /data/.ssh/authorized_keys. You should now be able to ssh to your Clarity Ensemble phone. You can also use scp to copy files to and from the phone. If you use Putty pscp to transfer files, make sure to use the -scp option to force SCP protocol. If not, you will get the error "/usr/libexec/sftp-server: not found" since pscp tries to use sftp which is not installed on the phone.
So can you post a video or pics of what the device screen looks like now? can you actually use the device as a tablet?
Hey guys, I've just decided to get inside of the Android development world. Anyways, I'm mostly a fan of Linux, so I've made my first Linux script, I know it's simple, but I've never interacted with the user before, or picked an output. When I knew that Android made use of Linux in its core, my interest on working inside it grew up faster than ever.
In my script, firstly, you type the filename. For compatibility reasons, it'll everytime save to /sdcard/filename. Then, it will ask you how many times you want the script to log everything, and lately, every how many seconds should it save everything to the file.
The script will save, before every entry at the log, the screen status (if it's on or off), that can help to, for example, if your device has been lagging as a result of a bad screen driver or UI error.
Last thnig: it also works on recovery (maybe it give some error, and if no dumpsys is present on your recovery's ramdisk, it'll save everything as OFF).
Remember to send it anywhere excepting from /storage and any sbudir, it won't work as the Android permissions system blocks script execution on those dirs.
Code:
clear
# Wipe $logfile content in /sdcard (if any existing)
echo "Please type the filename where you want to save the log: "
read -r logfile
echo "" > /sdcard/$logfile
echo "Deleted previous log."
echo "SCREEN | CPU" >> /sdcard/$logfile
#cont=60
cont=1
#SHOWLOG=X
echo "Please type how many times the cycle must repeat: "
read -r maxcont
echo "Please type how many seconds will the interval take: "
read -r maxmin
clear
# Here it counts how many times the logging script has been ran
while [ $cont -lt $((maxcont + 1)) ];
do
# That nested while takes control of how many seconds have passed in the current cycle
while [ "$contmin" -lt "$maxmin" ];
do
contmin=$((contmin + 1))
sleep 1
clear
echo "C: $cont/$maxcont - T: $contmin/$maxmin"
done
# echo "$maxmin seconds passed."
# Logs the fist line of "busybox top" to a var
LOGVAR=$(busybox top -d 1 -n 1 | grep "idle")
# Logs the screen state (on or off) to another var
SCREENSTATE=$(dumpsys input_method | grep mScreenOn | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]')
# Saves a string that tells what it should expect if the screen is on
SCREENSTATEON="msystemreadytruemscreenontrue"
if [ "$SCREENSTATE" == "$SCREENSTATEON" ]
then
echo "ON: $LOGVAR" >> /sdcard/$logfile
else
echo "OFF: $LOGVAR" >> /sdcard/$logfile
fi
cont=$((cont + 1))
contmin=0
done
echo "Show logged values? [Y/N]"
read -r SHOWLOG
case $SHOWLOG in
[yY] | [yY][Ee][Ss] )
cat /sdcard/$logfile
;;
[nN] | [n|N][O|o] )
echo "Ok, goodbye. You'll see a what you've asked me to log in /sdcard/$logfile";
exit 1
;;
*) echo "You must write Y or N to continue."
;;
esac
exit 0
For example, save it as script.sh (remember to save it using Unix codifcation, if you're running Windows, else, it'll tell you that it's unable to find many binaries, as long as Linux isn't ok with CR+LF and requires LF as newline). Then, send it to the sdcard (over USB or adb push script.sh /sdcard/) , now, run ADB shell. Type the following commands:
Code:
su -c "cp -f /sdcard/script.sh /data/local/;chmod 777 /data/local/script.sh"
Then, if you want to run it:
Code:
su
sh /data/local/script.sh
That's all, I hope you enjoy it and not so many people kills me for explaining and feeling so grateful for that simple script.