正在查看: Aptoide v9.22.5.3 应用的 PullingContentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Aptoide v9.22.5.3 应用的 PullingContentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package cm.aptoide.pt.notification;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.os.SystemClock;
import cm.aptoide.pt.AptoideApplication;
import cm.aptoide.pt.BaseService;
import cm.aptoide.pt.crashreports.CrashReport;
import cm.aptoide.pt.database.room.RoomUpdate;
import cm.aptoide.pt.download.DownloadFactory;
import cm.aptoide.pt.install.InstallManager;
import cm.aptoide.pt.preferences.managed.ManagerPreferences;
import cm.aptoide.pt.updates.UpdateRepository;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import rx.schedulers.Schedulers;
public class PullingContentService extends BaseService {
public static final String BOOT_COMPLETED_ACTION = "BOOT_COMPLETED_ACTION";
public static final String PUSH_NOTIFICATIONS_ACTION = "PUSH_NOTIFICATIONS_ACTION";
public static final String UPDATES_ACTION = "UPDATES_ACTION";
public static final long UPDATES_INTERVAL = 86400000;
private AptoideApplication application;
@Inject
DownloadFactory downloadFactory;
private InstallManager installManager;
@Inject
@Named
String marketName;
private SharedPreferences sharedPreferences;
private rx.t.b subscriptions;
@Inject
UpdateRepository updateRepository;
private rx.e<Boolean> autoUpdate(final List<RoomUpdate> list) {
return rx.e.S(Boolean.valueOf(ManagerPreferences.isAutoUpdateEnable(this.sharedPreferences) && ManagerPreferences.allowRootInstallation(this.sharedPreferences))).G(new rx.m.e() {
@Override
public final Object call(Object obj) {
return PullingContentService.this.c(list, (Boolean) obj);
}
});
}
private long getElapsedRealtimeTrigger(long j) {
return SystemClock.elapsedRealtime() + j;
}
private boolean isAlarmUp(Context context, String str) {
Intent intent = new Intent(context, (Class<?>) PullingContentService.class);
intent.setAction(str);
return PendingIntent.getService(context, 0, intent, 67108864) != null;
}
public ArrayList a(List list) {
ArrayList arrayList = new ArrayList(list.size());
Iterator it = list.iterator();
while (it.hasNext()) {
arrayList.add(this.downloadFactory.create((RoomUpdate) it.next(), false, Collections.emptyList()));
}
return arrayList;
}
public rx.e b(ArrayList arrayList) {
return this.installManager.startInstalls(arrayList);
}
public rx.e c(List list, Boolean bool) {
return bool.booleanValue() ? rx.e.S(list).j0(Schedulers.io()).X(new rx.m.e() {
@Override
public final Object call(Object obj) {
return PullingContentService.this.a((List) obj);
}
}).G(new rx.m.e() {
@Override
public final Object call(Object obj) {
return PullingContentService.this.b((ArrayList) obj);
}
}) : rx.e.S(Boolean.FALSE);
}
static rx.e lambda$setUpdatesAction$0(List list, Boolean bool) {
return bool.booleanValue() ? rx.e.B() : rx.e.S(list);
}
public rx.e d(final List list) {
return autoUpdate(list).G(new rx.m.e() {
@Override
public final Object call(Object obj) {
return PullingContentService.lambda$setUpdatesAction$0(list, (Boolean) obj);
}
});
}
public Boolean e(List list) {
return Boolean.valueOf(ManagerPreferences.isUpdateNotificationEnable(this.sharedPreferences));
}
public void f(int i, List list) {
stopSelf(i);
}
static void lambda$setUpdatesAction$4(List list) {
}
static void lambda$setUpdatesAction$5(Throwable th) {
th.printStackTrace();
CrashReport.getInstance().log(th);
}
private void setUpdatesAction(final int i) {
this.subscriptions.a(this.updateRepository.getAll(false).E().j0(Schedulers.computation()).G(new rx.m.e() {
@Override
public final Object call(Object obj) {
return PullingContentService.this.d((List) obj);
}
}).D(new rx.m.e() {
@Override
public final Object call(Object obj) {
return PullingContentService.this.e((List) obj);
}
}).j0(Schedulers.io()).x(new rx.m.b() {
@Override
public final void call(Object obj) {
PullingContentService.this.f(i, (List) obj);
}
}).H0(new rx.m.b() {
@Override
public final void call(Object obj) {
PullingContentService.lambda$setUpdatesAction$4((List) obj);
}
}, new rx.m.b() {
@Override
public final void call(Object obj) {
PullingContentService.lambda$setUpdatesAction$5((Throwable) obj);
}
}));
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
getApplicationComponent().inject(this);
AptoideApplication aptoideApplication = (AptoideApplication) getApplicationContext();
this.application = aptoideApplication;
this.sharedPreferences = aptoideApplication.getDefaultSharedPreferences();
this.installManager = this.application.getInstallManager();
this.subscriptions = new rx.t.b();
AlarmManager alarmManager = (AlarmManager) getSystemService("alarm");
if (isAlarmUp(this, UPDATES_ACTION)) {
return;
}
setAlarm(alarmManager, this, UPDATES_ACTION, UPDATES_INTERVAL);
}
@Override
public void onDestroy() {
this.subscriptions.b();
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
String action = intent == null ? null : intent.getAction();
if (action == null) {
return 2;
}
if (!action.equals(BOOT_COMPLETED_ACTION) && !action.equals(UPDATES_ACTION)) {
return 2;
}
setUpdatesAction(i2);
return 2;
}
public void setAlarm(AlarmManager alarmManager, Context context, String str, long j) {
Intent intent = new Intent(context, (Class<?>) PullingContentService.class);
intent.setAction(str);
alarmManager.setInexactRepeating(3, getElapsedRealtimeTrigger(j), getElapsedRealtimeTrigger(j), PendingIntent.getService(context, 0, intent, 67108864));
}
}