Don't need to wrap another layer of context

This commit is contained in:
topjohnwu 2019-10-26 15:37:12 -04:00
parent 588b3d14a3
commit 626507093a
2 changed files with 24 additions and 24 deletions

View File

@ -6,7 +6,6 @@ import androidx.annotation.NonNull;
import androidx.work.Worker; import androidx.work.Worker;
import androidx.work.WorkerParameters; import androidx.work.WorkerParameters;
import com.topjohnwu.magisk.HacksKt;
import com.topjohnwu.magisk.base.DelegateWorker; import com.topjohnwu.magisk.base.DelegateWorker;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
@ -19,7 +18,7 @@ public abstract class w<T extends DelegateWorker> extends Worker {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
w(@NonNull Context context, @NonNull WorkerParameters workerParams) { w(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(HacksKt.wrap(context, false), workerParams); super(context, workerParams);
try { try {
base = ((Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()) base = ((Class<T>) ((ParameterizedType) getClass().getGenericSuperclass())
.getActualTypeArguments()[0]).newInstance(); .getActualTypeArguments()[0]).newInstance();

View File

@ -165,12 +165,13 @@ private class JobSchedulerWrapper(private val base: JobScheduler) : JobScheduler
return base.getPendingJob(jobId) return base.getPendingJob(jobId)
} }
fun JobInfo.patch(): JobInfo { private fun JobInfo.patch(): JobInfo {
// We need to patch the component of JobInfo to access WorkManager SystemJobService // We need to patch the component of JobInfo to access WorkManager SystemJobService
val name = service.className val name = service.className
val component = ComponentName(service.packageName, Info.stub?.componentMap?.get(name) val component = ComponentName(
?: name) service.packageName,
Info.stub!!.componentMap[name] ?: name)
// Clone the JobInfo except component // Clone the JobInfo except component
val builder = JobInfo.Builder(id, component) val builder = JobInfo.Builder(id, component)