PBAP Client call-log cleanup
When a Bluetooth phone disconnects only cleanup call logs associated
with it by utilizing the same account name that the associoated telecom
stack uses.
Bug: 72997404
Test: runtest bluetooth -p com.android.bluetooth.pbapclient
Change-Id: I4ef2c22782e4390a043b55dad8e328f97b4b8774
diff --git a/src/com/android/bluetooth/pbapclient/CallLogPullRequest.java b/src/com/android/bluetooth/pbapclient/CallLogPullRequest.java
index 044fcf7..91652a6 100644
--- a/src/com/android/bluetooth/pbapclient/CallLogPullRequest.java
+++ b/src/com/android/bluetooth/pbapclient/CallLogPullRequest.java
@@ -88,7 +88,7 @@
ContentValues values = new ContentValues();
values.put(CallLog.Calls.TYPE, type);
- values.put(Calls.PHONE_ACCOUNT_ID, mAccount.hashCode());
+ values.put(Calls.PHONE_ACCOUNT_ID, mAccount.name);
List<PhoneData> phones = vcard.getPhoneList();
if (phones == null || phones.get(0).getNumber().equals(";")) {
values.put(CallLog.Calls.NUMBER, "");
diff --git a/src/com/android/bluetooth/pbapclient/PbapClientConnectionHandler.java b/src/com/android/bluetooth/pbapclient/PbapClientConnectionHandler.java
index f8e78a4..c060ab2 100644
--- a/src/com/android/bluetooth/pbapclient/PbapClientConnectionHandler.java
+++ b/src/com/android/bluetooth/pbapclient/PbapClientConnectionHandler.java
@@ -411,8 +411,8 @@
}
return;
}
- String where = Calls.PHONE_ACCOUNT_ID + "=" + account.hashCode();
- mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI, where, null);
+ mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI,
+ Calls.PHONE_ACCOUNT_ID + "=?", new String[]{mAccount.name});
} catch (IllegalArgumentException e) {
Log.d(TAG, "Call Logs could not be deleted, they may not exist yet.");
}
diff --git a/src/com/android/bluetooth/pbapclient/PbapClientService.java b/src/com/android/bluetooth/pbapclient/PbapClientService.java
index 5920119..9998e1b 100644
--- a/src/com/android/bluetooth/pbapclient/PbapClientService.java
+++ b/src/com/android/bluetooth/pbapclient/PbapClientService.java
@@ -116,14 +116,15 @@
if (VDBG) Log.v(TAG, "Found " + accounts.length + " unclean accounts");
for (Account acc : accounts) {
Log.w(TAG, "Deleting " + acc);
+ try {
+ getContentResolver().delete(CallLog.Calls.CONTENT_URI,
+ CallLog.Calls.PHONE_ACCOUNT_ID + "=?", new String[]{acc.name});
+ } catch (IllegalArgumentException e) {
+ Log.w(TAG, "Call Logs could not be deleted, they may not exist yet.");
+ }
// The device ID is the name of the account.
accountManager.removeAccountExplicitly(acc);
}
- try {
- getContentResolver().delete(CallLog.Calls.CONTENT_URI, null, null);
- } catch (IllegalArgumentException e) {
- Log.w(TAG, "Call Logs could not be deleted, they may not exist yet.");
- }
}
private class PbapBroadcastReceiver extends BroadcastReceiver {