正在查看: xDrip+ v04633772025.07.16 应用的 PlusSyncService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 PlusSyncService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip.services;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
import com.eveningoutpost.dexdrip.GcmActivity;
import com.eveningoutpost.dexdrip.GoogleDriveInterface;
import com.eveningoutpost.dexdrip.cloud.jamcm.Pusher;
import com.eveningoutpost.dexdrip.utilitymodels.UpdateActivity;
import com.eveningoutpost.dexdrip.xdrip;
import java.lang.ref.WeakReference;
public class PlusSyncService extends Service {
public static boolean created = false;
private static boolean keeprunning = false;
private static boolean skipnext = false;
public static long sleepcounter = 5000;
Context context;
final MyHandler mHandler = new MyHandler(this);
private SharedPreferences prefs;
public static void clearandRestartSyncService(Context context) {
GoogleDriveInterface.invalidate();
GcmActivity.token = null;
speedup();
Pusher.requestReconnect();
startSyncService(context, "clearAndRestart");
}
public static synchronized void startSyncService(Context context, String str) {
synchronized (PlusSyncService.class) {
if (created) {
Log.d("jamorham plussync", "Already created");
return;
}
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("disable_all_sync", false)) {
keeprunning = false;
GcmActivity.cease_all_activity = true;
Log.d("jamorham plussync", "Sync services disabled");
} else if (GcmActivity.token == null || xdrip.getAppContext() == null) {
Log.d("jamorham plussync", "Starting jamorham xDrip-Plus sync service: " + str);
context.startService(new Intent(context, (Class<?>) PlusSyncService.class));
}
}
}
public static void backoff_a_lot() {
if (sleepcounter < 60000) {
sleepcounter = 60000L;
}
skipnext = true;
}
public static void speedup() {
sleepcounter = 3000L;
skipnext = false;
}
@Override
public void onCreate() {
this.context = this;
this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
created = true;
Log.i("jamorham plussync", "jamorham xDrip-Plus sync service onStart command called");
keeprunning = true;
sleepcounter = 5000L;
new Thread(new Runnable() {
@Override
public void run() {
while (PlusSyncService.keeprunning) {
try {
Thread.sleep(PlusSyncService.sleepcounter);
if (PlusSyncService.skipnext) {
boolean unused = PlusSyncService.skipnext = false;
} else {
PlusSyncService.this.mHandler.sendEmptyMessage(0);
}
long j = PlusSyncService.sleepcounter;
if (j < 600000) {
PlusSyncService.sleepcounter = j + 500;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
PlusSyncService.created = false;
}
}).start();
Log.i("jamorham plussync", "jamorham xDrip-Plus sync service onStart command complete");
return 2;
}
@Override
public void onLowMemory() {
Log.e("jamorham plussync", "Low memory trigger!");
keeprunning = false;
}
@Override
public void onDestroy() {
keeprunning = false;
created = false;
}
@Override
public IBinder onBind(Intent intent) {
throw new UnsupportedOperationException("Not yet implemented");
}
private class MyHandler extends Handler {
private final WeakReference<PlusSyncService> mActivity;
public MyHandler(PlusSyncService plusSyncService) {
this.mActivity = new WeakReference<>(plusSyncService);
}
@Override
public void handleMessage(Message message) {
if (this.mActivity.get() != null) {
if (GoogleDriveInterface.getDriveIdentityString() == null) {
boolean z = PlusSyncService.this.prefs.getBoolean("I_understand", false);
if (GoogleDriveInterface.isRunning || !z) {
Log.d("jamorham plussync", "Drive interface is running or blocked");
return;
}
return;
}
if (GcmActivity.token == null) {
if (GcmActivity.cease_all_activity) {
Log.d("jamorham plussync", "GCM cease all activity flag set!");
updateCheckThenStop();
return;
} else {
Log.d("jamorham plussync", "Calling Google Cloud Interface");
new GcmActivity().jumpStart();
return;
}
}
Log.d("jamorham plussync", "Got our token - stopping polling");
updateCheckThenStop();
}
}
private void updateCheckThenStop() {
boolean unused = PlusSyncService.keeprunning = false;
boolean unused2 = PlusSyncService.skipnext = true;
UpdateActivity.checkForAnUpdate(PlusSyncService.this.context);
try {
Log.d("jamorham plussync", "Shutting down");
PlusSyncService.this.stopSelf();
} catch (Exception unused3) {
Log.e("jamorham plussync", "Exception with stop self");
}
}
}
}