aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java49
1 files changed, 34 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java
index 123ab208c..2a69d3650 100644
--- a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java
+++ b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java
@@ -17,16 +17,20 @@
package com.android.inputmethod.latin;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.os.Process;
import android.util.Log;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
-import com.android.inputmethod.compat.IntentCompatUtils;
+import com.android.inputmethod.dictionarypack.CommonPreferences;
+import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
import com.android.inputmethod.keyboard.KeyboardLayoutSet;
-import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager;
+import com.android.inputmethod.latin.setup.SetupActivity;
import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils;
/**
@@ -50,10 +54,6 @@ import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils;
* receiver and it checks 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 the system locale has been changed, {@link Intent#ACTION_LOCALE_CHANGED} is received by
* this receiver and the {@link KeyboardLayoutSet}'s cache is cleared.
*/
@@ -69,26 +69,25 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver {
// subtypes when the package is replaced.
RichInputMethodManager.init(context);
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
- final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes(context);
+ final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes();
richImm.setAdditionalInputMethodSubtypes(additionalSubtypes);
- LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context);
+ toggleAppIcon(context);
+ downloadLatestDictionaries(context);
} else if (Intent.ACTION_BOOT_COMPLETED.equals(intentAction)) {
Log.i(TAG, "Boot has been completed");
- LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context);
- } else if (IntentCompatUtils.is_ACTION_USER_INITIALIZE(intentAction)) {
- Log.i(TAG, "User initialize");
- LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context);
+ toggleAppIcon(context);
} else if (Intent.ACTION_LOCALE_CHANGED.equals(intentAction)) {
Log.i(TAG, "System locale changed");
KeyboardLayoutSet.onSystemLocaleChanged();
}
// 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,
+ // 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);
+ 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();
@@ -100,4 +99,24 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver {
Process.killProcess(myPid);
}
}
+
+ private void downloadLatestDictionaries(Context context) {
+ final Intent updateIntent = new Intent(
+ DictionaryPackConstants.INIT_AND_UPDATE_NOW_INTENT_ACTION);
+ context.sendBroadcast(updateIntent);
+ }
+
+ private static void toggleAppIcon(final Context context) {
+ final int appInfoFlags = context.getApplicationInfo().flags;
+ final boolean isSystemApp = (appInfoFlags & ApplicationInfo.FLAG_SYSTEM) > 0;
+ if (Log.isLoggable(TAG, Log.INFO)) {
+ Log.i(TAG, "toggleAppIcon() : FLAG_SYSTEM = " + isSystemApp);
+ }
+ context.getPackageManager().setComponentEnabledSetting(
+ new ComponentName(context, SetupActivity.class),
+ isSystemApp
+ ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
+ : PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
+ PackageManager.DONT_KILL_APP);
+ }
}