2020import android .text .TextUtils ;
2121import android .util .Log ;
2222
23- import com .flowcrypt .email .BuildConfig ;
2423import com .flowcrypt .email .api .email .FoldersManager ;
2524import com .flowcrypt .email .api .email .JavaEmailConstants ;
2625import com .flowcrypt .email .api .email .gmail .GmailConstants ;
@@ -85,8 +84,6 @@ public class EmailSyncService extends Service implements SyncListener {
8584 public static final int MESSAGE_GET_ACTIVE_ACCOUNT = 11 ;
8685 public static final int MESSAGE_SEND_MESSAGE_WITH_BACKUP = 12 ;
8786
88- public static final String EXTRA_KEY_GMAIL_ACCOUNT = BuildConfig .APPLICATION_ID
89- + ".EXTRA_KEY_GMAIL_ACCOUNT" ;
9087 private static final String TAG = EmailSyncService .class .getSimpleName ();
9188 /**
9289 * This {@link Messenger} is responsible for the receive intents from other client and
@@ -113,15 +110,10 @@ public EmailSyncService() {
113110 * This method can bu used to start {@link EmailSyncService}.
114111 *
115112 * @param context Interface to global information about an application environment.
116- * @param account The user {@link Account}
117113 */
118- public static void startEmailSyncService (Context context , Account account ) {
119- if (account != null ) {
120- Intent startEmailServiceIntent = new Intent (context , EmailSyncService .class );
121- startEmailServiceIntent .putExtra (EmailSyncService .EXTRA_KEY_GMAIL_ACCOUNT ,
122- account );
123- context .startService (startEmailServiceIntent );
124- } else throw new NullPointerException ("The account is null" );
114+ public static void startEmailSyncService (Context context ) {
115+ Intent startEmailServiceIntent = new Intent (context , EmailSyncService .class );
116+ context .startService (startEmailServiceIntent );
125117 }
126118
127119 @ Override
@@ -136,16 +128,13 @@ public void onCreate() {
136128
137129 @ Override
138130 public int onStartCommand (Intent intent , int flags , int startId ) {
139- Log .d (TAG , "onStartCommand |intent =" + intent + "|flags = " + flags + "|startId = " +
140- startId );
131+ Log .d (TAG , "onStartCommand |intent =" + intent + "|flags = " + flags + "|startId = " + startId );
141132 isServiceStarted = true ;
142- if (intent != null ) {
143- account = intent .getParcelableExtra (EXTRA_KEY_GMAIL_ACCOUNT );
144- if (account != null ) {
145- gmailSynsManager .beginSync (false );
146- } else {
147- //todo-denbond7 handle this error;
148- }
133+ this .account = new AccountDaoSource ().getActiveAccountInformation (this ).getAccount ();
134+ if (account != null ) {
135+ gmailSynsManager .beginSync (false );
136+ } else {
137+ //todo-denbond7 handle this error;
149138 }
150139
151140 return super .onStartCommand (intent , flags , startId );
@@ -184,7 +173,7 @@ public IBinder onBind(Intent intent) {
184173 account = accountDao .getAccount ();
185174
186175 if (account != null && !isServiceStarted ) {
187- EmailSyncService .startEmailSyncService (getContext (), account );
176+ EmailSyncService .startEmailSyncService (getContext ());
188177 }
189178 }
190179 } else {
0 commit comments