summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Catania <niko@google.com>2010-01-14 10:44:02 -0800
committerNicolas Catania <niko@google.com>2010-01-15 08:19:45 -0800
commitac835c94b81c9497404a27af4da9c957e5c82045 (patch)
tree32cf79cd662d66a1fc671d6bc9629491f8e04a2b
parent0f26ec1aa10f070dea33a24de02bb766ef698c0a (diff)
downloadframeworks_base-ac835c94b81c9497404a27af4da9c957e5c82045.zip
frameworks_base-ac835c94b81c9497404a27af4da9c957e5c82045.tar.gz
frameworks_base-ac835c94b81c9497404a27af4da9c957e5c82045.tar.bz2
New method to return the last dialed number
Bug:2227429
-rw-r--r--api/current.xml17
-rw-r--r--core/java/android/provider/CallLog.java54
2 files changed, 55 insertions, 16 deletions
diff --git a/api/current.xml b/api/current.xml
index 1142088..b3f54f4 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -119402,6 +119402,19 @@
visibility="public"
>
</constructor>
+<method name="getLastOutgoingCall"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+</method>
<field name="CACHED_NAME"
type="java.lang.String"
transient="false"
@@ -126082,7 +126095,7 @@
value="1"
static="true"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
</field>
@@ -126135,7 +126148,7 @@
abstract="false"
static="true"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<implements name="android.provider.BaseColumns">
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index 7854423..d52632b 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -22,6 +22,7 @@ import com.android.internal.telephony.Connection;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
+import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
@@ -111,25 +112,25 @@ public class CallLog {
* <P>Type: TEXT</P>
*/
public static final String CACHED_NAME = "name";
-
+
/**
* The cached number type (Home, Work, etc) associated with the
* phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed.
- * <P>Type: INTEGER</P>
+ * <P>Type: INTEGER</P>
*/
public static final String CACHED_NUMBER_TYPE = "numbertype";
-
+
/**
* The cached number label, for a custom number type, associated with the
* phone number, if it exists.
* This value is not guaranteed to be current, if the contact information
* associated with this number has changed.
- * <P>Type: TEXT</P>
+ * <P>Type: TEXT</P>
*/
public static final String CACHED_NUMBER_LABEL = "numberlabel";
-
+
/**
* Adds a call to the call log.
*
@@ -137,15 +138,15 @@ public class CallLog {
* if the contact is unknown.
* @param context the context used to get the ContentResolver
* @param number the phone number to be added to the calls db
- * @param presentation the number presenting rules set by the network for
+ * @param presentation the number presenting rules set by the network for
* "allowed", "payphone", "restricted" or "unknown"
* @param callType enumerated values for "incoming", "outgoing", or "missed"
* @param start time stamp for the call in milliseconds
* @param duration call duration in seconds
- *
+ *
* {@hide}
*/
- public static Uri addCall(CallerInfo ci, Context context, String number,
+ public static Uri addCall(CallerInfo ci, Context context, String number,
int presentation, int callType, long start, int duration) {
final ContentResolver resolver = context.getContentResolver();
@@ -175,22 +176,47 @@ public class CallLog {
values.put(CACHED_NUMBER_TYPE, ci.numberType);
values.put(CACHED_NUMBER_LABEL, ci.numberLabel);
}
-
+
if ((ci != null) && (ci.person_id > 0)) {
ContactsContract.Contacts.markAsContacted(resolver, ci.person_id);
}
-
+
Uri result = resolver.insert(CONTENT_URI, values);
-
+
removeExpiredEntries(context);
-
+
return result;
}
-
+
+ /**
+ * Query the call log database for the last dialed number.
+ * @param context Used to get the content resolver.
+ * @return The last phone number dialed (outgoing) or an empty
+ * string if none exist yet.
+ */
+ public static String getLastOutgoingCall(Context context) {
+ final ContentResolver resolver = context.getContentResolver();
+ Cursor c = null;
+ try {
+ c = resolver.query(
+ CONTENT_URI,
+ new String[] {NUMBER},
+ TYPE + " = " + OUTGOING_TYPE,
+ null,
+ DEFAULT_SORT_ORDER + " LIMIT 1");
+ if (c == null || !c.moveToFirst()) {
+ return "";
+ }
+ return c.getString(0);
+ } finally {
+ if (c != null) c.close();
+ }
+ }
+
private static void removeExpiredEntries(Context context) {
final ContentResolver resolver = context.getContentResolver();
resolver.delete(CONTENT_URI, "_id IN " +
- "(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
+ "(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
+ " LIMIT -1 OFFSET 500)", null);
}
}