Using encrypted OBB files in Android
<p>I was wondering if people have been successful in creating/mounting encrypted OBB (Opaque Binary Blob) files in Android? This is a follow up to this <a href="https://groups.google.com/forum/?fromgroups=#!searchin/android-developers/obbtool/android-developers/x_kTCgMfGG8/JVjLKm3v7zEJ" rel="nofollow">question</a>
  <a href="https://groups.google.com/forum/?fromgroups=#!searchin/android-developers/obbtool/android-developers/x_kTCgMfGG8/JVjLKm3v7zEJ" rel="nofollow">1</a>: <a href="http://stackoverflow.com/questions/4524981/what-is-obbopaque-binary-blob-in-android-develop-site">What is OBB(Opaque Binary Blob) in Android develop site?</a> , Following the direction in that post I executed the following (from ICS 4.01 baseline, Tried both on Ubuntu 10.10-32bit and Ubuntu 12.4-64bit):</p>

<pre><code>sudo modprobe cryptoloop
sudo modprobe twofish
sudo modprobe vfat
./mkobb.sh -d /tmp/obb/ -kblahblah -o /tmp/out.obb -v
obbtool a -n com.test.blah -v 1 -s 997ff9b1516a6788 /tmp/out.obb # 997ff... is the salt from the mkobb step
obbtool i /temp/out.obb # verify the obb file
adb push /temp/out.obb /sdcard/
</code></pre>

<p>From here I copy the out.obb file to the /sdcard/ on my phone. And mount with the following code:</p>

<pre><code>String obbFile = Environment.getExternalStorageDirectory() + "/out.obb";
mgr = (StorageManager) getSystemService(Context.STORAGE_SERVICE);  // mgr is a member varible of my main activity
Log.i("OBB", "trying to mount : " + obbFile + " does it exist? " + new File(obbFile).exists());

if (mgr.mountObb(obbFile, "blahblah", new OnObbStateChangeListener(){

    @Override
    public void onObbStateChange(String path, int state) {
        Log.i("OBB", String.format("onObbStateChange:Path [%s] State=%d", path, state));
        if (state == OnObbStateChangeListener.ERROR_COULD_NOT_MOUNT){
            Log.i("OBB", "THIS IS THE ERROR I GET");
        }
    }})) 
{
    Log.i("OBB", "Attempting to mount");
} else {
    Log.i("OBB", "Mount failed");   // this isn't happening
}
</code></pre>

<p>The end result of this is:</p>

<pre><code> E/MountService( 2004): Couldn't mount OBB file: -1
 I/OBB     (21219): onObbStateChange:Path [/mnt/sdcard/out.obb] State=21
 I/OBB     (21219): THIS IS THE ERROR I GET
</code></pre>

<p>Anyone see any problems with this? Seems like it should work!</p>

<p>Note: I do have android.permission.WRITE_EXTERNAL_STORAGE and also I get expected info from:</p>

<pre><code>ObbInfo info = ObbScanner.getObbInfo("/sdcard/out.obb"); // this returns expected info, so the file is there and able to be read.
</code></pre>

<p>Edit: Link to Android-Developer group question <a href="https://groups.google.com/forum/?fromgroups=#!searchin/android-developers/obbtool/android-developers/x_kTCgMfGG8/JVjLKm3v7zEJ" rel="nofollow">here</a></p>
