BuildBox
The main intend of this application is to provide an easy to use, but powerful way to serve updates and addons for developers to their users, but it doesn't stop there, it also can be used by the user itself as batch flashing tool for files on the internal or external sd (openrecoveryscript supporting recovery and root are prerequisite).
But please keep in mind, this is still beta stage, so far all is stable, but the code itself needs refactoring still and some additional features i want to add are still missing, also the included images are far from being great.
Why i built this?
The current alternatives public available seemed not as powerful as they could be, because of the fact that they are closed source i started to build something similar myself from scratch.
What does it serve?
Tabbed UI
Nested lists within the tabs (in theory infinite levels of nesting [but for usability i wouldn't recommend more than 5 steps])
Detail views with many optional fields, like description, changelog, developers, images,...
Completely remotly configured content using json
Optional Md5 verfification
Download queue
Changelist of added, removed, updated & downgraded items
Sorting of download queue by drag & drop
Concurrent downloads to achieve full use of bandwidth (configurable amount)
Backup and restore of download queues
Support of every host with direct link capabilities
Support of hosts with up to 5 redirects (note: still direct link redirects, download webpages don't get handled)
Internal retry or resume (if supported by the server) functionality to avoid broken downloads because of unstable connections (up to 5 retries)
Direct install of apks
"External" link handling
Direct flash capabilities (if an openrecoveryscript supporting recovery is installed)
Adding of zips from storage to the queue
Backup/wipe options before flashing
Queue filter to only flash Successful/Done (Successful=downloaded+md5sum correct, Done=donwloaded+no md5sum provided) downloads (md5mismatches can optional be taken in as well)
OTA updates
Configurable interval for update check
Update version filter to avoid multiple notifications per version
New version check on startup
Image recycling and scaling (if an image is used more than once [identified by it's url], it will be downloaded only once and simply reused, also it will be scaled to the fitting size of the view to take as less bandwidth and ram as possible)
more to come...
Why json and not xml?
Xml is pretty good for local configuration, but json is the way to go when it comes to remote content.
It is highly mutable, lightweight and easy to use. Also the possibility for typos and errors is much less than with xml, because simple brackets and key value pairs are used instead of tags.
Last but not least, json files are about half of the sice of xml files if the same content is provided and the possible use of a webservice to provide it is pretty simple.
How to use as rom developer?
The application uses build.prop properties to configure rom update url, content url, rom version and default download directoy.
For update and content url there are also string resources present (to be able to publish the app to the play store to provide the rom itself with it e.g.).
All of this properties are optional (if they are not provided default values are taken).
Build.prop sample
Code:
buildbox.downloaddir=/storage/sdcard0/TestRom
buildbox.version=1.0.3c1
buildbox.updateurl=http://www.test.com/Rom.json
buildbox.contenturl=http://www.test.com/Content.json
Common content description
At the content json all root items will be shown as tabs, everything inside them are listitems.
Every item containing another list of items must contain the "children" property.
Every item containing a detail item must contain the "detail" property instead.
Key Value pair description
Common properties:
Code:
"title": "some value" -> this is the title of the chapter/listitem/detailitem (depends on the item type) (if the detailview doesn't contain a title property it will be taken from it's parent)
"device": "GT-I9300" -> this value is used to filter content which is only available for specific devices, it is compared with the ro.product.model build.prop property (because it is almost untouched by moders)
"thumbnailurl": "some url" -> this is the thumbnail shown at a listitem, it will be loaded asynchronous
"children": [ { some child items } ] -> this property is used to identify that this item contains another list
"detail" : { some detail properties } -> this property is used to identify this item as last item before a detail view is shown
Additional detail properties:
Code:
"version": "some version" -> sets the version (must not be inside the detail item, can also be inside his parent)
"description": "some text" -> sets the description (basic html notation can be used for formating)
"type": "zip" -> possible values are zip, apk, web, other, this will override the basic behaviour of parsing the mime type and will directly threaten it as the provided type [if external is used and the url property is given the url property will be taken for opening instead of the first webpages link])
"md5": "a md5sum" -> sets the md5sum of the package (only used for download verification if provided)
"url": "some url" -> the url where the item can be downloaded from
"webpages": [ "some url",
"some other url",
....
] -> if no url provided the first item of this array will be taken as external link, but in common provided as hyperlinks on the detail view to support pages
"images": [ "some url",
"some other url",
....
] -> used to show screenshots,... within the detail view (also loaded asynchronous)
"changelog": [ "a change",
"another change",
......
] -> to show a changelog, also supports html notation
"developers": [ { "some developer name": "" },
{ "another developer name": "some donation or profile page" },
......
] -> used to show the realted developers, if a donation or profile url is given the name will be shown as hyperlink, if it's empty as plain text
Server File Samples
Content.json:
Code:
[{
"title":"Apps",
"device":"GT-I9300", [B]//optional, compared with the ro.product.model build.prop property, to shows items for specific devices only (can be put at every level inside the nesting of an item, except inside a detail item)[/B]
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Apps.png",
"children": [
{"title":"4.2 Camera/Gallery",
"detail":
{"description":"Aosp Camera from android 4.2 with sphere photo feature",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Apps/4.2Camera_App.zip",
"md5":"10cfc3983156d42a9dbafe7bc8265257"
}
},
{"title":"4.2 Clock",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Apps/4.2-Clock_App.zip",
"md5":"8334f1ed2ec79efbe4199a86fda7ee58"
}
},
{"title":"4.2 Keyboard",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Apps/4.2Keyboard_App.zip",
"md5":"de0d134795217b21ccbeb0f1b7dd3cdd"
}
}
]
},{
"title":"Bloat",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Bloat.png",
"children": [
{"title":"Calculator",
"detail":
{"webpages": [
"http://ms-team-hd.tectas.eu/download.php?file=Addons/Bloat/Calculator_App.zip"
],
"md5":"6adbc0077f7aac1f25ed584cff5c4d0e"
}
},
{"title":"SPlanner",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Bloat/SPlanner_App.zip",
"md5":"2949654d704a59cdbd17b7227b825d37"
}
}
]
},{
"title":"Themes",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Themes.png",
"children": [{
"title":"Battery Mods",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Battery.png",
"children": [
{"title":"Blue Battery",
"thumbnailurl":"http://ms-team-hd.tectas.eu/Addons/Battery/Images/BlueBattery.png",
"detail":
{"description":"Stock battery icon in blue made by raubkatze",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Battery/BlueBattery_Mod.zip",
"md5":"f1bc5f90dc284df34fb0c8d2d9044330"
}
},
{"title":"Blue Battery Percentage",
"thumbnailurl":"http://ms-team-hd.tectas.eu/Addons/Battery/Images/BlueBatteryPercentage.png",
"detail": {
"description":"Stock battery icon in blue with percentage made by thisiskindacrap",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Battery/BlueBatteryPercentage_Mod.zip"
}
},
{"title":"Blue Battery Circle",
"thumbnailurl":"http://ms-team-hd.tectas.eu/Addons/Battery/Images/BlueCircle.png",
"detail": {
"description":"Blue circle battericon with percentage in the center made by raubkatze",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Battery/BlueCircle_Mod.apk", //apk extension will be read and the install dialog will pop up
"md5":"c43c2734846ced3db5ed5987d5647bae"
}
}
]
},{
"title":"Framework Themes",
"thumbnailurl":"http://ms-team-hd.tectas.eu/images/Apps.png",
"children": [{
"title":"Elegant Theme",
"detail": {
"describtion":"Eye-Candy Theme by ThilinaC",
"url":"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=0B8AYcerB14i3YVBmTEM4b0tzOVU",
"md5":"5e0d5a4578f01cfa8b357e79193f070b"
}
},{
"title":"MS Team Blackbean Theme",
"detail": {
"description":"Black and white theme made by alvin551",
"url":"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=0B8AYcerB14i3VmUwWTVKdWZ6UWM",
"md5":"93442e1fb4197e554ebdb1c8ff9c52a1"
}
},{
"title":"MS Team HD Theme",
"detail": {
"description":"Holo style theme. The theme is not originally created by MS Team HD, it uses parts of many other themes. All credits to the creators of the themes this is based on.",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/MS-Team-HD_Theme.zip",
"md5":"15eec7c80db7acbaccd939f827d806e9"
}
}
]
},{
"title":"Multiwondow Themes",
"children": [{
"title":"Multiwindow Blackbean",
"detail": {
"description":"Multiwindow theme made by alvin551",
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/Flashbar-BlackBean_Mod.zip",
"md5":"4be1c0da1d77121de9627dd2570fee00"
}
},{
"title":"Multiwindow Black Glass",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/Flashbar-Glass-Black_Mod.zip",
"md5":"b8befba0558fdd954c8c73563761565c"
}
},{
"title":"Multiwindow Blue Glass",
"detail": {
"url":"http://ms-team-hd.tectas.eu/download.php?file=Addons/Themes/Flashbar-Glass-Blue_Mod.zip",
"md5":"d98c0cd04fc3240b372a78911a09c865"
}
}
]
}
]
}
]
Rom.json (which contains basically nothing less than a detailitem, means all optional properties used here can also be used at detail items within the Content.json):
Code:
{
"title": "MS Team HD", [B]//optional if parent item is present[/B]
"version": "9.0.1", [B]//optional[/B]
"description": "test", [B]//optional[/B]
"type": "zip", [B]//optional[/B]
"md5": "75a3a73d3ac941cc83f90dd80d000477", [B]//optional[/B]
"url": "http://ms-team-hd.tectas.eu/download.php?file=Rom/MS-Team-HD_9.0.1_XXEMA2.7z", [B]//optional[/B]
"webpages" : [
"http://forum.xda-developers.com/showthread.php?t=1886332",
"http://ms-team-hd.tectas.eu"
], [B]//optional[/B]
"images": [
"http://ms-team-hd.tectas.eu/Winscp-Screenshot.png"
], [B] //optional[/B]
"changelog": [
"change1",
"change2"
], [B]//optional[/B]
"developers": [
{ "tester": "" },
{ "tester2": "http://test" }
] [B]//optional[/B]
}
NOTE: if you simply want to take and alter this examples, remove the comments (everthing starting with //) they are not supported within json.
Is it open source?
Yes, the java packges are licensed under lgpl, which means they can be integrated within every other application without publishing the source, only if the code inside the packages themself is altered the code has to be published. I have chosen this approach in the open sense of android, everyone is allowed to fork/clone my github repository and do whatever he likes with the code, i just want possible fixes or enhancements to be public available for everyone (also fell free to send me pull requests if you like), that's at least my view of what open source means, all should work together to make the best out of something, if they like to, otherwise, take what is already served or find someone able to do the needed changes.
Wait, two repositories? Why the hell...
Well, it's pretty simple, the library part already includes everything which is needed to get the work done, except of one thing, the main activity. It "only" includes an generic abstract activity which serves the fitting implementations to get it's job done without taking into account how the main activity is build up (be it tabed, with lists or whatever). To make your own UI set up on this activity it serves abstract methods you have to implement to handle e.g. viewing the download queue, updating it while downloading,...
But that's as well only a nice to have and should give you more possibilities if you want to use them, if your fine with the tabed UI I built, simply take the application repository, override the resources you like (if you want to) and your already done. I also splitted it up for easier maintenance, the library part is generic and if something needs to be done another way you're able to by simply deriving from the given interfaces or classes itself within your application, the application itself is always specific (even when the differences can be close to none), so i would have to integrate the changes of the library part allover again to the different branches, if it would be included in one single repository, that way all is detached and much easier to maintain.
Common Information
The source itself can be found here (Application), here (library) and here (gradle base for android studio), feel free to send me pull requests
The generic apk is also available at the play store (NOTE: don't flash files from it unless you use a GT-I9300, also note the broken downloads are intended to show the different states).
Changelog
The full list of commits can be viewed here (application) and here (library)
1.0:
Changelist support (listing of updated, added, removed and downgraded packages at startup)
no additional file or work needed, except the present version property at items which should be able to show as downgraded or updated, everything else is done by the app itself
0.9.7.1:
Fixed Index out of bounds crash
Fixed 2 nullpointer crashes
Started to add changelist of content support (changelist of added or removed items from the remoterepository)
0.9.7:
Improved install logic
Improved build.prop property reading
Fixed wrong finished state at service while downloads still processing
0.9.6:
Fixed showing of restore menu item directly after backup;
Fixed caching/loading of download queue onStop/onRestart;
Fixed removing of cached queue onDestroy;
Fixed crash at add file dialog if it is closed before choosing an activity;
Fixed wrong "all finished respond" of service while still processing;
0.9.5:
Completely revised the structure of buildbox (is now splitted into 2 repositories, one for the library [includes the whole logic, main views,...] and one for the implementation of the main activity and for resource overriding [MainActivity, TabAdapter, ...)
Added device filter property (can be applied at every level except at the detail items) (uses the ro.product.model build.prop property for comparsion)
Many fixes and enhancements
0.9.3:
Fixed adding files from storage
Fixed crash at startup without internet connection available
0.9.2:
Apk handling fix
Recovery script fix
0.9.1:
Revised Install procedure for apks (thx to lowveld for the hint)
Fixed root shell command execution (sry)
small additional changes
Android Studio Guide
Get the Code
Get base repository
Code:
mkdir BuildBox && cd BuildBox
git clone https://github.com/tectas/buildbox-gradle-base.git .
Get Library
Code:
mkdir BuildBoxLib && cd BuildBoxLib
git clone https://github.com/tectas/buildbox-lib . && cd ..
Get App
Code:
[SIZE="3"]mkdir BuildBoxApp && cd BuildBoxApp
git clone [url]https://github.com/tectas/buildbox[/url] . && cd ..[/SIZE]
Import into android studio
Prerequesits:
Android Studio (obviously)
Android SDK Build-Tools rev. 18.1.1
Android SDK Platform Api lvl 14 & 18
If the prerequesits are met, simply open android studio, choose import project, go to the path you cloned the base repository in, choose the build.gradle file within the base repository folder, confirm and do the same at the next screen and your done.
The only thing needed to build BuildBox is to choose the BuildBoxApp directory within the project view and make or run it.
Update and screenshots attached to the first post, changelog at second.
Update also published to play store, will be available in some hours.
For those wanting to see an real life implementation of this app check this: https://play.google.com/store/apps/details?id=at.tectas.buildbox.msteam
(that's the implementation for the ms team hd rom for the i9300, additional content/tabs will be added within the next days [just to avoid confusion, at the server, app updates [if they happen and probably will] got nothing to do with the content itself], but you already get a pretty good feeling how it is).
Any feedback appreciated.
Gesendet von meinem GT-I9300 mit Tapatalk 2
Update to 0.9.7
Update published, attached and changelog updated.
0.9.7.1 Bugfix update
Bumped the version to 0.9.7.1, it's just a small bugfix update, but there is already a big update in the pipeline, stay tuned.
Changelog as always in second post or directly at github.
Oh, and sry for my long absence.
1.0 is here
I finally made it to the first major revision!
1.0 is here and brings changelist support with it. Almost nothing needed to use it, simply add the version property at items you like to be shown as up or downgraded, that's it, everything else is done internally and more important localy. The versions items,... are stored at an local sqlite database, when the server file has been retrieved the database content get's updated and compared with the old content to determine which items got removed, added, updated or downgraded.
What next, well, even while it is out of beta, it still isn't 100% bugfree, but at least about 95% (and the missing bug is view related, download,... work fine) and there are still additional features i like to add, so stay tuned.
Android Studio setup
Small change:
Added a base repository for the gradle files to build the apk with android studio, respectively at the terminal.
NOTE: the base repository takes BuildBoxApp and BuildBoxLib as the 2 subfolders for the library and application, if you like to use different ones, you have to change the names within the settings.gradle.
I also added the needed gradle files to the library and app repository.
Last but not least added a small guide on how to check out the repository for simple import to android studio.
why is this thread soooooo dead?
hisname said:
why is this thread soooooo dead?
Click to expand...
Click to collapse
Because no-one seems to be really interested to use it unfortunately and i got other things to do currently^^
Gesendet von meinem GT-I9300 mit Tapatalk
THis should have been on the front page of xda. I never knew this app existed.
Thread closed by OP Request.
Please see the continuation of the project here: http://forum.xda-developers.com/showthread.php?t=2543806
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
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
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
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