samsung galaxy s forum
Find Your Forum
  
Welcome, Guest. Please login or register.

News: Do you like Samsung Galaxy S?    
Advanced search
Scratch-Proof your Samsung Galaxy S                      Best Screen Protector for Samsung Galaxy S Cheap Cell Phone Accessories
Pages: [1]   Go Down
Print
Share this topic on AskShare this topic on Del.icio.usShare this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on LiveShare this topic on MySpaceShare this topic on RedditShare this topic on SquidooShare this topic on StumbleUponShare this topic on TwitterShare this topic on YahooShare this topic on Google buzz
Author Topic: Lost all settings after battery change  (Read 6969 times)
domdomsam
Jr. Member
**

Karma: +0/-0
Offline Offline

United Kingdom United Kingdom

Posts: 3


View Profile
« on: April 09, 2011, 05:26:34 PM »

Hi
I've bought an extra battery for my phone, not an original one I must confess. So I turned off the phone, swapped batteries and after turning it back on again with the new battery in I realised that all my settings, mail accounts, contacts, calendar settings, wallpaper, etc. are gone. Basically it looks like the phone reset itself to the factory settings. To be honest I don't believe it is  possible to recover those settings but I'm very curious what happened here so I could avoid this to happen again
Cheers
Best Screen Protector
domdomsam
Jr. Member
**

Karma: +0/-0
Offline Offline

United Kingdom United Kingdom

Posts: 3


View Profile
« Reply #1 on: April 10, 2011, 02:10:00 AM »

Now, it's getting even better. No matter what battery I have in the phone, after turning it on it shows some errors and forces some programs to close. It looks like I have to remove all extra apps and install them again. Great. Just how on earth battery change can cause so much truoble?
Best Screen Protector
Iztok67
Jr. Member
**

Karma: +0/-0
Offline Offline

Slovenia Slovenia

Posts: 14


View Profile
« Reply #2 on: April 13, 2011, 11:58:57 AM »

Same thing hapened to me (FC, not battery) and ONLY solution was factory reset. Sorry for bad news Crying
Best Screen Protector
FlorentBL
Jr. Member
**

Karma: +1/-0
Offline Offline

France France

Posts: 11


View Profile
« Reply #3 on: April 18, 2011, 04:42:55 PM »

