version:1.2

fix:优化卡顿
update:基本对接完成,增加指示器放大
This commit is contained in:
2023-02-23 11:26:22 +08:00
parent cd4ba088fc
commit 2772685f0e
182 changed files with 13448 additions and 418 deletions

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.util.Log;
import com.tencent.mmkv.MMKV;
import com.uiui.zyos.config.CommonConfig;
import com.uiui.zyos.utils.TimeUtils;
public class ConnectManager {
@@ -30,7 +31,7 @@ public class ConnectManager {
@SuppressLint("StaticFieldLeak")
private static ConnectManager sInstance;
private Context mContext;
private MMKV mMMKV = MMKV.defaultMMKV();
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
private ConnectManager(Context context) {
if (context == null) {

View File

@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
@@ -14,12 +15,19 @@ import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.mmkv.MMKV;
import com.uiui.zyos.BuildConfig;
import com.uiui.zyos.bean.MapBean;
import com.uiui.zyos.config.CommonConfig;
import com.uiui.zysn.IGetInfoInterface;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class RemoteManager {
private static final String TAG = RemoteManager.class.getSimpleName();
@@ -27,7 +35,8 @@ public class RemoteManager {
@SuppressLint("StaticFieldLeak")
private static RemoteManager sInstance;
private Context mContext;
private MMKV mMMKV = MMKV.defaultMMKV();
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
private static boolean mServiceConnected = false;
private IGetInfoInterface mGetInfoInterface;
private ServiceConnection mServiceConnection;
@@ -46,7 +55,16 @@ public class RemoteManager {
public void onServiceConnected(ComponentName name, IBinder service) {
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
mGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
mServiceConnected = true;
for (ConnectedListener listener : mListeners) {
listener.onConnected();
}
getLocation();
try {
Log.e(TAG, "onServiceConnected: macaddr = " + mGetInfoInterface.getSerial());
} catch (RemoteException e) {
e.printStackTrace();
}
Log.e(TAG, "onServiceConnected: " + getSerial());
aliyunPushInit();
}
@@ -56,6 +74,7 @@ public class RemoteManager {
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
//置空,重连
mGetInfoInterface = null;
mServiceConnected = false;
bindInfoService();
}
};
@@ -76,9 +95,41 @@ public class RemoteManager {
return sInstance;
}
private void bindInfoService() {
if (mGetInfoInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
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 interface ConnectedListener {
void onConnected();
}
private static Set<ConnectedListener> mListeners = new HashSet<>();
public static void setListener(ConnectedListener listener) {
mListeners.add(listener);
if (mServiceConnected) {
listener.onConnected();
}
}
public static void removeListener(ConnectedListener listener) {
mListeners.remove(listener);
}
public void aliyunPushInit() {
CloudPushService pushService = PushServiceFactory.getCloudPushService();
if (TextUtils.isEmpty(getSerial())) {
Log.e(TAG, "aliyunPushInit: empty");
return;
}
String account = getSerial();
CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.bindAccount(account, new CommonCallback() {
@Override
public void onSuccess(String s) {
@@ -106,24 +157,32 @@ public class RemoteManager {
});
}
private void bindInfoService() {
if (mGetInfoInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
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 tpushInit() {
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), RemoteManager.getInstance().getSerial()));
XGPushManager.upsertAccounts(mContext, accountInfoList, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
}
});
}
/**
* @return 获取sn
*/
public String getSerial() {
// if (BuildConfig.DEBUG) {
// return "1234567890ab";
// }
if (mGetInfoInterface != null) {
try {
return mGetInfoInterface.getSerial();
return mGetInfoInterface.getPushMac();
} catch (Exception e) {
Log.e(TAG, "getSerial: " + e.getMessage());
}