Remove all backwards compatibility nonsense

This also allows full obfuscation
This commit is contained in:
topjohnwu
2018-12-08 03:54:00 -05:00
parent a54eaf5371
commit c91f809eba
20 changed files with 188 additions and 717 deletions
@@ -3,10 +3,8 @@ package com.topjohnwu.magisk;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.net.LocalSocketAddress;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.FileObserver;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
@@ -43,48 +41,6 @@ public class SuRequestActivity extends BaseActivity {
private CountDownTimer timer;
private FingerprintHelper fingerprintHelper;
class SuConnectorV1 extends SuConnector {
SuConnectorV1(String name) throws IOException {
super(name);
}
@Override
public void connect(String name) throws IOException {
socket.connect(new LocalSocketAddress(name, LocalSocketAddress.Namespace.FILESYSTEM));
new FileObserver(name) {
@Override
public void onEvent(int fileEvent, String path) {
if (fileEvent == FileObserver.DELETE_SELF) {
finish();
}
}
}.startWatching();
}
@Override
public void onResponse() throws IOException {
out.write((policy.policy == Policy.ALLOW ? "socket:ALLOW" : "socket:DENY").getBytes());
}
}
class SuConnectorV2 extends SuConnector {
SuConnectorV2(String name) throws IOException {
super(name);
}
@Override
public void connect(String name) throws IOException {
socket.connect(new LocalSocketAddress(name, LocalSocketAddress.Namespace.ABSTRACT));
}
@Override
public void onResponse() throws IOException {
out.writeInt(policy.policy);
}
}
@Override
public int getDarkTheme() {
return R.style.SuRequest_Dark;
@@ -120,8 +76,12 @@ public class SuRequestActivity extends BaseActivity {
Intent intent = getIntent();
try {
String socketName = intent.getStringExtra("socket");
connector = intent.getIntExtra("version", 1) == 1 ?
new SuConnectorV1(socketName) : new SuConnectorV2(socketName);
connector = new SuConnector(socketName) {
@Override
protected void onResponse() throws IOException {
out.writeInt(policy.policy);
}
};
Bundle bundle = connector.readSocketInput();
int uid = Integer.parseInt(bundle.getString("uid"));
policy = mm.mDB.getPolicy(uid);