ACTION AIDL
来源:互联网 发布:vm数据区 编辑:程序博客网 时间:2024/06/04 21:50
import android.app.Application;import android.content.ContentResolver;import android.os.ServiceManager;import android.util.Log;public class ActionApplication extends Application { private static final String TAG = "Action-Application"; private static final String ACTION_SERVICE = "iaction"; private static ContentResolver mContentResolver; @Override public void onCreate() { super.onCreate(); mContentResolver = this.getContentResolver(); ServiceManager.addService(ACTION_SERVICE, new ActionService(this)); Utils.handleFirstBootIfNeed(this); Log.i(TAG, "add service[" + ACTION_SERVICE + " sucesss "); } public static ContentResolver getAppContentResolver() { return mContentResolver; }}
import android.os.IBinder.DeathRecipient;import android.os.ServiceManager;import android.os.RemoteException;import android.util.Log;public class FingerServerNavigationLib implements DeathRecipient { private static final String TAG = "ETS-FingerServerNavigationLib"; public static final int STATE_HAL_UNUSED = 0; public static final int STATE_HAL_USING = 1; public static final String NAVIGATION_SERVICE="navigation"; private INavigationService mService; private boolean mEnableNotify = true; public FingerServerNavigationLib(){ mService = INavigationService.Stub.asInterface(ServiceManager.getService(NAVIGATION_SERVICE)); if (mService == null) { Log.e(TAG, "mService is null"); return; } try { mService.asBinder().linkToDeath(this, 0); } catch (RemoteException e) { e.printStackTrace(); } } public int notifyFingerHalState(int halState){ if (mService == null) { Log.i(TAG, "notifyFingerHalState, try to get Navigation service"); mService = INavigationService.Stub.asInterface(ServiceManager.getService(NAVIGATION_SERVICE)); if (mService == null) { Log.e(TAG, "notifyFingerHalState, mService is null"); return -1; } try { mService.asBinder().linkToDeath(this, 0); } catch (RemoteException e) { e.printStackTrace(); } } try { if (mEnableNotify){ Log.d(TAG, "notifyFingerHalState()="+halState); return mService.notifyFingerHalState(halState); } else{ Log.i(TAG, "disable notifyFingerHalState"); return 0; } } catch (RemoteException e) { Log.e(TAG, "notifyHalState() RemoteException:"+e.getMessage()); return -1; }catch(Exception e) { Log.e(TAG, "notifyHalState() Exception:"+e.getMessage()); return -1; } } public void setEnableNotify(boolean enable){ Log.d(TAG, "setEnableNotify="+enable); mEnableNotify = enable; } @Override public void binderDied() { Log.e(TAG, "binderDied"); mService = null; }}
import android.os.Bundle;import java.util.List;interface IActionService { void sendMessage(int keyCode);}
/* * This file is auto-generated. DO NOT MODIFY. * Original file: E:\\Release_build\\p904\\ActionSettings\\src\\com\\mediatek\\action\\IActionService.aidl */package com.mediatek.action;public interface IActionService extends android.os.IInterface{/** Local-side IPC implementation stub class. */public static abstract class Stub extends android.os.Binder implements com.mediatek.action.IActionService{private static final java.lang.String DESCRIPTOR = "com.mediatek.action.IActionService";/** Construct the stub at attach it to the interface. */public Stub(){this.attachInterface(this, DESCRIPTOR);}/** * Cast an IBinder object into an com.mediatek.action.IActionService interface, * generating a proxy if needed. */public static com.mediatek.action.IActionService asInterface(android.os.IBinder obj){if ((obj==null)) {return null;}android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);if (((iin!=null)&&(iin instanceof com.mediatek.action.IActionService))) {return ((com.mediatek.action.IActionService)iin);}return new com.mediatek.action.IActionService.Stub.Proxy(obj);}@Override public android.os.IBinder asBinder(){return this;}@Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException{switch (code){case INTERFACE_TRANSACTION:{reply.writeString(DESCRIPTOR);return true;}case TRANSACTION_sendMessage:{data.enforceInterface(DESCRIPTOR);int _arg0;_arg0 = data.readInt();this.sendMessage(_arg0);reply.writeNoException();return true;}}return super.onTransact(code, data, reply, flags);}private static class Proxy implements com.mediatek.action.IActionService{private android.os.IBinder mRemote;Proxy(android.os.IBinder remote){mRemote = remote;}@Override public android.os.IBinder asBinder(){return mRemote;}public java.lang.String getInterfaceDescriptor(){return DESCRIPTOR;}@Override public void sendMessage(int keyCode) throws android.os.RemoteException{android.os.Parcel _data = android.os.Parcel.obtain();android.os.Parcel _reply = android.os.Parcel.obtain();try {_data.writeInterfaceToken(DESCRIPTOR);_data.writeInt(keyCode);mRemote.transact(Stub.TRANSACTION_sendMessage, _data, _reply, 0);_reply.readException();}finally {_reply.recycle();_data.recycle();}}}static final int TRANSACTION_sendMessage = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);}public void sendMessage(int keyCode) throws android.os.RemoteException;}
import android.os.IBinder.DeathRecipient;import android.os.ServiceManager;import android.os.RemoteException;import android.util.Log;public class ActionControlLib implements DeathRecipient { private static final String TAG = "Action-ControlLib"; private static final String ACTION_SERVICE = "iaction"; private IActionService mService; public ActionControlLib(){ mService = IActionService.Stub.asInterface(ServiceManager.getService(ACTION_SERVICE)); if (mService == null) { Log.e(TAG, "mService is null"); return; } try { mService.asBinder().linkToDeath(this, 0); } catch (RemoteException e) { e.printStackTrace(); } } public int sendMessageToAction(int keyCode){ if (mService == null) { Log.i(TAG, "sendMessageToAction, try to get Action service"); mService = IActionService.Stub.asInterface(ServiceManager.getService(ACTION_SERVICE)); if (mService == null) { Log.e(TAG, "sendMessageToAction, mService is null"); return -1; } try { mService.asBinder().linkToDeath(this, 0); } catch (RemoteException e) { e.printStackTrace(); } } try { Log.d(TAG, "sendMessageToAction " + keyCode); mService.sendMessage(keyCode); return 0; } catch (RemoteException e) { Log.e(TAG, "sendMessageToAction RemoteException: " + e.getMessage()); return -1; } catch(Exception e) { Log.e(TAG, "sendMessageToAction Exception: "+ e.getMessage()); return -1; } } @Override public void binderDied() { Log.e(TAG, "binderDied"); mService = null; }}
if (mActionLib == null) { mActionLib = new ActionControlLib(); } if (mActionLib == null) { android.util.Log.i(TAG,"ActionControlLib is null."); } else { android.util.Log.i(TAG,"sendMessageToAction keyCode: " + keyCode); mActionLib.sendMessageToAction(keyCode); }
package com.android.actions;import android.app.ActivityManager;import android.app.ActivityManager.RunningServiceInfo;import android.app.ActivityManager.RunningTaskInfo;import android.app.KeyguardManager;import android.app.KeyguardManager.KeyguardLock;import android.app.Service;import android.content.BroadcastReceiver;import android.content.ComponentName;import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.content.ContentResolver;import android.content.SharedPreferences;import android.database.ContentObserver;import android.database.Cursor;import android.graphics.Color;import android.graphics.drawable.ColorDrawable;import android.graphics.drawable.Drawable;import android.graphics.PixelFormat;import android.hardware.Sensor;import android.hardware.SensorEvent;import android.hardware.SensorEventListener;import android.hardware.SensorManager;import android.media.AudioManager;import android.net.Uri;import android.os.Bundle;import android.os.Handler;import android.os.IBinder;import android.os.Message;import android.os.PowerManager;import android.os.PowerManager.WakeLock;import android.os.RemoteException;import android.os.SystemClock;import android.os.UserHandle;import android.provider.Settings;import android.telephony.PhoneStateListener;import android.telecom.TelecomManager;import android.telephony.TelephonyManager;import android.util.Log;import android.view.KeyEvent;import android.view.View;import android.view.WindowManager;import android.view.WindowManager.LayoutParams;import android.view.LayoutInflater;import android.widget.ImageView;import android.view.WindowManagerGlobal;import android.widget.TextView;import android.view.Gravity;import com.android.internal.telephony.ITelephony;import com.mediatek.action.IActionService;import java.util.ArrayList;import java.util.Iterator;import java.util.List;public class ActionService extends IActionService.Stub { private String TAG = "Action-Service"; public static final String EXTRA_SLOT_ID = "com.android.phone.extra.slot"; private static final String ACTION_CALL_SECURE_CAMERA = "com.sagereal.actions.call_secure_camera"; private static final int UNUSED = 0x00000000; private static final int PICKANDDIAL = 0x00000001; private static final int ROTATEMUTE = 0x00000002; private static final int PICKANDRECEIVE = 0x00000003; private static final int PSSWITCH = 0x00000004; private static final int WAVEANDRECEIVE = 0x00000005; private static final int PICKANDDIALTRY = 0x00000006; private static final int PSENSOR_ACTION_ALWAYS_NEAR = 1; private static final int PSENSOR_ACTION_ALWAYS_FAR = 2; private static final int PSENSOR_ACTION_WAVE = 3; private static final int GSENSOR_ACTION_ALWAYS_VERTICAL = 1;// shu private static final int GSENSOR_ACTION_ALWAYS_HORIZONTAL = 2;// heng private static final int GSENSOR_ACTION_PICK = 3; private static final int GSENSOR_ACTION_ROTATE = 4; private static final int GSENSOR_VERTICAL = 1;// shu private static final int GSENSOR_HORIZONTAL = 2;// heng private static final int GSENSOR_ROTATE = 3; private static final int MSG_REMOVE_GESTURE_PALY = 110; private static final int MSG_REMOVE_TOAST = 111; private static final int MSG_GESTURE_KEYCODE = 112; private KeyguardManager keyguardManager; private TelephonyManager telephonyMgr; private SensorManager sensorMgr; private AudioManager audioMgr; private PowerManager mPowerManager; private SensorEventListener gsensorListener; private SensorEventListener psensorListener; private PhoneCallListener phoneListener; private Context mContext; private boolean ringing = false; private boolean is_action_active = false; private boolean is_rotate_mute_enable = false; private boolean is_double_click_enable = false; private boolean is_quick_launch_enable = false; private boolean is_pick_and_dial_enable = false; private boolean is_pick_and_receive_enable = false; private boolean is_ps_switch_enable = false; private boolean is_wave_and_receive_enable = false; private boolean is_pick_and_dial_sim1 = true; private boolean is_pick_and_dial_sim2 = false; private ActionServiceReceiver actionservicereceiver; private int ActionState = UNUSED; private float gsensor_horizontal_x = 0; private float gsensor_horizontal_y = 0; private float gsensor_horizontal_z = 10; private boolean is_gsensor_first_roll = true; private boolean is_psensor_first_roll = true; private float gsensor_diff_x = 0; private float gsensor_diff_y = 0; private float gsensor_diff_z = 0; private String sendnumber = null; private boolean is_dialed = false; private boolean is_rotated_mute_finish = false; private boolean gsensor_is_allow_to_dial = false; private boolean psensor_is_allow_to_dial = false; private DialThread dialthread = null; private boolean is_need_gsensor = false; private boolean is_need_psensor = false; private int MAX_RECORD_HISTORY_COUNT_X = 5; private int MAX_RECORD_HISTORY_COUNT_Y = 50; private int MAX_RECORD_HISTORY_COUNT_Z = 1; private float gsensor_record_history_x[] = new float[MAX_RECORD_HISTORY_COUNT_X];// unused private float gsensor_record_history_y[] = new float[MAX_RECORD_HISTORY_COUNT_Y];// 锟斤拷锟斤拷锟叫讹拷锟斤拷锟斤拷锟斤拷 private float gsensor_record_history_z[] = new float[MAX_RECORD_HISTORY_COUNT_Z];// 锟斤拷锟斤拷锟叫断凤拷转 private float psensor_record_history[] = {1, 1, 1, 1, 1};// default ps far new float[MAX_RECORD_HISTORY_COUNT_X]; private float psensor_record_last_history_x = -1;// use to judge ps first state private float psensor_record_curr_history_x = -1;// use to judge ps first state private float psensor_record_action_change_count = 0;// use to judge ps first state private int ring_mode_backup = -1; private int defaultVolume = -1; private boolean is_psensor_rotate = false; private View mMyStyleToast; private int mCallState = TelephonyManager.CALL_STATE_IDLE; public ActionService(Context context) { init(context); } private void init(Context context) { mContext = context; getActionSettingPref(); keyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); telephonyMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); sensorMgr = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); audioMgr = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); phoneListener = new PhoneCallListener(); telephonyMgr.listen(phoneListener, PhoneCallListener.LISTEN_CALL_STATE); actionservicereceiver = new ActionServiceReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction("com.sagereal.intent.action.pickanddial"); filter.addAction("com.sagereal.intent.action.setings.changed"); filter.addAction("com.sagereal.intent.action.pickanddial.try"); filter.addAction("android.intent.action.SCREEN_OFF"); filter.addAction("com.sagereal.action.gesture.keycode"); filter.addAction("com.transsion.countrylist.COUNTRY_SETUP_FINISHED"); mContext.registerReceiver(actionservicereceiver, filter); //bindKeyGuardService(); mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor("animation_disappear"), false, mDissmissAnimationObserver); } private void wakeUp() { Log.v(TAG,"wakeUp..."); acquireWakeLock(); //mPowerManager.wakeUp(SystemClock.uptimeMillis()); /*PowerManager.WakeLock wl = mPowerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.PARTIAL_WAKE_LOCK, "action"); wl.acquire(); wl.release();*/ } private float[] insertGsToQueue(float insert_obj, float arry[]) { float[] temp = new float[arry.length]; for (int i = 1; i < (arry.length - 1); i++) { temp[i] = arry[i - 1]; } temp[0] = insert_obj; return temp; } private float[] insertPsToQueue(float insert_obj, float arry[]) { float[] temp = {1, 1, 1, 1, 1}; for (int i = 1; i < (arry.length - 1); i++) { temp[i] = arry[i - 1]; } temp[0] = insert_obj; return temp; } private void getActionSettingPref() { SharedPreferences settings = mContext.getSharedPreferences( Utils.ACTION_SETTINGS_SHAREDPREFERENCE, Context.MODE_PRIVATE); if (settings != null) { is_action_active = settings.getBoolean("action_active", true); if (is_action_active) { is_pick_and_dial_enable = settings.getBoolean("pick_and_dial", false); is_rotate_mute_enable = settings .getBoolean("rotate_mute", true); is_double_click_enable = settings .getBoolean(Utils.DOUBLE_CLICK_WAKE_SWITCH, true); is_quick_launch_enable = settings .getBoolean(Utils.QUICK_LAUNCH_SWITCH, true); is_pick_and_receive_enable = settings.getBoolean( "pick_and_receive", false); is_ps_switch_enable = settings.getBoolean("ps_switch", false); is_wave_and_receive_enable = settings.getBoolean( "wave_receive", false); is_pick_and_dial_sim1 = settings.getBoolean( "action_pick_and_dial_pref_sim1", true); is_pick_and_dial_sim2 = settings.getBoolean( "action_pick_and_dial_pref_sim2", false); } else { is_pick_and_dial_enable = false; is_rotate_mute_enable = false; is_pick_and_receive_enable = false; is_ps_switch_enable = false; is_wave_and_receive_enable = false; is_pick_and_dial_sim1 = false; is_pick_and_dial_sim2 = false; } } else { Log.i(TAG, "getSharedPreferences(com.sagereal.actions_preferences) error"); } } private void unregisterSensor() { if (sensorMgr != null) { sensorMgr.unregisterListener(gsensorListener); sensorMgr.unregisterListener(psensorListener); // sensorMgr = null; is_psensor_rotate = false; } } private void openGsensor() { Log.v(TAG,"openGsensor sensorMgr = "+sensorMgr); is_gsensor_first_roll = true; if (sensorMgr != null) { Sensor orientation = null; is_psensor_rotate = false; gsensorListener = new GSensorListener(); orientation = sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (orientation != null && sensorMgr != null) { sensorMgr.registerListener(gsensorListener, orientation, SensorManager.SENSOR_DELAY_NORMAL); } } } private void openPsensor() { Log.v(TAG,"openPsensor sensorMgr = "+sensorMgr); psensor_record_last_history_x = -1; psensor_record_curr_history_x = -1; psensor_record_action_change_count = 0; if (sensorMgr != null) { Sensor orientation = null; psensorListener = new PSensorListener(); orientation = sensorMgr.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (orientation != null && sensorMgr != null) { sensorMgr.registerListener(psensorListener, orientation, SensorManager.SENSOR_DELAY_NORMAL); } } } private int getGsensorRealTimeState() { Log.v(TAG,"openPsensor sensorMgr = "+sensorMgr); float x = gsensor_record_history_x[0]; float y = gsensor_record_history_y[0]; float z = gsensor_record_history_z[0]; gsensor_diff_x = x - gsensor_horizontal_x; gsensor_diff_y = y - gsensor_horizontal_y; gsensor_diff_z = z - gsensor_horizontal_z; if ((y > 6) && (z < 3)) { return GSENSOR_VERTICAL; } if ((y < 3) && (z > 7)) { return GSENSOR_HORIZONTAL; } return 0; } private int getPsensorActionState() { if (psensor_record_history[0] == 1) { return PSENSOR_ACTION_ALWAYS_FAR; } else if (psensor_record_history[0] == 0) { return PSENSOR_ACTION_ALWAYS_NEAR; } return 0; } private boolean isPsensorWaveAction() { if (psensor_record_action_change_count == 3) { // psensor_record_action_change_count =0; return true; } return false; } private int getGsensorActionState() { boolean VerticalIsExsit = false; boolean HorizontalIsExsit = false; for (int i = 0; i < gsensor_record_history_y.length; i++) { if (gsensor_record_history_y[i] < 4) { HorizontalIsExsit = true; continue; } if (gsensor_record_history_y[i] > 7) { VerticalIsExsit = true; continue; } } if (HorizontalIsExsit && VerticalIsExsit && (GSENSOR_VERTICAL == getGsensorRealTimeState())) { return GSENSOR_ACTION_PICK;// } return 0; } private void doCallReceive() { if (!is_pick_and_receive_enable && !is_wave_and_receive_enable) { unregisterSensor(); return; } Log.e(TAG, "doCallReceive"); try { ITelephony iTelephony = PhoneUtils.getITelephony(telephonyMgr); iTelephony.answerRingingCall();// // iTelephony.endCall();// } catch (Exception e) { Log.e(TAG, "[callReceive]Exception=" + e.getMessage(), e); } finally { unregisterSensor(); } } private void doEndCall() { Log.e(TAG, "doCallReceive"); try { ITelephony iTelephony = PhoneUtils.getITelephony(telephonyMgr); iTelephony.endCall(); // iTelephony.endCall(); } catch (Exception e) { Log.e(TAG, "[endCall]Exception=" + e.getMessage(), e); } finally { unregisterSensor(); } } private void doOutGoingCall() { // if(!is_pick_and_dial_enable) { // unregisterSensor(); // return; // } // // int slot=-1; // List<SimInfoRecord> mSimInfoList= new ArrayList<SimInfoRecord>();; // int mSimNum; // final long defaultSim = Settings.System.getLong(mContext.getContentResolver(), // Settings.System.VOICE_CALL_SIM_SETTING, // Settings.System.DEFAULT_SIM_SETTING_ALWAYS_ASK); // // mSimInfoList = SimInfoManager.getInsertedSimInfoList(this); // mSimNum = mSimInfoList.size(); // if((defaultSim ==Settings.System.DEFAULT_SIM_SETTING_ALWAYS_ASK) && // (mSimNum >=2) ) //SIM manager is always ask,and sim number >=2 // { // if(is_pick_and_dial_sim1) // { // slot = 0; // }else if(is_pick_and_dial_sim2) // { // slot = 1; // } // } // // Intent dialintent =new // Intent(Intent.ACTION_CALL,Uri.parse("tel:"+sendnumber)); // dialintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Log.v(TAG,"slot == "+slot); // if(slot != -1) // { // dialintent.putExtra(EXTRA_SLOT_ID,slot); // } // mContext.startActivity(dialintent); // unregisterSensor(); } private void doMute() { int ringerMode = AudioManager.RINGER_MODE_SILENT; if (audioMgr != null) { getTelecommService().silenceRinger(); is_rotated_mute_finish = true; if (sensorMgr != null) { sensorMgr.unregisterListener(gsensorListener); } } } /** * get TelecomManager server * * @return */ private TelecomManager getTelecommService() { return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); } private int getCallState() { try { ITelephony iTelephony = PhoneUtils.getITelephony(telephonyMgr); return iTelephony.getCallState(); // iTelephony.endCall(); } catch (Exception e) { Log.e(TAG, "[callReceive]Exception=" + e.getMessage(), e); } return 0; } private class PhoneCallListener extends PhoneStateListener { @Override public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); Log.v(TAG, "onCallStateChanged state == " + state); Log.v(TAG, "onCallStateChanged incomingNumber == " + incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: mCallState = TelephonyManager.CALL_STATE_IDLE; ringing = false; if (is_rotated_mute_finish = false) { // didn't use rotate mute, caller end or reject directly happen if (sensorMgr != null) { sensorMgr.unregisterListener(gsensorListener); } } else if (ActionState == ROTATEMUTE) { Log.v(TAG, "CALL_STATE_IDLE ring_mode_backup == " + ring_mode_backup); if (ring_mode_backup != -1) { // audioMgr.setRingerMode(ring_mode_backup); } } break; case TelephonyManager.CALL_STATE_OFFHOOK: mCallState = TelephonyManager.CALL_STATE_OFFHOOK; ringing = false; if (is_rotated_mute_finish = false)// didn't use rotate mute , // user accept directly { if (sensorMgr != null) { sensorMgr.unregisterListener(gsensorListener); } } break; case TelephonyManager.CALL_STATE_RINGING: mCallState = TelephonyManager.CALL_STATE_RINGING; ActionState = UNUSED; is_need_gsensor = false; is_need_psensor = false; is_rotated_mute_finish = false; ringing = true; if (is_rotate_mute_enable) { ActionState = ROTATEMUTE; is_need_gsensor = true; is_psensor_rotate = false; ring_mode_backup = audioMgr.getRingerMode(); } if (is_pick_and_receive_enable) { ActionState = ActionState | PICKANDRECEIVE; is_need_gsensor = true; is_need_psensor = true; } if (is_wave_and_receive_enable) { ActionState = ActionState | WAVEANDRECEIVE; is_need_psensor = true; } if (is_need_psensor) { openPsensor(); } if (is_need_gsensor) { openGsensor(); } break; default: break; } } } class GSensorListener implements SensorEventListener { @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } @Override public void onSensorChanged(SensorEvent event) { Log.v(TAG, "onSensorChanged ActionState == " + ActionState);// ActionState if (ActionState == UNUSED) { return; } { gsensor_record_history_x = insertGsToQueue(event.values[0], gsensor_record_history_x); gsensor_record_history_y = insertGsToQueue(event.values[1], gsensor_record_history_y); gsensor_record_history_z = insertGsToQueue(event.values[2], gsensor_record_history_z); } if (event.values[2] > -5 && event.values[2] < 5) { is_psensor_rotate = true; } if ((ActionState & ROTATEMUTE) != 0) { // Log.v(TAG,"onCallStateChanged ringing == "+ringing); if (is_psensor_rotate && event.values[0] < 10 && event.values[0] > -10 && event.values[1] < 5 && event.values[1] > -5 && event.values[2] < -9 && event.values[2] > -10 && ringing) { doMute(); } else { if (audioMgr != null) { // audioMgr.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } } } } } public class PSensorListener implements SensorEventListener { @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { Log.v(TAG,"PSensorListener onAccuracyChanged accuracy= "+accuracy); } @Override public void onSensorChanged(SensorEvent event) { psensor_record_history = insertPsToQueue(event.values[0], psensor_record_history); if ((psensor_record_last_history_x == -1) || (psensor_record_curr_history_x == -1))// first time { psensor_record_last_history_x = event.values[0]; psensor_record_curr_history_x = event.values[0]; } else { psensor_record_last_history_x = psensor_record_curr_history_x; psensor_record_curr_history_x = event.values[0]; } if (psensor_record_curr_history_x != psensor_record_last_history_x) { psensor_record_action_change_count = psensor_record_action_change_count + 1; } if (ActionState == PICKANDDIAL) { if (sendnumber != null && (PSENSOR_ACTION_ALWAYS_NEAR == getPsensorActionState()) && (GSENSOR_ACTION_PICK == getGsensorActionState())) { // psensor_is_allow_to_dial =true; doOutGoingCall(); } else { // psensor_is_allow_to_dial=false; } } else if (ActionState == PICKANDDIALTRY) { Log.v(TAG, "ActionState == PICKANDDIALTRY "); if ((PSENSOR_ACTION_ALWAYS_NEAR == getPsensorActionState()) && (GSENSOR_ACTION_PICK == getGsensorActionState())) { Intent myintent = new Intent(); myintent.setAction("com.sagereal.intent.action.pickanddial.try.changed"); mContext.sendBroadcast(myintent); unregisterSensor(); } } else { if ((ActionState & WAVEANDRECEIVE) != 0) { Log.v(TAG, "getPsensorActionState() == " + getPsensorActionState()); if (isPsensorWaveAction() && (GSENSOR_HORIZONTAL == getGsensorRealTimeState())) { // doCallReceive(); doCallReceive(); return; } } if ((ActionState & PICKANDRECEIVE) != 0) { Log.v(TAG, "getGsensorActionState() == " + getGsensorActionState()); if ((PSENSOR_ACTION_ALWAYS_NEAR == getPsensorActionState()) && (GSENSOR_VERTICAL == getGsensorRealTimeState())) { // doCallReceive(); doCallReceive(); return; } } } } } public class ActionServiceReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals("com.sagereal.intent.action.pickanddial")) { if (!is_pick_and_dial_enable) { return; } Bundle bundle = intent.getExtras(); String number = bundle.getString("sendnumber"); String[] numberarray = bundle.getStringArray("sendnumberarray"); String activitystate = bundle.getString("activitystate"); if (number == null && ((numberarray != null) && (numberarray[0] != null))) { sendnumber = numberarray[0]; } else if (number != null) { sendnumber = number; } if (activitystate.equals("in") && (sendnumber != null)) { Log.v(TAG, " PickAndDialReceiver activitystate == in"); ActionState = UNUSED; ActionState = PICKANDDIAL; is_dialed = false; is_gsensor_first_roll = true; psensor_is_allow_to_dial = false; gsensor_is_allow_to_dial = false; openGsensor(); openPsensor(); // dialthread = new DialThread(); // dialthread.start(); } else { // out ActionState = UNUSED; sendnumber = null; unregisterSensor(); } } else if (action.equals("com.sagereal.intent.action.setings.changed")) { getActionSettingPref(); } else if (action.equals("com.sagereal.intent.action.pickanddial.try")) { ActionState = UNUSED; ActionState = PICKANDDIALTRY; openGsensor(); openPsensor(); } else if (action.equals("android.intent.action.SCREEN_OFF")) { unregisterSensor(); } else if ("com.sagereal.action.gesture.keycode".equals(action)) { Log.d(TAG, "Receiver : " + action + ", isFirstClick" + isFirstClick); /*if (isFirstClick) { wakeUp(); isFirstClick = false; } else { isFirstClick = true; } int keycode = intent.getIntExtra("keycode", 0); Log.d(TAG, "Receiver : " + action + ", isFirstClick" + isFirstClick + ", keycode" + keycode); if (Settings.Global.getInt(context.getContentResolver(), "country_setup_finished", 0) == 0) { Log.i(TAG, "should return by country_setup_finished !!!"); // if setupwizard not finish ,not handle the code return; } if (ActivityManager.isUserAMonkey()) { Log.d(TAG, "ignoring monkey's attempt to start application"); } else { gestureKeyCodeHandle(keycode); }*/ } } } private static boolean isFirstClick = false; private void acquireWakeLock() { Log.i(TAG, "acquireWakeLock"); PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); WakeLock m_wake = (WakeLock) pm.newWakeLock( PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "action"); m_wake.acquire(); //m_wake.acquire(5000); m_wake.release();// } private void gestureKeyCodeHandle(int keycode) { Log.i(TAG, "gestureKeyCodeHandle keycode: " + keycode); if (mGesturePlayingFloatView != null) { return; } switch (keycode) { case KeyEvent.KEYCODE_GESTURE_C:// C mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_C).start(); break; case KeyEvent.KEYCODE_GESTURE_E:// e mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_E).start(); break; case KeyEvent.KEYCODE_GESTURE_M:// m mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_M).start(); break; case KeyEvent.KEYCODE_GESTURE_O:// o mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_O).start(); break; case KeyEvent.KEYCODE_GESTURE_V:// v mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_V).start(); break; case KeyEvent.KEYCODE_GESTURE_S:// s mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_S).start(); break; case KeyEvent.KEYCODE_GESTURE_W:// w mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_W).start(); break; case KeyEvent.KEYCODE_GESTURE_Z:// z mGesturePlayingFloatView = showGesturePlayFloatView(null); new GestureThread(Utils.INDEX_Z).start(); break; case KeyEvent.KEYCODE_GESTURE_DOWN:// down // reserved break; case KeyEvent.KEYCODE_GESTURE_UP:// up // reserved break; case KeyEvent.KEYCODE_GESTURE_DCLICK:// dclick // do nothing ,because the key had setted to wake state in keyboard configuration wakeUp(); break; } } public ComponentName getShortCutAppComponent(int index) { String[] indexString = new String[1]; indexString[0] = index + ""; ComponentName result = null; ContentResolver contentResolver = mContext.getContentResolver(); Cursor cursor = contentResolver.query(Utils.CONTENT_URI, null, "_id=?", indexString, null); if ((cursor != null) && (cursor.getCount() != 0) && cursor.moveToFirst()) { String packagename = cursor.getString(cursor .getColumnIndex("packagename")); String activityname = cursor.getString(cursor .getColumnIndex("activityname")); if (packagename.equals("") || activityname.equals("")) { } else { result = new ComponentName(packagename, activityname); } } if (cursor != null) cursor.close(); // for empty return result; } private void dismissKeyGuard() { try { WindowManagerGlobal.getWindowManagerService().dismissKeyguard(); } catch (RemoteException e) { e.printStackTrace(); } } private boolean isAllowStartUnderSuperPower(ComponentName componentname) { boolean result = false; for (int i = 0; i < Utils.supperpowerpackageList.length; i++) { if (componentname.getPackageName().equals( Utils.supperpowerpackageList[i])) { result = true; } } return result; } public boolean isSpecialDoingNow() { ActivityManager myManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); ArrayList<RunningServiceInfo> runningService = (ArrayList<RunningServiceInfo>) myManager .getRunningServices(50); for (int i = 0; i < runningService.size(); i++) { if (runningService.get(i).service.getClassName().toString() .equals("com.android.deskclock.alarms.AlarmService")) { return true; } } return false; } private boolean isSpecialAppInTopActivity() { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1); if (runningTaskInfos != null) { if ((runningTaskInfos.get(0).topActivity.getClassName() .equals("com.android.deskclock.alarms.AlarmActivity")) || (runningTaskInfos.get(0).topActivity.getClassName() .equals("com.android.incallui.InCallActivity"))) { return true; } } return false; } private boolean isSpecialAppInTopActivityOnLocked() { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1); if (runningTaskInfos != null) { if (runningTaskInfos.get(0).topActivity.getPackageName().equals( "com.android.gallery3d") || (runningTaskInfos.get(0).topActivity.getPackageName() .equals("com.android.music"))) { return true; } } return false; } private String getTopActivity() { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1); if (runningTaskInfos != null) { return runningTaskInfos.get(0).topActivity.getClassName(); } return ""; } private String getTopPackageName() { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1); if (runningTaskInfos != null) { return runningTaskInfos.get(0).topActivity.getPackageName(); } return ""; } private boolean isNeedSendIntent(ComponentName componentname) { if ((getTopActivity().equals("com.android.gallery3d.app.MovieActivity") && componentname != null && componentname.getPackageName() .equals("com.mediatek.videoplayer")) || (getTopPackageName().equals("com.android.browser") && componentname != null && componentname .getPackageName().equals("com.android.browser"))) { return false; } return true; } private boolean tipForSpecialDoingNowIfNeed(ComponentName componentname) { if (componentname != null && Settings.System.getInt(mContext.getContentResolver(), "superpower", 0) == 1 && !isAllowStartUnderSuperPower(componentname)) { toastStyle(R.string.action_quick_not_allow_tip_for_superpower); return true; } if (mCallState != TelephonyManager.CALL_STATE_IDLE) { toastStyle(R.string.action_quick_not_allow_tip_for_incall); return true; } return false; } private void toastStyle(int strid) { if (mMyStyleToast != null) { return; } if (mGesturePlayingFloatView != null && (mGesturePlayingFloatView.getVisibility() == View.VISIBLE)) { mGesturePlayingFloatView.setVisibility(View.GONE);// remove the old show if need } { View mpreView = null; WindowManager mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(); wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT; //modify by wanpeng for bug 42414 wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.windowAnimations = com.android.internal.R.style.Animation_Toast; wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; wmParams.format = PixelFormat.RGBA_8888; mpreView = LayoutInflater.from(mContext).inflate( com.android.internal.R.layout.transient_notification, null); mpreView.setVisibility(View.VISIBLE); TextView tv = (TextView) mpreView .findViewById(com.android.internal.R.id.message); tv.setGravity(Gravity.CENTER); if (tv != null) { tv.setText(mContext.getString(strid)); } mWindowManager.addView(mpreView, wmParams); new ToastTimerThread().start(); mMyStyleToast = mpreView; } } private class ToastTimerThread extends Thread { ToastTimerThread() { } public void run() { try { Thread.sleep(2000); } catch (InterruptedException e) { } Message message = new Message(); message.what = MSG_REMOVE_TOAST; myHandler.sendMessage(message); } } private class disableAndEnableLockThread extends Thread { disableAndEnableLockThread() { } public void run() { // mKeyguardLock.disableKeyguard(); // hasDisableLock = true; try { Thread.sleep(3000); } catch (InterruptedException e) { } // mKeyguardLock.reenableKeyguard(); // hasDisableLock = false; } } private boolean launcherSecureCameraIfNeed(ComponentName componentname) { boolean result = false; if (componentname != null && componentname.getPackageName().equals( "com.android.gallery3d") && componentname.getClassName().equals( "com.android.camera.CameraLauncher")) { if (keyguardManager.isKeyguardSecure()) { Log.i(TAG, "launcherSecureCameraIfNeed keyguardManager.isSecure()"); launchCamera(); result = true; } } return result; } private static final String ACTION_DISMISS_NOTIFICATION_PANEL_VIEW = "com.sagereal.actions.dismiss_notificationPanelView"; private static boolean isSecureCamera = false; private static boolean isCamera = false; private void sendBrocastForDismissNitificationPanelViews(ComponentName componentname) { if (keyguardManager.isKeyguardSecure()) { Intent intent = new Intent(ACTION_DISMISS_NOTIFICATION_PANEL_VIEW); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null, null, null, 0, null, null); if (componentname != null && componentname.getPackageName().equals( "com.android.gallery3d") && componentname.getClassName().equals( "com.android.camera.CameraLauncher")) { //isSecureCamera = true; } else { //isSecureCamera = false; } } dismissKeyGuard(); } private void launchCameras() { //startActivity(SECURE_CAMERA_INTENT); Intent intent = new Intent(ACTION_CALL_SECURE_CAMERA); mContext.sendOrderedBroadcast(intent, null); } private boolean sendBrocastForDismissNitificationPanelView(ComponentName componentname) { Settings.System.putInt(mContext.getContentResolver(), "animation_disappear", 1); Settings.System.putInt(mContext.getContentResolver(), LAUNCHER_CAMERA, 0); if (componentname != null && componentname.getPackageName().equals( "com.mediatek.camera") && componentname.getClassName().equals( "com.android.camera.CameraLauncher")) { if (keyguardManager.isKeyguardSecure()) { launchCamera(); isSecureCamera = true; isCamera = false; } else { isSecureCamera = false; isCamera = true; } } else { isSecureCamera = false; isCamera = false; Settings.System.putInt(mContext.getContentResolver(), DISSMISS_STATUS_BAR, 1); dismissKeyGuard(); } Log.i(TAG, "sendBrocast LAUNCHER_CAMERA = " + Settings.System.getInt( mContext.getContentResolver(), LAUNCHER_CAMERA, 0)); return isSecureCamera; } private static final String LAUNCHER_CAMERA = "launcher_camera_for_actionsettings"; private static final String DISSMISS_STATUS_BAR = "dissmiss_status_bar_for_actionsettings"; private void launchCamera() { Settings.System.putInt(mContext.getContentResolver(), LAUNCHER_CAMERA, 1); Log.i(TAG, "launchCamera LAUNCHER_CAMERA = " + Settings.System.getInt( mContext.getContentResolver(), DISSMISS_STATUS_BAR, 0)); } private boolean launcherMusicInSecureLocked(ComponentName componentname) { boolean result = false; if (componentname != null && componentname.getPackageName().equals("com.android.music") && componentname.getClassName().equals( "com.android.music.ShortCutActivity")) { if (keyguardManager.isKeyguardSecure()) { android.provider.Settings.System.putInt( mContext.getContentResolver(), "fromsecurekeyguard", 1); Intent intent = new Intent(); intent.setComponent(componentname); intent.putExtra("fromsecurekeyguard", true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent); result = true; } else { android.provider.Settings.System.putInt( mContext.getContentResolver(), "fromsecurekeyguard", 0); } } return result; } public void removeTaskIfNeed(Context context, ComponentName componentname) { if (!componentname.getPackageName().equals("com.android.browser") || getTopPackageName().equals("com.android.browser")) { return; } else { ActivityManager localActivityManager = (ActivityManager) context.getSystemService("activity"); Iterator localIterator = localActivityManager.getRecentTasks(50, 2) .iterator(); while (localIterator.hasNext()) { ActivityManager.RecentTaskInfo localRecentTaskInfo = (ActivityManager.RecentTaskInfo) localIterator .next(); String str = localRecentTaskInfo.baseIntent.getComponent() .getPackageName(); if (str.equals("com.android.browser")) { Log.d(TAG, "removeTaskIfNeed componentname == " + componentname); // localActivityManager.removeTask(localRecentTaskInfo.persistentId, 1); localActivityManager.killBackgroundProcesses(str); } } } } private View mGesturePlayingFloatView; private boolean gestureIsplaying = false; private int mLevel = -1; private ImageView mGesturePlayingDrawable; private TextView mGestureTextTip; Handler myHandler = new Handler() { public void handleMessage(Message msg) { Log.d(TAG, "myHandler handleMessage mLevel = " + mLevel); if (mLevel == 1) { wakeUp(); } switch (msg.what) { case Utils.INDEX_C: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_C); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_c.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_c[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case Utils.INDEX_M: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_M); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_m.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_m[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case Utils.INDEX_W: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_W); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_w.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_w[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case Utils.INDEX_E: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_E); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_e.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_e[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case Utils.INDEX_O: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_O); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_o.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_o[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case Utils.INDEX_V: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_V); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_v.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_v[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case Utils.INDEX_Z: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_Z); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_z.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_z[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case Utils.INDEX_S: if (mGesturePlayingFloatView != null && gestureIsplaying) { ComponentName componentname = null; componentname = getShortCutAppComponent(Utils.INDEX_S); if (tipForSpecialDoingNowIfNeed(componentname)) { gestureIsplaying = false; mLevel = 0xFF; } else if (mLevel < Utils.resid_s.length) { mGesturePlayingDrawable .setImageResource(Utils.resid_s[mLevel]); mLevel++; } else { gestureIsplaying = false; startActivityByName(componentname); } } break; case MSG_REMOVE_GESTURE_PALY: //if(keyguardManager.isKeyguardSecure() && isSecureCamera){ if (isSecureCamera || isCamera) { isSecureCamera = false; if (isCamera) { Settings.System.putInt(mContext.getContentResolver(), DISSMISS_STATUS_BAR, 1); dismissKeyGuard(); } isCamera = false; mGesturePlayingDrawable.setImageDrawable(new ColorDrawable(Color.BLACK)); myHandler.sendEmptyMessageDelayed(MSG_REMOVE_GESTURE_PALY, 2000); return; } if (mGesturePlayingFloatView != null) { mGesturePlayingFloatView.setVisibility(View.GONE); mGesturePlayingFloatView = null; } break; case MSG_REMOVE_TOAST: mMyStyleToast.setVisibility(View.GONE); mMyStyleToast = null; break; case MSG_GESTURE_KEYCODE: gestureKeyCodeHandle((Integer) msg.obj); break; } super.handleMessage(msg); } }; private void startActivityByName(ComponentName componentname) { if (componentname != null) { if (!sendBrocastForDismissNitificationPanelView(componentname)) { if (isNeedSendIntent(componentname)) { removeTaskIfNeed(mContext, componentname); Intent intent = new Intent(); intent.setComponent(componentname); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); mContext.startActivity(intent); } } } } class GestureThread extends Thread { int mindex; GestureThread(int index) { Log.i(TAG, "GestureThread index:" + index); mindex = index; gestureIsplaying = true; mLevel = 0; } public void run() { while (gestureIsplaying) { Message message = new Message(); message.what = mindex; myHandler.sendMessage(message); try { if (mindex == Utils.INDEX_C) { Thread.sleep(100); } else { Thread.sleep(150); } } catch (InterruptedException e) { e.printStackTrace(); } } if (gestureIsplaying == false) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } Message message = new Message(); message.what = MSG_REMOVE_GESTURE_PALY; myHandler.sendMessage(message); } } } private ContentObserver mDissmissAnimationObserver = new ContentObserver(new Handler()) { public void onChange(boolean selfChange) { if (Settings.System.getInt(mContext.getContentResolver(), "animation_disappear", 0) == 0) { Settings.System.putInt(mContext.getContentResolver(), DISSMISS_STATUS_BAR, 1); dismissKeyGuard(); if (mGesturePlayingFloatView != null) { mGesturePlayingFloatView.setVisibility(View.GONE); mGesturePlayingFloatView = null; } } } }; private View showGesturePlayFloatView(String text_tip) { if (mGesturePlayingFloatView != null && (mGesturePlayingFloatView.getVisibility() == View.VISIBLE)) { // mGesturePlayingFloatView.setVisibility(View.GONE);//remove the old show if need return mGesturePlayingFloatView; } View mpreView = null; WindowManager mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(); //wmParams.systemUiVisibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.INVISIBLE | View.SYSTEM_UI_FLAG_FULLSCREEN; //wmParams.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; //wmParams.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.INVISIBLE; //wmParams.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; //wmParams.systemUiVisibility = View.INVISIBLE; wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;//TYPE_STATUS_BAR_PANEL; int rotation = mWindowManager.getDefaultDisplay().getRotation(); wmParams.screenOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; Log.v(TAG, "showGesturePlayFloatView rotation: " + rotation + ", params: " + wmParams.screenOrientation); //wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; wmParams.width = 800; wmParams.height = 1440; wmParams.format = PixelFormat.RGBA_8888; //wmParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; mpreView = LayoutInflater.from(mContext).inflate(R.layout.gesture_play, null); mpreView.setVisibility(View.VISIBLE); mGesturePlayingDrawable = ((ImageView) mpreView.findViewById(R.id.gesture_play)); mGestureTextTip = ((TextView) mpreView.findViewById(R.id.text_tip)); if (text_tip != null) { mGesturePlayingDrawable.setBackgroundColor(Color.WHITE); mGestureTextTip.setText(text_tip); } mGesturePlayingDrawable.setEnabled(false); mWindowManager.addView(mpreView, wmParams); return mpreView; } class DialThread extends Thread { DialThread() { } public void run() { while (ActionState == PICKANDDIAL) { Log.v(TAG, "DialThread == psensor_is_allow_to_dial == " + psensor_is_allow_to_dial); Log.v(TAG, "DialThread == gsensor_is_allow_to_dial == " + gsensor_is_allow_to_dial); if (psensor_is_allow_to_dial && gsensor_is_allow_to_dial) { Intent dialintent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + sendnumber)); dialintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(dialintent); is_dialed = true; psensor_is_allow_to_dial = false; gsensor_is_allow_to_dial = false; break; } } } } public boolean isServiceRunning(Context context, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> serviceList = activityManager.getRunningServices(Integer.MAX_VALUE); if (!(serviceList.size() > 0)) { return false; } for (int i = 0; i < serviceList.size(); i++) { if (serviceList.get(i).service.getClassName().equals(className) == true) { isRunning = true; break; } } Log.i(TAG, "service is running ?= " + isRunning); return isRunning; } @Override public void sendMessage(int keyCode) throws RemoteException { Log.i(TAG, "sendMessage: " + keyCode); handleGestureKeycode(keyCode); } private void handleGestureKeycode(int keyCode) { if (isFirstClick) { //wakeUp(); isFirstClick = false; } else { isFirstClick = true; return; } Log.d(TAG, "handleGestureKeycode isFirstClick" + isFirstClick + ", keycode" + keyCode); if (Settings.Global.getInt(mContext.getContentResolver(), "country_setup_finished", 0) == 0) { Log.i(TAG, "should return by country_setup_finished !!!"); // if setupwizard not finish ,not handle the code wakeUp(); return; } if (ActivityManager.isUserAMonkey()) { Log.d(TAG, "ignoring monkey's attempt to start application"); } else { Message msg = new Message(); msg.what = MSG_GESTURE_KEYCODE; msg.obj = keyCode; myHandler.sendMessage(msg); } }}
package com.android.navigation;import java.util.ArrayList;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import egistec.ets.api.EtsLib;import egistec.ets.api.FingerprintReceiver;import egistec.ets.api.FpResDef;import com.android.server.fingerprint.FingerServerNavigationLib;import com.android.server.fingerprint.INavigationService;import com.android.server.fingerprint.INavigationServiceCallback;import android.app.ActivityManager;import android.app.Instrumentation;import android.app.KeyguardManager;import android.content.ComponentName;import android.content.Context;import android.content.Intent;import android.os.Handler;import android.os.IBinder;import android.os.Message;import android.os.PowerManager;import android.os.RemoteException;import android.os.SystemClock;import android.os.SystemProperties;import android.os.UserHandle;import android.provider.MediaStore;import android.provider.Settings;import android.telecom.TelecomManager;import android.util.Log;import android.util.SparseArray;import android.view.KeyEvent;import android.view.MotionEvent;public class NavigationService extends INavigationService.Stub { private static final String TAG = "Navigation-Service"; private static final String ACTION_SCREEN_SHOT = "android.intent.action.action_screen_shot"; private static final int START_NAVIGATION_TIMEOUT = 400; private static final int LONG_TOUCH_DURATION = 400; /** * Defines the duration in milliseconds between the first tap's up event and * the second tap's down event for an interaction to be considered a * double-tap. */ private static final int DOUBLE_TAP_TIMEOUT = 600; /** * Defines the minimum duration in milliseconds between the first tap's up event and * the second tap's down event for an interaction to be considered a * double-tap. */ private static final int DOUBLE_TAP_MIN_TIME = 100; private static final int MSG_DO_NAVIGATION = 0; private static final int MSG_CLICK_EVENT = 1000; private static final int DEFAULT_MOVE_STEPS = 30; private static final int DEFAULT_FAST_MOVE_STEPS = 15; private static final int DEFAULT_DOUBLE_MOVE_STEPS = DEFAULT_FAST_MOVE_STEPS; private static final int DEFAULT_LOCATION_X = 545;//175 private static final int DEFAULT_LOCATION_Y = 480;//600 private static final int DEFAULT_MOVE_DISTANCE = 200; private static final int DEFAULT_FAST_MOVE_DISTANCE = 300; private static final int DEFAULT_FINGERPRINT_ANSWER_CALL = 0; private static final int DEFAULT_FINGERPRINT_TAKE_PHOTO = 1; private static final int DEFAULT_FINGERPRINT_SWIP_NORMAL = 1; private long lastNaviEventTime = 0L; public static ExecutorService mPools = Executors.newSingleThreadExecutor(); public static final String[] mNavigationWhitelist = { "com.android.fmradio.FmMainActivity", "com.android.hios.launcher3.Launcher" }; private enum NavigationState { NAVI_IDLE, NAVI_CONNECTING, NAVI_RUNNING } private Context mContext; private EtsLib mEtsLib; private NavigationState mNavigationState = NavigationState.NAVI_IDLE; private boolean mIsLocking = false; private boolean mEnableAutoNavigation = true; private int mCallingThreadID; private SparseArray<INavigationServiceCallback> mFPClientCallbackMap = new SparseArray<INavigationServiceCallback>(); /** jmt101 et310 */ private static boolean sIsETSSupported = SystemProperties.get("persist.fingerprint").contains("et"); private ArrayList<Boolean> mEnableNaviList = new ArrayList<Boolean>(); private Handler mHandlerTime = new Handler(); private final Runnable timerRun = new Runnable() { @Override public void run() { if (mNavigationState == NavigationState.NAVI_RUNNING) { Log.i(TAG, "Navigation is running"); return; } mNavigationState = NavigationState.NAVI_CONNECTING; int ret = mEtsLib.startNavigation(LONG_TOUCH_DURATION); Log.d(TAG, "startNavigation ret=" + ret); if (ret == FpResDef.RESULT_OK) { mNavigationState = NavigationState.NAVI_RUNNING; return; } Log.d(TAG, "try post delay navigation again"); mHandlerTime.postDelayed(this, START_NAVIGATION_TIMEOUT); } }; public NavigationService(Context context) { Log.i(TAG, "on create SystemProperties:" + SystemProperties.get("persist.fingerprint")); Log.i(TAG, "mEnableAutoNavigation is " + mEnableAutoNavigation + ", sIsETSSupported =" + sIsETSSupported); mContext = context; mEtsLib = EtsLib.getInstance(); mEtsLib.startListening(new FingerprintReceiver() { @Override public void onFingerprintEvent(int eventId, int value1, int value2, Object eventObj) { switch (eventId) { case FpResDef.EVENT_NAVIGATION: Log.d(TAG, "EVENT_NAVIGATION id=" + mCallingThreadID + ",value=" + value1); if (!isScreenOnAndNotLocked(mContext)) { Log.d(TAG, "EVENT_NAVIGATION interrupt screen off !"); return; } // Global events /*if (value1 == FpResDef.NAVIGATION_CLICK) { interceptEventBeforeQueueing(eventId, value1, value2); break; }*/ if (mCallingThreadID > 0) { // Global events if (value1 == FpResDef.NAVIGATION_LONG_CLICK) { doNaviEvent(value1, value2); } sendMsgToClient(mCallingThreadID, eventId, value1, value2, new byte[0]); return; } if (mEnableAutoNavigation) { doNaviEvent(value1, value2); } break; default: Log.e(TAG, "onFingerprintEvent eventId=" + eventId + " v1=" + value1 + " v2=" + value2); } } }); if (mEnableAutoNavigation) { int ret = mEtsLib.startNavigation(LONG_TOUCH_DURATION); Log.d(TAG, "startNavigation ret=" + ret); } } private void interceptEventBeforeQueueing(int eventId, int keyCode, int value2) { long currentEventTime = System.currentTimeMillis(); if ((currentEventTime - lastNaviEventTime) < DOUBLE_TAP_TIMEOUT && (currentEventTime - lastNaviEventTime) >= DOUBLE_TAP_MIN_TIME) { Log.i(TAG, "double click detected between " + (currentEventTime - lastNaviEventTime) + "ms."); myHandler.removeMessages(MSG_CLICK_EVENT); lastNaviEventTime = 0L;//lastNaviEventTime = currentEventTime; // Global events doNaviEvent(FpResDef.NAVIGATION_DB_CLICK, value2); if (mCallingThreadID > 0) { sendMsgToClient(mCallingThreadID, eventId, FpResDef.NAVIGATION_DB_CLICK, value2, new byte[0]); } } else { lastNaviEventTime = currentEventTime; Message msg = myHandler.obtainMessage(MSG_CLICK_EVENT, eventId, value2, null); myHandler.sendMessageDelayed(msg, DOUBLE_TAP_TIMEOUT); } } /** * @return true if the screen is on and not locked; false otherwise, in which case tests that * send key events will fail. */ public boolean isScreenOnAndNotLocked(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (!pm.isInteractive()) { return false; } return true; } public boolean isScreenLocked() { // if support keyguard detect KeyguardManager km = (KeyguardManager) mContext .getSystemService(Context.KEYGUARD_SERVICE); if (km.inKeyguardRestrictedInputMode()) { return true; } return false; } /** * method to check fingerprint Settings * @return true if user has enable the function; false otherwise */ private boolean isFingerprintSettingEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.FINGERPRINT_ANSWER_CALL, DEFAULT_FINGERPRINT_ANSWER_CALL) != 0; } /** * method to check fingerprint Settings * @return true if user has enable the function; false otherwise */ private boolean isFingerprintCameraEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.FINGERPRINT_TAKE_PHOTO, DEFAULT_FINGERPRINT_TAKE_PHOTO) != 0; } /** * method to check fingerprint Settings * @return true if user has enable the function; false otherwise */ private boolean isFingerprintSwipEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.FINGERPRINT_SWIP_NORMAL, DEFAULT_FINGERPRINT_SWIP_NORMAL) != 0; } /** * method to check if is available by {@link # mNavigationWhitelist} * @return true if in white list, or return false; */ private boolean inWhitelist() { try { ActivityManager am = (ActivityManager) mContext .getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; Log.d(TAG, "inWhitelist cn" + cn.toShortString()); for (String item : mNavigationWhitelist) { if (cn != null && item.equals(cn.getClassName())) { return true; } } } catch (Exception e) { e.printStackTrace(); } return false; } private void sendMsgToClient(int clientId, int eventId, int value1, int value2, byte[] obj) { Log.d(TAG, "sendMsgToClient() event:" + value1); INavigationServiceCallback cb = mFPClientCallbackMap.get(clientId); if (cb == null) { Log.e(TAG, "NavigationServiceCallback instance is null at CallingThreadID=" + mCallingThreadID); return; } try { cb.postMessage(eventId, value1, value2, new byte[0]); } catch (RemoteException e) { e.printStackTrace(); } } TelecomManager getTelecommService() { return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); } private void answerCall() { if (!isFingerprintSettingEnabled()) { return; } TelecomManager telecomManager = getTelecommService(); try { Log.i(TAG, "ringing: answerCall() ring:" + telecomManager.isRinging()); if (telecomManager != null) { if (telecomManager.isRinging()) { Log.i(TAG, "ringing: Answer the call!"); telecomManager.acceptRingingCall(); } } } catch (Exception e) { e.printStackTrace(); } } private void execActionKey(final int keyCode, final int action) { Log.d(TAG, "actionKey keycode=" + keyCode + " action=" + action); mPools.execute(new Runnable() { @Override public void run() { try { Instrumentation inst = new Instrumentation(); inst.sendKeySync(new KeyEvent(action, keyCode)); } catch (Exception e) { e.printStackTrace(); } } }); } private void execActionKeyDownUp(final int keyCode) { Log.d(TAG, "actionKeyDownUp =" + keyCode); mPools.execute(new Runnable() { @Override public void run() { try { Instrumentation inst = new Instrumentation(); inst.sendKeyDownUpSync(keyCode); } catch (Exception e) { e.printStackTrace(); } } }); } private void handleActionSwipe(final int distance, boolean isFast) { if (inWhitelist() || isScreenLocked()) return; long currentEventTime = System.currentTimeMillis(); if ((currentEventTime - lastNaviEventTime) < DOUBLE_TAP_TIMEOUT) { handleActionDoubleSwipe(distance, currentEventTime - lastNaviEventTime); lastNaviEventTime = currentEventTime; return; } Log.d(TAG, "handleActionSwipe distance =" + distance + ", time:" + (currentEventTime - lastNaviEventTime)); lastNaviEventTime = currentEventTime; final long time = isFast ? 100 : 200; final int step = isFast ? DEFAULT_FAST_MOVE_STEPS : DEFAULT_MOVE_STEPS; final int gap = distance / step; final long elapsedTime = time / step; mPools.execute(new Runnable() { @Override public void run() { try { Instrumentation inst = new Instrumentation(); long downTime = SystemClock.uptimeMillis(); // ACTION_DOWN MotionEvent downEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, DEFAULT_LOCATION_X, DEFAULT_LOCATION_Y, 0); inst.sendPointerSync(downEvent); // ACTION_MOVE for (int i = 1; i <= step; i++) { downTime += elapsedTime; MotionEvent moveEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_MOVE, DEFAULT_LOCATION_X, DEFAULT_LOCATION_Y + gap * i, 0); inst.sendPointerSync(moveEvent); downTime = SystemClock.uptimeMillis(); } // ACTION_UP MotionEvent upEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_UP, DEFAULT_LOCATION_X, distance + DEFAULT_LOCATION_Y, 0); inst.sendPointerSync(upEvent); } catch (Exception e) { e.printStackTrace(); } } }); } private void handleActionDoubleSwipe(final int distance, long tag) { Log.d(TAG, "handleActionDoubleSwipe distance =" + distance + ",time:" + tag); if (inWhitelist() || isScreenLocked()) return; final long time = 80; final int gap = distance / DEFAULT_DOUBLE_MOVE_STEPS; final long elapsedTime = time / DEFAULT_DOUBLE_MOVE_STEPS; mPools.execute(new Runnable() { @Override public void run() { try { Instrumentation inst = new Instrumentation(); long downTime = SystemClock.uptimeMillis(); // ACTION_DOWN MotionEvent downEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, DEFAULT_LOCATION_X, DEFAULT_LOCATION_Y, 0); inst.sendPointerSync(downEvent); // ACTION_MOVE for (int i = 1; i <= DEFAULT_DOUBLE_MOVE_STEPS; i++) { downTime += elapsedTime; MotionEvent moveEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_MOVE, DEFAULT_LOCATION_X, DEFAULT_LOCATION_Y + gap * i, 0); downTime = SystemClock.uptimeMillis(); inst.sendPointerSync(moveEvent); } // ACTION_UP downTime += time; MotionEvent upEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_UP, DEFAULT_LOCATION_X, distance + DEFAULT_LOCATION_Y, 0); inst.sendPointerSync(upEvent); } catch (Exception e) { e.printStackTrace(); } } }); } private void doNaviEvent(int value1, int value2) { switch (value1) { case FpResDef.NAVIGATION_CLICK: Log.i(TAG, "NAVIGATION_CLICK"); // execActionKeyDownUp(KeyEvent.KEYCODE_BACK); break; case FpResDef.NAVIGATION_DB_CLICK: Log.i(TAG, "NAVIGATION_DB_CLICK"); //mContext.sendBroadcastAsUser(new Intent(ACTION_SCREEN_SHOT), UserHandle.ALL); break; case FpResDef.NAVIGATION_LONG_CLICK: Log.i(TAG, "NAVIGATION_LONG_CLICK enable-" + isFingerprintCameraEnabled()); if (isFingerprintCameraEnabled() && inWhitelist()) { execActionKeyDownUp(KeyEvent.KEYCODE_CAMERA); } answerCall(); // execActionKey(KeyEvent.KEYCODE_HOME, KeyEvent.ACTION_DOWN); break; case FpResDef.NAVIGATION_HORI_MOVENT_PLUS: Log.i(TAG, "NAVIGATION_SWIPE_LEFT enable-" + isFingerprintSwipEnabled()); if (isFingerprintSwipEnabled()) { handleActionSwipe(-1 * DEFAULT_MOVE_DISTANCE, false); } break; case FpResDef.NAVIGATION_HORI_MOVENT_MINNUS: Log.i(TAG, "NAVIGATION_SWIPE_RIGHT enable-" + isFingerprintSwipEnabled()); if (isFingerprintSwipEnabled()) { handleActionSwipe(DEFAULT_MOVE_DISTANCE, false); } break; case FpResDef.NAVIGATION_FAST_MOVENT_PLUS: Log.i(TAG, "NAVIGATION_FAST_SWIPE_LEFT enable-" + isFingerprintSwipEnabled()); if (isFingerprintSwipEnabled()) { handleActionSwipe(-1 * DEFAULT_FAST_MOVE_DISTANCE, true); } break; case FpResDef.NAVIGATION_FAST_MOVENT_MINNUS: Log.i(TAG, "NAVIGATION_FAST_SWIPE_RIGHT enable-" + isFingerprintSwipEnabled()); if (isFingerprintSwipEnabled()) { handleActionSwipe(DEFAULT_FAST_MOVE_DISTANCE, true); } break; default: Log.e(TAG, "doNaviEvent v1=" + value1 + " v2=" + value2); } } private final class Callback implements IBinder.DeathRecipient { @Override public void binderDied() { Log.i(TAG, "binderDied enter"); mCallingThreadID = 0; /* * int pid = getCallingPid(); Log.d(TAG, "calling pid = "+pid); * mFPClientCallbackMap.remove(pid); if (mCallingThreadID == pid) * mCallingThreadID = 0; */ } } private void startNavigation() { Log.i(TAG, "start Navigation"); if (mNavigationState != NavigationState.NAVI_IDLE) { Log.e(TAG, "Already Navigation State"); return; } mHandlerTime.removeCallbacks(timerRun); mHandlerTime.postDelayed(timerRun, START_NAVIGATION_TIMEOUT); } private void removeNavigationListen() { Log.i(TAG, "remove navigation listen"); mHandlerTime.removeCallbacks(timerRun); mNavigationState = NavigationState.NAVI_IDLE; } @Override public int notifyFingerHalState(int halState) throws RemoteException { Log.d(TAG, "notifyHalState halState=" + halState); if (halState == FingerServerNavigationLib.STATE_HAL_USING) { if (mCallingThreadID > 0) { sendMsgToClient(mCallingThreadID, FpResDef.EVENT_NAVIGATION, FpResDef.NAVIGATION_STOP, 0, new byte[0]); mCallingThreadID = 0; } } if (!mEnableAutoNavigation) { return 0; } mEnableNaviList .add(halState == FingerServerNavigationLib.STATE_HAL_UNUSED); myHandler.obtainMessage(MSG_DO_NAVIGATION, 0, 0, null).sendToTarget(); return 0; } Handler myHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_DO_NAVIGATION: Log.d(TAG, "MSG_DO_NAVIGATION"); if (mIsLocking) { Log.d(TAG, "MSG_DO_NAVIGATION locking"); return; } mIsLocking = true; Log.d(TAG, "handle mEnableNaviList"); while (!mEnableNaviList.isEmpty()) { if (mEnableNaviList.get(0)) { startNavigation(); } else { removeNavigationListen(); } mEnableNaviList.remove(0); } Log.d(TAG, "end handle mEnableNaviList"); mIsLocking = false; break; case MSG_CLICK_EVENT: if (mCallingThreadID > 0) { sendMsgToClient(mCallingThreadID, (int)msg.arg1, FpResDef.NAVIGATION_CLICK, (int)msg.arg2, new byte[0]); return; } if (mEnableAutoNavigation) { doNaviEvent((int)msg.arg1, (int)msg.arg2); } break; default: break; } } }; @Override public void registerCallback(INavigationServiceCallback callback) throws RemoteException { Log.i(TAG, "registerCallback()"); if (callback == null) { Log.e(TAG, "NavigationServiceCallback instance is null"); return; } IBinder binder = callback.asBinder(); if (binder == null) { Log.e(TAG, "callback's binder is null"); return; } binder.linkToDeath(new Callback(), 0); int pid = getCallingPid(); Log.d(TAG, "calling pid = " + pid); mFPClientCallbackMap.put(pid, callback); } @Override public int doNavigation() throws RemoteException { mCallingThreadID = getCallingPid(); int ret = mEtsLib.startNavigation(LONG_TOUCH_DURATION); Log.d(TAG, "startNavigation ret=" + ret); if (ret == FpResDef.RESULT_OK) { mNavigationState = NavigationState.NAVI_RUNNING; return ret; } if ((ret == FpResDef.RESULT_THREAD_BUSY) && (mNavigationState == NavigationState.NAVI_RUNNING)) { Log.d(TAG, "Navigation is running"); return FpResDef.RESULT_OK; } return ret; } @Override public void unregisterCallback(INavigationServiceCallback arg0) throws RemoteException { Log.i(TAG, "unregisterCallback()"); int pid = getCallingPid(); Log.d(TAG, "calling pid = " + pid); mFPClientCallbackMap.remove(pid); if (mCallingThreadID == pid) mCallingThreadID = 0; }}
0 0
- ACTION AIDL
- AIDL
- aidl
- AIDL
- AIDL
- AIDL
- AIDL
- AIDL
- aidl
- aidl
- AIDL
- AIDL
- aidl
- AIDL
- AIDL
- AIDL
- aidl
- aidl
- 在安卓中使用AnimationSet类同时执行多种动画效果
- spring+springMVC声明事物管理配置
- linux下yum源配置
- centos下搭建MySQL主从复制
- nyoj252 01串(动态规划)
- ACTION AIDL
- Python使用poster
- Python---BeautifulSoup 简单的爬虫实例
- ubuntu 安装 redis,并配置远程、密码
- 并发数 = QPS*平均响应时间
- 设计模式学习之适配器模式
- 项目名字缩成rtp了:关于ROS actionlib的multiple goals
- linux命令rm
- vue-cli搭建项目