سؤال

We've been successfully using the APK expansion file technology in our app for some time by expanding the .obb file into another directory for reading of the various pieces. We finally decided to try reading directly out of the bob by mounting it using StorageManager. The code we are using seems pretty common on the net.

We make the call:

        if ( storageManager.mountObb( obbFile.getAbsolutePath(), null, obbListener ) )
        {
            Log.d( "STORAGE_MNT", "SUCCESSFULLY QUEUED" );
        }
        else
        {
            Log.d( "STORAGE_MNT", "FAILED" );
        }

and this succeeds as "SUCCESSFULLY QUEUED". However the obbListener is never called afterwards. If you look in the LogCat you do see the following:

Calling a method in the system process without a qualified user: 
android.app.ContextImpl.bindService:1543 
com.android.server.MountService$ObbActionHandler.connectToService:2458 
com.android.server.MountService$ObbActionHandler.handleMessage:2337 
android.os.Handler.dispatchMessage:102 android.os.Looper.loop:136 

I assume this is related to the problem but I have been unable to find much on why there is no "qualified user". Can someone please explain what could be going on here?

We have verified that obbFile.exists() is true. This file is there.

While searching for an answer I've see lots of references to broken a JOBB tool. It also seems like Android 4.4 had a bug that prevented this from working (although I'm using 4.4.2 right now). I'm wondering if this is stable enough to use for production code.

هل كانت مفيدة؟

المحلول

Well, I think I finally figured out what is happening. It looks like the obb file in question was already mounted. The file was an APK expansion file and it would appear this is automatically mounted for you by the system.

If, before trying to mount it, I execute:

        if (storageManager.isObbMounted( obbFile.getAbsolutePath() ))
        {
            Log.d("", "obb file mounted at " + storageManager.getMountedObbPath( obbFile.getAbsolutePath() ));
        }

without first explicitly mounting it, I get a valid mount path. I really wish the docs (or LogCat messages) were more explicit about this. It took me about a day to discover this. It wasn't until I explicitly used an (necessary) encryption key on the obb that I saw a message in LogCat saying the file was already mounted.

نصائح أخرى

Another reason for the listener not being called is if the OBB is invalid - such as not being created with JOBB using the correct package name. In my case I messed up creating the test environment and so was attempting to mount a pre-Storage Manage / JOBB expansion file created the old way with zip. I once got an internal error event, but only once out of hundreds of hair-pulling attempts. It seems that the Storage Manager will fail silently after successfully queuing the mount and never call the listener. As soon as I went back to basics and redid everything from scratch I spotted the invalid .obb file, fixed it, and it all worked as documented.

Note that I also have a background task that tests for the expansion file being mounted as a fallback running once a second. I found this idea from a web article somewhere. Often the background task spots the OBB expansion is mounted way before the Storage Manager listener callback is invoked.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top