8000 modified sqlcipher package to point to info.guardianproject.database · Fiv38/android-database-sqlcipher@35e7517 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 35e7517

Browse files
committed
modified sqlcipher package to point to info.guardianproject.database
10000
1 parent c8310d6 commit 35e7517

13 files changed

+148
-47
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
**
3+
** Copyright 2007, The Android Open Source Project
4+
**
5+
** Licensed under the Apache License, Version 2.0 (the "License");
6+
** you may not use this file except in compliance with the License.
7+
** You may obtain a copy of the License at
8+
**
9+
** http://www.apache.org/licenses/LICENSE-2.0
10+
**
11+
** Unless required by applicable law or agreed to in writing, software
12+
** distributed under the License is distributed on an "AS IS" BASIS,
13+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
** See the License for the specific language governing permissions and
15+
** limitations under the License.
16+
*/
17+
18+
package info.guardianproject.database;
19+
20+
/**
21+
* @hide
22+
*/
23+
interface IContentObserver
24+
{
25+
/**
26+
* This method is called when an update occurs to the cursor that is being
27+
* observed. selfUpdate is true if the update was caused by a call to
28+
* commit on the cursor that is being observed.
29+
*/
30+
oneway void onChange(boolean selfUpdate);
31+
}

src/info/guardianproject/database/sqlcipher/SQLiteClosable.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package info.guardianproject.database.sqlcipher;
1818

19-
import android.database.CursorWindow;
19+
import info.guardianproject.database.*;
2020

2121
/**
2222
* An object created from a SQLiteDatabase that can be closed.
@@ -67,10 +67,11 @@ private String getObjInfo() {
6767
this instanceof SQLiteQuery) {
6868
buff.append("mSql = ");
6969
buff.append(((SQLiteProgram)this).mSql);
70-
} else if (this instanceof CursorWindow) {
70+
}
71+
/*else if (this instanceof CursorWindow) {
7172
buff.append("mStartPos = ");
7273
buff.append(((CursorWindow)this).getStartPosition());
73-
}
74+
}*/
7475
buff.append(") ");
7576
return buff.toString();
7677
}

src/info/guardianproject/database/sqlcipher/SQLiteContentHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
package info.guardianproject.database.sqlcipher;
18+
import info.guardianproject.database.*;
1819

1920
import android.content.res.AssetFileDescriptor;
20-
import android.database.Cursor;
2121
import android.os.MemoryFile;
2222

