EricTangYY / roottools

Automatically exported from code.google.com/p/roottools
0 stars 0 forks source link

Issue with RootTools.copyFile #33

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. RootTools.copyFile(source, dest, true, true);

--------------------------------------------------------------------------------
--

What is the expected output? What do you see instead?
1. I tried "copyFile" on two database files and that worked.
2. But When I tried to open those databases in android using 
"SQLiteDatabase.openDatabase(database, null, 
SQLiteDatabase.NO_LOCALIZED_COLLATORS);" the first database opened without any 
issue but the second give me SQLiteException that unable to open, I tried it 
many times but no luck.
3. But when I copied the second database by executing "cat" command via 
RootTools with "su" and then tried to open the database it works like charm.

--------------------------------------------------------------------------------
--

What version of the product are you using? On what operating system?
1. RootTools-2.6
2. Android - 2.3.6
3. su binary - v3.1.1(17)
4. busy box - v1.21.0
5. MyOS - Ubuntu 13.04

--------------------------------------------------------------------------------
--

Please provide any additional information below.
It seems like that "copyFile" after copying the file has maintained a lock or 
something on that file but seriously I am no expert, that is what I observed.

Please let me know what else info I can provide...
Seriously this tool has helped me a lot.

Original issue reported on code.google.com by shrewd.h...@gmail.com on 9 May 2013 at 6:20

GoogleCodeExporter commented 8 years ago
It's probably the permissions. Did you chmod the copied file to have the 
correct permissions necessary for your application to read it?

Original comment by Stericso...@gmail.com on 9 May 2013 at 6:43

GoogleCodeExporter commented 8 years ago
No I did not do "chmod" on any of the database files but if this is the case 
then how come the first database is working fine but not the second. As both 
are copied from same location to a same folder.

Original comment by shrewd.h...@gmail.com on 10 May 2013 at 3:52

GoogleCodeExporter commented 8 years ago
Adding to above comment:
using "cat" without "chmod" made the second database work.
So, I dont think its chmod issue.

Original comment by shrewd.h...@gmail.com on 10 May 2013 at 8:00

GoogleCodeExporter commented 8 years ago
I'd guess it's a owner issue.

When you copy the database using RootTools you are copying the file as root 
user. Therefore the new database will be owned by user "root".

When you do cat (I assume using adb shell) you are also user "root". Therefore 
you anyway can read any file. However you need to change the ownership to the 
app user who will open the database. (Android creates a new user for each app)

Maybe you can also open the database if you make it world read- and writeable 
(chmod a+r, chmod a+w). But maybe you then just run into security issues and 
Android won't allow this. You can give it a try first, because finding out the 
user for an app is not trivial.

Original comment by tob...@schulz-hess.de on 4 Jul 2013 at 8:40

GoogleCodeExporter commented 8 years ago
I have another problem with move/copy files in my Android app. If I copy a file 
with spaces in name (hello world) for me it didnt work but without spaces it 
works (helloworld).

Original comment by dnielfe on 3 Oct 2013 at 11:10