k-9/src/com/fsck/k9/service/RemoteControlReceiver.java

51 lines
1.8 KiB
Java
Raw Normal View History

package com.fsck.k9.service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.remotecontrol.K9RemoteControl;
import com.fsck.k9.Preferences;
import static com.fsck.k9.remotecontrol.K9RemoteControl.*;
public class RemoteControlReceiver extends CoreReceiver {
@Override
public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlReceiver.onReceive" + intent);
if (K9RemoteControl.K9_SET.equals(intent.getAction())) {
RemoteControlService.set(context, intent, tmpWakeLockId);
tmpWakeLockId = null;
} else if (K9RemoteControl.K9_REQUEST_ACCOUNTS.equals(intent.getAction())) {
try {
Preferences preferences = Preferences.getPreferences(context);
Account[] accounts = preferences.getAccounts();
String[] uuids = new String[accounts.length];
String[] descriptions = new String[accounts.length];
for (int i = 0; i < accounts.length; i++) {
Merge branch 'mail-on-sd' * mail-on-sd: (40 commits) Added more comments to explain how the locking mecanism works for LocalStore Fixed wrong method being called during experimental provider initialization (since provider isn't enabled, that didn't harm) Add more comments about how the various StorageProviders work and how they're enabled find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs French localization for storage related settings Remove unused SD card strings (replaced with storage indirection) Merge mail-on-sd branch from trunk Reset mail service on storage mount (even if no account uses the storage, to be improved) find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs Migraion -> Migration move the Storage location preference into preferences rather than the wizard. Made LocalStore log less verbose Added @Override compile checks Added ACTION_SHUTDOWN broadcast receiver to properly initiate shutdown sequence (not yet implemented) and cancel any scheduled Intent Be more consistent about which SQLiteDatabase variable is used (from instance variable to argument variable) to make code more refactoring-friendly (class is already big, code extraction should be easier if not referencing the instance variable). Added transaction timing logging Factorised storage lock/transaction handling code for regular operations. Use DB transactions to batch modifications (makes code more robust / could improve performances) Merge mail-on-sd branch from trunk Update issue 888 Added DB close on unmount / DB open on mount Update issue 888 Back to account list when underlying storage not available/unmounting in MessageView / MessageList ...
2010-11-13 16:40:56 -05:00
//warning: account may not be isAvailable()
Account account = accounts[i];
2010-01-17 19:11:02 -05:00
uuids[i] = account.getUuid();
descriptions[i] = account.getDescription();
}
Bundle bundle = getResultExtras(true);
bundle.putStringArray(K9_ACCOUNT_UUIDS, uuids);
bundle.putStringArray(K9_ACCOUNT_DESCRIPTIONS, descriptions);
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Could not handle K9_RESPONSE_INTENT", e);
}
2010-01-17 19:11:02 -05:00
}
2010-01-17 19:11:02 -05:00
return tmpWakeLockId;
}
}