// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.olio.data.object.analytics.database; import android.content.ContentProvider; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteFullException; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import com.olio.olios.model.record.DatabaseRecord; import com.olio.olios.model.record.DatabaseRecordMixins; import com.olio.util.ALog; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; // Referenced classes of package com.olio.data.object.analytics.database: // AnalyticsDataContract, AnalyticsDatabaseHelper public class AnalyticsDataProvider extends ContentProvider { public static final String NO = "NO"; private static final int REQUEST = 1; private static final int REQUEST_ID = 2; private static final int REQUEST_ID_PATH_POSITION = 1; public static final String SHOULD_NOTIFY_KEY = "shouldNotify"; public static final String TYPE_NAME = "typeName"; public static final String YES = "YES"; private static final Map uriMatchers; private AnalyticsDatabaseHelper mDataHelper; public AnalyticsDataProvider() { } public static void clearDatabase(Context context) { SQLiteDatabase sqlitedatabase = (new AnalyticsDatabaseHelper(context)).getWritableDatabase(); com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = AnalyticsDataContract.getDatabaseTables(); int j = adatabaserecordfactory.length; for (int i = 0; i < j; i++) { String s = adatabaserecordfactory[i].getRecordInstance().tableName(); ALog.d("%s rows deleted from table '%s'", new Object[] { Integer.valueOf(sqlitedatabase.delete(s, "1", null)), s }); } sqlitedatabase.close(); ALog.d("%s rows deleted from table 'notifications'", new Object[] { Integer.valueOf(com.olio.communication.notifications.NotificationContract.Notifications.clearDatabase(context.getContentResolver())) }); } public int delete(Uri uri, String s, String as[]) { Iterator iterator; SQLiteDatabase sqlitedatabase; boolean flag; flag = false; ALog.d((new StringBuilder()).append("DataProvider: delete called for uri: ").append(uri.toString()).toString(), new Object[0]); sqlitedatabase = mDataHelper.getWritableDatabase(); if (!Objects.equals(uri.getQueryParameter("shouldNotify"), "NO")) { flag = true; } iterator = uriMatchers.keySet().iterator(); _L4: if (!iterator.hasNext()) goto _L2; else goto _L1 _L1: UriMatcher urimatcher; int i; urimatcher = (UriMatcher)iterator.next(); i = urimatcher.match(uri); if (i == -1) goto _L4; else goto _L3 _L3: DatabaseRecord databaserecord = ((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(urimatcher)).getRecordInstance(); i; JVM INSTR tableswitch 1 2: default 152 // 1 179 // 2 215; goto _L5 _L6 _L7 _L5: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); _L6: i = sqlitedatabase.delete(databaserecord.tableName(), s, as); _L8: if (flag) { getContext().getContentResolver().notifyChange(uri, null); } return i; _L7: String s2 = (new StringBuilder()).append(databaserecord.indexColumn()).append("=").append((String)uri.getPathSegments().get(1)).toString(); String s1 = s2; if (s != null) { s1 = (new StringBuilder()).append(s2).append(" AND ").append(s).toString(); } i = sqlitedatabase.delete(databaserecord.tableName(), s1, as); if (true) goto _L8; else goto _L2 _L2: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } public String getType(Uri uri) { return "vnd.android.cursor.dir/vnd.olio.data"; } public Uri insert(Uri uri, ContentValues contentvalues) { ALog.d((new StringBuilder()).append("DataProvider: insert called for uri: ").append(uri.toString()).toString(), new Object[0]); Object obj1 = null; Iterator iterator = uriMatchers.keySet().iterator(); Object obj; do { obj = obj1; if (!iterator.hasNext()) { break; } obj = (UriMatcher)iterator.next(); } while (((UriMatcher) (obj)).match(uri) != 1); if (obj == null) { throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } boolean flag; long l; if (!Objects.equals(uri.getQueryParameter("shouldNotify"), "NO")) { flag = true; } else { flag = false; } if (contentvalues != null) { contentvalues = new ContentValues(contentvalues); } else { contentvalues = new ContentValues(); } obj1 = Long.valueOf(GregorianCalendar.getInstance().getTimeInMillis()); if (!contentvalues.containsKey("date_created")) { contentvalues.put("date_created", ((Long) (obj1))); } if (!contentvalues.containsKey("date_modified")) { contentvalues.put("date_modified", ((Long) (obj1))); } obj1 = mDataHelper.getWritableDatabase(); obj = (com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(obj); try { l = ((SQLiteDatabase) (obj1)).insertWithOnConflict(((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory) (obj)).getRecordInstance().tableName(), null, contentvalues, 2); } // Misplaced declaration of an exception variable catch (Uri uri) { ALog.e("Unable to log more analytics (insert)", new Object[0]); return null; } if (l > 0L) { contentvalues = ContentUris.withAppendedId(DatabaseRecordMixins.baseUriForAnalyticsTable(((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory) (obj))), l); obj = uri.getQueryParameter("typeName"); uri = contentvalues; if (obj != null) { uri = contentvalues.buildUpon().appendQueryParameter("typeName", ((String) (obj))).build(); } if (flag) { getContext().getContentResolver().notifyChange(uri, null); } return uri; } else { throw new SQLException((new StringBuilder()).append("Failed to insert row into ").append(uri).toString()); } } public boolean onCreate() { mDataHelper = new AnalyticsDatabaseHelper(getContext()); return true; } public Cursor query(Uri uri, String as[], String s, String as1[], String s1) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = AnalyticsDataContract.getDatabaseTables(); int k = adatabaserecordfactory.length; for (int i = 0; i < k; i++) { Cursor cursor = adatabaserecordfactory[i].getRecordInstance().handleCustomUriQuery(uri, as, s, as1, s1); if (cursor != null) { return cursor; } } s1 = uriMatchers.keySet().iterator(); _L4: if (!s1.hasNext()) goto _L2; else goto _L1 _L1: Object obj; int j; obj = (UriMatcher)s1.next(); j = ((UriMatcher) (obj)).match(uri); if (j == -1) goto _L4; else goto _L3 _L3: SQLiteDatabase sqlitedatabase; s1 = new SQLiteQueryBuilder(); obj = ((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(obj)).getRecordInstance(); s1.setTables(((DatabaseRecord) (obj)).tableName()); sqlitedatabase = mDataHelper.getReadableDatabase(); j; JVM INSTR tableswitch 1 2: default 188 // 1 188 // 2 209; goto _L5 _L5 _L6 _L5: return s1.query(sqlitedatabase, as, s, as1, null, null, ((DatabaseRecord) (obj)).defaultOrderBy()); _L6: s1.appendWhere((new StringBuilder()).append(((DatabaseRecord) (obj)).indexColumn()).append("=").append((String)uri.getPathSegments().get(1)).toString()); if (true) goto _L5; else goto _L2 _L2: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } public int update(Uri uri, ContentValues contentvalues, String s, String as[]) { SQLiteDatabase sqlitedatabase; DatabaseRecord databaserecord; boolean flag; int k; ALog.d((new StringBuilder()).append("DataProvider: update called for uri: ").append(uri.toString()).toString(), new Object[0]); sqlitedatabase = mDataHelper.getWritableDatabase(); Iterator iterator; UriMatcher urimatcher; int i; long l; if (!Objects.equals(uri.getQueryParameter("shouldNotify"), "NO")) { flag = true; } else { flag = false; } l = GregorianCalendar.getInstance().getTimeInMillis(); if (!contentvalues.containsKey("date_modified")) { contentvalues.put("date_modified", Long.valueOf(l)); } iterator = uriMatchers.keySet().iterator(); _L4: if (!iterator.hasNext()) goto _L2; else goto _L1 _L1: urimatcher = (UriMatcher)iterator.next(); i = urimatcher.match(uri); if (i == -1) goto _L4; else goto _L3 _L3: databaserecord = ((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(urimatcher)).getRecordInstance(); i; JVM INSTR tableswitch 1 2: default 398 // 1 230 // 2 272; goto _L5 _L6 _L7 _L5: try { throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } // Misplaced declaration of an exception variable catch (Uri uri) { ALog.e("Unable to log more analytics (update)", new Object[0]); } k = 0; _L9: return k; _L6: int j = sqlitedatabase.update(databaserecord.tableName(), contentvalues, s, as); _L12: k = j; if (!flag) goto _L9; else goto _L8 _L8: getContext().getContentResolver().notifyChange(uri, null); return j; _L7: String s2 = (new StringBuilder()).append(databaserecord.indexColumn()).append("=").append((String)uri.getPathSegments().get(1)).toString(); String s1 = s2; if (s == null) goto _L11; else goto _L10 _L10: s1 = (new StringBuilder()).append(s2).append(" AND ").append(s).toString(); _L11: j = sqlitedatabase.update(databaserecord.tableName(), contentvalues, s1, as); goto _L12 _L2: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } static { uriMatchers = new HashMap(); com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = AnalyticsDataContract.getDatabaseTables(); int j = adatabaserecordfactory.length; for (int i = 0; i < j; i++) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory = adatabaserecordfactory[i]; UriMatcher urimatcher = new UriMatcher(-1); urimatcher.addURI("com.olio.data.object.analytics.database.Data", databaserecordfactory.getRecordInstance().tableName(), 1); urimatcher.addURI("com.olio.data.object.analytics.database.Data", (new StringBuilder()).append(databaserecordfactory.getRecordInstance().tableName()).append("/#").toString(), 2); uriMatchers.put(urimatcher, databaserecordfactory); } } }