Esempio n. 1
0
  /**
   * Get friend key associated with event id
   *
   * @param context Context with permissions to access Notification db
   * @param eventId Id of event
   * @return Event title or null if not found.
   */
  public static String getFriendKey(final Context context, long eventId) {
    Cursor cursor = null;
    String freindKey = null;
    try {
      cursor =
          queryEvents(
              context,
              new String[] {Notification.EventColumns.FRIEND_KEY},
              EVENT_ID + " = " + eventId,
              null,
              null);

      if (cursor != null && cursor.moveToFirst()) {
        int titleIndex = cursor.getColumnIndex(Notification.EventColumns.FRIEND_KEY);
        freindKey = cursor.getString(titleIndex);
      }
    } catch (SQLException e) {
      if (Dbg.DEBUG) {
        Dbg.w("Failed to query events", e);
      }
    } catch (SecurityException e) {
      if (Dbg.DEBUG) {
        Dbg.w("Failed to query events", e);
      }
    } catch (IllegalArgumentException e) {
      if (Dbg.DEBUG) {
        Dbg.w("Failed to query events", e);
      }
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
    return freindKey;
  }
Esempio n. 2
0
 /**
  * Get source ids associated with extension.
  *
  * @param context Context with permissions to access Notification db
  * @return Source ids, empty array if not found
  */
 public static ArrayList<Integer> getSourceIds(final Context context, boolean enabled) {
   ArrayList<Integer> sourceIds = new ArrayList<Integer>();
   Cursor cursor = null;
   String where = Notification.SourceColumns.ENABLED + "=" + (enabled ? "1" : "0");
   try {
     cursor =
         querySources(context, new String[] {Notification.SourceColumns._ID}, where, null, null);
     while (cursor != null && cursor.moveToNext()) {
       sourceIds.add(cursor.getInt(cursor.getColumnIndex(Notification.SourceColumns._ID)));
     }
   } catch (SQLException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to query source", e);
     }
   } catch (SecurityException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to query source", e);
     }
   } catch (IllegalArgumentException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to query source", e);
     }
   } finally {
     if (cursor != null) {
       cursor.close();
     }
   }
   return sourceIds;
 }
Esempio n. 3
0
 /**
  * Get all source ids associated with extension
  *
  * @param context Context with permissions to access Notification db
  * @return All source ids, empty array if not found
  */
 public static ArrayList<Long> getSourceIds(final Context context) {
   ArrayList<Long> sourceIds = new ArrayList<Long>();
   Cursor cursor = null;
   try {
     cursor =
         querySources(context, new String[] {Notification.SourceColumns._ID}, null, null, null);
     if (cursor != null && cursor.moveToFirst()) {
       do {
         sourceIds.add(cursor.getLong(cursor.getColumnIndex(Notification.SourceColumns._ID)));
       } while (cursor.moveToNext());
     }
   } catch (SQLException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to query sources", e);
     }
   } catch (SecurityException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to query sources", e);
     }
   } catch (IllegalArgumentException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to query sources", e);
     }
   } finally {
     if (cursor != null) {
       cursor.close();
     }
   }
   return sourceIds;
 }
Esempio n. 4
0
 /**
  * Add new event to Event table
  *
  * @param context Context with permissions to access Notification db
  * @param eventValues A reference to the notification com.sonyericsson.extras
  *     .liveware.aef.notification.Notification.
  * @return Uri to the created event
  */
 public static Uri addEvent(final Context context, final ContentValues eventValues) {
   try {
     return context.getContentResolver().insert(Notification.Event.URI, eventValues);
   } catch (SQLException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to add event", e);
     }
   } catch (SecurityException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to add event", e);
     }
   } catch (IllegalArgumentException e) {
     if (Dbg.DEBUG) {
       Dbg.w("Failed to add event", e);
     }
   }
   return null;
 }