Consolidate stubs

This commit is contained in:
topjohnwu 2020-01-13 23:10:17 +08:00
parent 707d7b3342
commit dd50c19ba3
9 changed files with 55 additions and 95 deletions

View File

@ -1,5 +0,0 @@
package a
import com.topjohnwu.magisk.ui.MainActivity
class b : MainActivity()

View File

@ -1,7 +0,0 @@
package a;
import com.topjohnwu.magisk.core.SplashActivity;
public class c extends SplashActivity {
/* stub */
}

View File

@ -1,13 +0,0 @@
package a;
import com.topjohnwu.magisk.core.App;
public class e extends App {
public e() {
super();
}
public e(Object o) {
super(o);
}
}

View File

@ -1,7 +0,0 @@
package a;
import com.topjohnwu.magisk.legacy.flash.FlashActivity;
public class f extends FlashActivity {
/* stub */
}

View File

@ -1,7 +0,0 @@
package a;
import com.topjohnwu.magisk.core.GeneralReceiver;
public class h extends GeneralReceiver {
/* stub */
}

View File

@ -1,7 +0,0 @@
package a;
import com.topjohnwu.magisk.core.download.DownloadService;
public class j extends DownloadService {
/* stub */
}

View File

@ -1,7 +0,0 @@
package a;
import com.topjohnwu.magisk.legacy.surequest.SuRequestActivity;
public class m extends SuRequestActivity {
/* stub */
}

View File

@ -0,0 +1,55 @@
package a
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.topjohnwu.magisk.core.App
import com.topjohnwu.magisk.core.GeneralReceiver
import com.topjohnwu.magisk.core.SplashActivity
import com.topjohnwu.magisk.core.base.BaseWorkerWrapper
import com.topjohnwu.magisk.core.download.DownloadService
import com.topjohnwu.magisk.legacy.flash.FlashActivity
import com.topjohnwu.magisk.legacy.surequest.SuRequestActivity
import com.topjohnwu.magisk.ui.MainActivity
import java.lang.reflect.ParameterizedType
class b : MainActivity()
class c : SplashActivity()
class e : App {
constructor() : super()
constructor(o: Any) : super(o)
}
class f : FlashActivity()
class h : GeneralReceiver()
class j : DownloadService()
class m : SuRequestActivity()
/**
* Wrapper class to workaround Proguard rule :
* -keep class * extends Worker
* */
abstract class w<T : BaseWorkerWrapper>(
context: Context,
workerParams: WorkerParameters
) : Worker(context, workerParams) {
private var base: T? = null
override fun doWork() = base?.doWork() ?: Result.failure()
override fun onStopped() = base?.onStopped() ?: Unit
init {
try {
base = ((javaClass.genericSuperclass as ParameterizedType)
.actualTypeArguments[0] as Class<T>).newInstance()
base?.attachWorker(this)
} catch (e : java.lang.Exception) {}
}
}

View File

@ -1,42 +0,0 @@
package a;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import com.topjohnwu.magisk.core.base.BaseWorkerWrapper;
import java.lang.reflect.ParameterizedType;
public abstract class w<T extends BaseWorkerWrapper> 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();
base.attachWorker(this);
} catch (Exception ignored) {}
}
@NonNull
@Override
public Result doWork() {
if (base == null)
return Result.failure();
return base.doWork();
}
@Override
public void onStopped() {
if (base != null)
base.onStopped();
}
}