package com.uiui.sn.service; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; import android.provider.Settings; import android.util.Log; import com.google.gson.JsonObject; import com.uiui.sn.IGetInfoInterface; import com.uiui.sn.service.main.MainService; import com.uiui.sn.utils.JGYUtils; import com.uiui.sn.utils.SPUtils; import com.uiui.sn.utils.Utils; import java.util.List; public class RemoteService extends Service { private String TAG = RemoteService.class.getSimpleName(); public RemoteService() { } @Override public IBinder onBind(Intent intent) { Log.e(TAG, "onBind: "); return mBinde; } @Override public void onCreate() { Log.e(TAG, "onCreate: "); super.onCreate(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e(TAG, "onStartCommand: "); return super.onStartCommand(intent, flags, startId); } private IBinder mBinde = new IGetInfoInterface.Stub() { @Override public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException { } @Override public String getSerial() throws RemoteException { return Utils.getSerial(); } @Override public String getUserInfo() throws RemoteException { if (MainService.getPresenter() != null) { // MainService.getPresenter().getUserInfo(); } String username = Settings.System.getString(getContentResolver(), "UserInfo_username"); String avatar = Settings.System.getString(getContentResolver(), "UserInfo_avatar"); int gread = (int) SPUtils.get(RemoteService.this, "int_grade", 0); String gankaoUID = Settings.System.getString(getContentResolver(), "gankaoUID"); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("username", username); jsonObject.addProperty("avatar", avatar); jsonObject.addProperty("grade", gread); jsonObject.addProperty("userid", gankaoUID); jsonObject.addProperty("sn", Utils.getSerial()); Log.e(TAG, "getUserInfo:" + jsonObject.toString()); return jsonObject.toString(); } @Override public List getHideAPP() throws RemoteException { return JGYUtils.getInstance().getHideList(); } @Override public List getForbidAPP() throws RemoteException { return JGYUtils.getInstance().getForbidList(); } }; }