Dear sirs,
Sorry, "openTypedAssetFileDescriptor" found a very strange place, that is 
marked 
as the red , "releaseUnstableProvider" seems been performed twice.
Not sure if I understand it correctly, Thank you in advance.
 
*public final AssetFileDescriptor openTypedAssetFileDescriptor(Uri uri,*        
  

        *String mimeType, Bundle opts) throws FileNotFoundException {  *        
  

    IContentProvider unstableProvider = 
acquireUnstableProvider(uri);           
    if (unstableProvider == null) 
{                                             
        throw new FileNotFoundException("No content provider: " + 
uri);         
    
}                                                                           
    IContentProvider stableProvider = 
null;                                     
    AssetFileDescriptor fd = 
null;                                              
                                                                                

    try 
{                                                                       
        try 
{                                                                   
            fd = unstableProvider.openTypedAssetFile(uri, mimeType, 
opts);      
            if (fd == null) 
{                                                   
                // The provider will be released by the finally{} 
clause        
                return 
null;                                                    
            
}                                                                   
        } catch (DeadObjectException e) 
{                                       
            // The remote process has died...  but we only hold an 
unstable     
            // reference though, so we might recover!!!  Let's 
try!!!!          
            // This is 
exciting!!1!!1!!!!1                                      
            
unstableProviderDied(unstableProvider);                             
            stableProvider = 
acquireProvider(uri);                              
            if (stableProvider == null) 
{                                       
                throw new FileNotFoundException("No content provider: " + 
uri); 
            
}                                                                   
            fd = stableProvider.openTypedAssetFile(uri, mimeType, 
opts);        
            if (fd == null) 
{                                                   
             // The provider will be released by the finally{} 
clause           
                return 
null;                                                    
            
}                                                                   
        
}                                                                       
                                                                                

        if (stableProvider == null) 
{                                           
            stableProvider = 
acquireProvider(uri);                              
        
}                                                                       
        *releaseUnstableProvider(unstableProvider);*                =>   
Redundant??            
        ParcelFileDescriptor pfd = new 
ParcelFileDescriptorInner(               
                fd.getParcelFileDescriptor(), 
stableProvider);                  
                                                                                

        // Success!  Don't release the provider when exiting, 
let               
        // ParcelFileDescriptorInner do that when it is 
closed.                 
        stableProvider = 
null;                                                  
                                                                                

        return new AssetFileDescriptor(pfd, 
fd.getStartOffset(),                
                
fd.getDeclaredLength());                                        
                                                                                

    } catch (RemoteException e) 
{                                               
        // Whatever, whatever, we'll go 
away.                                   
        throw new 
FileNotFoundException(                                        
                "Failed opening content provider: " + 
uri);                     
    } catch (FileNotFoundException e) 
{                                         
        throw 
e;                                                                
    } finally 
{                                                                 
        if (stableProvider != null) 
{                                           
            
releaseProvider(stableProvider);                                    
        
}                                                                       
        if (unstableProvider != null) 
{                                         
            *releaseUnstableProvider(unstableProvider);*                        
  

        
}                                                                       
    
}                                                                           
} 
 
 
BR,
Jonathan

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to