version:3.6

fix:去点腾讯推送
update:去掉系统节点
This commit is contained in:
2023-08-26 15:27:31 +08:00
parent 66171ac7e5
commit bf183a1dc2
116 changed files with 2566 additions and 1751 deletions

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;
@@ -18,20 +19,26 @@ import com.uiuios.aios.disklrucache.CacheHelper;
import com.uiuios.sn.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();
private static final String SN_KEY = "sn_serial_key";
@SuppressLint("StaticFieldLeak")
private static RemoteManager sInstance;
private Context mContext;
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
private CacheHelper mCacheHelper;
private IGetInfoInterface getInfoInterface;
private IGetInfoInterface mGetInfoInterface;
private ServiceConnection mIGetInfoConnection;
private RemoteManager(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
@@ -42,14 +49,26 @@ public class RemoteManager {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
getInfoInterface = IGetInfoInterface.Stub.asInterface(service);
mGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
for (ConnectedListener listener : mListeners) {
if (listener != null) {
listener.onConnected();
}
}
try {
String sn = mGetInfoInterface.getSerial();
mMMKV.encode(SN_KEY, sn);
Log.e(TAG, "onServiceConnected: sn = " + sn);
} catch (RemoteException e) {
e.printStackTrace();
}
getLocation();
}
@Override
public void onServiceDisconnected(ComponentName name) {
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
getInfoInterface = null;
mGetInfoInterface = null;
bindInfoService();
}
};
@@ -70,8 +89,21 @@ public class RemoteManager {
return sInstance;
}
public interface ConnectedListener {
void onConnected();
}
Set<ConnectedListener> mListeners = new HashSet<>();
public void setListener(ConnectedListener listener) {
mListeners.add(listener);
if (mGetInfoInterface != null) {
listener.onConnected();
}
}
private void bindInfoService() {
if (getInfoInterface == null) {
if (mGetInfoInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
intent.setAction("com.uiuios.sn.IGetInfoInterface");
@@ -81,10 +113,26 @@ public class RemoteManager {
}
}
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 mMMKV.decodeString(SN_KEY, "");
}
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());
@@ -127,7 +175,7 @@ public class RemoteManager {
getLocation();
return "北京";
} else {
return mapBean.getCity() + "\t" + mapBean.getDistrict();
return mapBean.getCity() + "\t" + mapBean.getDistrict();
}
}
@@ -157,9 +205,82 @@ public class RemoteManager {
getLocation();
return "0.0";
} else {
return mapBean.getLongitude() + "," + mapBean.getLatitude();
return mapBean.getLongitude() + "," + mapBean.getLatitude();
}
}
public boolean putSystemInt(String name, int value) {
if (mGetInfoInterface != null) {
try {
return mGetInfoInterface.SystemPutInt(name, value);
} catch (Exception e) {
Log.e(TAG, "putSystemInt: " + e.getMessage());
}
} else {
bindInfoService();
}
return false;
}
public void killBackgroundProcesses(String pkg) {
if (mGetInfoInterface != null) {
try {
mGetInfoInterface.killBackgroundProcesses(pkg);
} catch (Exception e) {
Log.e(TAG, "killBackgroundProcesses: " + e.getMessage());
}
} else {
bindInfoService();
}
}
public String getConnectWifiSsid() {
if (mGetInfoInterface != null) {
try {
return mGetInfoInterface.getWifiSsid();
} catch (Exception e) {
Log.e(TAG, "killBackgroundProcesses: " + e.getMessage());
}
} else {
bindInfoService();
}
return "获取失败";
}
public String getBluetoothDeviceName() {
if (mGetInfoInterface != null) {
try {
return mGetInfoInterface.getBluetoothSsid();
} catch (Exception e) {
Log.e(TAG, "killBackgroundProcesses: " + e.getMessage());
}
} else {
bindInfoService();
}
return "获取失败";
}
public void openLauncher3() {
if (mGetInfoInterface != null) {
try {
mGetInfoInterface.openLauncher3();
} catch (Exception e) {
Log.e(TAG, "openLauncher3: " + e.getMessage());
}
} else {
bindInfoService();
}
}
public void setDefaultDesktop(String pkgName, String className) {
if (mGetInfoInterface != null) {
try {
mGetInfoInterface.setDefaultDesktop(pkgName, className);
} catch (Exception e) {
Log.e(TAG, "setDefaultDesktop: " + e.getMessage());
}
} else {
bindInfoService();
}
}
}