Add Discord community version (64-bit only)

- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
This commit is contained in:
2026-02-18 15:48:36 -08:00
parent c19eb3d7ff
commit c080f0d97f
26930 changed files with 2529574 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package androidx.work.impl.foreground;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.work.ForegroundInfo;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public interface ForegroundProcessor {
void startForeground(@NonNull String str, @NonNull ForegroundInfo foregroundInfo);
}

View File

@@ -0,0 +1,323 @@
package androidx.work.impl.foreground;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.work.ForegroundInfo;
import androidx.work.Logger;
import androidx.work.WorkInfo;
import androidx.work.impl.ExecutionListener;
import androidx.work.impl.WorkManagerImpl;
import androidx.work.impl.constraints.ConstraintsState;
import androidx.work.impl.constraints.OnConstraintsStateChangedListener;
import androidx.work.impl.constraints.WorkConstraintsTracker;
import androidx.work.impl.constraints.WorkConstraintsTrackerKt;
import androidx.work.impl.model.WorkGenerationalId;
import androidx.work.impl.model.WorkSpec;
import androidx.work.impl.model.WorkSpecKt;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import kotlinx.coroutines.Job;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SystemForegroundDispatcher implements OnConstraintsStateChangedListener, ExecutionListener {
private static final String ACTION_CANCEL_WORK = "ACTION_CANCEL_WORK";
private static final String ACTION_NOTIFY = "ACTION_NOTIFY";
private static final String ACTION_START_FOREGROUND = "ACTION_START_FOREGROUND";
private static final String ACTION_STOP_FOREGROUND = "ACTION_STOP_FOREGROUND";
private static final String KEY_FOREGROUND_SERVICE_TYPE = "KEY_FOREGROUND_SERVICE_TYPE";
private static final String KEY_GENERATION = "KEY_GENERATION";
private static final String KEY_NOTIFICATION = "KEY_NOTIFICATION";
private static final String KEY_NOTIFICATION_ID = "KEY_NOTIFICATION_ID";
private static final String KEY_WORKSPEC_ID = "KEY_WORKSPEC_ID";
static final String TAG = Logger.tagWithPrefix("SystemFgDispatcher");
@Nullable
private Callback mCallback;
final WorkConstraintsTracker mConstraintsTracker;
private Context mContext;
WorkGenerationalId mCurrentForegroundId;
final Map<WorkGenerationalId, ForegroundInfo> mForegroundInfoById;
final Object mLock;
private final TaskExecutor mTaskExecutor;
final Map<WorkGenerationalId, Job> mTrackedWorkSpecs;
private WorkManagerImpl mWorkManagerImpl;
final Map<WorkGenerationalId, WorkSpec> mWorkSpecById;
public interface Callback {
@MainThread
void cancelNotification(int i);
@MainThread
void notify(int i, @NonNull Notification notification);
@MainThread
void startForeground(int i, int i2, @NonNull Notification notification);
@MainThread
void stop();
}
public SystemForegroundDispatcher(@NonNull Context context) {
this.mContext = context;
this.mLock = new Object();
WorkManagerImpl workManagerImpl = WorkManagerImpl.getInstance(context);
this.mWorkManagerImpl = workManagerImpl;
this.mTaskExecutor = workManagerImpl.getWorkTaskExecutor();
this.mCurrentForegroundId = null;
this.mForegroundInfoById = new LinkedHashMap();
this.mTrackedWorkSpecs = new HashMap();
this.mWorkSpecById = new HashMap();
this.mConstraintsTracker = new WorkConstraintsTracker(this.mWorkManagerImpl.getTrackers());
this.mWorkManagerImpl.getProcessor().addExecutionListener(this);
}
@VisibleForTesting
public SystemForegroundDispatcher(@NonNull Context context, @NonNull WorkManagerImpl workManagerImpl, @NonNull WorkConstraintsTracker workConstraintsTracker) {
this.mContext = context;
this.mLock = new Object();
this.mWorkManagerImpl = workManagerImpl;
this.mTaskExecutor = workManagerImpl.getWorkTaskExecutor();
this.mCurrentForegroundId = null;
this.mForegroundInfoById = new LinkedHashMap();
this.mTrackedWorkSpecs = new HashMap();
this.mWorkSpecById = new HashMap();
this.mConstraintsTracker = workConstraintsTracker;
this.mWorkManagerImpl.getProcessor().addExecutionListener(this);
}
@Override // androidx.work.impl.ExecutionListener
@MainThread
public void onExecuted(@NonNull WorkGenerationalId workGenerationalId, boolean z) {
Map.Entry<WorkGenerationalId, ForegroundInfo> entry;
synchronized (this.mLock) {
try {
Job remove = this.mWorkSpecById.remove(workGenerationalId) != null ? this.mTrackedWorkSpecs.remove(workGenerationalId) : null;
if (remove != null) {
remove.cancel(null);
}
} catch (Throwable th) {
throw th;
}
}
ForegroundInfo remove2 = this.mForegroundInfoById.remove(workGenerationalId);
if (workGenerationalId.equals(this.mCurrentForegroundId)) {
if (this.mForegroundInfoById.size() > 0) {
Iterator<Map.Entry<WorkGenerationalId, ForegroundInfo>> it = this.mForegroundInfoById.entrySet().iterator();
Map.Entry<WorkGenerationalId, ForegroundInfo> next = it.next();
while (true) {
entry = next;
if (!it.hasNext()) {
break;
} else {
next = it.next();
}
}
this.mCurrentForegroundId = entry.getKey();
if (this.mCallback != null) {
ForegroundInfo value = entry.getValue();
this.mCallback.startForeground(value.getNotificationId(), value.getForegroundServiceType(), value.getNotification());
this.mCallback.cancelNotification(value.getNotificationId());
}
} else {
this.mCurrentForegroundId = null;
}
}
Callback callback = this.mCallback;
if (remove2 == null || callback == null) {
return;
}
Logger.get().debug(TAG, "Removing Notification (id: " + remove2.getNotificationId() + ", workSpecId: " + workGenerationalId + ", notificationType: " + remove2.getForegroundServiceType());
callback.cancelNotification(remove2.getNotificationId());
}
@MainThread
public void setCallback(@NonNull Callback callback) {
if (this.mCallback != null) {
Logger.get().error(TAG, "A callback already exists.");
} else {
this.mCallback = callback;
}
}
@MainThread
public void onStartCommand(@NonNull Intent intent) {
String action = intent.getAction();
if (ACTION_START_FOREGROUND.equals(action)) {
handleStartForeground(intent);
handleNotify(intent);
} else if (ACTION_NOTIFY.equals(action)) {
handleNotify(intent);
} else if (ACTION_CANCEL_WORK.equals(action)) {
handleCancelWork(intent);
} else if (ACTION_STOP_FOREGROUND.equals(action)) {
handleStop(intent);
}
}
@MainThread
public void onDestroy() {
this.mCallback = null;
synchronized (this.mLock) {
try {
Iterator<Job> it = this.mTrackedWorkSpecs.values().iterator();
while (it.hasNext()) {
it.next().cancel(null);
}
} catch (Throwable th) {
throw th;
}
}
this.mWorkManagerImpl.getProcessor().removeExecutionListener(this);
}
@MainThread
public void onTimeout(int i, int i2) {
Logger.get().info(TAG, "Foreground service timed out, FGS type: " + i2);
for (Map.Entry<WorkGenerationalId, ForegroundInfo> entry : this.mForegroundInfoById.entrySet()) {
if (entry.getValue().getForegroundServiceType() == i2) {
this.mWorkManagerImpl.stopForegroundWork(entry.getKey(), WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT);
}
}
Callback callback = this.mCallback;
if (callback != null) {
callback.stop();
}
}
@MainThread
private void handleStartForeground(@NonNull Intent intent) {
Logger.get().info(TAG, "Started foreground service " + intent);
final String stringExtra = intent.getStringExtra(KEY_WORKSPEC_ID);
this.mTaskExecutor.executeOnTaskThread(new Runnable() { // from class: androidx.work.impl.foreground.SystemForegroundDispatcher.1
@Override // java.lang.Runnable
public void run() {
WorkSpec runningWorkSpec = SystemForegroundDispatcher.this.mWorkManagerImpl.getProcessor().getRunningWorkSpec(stringExtra);
if (runningWorkSpec == null || !runningWorkSpec.hasConstraints()) {
return;
}
synchronized (SystemForegroundDispatcher.this.mLock) {
SystemForegroundDispatcher.this.mWorkSpecById.put(WorkSpecKt.generationalId(runningWorkSpec), runningWorkSpec);
SystemForegroundDispatcher systemForegroundDispatcher = SystemForegroundDispatcher.this;
SystemForegroundDispatcher.this.mTrackedWorkSpecs.put(WorkSpecKt.generationalId(runningWorkSpec), WorkConstraintsTrackerKt.listen(systemForegroundDispatcher.mConstraintsTracker, runningWorkSpec, systemForegroundDispatcher.mTaskExecutor.getTaskCoroutineDispatcher(), SystemForegroundDispatcher.this));
}
}
});
}
@MainThread
private void handleNotify(@NonNull Intent intent) {
if (this.mCallback == null) {
throw new IllegalStateException("handleNotify was called on the destroyed dispatcher");
}
int i = 0;
int intExtra = intent.getIntExtra(KEY_NOTIFICATION_ID, 0);
int intExtra2 = intent.getIntExtra(KEY_FOREGROUND_SERVICE_TYPE, 0);
String stringExtra = intent.getStringExtra(KEY_WORKSPEC_ID);
WorkGenerationalId workGenerationalId = new WorkGenerationalId(stringExtra, intent.getIntExtra(KEY_GENERATION, 0));
Notification notification = (Notification) intent.getParcelableExtra(KEY_NOTIFICATION);
Logger.get().debug(TAG, "Notifying with (id:" + intExtra + ", workSpecId: " + stringExtra + ", notificationType :" + intExtra2 + ")");
if (notification == null) {
throw new IllegalArgumentException("Notification passed in the intent was null.");
}
ForegroundInfo foregroundInfo = new ForegroundInfo(intExtra, notification, intExtra2);
this.mForegroundInfoById.put(workGenerationalId, foregroundInfo);
ForegroundInfo foregroundInfo2 = this.mForegroundInfoById.get(this.mCurrentForegroundId);
if (foregroundInfo2 == null) {
this.mCurrentForegroundId = workGenerationalId;
} else {
this.mCallback.notify(intExtra, notification);
if (Build.VERSION.SDK_INT >= 29) {
Iterator<Map.Entry<WorkGenerationalId, ForegroundInfo>> it = this.mForegroundInfoById.entrySet().iterator();
while (it.hasNext()) {
i |= it.next().getValue().getForegroundServiceType();
}
foregroundInfo = new ForegroundInfo(foregroundInfo2.getNotificationId(), foregroundInfo2.getNotification(), i);
} else {
foregroundInfo = foregroundInfo2;
}
}
this.mCallback.startForeground(foregroundInfo.getNotificationId(), foregroundInfo.getForegroundServiceType(), foregroundInfo.getNotification());
}
@MainThread
public void handleStop(@NonNull Intent intent) {
Logger.get().info(TAG, "Stopping foreground service");
Callback callback = this.mCallback;
if (callback != null) {
callback.stop();
}
}
@MainThread
private void handleCancelWork(@NonNull Intent intent) {
Logger.get().info(TAG, "Stopping foreground work for " + intent);
String stringExtra = intent.getStringExtra(KEY_WORKSPEC_ID);
if (stringExtra == null || TextUtils.isEmpty(stringExtra)) {
return;
}
this.mWorkManagerImpl.cancelWorkById(UUID.fromString(stringExtra));
}
@Override // androidx.work.impl.constraints.OnConstraintsStateChangedListener
public void onConstraintsStateChanged(@NonNull WorkSpec workSpec, @NonNull ConstraintsState constraintsState) {
if (constraintsState instanceof ConstraintsState.ConstraintsNotMet) {
String str = workSpec.id;
Logger.get().debug(TAG, "Constraints unmet for WorkSpec " + str);
this.mWorkManagerImpl.stopForegroundWork(WorkSpecKt.generationalId(workSpec), ((ConstraintsState.ConstraintsNotMet) constraintsState).getReason());
}
}
@NonNull
public static Intent createStartForegroundIntent(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId, @NonNull ForegroundInfo foregroundInfo) {
Intent intent = new Intent(context, (Class<?>) SystemForegroundService.class);
intent.setAction(ACTION_START_FOREGROUND);
intent.putExtra(KEY_WORKSPEC_ID, workGenerationalId.getWorkSpecId());
intent.putExtra(KEY_GENERATION, workGenerationalId.getGeneration());
intent.putExtra(KEY_NOTIFICATION_ID, foregroundInfo.getNotificationId());
intent.putExtra(KEY_FOREGROUND_SERVICE_TYPE, foregroundInfo.getForegroundServiceType());
intent.putExtra(KEY_NOTIFICATION, foregroundInfo.getNotification());
return intent;
}
@NonNull
public static Intent createCancelWorkIntent(@NonNull Context context, @NonNull String str) {
Intent intent = new Intent(context, (Class<?>) SystemForegroundService.class);
intent.setAction(ACTION_CANCEL_WORK);
intent.setData(Uri.parse("workspec://" + str));
intent.putExtra(KEY_WORKSPEC_ID, str);
return intent;
}
@NonNull
public static Intent createNotifyIntent(@NonNull Context context, @NonNull WorkGenerationalId workGenerationalId, @NonNull ForegroundInfo foregroundInfo) {
Intent intent = new Intent(context, (Class<?>) SystemForegroundService.class);
intent.setAction(ACTION_NOTIFY);
intent.putExtra(KEY_NOTIFICATION_ID, foregroundInfo.getNotificationId());
intent.putExtra(KEY_FOREGROUND_SERVICE_TYPE, foregroundInfo.getForegroundServiceType());
intent.putExtra(KEY_NOTIFICATION, foregroundInfo.getNotification());
intent.putExtra(KEY_WORKSPEC_ID, workGenerationalId.getWorkSpecId());
intent.putExtra(KEY_GENERATION, workGenerationalId.getGeneration());
return intent;
}
@NonNull
public static Intent createStopForegroundIntent(@NonNull Context context) {
Intent intent = new Intent(context, (Class<?>) SystemForegroundService.class);
intent.setAction(ACTION_STOP_FOREGROUND);
return intent;
}
}

