[Moto G 2015 Q&A, Help & Troubleshooting] highlower:
Can't access SD card

Hi guys, can't post in the other thread so I guess this will do it.

I just installed CM13 on my Moto G and everything seems to be working fine, apart from using my external SD card. I configured it as a "portable storage", but I can't access it using the CM file browser nor by pressing "explore" in the notification about the SD card.

It's likely an issue with SELinux (everything works fine if I disable it, and also the logs scream "avc: denied"), and I guess the problem is that my SD is formatted in ext4.

Logcat:

01-23 21:45:17.485 310 977 W msm8916_platform: Codec backend bitwidth 16, samplerate 48000
01-23 21:45:17.488 310 977 W audio_hw_utils: audio_extn_utils_update_stream_app_type_cfg: App type could not be selected. Falling back to default
01-23 21:45:17.588 3577 3577 W Binder_1: type=1400 audit(0.0:335): avc: denied { getattr } for uid=10010 path="/mnt/media_rw/57f8f4bc-abf4-655f-bf67-946fc0f9f25b" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
01-23 21:45:17.588 3577 3577 W Binder_1: type=1400 audit(0.0:336): avc: denied { getattr } for uid=10010 path="/mnt/media_rw/57f8f4bc-abf4-655f-bf67-946fc0f9f25b" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
01-23 21:45:17.588 3577 3577 W Binder_1: type=1400 audit(0.0:337): avc: denied { getattr } for uid=10010 path="/mnt/media_rw/57f8f4bc-abf4-655f-bf67-946fc0f9f25b" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
01-23 21:45:17.818 3577 3577 W Binder_1: type=1400 audit(0.0:338): avc: denied { read } for uid=10010 name="/" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
01-23 21:45:17.831 3564 3577 E DatabaseUtils: Writing exception to parcel
01-23 21:45:17.831 3564 3577 E DatabaseUtils: java.lang.NullPointerException: Attempt to get length of null array
01-23 21:45:17.831 3564 3577 E DatabaseUtils: at com.android.externalstorage.ExternalStorageProvider.queryChildDocuments(ExternalStorageProvider.java:426)
01-23 21:45:17.831 3564 3577 E DatabaseUtils: at android.provider.DocumentsProvider.query(DocumentsProvider.java:498)
01-23 21:45:17.831 3564 3577 E DatabaseUtils: at android.content.ContentProvider.query(ContentProvider.java:1017)
01-23 21:45:17.831 3564 3577 E DatabaseUtils: at android.content.ContentProvider$Transport.query(ContentProvider.java:238)
01-23 21:45:17.831 3564 3577 E DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
01-23 21:45:17.831 3564 3577 E DatabaseUtils: at android.os.Binder.execTransact(Binder.java:453)
01-23 21:45:17.835 3587 3629 W Documents: Failed to query
01-23 21:45:17.835 3587 3629 W Documents: java.lang.NullPointerException: Attempt to get length of null array
01-23 21:45:17.835 3587 3629 W Documents: at android.os.Parcel.readException(Parcel.java:1626)
01-23 21:45:17.835 3587 3629 W Documents: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
01-23 21:45:17.835 3587 3629 W Documents: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
01-23 21:45:17.835 3587 3629 W Documents: at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
01-23 21:45:17.835 3587 3629 W Documents: at android.content.ContentProviderClient.query(ContentProviderClient.java:136)
01-23 21:45:17.835 3587 3629 W Documents: at com.android.documentsui.DirectoryLoader.loadInBackground(DirectoryLoader.java:167)
01-23 21:45:17.835 3587 3629 W Documents: at com.android.documentsui.DirectoryLoader.loadInBackground(DirectoryLoader.java:94)
01-23 21:45:17.835 3587 3629 W Documents: at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:312)
01-23 21:45:17.835 3587 3629 W Documents: at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:69)
01-23 21:45:17.835 3587 3629 W Documents: at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:66)
01-23 21:45:17.835 3587 3629 W Documents: at android.os.AsyncTask$2.call(AsyncTask.java:295)
01-23 21:45:17.835 3587 3629 W Documents: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-23 21:45:17.835 3587 3629 W Documents: at com.android.documentsui.ProviderExecutor.run(ProviderExecutor.java:107)
01-23 21:45:17.818 3577 3577 W Binder_1: type=1400 audit(0.0:339): avc: denied { read } for uid=10010 name="/" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
01-23 21:45:18.549 3008 3537 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
01-23 21:45:18.549 3008 3537 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...

dmesg:

[ 1215.786987,3] type=1400 audit(1453582725.608:355): avc: denied { getattr } for uid=10010 pid=3578 comm="Binder_2" path="/mnt/media_rw/57f8f4bc-abf4-655f-bf67-946fc0f9f25b" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
[ 1215.788606,3] type=1400 audit(1453582725.608:356): avc: denied { getattr } for uid=10010 pid=3578 comm="Binder_2" path="/mnt/media_rw/57f8f4bc-abf4-655f-bf67-946fc0f9f25b" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
[ 1215.788766,3] type=1400 audit(1453582725.608:357): avc: denied { getattr } for uid=10010 pid=3578 comm="Binder_2" path="/mnt/media_rw/57f8f4bc-abf4-655f-bf67-946fc0f9f25b" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
[ 1215.949788,2] type=1400 audit(1453582725.768:358): avc: denied { read } for uid=10010 pid=3577 comm="Binder_1" name="/" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
[ 1215.951272,2] type=1400 audit(1453582725.768:359): avc: denied { read } for uid=10010 pid=3577 comm="Binder_1" name="/" dev="mmcblk1p1" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0

(Sorry, can't link urls not attach files to my post yet)

I'm not sure if I should report this here, since I guess it's not an issue strictly related to this phone (but can't test it on others). Can't report it on the CM's jira either, as I don't think this is a regression.

So I hope here it's fine :)

Oh, and thanks for the great work!