Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b982c10a authored by Hemant Gupta's avatar Hemant Gupta Committed by Gerrit - the friendly Code Review server
Browse files

PBAP: Catch CursorWindowAllocationException

This patch will add the changes to catch the
CursorWindowAllocationException at all the places
where cursor is used for quering operations.

CRs-Fixed: 597186
Change-Id: I6a4fadb949969dca453cff0fe84a25d849063573
parent 81e8cc76
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ package com.android.bluetooth.pbap;

import android.content.ContentResolver;
import android.content.Context;
import android.database.CursorWindowAllocationException;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog;
@@ -181,9 +182,12 @@ public class BluetoothPbapVcardManager {
            if (contactCursor != null) {
                size = contactCursor.getCount() + 1; // always has the 0.vcf
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while getting Contacts size");
        } finally {
            if (contactCursor != null) {
                contactCursor.close();
                contactCursor = null;
            }
        }
        return size;
@@ -198,9 +202,12 @@ public class BluetoothPbapVcardManager {
            if (contactCursor != null) {
                size = contactCursor.getCount() +1;  //always has the 0.vcf
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while getting SIM Contacts size");
        } finally {
            if (contactCursor != null) {
                contactCursor.close();
                contactCursor = null;
            }
        }
        return size;
@@ -217,9 +224,12 @@ public class BluetoothPbapVcardManager {
            if (callCursor != null) {
                size = callCursor.getCount();
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while getting CallHistory size");
        } finally {
            if (callCursor != null) {
                callCursor.close();
                callCursor = null;
            }
        }
        return size;
@@ -257,9 +267,12 @@ public class BluetoothPbapVcardManager {
                    list.add(name);
                }
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while loading CallHistory");
        } finally {
            if (callCursor != null) {
                callCursor.close();
                callCursor = null;
            }
        }
        return list;
@@ -283,9 +296,12 @@ public class BluetoothPbapVcardManager {
                    allnames.add(name);
                }
            }
        } catch (CursorWindowAllocationException e) {
          Log.e(TAG, "CursorWindowAllocationException while getting SIM Phonebook name list");
        } finally {
            if (contactCursor != null) {
                contactCursor.close();
                contactCursor = null;
            }
        }
        if (orderByWhat == BluetoothPbapObexServer.ORDER_BY_INDEXED) {
@@ -342,9 +358,12 @@ public class BluetoothPbapVcardManager {
                    nameList.add(name + "," + id);
                }
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while getting Phonebook name list");
        } finally {
            if (contactCursor != null) {
                contactCursor.close();
                contactCursor = null;
            }
        }
        return nameList;
@@ -405,9 +424,12 @@ public class BluetoothPbapVcardManager {
                    }
                }
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while getting SIM contact names");
        } finally {
            if (contactCursor != null) {
                contactCursor.close();
                contactCursor = null;
            }
        }
        int startListSize = startNameList.size();
@@ -449,9 +471,12 @@ public class BluetoothPbapVcardManager {
                    tempNameList.add(name + "," + id);
                }
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while getting contact names");
        } finally {
            if (contactCursor != null) {
                contactCursor.close();
                contactCursor = null;
            }
        }
        int tempListSize = tempNameList.size();
@@ -497,9 +522,12 @@ public class BluetoothPbapVcardManager {
                }
                if (V) Log.v(TAG, "Call log query endPointId = " + endPointId);
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while composing calllog vcards");
        } finally {
            if (callsCursor != null) {
                callsCursor.close();
                callsCursor = null;
            }
        }

@@ -551,9 +579,12 @@ public class BluetoothPbapVcardManager {
                }
                if (V) Log.v(TAG, "Query endPointId = " + endPointId);
            }
        } catch (CursorWindowAllocationException e) {
            Log.e(TAG, "CursorWindowAllocationException while composing phonebook vcards");
        } finally {
            if (contactCursor != null) {
                contactCursor.close();
                contactCursor = null;
            }
        }

@@ -632,9 +663,12 @@ public class BluetoothPbapVcardManager {
                    contactId = contactCursor.getLong(CONTACTS_ID_COLUMN_INDEX);
                    if (V) Log.v(TAG, "Query startPointId = " + contactId);
                }
            } catch (CursorWindowAllocationException e) {
                Log.e(TAG, "CursorWindowAllocationException while composing phonebook one vcard order by index");
            } finally {
                if (contactCursor != null) {
                    contactCursor.close();
                    contactCursor = null;
                }
            }
        } else if (orderByWhat == BluetoothPbapObexServer.ORDER_BY_ALPHABETICAL) {
@@ -646,9 +680,12 @@ public class BluetoothPbapVcardManager {
                    contactId = contactCursor.getLong(CONTACTS_ID_COLUMN_INDEX);
                    if (V) Log.v(TAG, "Query startPointId = " + contactId);
                }
            } catch (CursorWindowAllocationException e) {
                Log.e(TAG, "CursorWindowAllocationException while composing phonebook one vcard order by alphabetical");
            } finally {
                if (contactCursor != null) {
                    contactCursor.close();
                    contactCursor = null;
                }
            }
        } else {