Suppress camera launch gesture until setup is complete
Bug: 22792563

Change-Id: I779d15894375ebd2639f41bc5f60317030f927f4
diff --git a/services/core/java/com/android/server/GestureLauncherService.java b/services/core/java/com/android/server/GestureLauncherService.java
index d7b0765..e17ff5c 100644
--- a/services/core/java/com/android/server/GestureLauncherService.java
+++ b/services/core/java/com/android/server/GestureLauncherService.java
@@ -32,6 +32,7 @@
 import android.os.PowerManager.WakeLock;
 import android.os.SystemProperties;
 import android.provider.MediaStore;
+import android.provider.Settings;
 import android.util.Slog;
 
 /**
@@ -152,13 +153,25 @@
 
         private void handleCameraLaunchGesture() {
             if (DBG) Slog.d(TAG, "Received a camera launch event.");
+            boolean userSetupComplete = Settings.Secure.getInt(mContext.getContentResolver(),
+                    Settings.Secure.USER_SETUP_COMPLETE, 0) != 0;
+            if (!userSetupComplete) {
+                if (DBG) Slog.d(TAG, String.format(
+                        "userSetupComplete = %s, ignoring camera launch gesture.",
+                        userSetupComplete));
+                return;
+            }
+            if (DBG) Slog.d(TAG, String.format(
+                    "userSetupComplete = %s, performing camera launch gesture.",
+                    userSetupComplete));
             boolean locked = mKeyGuard != null && mKeyGuard.inKeyguardRestrictedInputMode();
             String action = locked
                     ? MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE
                     : MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA;
             Intent intent = new Intent(action);
             PackageManager pm = mContext.getPackageManager();
-            ResolveInfo componentInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
+            ResolveInfo componentInfo = pm.resolveActivity(intent,
+                PackageManager.MATCH_DEFAULT_ONLY);
             if (componentInfo == null) {
                 if (DBG) Slog.d(TAG, "Couldn't find an app to process the camera intent.");
                 return;
@@ -167,7 +180,6 @@
             if (mVibrator != null && mVibrator.hasVibrator()) {
                 mVibrator.vibrate(1000L);
             }
-
             // Turn on the screen before the camera launches.
             mWakeLock.acquire(500L);
             intent.setComponent(new ComponentName(componentInfo.activityInfo.packageName,