[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] bug fix
commit 67d999b8317282ca375f85344e81ebee7f063750
Author: arrase <arrase@xxxxxxxxx>
Date: Thu Nov 17 20:45:40 2016 +0100
bug fix
---
.../android/ui/hs/providers/HSContentProvider.java | 12 ++++++-
.../org/torproject/android/service/TorService.java | 39 +++++++++++-----------
2 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java b/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java
index 9b52a37..d340499 100644
--- a/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java
+++ b/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java
@@ -106,7 +106,17 @@ public class HSContentProvider extends ContentProvider {
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- return 0;
+ SQLiteDatabase db = mServerDB.getWritableDatabase();
+
+ String where = selection;
+ if (uriMatcher.match(uri) == ONION_ID) {
+ where = "_id=" + uri.getLastPathSegment();
+ }
+
+ Integer rows = db.update(HSDatabase.HS_DATA_TABLE_NAME, values, where, null);
+ mContext.getContentResolver().notifyChange(CONTENT_URI, null);
+
+ return rows;
}
public static final class HiddenService implements BaseColumns {
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
index 915aad7..09a75ca 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
@@ -773,29 +773,28 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
Integer HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.PORT));
// Update only new domains
- if(!"".equals(HSDomain))
- continue;
+ if(HSDomain == null || HSDomain.length() < 1) {
+ String hsDirPath = new File(appCacheHome,"hs" + HSLocalPort).getCanonicalPath();
+ File file = new File(hsDirPath, "hostname");
- String hsDirPath = new File(appCacheHome,"hs" + HSLocalPort).getCanonicalPath();
- File file = new File(hsDirPath, "hostname");
-
- if (file.exists())
- {
- ContentValues fields = new ContentValues();
-
- try {
- String onionHostname = Utils.readString(new FileInputStream(file)).trim();
- fields.put("domain", onionHostname);
- mCR.update(CONTENT_URI, fields, "port=" + HSLocalPort , null);
- } catch (FileNotFoundException e) {
- logException("unable to read onion hostname file",e);
- showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ if (file.exists())
+ {
+ ContentValues fields = new ContentValues();
+
+ try {
+ String onionHostname = Utils.readString(new FileInputStream(file)).trim();
+ fields.put("domain", onionHostname);
+ mCR.update(CONTENT_URI, fields, "port=" + HSLocalPort , null);
+ } catch (FileNotFoundException e) {
+ logException("unable to read onion hostname file",e);
+ showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ }
}
- }
- else
- {
- showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ else
+ {
+ showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ }
}
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits