2

I have a Moto G 4th Edition (harpia) running LineageOS 14.1 nightly. I was trying to debug some issues with its MMS and I used Titanium Backup to take a backup of the APN settings because I was about to follow some tutorials and I wanted to know I could certainly undo them if I needed to. I wasn't able to fix the problem, so I tried to restore using Titanium Backup. When I was restoring the settings, it asked me if I wanted to restore App, Data, or App+Data. Without thinking too much about it, I clicked "App+Data". Then, I went back to the APN settings page to see if the APN settings I had were restored. When I clicked on an APN, it crashed. I think the exception in question is:

06-27 18:44:22.454  2067  3374 E DatabaseUtils: java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.TelephonyProvider uri content://telephony/carriers/1265 from pid=4901, uid=1000 requires the provider be exported, or grantUriPermission()
06-27 18:44:22.454  2067  3374 E DatabaseUtils:     at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:608)
06-27 18:44:22.454  2067  3374 E DatabaseUtils:     at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:483)
06-27 18:44:22.454  2067  3374 E DatabaseUtils:     at android.content.ContentProvider$Transport.query(ContentProvider.java:212)
06-27 18:44:22.454  2067  3374 E DatabaseUtils:     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
06-27 18:44:22.454  2067  3374 E DatabaseUtils:     at android.os.Binder.execTransact(Binder.java:565)

(But another suspicious-looking message I see is 06-27 18:44:20.760 2067 5631 W ContextImpl: Failed to ensure /data/user_de/0/com.android.settings/databases: mkdir failed: EACCES (Permission denied).) I reached out to Titanium Track via their "Contact Us" page but haven't gotten a response so far (it's only been about 36 hours). In the meantime, I noticed that I also can't even use the Messaging app on my phone. When I try to enter an SMS conversation, it crashes. I think the exception for that is:

06-27 18:43:54.101  1141  2774 W ActivityManager: Permission Denial: opening provider com.android.providers.telephony.SmsProvider from ProcessRecord{890eeb3 3530:com.android.messaging/u0a73} (pid=3530, uid=10073) that is not exported from uid 1001
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel: wtf
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel: SyncMessagesAction: unexpected failure in scan
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.telephony.SmsProvider from ProcessRecord{890eeb3 3530:com.android.messaging/u0a73} (pid=3530, uid=10073) that is not exported from uid 1001
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.os.Parcel.readException(Parcel.java:1684)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.os.Parcel.readException(Parcel.java:1637)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4199)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.app.ActivityThread.acquireProvider(ActivityThread.java:5534)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2239)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1520)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.content.ContentResolver.query(ContentResolver.java:518)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.content.ContentResolver.query(ContentResolver.java:475)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.mmslib.a.VL(SourceFile:40)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.sms.i.ahs(SourceFile:1498)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.sms.DatabaseMessages$SmsMessage.getProjection(SourceFile:120)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.datamodel.action.q.<init>(SourceFile:450)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.datamodel.action.m.Lg(SourceFile:131)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.datamodel.action.SyncMessagesAction.Jf(SourceFile:293)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.datamodel.action.SyncMessagesAction.IU(SourceFile:244)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.datamodel.action.BackgroundWorkerService.Kk(SourceFile:146)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at com.android.messaging.datamodel.action.BackgroundWorkerService.onHandleIntent(SourceFile:123)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:68)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.os.Handler.dispatchMessage(Handler.java:102)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.os.Looper.loop(Looper.java:154)
06-27 18:43:54.103  3530  3843 F MessagingAppDataModel:     at android.os.HandlerThread.run(HandlerThread.java:61)
06-27 18:43:54.103  3530  3843 E MessagingAppDataModel: SyncMessagesAction: unexpected failure in scan

Based on these two exceptions, I'm guessing that I shouldn't have restored the app but just the data, and some important metadata of the app got lost or wasn't restored correctly. However I'm not sure where I would find that metadata or what it should be.

  • I tried TWRP "Restore Contexts".
  • Someone on the /r/Android Discourse suggested I dirty load the same ROM. Unfortunately support for LineageOS on my handset is discontinued and there's no images to download. I tried re-using the latest update from /data/lineageos_updates, but that didn't fix my problem.
  • I took a backup of my phone in its current (semi-working) state and I've tried wiping data for the messaging app, the telephony provider, the settings app, but I still have the same crashes.

Has anyone seen these exceptions before? What are these providers? Where are they kept on a normal Android system? What creates them, and is there a way to manually cause them to be created?

  • Looks like for some reason the permissions (here: ownership) of the app got messed up. You could try figuring out where (what file; most likely the APK) and fix that – or simply perform a "dirty flash" of the very same ROM, which should fix it implicitly ("dirty" means w/o factory reset etc, so all your apps, configurations and such are not touched). And yes, with system apps, usually only restore data ;) – Izzy Jun 28 at 6:15
  • I've tried doing a "dirty flash" several times (wipe the system partition, sideload the last available Lineage 14.1 for my device, sideload a gapps package with wiping cache and Dalvik cache). It doesn't solve the problem. (Not only that, but when I do it, I start getting "Calendar has stopped" errors.) – Ethan Jun 28 at 13:48
3

