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

Commit 9e51994d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Switch TelephonyEventLog from using ITelephonyDebug to...

Merge "Switch TelephonyEventLog from using ITelephonyDebug to ConnectivityMetricsLogger" into nyc-dev
parents e8165ef3 7a1c1b02
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -153,7 +153,7 @@ public class GsmCdmaCallTracker extends CallTracker {


        updatePhoneType(true);
        updatePhoneType(true);


        mEventLog = TelephonyEventLog.getInstance(mPhone.getContext(), mPhone.getPhoneId());
        mEventLog = new TelephonyEventLog(mPhone.getPhoneId());
    }
    }


    public void updatePhoneType() {
    public void updatePhoneType() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -719,7 +719,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        TelephonyDevController tdc = TelephonyDevController.getInstance();
        TelephonyDevController tdc = TelephonyDevController.getInstance();
        tdc.registerRIL(this);
        tdc.registerRIL(this);


        mEventLog = TelephonyEventLog.getInstance(mContext, mInstanceId);
        mEventLog = new TelephonyEventLog(mInstanceId);
    }
    }


    //***** CommandsInterface implementation
    //***** CommandsInterface implementation
+1 −1
Original line number Original line Diff line number Diff line
@@ -536,7 +536,7 @@ public class ServiceStateTracker extends Handler {
        filter.addAction(ACTION_RADIO_OFF);
        filter.addAction(ACTION_RADIO_OFF);
        context.registerReceiver(mIntentReceiver, filter);
        context.registerReceiver(mIntentReceiver, filter);


        mEventLog = TelephonyEventLog.getInstance(mPhone.getContext(), mPhone.getPhoneId());
        mEventLog = new TelephonyEventLog(mPhone.getPhoneId());
    }
    }


    @VisibleForTesting
    @VisibleForTesting
+16 −45
Original line number Original line Diff line number Diff line
@@ -5,14 +5,15 @@ import com.android.ims.ImsReasonInfo;
import com.android.ims.internal.ImsCallSession;
import com.android.ims.internal.ImsCallSession;
import com.android.internal.telephony.dataconnection.DataCallResponse;
import com.android.internal.telephony.dataconnection.DataCallResponse;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.ITelephonyDebug;


import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.ServiceConnection;
import android.net.ConnectivityMetricsLogger;
import android.os.Bundle;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.RemoteException;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.util.Log;
import android.util.Log;
@@ -27,7 +28,7 @@ import static com.android.internal.telephony.RILConstants.*;
 *
 *
 * @hide
 * @hide
 */
 */
public class TelephonyEventLog {
public class TelephonyEventLog extends ConnectivityMetricsLogger {
    private static String TAG = "TelephonyEventLog";
    private static String TAG = "TelephonyEventLog";
    private static final boolean DBG = true;
    private static final boolean DBG = true;
    private static final boolean VDBG = false; // STOPSHIP if true
    private static final boolean VDBG = false; // STOPSHIP if true
@@ -99,6 +100,10 @@ public class TelephonyEventLog {
    public static final int IMS_CONNECTION_STATE_RESUMED = 4;
    public static final int IMS_CONNECTION_STATE_RESUMED = 4;
    public static final int IMS_CONNECTION_STATE_SUSPENDED = 5;
    public static final int IMS_CONNECTION_STATE_SUSPENDED = 5;


    public static final String DATA_KEY_PHONE_ID = "phoneId";
    public static final String DATA_KEY_PARAM1 = "param1";
    public static final String DATA_KEY_PARAM2 = "param2";

    public static final String DATA_KEY_REASONINFO_CODE = "code";
    public static final String DATA_KEY_REASONINFO_CODE = "code";
    public static final String DATA_KEY_REASONINFO_EXTRA_CODE = "extra-code";
    public static final String DATA_KEY_REASONINFO_EXTRA_CODE = "extra-code";
    public static final String DATA_KEY_REASONINFO_EXTRA_MESSAGE = "extra-message";
    public static final String DATA_KEY_REASONINFO_EXTRA_MESSAGE = "extra-message";
@@ -137,41 +142,11 @@ public class TelephonyEventLog {
    public static final String DATA_KEY_TARGET_TECH = "target-tech";
    public static final String DATA_KEY_TARGET_TECH = "target-tech";


    int mPhoneId;
    int mPhoneId;
    private ITelephonyDebug mService;

    private static final SparseArray<TelephonyEventLog> sInstances =
            new SparseArray<TelephonyEventLog>();

    public static TelephonyEventLog getInstance(Context context, int phoneId) {
        synchronized (sInstances) {
            if (sInstances.get(phoneId) == null) {
                TelephonyEventLog mgr = new TelephonyEventLog(context, phoneId);
                sInstances.put(phoneId, mgr);
            }


            return sInstances.get(phoneId);
    public TelephonyEventLog(int phoneId) {
        }
        super();
    }


    private TelephonyEventLog(Context context, int phoneId) {
        mPhoneId = phoneId;
        mPhoneId = phoneId;

        final Intent intent = new Intent();
        intent.setClassName(context, "com.android.phone.TelephonyDebugService");

        ServiceConnection connection = new ServiceConnection() {
            public void onServiceConnected(ComponentName className, IBinder service) {
                if (DBG) Log.d(TAG, "onServiceConnected()");
                mService = ITelephonyDebug.Stub.asInterface(service);
            }

            public void onServiceDisconnected(ComponentName className) {
                if (DBG) Log.d(TAG, "onServiceDisconnected()");
                mService = null;
            }
        };

        context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
    }
    }


    private void writeEvent(int tag, Bundle data) {
    private void writeEvent(int tag, Bundle data) {
@@ -187,19 +162,15 @@ public class TelephonyEventLog {
    }
    }


    private void writeEvent(long timestamp, int tag, int param1, int param2, Bundle data) {
    private void writeEvent(long timestamp, int tag, int param1, int param2, Bundle data) {
        if (mService == null) {
        Bundle b = data;
            if (VDBG) {
        if (b == null) {
                Log.d(TAG, "writeEvent("+tag+","+param1+","+param2+","+data+")"
            b = new Bundle();
                        + " Service not ready");
            }
            return;
        }
        }
        b.putInt(DATA_KEY_PHONE_ID, mPhoneId);
        b.putInt(DATA_KEY_PARAM1, param1);
        b.putInt(DATA_KEY_PARAM2, param2);


        try {
        logEvent(timestamp, ConnectivityMetricsLogger.COMPONENT_TAG_TELEPHONY, tag, b);
            mService.writeEvent(timestamp, mPhoneId, tag, param1, param2, data);
        } catch (RemoteException e) {
            Log.e(TAG, e.toString());
        }
    }
    }


    public void writeServiceStateChanged(ServiceState serviceState) {
    public void writeServiceStateChanged(ServiceState serviceState) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -227,7 +227,7 @@ public class ImsPhoneCallTracker extends CallTracker {
    public ImsPhoneCallTracker(ImsPhone phone) {
    public ImsPhoneCallTracker(ImsPhone phone) {
        this.mPhone = phone;
        this.mPhone = phone;


        mEventLog = TelephonyEventLog.getInstance(mPhone.getContext(), mPhone.getPhoneId());
        mEventLog = new TelephonyEventLog(mPhone.getPhoneId());


        IntentFilter intentfilter = new IntentFilter();
        IntentFilter intentfilter = new IntentFilter();
        intentfilter.addAction(ImsManager.ACTION_IMS_INCOMING_CALL);
        intentfilter.addAction(ImsManager.ACTION_IMS_INCOMING_CALL);
Loading