Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposer.java +3 −14 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ import java.util.Calendar; /** VCard composer especially for Call Log used in Bluetooth. */ // Next tag value for ContentProfileErrorReportUtils.report(): 3 public class BluetoothPbapCallLogComposer { public class BluetoothPbapCallLogComposer implements AutoCloseable { private static final String TAG = "PbapCallLogComposer"; @VisibleForTesting Loading Loading @@ -92,8 +92,6 @@ public class BluetoothPbapCallLogComposer { private final Context mContext; private Cursor mCursor; private boolean mTerminateIsCalled; private String mErrorReason = NO_ERROR; private final String RFC_2455_FORMAT = "yyyyMMdd'T'HHmmss"; Loading Loading @@ -281,7 +279,8 @@ public class BluetoothPbapCallLogComposer { toRfc2455Format(dateAsLong)); } public void terminate() { /** Closes the composer, releasing all of its resources. */ public void close() { if (mCursor != null) { try { mCursor.close(); Loading @@ -296,16 +295,6 @@ public class BluetoothPbapCallLogComposer { } mCursor = null; } mTerminateIsCalled = true; } @Override @SuppressWarnings("Finalize") // TODO: b/366307571 remove override public void finalize() { if (!mTerminateIsCalled) { terminate(); } } public int getCount() { Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +1 −6 Original line number Diff line number Diff line Loading @@ -1103,13 +1103,11 @@ public class BluetoothPbapVcardManager { boolean vCardSelct) { long timestamp = System.currentTimeMillis(); BluetoothPbapCallLogComposer composer = null; HandlerForStringBuffer buffer = null; try { try (BluetoothPbapCallLogComposer composer = new BluetoothPbapCallLogComposer(mContext)) { VCardFilter vcardfilter = new VCardFilter(ignorefilter ? null : filter); PropertySelector vcardselector = new PropertySelector(selector); composer = new BluetoothPbapCallLogComposer(mContext); buffer = new HandlerForStringBuffer(op, ownerVCard); if (!composer.init(CallLog.Calls.CONTENT_URI, selection, null, CALLLOG_SORT_ORDER) || !buffer.init()) { Loading Loading @@ -1182,9 +1180,6 @@ public class BluetoothPbapVcardManager { return pbSize; } } finally { if (composer != null) { composer.terminate(); } if (buffer != null) { buffer.terminate(); } Loading android/app/tests/unit/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposerTest.java +3 −10 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class BluetoothPbapCallLogComposerTest { @After public void tearDown() throws Exception { BluetoothMethodProxy.setInstanceForTesting(null); mComposer.close(); } @Test Loading Loading @@ -165,18 +166,10 @@ public class BluetoothPbapCallLogComposerTest { } @Test public void testTerminate() { public void testClose() { mComposer.init(CALL_LOG_URI, SELECTION, SELECTION_ARGS, SORT_ORDER); mComposer.terminate(); verify(mMockCursor).close(); } @Test public void testFinalize() { mComposer.init(CALL_LOG_URI, SELECTION, SELECTION_ARGS, SORT_ORDER); mComposer.finalize(); mComposer.close(); verify(mMockCursor).close(); } Loading Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposer.java +3 −14 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ import java.util.Calendar; /** VCard composer especially for Call Log used in Bluetooth. */ // Next tag value for ContentProfileErrorReportUtils.report(): 3 public class BluetoothPbapCallLogComposer { public class BluetoothPbapCallLogComposer implements AutoCloseable { private static final String TAG = "PbapCallLogComposer"; @VisibleForTesting Loading Loading @@ -92,8 +92,6 @@ public class BluetoothPbapCallLogComposer { private final Context mContext; private Cursor mCursor; private boolean mTerminateIsCalled; private String mErrorReason = NO_ERROR; private final String RFC_2455_FORMAT = "yyyyMMdd'T'HHmmss"; Loading Loading @@ -281,7 +279,8 @@ public class BluetoothPbapCallLogComposer { toRfc2455Format(dateAsLong)); } public void terminate() { /** Closes the composer, releasing all of its resources. */ public void close() { if (mCursor != null) { try { mCursor.close(); Loading @@ -296,16 +295,6 @@ public class BluetoothPbapCallLogComposer { } mCursor = null; } mTerminateIsCalled = true; } @Override @SuppressWarnings("Finalize") // TODO: b/366307571 remove override public void finalize() { if (!mTerminateIsCalled) { terminate(); } } public int getCount() { Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +1 −6 Original line number Diff line number Diff line Loading @@ -1103,13 +1103,11 @@ public class BluetoothPbapVcardManager { boolean vCardSelct) { long timestamp = System.currentTimeMillis(); BluetoothPbapCallLogComposer composer = null; HandlerForStringBuffer buffer = null; try { try (BluetoothPbapCallLogComposer composer = new BluetoothPbapCallLogComposer(mContext)) { VCardFilter vcardfilter = new VCardFilter(ignorefilter ? null : filter); PropertySelector vcardselector = new PropertySelector(selector); composer = new BluetoothPbapCallLogComposer(mContext); buffer = new HandlerForStringBuffer(op, ownerVCard); if (!composer.init(CallLog.Calls.CONTENT_URI, selection, null, CALLLOG_SORT_ORDER) || !buffer.init()) { Loading Loading @@ -1182,9 +1180,6 @@ public class BluetoothPbapVcardManager { return pbSize; } } finally { if (composer != null) { composer.terminate(); } if (buffer != null) { buffer.terminate(); } Loading
android/app/tests/unit/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposerTest.java +3 −10 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class BluetoothPbapCallLogComposerTest { @After public void tearDown() throws Exception { BluetoothMethodProxy.setInstanceForTesting(null); mComposer.close(); } @Test Loading Loading @@ -165,18 +166,10 @@ public class BluetoothPbapCallLogComposerTest { } @Test public void testTerminate() { public void testClose() { mComposer.init(CALL_LOG_URI, SELECTION, SELECTION_ARGS, SORT_ORDER); mComposer.terminate(); verify(mMockCursor).close(); } @Test public void testFinalize() { mComposer.init(CALL_LOG_URI, SELECTION, SELECTION_ARGS, SORT_ORDER); mComposer.finalize(); mComposer.close(); verify(mMockCursor).close(); } Loading