package com.hjx.personalcenter.service; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; import com.google.gson.Gson; import com.hjx.personalcenter.activity.LoginAndRegisterActivity; import com.hjx.personalcenter.db.SaveParam; import com.hjx.personalcenter.model.CardInfo; import com.hjx.personalcenter.model.LoginInfo; import com.hjx.personalcenter.model.UserInfoModer; import com.hjx.personalcenter.util.GetDevicesUtil; /** * Created by h on 2017/9/1. */ public class CenterService extends BaseService { enum ACTIVITY_ACTION{ userinfo_activity } public CenterService(){ } IPresonalInterface.Stub binder = new IPresonalInterface.Stub() { @Override public String sayHello() throws RemoteException { return "这是测试AIDL的方法"; } @Override public String viewPage(String action) throws RemoteException { String result = null; if(action.equals(ACTIVITY_ACTION.userinfo_activity.toString())){ //登录界面 Intent intent = new Intent(); intent.setClass(CenterService.this, LoginAndRegisterActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); result= "跳转成功"; } return result; } @Override public String getSimpleUser() throws RemoteException { String logininfo = null; Gson gson = new Gson(); LoginInfo loginInfo = new LoginInfo(); String islogin = SaveParam.getInstance().getLoginParam(getApplication(),"login"); //子账户id String childsidid = SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CHILDSID); //账户类型 String accounts = SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ACCOUNT); if ("true".equals(islogin)){ loginInfo.setUsername(SaveParam.getInstance().getLoginParam(getApplication(), "username")); loginInfo.setPassword(SaveParam.getInstance().getLoginParam(getApplication(), "password")); loginInfo.setAccess_token(SaveParam.getInstance().getLoginParam(getApplication(), "access_token")); loginInfo.setLoginStatus(SaveParam.getInstance().getLoginParam(getApplication(), "login")); if ("2".equals(accounts)){ loginInfo.setUserId(childsidid); }else { loginInfo.setUserId(SaveParam.getInstance().getLoginParam(getApplication(), "userId")); } logininfo =gson.toJson(loginInfo); //Log.e("test","登录信息"+logininfo); } return logininfo; } //保卡信息 @Override public String getcardUser() throws RemoteException { String results = null; // CardInfo cardInfo = new CardInfo(); CardInfo.DataBean dataBean = new CardInfo.DataBean(); Gson gson = new Gson(); //获取设备信息 dataBean.setProductModel(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceModel()); dataBean.setDeviceNumber(GetDevicesUtil.getDevicesInfo(getApplication()).getDeviceNumber()); dataBean.setMacAddress(GetDevicesUtil.getDevicesInfo(getApplication()).getMac()); //获取保卡信息 dataBean.setCustomerName(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CUNSTEMNAME)); dataBean.setCustomerAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.ADRESSCUNSTEM)); dataBean.setBuyTime(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTIME)); dataBean.setBuyAddress(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPADRESS)); dataBean.setAlterSaleCall(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.SHOPTLEPHONE)); dataBean.setMobilePhone(SaveParam.getInstance().getCustomizeParam(getApplication(),SaveParam.CARDPHONE)); // cardInfo.setData(dataBean); //Log.e("test","保卡信息"+results); String yangji = SaveParam.getInstance().getLoginParam(getApplication(), SaveParam.YANGJI); if ("1".equals(yangji)) { results = null; } else { results = gson.toJson(dataBean); } return results; } @Override public String getUserInfo() throws RemoteException { String userinfo = null; Gson gson = new Gson(); UserInfoModer userInfoModer = new UserInfoModer(); userInfoModer.setNickName(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.ACCOUNTUSERNAME)); userInfoModer.setGrade(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.ACCOUNTGRADES)); userInfoModer.setSchool(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.ACCOUNTSCHOOL)); userInfoModer.setBirthday(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.ACCOUNTCONSTELLATION)); userInfoModer.setGender(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.ACCOUNTSEX)); userInfoModer.setQq(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.ACCOUNTQQ)); userInfoModer.setAddress(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.ACCOUNTXINGZUO)); userInfoModer.setPortrait(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.PORTAIT)); userInfoModer.setGradeid(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.GRADENS)); userInfoModer.setIsprototype(SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.YANGJI)); userinfo = gson.toJson(userInfoModer); return userinfo; } @Override public String logout() throws RemoteException { String visoninfo = SaveParam.getInstance().getLoginParam(getApplication(),SaveParam.VERSIONINTEFACE); return visoninfo; } @Override public String validateToken() throws RemoteException { return null; } @Override public String getDeviceID() throws RemoteException { return null; } @Override public String getChildsInfo() throws RemoteException { return null; } }; @Override public IBinder onBind(Intent intent) { return binder; } @Override public void onDestroy() { super.onDestroy(); } }