OK, so I figured it out. For posterity, here's the process I went through.

  • I took a complete backup using TWRP before I made anything any worse.

  • I was fortunate in that I had a pretty clear idea what I had done to make everything go wrong (restore "App+Data"). That meant I could do it again and try to get a sense of what the app had done. I used find on the device to get a list of all the files that got changed when I did the bad restore. (busybox find doesn't have -mmin so I did touch somefile; [do the bad thing]; find . -newer somefile.) This gave me a list of "suspect" files: some stuff in the data partition /data/data, some stuff in /data/misc/profiles that I couldn't figure out; some stuff in /data/app incl. an APK and ODEX stuff; and a handful of files in /data/system: users/0/runtime-permissions.xml, users/0/package-restrictions.xml, packages.xml, packages.list, and a few others.

  • In Titanium Backup, the thing that was being restored ("Phone and Messaging") seems actually to be an alias for com.android.providers.telephony -- when you click "Open system details", that is the "App" that comes up. This sorta matches the errors from the logs.

  • I found https://github.com/TilesOrganization/support/wiki/How-to-use-ADB-to-grant-permissions and https://gist.github.com/Arinerron/1bcaadc7b1cbeae77de0263f4e15156f which were interesting. When I tried to adb pm dump the com.android.providers.telephony package, I saw that it had WRITE_APN_SETTINGS: granted=true. This increased my confidence that the permissions weren't really the issue.

  • I also looked through the /data/data for the com.android.providers.telephony package. Everything was owned by system rather than by an app-specific account, but maybe that was OK. restorecon didn't do anything on any of those files either.

  • Among the things that I tried in order to get stuff working again was to flash LineageOS 15.1 from a random post on XDA-Developers. That led to other problems but at least my messaging app didn't crash any more. This gave me a "known good" state. From this I adb pulled a bunch of stuff from /data: system, misc, app, user_de, data.

  • I grepped through all the files looking for telephony since I was pretty sure that was the thing that had been restored wrong. Nothing in runtime-permissions.xml had telephony in it (and I didn't really suspect permissions anyhow because of the WRITE_APN_SETTINGS thing, above). package-restrictions.xml seemed OK -- there was only one entry that referenced the providers package and there was nothing in it except stopped="true". (telephony occurred in some other entries for other packages, but always under enabled-components, so that seemed OK to me.) telephony did show up in packages.xml but I didn't understand enough of the data format to know what it was saying. (Attributes present include ft, it, ut, and isOrphaned.)

  • By comparing the packages.xml from the "broken" 14.1 install and the one from the "working" 15.1 install, I made some progress. From the 14.1 version:

    <package name="com.android.providers.telephony" codePath="/data/app/com.android.providers.telephony-2" nativeLibraryPath="/data/app/com.android.providers.telephony-2/lib" publicFlags="1007402629" privateFlags="8" ft="16b952851c0" it="11e8f7d4c00" ut="16b95285980" version="25" sharedUserId="1001" installer="com.android.vending" isOrphaned="true">
        <sigs count="1">
            <cert index="1" />
        </sigs>
        <perms>
        <!-- Some stuff that I disregarded because again I didn't think this was a permissions issue -->
        </perms>
        <proper-signing-keyset identifier="1" />
    </package>
<!-- much later... -->
    <updated-package name="com.android.providers.telephony" codePath="/system/priv-app/TelephonyProvider" ft="11e8f7d4c00" it="11e8f7d4c00" ut="11e8f7d4c00" version="25" nativeLibraryPath="/system/priv-app/TelephonyProvider/lib" sharedUserId="1001" />

From the 15.1 "working" version:

    <package name="com.android.providers.telephony" codePath="/system/priv-app/TelephonyProvider" nativeLibraryPath="/system/priv-app/TelephonyProvider/lib" publicFlags="1007402501" privateFlags="8" ft="11e8e4f2c40" it="11e8e4f2c40" ut="11e8e4f2c40" version="27" sharedUserId="1001" isOrphaned="true">
        <sigs count="1">
            <cert index="1" />
        </sigs>
        <perms>
        <!-- snip -->
        </perms>
        <proper-signing-keyset identifier="97" />
    </package>

OK! It seems like the codePath and nativeLibraryPath are screwed up. Possibly the ft, it, and ut fields too. I still don't really know what those are for, but they correspond to fields in other apps in the packages.xml file. Maybe they represent some kind of cross-application sharing. Anyhow, I used vim on the device to make some changes -- first removing stopped from package-restrictions.xml, and (when that didn't work) editing packages.xml to merge the two entries into one <package> entry with the codePath, nativeLibraryPath, ft, it, and ut fields from the <updated-package> element (and then deleting <updated-package>). I restarted the phone after each change to see if it worked. I can edit APNs/read SMS messages again so that's nice.

I was able to find https://dzone.com/articles/depth-android-package-manager which says that the ft, it, and ut fields represent timestamps so probably they don't correspond to anything in particular. Probably the paths were the essential change.

Overall I would say that I think Android could one day become as approachable and user-friendly as Linux, given enough effort. I don't even think it would require anything difficult -- just more effort documenting how things work from the user/system administrator's perspective (to balance out all the extant documentation about how things work from the app developer's perspective). A good example would be "What is the package.xml file and what do ft, it, and ut stand for". Also it would be great if the source of truth for Android distributions wasn't an ad-encrusted forum like XDA, but hey, one step at a time.

  • Looks like TiBu restored the APK as user app and then messed up the XML consider it being a user app – thus ignoring the "system status". Apart from the fact we both know by now one shouldn't restore "app + data" on a system app, as TiBu offers this option it shouldn't mess it up. Glad to see you've solved it finally; but it would certainly be a good idea reporting this to Joël (the TiBu dev) so he can fix it. Thanks for sharing your evaluation and solution!!! – Izzy Jun 28 at 17:53
0

Today, I made the same mistake (restoring the whole 'Phone and SMS Storage' app with Titanium Backup) and solved it by

  • uninstalling it from within TitaniumBackup (a warning appeared, but it was safe to ignore for me and uninstalling the update is not possible via the normal Android app settings)
  • and restoring my SMS from an XML file afterward (Titanium Backup -> Menu Button -> Restore Data from XML...).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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