7th attempt to fix the privileged options problem
This commit is contained in:
parent
b088223177
commit
f1b063c84b
1 changed files with 15 additions and 9 deletions
|
|
@ -21,6 +21,8 @@ import io.github.sspanak.tt9.util.Logger;
|
||||||
import io.github.sspanak.tt9.util.SystemSettings;
|
import io.github.sspanak.tt9.util.SystemSettings;
|
||||||
|
|
||||||
public class TraditionalT9 extends MainViewHandler {
|
public class TraditionalT9 extends MainViewHandler {
|
||||||
|
private static final String LOG_TAG = "MAIN";
|
||||||
|
|
||||||
@NonNull private final Handler backgroundTasks = new Handler(Looper.getMainLooper());
|
@NonNull private final Handler backgroundTasks = new Handler(Looper.getMainLooper());
|
||||||
@NonNull private final Handler zombieDetector = new Handler(Looper.getMainLooper());
|
@NonNull private final Handler zombieDetector = new Handler(Looper.getMainLooper());
|
||||||
private boolean isDead = false;
|
private boolean isDead = false;
|
||||||
|
|
@ -71,7 +73,7 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
@Override
|
@Override
|
||||||
public void onStartInput(EditorInfo inputField, boolean restarting) {
|
public void onStartInput(EditorInfo inputField, boolean restarting) {
|
||||||
Logger.i(
|
Logger.i(
|
||||||
"KeyPadHandler",
|
LOG_TAG,
|
||||||
"===> Start Up; packageName: " + inputField.packageName + " inputType: " + inputField.inputType + " actionId: " + inputField.actionId + " imeOptions: " + inputField.imeOptions + " privateImeOptions: " + inputField.privateImeOptions + " extras: " + inputField.extras
|
"===> Start Up; packageName: " + inputField.packageName + " inputType: " + inputField.inputType + " actionId: " + inputField.actionId + " imeOptions: " + inputField.imeOptions + " privateImeOptions: " + inputField.privateImeOptions + " extras: " + inputField.extras
|
||||||
);
|
);
|
||||||
onStart(getCurrentInputConnection(), inputField);
|
onStart(getCurrentInputConnection(), inputField);
|
||||||
|
|
@ -117,6 +119,7 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
@Override
|
@Override
|
||||||
protected void onInit() {
|
protected void onInit() {
|
||||||
isDead = false;
|
isDead = false;
|
||||||
|
zombieChecks = 0;
|
||||||
settings.setDemoMode(false);
|
settings.setDemoMode(false);
|
||||||
Logger.setLevel(settings.getLogLevel());
|
Logger.setLevel(settings.getLogLevel());
|
||||||
LanguageCollection.init(this);
|
LanguageCollection.init(this);
|
||||||
|
|
@ -127,8 +130,8 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onStart(InputConnection connection, EditorInfo field) {
|
protected boolean onStart(InputConnection connection, EditorInfo field) {
|
||||||
if (!SystemSettings.isTT9Selected(this) && !isDead) {
|
if (zombieChecks == 0 && !SystemSettings.isTT9Selected(this)) {
|
||||||
zombieDetector.postDelayed(this::startZombieCheck, SettingsStore.ZOMBIE_CHECK_INTERVAL);
|
startZombieCheck();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,20 +186,20 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Android 11 the IME is sometimes not killed when the user switches to a different one.
|
* On Android 11+ the IME is sometimes not killed when the user switches to a different one.
|
||||||
* Here we attempt to detect if we are disabled, then hide and kill ourselves.
|
* Here we attempt to detect if we are disabled, then hide and kill ourselves.
|
||||||
*/
|
*/
|
||||||
protected void startZombieCheck() {
|
protected void startZombieCheck() {
|
||||||
if (!SystemSettings.isTT9Selected(this)) {
|
if (zombieChecks > 0 && !SystemSettings.isTT9Selected(this)) {
|
||||||
zombieChecks = 0;
|
zombieChecks = 0;
|
||||||
onZombie();
|
onZombie();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++zombieChecks < SettingsStore.ZOMBIE_CHECK_MAX) {
|
if (!isDead && ++zombieChecks < SettingsStore.ZOMBIE_CHECK_MAX) {
|
||||||
zombieDetector.postDelayed(this::startZombieCheck, SettingsStore.ZOMBIE_CHECK_INTERVAL);
|
zombieDetector.postDelayed(this::startZombieCheck, SettingsStore.ZOMBIE_CHECK_INTERVAL);
|
||||||
} else {
|
} else {
|
||||||
Logger.d("startZombieCheck", "Not a zombie after " + zombieChecks + " checks");
|
Logger.d(LOG_TAG, "Not a zombie after " + zombieChecks + " checks");
|
||||||
zombieChecks = 0;
|
zombieChecks = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -204,11 +207,11 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
|
|
||||||
protected void onZombie() {
|
protected void onZombie() {
|
||||||
if (isDead) {
|
if (isDead) {
|
||||||
Logger.w("onZombie", "===> Already dead. Nothing to do.");
|
Logger.w(LOG_TAG, "===> Already dead. Nothing to do.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.w("onZombie", "===> Killing self");
|
Logger.w(LOG_TAG, "===> Killing self");
|
||||||
requestHideSelf(0);
|
requestHideSelf(0);
|
||||||
cleanUp();
|
cleanUp();
|
||||||
stopSelf();
|
stopSelf();
|
||||||
|
|
@ -220,7 +223,9 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
super.cleanUp();
|
super.cleanUp();
|
||||||
setInputField(null, null);
|
setInputField(null, null);
|
||||||
backgroundTasks.removeCallbacksAndMessages(null);
|
backgroundTasks.removeCallbacksAndMessages(null);
|
||||||
|
zombieChecks = SettingsStore.ZOMBIE_CHECK_MAX;
|
||||||
zombieDetector.removeCallbacksAndMessages(null);
|
zombieDetector.removeCallbacksAndMessages(null);
|
||||||
|
Logger.d(LOG_TAG, "===> Final cleanup completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -229,6 +234,7 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
cleanUp();
|
cleanUp();
|
||||||
isDead = true;
|
isDead = true;
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
Logger.d(LOG_TAG, "===> Shutdown completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue