Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 271b9ae5 authored by Yong Jiang's avatar Yong Jiang Committed by John Huang
Browse files

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
parent 88336c2e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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" />
+17 −0
Original line number Diff line number Diff line
@@ -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 @@ final class CallLogManager extends CallsManagerListenerBase {
    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 @@ final class CallLogManager extends CallsManagerListenerBase {
        // 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 @@ final class CallLogManager extends CallsManagerListenerBase {
            }
        }
    }

    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);
    }
}