Broadcast the call type/duration information
Allows interested system app to update information like life timer of device
and call durations. Intent is restricted to system apps.
Bug: 17571977
Change-Id: Ie61da174bf6bce479449e8153e318de026775652
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3877edf..5d11fb3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -36,6 +36,7 @@
<uses-permission android:name="android.permission.BIND_CONNECTION_SERVICE" />
<uses-permission android:name="android.permission.BIND_INCALL_SERVICE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
+ <uses-permission android:name="android.permission.BROADCAST_CALLLOG_INFO" />
<!-- Protects the ability to register any PhoneAccount with a capability flags of either
PhoneAccount#CAPABILITY_CALL_PROVIDER or PhoneAccount#CAPABILITY_SIM_SUBSCRIPTION. -->
@@ -44,6 +45,16 @@
android:label="Register CALL_PROVIDER or SIM_SUBSCRIPTION PhoneAccount"
android:protectionLevel="signature"/>
+ <permission
+ android:name="android.permission.BROADCAST_CALLLOG_INFO"
+ android:label="Broadcast the call type/duration information"
+ android:protectionLevel="signature|system"/>
+
+ <permission
+ android:name="android.permission.PROCESS_CALLLOG_INFO"
+ android:label="Register to handle the broadcasted call type/duration information"
+ android:protectionLevel="signature|system"/>
+
<!-- Declare which SDK level this application was built against. This is needed so that IDEs
can check for incompatible APIs. -->
<uses-sdk android:minSdkVersion="19" />
diff --git a/src/com/android/server/telecom/CallLogManager.java b/src/com/android/server/telecom/CallLogManager.java
old mode 100644
new mode 100755
index 89d9316..658af10
--- a/src/com/android/server/telecom/CallLogManager.java
+++ b/src/com/android/server/telecom/CallLogManager.java
@@ -17,6 +17,8 @@
package com.android.server.telecom;
import android.content.Context;
+import android.content.Intent;
+import android.Manifest.permission;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.CallLog.Calls;
@@ -83,6 +85,12 @@
private static final String TAG = CallLogManager.class.getSimpleName();
private final Context mContext;
+ private static final String ACTION_CALLS_TABLE_ADD_ENTRY =
+ "com.android.server.telecom.intent.action.CALLS_ADD_ENTRY";
+ private static final String PERMISSION_PROCESS_CALLLOG_INFO =
+ "android.permission.PROCESS_CALLLOG_INFO";
+ private static final String CALL_TYPE = "callType";
+ private static final String CALL_DURATION = "duration";
public CallLogManager(Context context) {
mContext = context;
@@ -174,6 +182,8 @@
// Don't log emergency numbers if the device doesn't allow it.
final boolean isOkToLogThisCall = !isEmergencyNumber || okToLogEmergencyNumber;
+ sendAddCallBroadcast(callType, duration);
+
if (isOkToLogThisCall) {
Log.d(TAG, "Logging Calllog entry: " + callerInfo + ", "
+ Log.pii(number) + "," + presentation + ", " + callType
@@ -293,4 +303,11 @@
}
}
}
+
+ private void sendAddCallBroadcast(int callType, long duration) {
+ Intent callAddIntent = new Intent(ACTION_CALLS_TABLE_ADD_ENTRY);
+ callAddIntent.putExtra(CALL_TYPE, callType);
+ callAddIntent.putExtra(CALL_DURATION, duration);
+ mContext.sendBroadcast(callAddIntent, PERMISSION_PROCESS_CALLLOG_INFO);
+ }
}