View File

@@ -0,0 +1,145 @@
package androidx.work.impl.foreground;
import android.app.ForegroundServiceStartNotAllowedException;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresPermission;
import androidx.annotation.RestrictTo;
import androidx.lifecycle.LifecycleService;
import androidx.work.Logger;
import androidx.work.impl.foreground.SystemForegroundDispatcher;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class SystemForegroundService extends LifecycleService implements SystemForegroundDispatcher.Callback {
private static final String TAG = Logger.tagWithPrefix("SystemFgService");
@Nullable
private static SystemForegroundService sForegroundService = null;
SystemForegroundDispatcher mDispatcher;
private boolean mIsShutdown;
NotificationManager mNotificationManager;
@Nullable
public static SystemForegroundService getInstance() {
return sForegroundService;
}
@Override // androidx.lifecycle.LifecycleService, android.app.Service
public void onCreate() {
super.onCreate();
sForegroundService = this;
initializeDispatcher();
}
@Override // androidx.lifecycle.LifecycleService, android.app.Service
public int onStartCommand(@Nullable Intent intent, int i, int i2) {
super.onStartCommand(intent, i, i2);
if (this.mIsShutdown) {
Logger.get().info(TAG, "Re-initializing SystemForegroundService after a request to shut-down.");
this.mDispatcher.onDestroy();
initializeDispatcher();
this.mIsShutdown = false;
}
if (intent == null) {
return 3;
}
this.mDispatcher.onStartCommand(intent);
return 3;
}
@Override // androidx.lifecycle.LifecycleService, android.app.Service
public void onDestroy() {
super.onDestroy();
this.mDispatcher.onDestroy();
}
@MainThread
private void initializeDispatcher() {
this.mNotificationManager = (NotificationManager) getApplicationContext().getSystemService("notification");
SystemForegroundDispatcher systemForegroundDispatcher = new SystemForegroundDispatcher(getApplicationContext());
this.mDispatcher = systemForegroundDispatcher;
systemForegroundDispatcher.setCallback(this);
}
@Override // androidx.work.impl.foreground.SystemForegroundDispatcher.Callback
@MainThread
public void stop() {
this.mIsShutdown = true;
Logger.get().debug(TAG, "Shutting down.");
stopForeground(true);
sForegroundService = null;
stopSelf();
}
@Override // android.app.Service
public void onTimeout(int i) {
if (Build.VERSION.SDK_INT >= 35) {
return;
}
this.mDispatcher.onTimeout(i, 2048);
}
public void onTimeout(int i, int i2) {
this.mDispatcher.onTimeout(i, i2);
}
@Override // androidx.work.impl.foreground.SystemForegroundDispatcher.Callback
@MainThread
public void startForeground(int i, int i2, @NonNull Notification notification) {
int i3 = Build.VERSION.SDK_INT;
if (i3 >= 31) {
Api31Impl.startForeground(this, i, notification, i2);
} else if (i3 >= 29) {
Api29Impl.startForeground(this, i, notification, i2);
} else {
startForeground(i, notification);
}
}
@Override // androidx.work.impl.foreground.SystemForegroundDispatcher.Callback
@RequiresPermission("android.permission.POST_NOTIFICATIONS")
@MainThread
public void notify(int i, @NonNull Notification notification) {
this.mNotificationManager.notify(i, notification);
}
@Override // androidx.work.impl.foreground.SystemForegroundDispatcher.Callback
@MainThread
public void cancelNotification(int i) {
this.mNotificationManager.cancel(i);
}
@RequiresApi(29)
public static class Api29Impl {
private Api29Impl() {
}
public static void startForeground(Service service, int i, Notification notification, int i2) {
service.startForeground(i, notification, i2);
}
}
@RequiresApi(31)
public static class Api31Impl {
private Api31Impl() {
}
public static void startForeground(Service service, int i, Notification notification, int i2) {
try {
service.startForeground(i, notification, i2);
} catch (ForegroundServiceStartNotAllowedException e) {
Logger.get().warning(SystemForegroundService.TAG, "Unable to start foreground service", e);
} catch (SecurityException e2) {
Logger.get().warning(SystemForegroundService.TAG, "Unable to start foreground service", e2);
}
}
}
}