Make TouchInteractionService direct boot aware

- Add directBootAware="true" to TouchInteractionService manifest component
- Add DeviceLockedInputConsumer which just sends a home intent on touch down

Test:
- Reboot
- Swipe up anywhere to get to bouncer (pin/password/pattern)
- Click "Emergency" to launch dialer while still in direct boot
- Swipe up from the nav bar to exit/bring up bouncer

Test:
- Lock screen
- Double press power to launch camera
- Swipe up from nav bar to exit/bring up bouncer

Bug: 125364936
Change-Id: I7a4cd2dc3a635daf4bb9a643a1e5251ca4e91e33
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 74fa447..7bb6071 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -19,12 +19,14 @@
 import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
 import static com.android.launcher3.util.SecureSettingsObserver.newNotificationSettingsObserver;
 
+import android.app.KeyguardManager;
 import android.content.ComponentName;
 import android.content.ContentProviderClient;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Handler;
+import android.os.Process;
 import android.util.Log;
 
 import com.android.launcher3.compat.LauncherAppsCompat;
@@ -66,6 +68,9 @@
     }
 
     private LauncherAppState(Context context) {
+        if (!UserManagerCompat.getInstance(context).isUserUnlocked(Process.myUserHandle())) {
+            throw new RuntimeException("LauncherAppState should not start in direct boot mode");
+        }
         if (getLocalProvider(context) == null) {
             throw new RuntimeException(
                     "Initializing LauncherAppState in the absence of LauncherProvider");
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index e5ab2d1..832e9c9 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -16,8 +16,12 @@
 
 package com.android.launcher3;
 
+import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
+import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
+
 import android.app.ActivityManager;
 import android.app.WallpaperManager;
+import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -67,9 +71,6 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
-import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
-
 /**
  * Various utilities shared amongst the Launcher's classes.
  */
@@ -590,4 +591,10 @@
         outRect.set(viewLocationLeft, viewLocationTop, viewLocationLeft + rect.width(),
                 viewLocationTop + rect.height());
     }
+
+    public static void unregisterReceiverSafely(Context context, BroadcastReceiver receiver) {
+        try {
+            context.unregisterReceiver(receiver);
+        } catch (IllegalArgumentException e) { }
+    }
 }