mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-25 11:05:34 +00:00
36 lines
960 B
Java
36 lines
960 B
Java
|
package a;
|
||
|
|
||
|
import android.content.Context;
|
||
|
|
||
|
import com.topjohnwu.magisk.services.DelegateWorker;
|
||
|
|
||
|
import java.lang.reflect.ParameterizedType;
|
||
|
|
||
|
import androidx.annotation.NonNull;
|
||
|
import androidx.work.Worker;
|
||
|
import androidx.work.WorkerParameters;
|
||
|
|
||
|
public class w<T extends DelegateWorker> extends Worker {
|
||
|
|
||
|
/* Wrapper class to workaround Proguard -keep class * extends Worker */
|
||
|
|
||
|
private T base;
|
||
|
|
||
|
@SuppressWarnings("unchecked")
|
||
|
w(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
||
|
super(context, workerParams);
|
||
|
try {
|
||
|
base = ((Class<T>) ((ParameterizedType) getClass().getGenericSuperclass())
|
||
|
.getActualTypeArguments()[0]).newInstance();
|
||
|
} catch (IllegalAccessException | InstantiationException ignored) {}
|
||
|
}
|
||
|
|
||
|
@NonNull
|
||
|
@Override
|
||
|
public Result doWork() {
|
||
|
if (base == null)
|
||
|
return Result.failure();
|
||
|
return base.doWork();
|
||
|
}
|
||
|
}
|