Buggy code:
public class DeckManager { public static final int REQUESTING_ACTIVITY_STUDYOPTIONS = 0 ; public static final int REQUESTING_ACTIVITY_DECKPICKER = 1 ; public static final int REQUESTING_ACTIVITY_WIDGETSTATUS = 2 ; public static final int REQUESTING_ACTIVITY_BIGWIDGET = 3 ; public static final int REQUESTING_ACTIVITY_STATISTICS = 4 ; public static final int REQUESTING_ACTIVITY_SYNCCLIENT = 5 ; public static final int REQUESTING_ACTIVITY_CARDEDITOR = 6 ; public static final int REQUESTING_ACTIVITY_DOWNLOADMANAGER = 7 ; private static HashMap < String , DeckManager . DeckInformation > sLoadedDecks = new HashMap < String , DeckManager . DeckInformation > ( ) ; private static HashMap < String , ReentrantLock > sDeckLocks = new HashMap < String , ReentrantLock > ( ) ; private static HashMap < String , String > sDeckPaths ; private static String [ ] sDeckNames ; private static String sMainDeckPath ; public static Deck getDeck ( String deckpath , int requestingActivity ) { } public static Deck getDeck ( String deckpath , boolean setAsMainDeck , int requestingActivity ) { } public static Deck getDeck ( String deckpath , int requestingActivity , boolean rebuild ) { } public static synchronized Deck getDeck ( String deckpath , boolean setAsMainDeck , boolean doSafetyBackupIfNeeded , int requestingActivity , boolean rebuild ) { Deck deck = null ; DeckManager . lockDeck ( deckpath ) ; try { if ( DeckManager . sLoadedDecks . containsKey ( deckpath ) ) { DeckManager . DeckInformation deckInformation = DeckManager . sLoadedDecks . get ( deckpath ) ; try { AsyncTask < DeckManager . CloseDeckInformation , Void , DeckManager . DeckInformation > closingTask = deckInformation . mClosingAsyncTask ; if ( ( ( closingTask != null ) && ( ( closingTask . getStatus ( ) ) == ( Status . RUNNING ) ) ) && ( ! ( closingTask . isCancelled ( ) ) ) ) { if ( deckInformation . mWaitForDeckTaskToFinish ) { Log . i ( TAG , ( ( "DeckManager:<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) + "<seq2seq4repair_space>is<seq2seq4repair_space>closing<seq2seq4repair_space>now,<seq2seq4repair_space>cancelling<seq2seq4repair_space>this" ) ) ; closingTask . cancel ( true ) ; deckInformation . mOpenedBy = new ArrayList < Integer > ( ) ; } else { Log . i ( TAG , ( ( "DeckManager:<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) + "<seq2seq4repair_space>is<seq2seq4repair_space>closing<seq2seq4repair_space>now,<seq2seq4repair_space>waiting<seq2seq4repair_space>for<seq2seq4repair_space>this<seq2seq4repair_space>to<seq2seq4repair_space>finish<seq2seq4repair_space>and<seq2seq4repair_space>reopening<seq2seq4repair_space>it" ) ) ; while ( ( closingTask . getStatus ( ) ) == ( Status . RUNNING ) ) { closingTask . get ( ) ; } return DeckManager . getDeck ( deckpath , setAsMainDeck , doSafetyBackupIfNeeded , requestingActivity , rebuild ) ; } } } catch ( Exception e ) { Log . i ( TAG , ( "DeckManager:<seq2seq4repair_space>An<seq2seq4repair_space>exception<seq2seq4repair_space>occurred<seq2seq4repair_space>while<seq2seq4repair_space>waiting<seq2seq4repair_space>for<seq2seq4repair_space>closing<seq2seq4repair_space>task<seq2seq4repair_space>of<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) ) ; } ArrayList < Integer > openList = deckInformation . mOpenedBy ; if ( ! ( openList . contains ( requestingActivity ) ) ) { Log . i ( TAG , ( ( "DeckManager:<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) + "<seq2seq4repair_space>already<seq2seq4repair_space>loaded,<seq2seq4repair_space>adding<seq2seq4repair_space>requesting<seq2seq4repair_space>activity" ) ) ; openList . add ( requestingActivity ) ; } else { Log . i ( TAG , ( ( "DeckManager:<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) + "<seq2seq4repair_space>already<seq2seq4repair_space>loaded<seq2seq4repair_space>by<seq2seq4repair_space>this<seq2seq4repair_space>activity!" ) ) ; } Log . i ( TAG , ( ( ( "DeckManager:<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) + "<seq2seq4repair_space>is<seq2seq4repair_space>now<seq2seq4repair_space>opened<seq2seq4repair_space>by<seq2seq4repair_space>" ) + ( openList . toString ( ) ) ) ) ; deck = deckInformation . mDeck ; if ( requestingActivity == ( DeckManager . REQUESTING_ACTIVITY_SYNCCLIENT ) ) { DeckManager . sendWidgetBigClosedNotification ( ) ; <START_BUG> deckInformation . mOpenedBy . remove ( DeckManager . REQUESTING_ACTIVITY_BIGWIDGET ) ; <END_BUG> if ( ! ( deckInformation . mDeleteJournalModeForced ) ) { Cursor cur = null ; try { cur = deck . getDB ( ) . getDatabase ( ) . rawQuery ( "PRAGMA<seq2seq4repair_space>journal_mode" , null ) ; if ( cur . moveToFirst ( ) ) { if ( ! ( cur . getString ( 0 ) . equalsIgnoreCase ( "delete" ) ) ) { Log . i ( TAG , "DeckManager:<seq2seq4repair_space>Journal<seq2seq4repair_space>mode<seq2seq4repair_space>not<seq2seq4repair_space>set<seq2seq4repair_space>to<seq2seq4repair_space>delete,<seq2seq4repair_space>reloading<seq2seq4repair_space>deck" ) ; deck . closeDeck ( ) ; deck = Deck . openDeck ( deckpath , rebuild , true ) ; } deckInformation . mDeleteJournalModeForced = true ; } } finally { if ( ( cur != null ) && ( ! ( cur . isClosed ( ) ) ) ) { cur . close ( ) ; } } } else if ( deckInformation . mOpenedBy . contains ( DeckManager . REQUESTING_ACTIVITY_SYNCCLIENT ) ) { deck = null ; } } else if ( rebuild ) { if ( ! ( deckInformation . mInitiallyRebuilt ) ) { Log . i ( TAG , "DeckManager:<seq2seq4repair_space>reopen<seq2seq4repair_space>deck<seq2seq4repair_space>in<seq2seq4repair_space>order<seq2seq4repair_space>to<seq2seq4repair_space>rebuild" ) ; deck . closeDeck ( false ) ; deckInformation . mDeck = Deck . openDeck ( deckpath , true , ( requestingActivity == ( DeckManager . REQUESTING_ACTIVITY_SYNCCLIENT ) ) ) ; deckInformation . mInitiallyRebuilt = true ; WidgetStatus . update ( AnkiDroidApp . getInstance ( ) . getBaseContext ( ) , WidgetStatus . getDeckStatus ( deck ) ) ; } } } else { try { Log . i ( TAG , ( ( ( ( "DeckManager:<seq2seq4repair_space>try<seq2seq4repair_space>to<seq2seq4repair_space>load<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) + "<seq2seq4repair_space>(" ) + requestingActivity ) + ")" ) ) ; if ( doSafetyBackupIfNeeded ) { BackupManager . safetyBackupNeeded ( deckpath , SAFETY_BACKUP_THRESHOLD ) ; } deck = Deck . openDeck ( deckpath , rebuild , ( requestingActivity == ( DeckManager . REQUESTING_ACTIVITY_SYNCCLIENT ) ) ) ; Log . i ( TAG , "DeckManager:<seq2seq4repair_space>Deck<seq2seq4repair_space>loaded!" ) ; DeckManager . sLoadedDecks . put ( deckpath , new DeckManager . DeckInformation ( deckpath , deck , requestingActivity , rebuild ) ) ; } catch ( RuntimeException e ) { Log . e ( TAG , ( ( ( "DeckManager:<seq2seq4repair_space>deck<seq2seq4repair_space>" + deckpath ) + "<seq2seq4repair_space>could<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>opened<seq2seq4repair_space>=<seq2seq4repair_space>" ) + ( e . getMessage ( ) ) ) ) ; BackupManager . restoreDeckIfMissing ( deckpath ) ; deck = null ; } } } finally { if ( setAsMainDeck && ( deck != null ) ) { DeckManager . sMainDeckPath = deckpath ; } DeckManager . unlockDeck ( deckpath ) ; } return deck ; } public static void lockDeck ( String path ) { } public static void unlockDeck ( String path ) { } public static String getMainDeckPath ( ) { }

Fix:
deckInformation . mOpenedBy . remove ( new Integer ( DeckManager . REQUESTING_ACTIVITY_BIGWIDGET ) ) ;