Remove All Ads from XDA

Preferences Ownership issues?

14 posts
Thanks Meter: 0
By schnogg, Junior Member on 28th May 2009, 10:35 PM
Post Reply Email Thread
I have been using JF 1.43 for a few months and loved it. Seeing that Cupcake became mainstream, I took the plunge two days ago and have been having issues. I tried JF 1.51, then a mod, then theDudes, all with some problems. I tried wiping and keeping apps in regular memory just for testing. I finally got a clean install using TheDudesCupcake which worked ok for me. When I pushed my preferences back using adb, it just hung on the "android" screen.

I was getting annoyed at myself for not understanding what was going on . The confounding problem was that the set of prefs that I was restoring had adb disabled, so I couldn't get a logcat to see what was really happening.

Long story shorter...
After some more fresh installs, I think what I have sorted out is that all of my preferences files lost their correct ownership. I found that when I had a program that was crashing, I would log in to an adb shell, use ps to see what user the app was running as, for example app_82. Then, I would chown app_82.app_82 for the directory within /data/data. I would then to it recursively since busybox doesn't have -R for chown by issuing the command chown app_82.app_82 /data/data/* and then chown app_82.app_82 /data/data/

It fixes programs that were having problems accessing their sqlite3 DBs which was the clue in the logs that led me to this solution.

As I am going through I see that it improves the performance and error rate of programs by doing this. Obviously core functionality doesn't have the same ease of repair.

Is this the wrong thing to do here? Is there a better way to restore files after an upgrade so that this doesn't happen again?

I saw that someone wrote a python script to fix these permissions, though I don't understand where they got python to run on Android in the first place. Is there a shell script that can parse an app's uid and fix its supplemental files accordingly?

I tried searching, but may not have used good keywords about this issue.

Any help/advice/info would be appreciated.
29th May 2009, 07:07 PM |#2  
OP Junior Member
Thanks Meter: 0
The answer
This guy has a python scirpt that nicely spits out a shell script to fix all of them

"""Parse Android's /data/system/packages.xml file and spits out
shell code to fix UIDs.

This helps you fix "Package x.y.z has mismatched uid: 10089 on disk, 10079
in settings" errors.

from xml.dom import minidom

xmldoc = minidom.parse('packages.xml')

packages = xmldoc.getElementsByTagName('package')
ignored = []
for package in packages:
        userId = package.attributes['userId'].value
        is_shared = False
    except KeyError:
        userId = package.attributes['sharedUserId'].value
        is_shared = True

    # do not touch permissions of shared apks (they userid always seems to be 1000)
    if not is_shared:
        print "busybox chown %s:%s %s" % (userId, userId, package.attributes['codePath'].value) 

    for subdir in ('', 'databases', 'shared_prefs'):  # note we don't touch lib/
        print "busybox chown %s %s:%s /data/data/%s/%s" % (
            '-R' if subdir else '', userId, userId, package.attributes['name'].value, subdir)
Essentially, you can use adb pull to pull /data/system/packages.xml locally, run this python script on it, and then send each command back. One way to do this on *NIX is

adb pull /data/system/packages.xml . ; python fix.txt | xargs adb shell
Attached Files
File Type: txt fix.txt - [Click for QR Code] (978 Bytes, 6 views)
Post Reply Subscribe to Thread

chown, file, owner, permissions

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes