Files
FLYSN/app/src/main/java/com/fuying/sn/service/RemoteService.java
T
tongtong 87f728c386 version:3.3.8
fix:修复没有设置管控时间无法管控问题
update:
2025-06-27 10:24:09 +08:00

109 lines
3.8 KiB
Java

package com.fuying.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.fuying.sn.BuildConfig;
import com.fuying.sn.IGetInfoInterface;
import com.fuying.sn.config.CommonConfig;
import com.fuying.sn.desktop.RunningAppManager;
import com.fuying.sn.network.NetInterfaceManager;
import com.fuying.sn.utils.Utils;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
import java.util.ArrayList;
import java.util.List;
public class RemoteService extends Service {
private static final String TAG = "RemoteService";
public RemoteService() {
}
@Override
public IBinder onBind(Intent intent) {
Log.e(TAG, "onBind: ");
return mBinde;
}
@Override
public void onCreate() {
super.onCreate();
Log.e(TAG, "onCreate: ");
tPushInit();
}
private void tPushInit() {
XGPushConfig.enableDebug(this, true);
XGPushManager.registerPush(this, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
//token在设备卸载重装的时候有可能会变
Log.e("TPush", "注册成功,设备token为:" + data);
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
Log.e("TPush", "onSuccess: " + Utils.getSerial());
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
XGPushManager.upsertAccounts(RemoteService.this, accountInfoList, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
Log.e("TPush", "upsertAccounts onSuccess, data:" + data + ", flag:" + flag);
NetInterfaceManager.getInstance().setPushTags();
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "upsertAccounts onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
}
});
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
}
});
}
@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 boolean isControl() throws RemoteException {
int is_control = Settings.System.getInt(getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
Log.e(TAG, "inControlTime: is_control = " + is_control);
return is_control == 1;
}
@Override
public boolean inControl(String pkg) throws RemoteException {
boolean control = RunningAppManager.getInstance().inControlTime(pkg);
Log.e(TAG, "inControl: " + control);
return control;
}
@Override
public String getDisableContent(String pkg) throws RemoteException {
String content = RunningAppManager.getInstance().getDisableContent(pkg);
if (BuildConfig.DEBUG) {
Log.e(TAG, "getDisableContent: " + content);
}
return content;
}
};
}