2323
import java.io.FileNotFoundException;
@@ -43,14 +43,14 @@ public class SQLiteContentHelper {
4343
* value of column 0 is NULL, or if there is an error creating the
4444
* asset file descriptor.
4545
*/
46-
public static AssetFileDescriptor getBlobColumnAsAssetFile(SQLiteDatabase db, String sql,
46+
public static MemoryFile getBlobColumnAsAssetFile(SQLiteDatabase db, String sql,
4747
String[] selectionArgs) throws FileNotFoundException {
4848
try {
4949
MemoryFile file = simpleQueryForBlobMemoryFile(db, sql, selectionArgs);
5050
if (file == null) {
5151
throw new FileNotFoundException("No results.");
5252
}
53-
return AssetFileDescriptor.fromMemoryFile(file);
53+
return file;
5454
} catch (IOException ex) {
5555
throw new FileNotFoundException(ex.toString());
5656
}
@@ -82,7 +82,7 @@ private static MemoryFile simpleQueryForBlobMemoryFile(SQLiteDatabase db, String
8282
}
8383
MemoryFile file = new MemoryFile(null, bytes.length);
8484
file.writeBytes(bytes, 0, 0, bytes.length);
85-
file.deactivate();
85+
// file.deactivate();
8686
return file;
8787
} finally {
8888
cursor.close();

src/info/guardianproject/database/sqlcipher/SQLiteCursor.java

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
package info.guardianproject.database.sqlcipher;
1818

19-
import android.database.AbstractWindowedCursor;
20-
import android.database.CursorWindow;
21-
import android.database.DataSetObserver;
22-
import android.database.SQLException;
19+
import info.guardianproject.database.*;
2320

2421
import android.os.Handler;
2522
import android.os.Message;
@@ -160,12 +157,15 @@ public void run() {
160157
}
161158
}
162159

160+
163161
/**
164162
* @hide
165163
*/
166164
protected class MainThreadNotificationHandler extends Handler {
167165
public void handleMessage(Message msg) {
168-
notifyDataSetChange();
166+
167+
notifyDataSetChange();
168+
169169
}
170170
}
171171

@@ -182,7 +182,7 @@ public void registerDataSetObserver(DataSetObserver observer) {
182182
try {
183183
mNotificationHandler = new MainThreadNotificationHandler();
184184
if (mPendingData) {
185-
notifyDataSetChange();
185+
notifyDataSetChange();
186186
mPendingData = false;
187187
}
188188
} finally {
@@ -325,7 +325,7 @@ public int getColumnIndex(String columnName) {
325325
* @hide
326326
* @deprecated
327327
*/
328-
@Override
328+
// @Override
329329
public boolean deleteRow() {
330330
checkPosition();
331331

@@ -384,16 +384,17 @@ public String[] getColumnNames() {
384384
* @hide
385385
* @deprecated
386386
*/
387-
@Override
387+
// @Override
388388
public boolean supportsUpdates() {
389-
return super.supportsUpdates() && !TextUtils.isEmpty(mEditTable);
389+
// return super.supportsUpdates() && !TextUtils.isEmpty(mEditTable);
390+
return !TextUtils.isEmpty(mEditTable);
390391
}
391392

392393
/**
393394
* @hide
394395
* @deprecated
395396
*/
396-
@Override
397+
// @Override
397398
public boolean commitUpdates(Map<? extends Long,
398399
? extends Map<String, Object>> additionalValues) {
399400
if (!supportsUpdates()) {
@@ -599,4 +600,57 @@ protected void finalize() {
599600
super.finalize();
600601
}
601602
}
603+
604+
@Override
605+
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
606+
// TODO Auto-generated method stub
607+
608+
}
609+
610+
@Override
611+
public void registerContentObserver(ContentObserver observer) {
612+
// TODO Auto-generated method stub
613+
614+
}
615+
616+
@Override
617+
public void registerDataSetObserver(
618+
android.database.DataSetObserver observer) {
619+
// TODO Auto-generated method stub
620+
621+
}
622+
623+
@Override
624+
public void unregisterContentObserver(ContentObserver observer) {
625+
// TODO Auto-generated method stub
626+
627+
}
628+
629+
@Override
630+
public void unregisterDataSetObserver(
631+
android.database.DataSetObserver observer) {
632+
// TODO Auto-generated method stub
633+
634+
}
635+
636+
@Override
637+
public void copyStringToBuffer(int columnIndex,
638+
android.database.CharArrayBuffer buffer) {
639+
// TODO Auto-generated method stub
640+
641+
}
642+
643+
@Override
644+
public void registerContentObserver(
645+
android.database.ContentObserver observer) {
646+
// TODO Auto-generated method stub
647+
648+
}
649+
650+
@Override
651+
public void unregisterContentObserver(
652+
android.database.ContentObserver observer) {
653+
// TODO Auto-generated method stub
654+
655+
}
602656
}

src/info/guardianproject/database/sqlcipher/SQLiteCursorDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package info.guardianproject.database.sqlcipher;
1818

19-
import android.database.Cursor;
2019
import info.guardianproject.database.sqlcipher.SQLiteDatabase.CursorFactory;
20+
import info.guardianproject.database.*;
2121

2222
/**
2323
* A driver for SQLiteCursors that is used to create them and gets notified

src/info/guardianproject/database/sqlcipher/SQLiteDatabase.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,10 @@
1616

1717
package info.guardianproject.database.sqlcipher;
1818

19-
import com.google.android.collect.Maps;
20-
21-
import android.app.ActivityThread;
22-
import android.content.ContentValues;
23-
import android.database.Cursor;
24-
import android.database.DatabaseUtils;
25-
import android.database.SQLException;
19+
import info.guardianproject.database.Cursor;
20+
import info.guardianproject.database.DatabaseUtils;
21+
import info.guardianproject.database.SQLException;
2622
import info.guardianproject.database.sqlcipher.SQLiteDebug.DbStats;
27-
import android.os.Debug;
28-
import android.os.SystemClock;
29-
import android.os.SystemProperties;
30-
import android.text.TextUtils;
31-
import android.util.Config;
32-
import android.util.EventLog;
33-
import android.util.Log;
34-
import android.util.Pair;
3523

3624
import java.io.File;
3725
import java.lang.ref.WeakReference;
@@ -48,6 +36,17 @@
4836
import java.util.concurrent.locks.ReentrantLock;
4937
import java.util.regex.Pattern;
5038

39+
import com.google.common.collect.Maps;
40+
41+
import android.content.ContentValues;
42+
import android.os.Debug;
43+
import android.os.SystemClock;
44+
import android.text.TextUtils;
45+
import android.util.Config;
46+
import android.util.EventLog;
47+
import android.util.Log;
48+
import android.util.Pair;
49+
5150
/**
5251
* Exposes methods to manage a SQLite database.
5352
* <p>SQLiteDatabase has methods to create, delete, execute SQL commands, and
@@ -825,7 +824,7 @@ public static SQLiteDatabase openDatabase(String path, CursorFactory factory, in
825824
// Try to recover from this, if we can.
826825
// TODO: should we do this for other open failures?
827826
Log.e(TAG, "Deleting and re-creating corrupt database " + path, e);
828-
EventLog.writeEvent(EVENT_DB_CORRUPT, path);
827+
// EventLog.writeEvent(EVENT_DB_CORRUPT, path);
829828
if (!path.equalsIgnoreCase(":memory")) {
830829
// delete is only for non-memory database files
831830
new File(path).delete();
@@ -1550,6 +1549,7 @@ public long insertWithOnConflict(String table, String nullColumnHack,
15501549
for (int i = 0; i < size; i++) {
15511550
Map.Entry<String, Object> entry = entriesIter.next();
15521551
DatabaseUtils.bindObjectToProgram(statement, i + 1, entry.getValue());
1552+
15531553
}
15541554
}
15551555

@@ -1814,7 +1814,7 @@ private SQLiteDatabase(String path, CursorFactory factory, int flags) {
18141814
}
18151815
mFlags = flags;
18161816
mPath = path;
1817-
mSlowQueryThreshold = SystemProperties.getInt(LOG_SLOW_QUERIES_PROPERTY, -1);
1817+
mSlowQueryThreshold = -1;//SystemProperties.getInt(LOG_SLOW_QUERIES_PROPERTY, -1);
18181818
mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
18191819
mFactory = factory;
18201820
dbopen(mPath, mFlags);
@@ -1888,7 +1888,7 @@ public final String getPath() {
18881888
return;
18891889
}
18901890
if (sQueryLogTimeInMillis == 0) {
1891-
sQueryLogTimeInMillis = SystemProperties.getInt("db.db_operation.threshold_ms", 500);
1891+
sQueryLogTimeInMillis = 500;//SystemProperties.getInt("db.db_operation.threshold_ms", 500);
18921892
}
18931893
if (durationMillis >= sQueryLogTimeInMillis) {
18941894
samplePercent = 100;
@@ -1913,7 +1913,8 @@ public final String getPath() {
19131913
// main thread, or when we are invoked via Binder (e.g. ContentProvider).
19141914
// Hopefully the full path to the database will be informative enough.
19151915

1916-
String blockingPackage = ActivityThread.currentPackageName();
1916+
//TODO get the current package name
1917+
String blockingPackage = "unknown";//ActivityThread.currentPackageName();
19171918
if (blockingPackage == null) blockingPackage = "";
19181919

19191920
EventLog.writeEvent(

src/info/guardianproject/database/sqlcipher/SQLiteDirectCursorDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package info.guardianproject.database.sqlcipher;
1818

19-
import android.database.Cursor;
19+
import info.guardianproject.database.*;
2020
import info.guardianproject.database.sqlcipher.SQLiteDatabase.CursorFactory;
2121

2222
/**

src/info/guardianproject/database/sqlcipher/SQLiteException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDif 341A f line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package info.guardianproject.database.sqlcipher;
1818

19-
import android.database.SQLException;
19+
import info.guardianproject.database.*;
2020

2121
/**
2222
* A SQLite exception that indicates there was an error with SQL parsing or execution.

src/info/guardianproject/database/sqlcipher/SQLiteOpenHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ public synchronized SQLiteDatabase getWritableDatabase() {
9494
mIsInitializing = true;
9595
if (mName == null) {
9696
db = SQLiteDatabase.create(null);
97+
9798
} else {
98-
db = mContext.openOrCreateDatabase(mName, 0, mFactory);
99+
100+
//db = mContext.openOrCreateDatabase(mName, 0, mFactory);
99101
}
100102

101103
int version = db.getVersion();

src/info/guardianproject/database/sqlcipher/SQLiteQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
package info.guardianproject.database.sqlcipher;
18+
import info.guardianproject.database.*;
1819

19-
import android.database.CursorWindow;
2020
import android.os.SystemClock;
2121
import android.util.Log;
2222

0 commit comments

Comments
 (0)
0