Play sound file from application floder - Windows Mobile Software Development

I have this code to play .wav file when button is pressed:
(I am using MS Visual Studio 2008, C#, WM5 Pocket PC SDK, NET CF 3.5)
Code:
private void button1_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = "/M1.wav";
myPlayer.Play();
}
Problem - It will play this sound file only if it is located in root of my deviece.
Question - How can I make it play from my application folder?

Use this to get the application folder...
Code:
string folder = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).DirectoryName;
and then use...
Code:
myPlayer.SoundLocation = folder + "\M1.wav";
Hope this helps

Thanks! This worked.
Code:
string folder = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).DirectoryName;
Now i have another question - how can I play music in background when I press button and how can i turn it of by pressing button? I did some search, but i could not find anything about it.

Google is your friend, mate.
A quick search turned this up for me...
http://www.developerfusion.com/forum/thread/41606/
I've not tried it, but it has start and stop methods, so it looks spot on.
Good luck
Edit:
Here's another one that may help...
http://www.davidjsushil.com/tutorials/winapisounds.pdf

Thanks again!
Everything works like it should expect one more thing -
I have 3 Forms and when I switch between them, they all stays opened?
What do I have to do to make them close when I switch between them?
Thanks again.

Podkasts said:
Thanks again!
Everything works like it should expect one more thing -
I have 3 Forms and when I switch between them, they all stays opened?
What do I have to do to make them close when I switch between them?
Thanks again.
Click to expand...
Click to collapse
Just do a close on the form that is opening the next one...
Code:
form2.Show();
form1.Close();
(obviously, they're example names - change them to suit).
Closing the forms may not be the right thing to do though - it obviously depends what you're doing with them.

I had already tried that and it gives this error:
Code:
error CS0103: The name 'form1' does not exist in the current context
(Yes, form name is "form1")

Podkasts said:
I had already tried that and it gives this error:
Code:
error CS0103: The name 'form1' does not exist in the current context
(Yes, form name is "form1")
Click to expand...
Click to collapse
Sorry... you can't do that because form1 doesn't know it's called form1. My bad.
Use this instead...
Code:
this.Close();
Hope that helps mate.

johncmolyneux said:
Use this to get the application folder...
Code:
string folder = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).DirectoryName;
and then use...
Code:
myPlayer.SoundLocation = folder + "\M1.wav";
Hope this helps
Click to expand...
Click to collapse
Hi. Do you know about similar code for embedded C++?
I am actually using this:
PlaySound (TEXT("\\APPLICATION DATA\\MYAPP\\MYSOUND.WAV"), NULL, SND_ASYNC | SND_LOOP);

Related

Opera Mobile

Hi all
I have a couple of problems with Opera Mobile and I was wondering whether anybody knows a solution. Firstly I can't seem to enable Opera to open more than two tabs at a time, which I find annoying. Secondly, does anybody know how to enable flash from websites within Opera? I did notice that this question had been asked before but that there wasn't an answer. I've installed the Flash 3.1 which was taken from a 207XX build of WM6.1. Should I install the official Flash Lite 3.1 Distributable instead? I understood that this was a stand alone player.
Despite my signature I'm using the HTC TP2 with a stock WWE ROM from HTC Europe.
Cheers
andrew-in-woking
Opera Mobile 9.7 open beta should be out tomorrow (Monday).
If you can, please install it and let us know how tabs & flash work?
I think that's just a rumour. No official confirmation.
________________________________________
Check out my in-depth review of HTC's Touch Pro2
http://www.youtube.com/watch?v=VgTjSbpFDhQ&feature=channel_page
To change the number of tabs
From within opera go to
opera:config
select User Prefs
Maximum Tabs - choose your preference
Then scroll down to "Save"
Hope that helps.
to watch flash vids with opera(embedded videos) you need to add text string to axobjects.ini(axobjects). i have done it and it works. you need to go to app data,opera9 and use a text editor and enter this string of text:
go here in file explorer - \Application Data\Opera\axobjects.ini to support flash
CODE:
[Shockwave Flash]
Allow=Url|Embed|Object|Scripts
thedudelasse said:
I think that's just a rumour. No official confirmation.
Click to expand...
Click to collapse
No rumor.
The beta 1 is out *now*.
Start downloading and reviewing, Lasse!
http://www.opera.com/mobile/download/
shingers5 said:
to watch flash vids with opera(embedded videos) you need to add text string to axobjects.ini(axobjects). i have done it and it works. you need to go to app data,opera9 and use a text editor and enter this string of text:
go here in file explorer - \Application Data\Opera\axobjects.ini to support flash
CODE:
[Shockwave Flash]
Allow=Url|Embed|Object|Scripts
Click to expand...
Click to collapse
Hi shingers5
Unfortunately this didn't work for me.
Thanks
andrew-in-woking
Thanks but done that already!
jmak said:
To change the number of tabs
From within opera go to
opera:config
select User Prefs
Maximum Tabs - choose your preference
Then scroll down to "Save"
Hope that helps.
Click to expand...
Click to collapse
Hi jmak
Thanks for that. Unfortunately it keeps reverting to 2 tabs max on restart of the application.
Cheers
andrew-in-woking
There is a dedicated thread n general section
"Opera mobile all versions thread"
andrew-in-woking said:
Hi shingers5
Unfortunately this didn't work for me.
Thanks
andrew-in-woking
Click to expand...
Click to collapse
hmmmmmmmmm very strange as it works with all versions of opera. what text editor did you use. you need to go to app data-opera9 and edit file axobjects with a text editor. enter the text string for shockwave player as is. i usually put it in the middle of all the text. also have you installed dvhaflashlite 3.1 as that one works best
andrew-in-woking said:
Hi jmak
Thanks for that. Unfortunately it keeps reverting to 2 tabs max on restart of the application.
Cheers
andrew-in-woking
Click to expand...
Click to collapse
Yes, I found this; it would keep ignoring the setting, or reset it. Eventually my TP2 decided that it would use more tabs, after a few restarts and device resets where I doggedly kept changing the tabs up to 5. Very odd, but persist with it. I had to do this twice (once after a hard reset), it was a struggle each time, and I still have no idea why it eventually fell in line.
ianjd said:
Yes, I found this; it would keep ignoring the setting, or reset it. Eventually my TP2 decided that it would use more tabs, after a few restarts and device resets where I doggedly kept changing the tabs up to 5. Very odd, but persist with it. I had to do this twice (once after a hard reset), it was a struggle each time, and I still have no idea why it eventually fell in line.
Click to expand...
Click to collapse
Hi ianjd
I found that the answer was to manually edit the opera.ini file in:
\Windows\Opera9\
Find the bit with Max Allowed Tabs.
Cheers
andrew-in-woking
Ah, thanks; that'll be useful the next time disaster strikes!
shingers5 said:
hmmmmmmmmm very strange as it works with all versions of opera. what text editor did you use. you need to go to app data-opera9 and edit file axobjects with a text editor. enter the text string for shockwave player as is. i usually put it in the middle of all the text. also have you installed dvhaflashlite 3.1 as that one works best
Click to expand...
Click to collapse
Didn't work for me either
shingers5 said:
to watch flash vids with opera(embedded videos) you need to add text string to axobjects.ini(axobjects). i have done it and it works. you need to go to app data,opera9 and use a text editor and enter this string of text:
go here in file explorer - \Application Data\Opera\axobjects.ini to support flash
CODE:
[Shockwave Flash]
Allow=Url|Embed|Object|Scripts
Click to expand...
Click to collapse
hey guys, my axobjects.ini seem to be placed in the windows folder: windows/opera/axobjects.ini
added this line via texteditor on the computer and replaced the modified ini onto the phone
couldn't get it working
anyone else have this trouble?
p.s. using Dvha79 AdobeFlash3.1 plugin

