// 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.olios.model; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import com.olio.communication.bluetooth.channel_messages.ANCSNotification; import com.olio.olios.model.record.DatabaseRecord; import com.olio.util.ALog; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; // Referenced classes of package com.olio.olios.model: // DataContract public class OlioDatabaseHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "data_contract_database"; private static final int DATABASE_VERSION = 31; private static com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaseTablesToReset[] = { ANCSNotification.staticFactory() }; HashMap mModifiedTables; public OlioDatabaseHelper(Context context) { super(context, "data_contract_database", null, 31); mModifiedTables = new HashMap(); } private void cleanTables(SQLiteDatabase sqlitedatabase, int i) { mModifiedTables.put(Integer.valueOf(21), Arrays.asList(new String[] { "phone_call_status" })); mModifiedTables.put(Integer.valueOf(23), Arrays.asList(new String[] { "file_transfers" })); mModifiedTables.put(Integer.valueOf(24), Arrays.asList(new String[] { "ancs_notifications" })); mModifiedTables.put(Integer.valueOf(25), Arrays.asList(new String[] { "analytics_logs" })); mModifiedTables.put(Integer.valueOf(26), Arrays.asList(new String[] { "ancs_notifications" })); mModifiedTables.put(Integer.valueOf(27), Arrays.asList(new String[] { "ancs_notifications" })); mModifiedTables.put(Integer.valueOf(28), Arrays.asList(new String[] { "ancs_notifications" })); mModifiedTables.put(Integer.valueOf(29), Arrays.asList(new String[] { "bluetooth_status" })); mModifiedTables.put(Integer.valueOf(30), Arrays.asList(new String[] { "file_transfers" })); mModifiedTables.put(Integer.valueOf(31), Arrays.asList(new String[] { "active_remind_me_later" })); Iterator iterator = mModifiedTables.entrySet().iterator(); do { if (!iterator.hasNext()) { break; } Object obj = (java.util.Map.Entry)iterator.next(); if (((Integer)((java.util.Map.Entry) (obj)).getKey()).intValue() > i) { obj = ((List)((java.util.Map.Entry) (obj)).getValue()).iterator(); while (((Iterator) (obj)).hasNext()) { String s = (String)((Iterator) (obj)).next(); try { ALog.d("dropping table %s", new Object[] { s }); sqlitedatabase.execSQL((new StringBuilder()).append("DROP TABLE IF EXISTS ").append(s).toString()); } catch (IllegalArgumentException illegalargumentexception) { ALog.e(illegalargumentexception.toString(), new Object[0]); illegalargumentexception.printStackTrace(); } } } } while (true); } private String createStatementForRecordFactory(com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory) { Object obj = databaserecordfactory.getRecordInstance(); databaserecordfactory = new StringBuilder(); databaserecordfactory.append((new StringBuilder()).append("CREATE TABLE ").append(((DatabaseRecord) (obj)).tableName()).append(" ( \n").toString()); databaserecordfactory.append("_id INTEGER PRIMARY KEY,\n"); obj = ((DatabaseRecord) (obj)).recordFields().iterator(); do { if (!((Iterator) (obj)).hasNext()) { break; } com.olio.olios.model.record.DatabaseRecord.RecordField recordfield = (com.olio.olios.model.record.DatabaseRecord.RecordField)((Iterator) (obj)).next(); if (!recordfield.columnName().equals("_id") && !recordfield.columnName().equals("date_created") && !recordfield.columnName().equals("date_modified")) { databaserecordfactory.append((new StringBuilder()).append(recordfield.columnName()).append(" ").append(recordfield.createType()).append(",\n").toString()); } } while (true); databaserecordfactory.append("date_created LONG,\n"); databaserecordfactory.append("date_modified LONG\n"); databaserecordfactory.append(");"); return databaserecordfactory.toString(); } public void onCreate(SQLiteDatabase sqlitedatabase) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = DataContract.getDatabaseTables(); int j = adatabaserecordfactory.length; int i = 0; while (i < j) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory = adatabaserecordfactory[i]; try { sqlitedatabase.execSQL(createStatementForRecordFactory(databaserecordfactory)); } catch (SQLiteException sqliteexception) { ALog.w("Problem creating database: %s", sqliteexception, new Object[] { databaserecordfactory.getRecordInstance().tableName() }); } i++; } } public void onDowngrade(SQLiteDatabase sqlitedatabase, int i, int j) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = DataContract.getDatabaseTables(); j = adatabaserecordfactory.length; for (i = 0; i < j; i++) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory = adatabaserecordfactory[i]; sqlitedatabase.execSQL((new StringBuilder()).append("DROP TABLE IF EXISTS ").append(databaserecordfactory.getRecordInstance().tableName()).toString()); } onCreate(sqlitedatabase); } public void onOpen(SQLiteDatabase sqlitedatabase) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = databaseTablesToReset; int j = adatabaserecordfactory.length; for (int i = 0; i < j; i++) { sqlitedatabase.delete(adatabaserecordfactory[i].getRecordInstance().tableName(), null, null); } } public void onUpgrade(SQLiteDatabase sqlitedatabase, int i, int j) { ALog.d("onUpgrade -- old version: %d new version: %d", new Object[] { Integer.valueOf(i), Integer.valueOf(j) }); cleanTables(sqlitedatabase, i); onCreate(sqlitedatabase); } }