8000 Adjustments based on lint results · dw3/android-database-sqlcipher@fba7fa5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fba7fa5

Browse files
Adjustments based on lint results
1 parent 5263292 commit fba7fa5

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

src/net/sqlcipher/AbstractCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public boolean update(int columnIndex, Object obj) {
369369

370370
// Long.valueOf() returns null sometimes!
371371
// Long rowid = Long.valueOf(getLong(mRowIdColumnIndex));
372-
Long rowid = new Long(getLong(mRowIdColumnIndex));
372+
Long rowid = Long.valueOf(getLong(mRowIdColumnIndex));
373373
if (rowid == null) {
374374
throw new IllegalStateException("null rowid. mRowIdColumnIndex = " + mRowIdColumnIndex);
375375
}

src/net/sqlcipher/BulkCursorNative.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
166166

167167
case RESPOND_TRANSACTION: {
168168
data.enforceInterface(IBulkCursor.descriptor);
169-
Bundle extras = data.readBundle();
169+
Bundle extras = data.readBundle(getClass().getClassLoader());
170170
Bundle returnExtras = respond(extras);
171171
reply.writeNoException();
172172
reply.writeBundle(returnExtras);
@@ -334,7 +334,7 @@ public int requery(IContentObserver observer, CursorWindow window) throws Remote
334334
count = -1;
335335
} else {
336336
count = reply.readInt();
337-
mExtras = reply.readBundle();
337+
mExtras = reply.readBundle(getClass().getClassLoader());
338338
}
339339

340340
data.recycle();
@@ -412,7 +412,7 @@ public Bundle getExtras() throws RemoteException {
412412

413413
DatabaseUtils.readExceptionFromParcel(reply);
414414

415-
mExtras = reply.readBundle();
415+
mExtras = reply.readBundle(getClass().getClassLoader());
416416
data.recycle();
417417
reply.recycle();
418418
}
@@ -431,7 +431,7 @@ public Bundle respond(Bundle extras) throws RemoteException {
431431

432432
DatabaseUtils.readExceptionFromParcel(reply);
433433

434-
Bundle returnExtras = reply.readBundle();
434+
Bundle returnExtras = reply.readBundle(getClass().getClassLoader());
435435
data.recycle();
436436
reply.recycle();
437437
return returnExtras;

src/net/sqlcipher/DefaultDatabaseErrorHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
public final class DefaultDatabaseErrorHandler implements DatabaseErrorHandler {
3636

37-
private static final String TAG = "DefaultDatabaseErrorHandler";
37+
private final String TAG = getClass().getSimpleName();
3838

3939
/**
4040
* defines the default method to be invoked when database corruption is detected.

src/net/sqlcipher/database/SQLiteCursor.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import net.sqlcipher.CursorWindow;
2121
import net.sqlcipher.SQLException;
2222

23+
import java.lang.ref.WeakReference;
2324
import java.util.HashMap;
2425
import java.util.Iterator;
2526
import java.util.Map;
@@ -165,11 +166,19 @@ public void run() {
165166
/**
166167
* @hide
167168
*/
168-
protected class MainThreadNotificationHandler extends Handler {
169+
protected static class MainThreadNotificationHandler extends Handler {
170+
171+
private final WeakReference<SQLiteCursor> wrappedCursor;
172+
173+
MainThreadNotificationHandler(SQLiteCursor cursor) {
174+
wrappedCursor = new WeakReference<SQLiteCursor>(cursor);
175+
}
176+
169177
public void handleMessage(Message msg) {
170-
171-
notifyDataSetChange();
172-
178+
SQLiteCursor cursor = wrappedCursor.get();
179+
if(cursor != null){
180+
cursor.notifyDataSetChange();
181+
}
173182
}
174183
}
175184

@@ -184,7 +193,7 @@ public void registerDataSetObserver(DataSetObserver observer) {
184193
mNotificationHandler == null) {
185194
queryThreadLock();
186195
try {
187-
mNotificationHandler = new MainThreadNotificationHandler();
196+
mNotificationHandler = new MainThreadNotificationHandler(this);
188197
if (mPendingData) {
189198
notifyDataSetChange();
190199
mPendingData = false;

src/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ private void keyDatabase(SQLiteDatabaseHook databaseHook, Runnable keyOperation)
24962496
}
24972497

24982498
private String getTime() {
2499-
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS ").format(System.currentTimeMillis());
2499+
return new SimpleDateFormat("yyyy-MM-dd HH:mm: A93C ss.SSS ", Locale.US).format(System.currentTimeMillis());
25002500
}
25012501

25022502
/**

src/net/sqlcipher/database/SQLiteQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ public void bindArguments(Object[] args){
206206
bindDouble(i + 1, (Double)value);
207207
} else if (value instanceof Float) {
208208
float number = ((Number)value).floatValue();
209-
bindDouble(i + 1, new Double(number));
209+
bindDouble(i + 1, Double.valueOf(number));
210210
} else if (value instanceof Long) {
211211
bindLong(i + 1, (Long)value);
212212
} else if(value instanceof Integer) {
213213
int number = ((Number) value).intValue();
214-
bindLong(i + 1, new Long(number));
214+
bindLong(i + 1, Long.valueOf(number));
215215
} else if (value instanceof Boolean) {
216216
bindLong(i + 1, (Boolean)value ? 1 : 0);
217217
} else if (value instanceof byte[]) {

0 commit comments

Comments
 (0)
0