[App][WM6.5] CHome Visual Editor - compatible with all kinds of CPR

[31/08/2009] New release is avaliable, you can download the new verison from: http://cve.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32228
CHome Visual Editor is a visual CPR editor for Windows Mobile 6.5.
** You need install .net 3.5 sp1 in your computer in order to run CVE. **
With CVE, you can edit:
Titanium
LS_AlarmScene
LS_LockScene
LS_PhoneAlertScene
LS_PhoneCallScene
LS_SimplePinScene
StartMenu_GridScene
For this release, you can:
Open CPR file visually and move elements visually.
Modify all properties of the selected element by the property grid on the right side.
Change & Save (auto) the screen resolution.
Change & Save (auto) the scale rate.
Undo/Redo
Setup folder mapping between PPC and your OS.
Import registry file to load the element values (text, image source)
Save the modification.
More functions not listed.
This release only provide two language resource. The embedded language is Chinese, en-US is provided. If your OS language is not en-US, you may need to open configuration.xml and add one line to display en-US:
<language>en-us</language>
or you will get Chinese character.
wow.. looks like very good application
downloading & trying it now!!!!
Looks good indeed! Just downloaded but I can't try it now...
Got some problem here, I can't open any .cpr file to edit???
morningmoon said:
Got some problem here, I can't open any .cpr file to edit???
Click to expand...
Click to collapse
do you mean the application crash when you open *.cpr? can you upload error.log file here under CVE folder? it's all about the exceptions, none private will recorded in this file.
<?xml version="1.0"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<scale>1</scale>
<language>en-us</language>
<resolution>
<Width>240</Width>
<Height>320</Height>
</resolution>
<directory name="\Windows">
<mapping>Windows</mapping>
<mapping>E:\WindowsMobile\i780_21501_Kitchen\SYS\Lockscreen_DPI_96</mapping>
</directory>
<directory name="\Program Files">
<mapping>Program Files</mapping>
</directory>
</configuration>
Click to expand...
Click to collapse
Placed the language line in like above. But still no English.
Is there some thing we need to do more.
ebsbow said:
Placed the language line in like above. But still no English.
Is there some thing we need to do more.
Click to expand...
Click to collapse
This is strange, i copied your configuration and tested it in my comupoter, it works fine.
If you opened CVE and close it normally (the configuration will be saved again while cloing), the configuration should not not looks like your posted. the lanuguage should be the first element of configuration node. It may caused by path you placed CVE or permission issue.
JerryJiang said:
do you mean the application crash when you open *.cpr? can you upload error.log file here under CVE folder? it's all about the exceptions, none private will recorded in this file.
Click to expand...
Click to collapse
No. not crash, just can't get the Open File box to display, so I can't choose any file to open???
morningmoon said:
No. not crash, just can't get the Open File box to display, so I can't choose any file to open???
Click to expand...
Click to collapse
I never wrap the open file dialog. The open file dialog i am using is system provided, do you have any other WPF application in your computer that with a open file feature, if so, can you tested it whether it works fine?
error
Opening any CPR file the application is crashing. I am uploading the error log file. Please look and give a resolution.
Copied the "<language>en-us</language>" just below the configuration tag. But the problem is still the same.
All is in Chinees. is there anything else I need to check?
I have added the last error log.
ajeshm said:
Opening any CPR file the application is crashing. I am uploading the error log file. Please look and give a resolution.
Click to expand...
Click to collapse
The exception is caused by some color string of TextStage element in your CPR file, normally, i define the color in CPR file use the #FFxxxxxx pattern.
it seems that the color definition between WM and WPF have inconsistent rules. So can you look through the CPR file and try to find out whether there is any color definition in <TextStage/> section is not follow the rule?
I will update my code to fix the problem if you can kindlly post the inconsistant rule. Thx.
ebsbow said:
Copied the "<language>en-us</language>" just below the configuration tag. But the problem is still the same.
All is in Chinees. is there anything else I need to check?
I have added the last error log.
Click to expand...
Click to collapse
<?xml version="1.0"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<language>en-US</language>
<enable_effect>true</enable_effect>
<scale>1</scale>
<resolution>
<Width>240</Width>
<Height>320</Height>
</resolution>
<directory name="\Windows">
<mapping>Windows</mapping>
</directory>
<directory name="\Program Files">
<mapping>Program Files</mapping>
</directory>
</configuration>
karim_31 said:
<?xml version="1.0"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<language>en-US</language>
<enable_effect>true</enable_effect>
<scale>1</scale>
<resolution>
<Width>240</Width>
<Height>320</Height>
</resolution>
<directory name="\Windows">
<mapping>Windows</mapping>
</directory>
<directory name="\Program Files">
<mapping>Program Files</mapping>
</directory>
</configuration>
Click to expand...
Click to collapse
Thanks for posting your configuration. I should update my build package to include the language element instead of let the users update the xml by themselves.
ebsbow said:
Copied the "<language>en-us</language>" just below the configuration tag. But the problem is still the same.
All is in Chinees. is there anything else I need to check?
I have added the last error log.
Click to expand...
Click to collapse
Could you please try again with karim_31's configuration?
Unfortunately I don't have one. Still can't use this application
Any suggestion? What do I need to install for the open file to work?
Thanks!
JerryJiang said:
I never wrap the open file dialog. The open file dialog i am using is system provided, do you have any other WPF application in your computer that with a open file feature, if so, can you tested it whether it works fine?
Click to expand...
Click to collapse
The language works now,
Thanks, but the app seems to crash a lot when loading an cpr.
Disabling effects helps, but the apps crashes on other actions as well.
ebsbow said:
The language works now,
Thanks, but the app seems to crash a lot when loading an cpr.
Disabling effects helps, but the apps crashes on other actions as well.
Click to expand...
Click to collapse
Can you upload your error.log so that i can do some analysis to improve the quality of the application.
Sure. Here you go.
ebsbow said:
Sure. Here you go.
Click to expand...
Click to collapse
It's caused by color token:
http://forum.xda-developers.com/showpost.php?p=3952898&postcount=12
i will add more check of the token, by unless i get the inconsistant token, the color may not display correctly.
I cant even launch it
No error log... so where do i need to install all the files? it simply says that the app fails... thats all!
what im a doing wrong?
I set all in C:\ and the stwater added to windows directory

[HACK] Customizing Bada OS

Hi all, using TkFileExplorer 2.4 you can see and edit Bada system files, in this thread I will report all usefull changes I will find and you could perform using this tool
If you find something other, you might write it here so we have all them collected in the same place
How to use TkFileExplorer:
-Connect your wave to PC with usb cable;
-Select USB Debug connection;
-Start TkFileExplorer and clic Connect;
-if the program fails to connect, try changing the COM port number in Settings;
-Make a backup of the files you change;
-...and try at your own risk!
Changing default browser brightness:
File: Phone:/Settings/Default/Registry/BrowserSettings.ini
Customize power on/off screen:
for configuration:
File: Phone:/Settings/Default/Registry/PowerOnOff.ini
for resources:
Directory: Phone:/SystemFS/PowerOnOff/
Change volume presets for calls, audio player, fm radio, video player, ringtone...:
File: Phone:/SystemFS/Driver/volpresets.xml
Cleaning themes preview images:
Simply clean the files in:
Directory: Phone:/User/Mass/Theme/Default/
Change camera settings:
File: Phone:/Settings/Default/Registry/CamSetting.ini
File: Phone:/SystemFS/Driver/CameraCaps/DevCamDeviceCapsNConfig_Primary.xml [only Bada 1.2]
Change Samsung LBS settings:
File: Phone:/Settings/Default/Registry/LbsConfig.ini
for using external bluetooth gps antenna, change BtGPS=1 (not tested yet) in:
File: Phone:/Settings/Default/Registry/LbsAppRegistry.ini
Usefull directories:
Internal user storage: Phone:/Media
MicroSD storage: Phone:/Mount/Mmc
Preinstalled apps: Phone:/Osp/Application/
Hey thanks a lot for the heads up! I just had a question... Can we really change the intro animation..? I mean completely replace it..? Or is that not possible??
Reply soon....
Hi all, I find the file /User/OspSys/LifeLog/Database/lifelog.db.
It's SQLite (view by sqlitebrowser.sourceforge.net )
There are many information, calls, deleted messages (but only 100 chars).
I hope, it's information isn't send anywhere, because my wave is trying to connect once a day (it's maybe one of the widget)
sonalswaroop said:
Hey thanks a lot for the heads up! I just had a question... Can we really change the intro animation..? I mean completely replace it..? Or is that not possible??
Reply soon....
Click to expand...
Click to collapse
hi, today I just gave a quick look to all files, but I think it's possible, in PowerOnOff.ini there are clear bindings to two .swf files and a startup / shutdown .wav sound contained in the resource path Phone:/SystemFS/PowerOnOff not sure, need to watch those files, I'll verify in next days..
guari said:
Change volume presets for calls, audio player, fm radio, video player, ringtone...:
File: Phone:/SystemFS/Driver/volpresets.xml
Click to expand...
Click to collapse
Yes, you can change this too in Trix but in fact nothing change. Exp. you can't change "volume level" (exp. in MediaPlayer there is limit to 14 steps, if you change that to 15 steps and add one more <spklevel> and <earlevel>-so that there will be 15 steps, but nothing change in Wave, you can still able go to max. 14 steps in MediaPlayer) and you can't change that may mp3 playing miusic lauder as well as playing video, even if you copy and paste settings from VideoPlayer to MediaPlayer (only test that on speaker not on headphones).
In Registry\MainMenu_reg.ini you can remove any icons from the main menu (except SamsungApps). The file format is clear, I will note only that the system items will have MenuType=0, custom user applications - MenuType=1, SamsungApps - MenuType=2.
And, of course, make a backup before any manipulations with MainMenu_reg.ini
to be clear
adfree had made all those expermintes before & we already know these things
if there is something new please post it
Is there a file in registry where are the settings for the screen lock?Or other display related settings?
azcv said:
Is there a file in registry where are the settings for the screen lock?Or other display related settings?
Click to expand...
Click to collapse
Unfortunately I have not found anything like that using tkFileExplorer...
Assuming that replacing original browser it's difficult to do, source code is available (http://opensource.samsung.com/reception/reception_main.do?method=reception_list&menu_item=mobile thanks to sabianadmin) but the browser seems deeply integrated in the os files (also notice that Samsung Dolfin is not the open source browser Dolphin..): is there anyone who found in filesystem files the textures used by the browser GUI? if aren't cripted it will be possibile to change them for having a more usable GUI on our little screen (I'm thinking of upper/lower bars..)
guari said:
Assuming that replacing original browser it's difficult to do, source code is available (http://opensource.samsung.com/reception/reception_main.do?method=reception_list&menu_item=mobile thanks to sabianadmin) but the browser seems deeply integrated in the os files (also notice that Samsung Dolfin is not the open source browser Dolphin..): is there anyone who found in filesystem files the textures used by the browser GUI? if aren't cripted it will be possibile to change them for having a more usable GUI on our little screen (I'm thinking of upper/lower bars..)
Click to expand...
Click to collapse
I think the browser user interface might be in the file called BrowserAppControl.so which can be found in the SystemFS>Osp folder. All files in that folder are in .so formats. But they are RSA 1024bit signed. And they are not like other settings in phones which are written in html or xml. These files are similar to the .dll files on Windows. .so files are Linux format files.
Is there anyway to modify an *.ini file to enable "Noise Reduction" to always be on during calls?
tibere86 said:
Is there anyway to modify an *.ini file to enable "Noise Reduction" to always be on during calls?
Click to expand...
Click to collapse
I will check on that and get back to you.
astrotom said:
I will check on that and get back to you.
Click to expand...
Click to collapse
Thank you astrotom!
Can I changing default brightness in the VideoPlayer?
Hello
This software doesn't work with my phone. I can't click on the connection i receved error message : "Warning : Unable to open the specified port. Please try again". But i can't configure in the settings.
Thanks for your help.
I'm sory for my bad english, but i'm french.
vort said:
Hello
This software doesn't work with my phone. I can't click on the connection i receved error message : "Warning : Unable to open the specified port. Please try again". But i can't configure in the settings.
Thanks for your help.
I'm sory for my bad english, but i'm french.
Click to expand...
Click to collapse
i got the same error
im running the latest firmware s8530DXKB1/s8530OLBKB1
you have to specify the port you are using for connection from settings
in Phone:/SystemFS/Driver/CameraCaps/DevCamDeviceCapsNConfig_Primary.xml
you can change max ISO and max resolution parameters for phone camera, so you can set iso1600 or 8mp for photos, probably it is useless but it's still a hack
thanks to: http://www.badaitalia.com/2011/06/13/fotografie-con-poca-luce-a-iso-1600/
(on Bada 1.0.2 this system folder is missing so it's not possible..)
Yeah, I read it. Tonight I'll try and I'll let you know.

Making modifications & mergesmali

This is a new thread on the subject of modifying the system or
applications on the Nook. I'd like to see a separate thread on
modifying the kernel, but let's keep that off this.
The Basics
A bit of the system or an app is usually written in Java. Different
tools are used to compile and process it to the final product.
The Java Runtime Environment (JRE) is what allows you to run various tools and program on your host computer.
The Java Development Kit (JDK), version 6, update 33 contains the tools you need to work with Java
javac - the Java compiler
jarsigner - a tool for signing products
Android Software Development Kit (SDK), with downloads for Level 7 API.
Android Asset Packaging Tool (AAPT) - processes resources like images and layouts
Android Debug Bridge (ADB) - allows connection and debugging to your device
The final product is either an APK file or a JAR file, both of which
are basically ZIP files. Both of these contain a file called
classes.dex which contain the executable code. An APK file also
contains resources in a directory hierarchy. Some of these items,
like regular PNG graphics are exactly as you'd find them anywhere.
Other items, like "9 patch files" (9.png), are modified and others,
like XML files, are compressed. An APK file also contains a file
called AndroidManifest.xml that describes the product. Both APK
and JAR files can also contain signatures in the META-INF
directory.
Reverse Engineering
In the best of all worlds, you would have the original Java code that
the developers used to make the product. This is seldom available.
To work around this you need to backwards step the entire
process to get back to the original Java code. There is a problem,
the backwards process is not unambiguous. Yes, you can
backtrack to some Java code, that if compiled would work the
same as the original, but it would not look the same. Often the
intent of a piece of software is apparent from its layout. Also, you
will have none of the comments in the original code.
We can easily backtrack to an intermediate place between source
Java code and the final product. This is a place that does not really
exist in the original product generation process. We can take the
raw executable code out of a product and display it in a human
readable (and editable) form. "Smali" is the name of this
representation. It is analogous to assembly code. As stated, it
really does not exist as a language in the original compilation.
There is a software tool for taking apart a product and dissecting
it into the Smali code and the resources (if any). This tool also can
be used for compiling the Smali code back into the modified
product.
apktool, a tool for reverse engineering Android files
One of the main actions of the apktool is to take apart classes.dex
and generate a whole tree of files that end in the extension ".smali".
These files will have names like:
\NeatoApp\smali\com\bigcompany\neatoapp\MainView$23.smali
Modifying a Product
So, we can take a finished product, use apktool on it to take it apart
to pieces, modify some piece, then put it back together with
apktool. Modifying a resource like a graphic is easy, just modify
it (except 9.png, more later). Changing the wording of a popup
message is also easy. Changing the language of the interface
takes a bit more care to do it correctly. Modifying the Smali code
takes a bit of knowledge and done incorrectly can even brick your
device (repairable with a backup). If you have a chunk of Smali
code that someone modified for some reason, it's not too difficult
to open up your extracted Smali file, edit in the chunk, save it and
run apktool to put everything back together.
The Problem
We see this problem with kernels all the time, that some users want
a kernel with A, B, C and others want it with C, D, E. The number
of competing configuration gets out of hand. Moreover if you
come up with feature F, then you have to find a way to package
it up with A, B, C, for the first user and D, E for the second user.
A Solution
One possible solution is to let the user decide. You can distribute
options A-F independently and let the user install them themselves.
In principle, this means the user takes whatever version of
something they have on their device, apply a specific patch, then
reinstall it on their device. This would also open things up to
modifying different versions (for example Nook Touch vs. Nook
Glow) with the same mod.
mergesmali
mergesmali is a new tool for managing modifications to Smali
code. There is no particular magic behind it. It simply can replace
sections of Smali in a text file. It is agile enough to not rely on line
numbers or exact specifics of the Smali file. Here is a simple
example how you would use it to modify something:
Code:
adb pull /system/framework/android.policy.jar
apktool d android.policy.jar \Policy
mergesmali /v \Policy\smali\com\android\internal\policy\impl\LockScreen.smali landscapemod.smali
apktool b \Policy android.policy.jar
adb push android.policy.jar /system/framework
Mod Developers
We'll get to how to make the modification files for Smali soon...
Renate,
Great post! :good:
Could you add few words on logcat/ddms to help with troubleshooting, if a mod doesn’t work as expected, please?
Yes, I'm still working on this.
I've been patching the stock reader for dictionary and other things.
I was doing the patches on the 1.1.2 Reader.apk and it worked fine.
I just switched over to the 1.1.5 Reader.apk and it patched it fine without any changes.
This post addresses the developer side of things.
It is possible to patch Smali by hand.
For quick and dirty, this is not a bad solution.
The problem is that one must be aware of how many registers are used and for what.
In the first instance, if I need another register for my mod, that can push register references on other instructions out of the 4 bit range.
Also, if the stock code is revised later that can also change register references.
Even the simple addition of a debug print statement (Log.d) can affect things.
The solution is to always replace entire methods.
That way you are not fighting with conflicting code.
The logical place to keep your patches is in Java.
Obviously you can't have a standalone method, there has to be a class.
For instance, the stock Reader.apk has a place where it validates EAN (ISBN).
It checks for all digits, which bombs on sequences with dashes.
We want to replace that, easy enough, but we have to wrap it in the class.
Code:
package com.bn.nook.model.product;
public class Products
{
public static boolean isValidEan(String ean)
{
return(true);
}
}
Obviously this does not fully implement the class, but it has enough for our little method.
We do a normal compile of this, then apktool d it to the smali.
mergesmali can then scan through this smali and edit the stock smali from the apktool d'ed stock app.
A final apktool b, jarsigning and zipaligning puts it all back together.
But what if the method that we want to replace called some other method?
We would have to put something in our class to prevent compilation errors and to ensure that the smali code for our method did the correct invocation.
We end up writing stubs for these methods that do nothing.
If it's a void method, the body of the method is simply {}, for boolean types {return(false);}, etc.
But how do we make sure that mergesmali does not substitute these stub methods for the good methods already in stock?
Annotations.
By putting Annotations before each method, we can tell mergesmali what to do.
These annotations are preserved in the decoded smali.
They are subsequently deleted when mergesmali merges the smali.
Expanding our original example (this is just an example, not realistic):
Code:
package com.bn.nook.model.product;
import com.whoever.MergeSmali.*;
public class Products
{
@Ignore
public Products() {}
@Ignore
public static double complicatedOtherMethod(String ean, String msg)
{ return(0.0); }
@Replace
public static boolean isValidEan(String ean)
{
if (complicatedOtherMethod(ean, "Hello")<2.3) return(false);
return(true);
}
}
The @Replace tells mergesmali to replace this method.
The @Ignore tells mergesmali not to replace this method.
We need to have the stub for complicatedOtherMethod in the source.
Well, why is the constructor in there?
The compiler will generate a default constructor if we don't write one and it would have no annotation.
mergesmali prints an error if any method does not have an annotation;
There is also @Append for new methods that are not in the stock.
There is also @Delete to delete methods (that either have a super or not being used at all with the rewritten methods).
What's in com.whoever.MergeSmali.* ?
Code:
package com.whoever;
public class MergeSmali
{
public @interface Ignore {}
public @interface Replace {}
public @interface Append {}
public @interface Delete {}
}
The package is not important as long as it's an Annotation and the class/subclasses are as indicated.
collaboration?
Maybe we could start some sort of work distribution (and knowledge) towards fullfiiling some common goal for the NST.
Here's the Windows (command line) executable for mergesmali.
The basic usage is:
Code:
mergesmali /v [i]stock.smali[/i] [i]patch.smali[/i]
And here's the commands to integrate the new dictionary app to the stock Reader.
Code:
apktool.bat d Reader.apk \Reader
mergesmali /v \Reader\smali\com\bn\nook\reader\ui\ReaderMainView.smali ReaderMainView.smali
apktool.bat b \Reader NewReader.apk
It should generate the following message:
Code:
Replaced: public showLookupView()V
At this point you only have the question of how you are going to sign the modified Reader.
If you have resigned your whole system already, you can just resign with that and install.
You could also edit AndroidManifest.xml before the apktool b and delete the sharedid.
Then you could install it as a regular app after deleting the system app.
Renate NST said:
At this point you only have the question of how you are going to sign the modified Reader.
If you have resigned your whole system already
Click to expand...
Click to collapse
I guess no one did it... yet.
Renate NST said:
You could also edit AndroidManifest.xml before the apktool b and delete the sharedid.
Then you could install it as a regular app after deleting the system app.
Click to expand...
Click to collapse
I don’t understand Android security well enough.
There a discrepancy between documentation and how it works or maybe I don’t understand it at all.
Anyway – if Reader.apk is resigned, it should run under different user, thus loose access to shared databases (internal, annotations, bookmarks, etc.)
Do we need to fix permission to make them RW for everyone?
Could you check (ps) what user(s) "home", "library" and "patched reader" use on you nook now, please?
Annotations, bookmarks, last reading point are all providers implemented and used in Reader.apk.
As far as I can tell, there is no particular reason why Reader.apk uses a sharedId.
I don't have stock Home or Library running on my Nook.
I forget where I have Reader.apk installed right now.
It's been in /system/app or /data/app and worked fine in either place.
Resigning does not change user.
Renate NST said:
Annotations, bookmarks, last reading point are all providers implemented and used in Reader.apk.
Click to expand...
Click to collapse
I would expect the provider for Annotations, bookmarks is Reader.apk
They are not used anywhere else.
last reading point is used in Home.apk too.
Out of curiosity, where Annotations, bookmarks and last reading point providers are implemented?
In framework itself?
Renate NST said:
Resigning does not change user.
Click to expand...
Click to collapse
Ouch.
Stock reader runs as shared user.
If we resign it – it has to run as different one, according to security docs...
And it doesn’t matter if shared id is in manifest still or not.
I guess, I need to do some testing…
Ok, I meant resigning it with the system signature it can keep the same sharedId.
If you don't sign it with the same signature then you have to get rid of the sharedId.
It will then have a normal application user ID.
As far as I can tell, this should make no difference in anything.
But I have gutted most of the B&N stuff so I can't guarantee that in-store browsing or something else won't be affected.
Renate,
Could you answer this one:
ApokrifX said:
Out of curiosity, where Annotations, bookmarks and last reading point providers are implemented?
In framework itself?
Click to expand...
Click to collapse
And one more:
Is it difficult to mod and stock side-by-side?
Change app name + package for every class?
In Reader.apk
com.bn.nook.reader.providers.AnnotationsProvider
com.bn.nook.reader.providers.BaseDictionaryProvider
com.bn.nook.reader.providers.BookmarksProvider
com.bn.nook.reader.providers.LastReadingPointProvider
com.bn.nook.reader.providers.ReaderLocalProvider
(I'd like to know some time why the forums breaks words up.)
On your second question, that's an interesting one.
You'd have to change the package name all over the place,
not just in the manifest, but every smali file and every function call.
But sure, it could be done.
Renate NST said:
In Reader.apk
com.bn.nook.reader.providers.AnnotationsProvider
com.bn.nook.reader.providers.BaseDictionaryProvider
com.bn.nook.reader.providers.BookmarksProvider
com.bn.nook.reader.providers.LastReadingPointProvider
com.bn.nook.reader.providers.ReaderLocalProvider
Click to expand...
Click to collapse
Thank you!
Renate NST said:
(I'd like to know some time why the forums breaks words up.)
Click to expand...
Click to collapse
No idea…
Renate NST said:
Annotations, bookmarks, last reading point are all providers implemented and used in Reader.apk.
As far as I can tell, there is no particular reason why Reader.apk uses a sharedId.
Click to expand...
Click to collapse
Looking at B&N coding style, I won’t be surprised if Home.apk uses its own provider to read the "last reading point".
If this is the case sharedId in a must.
Renate NST said:
On your second question, that's an interesting one.
You'd have to change the package name all over the place,
not just in the manifest, but every smali file and every function call.
But sure, it could be done.
Click to expand...
Click to collapse
and every function call But it can be automated easily, right?
ApokrifX said:
If this is the case sharedId in a must.
Click to expand...
Click to collapse
No.
The "Last read" icon in the upper left corner broadcasts com.bn.nook.launch.LAST_BOOK
This is usually received by Home.apk, which uses the LRP provider in Reader.apk to get the EAN of the last book.
Home.apk then sends the intent android.intent.action.VIEW to Reader.apk with the path of the book.
Reader.apk then uses it's own LRP provider to get the actual LRP in the book.
None of this requires sharedIDs.
#2 Sure, that could be automated.
Renate NST said:
No.
The "Last read" icon in the upper left corner broadcasts com.bn.nook.launch.LAST_BOOK
This is usually received by Home.apk, which uses the LRP provider in Reader.apk to get the EAN of the last book.
Home.apk then sends the intent android.intent.action.VIEW to Reader.apk with the path of the book.
Reader.apk then uses it's own LRP provider to get the actual LRP in the book.
None of this requires sharedIDs.
Click to expand...
Click to collapse
Home shows "last book thumbnail" + on page #XYZ of #ABC also.
I recall you have deleted Home.apk.
Renate NST said:
#2 Sure, that could be automated.
Click to expand...
Click to collapse
Ok. I gotta take a look.Will try to do later today.
ApokrifX said:
Home shows "last book thumbnail" + on page #XYZ of #ABC also.
I recall you have deleted Home.apk.
Click to expand...
Click to collapse
Yes, my Library.apk replacement has a receiver for the com.bn.nook.launch.LAST_BOOK intent.
Even though Home.apk uses the Reader.apk to find LB & LRP for the preview,
it only uses LB to tell the Reader.apk what to open.
Reader.apk does its own homework checking LRP for the desired book.
This can easily be verified by opening a few books with a file manager.
Renate NST said:
Yes, my Library.apk replacement has a receiver for the com.bn.nook.launch.LAST_BOOK intent.
Even though Home.apk uses the Reader.apk to find LB & LRP for the preview,
it only uses LB to tell the Reader.apk what to open.
Reader.apk does its own homework checking LRP for the desired book.
This can easily be verified by opening a few books with a file manager.
Click to expand...
Click to collapse
Ok. I.e. it shouldn't be a problem to run side-by-side readers, right?
They both modify LRP, and Home will be able to pull it via stock reader.
Same idiotic question: do we need to need to change any permissions to let both readers access media databases?
As it stands, if I understand what you want to do,
you'd have to disable the providers in one of the Readers.
You can't have two providers responding to the same intents.
Is there some overwhelming reason why you want to do all this?
Renate NST said:
As it stands, if I understand what you want to do,
you'd have to disable the providers in one of the Readers.
You can't have two providers responding to the same intents.
Click to expand...
Click to collapse
I didn't realize until now, provider responds to URI, so better have one only to avoid problems...
Renate NST said:
Is there some overwhelming reason why you want to do all this?
Click to expand...
Click to collapse
To "not break existing functionality"
I see, it'll be too difficult to have both, too many changes are needed...
Just a bump, old posts don't have signatures.
mergesmali & other stuff can be downloaded from my signature blob.

[Tutorial] (Default camera) How to set unsupported third party apps as default camera

In this post I want to teach you how to change your default camera to (almost) any third party app you like. Let's go!
Tested on my Lumia 535 and working
What you need:
-Interop tools by @gus33000
Click to expand...
Click to collapse
First you should find your third party camera appID you can do this by interop tools. Open interop tools, go to applications, package list, and then choose the app you want to see it's details.
The first Section "Name" is appID that is something like this:
6fca829e-0622-478c-848f-1175daf3bd5a
(That code was for camera 360 sight)
Write down that code somewhere
Open registry editor. Go to HKLM\Software\Microsoft\Photos\Shared\CameraSettings
Then open DefaultCameraAppID
The default value is Windows camera appID. Copy that as a backup for when you want to change it back. Now replace your appID with the default one. Don't forget to include the brackets:
{6fca829e-0622-478c-848f-1175daf3bd5a}
Click to expand...
Click to collapse
DONE.
No restart needed. You can now test it using quick action, lock screen, or with camera shutter button.
Hope you enjoy that:laugh:
Not working on Lumia 735 with 14393.576 installed.
Andrew[N] said:
Not working on Lumia 735 with 14393.576 installed.
Click to expand...
Click to collapse
Could you be more specific? What is the problem?
Did you do all the steps?
Or this key doesn't exist?!
Is your phone interop unlocked?
infinite41i said:
Could you be more specific? What is the problem?
Did you do all the steps?
Or this key doesn't exist?!
Is your phone interop unlocked?
Click to expand...
Click to collapse
I changed the key to ProShot ID, but Windows Camera is still default.
Andrew[N] said:
I changed the key to ProShot ID, but Windows Camera is still default.
Click to expand...
Click to collapse
I tried with proshot classic trial version and it worked. I don't have the windows 10 version. probably you made some mistakes in typing or you may have forgotten these brackets { }
proshot classic trial appID : {3d6a3d7e-5aca-4aee-b059-590b9f53cc13}
P.S. My build is the same as yours.
infinite41i said:
I tried with proshot classic trial version and it worked. I don't have the windows 10 version.
Click to expand...
Click to collapse
Do you mean, old xap version?
Yep! I don't have proshot
Maybe there's a problem with appx's?!
It is easier to make xap/appx with swaped GUID to make it see by OS in default camera menu
djtonka said:
It is easier to make xap/appx with swaped GUID to make it see by OS in default camera menu
Click to expand...
Click to collapse
What is swaped GUID?
infinite41i said:
Open registry editor. Go to HKLM\Software\Microsoft\Photos\Shared\CameraSettings
Then open DefaultCameraAppID
The default value is Windows camera appID. Copy that as a backup for when you want to change it back. Now replace your appID with the default one. Don't forget to include the brackets:
DONE.
No restart needed. You can now test it using quick action, lock screen, or with camera shutter button.
Hope you enjoy that:laugh:
Click to expand...
Click to collapse
Man that worked nicely for me! Thank you!
Although most of the "non-original" camera apps seems to take longer to launch.
Furthermore, I was not satisfied with going to the registry and editing the strings everytime I wanted to change the default app so I did a little digging.
TL;DR: I've found out how to add a new app to the default camera list in the settings menu on Windows 10 mobile
Complete description:
I found this original document from Microsoft made for the OEM on how to enable third party camera launch above lockscreen:
https ://docs. Microsoft .com/pt-br/windows-hardware/customize/mobile/mcsf/configuring-oem-lens-apps-to-launch-above-the-lock-screen
I used interop tools to create a folder as sugested on the link at software>Microsoft>ph otos> LensApps>{#AppID}\
The folder has to have the AppID name inside brackets. Each AppID folder has to have a Key named "Title" in wich the value is a string with the firendly name wich will be showed in the settings (ex: Camera360)
Well, that did'nt worked out, so I kept digging and found an already existing folder called "DefaultLens" located at software>Microsoft>ph otos>OEM>DefaultLens wich had the same pattern explained in the link. I suppose this is the adaptation for windows10 mobile, since the link is for WP8.1.
So, inside this folder I created a new entry (folder) named as the app ID for the 360 "{6fca829e-0622-478c-848f-1175daf3bd5a}". inside this folder I created the "Title" Key and set the value for "Camera360" (string). Now if I go to the camera settings I can choose between Camera and Camera360. If i choose the second one, it Works just as expected.
The problem I had was under lockscreen. If i pressed the camera button (on my 830) it went to the lockscreen and I have to put my pin before opening the camera. This can be solved creating another key inside the folder called "MinVerAboveLock" in wich its value (string) must be, as the name suggest, the version of the app. The Camera360 info on the app shows version 1.1.2, so I've put 1.1.1 as the value and now it works just as it should.
I haven't tried out Proshot with this, but a can't see any reason it wouldn't work, as when I changed the appID using your suggestion in the original post it worked.
I must say, though, tht de camera360 tends to take substantially more time to open. Anyhow, doing this I believe you can set up up to five default cameras in the list (as the link says) for fast/normal changing and test the one wich better suits your needs.
So, theres, that. Tell me if it Works for you! Cheers.
1Shot v2.2.2.0
Download
djtonka said:
1Shot v2.2.2.0
Click to expand...
Click to collapse
I'm glad it worked for you too!
Hey which lumia camera appxbundle are you using? Does it Works? I had the original appxbundle from somwhere and although I sideloaded it when i try opening it doesn't work, displaying a message about using the new Windows camera and so...
Also, do you recommend 1shot?
thx
martinwrh said:
Man that worked nicely for me! Thank you!
Click to expand...
Click to collapse
I'm glad that you found a better way!
I'll try it soon ( 2 weeks later ) because I don't have time now.
BTW you can have Lumia camera by doing a hard reset and then stoping apps from getting updated automatically.
Hey guys!
I've faced a problem. After downgrading to 8.1 and then upgrading to 10 again, there's nothing in HKLM\SOFTWARE\Microsoft\Photos.
Any idea what happened?
1Shot v2.2.5.0 appx
http://bit.ly/2ePEH1U
In "AppxManifest.xml"
<mphoneIdentity PhoneProductId="04c91c9d-4d31-4273-a430-f04f8d4c86db"

Categories

Resources