Shared Preferences with Xposed - Java for Android App Development

I try to get shared preferences in the exposed class.
This is a straight forward issue in android java. I do not know whether the permissions are the problem but things are not as straight with Xposed.
Xposed asks to provide the name of the file and the package at init Zigote. I have tried many versions and none of them seems to work. Also, the file which I make may not be available when init Zygote is called, however, I take XposedBridge wants to just register the name of the file and, probably, to prepare to override some permissions when the file is created.
I also try to double the call to the Xposed Shared Method inside the hooked method. I check for the existence of the shared preference file before. Everything is there but the reload method does not seem to reload and the file is not read but defaults are loaded by getInt and getFloat.
There is probably something more to be done, although the examples I have seen do not do anything, yet they override other methods inside init Zygote which I do not need to do.
All I need is to read a simple file from an Xposed Module.
PLEASE, INFORM.
Here is what I have tried :
I have tried many different variation and XposedBridge methods for 4 hours. I have also
tried many name variations with and without .xml.
In the standard Java for Android, there is just one get method to read a shared
preferences file. This does not seem to be the case with exposed.
I do have :
@override
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
prefs = new XSharedPreferences("PackageName", "SharedPreferenceFileNameWithotDotXml");
}
MODULE_PATH is not used, although I have tried many other methods where was.
Because the file changes on the fly, I called :
prefs.reload();
before I read the data. I tried without this call too. I also tried to get another
prefs before the reload :
prefs = new XSharedPreferences("PackageName", "SharedPreferenceFileNameWithotDotXml");
prefs.reload();
Then I try to read the data from the file :
theStart=prefs.getInt("Start", 2);
theValue=prefs.getFloat("Value", 102.0f);
I always get the defaults 2 and 102.0 although the file is there and the values of the
file are different. I have read the file.
In standard java for android philosophy, just the initialisation in init zygote and
prefs.reload() are sufficient to load the changing values of the shared preferences
file into prefs and then into the variables.
Xposed seems to be different.
I have been told there is a way to read the data from the file. I have tried most
anything and cannot. What is the way to do so. Must be simple and straight as in the
standard java for android. I must not do everything necessary.
Please, inform.
I have also tried to read the file manually from the Xposed class. Access denied. Tried
just in cases. Access denied, again.
Tried to make the shared preferences file with Activity.MODE_WORLD_READABLE. Still
access denied to be read manually.
Even with Activity.MODE_WORLD_READABLE, Xposed cannot read the file as previously
explained.
Tried :
@override
public void initZygote(StartupParam startupParam) throws Throwable {
prefs = new XSharedPreferences(TheNameOfTheXposedClass.class.getPackage().getName
());
prefs.makeWorldReadable();
}
Then, in the hooked method :
prefs.reload();
theStart = prefs.getInt("Start", 2);
theValue = prefs.getFloat("Value", 102.0f);
Still returns only the default, although the file is there. I think, in all attempts,
XSharedPreferences() cannot get the name of the package and or or the name of the file.
The file is in /data/data/NameOfPackage/shared_prefs/NameOfFile.xml
Tried :
@override
public void initZygote(StartupParam startupParam) throws Throwable {
prefs = new XSharedPreferences
("/data/data/NameOfPackage/shared_prefs/NameOfFile.xml");
prefs.makeWorldReadable();
}
with and without .xml
Still nothing.

