aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java')
-rw-r--r--java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java64
1 files changed, 15 insertions, 49 deletions
diff --git a/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java b/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java
index 050d8d26f..9585736e7 100644
--- a/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java
+++ b/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java
@@ -16,85 +16,51 @@
package com.android.inputmethod.latin.setup;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
-import android.os.Process;
import android.preference.PreferenceManager;
import android.util.Log;
-import android.view.inputmethod.InputMethodManager;
import com.android.inputmethod.compat.IntentCompatUtils;
import com.android.inputmethod.latin.settings.Settings;
/**
- * This class detects the {@link Intent#ACTION_MY_PACKAGE_REPLACED} broadcast intent when this IME
- * package has been replaced by a newer version of the same package. This class also detects
+ * This class handles the {@link Intent#ACTION_MY_PACKAGE_REPLACED} broadcast intent when this IME
+ * package has been replaced by a newer version of the same package. This class also handles
* {@link Intent#ACTION_BOOT_COMPLETED} and {@link Intent#ACTION_USER_INITIALIZE} broadcast intent.
*
* If this IME has already been installed in the system image and a new version of this IME has
- * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver and it
- * will hide the setup wizard's icon.
+ * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received to this class to hide the
+ * setup wizard's icon.
*
* If this IME has already been installed in the data partition and a new version of this IME has
- * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver but it
+ * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is forwarded to this class but it
* will not hide the setup wizard's icon, and the icon will appear on the launcher.
*
* If this IME hasn't been installed yet and has been newly installed, no
* {@link Intent#ACTION_MY_PACKAGE_REPLACED} will be sent and the setup wizard's icon will appear
* on the launcher.
*
- * When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is received by this
- * receiver and it checks whether the setup wizard's icon should be appeared or not on the launcher
+ * When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is forwarded to this class
+ * to check whether the setup wizard's icon should be appeared or not on the launcher
* depending on which partition this IME is installed.
*
- * When a multiuser account has been created, {@link Intent#ACTION_USER_INITIALIZE} is received
- * by this receiver and it checks the whether the setup wizard's icon should be appeared or not on
- * the launcher depending on which partition this IME is installed.
+ * When a multiuser account has been created, {@link Intent#ACTION_USER_INITIALIZE} is forwarded to
+ * this class to check whether the setup wizard's icon should be appeared or not on the launcher
+ * depending on which partition this IME is installed.
*/
-public final class LauncherIconVisibilityManager extends BroadcastReceiver {
+public final class LauncherIconVisibilityManager {
private static final String TAG = LauncherIconVisibilityManager.class.getSimpleName();
- @Override
- public void onReceive(final Context context, final Intent intent) {
- if (shouldHandleThisIntent(intent, context)) {
+ public static void onReceiveGlobalIntent(final String action, final Context context) {
+ if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(action) ||
+ Intent.ACTION_BOOT_COMPLETED.equals(action) ||
+ IntentCompatUtils.is_ACTION_USER_INITIALIZE(action)) {
updateSetupWizardIconVisibility(context);
}
-
- // The process that hosts this broadcast receiver is invoked and remains alive even after
- // 1) the package has been re-installed, 2) the device has just booted,
- // 3) a new user has been created.
- // There is no good reason to keep the process alive if this IME isn't a current IME.
- final InputMethodManager imm =
- (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
- // Called to check whether this IME has been triggered by the current user or not
- final boolean isInputMethodManagerValidForUserOfThisProcess =
- !imm.getInputMethodList().isEmpty();
- final boolean isCurrentImeOfCurrentUser = isInputMethodManagerValidForUserOfThisProcess
- && SetupActivity.isThisImeCurrent(context, imm);
- if (!isCurrentImeOfCurrentUser) {
- final int myPid = Process.myPid();
- Log.i(TAG, "Killing my process: pid=" + myPid);
- Process.killProcess(myPid);
- }
- }
-
- private static boolean shouldHandleThisIntent(final Intent intent, final Context context) {
- final String action = intent.getAction();
- if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(action)) {
- Log.i(TAG, "Package has been replaced: " + context.getPackageName());
- return true;
- } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
- Log.i(TAG, "Boot has been completed");
- return true;
- } else if (IntentCompatUtils.is_ACTION_USER_INITIALIZE(action)) {
- Log.i(TAG, "User initialize");
- return true;
- }
- return false;
}
public static void updateSetupWizardIconVisibility(final Context context) {