package com.gs.apidemo;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

@Deprecated
public class DemoService extends Service {
    private static final String TAG = "DemoService";

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate");
        //startMonitorHandsetChange();
        //startMonitorCallLines();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy");
        //stopMonitorHandsetChange();
        //stopMonitorCallLines();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        return super.onUnbind(intent);
    }



    /////////////////////////////////////////////////////
    //
    // Handset Monitor
    //
    // Not recommend method to monitor handset.
    //
    /////////////////////////////////////////////////////
    /*private void startMonitorHandsetChange() {
        mHookStatusListener = new MyHookStatusListener();
        BaseCallApi.addStatusListener("com.gs.apidemo.MonitorHandset", mHookStatusListener.callback,
                PhoneContext.ListenType.HOOK_EVENT_STATUS,false);
    }

    private void stopMonitorHandsetChange() {
        BaseCallApi.removeStatusListener(mHookStatusListener.callback);
        mHookStatusListener.destroy();
        mHookStatusListener = null;
    }

    private class MyHookStatusListener extends CallStatusListener {
        @Override
        public void onHookEventChanged(int device, boolean isOffHook) {
            Log.i(TAG, "device " + device + ", isOffHook " + isOffHook);
        }
    }

    private CallStatusListener mHookStatusListener = null;*/

    /////////////////////////////////////////////////////
    //
    // Handset Monitor and Call Line Monitor
    //
    /////////////////////////////////////////////////////

    /*private void startMonitorCallLines() {
        mCallStatusListener = new MyCallStatusListener();
        BaseCallApi.addStatusListener("com.gs.apidemo.MonitorCall", mCallStatusListener.callback,
                PhoneContext.ListenType.LINE_ID | PhoneContext.ListenType.LINE_STATUS,false);
    }

    private void stopMonitorCallLines() {
        BaseCallApi.removeStatusListener(mCallStatusListener.callback);
        mCallStatusListener.destroy();
        mCallStatusListener = null;
    }

    private class MyCallStatusListener extends CallStatusListener {
        @Override
        public void onLineStatusChanged(int notifyType, BaseLine baseLine, List<BaseLine> list) {
            Log.i(TAG, "notifyType "+notifyType);
            Log.i(TAG, "lineInfo "+baseLine);
        }

        // needn't onLineIdChanged any more.
        // @Override
        // public void onLineIdChanged(int oldLineId, int newLineId) {
        //     Log.i(TAG, "oldLineId " + oldLineId + ", newLineId " + newLineId);
        //     DemoApplication app = (DemoApplication) getApplication();
        //     app.setCurLineId(newLineId);
        // }
    }

    private CallStatusListener mCallStatusListener = null;*/
}