Same thing happened to me... twice  Angry (see http://www.samsunggalaxysforum.com/media-problems/battery-removal-cause-configuration-lost-and-applications-stopped-unexpectedly/ for description)

I have looked around in different forums on SGS, and it seems that this kind of symptom is not as rare as it should be.

Can you elaborate on your configuration? I'd like to compare with mine.
Best Screen Protector

Samsung Galaxy S formerly locked by Orange
Froyo XWJS8
Go Launcher
domdomsam
Jr. Member
**

Karma: +0/-0
Offline Offline

United Kingdom United Kingdom

Posts: 3


View Profile
« Reply #4 on: April 20, 2011, 11:17:03 AM »

It's GT-I900, 2.2.1 Firmware, FRIYO.BVJS4
Hope that helps

My guess is that I accidently hard reset the phone. Maybe I took the battery out too soon whiile the phone wasn't completely switched off.
Best Screen Protector
FlorentBL
Jr. Member
**

Karma: +1/-0
Offline Offline

France France

Posts: 11


View Profile
« Reply #5 on: April 20, 2011, 07:16:37 PM »

That may be the point (removing battery too soon).

After further investigation, it appears that the guilty one is a file named packages.xml. Under some cicumstances, android recreates it... and fails to do it properly.

After that, the userid of apps are corrupted and the phone behaves strangely. Apps that have good userid are ok. Apps that have their userid changed are forced to close.

Some scripts can repair the phone. But you need a rooted phone for that. Those files change owners of the previously created files to make them match with the new apps userid.

The following shell code worked for me


#!/sbin/sh
#
# permfixer.sh - fixes permissions on Android data directories after upgrade
# shade@chemlab.org
#
# thanks to: http://blog.elsdoerfer.name/2009/05/25/android-fix-package-uid-mismatches/
#
# v1.1 - work with protected apps

CODEPATH="";
UID="";
PACKAGE="";
IS_PROTECTED="0";

DEVICE="$(grep /system /proc/mounts | cut -f1 -d" ")"
mount -o remount,rw "${DEVICE}" /system || (echo "Unable to remount /system" && exit 1)

cat /dbdata/system/packages.xml | grep "^<package" | grep userId | while read line;
do
   for i in `echo $line | tr " " "\n"`;
   do
      if [ $i = "<package" ];
      then
         CODEPATH="";
         PACKAGE="";
         UID="";
      elif ( echo $i | grep "^codePath" > /dev/null );
      then
         CODEPATH=`echo $i | cut -d \" -f 2`;
      elif ( echo $i | grep "^name" > /dev/null );
      then
         PACKAGE=`echo $i | cut -d \" -f 2`;
      elif ( echo $i | grep "^userId" > /dev/null );
      then
         UID=`echo $i | cut -d \" -f 2`;
      fi;
   
      APPDIR=`echo $CODEPATH | cut -d / -f 3`;
      if [ "$APPDIR" = "app-private" ];
      then
         IS_PROTECTED=1;
      else
         IS_PROTECTED=0;
      fi

   done;

   echo "Fixing permissions for: $PACKAGE";

   if [ $IS_PROTECTED = "1" ];
   then
      busybox chown 1000:$UID $CODEPATH;
   else
      busybox chown $UID:$UID $CODEPATH;
   fi;

   busybox chown $UID:$UID /data/data/$PACKAGE;
   cd /data/data/$PACKAGE
   for dir in * ;
   do
      test="$(ls -d -l /data/data/$PACKAGE/$dir | cut -f2 -d" ")"
      if [ "${test}" != "system" ]; then
         if [ -d /data/data/$PACKAGE/$dir ];
         then
            busybox chown -R $UID:$UID /data/data/$PACKAGE/$dir;
         fi
      fi;
   done   
   ls -a -l -d /data/data/$PACKAGE
   ls -a -l /data/data/$PACKAGE
done;

mount -o remount,ro "${DEVICE}" /system || (echo "Unable to remount /system" && exit 1)

exit 0
Best Screen Protector
arsenic
Newbie
*

Karma: +0/-0
Offline Offline

Israel Israel

Posts: 1


View Profile
« Reply #6 on: May 14, 2011, 11:08:49 AM »

Hi FlorentBL,

I'm sorry for a newbie question Embarrased , but how did exactly this script solve the problem for you?

When do you run it?
Is it a postmortem script that you run after a crash? Or is it a preventive script that you run after each install?

Does it recover lost applications? Or does it recover only the applications that didn't get lost, but only started crashing?

Could you, please, elaborate a little?

Are you familiar to some build of Android that already has a built-in solution for this problem?

Any help will be highly appreciated.
Thank you a lot in advance.
Best Screen Protector
FlorentBL
Jr. Member
**

Karma: +1/-0
Offline Offline

France France

Posts: 11


View Profile
« Reply #7 on: May 15, 2011, 02:19:31 PM »

Hi FlorentBL,

I'm sorry for a newbie question Embarrased , but how did exactly this script solve the problem for you?

When do you run it?
Is it a postmortem script that you run after a crash? Or is it a preventive script that you run after each install?

It's a script to run after an install or an event that causes unexpected "force close".
Symptoms : several of your applications that previously worked cannot be launched and "force to close" pops up for each one.
Cause : all applications are described in a Packages.xml file, which is either altered or have been erased by an install, a crash, or things like that. System tries to rebuild the file but fails to do it properly.
This script has to be run once and it will hopefully restore normal functionning by reenabling the correct permissions for every application. But it has to be run as root, and so you need to root your phone in order to execute it.

Quote
Does it recover lost applications? Or does it recover only the applications that didn't get lost, but only started crashing?

Could you, please, elaborate a little?

It doesn't recover lost applications.
Quote
Are you familiar to some build of Android that already has a built-in solution for this problem?

Any help will be highly appreciated.
Thank you a lot in advance.

Since I posted the script, I discovered that the bug was a known one (see
http://code.google.com/p/android/issues/detail?id=9976). It should be corrected in Android 2.3. It originates in a false assumption of the kernel (actually the guy that programmed it ;-) that the physical writes on hardware were done sequentially, which is not the case, specially on an sd card.

I here translate a mini tutorial I have posted on a french forum. Your phone is supposed rooted.

1. Open a shell either on phone or by using adb shell on your connected PC

2. Tape su command and accept root permissions on the phone.

3. Copy/paste this (long) command:

Code:
/system/bin/sh <<EOF
#!/sbin/sh
#
# permfixer.sh - fixes permissions on Android data directories after upgrade
# shade@chemlab.org
#
# thanks to: http://blog.elsdoerfer.name/2009/05/25/android-fix-package-uid-mismatches/
#
# v1.1 - work with protected apps

CODEPATH="";
UID="";
PACKAGE="";
IS_PROTECTED="0";

DEVICE="$(grep /system /proc/mounts | cut -f1 -d" ")"
mount -o remount,rw "${DEVICE}" /system || (echo "Unable to remount /system... have you typed: su ?" && exit 1)

for dir in /dbdata/system /data/system; do
  PACKAGES="${dir}/packages.xml"
  [[ -f "${PACKAGES}" ]] && break
done

cat "${PACKAGES}" | grep "^<package" | grep -i userId | while read line;
do
for i in `echo $line | tr " " "\n"`;
do
if [ $i = "<package" ];
then
CODEPATH="";
PACKAGE="";
UID="";
elif ( echo $i | grep "^codePath" > /dev/null );
then
CODEPATH=`echo $i | cut -d \" -f 2`;
elif ( echo $i | grep "^name" > /dev/null );
then
PACKAGE=`echo $i | cut -d \" -f 2`;
elif ( echo $i | grep "^userId" > /dev/null );
then
UID=`echo $i | cut -d \" -f 2`;
elif ( echo $i | grep "^sharedUserId" > /dev/null );
then
UID=`echo $i | cut -d \" -f 2`;
fi;

APPDIR=`echo $CODEPATH | cut -d / -f 3`;
if [ "$APPDIR" = "app-private" ];
then
IS_PROTECTED=1;
else
IS_PROTECTED=0;
fi

done;

echo "Fixing permissions for: $PACKAGE";

if [ $IS_PROTECTED = "1" ];
then
busybox chown 1000:$UID $CODEPATH;
else
busybox chown $UID:$UID $CODEPATH;
fi;

for datadir in /data/data /dbdata/databases; do
if [ -d $datadir/$PACKAGE ]; then
busybox chown $UID:$UID $datadir/$PACKAGE;
cd $datadir/$PACKAGE
for dir in * ;
do
test="$(ls -d -l $datadir/$PACKAGE/$dir | cut -f2 -d" "| cut -f1 -d"_")"
if [ "${test}" = "app" ]; then
if [ -d $datadir/$PACKAGE/$dir ];
then
busybox chown -R $UID:$UID $datadir/$PACKAGE/$dir;
else
busybox chown $UID:$UID $datadir/$PACKAGE/$dir;
fi
fi;
done
ls -a -l -d $datadir/$PACKAGE
ls -a -l $datadir/$PACKAGE
fi
done;
done;

mount -o remount,ro "${DEVICE}" /system || (echo "Unable to remount /system" && exit 1)

exit 0
EOF

Your applications should now work.

Actually, there is also a fix_permission script in most installations, but recent changes in the Packages.xml location have broken it. I have reported that, but it can take a little to be fixed.

I hope this helps.
Best Screen Protector
LarryBrown
Newbie
*

Karma: +0/-0
Offline Offline

United States United States

Posts: 2


I hope you enjoy my posts.


View Profile WWW
« Reply #8 on: June 09, 2011, 03:52:41 AM »

1: This problem is also discussed in this thread: http://www.samsunggalaxysforum.com/media-problems/battery-removal-cause-configuration-lost-and-applications-stopped-unexpectedly/
I have a post over there with info that I'll not repeat here.  Angel
2: Let's call this problem the "packages.xml permissions problem."  Sticking out tongue
3: The battery has nothing to do with it. It's a bug in Android. Crying
4: If you get stuck in a loop you can hold down the "home" key to get to the task manager and from there you have some control.  Cool
5: NOTICE: The script reproduced in this thread is a little old, it's been modified and improved since then and has some enhancements specifically for the Galaxy S. Here's an updated version (v1.4E): http://pastebin.com/rLWduRWc   Angel


Let's all give a big round of applause (including from me because he got me going) to FlorentBL for posting that script. The script also worked for me. However FlorentBL is such a genius that it's difficult for him to understand arsenic's newbieness, so I've written some expanded instructions.  Angel

The code that you see is a Linux shell script, which means that it's like an old DOS batch file. You might think that such batch files are old fashioned but they aren't. Especially in Linux, scripts like this are a main way of doing things and the UNIX scripting language is awesomely powerful in contrast to the old klunky DOS scripting, which was written by one guy in his spare time after work and on weekends. To run the script, you'll need to copy/paste the code into a text file and save it on your SD card, and then run it. To run it you have to go to a command prompt and run it from there with a command. Otherwise there is an app called "GScript Lite" that  will browse to the script and run it. I hope the following comments will help you, I suggest that you copy the comments into the script and save them with the script for future reference, when you have the problem AGAIN!  Angry

I tried to copy/paste the script from this thread while working on my phone, but I was not able to do that so I had to use the computer to make the file and then transfer it over. The "pastebin" link that I referenced up above might help you if you are working on your phone.  Lips Sealed

# This script is needed when the packages.xml file gets corrupted on the phone
# (happens from time to time) and Android tries to rebuild it and gets the permissions
# wrong. Symptoms are: Apps suddenly start crashing after a reboot,
# apps can't save their settings, apps lose data. The problem is that the apps lose
# permission to get at their data stores. This script scans the packages.xml file,
# ferrets out the userID for each app as well as the location of its data store folder,
# and than sets permission on the data folder to allow the app's UserID to have access.
# The script uses busybox (both implicitly and explicitly) and needs BusyBox v1.19
# (which is the first version to support the "cut" command). The script looked for
# packages.xml in /dbdata/system, but on my Samsung Galaxy S Epic it was found in
# /data/system instead, so I had to edit that path in the script.
# Remember that Linux is exhaustively case sensitive, so if you have Packages.xml in the
# script when you need packages.xml, it won't work.
# You'll need most or all of the following things: root, a text editor app,
# a file manager app,
# BusyBox v1.19 or later, BusyBox Installer (the only way to get BusyBox v1.19), some way to transfer
# files from your computer to your phone (like a USB cable or an ftp server on your phone-I use SwifTP - it's awesome),
# and either GScript Lite or a "terminal emulator" app.
# The script needs super-user (su) access, so your phone will need to be rooted. There's
# no downside to rooting your phone, so just do it BEFORE you get hosed by this problem.
# If you have been asking for the last
# year "Why would I need to root my phone?" here ya go.
# You can launch the script from the Android GUI by downloading and using app GScript Lite,
# or you can launch it from the Android command line by downloading a so-called
# "terminal emulator" app (which may be the right name technically but it's really just a
# "command line interface" app), and then entering the following four commands on the
# command line (you have to hit "return" on the keyboard after you enter each command to
# make it execute):
# -----------------------------
# $ su
# # cd /mnt/sdcard/
# # pwd
# # sh ./permfixer.sh
# -----------------------------
# Those commands assume that you saved the "permfixer.sh" file in the root folder of
# your SD card.
# In the above commands, on each line, ignore the first # sign, don't type it on the
# command line, that's just a comment character that has to be the first character of
# all these comment lines in this script. The second character (either $ or #) is the
# Linux command line prompt, the $ is the normal Linux command line prompt, so you don't
# type that $ or # either. The "su" command means "switch to super-user," and if it works
# Linux will switch the prompt from a $ to a # to remind you that you are in super-user
# mode, that's why the other three lines start with a # prompt. The "cd" command means
# "change working directory" and changes it so that you are working at the root folder of
# your SD card. If that line does not work for you, you may have to change the "/mnt/sdcard"
# path (which worked for me) to something else. The "pwd" command means
# "print working directory" and will print out your current working directory, which will
# allow you to verify that the "cd" command you entered worked properly. The "sh" command
# means "Linux shell" and will cause Linux to execute the script file. The "./" in that
# line means that the script will be found in the current working directory, without that
# Linux failed to find the script for me.
# So nutshell instructions for a rooted phone are:
# Use your computer to copy the script into a text file using Notepad.
# Save the Notepad file to your computer
# transfer the file to your phone's SD card.
# download and install GScript Lite.
# Use Gscript Lite to browse to the script on your phone and run it.
# The script will print interesting info that you can read and decide if it worked or not.
# Repeat efforts until it works
Best Screen Protector
FlorentBL
Jr. Member
**

Karma: +1/-0
Offline Offline

France France

Posts: 11


View Profile
« Reply #9 on: June 12, 2011, 04:12:24 PM »

5: NOTICE: The script reproduced in this thread is a little old, it's been modified and improved since then and has some enhancements specifically for the Galaxy S. Here's an updated version (v1.4E): http://pastebin.com/rLWduRWc   Angel

The script you point out won't work in recent configurations, because packages.xml place has changed ;-( That's why I've made my own script. I will patch it asap.

Quote
Let's all give a big round of applause (including from me because he got me going) to FlorentBL for posting that script. The script also worked for me. However FlorentBL is such a genius that it's difficult for him to understand arsenic's newbieness, so I've written some expanded instructions.  Angel

Thank you for the applause and sorry for the newbies. It's not genie, it's lack of time ;-)
Best Screen Protector
Pages: [1]   Go Up
Print

Jump to:  

Got a new phone? Find the forum here






Thanks for visiting Samsung Galaxy S Forum

















CopyRight 2010 Samsung Galaxy S Forum
Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC
Sitemap

Galaxy S3 | Galaxy Note | Galaxy Nexus | Kindle Fire | Atrix 4G | Motorola Xoom | Windows Phone 7
Nokia Lumia | Top Hosts | Samsung Galaxy Tab | Samsung Galaxy S2 | Samsung Galaxy S | Samsung Wave
HTC Evo 3D | HTC Evo 4G | HTC Incredible | HTC Incredible 2 | HTC Incredible S | HTC Thunderbolt
Motorola Droid Razr
| HTC Desire | HTC Desire HD | HTC Desire Z | HTC Desire S | HTC Wildfire
Motorola Droid | Galaxy Indulge | Nokia N8 | Droid Charge | Droid X | Droid X2 | Droid 2| Droid 3 | Fascinate
HTC Sensation | HTC Flyer | LG Revolution | Asus Transformer | Xperia Play | iPhone 4 | Nexus S | Droid Bionic
HTC One | HTC Wildfire S | HTC Droid Eris


This is an Un-Official fan based Website. The views expressed on this website are solely those of the proprietor, or contributors to the site, and do not necessarily reflect the views or opinions of the parties it covers, and is not affiliated with, endorsed or sponsored by parties involved.
If you have a problem with any of the content posted on this website, please contact "sales@verticalscope.com"
Term of Use | Privacy Policy | BlackRain 2006 by, Crip