app: prevent app store version from auto-starting app by default

Change-Id: I2a1a52ec7ff2f5c76b34438c250b8e9d019f846a
diff --git a/src/RingWizardLinkAccountVC.mm b/src/RingWizardLinkAccountVC.mm
index f932de7..07cf824 100644
--- a/src/RingWizardLinkAccountVC.mm
+++ b/src/RingWizardLinkAccountVC.mm
@@ -38,6 +38,7 @@
 
 #import "Constants.h"
 #import "views/NSImage+Extensions.h"
+#import "utils.h"
 
 @interface RingWizardLinkAccountVC ()
 
@@ -165,12 +166,14 @@
  */
 - (void)registerDefaultPreferences
 {
-    // enable AutoStartup
-    LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
-    if (loginItemsRef == nil) return;
-    CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
-    LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL);
-    if (itemRef) CFRelease(itemRef);
+    if (!appSandboxed()) {
+        // enable AutoStartup
+        LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
+        if (loginItemsRef == nil) return;
+        CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
+        LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL);
+        if (itemRef) CFRelease(itemRef);
+    }
 
     // enable Notifications
     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::Notifications];
diff --git a/src/RingWizardNewAccountVC.mm b/src/RingWizardNewAccountVC.mm
index 27f153f..3db5045 100644
--- a/src/RingWizardNewAccountVC.mm
+++ b/src/RingWizardNewAccountVC.mm
@@ -42,6 +42,7 @@
 #import "Constants.h"
 #import "views/NSImage+Extensions.h"
 #import "views/NSColor+RingTheme.h"
+#import "utils.h"
 
 @interface RingWizardNewAccountVC ()
 @end
@@ -254,12 +255,14 @@
  */
 - (void)registerDefaultPreferences
 {
-    // enable AutoStartup
-    LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
-    if (loginItemsRef == nil) return;
-    CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
-    LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL);
-    if (itemRef) CFRelease(itemRef);
+    if (!appSandboxed()) {
+        // enable AutoStartup
+        LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
+        if (loginItemsRef == nil) return;
+        CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
+        LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL);
+        if (itemRef) CFRelease(itemRef);
+    }
 
     // enable Notifications
     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::Notifications];