PROBLEM SOLVED.
Thank you for your reply. Everything was WORLD READABLE : in the non Xposed class and in the Xposed class on a number of occasions.
Also, I have used the hard values for the package and path.
The problem was not related to Java and Android but to Android arrangements and how much Xposed can cope with. The Android permissions for to access the file from the Xposed class had to be elevated which is unusual but this is what solved the problem, I think. Someone also reported the same problem and the same solution : http://forum.xda-developers.com/xposed/development-xsharedpreferences-issue-t2931396
In the non Xposed class, I have used the same solution just with a hard coded path and file. After I make the shared preferences file in the non Xposed class, I gave more permissions by :
File theSharedPrefsFile;
theSharedPrefsFile = new File("/data/data/PackageName/shared_prefs/FileName.xml");
theSharedPrefsFile.setReadable(true, false);
This seems to have solved the problem.
I am not sure of how reliable the solution is, though. I still check in the Xposed class whethere there is such a file or not. I have not tested what happens when the file is not there initially. Must do.
theXposedCommunicationPreferenceFile = new File("/data/data/PackageName/shared_prefs/FileName.xml");
if (theXposedCommunicationPreferenceFile.exists() == false) XposedBridge.log("Check in hooked method cannot find the file");
Hope everything would be OK.
Even though everything should be OK, I am not sure how reliable the dependence of permissions is.
I have also tried the secure reload :
StrictMode.ThreadPolicy oldPolicy;
oldPolicy = StrictMode.allowThreadDiskReads();
try {
prefs.reload();
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
I am not sure how reliable this is either so I put another simple reload on top :
prefs.reload();
StrictMode.ThreadPolicy oldPolicy;
oldPolicy = StrictMode.allowThreadDiskReads();
try {
prefs.reload();
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
I think, neither of these has made any difference and the real solution was the higher permissions to access the shared preference file given in the non Xposed class, again :
File theSharedPrefsFile;
theSharedPrefsFile = new File("/data/data/PackageName/shared_prefs/FileName.xml");
theSharedPrefsFile.setReadable(true, false);
Pretty nasty problem and difficult to find solution although published in the XDA Forum the searchability of post in the said forum is not very good.
Yet another sleepless night.

StevenStanleyBayes said:
I think, neither of these has made any difference and the real solution was the higher permissions to access the shared preference file given in the non Xposed class, again :
Click to expand...
Click to collapse
I know this is a pretty old thread but I have elevated the permission level to 777 of both the dir and preferences file and yet cannot access the file from the xposedClass is there any chance you are still developing xposed modules and can help

Related

[Project] Decompile Apps to Java

A little introduction:
I already created a project on GoogleCode with the goal to decompile Dalvik's bytecode to fully compilable java-sourcecode.
I know that's a complex thing and that there are some technical barriers like the fact that dalvik uses registers but I think this should and can be done.
There are already some projects like dex2jar or baksmali which does a very good job.
Dex2jar does only produce a readable java-code(not good for making changes and to recompile everything).
The smali-code produced by baksmali is a little bit hard to read but it's the best for making changes.
So I decided to use the sourcecode of baksmali so I don't need to write a smali or dex-parser and I can directly start converting the smali-language to java-code.
A clarification: I only want to make it possible to use code for studying or to recover your own code.
The goal of this project will never be to support piracy or code-stealing!!!
Click to expand...
Click to collapse
GoogleCode-Project:
http://code.google.com/p/bakjava/
Project-Status:
What's working?
Code:
Package-Names
Class-Definitions with extends and implements
Methods with return-types, accessors and parameters
Fields with data-type and accessors
What doesn't work?
Code:
Interfaces
Annotations
Generics
Variables
Instructions
Loops
everything else what I forgot...
I hope that there is any interest by the community and maybe some coders who wants to help.
I think this will be very, very hard. Disassembling or converting class and method names only is quite easy to do because they're 1:1 conversions. You have method with 2 int arguments? You write it as "someMethod(II)V" or "void someMethod(int p0, int p1)" - it's really easy.
But this is not the case for decompilation. Decompilation is a process of guessing how sources might look like before the compilation. This is not 1:1, it requires you to create an "intelligent" tool which supports thousands of different situations.
You see, JVM bytecode decompilers are developed for over ten years and they're still far from perfect. Now you want to create DVM bytecode decompiler just like that
I think dex2jar & JD is the way to go. You convert DVM to JVM only, which is nearly 1:1 and then use the power of years of experience on JVM decompilation.
Ahh, of course you can create simple decompiler which will output something like:
Code:
int r0 = 5;
int r1 = 8;
int r2 = r0 + r1;
r1 = 20;
r2 = r2 - r1;
But that's not better than smali. In fact it's even worse. And still it's quite hard to convert goto's to loops, if's, etc.
You're right. It's not easy but I want to give it a try.
BTW goto's doesn't exist in Java. Android-Apps which were directly written in smali aren't easy to compile.
But the purpose of this project is to decompile Apps which where written in Java.
m11kkaa said:
BTW goto's doesn't exist in Java. Android-Apps which were directly written in smali aren't easy to compile.
But the purpose of this project is to decompile Apps which where written in Java.
Click to expand...
Click to collapse
Goto's don't exist in Java source, but they do in the bytecode. All flow control instructions like if, else, while, do..while, for, switch, etc. are compiled to goto's (or to other types of jumps).
You're right
But I still want to try this just to test myself and to see what can be done.
Now instead of disussing the difficulty of this project let's start planning and coding
Would be great if anyone has some knowledge on complex algorithms and coding-algebra and wants to contribute to this project.
Maybe don't convert gotos to if/loop statements..
dex2jar creates lots of loops and their first instruction is a break/return -_-
If you convert everything but goto's, the code should already be much more readable, and at least goto is a reserverd java keyword.
On the downside this would require an extra compiler or the code is read-only.
I didn't test that logic but theoretically we could split the code at the goto's and write the blocks into method's.
This methods could be called instead of the goto's.
Would be less readable but it should work or am I wrong?
BTW: Currently I'm working on converting the standard-code into java. Theoretically simple but that's very much work. Would be really great if someone wants to help. baksmali is written in java so you don't need any c/c++-knowledges.
m11kkaa said:
I didn't test that logic but theoretically we could split the code at the goto's and write the blocks into method's.
This methods could be called instead of the goto's.
Would be less readable but it should work or am I wrong?
Click to expand...
Click to collapse
It will be much, much less readable than smali and it'll greatly decrease performance after recompilation. Methods has averagely 5-10 branches of code, so you would have to break them into very large number of methods.
Let's get for example very simple method:
Code:
private String someMethod(Object o) {
return o == null ? "" : o.toString();
}
In smali it would be something like:
Code:
if-nez p1, :cond_0
const-string v0, ""
:goto_0
return-object v0
:cond_0
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object v0
goto :goto_0
As you can see it has 4 branches of code, so it would be decompiled into:
Code:
private String someMethod1(Object o) {
String ret;
if (o == null) {
ret = someMethod2();
} else {
ret = someMethod3(o);
}
return ret;
}
private String someMethod2() {
return "";
}
private String someMethod3(Object o) {
return o.toString();
}
I have already do some optimization, because I have decompiled 4 branches into 3 methods, not 4.
m11kkaa said:
Would be really great if someone wants to help. baksmali is written in java so you don't need any c/c++-knowledges.
Click to expand...
Click to collapse
I think I know how to do that, but for me it's a waste of time. It'll take many months to be able to decompile simple applications and still results will be poor.

pushing files from your apk to the sdcard?

Im designing a new theme engine for the 360 Launcher so users can start developing their own themes for the 360 Launcher Pro and i360 Launcher. I already design themes for the 360 on google play but I want to get a little bit creative with it and open source it to fellow themers, but I have a question first...
Lets say I stored the appropriate drawables in a /raw folder in the apk. What command in the java code would I use to "push" those files to /sdcard/360/themes/ (So, when a user clicks the install button, it pushes the appropiate files in the correct folders in the devices sdcard or memory) .
Im not a junkie for linux commands so I need a helping hand here, probably something simple.
No need for command line things.
Move your files to the assets directory. Then you will be able to read them. Just write the content to the SD card afterwards. (Android does not use a /raw folder.)
Have a look at this: http://stackoverflow.com/questions/...he-full-contents-of-a-file-to-an-outputstream
Or even better: http://stackoverflow.com/questions/4447477/android-how-to-copy-files-in-assets-to-sdcard
nikwen said:
No need for command line things.
Move your files to the assets directory. Then you will be able to read them. Just write the content to the SD card afterwards. (Android does not use a /raw folder.)
Have a look at this: http://stackoverflow.com/questions/...he-full-contents-of-a-file-to-an-outputstream
Or even better: http://stackoverflow.com/questions/4447477/android-how-to-copy-files-in-assets-to-sdcard
Click to expand...
Click to collapse
Well that works better if thats the case, lemme give this a shot then. rather not beat around the bush and use people memory. I use a /raw folder when I store files in a apk if its a txt file or something thats not relevent to default apk folders.
Hmmm still having troubles with this...
Would this be as equal as what they discuss above?
http://www.codeofaninja.com/2013/01/copy-files-from-assets-folder-to-sd.html
Ive been even messing with this method
Nx Biotic said:
Hmmm still having troubles with this...
Would this be as equal as what they discuss above?
http://www.codeofaninja.com/2013/01/copy-files-from-assets-folder-to-sd.html
Ive been even messing with this method
Click to expand...
Click to collapse
I think so.
Did you add the proper permission for accessing the SD card?
Which error message do you get?
i didn't get errors, just didn't apply
Sent from my 9300 using xda app-developers app
Nx Biotic said:
i didn't get errors, just didn't apply
Sent from my 9300 using xda app-developers app
Click to expand...
Click to collapse
Does your phone have an internal and an internal SD card. Check both.
Did you print the stacktrace in the try and catch blocks? The error might be there.
The code i use:
Code:
public void copyFileFromRaw(int fileID, String destFile)
{
try
{
InputStream is = getResources().openRawResource(fileID);
FileOutputStream fos = new FileOutputStream(destFile);
byte[] buffer = new byte[1024];
int offset;
while ( ( offset = is.read(buffer) ) > 0 ) fos.write(buffer, 0, offset);
is.close();
fos.close();
Runtime.getRuntime().exec("chmod 700 " + destFile); // or chmod to whatever you need
}
catch (Exception e)
{
// print error log
}
}
Args:
fileID -> resource ID of your file, e.g. R.raw.myfile (note this is an ID, not a string)
destFile -> destination file (full path!)
So let's say you put inside the /res/raw/ folder a file called "myfile", now you want to copy that file to the sdcard:
copyFileFromRaw(R.raw.myfile, "/mnt/sdcard/myfile");
nikwen said:
Does your phone have an internal and an internal SD card. Check both.
Did you print the stacktrace in the try and catch blocks? The error might be there.
Click to expand...
Click to collapse
all of my devices do
Sent from my 9300 using xda app-developers app
xdaid said:
The code i use:
Code:
public void copyFileFromRaw(int fileID, String destFile)
{
try
{
InputStream is = getResources().openRawResource(fileID);
FileOutputStream fos = new FileOutputStream(destFile);
byte[] buffer = new byte[1024];
int offset;
while ( ( offset = is.read(buffer) ) > 0 ) fos.write(buffer, 0, offset);
is.close();
fos.close();
Runtime.getRuntime().exec("chmod 700 " + destFile); // or chmod to whatever you need
}
catch (Exception e)
{
// print error log
}
}
Args:
fileID -> resource ID of your file, e.g. R.raw.myfile (note this is an ID, not a string)
destFile -> destination file (full path!)
So let's say you put inside the /res/raw/ folder a file called "myfile", now you want to copy that file to the sdcard:
copyFileFromRaw(R.raw.myfile, "/mnt/sdcard/myfile");
Click to expand...
Click to collapse
il give this a shot
Sent from my 9300 using xda app-developers app
Nx Biotic said:
all of my devices do
Sent from my 9300 using xda app-developers app
Click to expand...
Click to collapse
I meant that it might have been saved on the internal instead of the external SD card.
nikwen said:
I meant that it might have been saved on the internal instead of the external SD card.
Click to expand...
Click to collapse
Neither, i monitored both partitions. Im gna give this another shot tonight with the information You guys gathered so hopefully i can get something working.
Sent from my 9300 using xda app-developers app

NEED HELP

hello guys i need help with an apk i want to add a link in my apk for example "if u dont have ****launcher installed press here" and to redirect him to the specified web page
sorry if is a wrong thread
sorry for my bad english
cheers
Laurentiu27 said:
hello guys i need help with an apk i want to add a link in my apk for example "if u dont have ****launcher installed press here" and to redirect him to the specified web page
sorry if is a wrong thread
sorry for my bad english
cheers
Click to expand...
Click to collapse
Intents are used in Android to share or link across to other apps, including URLs. If you want to link to a Play Store page, read this documentation. Otherwise, consider implicit intents here.
This is what I would do. The below code is a function that you would call to determine if a certain apk(package) is installed. What is in bold is where you would place the package name to search for. You could take it a step further and and a String to pass to the function and it would make the function more useful by being able to check for multiple package names.
Code:
/**
* Determine whether the APK is installed.
* /
public boolean isApkInstalled(Context myContext) {
PackageManager myPackageMgr = myContext.getPackageManager();
try {
myPackageMgr.getPackageInfo("[B]com.apps.whatever[/B]", PackageManager.GET_ACTIVITIES);
}
catch (PackageManager.NameNotFoundException e) {
return (false);
}
return (true);
}
This code would be used to install a package. So in theory, you could call your isApkInstalled() function and if it returns false, then call this and present the option for the user to download. The bold is where you would change the package name to whatever package you are looking for.
Code:
/**
* Install the APK through the market: URI scheme.
* /
public void goToMarket(Context myContext) {
Uri marketUri = Uri.parse("market://details?id=[B]com.apps.whatever[/B]");
Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myContext.startActivity(myIntent);
return;
}
zalez said:
This is what I would do. The below code is a function that you would call to determine if a certain apk(package) is installed. What is in bold is where you would place the package name to search for. You could take it a step further and and a String to pass to the function and it would make the function more useful by being able to check for multiple package names.
Code:
/**
* Determine whether the APK is installed.
* /
public boolean isApkInstalled(Context myContext) {
PackageManager myPackageMgr = myContext.getPackageManager();
try {
myPackageMgr.getPackageInfo("[B]com.apps.whatever[/B]", PackageManager.GET_ACTIVITIES);
}
catch (PackageManager.NameNotFoundException e) {
return (false);
}
return (true);
}
This code would be used to install a package. So in theory, you could call your isApkInstalled() function and if it returns false, then call this and present the option for the user to download. The bold is where you would change the package name to whatever package you are looking for.
Code:
/**
* Install the APK through the market: URI scheme.
* /
public void goToMarket(Context myContext) {
Uri marketUri = Uri.parse("market://details?id=[B]com.apps.whatever[/B]");
Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myContext.startActivity(myIntent);
return;
}
Click to expand...
Click to collapse
thank u for your help
SimplicityApks said:
Intents are used in Android to share or link across to other apps, including URLs. If you want to link to a Play Store page, read this documentation. Otherwise, consider implicit intents here.
Click to expand...
Click to collapse
thank you

[How to] launch any deployed app within your own app

Hello again,
while I´m still working on my PDF to Office app I found out how to use <Capability Name="ID_CAP_OEM_DEPLOYMENT" />.
Using this capability lets you launch any deployed app within another app or lets you get the applist of all deployed apps (sadly less system apps like Office) including appname, uri, appicon and so on.
1. add
Code:
<Capability Name="ID_CAP_OEM_DEPLOYMENT" />
to your WMAppManifestXML
Add to your *xaml.cs file:
2.
Code:
using Windows.ApplicationModel;
using Windows.Phone.Management.Deployment;
3.
Code:
public Package GetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
=> the code will return the package (app) you want to launch if it exists
4.
Code:
private void LaunchAR_Click(object sender, System.Windows.Input.GestureEventArgs e)
{
Package packageById = GetPackageByID("{134E363E-8811-44BE-B1E3-D8A0C60D4692}");
if (packageById != null)
{
packageById.Launch(string.Empty);
}
else
{
// do something if the app doesn´t exist
}
}
=> this sample code will launch Adobe Reader if the app is present on your device
With some simple modifications of the above code you will easyly be able to make visible the whole applist in a ScrollistViewer or Listbox.
=> this could be useful for coding a new AppData backup app for interop-unlocked devices.
Cheers
contable
contable said:
Hello again,
while I´m still working on my PDF to Office app I found out how to use <Capability Name="ID_CAP_OEM_DEPLOYMENT" />.
Using this capability lets you launch any deployed app within another app or lets you get the applist of all deployed apps (sadly less system apps like Office) including appname, uri, appicon and so on.
1. add
Code:
<Capability Name="ID_CAP_OEM_DEPLOYMENT" />
to your WMAppManifestXML
Add to your *xaml.cs file:
2.
Code:
using Windows.ApplicationModel;
using Windows.Phone.Management.Deployment;
3.
Code:
public Package GetPackageByID(string id)
{
using (List<Package>.Enumerator enumerator = new List<Package>(InstallationManager.FindPackages()).GetEnumerator())
{
while (enumerator.MoveNext())
{
Package current = enumerator.Current;
try
{
if (current.Id.ProductId.Contains(id))
return current;
}
catch (Exception ex)
{
}
}
}
return (Package)null;
}
=> the code will return the package (app) you want to launch if it exists
4.
Code:
private void LaunchAR_Click(object sender, System.Windows.Input.GestureEventArgs e)
{
Package packageById = GetPackageByID("{134E363E-8811-44BE-B1E3-D8A0C60D4692}");
if (packageById != null)
{
packageById.Launch(string.Empty);
}
else
{
// do something if the app doesn´t exist
}
}
=> this sample code will launch Adobe Reader if the app is present on your device
With some simple modifications of the above code you will easyly be able to make visible the whole applist in a ScrollistViewer or Listbox.
=> this could be useful for coding a new AppData backup app for interop-unlocked devices.
Cheers
contable
Click to expand...
Click to collapse
Yep! This is used in Samsung AppFolder
-W_O_L_F- said:
Yep! This is used in Samsung AppFolder
Click to expand...
Click to collapse
Exactly.
Do you you know how "InstallationManager.AddPackageAsync" works ?
contable said:
Exactly.
Do you you know how "InstallationManager.AddPackageAsync" works ?
Click to expand...
Click to collapse
I am hoping to learn that myself. I know that Nokia's "Extras & Info" app uses this API for their "SilentInstaller". Nokia's "SilentInstaller" has the ability to install interop-unlocked apps as long as they are fully and properly signed with the appropriate license.xml and wmprheader.xml.
Microsoft has some documentation about this API at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207248(v=vs.105).aspx
**EDIT**
Found it! (I think)
we can deploy apps with InstallationManager.AddPackageAsync(String title, Uri sourceLocation, String instanceId, String offerId, Uri license)
This info matches EVERYTHING that is included with a valid xap signed by Microsoft. All the data is contained in the xap's provxml, too (albeit in the wrong order)
Info about this "undocumented" api is at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662948(v=vs.105).aspx
The million-dollar questions are what privileges are required to access this API, and can we use it without interop unlock?
Really wishing I had my phone back! (won't be here until tomorrow)
Very nice, thanks for publishing! I was going to pull apart App Folder and see how it works myself; thanks for taking the time to do that for me and share it with us all!
For what it's worth, a foreach loop will read more cleanly than explicitly calling GetEnumerator() and then iterating over it, but the basic structure of the code is fine (and I think the MSIL is the same anyhow - foreach being just syntactic sugar - so they probably did it that way when actually writing the app and your decompiler just produced the more verbose version from the MSIL).
Note that this can also, of course, be used to create launcher apps. An alternative to the Start screen, potentially, even (with some other hackery to hook it in where needed). To use it in Backup apps, though, we'll need access to the app's storage folder too (or a way to activate the SeBackup privilege in the app's token...)
Well... already known when I decompiled samsung's app folder app.
---------- Post added at 12:37 PM ---------- Previous post was at 12:29 PM ----------
compu829 said:
I am hoping to learn that myself. I know that Nokia's "Extras & Info" app uses this API for their "SilentInstaller". Nokia's "SilentInstaller" has the ability to install interop-unlocked apps as long as they are fully and properly signed with the appropriate license.xml and wmprheader.xml.
Microsoft has some documentation about this API at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207248(v=vs.105).aspx
**EDIT**
Found it! (I think)
we can deploy apps with InstallationManager.AddPackageAsync(String title, Uri sourceLocation, String instanceId, String offerId, Uri license)
This info matches EVERYTHING that is included with a valid xap signed by Microsoft. All the data is contained in the xap's provxml, too (albeit in the wrong order)
Info about this "undocumented" api is at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662948(v=vs.105).aspx
The million-dollar questions are what privileges are required to access this API, and can we use it without interop unlock?
Really wishing I had my phone back! (won't be here until tomorrow)
Click to expand...
Click to collapse
see nokia extra+info app's capability
You can use Shell Chrome API directly to launch any URI, just 2 lines code
reker said:
You can use Shell Chrome API directly to launch any URI, just 2 lines code
Click to expand...
Click to collapse
So please post the two lines of code so that I can launch any URI without using a Toast.
DELETED
GoodDayToDie said:
Very nice, thanks for publishing! I was going to pull apart App Folder and see how it works myself; thanks for taking the time to do that for me and share it with us all!
For what it's worth, a foreach loop will read more cleanly than explicitly calling GetEnumerator() and then iterating over it, but the basic structure of the code is fine (and I think the MSIL is the same anyhow - foreach being just syntactic sugar - so they probably did it that way when actually writing the app and your decompiler just produced the more verbose version from the MSIL).
Note that this can also, of course, be used to create launcher apps. An alternative to the Start screen, potentially, even (with some other hackery to hook it in where needed). To use it in Backup apps, though, we'll need access to the app's storage folder too (or a way to activate the SeBackup privilege in the app's token...)
Click to expand...
Click to collapse
Here an improved code:
Code:
public Package GetPackageByID(string id)
{
List<Package> packages = new List<Package>(InstallationManager.FindPackages());
foreach (var cpackage in packages)
{
if (cpackage.Id.ProductId.Contains(id))
return cpackage;
}
return (Package)null;
}
Indeed to create an AppData Backup app we need access to the app´s storage folder first. Atm we only can copy files from the app´s storage folder with another RPCComponent discovered by -W_O_L_F-. But when the time comes a Backup app can be created in a few hours...
Oneliner (untested)
Code:
public Package LinqGetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
jessenic said:
Oneliner (untested)
Code:
public Package LinqGetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
Click to expand...
Click to collapse
Thanks. The oneliner works fine. :good:
Edit:
post #1 updated with the oneliner....
jessenic said:
Oneliner (untested)
Code:
public Package LinqGetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
Click to expand...
Click to collapse
Is it also possible to check if an app is installed and if yes, which version? that would be nice...
gipfelgoas said:
Is it also possible to check if an app is installed and if yes, which version? that would be nice...
Click to expand...
Click to collapse
Yes. With this method you can get all informations about an installed package: version, publisher and so on...

Kotlin app can't find file even though it exists

I'm working on a Kotlin app where I need to access the Cookies file located at /data/data/com.android.chrome/app_chrome/Default/Cookies. However, when I try to access the file, I get a "file not found" error, even though the file definitely exists at that location.
I've double-checked the file path and made sure there are no typos (I can see the file with adb shell and Amaze File Manager), and I've also checked that the app has permission to access the file (app has root permissions).
First I was trying to open and read the file directly and I got the error:
CODE at https://stackoverflow.com/questions/76064385/kotlin-app-cant-find-file-even-though-it-exists
I though maybe Chrome was running so I couldn't open the file directly so I tried copying it to a temp folder and reading that:
CODE at https://stackoverflow.com/questions/76064385/kotlin-app-cant-find-file-even-though-it-exists
But that still fails:
CODE at https://stackoverflow.com/questions/76064385/kotlin-app-cant-find-file-even-though-it-exists
Is there anything else I can try to troubleshoot this issue?
Something in the code triggers cloudflare and blocks me from posting
Code:
Sorry, you have been blocked
You are unable to access xda-developers.com
Why have I been blocked?
This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.
What can I do to resolve this?
You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.
Cloudflare Ray ID: 7badda7c6b9486c6 • Your IP: Click to reveal • Performance & security by Cloudflare
SQLite definitely won't open the file. So, your decision to copy it was right.
Firstly, try to split the single command string into an array.
The documentation for ProcessBuilder class has an example:
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Or try to use SuFile from the libsu, for example:
AndroidIDeditor/Util.java at 6a62bac0e3e63502e9a7b538217f65189ff85fa4 · sdex/AndroidIDeditor
Android Device ID changer. Contribute to sdex/AndroidIDeditor development by creating an account on GitHub.
github.com
lioce said:
SQLite definitely won't open the file. So, your decision to copy it was right.
Firstly, try to split the single command string into an array.
The documentation for ProcessBuilder class has an example:
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Or try to use SuFile from the libsu, for example:
AndroidIDeditor/Util.java at 6a62bac0e3e63502e9a7b538217f65189ff85fa4 · sdex/AndroidIDeditor
Android Device ID changer. Contribute to sdex/AndroidIDeditor development by creating an account on GitHub.
github.com
Click to expand...
Click to collapse
Seems like not even like that can I read the Cookies file from Chrome
Code:
fun copyFile(source: String, destination: String) {
Log.d("CookieSwapLogger", "copyFile '$source' to '$destination'")
val sourceFile = SuFile(source)
if (sourceFile.exists()) {
Log.d("CookieSwapLogger", "sourceFile.exists")
} else {
Log.d("CookieSwapLogger", "sourceFile.notExists")
}
---------------
2023-04-21 18:20:47.440 6347-6347 CookieSwapLogger com.david.cookieswapper D copyFile '/data/data/com.android.chrome/app_chrome/Default/Cookies' to '/data/user/0/com.david.cookieswapper/app_temp/Cookies'
2023-04-21 18:20:47.492 6347-6347 CookieSwapLogger com.david.cookieswapper D sourceFile.notExists

Categories

Resources