7

After dirty flashing my OnePlus One (bacon) from CM12.1 to CM13, I am constantly getting force close dialogs popup

Unfortunately the process com.android.phone has stopped

Logcat is filled with stacktraces like this:

Shutting down VM
FATAL EXCEPTION: main
Process: com.android.phone, PID: 13148
java.lang.RuntimeException: Unable to get provider com.android.providers.telephony.TelephonyProvider: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
    at android.app.ActivityThread.installProvider(ActivityThread.java:5205)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4797)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4737)
    at android.app.ActivityThread.-wrap1(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5466)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
    at android.database.CursorWindow.nativeGetString(Native Method)
    at android.database.CursorWindow.getString(CursorWindow.java:438)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
    at com.android.providers.telephony.TelephonyProvider$DatabaseHelper.getStringValueFromCursor(TelephonyProvider.java:993)
    at com.android.providers.telephony.TelephonyProvider$DatabaseHelper.copyPreservedApnsToNewTable(TelephonyProvider.java:905)
    at com.android.providers.telephony.TelephonyProvider$DatabaseHelper.onUpgrade(TelephonyProvider.java:641)
    at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256)
    at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
    at com.android.providers.telephony.TelephonyProvider.onCreate(TelephonyProvider.java:1457)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
    at android.app.ActivityThread.installProvider(ActivityThread.java:5202)
    ... 10 more

Once I somehow get rid of the persistent UI popup, it seems like com.android.phone is crashing at least 10 times per second, flooding logcat, and making it almost impossible to use the phone.

Is there any hope for a fix, or is a hard reset the only option?

  • 1
    Do clear data for com.android.providers.telephony (app goes by the label "Phone/Telephony storage/providers"). While you're on it, do it for Phone app as well (com.android.phone), restart and tell us the results. It appears that the database of com.android.providers.telephony cannot be read. It may be possible that you can't clear data for those apps. In that case, remove their /data/data directories from the face of earth. – Firelord Nov 25 '15 at 17:32
  • Clearing the cache (from recovery) may help – Ankush Nov 26 '15 at 2:06
  • I tried to remove these folders using Total Commander in root mode. I managed to delete but it didn't help. I made a reboot as well :( I can't call anyone... – Nickon Nov 30 '15 at 17:29
7

This was because of a change in the code.

As Firelord has said, clear the data for the apps, This can be done like so (this will also delete your SMS/MMS database, so make sure to backup them beforehand):

adb shell
rm -fr /data/data/com.android.providers.telephony/
rm -fr /data/data/com.android.phone/
exit

The -f flag is for force and -r flag means recursive.

  • That worked! Thanks. I also noticed this line in my logcat: TelephonyProvider: dbh.onUpgrade:+ db=SQLiteDatabase: /data/user/0/com.android.providers.telephony/databases/telephony.db oldV=1114120 newV=1376264 After removing the data dir and a reboot, the force close dialogs stopped. What was in the database? I noticed all my text messages are gone. Anything else? – friederbluemle Nov 27 '15 at 10:22
  • 2
    Readers: make sure to reboot the device after deleting those directories. – Firelord Dec 24 '15 at 10:33
  • Interesstingly it was not possible to delete the data from the App menu. I needed to reboot into TWRP and delete the folder there (the first one was sufficient) – reox Jun 24 '16 at 21:34
  • This method doesn't work for Cyanogenmod 14/Android 7 – Adem Nov 14 '16 at 0:11
  • @Adem Nov , whats the logcat? – Aaahh Nov 20 '16 at 0:32
6

I had the same problem while upgrading to CM13 from CM12.1. You can solve this problem without deleting your database files and therefore losing data as suggested in the other answers.

The culprit seems to be broken database onUpgrade code in the TelephonyProvider of CM. The ppp_number column of the carriers table does not exists, but the upgrade code assumes it already exists.

I solved it by copying the telephony.db to my local Linux machine and reverting the database version to version 16 << 16 | 6 = 1048582 to force the upgrade code to add the missing columns. The ALTER TABLE statements in the linked code are guarded by try-catch-blocks, so that it doesn't matter if some of the columns already exists. Boot the phone into recovery (e.g. TWRP) to have adb root priviliges and avoid lock races with the Android Runtime which is constantly trying to start the telephony provider.

% adb pull /data/user/0/com.android.providers.telephony/databases/telephony.db
% adb pull /data/user/0/com.android.providers.telephony/databases/telephony.db-journal

Create backups

% cp telephony.db telephony.db.bak
% cp telephony.db-journal telephony.db-journal.bak

Then open the database with sqlite and set the version

% sqlite3 telephony.db
sqlite> PRAGMA user_version = 1048582;
sqlite> .quit

Upload the changed database back to the device and fix permissions

% adb push telephony.db /data/user/0/com.android.providers.telephony/databases
% adb shell
~ # cd /data/user/0/com.android.providers.telephony/databases
/data/data/com.android.providers.telephony/databases # rm telephony.db-journal
/data/data/com.android.providers.telephony/databases # chown radio:radio telephony.db
/data/data/com.android.providers.telephony/databases # chmod 660 telephony.db

You could also try this on the broken system, which I wouldn't recommend. You would probably have to become root with adb root in order to copy and modify the files with adb.

  • Excellent attention to detail! The explanation is much appreciated. Like @gedenkt, I followed these instructions, but they didn't work for me either. :-/ Simply deleting these two *.db* files did solve the problem though. – Tommy Stanton Jul 17 '16 at 7:31
  • You can use the "vacuum" command to merge the journal to the db. $ sqlite3 telephony.db VACUUM – tlwhitec Aug 28 '16 at 20:18
4

I tried Sebastian's solution, but the error persisted. The accepted answer results in losing all your SMS, therefore was not an option for me. However, after booting into recovery mode and deleting the files

/data/data/com.android.providers.telephony/databases/telephony.db
/data/data/com.android.providers.telephony/databases/telephony.db-journal

the phone worked perfectly again. The files seem to contain only auto-generated data, so it is safe to delete them.

  • How can I delete certain files in recovery mode? – Hinrich May 9 '16 at 5:37
  • 1
    @Hinrich If you use a full-featured recovery like TWRP, you can use the built-in file manager. – Enigma May 10 '16 at 20:36
  • Here's a bit more detail on TWRP. In my case, I'm running Safestrap 3.75 (TWRP v2.7.1.0), and I had to use the "Mount" button, then check "Data," then go back, then use the "Advanced" button to use the "File Manager" button (then navigate, starting from the "data" folder). – Tommy Stanton Jul 17 '16 at 7:46
1

If you are unable to get in to an adb shell or remove the directory from your phone because it is unusable you can also remove the directory from whitin TWRP recovery.

  • 1
    Please add the necessary directions to do that in your answer. What if the OP doesn't have TWRP? – Tamoghna Chowdhury Jan 18 '16 at 9:05
0

Had the same poblem after updating from CM12 to CM13. Here is how I was able to fix it:

I removed these two directories

/data/user/0/com.android.providers.telephony
/data/data/com.android.phone/

completly from my phone (Nexus 5). I used ES Explorer to do so, I had to turn on Root Mode and Show Hidden Files to be able to delete files in that directory.

Call log and SMS are still there, cannot see any disadvantages resulting from deleting those directories. Everything seems to work smooth again.

protected by Community Jun 12 '16 at 11:32

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.