version:1.0

fix:
update:基本布局实现
This commit is contained in:
2023-02-09 16:03:47 +08:00
parent ace6008709
commit 34433f4f1f
360 changed files with 6211 additions and 8615 deletions

View File

@@ -14,8 +14,7 @@ import com.google.gson.reflect.TypeToken;
import com.tencent.mmkv.MMKV;
import com.uiui.zyos.bean.MapBean;
import com.uiui.zyos.config.CommonConfig;
import com.uiui.zyos.disklrucache.CacheHelper;
import com.uiui.sn.IGetInfoInterface;
import com.uiui.zysn.IGetInfoInterface;
import java.lang.reflect.Type;
@@ -26,30 +25,33 @@ public class RemoteManager {
private static RemoteManager sInstance;
private Context mContext;
private MMKV mMMKV = MMKV.defaultMMKV();
private CacheHelper mCacheHelper;
private IGetInfoInterface getInfoInterface;
private ServiceConnection mIGetInfoConnection;
private IGetInfoInterface mGetInfoInterface;
private ServiceConnection mServiceConnection;
private static final String SN_AIDL_NAME = "com.uiui.zysn.IGetInfoInterface";
private static final String SN_PACKAGE_NAME = "com.uiui.zysn";
private static final String SN_SERVICE_NAME = "com.uiui.zysn.service.RemoteService";
private RemoteManager(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
}
this.mContext = context;
this.mCacheHelper = new CacheHelper(context);
mIGetInfoConnection = new ServiceConnection() {
mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
getInfoInterface = IGetInfoInterface.Stub.asInterface(service);
mGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
getLocation();
Log.e(TAG, "onServiceConnected: " + getSerial());
}
@Override
public void onServiceDisconnected(ComponentName name) {
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
getInfoInterface = null;
//置空,重连
mGetInfoInterface = null;
bindInfoService();
}
};
@@ -71,20 +73,36 @@ public class RemoteManager {
}
private void bindInfoService() {
if (getInfoInterface == null) {
if (mGetInfoInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
intent.setAction("com.uiui.sn.IGetInfoInterface");
intent.setPackage("com.uiui.sn");
intent.setComponent(new ComponentName("com.uiui.sn", "com.uiui.sn.service.RemoteService"));
mContext.bindService(intent, mIGetInfoConnection, Context.BIND_AUTO_CREATE);
intent.setAction(SN_AIDL_NAME);
intent.setPackage(SN_PACKAGE_NAME);
intent.setComponent(new ComponentName(SN_PACKAGE_NAME, SN_SERVICE_NAME));
mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
}
}
public void getLocation() {
if (getInfoInterface != null) {
/**
* @return 获取sn
*/
public String getSerial() {
if (mGetInfoInterface != null) {
try {
String jsonString = getInfoInterface.getMapResult();
return mGetInfoInterface.getSerial();
} catch (Exception e) {
Log.e(TAG, "getSerial: " + e.getMessage());
}
} else {
bindInfoService();
}
return "unknown";
}
public void getLocation() {
if (mGetInfoInterface != null) {
try {
String jsonString = mGetInfoInterface.getMapResult();
mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, jsonString);
} catch (Exception e) {
Log.e(TAG, "getMapResult: " + e.getMessage());
@@ -120,14 +138,13 @@ public class RemoteManager {
}
}
public String getCityDistrict() {
MapBean mapBean = getMapBean();
if (mapBean == null) {
getLocation();
return "北京";
} else {
return mapBean.getCity() + "\t" + mapBean.getDistrict();
return mapBean.getCity() + "\t" + mapBean.getDistrict();
}
}
@@ -157,9 +174,7 @@ public class RemoteManager {
getLocation();
return "0.0";
} else {
return mapBean.getLongitude() + "," + mapBean.getLatitude();
return mapBean.getLongitude() + "," + mapBean.getLatitude();
}
}
}