2012-07-17 02:49:37 +00:00
|
|
|
/**
|
2011-12-20 18:20:44 +00:00
|
|
|
* Copyright (C) 2011 Whisper Systems
|
2012-07-17 02:49:37 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2012-07-17 02:49:37 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package org.thoughtcrime.securesms.service;
|
|
|
|
|
2014-02-25 18:32:42 +00:00
|
|
|
import android.annotation.TargetApi;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.app.AlarmManager;
|
|
|
|
import android.app.Notification;
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
import android.app.Service;
|
2013-02-11 01:30:51 +00:00
|
|
|
import android.content.Context;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.content.Intent;
|
2013-07-01 17:15:36 +00:00
|
|
|
import android.os.AsyncTask;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.os.Binder;
|
2012-09-09 16:18:17 +00:00
|
|
|
import android.os.Build;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.SystemClock;
|
2013-11-18 23:29:19 +00:00
|
|
|
import android.support.v4.app.NotificationCompat;
|
2011-12-20 18:20:44 +00:00
|
|
|
import android.util.Log;
|
2012-09-09 16:18:17 +00:00
|
|
|
import android.widget.RemoteViews;
|
2011-12-20 18:20:44 +00:00
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.thoughtcrime.securesms.ApplicationContext;
|
2014-12-15 20:25:55 +00:00
|
|
|
import org.thoughtcrime.securesms.ConversationListActivity;
|
2013-05-16 20:16:42 +00:00
|
|
|
import org.thoughtcrime.securesms.DatabaseUpgradeActivity;
|
2014-03-03 19:45:05 +00:00
|
|
|
import org.thoughtcrime.securesms.DummyActivity;
|
2012-07-17 02:49:37 +00:00
|
|
|
import org.thoughtcrime.securesms.R;
|
2013-07-01 17:15:36 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.InvalidPassphraseException;
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
2013-07-01 17:15:36 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
2013-02-08 19:57:54 +00:00
|
|
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
2014-12-11 23:04:32 +00:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.thoughtcrime.securesms.util.ParcelUtil;
|
2013-07-10 01:26:18 +00:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.whispersystems.jobqueue.EncryptionKeys;
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-12-13 00:07:02 +00:00
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
/**
|
|
|
|
* Small service that stays running to keep a key cached in memory.
|
2012-07-17 02:49:37 +00:00
|
|
|
*
|
2011-12-20 18:20:44 +00:00
|
|
|
* @author Moxie Marlinspike
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class KeyCachingService extends Service {
|
|
|
|
|
2013-02-11 01:30:51 +00:00
|
|
|
public static final int SERVICE_RUNNING_ID = 4141;
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
public static final String KEY_PERMISSION = "org.thoughtcrime.securesms.ACCESS_SECRETS";
|
|
|
|
public static final String NEW_KEY_EVENT = "org.thoughtcrime.securesms.service.action.NEW_KEY_EVENT";
|
2013-02-08 19:57:54 +00:00
|
|
|
public static final String CLEAR_KEY_EVENT = "org.thoughtcrime.securesms.service.action.CLEAR_KEY_EVENT";
|
|
|
|
private static final String PASSPHRASE_EXPIRED_EVENT = "org.thoughtcrime.securesms.service.action.PASSPHRASE_EXPIRED_EVENT";
|
2011-12-20 18:20:44 +00:00
|
|
|
public static final String CLEAR_KEY_ACTION = "org.thoughtcrime.securesms.service.action.CLEAR_KEY";
|
2013-07-01 17:15:36 +00:00
|
|
|
public static final String DISABLE_ACTION = "org.thoughtcrime.securesms.service.action.DISABLE";
|
2011-12-20 18:20:44 +00:00
|
|
|
public static final String ACTIVITY_START_EVENT = "org.thoughtcrime.securesms.service.action.ACTIVITY_START_EVENT";
|
|
|
|
public static final String ACTIVITY_STOP_EVENT = "org.thoughtcrime.securesms.service.action.ACTIVITY_STOP_EVENT";
|
2014-12-11 23:04:32 +00:00
|
|
|
public static final String LOCALE_CHANGE_EVENT = "org.thoughtcrime.securesms.service.action.LOCALE_CHANGE_EVENT";
|
|
|
|
|
|
|
|
private DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private PendingIntent pending;
|
2012-07-17 02:49:37 +00:00
|
|
|
private int activitiesRunning = 0;
|
2014-11-03 23:16:04 +00:00
|
|
|
private final IBinder binder = new KeySetBinder();
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
private static MasterSecret masterSecret;
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
public KeyCachingService() {}
|
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
public static synchronized MasterSecret getMasterSecret(Context context) {
|
|
|
|
if (masterSecret == null && TextSecurePreferences.isPasswordDisabled(context)) {
|
|
|
|
try {
|
|
|
|
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(context, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
|
|
|
Intent intent = new Intent(context, KeyCachingService.class);
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
context.startService(intent);
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
return masterSecret;
|
|
|
|
} catch (InvalidPassphraseException e) {
|
|
|
|
Log.w("KeyCachingService", e);
|
|
|
|
}
|
|
|
|
}
|
2013-02-08 19:57:54 +00:00
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
return masterSecret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMasterSecret(final MasterSecret masterSecret) {
|
|
|
|
synchronized (KeyCachingService.class) {
|
|
|
|
KeyCachingService.masterSecret = masterSecret;
|
|
|
|
|
|
|
|
foregroundService();
|
|
|
|
broadcastNewSecret();
|
|
|
|
startTimeoutIfAppropriate();
|
|
|
|
|
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Void... params) {
|
|
|
|
if (!DatabaseUpgradeActivity.isUpdate(KeyCachingService.this)) {
|
|
|
|
ApplicationContext.getInstance(KeyCachingService.this)
|
|
|
|
.getJobManager()
|
|
|
|
.setEncryptionKeys(new EncryptionKeys(ParcelUtil.serialize(masterSecret)));
|
|
|
|
MessageNotifier.updateNotification(KeyCachingService.this, masterSecret);
|
|
|
|
}
|
|
|
|
return null;
|
2013-05-16 20:16:42 +00:00
|
|
|
}
|
2014-11-03 23:16:04 +00:00
|
|
|
}.execute();
|
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
@Override
|
2013-07-01 17:15:36 +00:00
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
|
if (intent == null) return START_NOT_STICKY;
|
2014-12-15 20:25:55 +00:00
|
|
|
Log.w("KeyCachingService", "onStartCommand, " + intent.getAction());
|
2012-08-05 19:41:31 +00:00
|
|
|
|
2014-12-11 23:04:32 +00:00
|
|
|
if (intent.getAction() != null) {
|
|
|
|
switch (intent.getAction()) {
|
|
|
|
case CLEAR_KEY_ACTION: handleClearKey(); break;
|
|
|
|
case ACTIVITY_START_EVENT: handleActivityStarted(); break;
|
|
|
|
case ACTIVITY_STOP_EVENT: handleActivityStopped(); break;
|
|
|
|
case PASSPHRASE_EXPIRED_EVENT: handleClearKey(); break;
|
|
|
|
case DISABLE_ACTION: handleDisableService(); break;
|
|
|
|
case LOCALE_CHANGE_EVENT: handleLocaleChanged(); break;
|
|
|
|
}
|
|
|
|
}
|
2013-07-01 17:15:36 +00:00
|
|
|
|
|
|
|
return START_NOT_STICKY;
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
2014-12-15 20:25:55 +00:00
|
|
|
Log.w("KeyCachingService", "onCreate()");
|
2013-02-08 19:57:54 +00:00
|
|
|
super.onCreate();
|
2013-07-01 17:15:36 +00:00
|
|
|
this.pending = PendingIntent.getService(this, 0, new Intent(PASSPHRASE_EXPIRED_EVENT, null,
|
|
|
|
this, KeyCachingService.class), 0);
|
|
|
|
|
2013-07-10 01:26:18 +00:00
|
|
|
if (TextSecurePreferences.isPasswordDisabled(this)) {
|
2013-07-01 17:15:36 +00:00
|
|
|
try {
|
|
|
|
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
|
|
|
setMasterSecret(masterSecret);
|
|
|
|
} catch (InvalidPassphraseException e) {
|
|
|
|
Log.w("KeyCachingService", e);
|
|
|
|
}
|
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
@Override
|
|
|
|
public void onDestroy() {
|
2013-02-08 19:57:54 +00:00
|
|
|
super.onDestroy();
|
|
|
|
Log.w("KeyCachingService", "KCS Is Being Destroyed!");
|
|
|
|
handleClearKey();
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-03-03 19:45:05 +00:00
|
|
|
/**
|
|
|
|
* Workaround for Android bug:
|
|
|
|
* https://code.google.com/p/android/issues/detail?id=53313
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void onTaskRemoved(Intent rootIntent) {
|
|
|
|
Intent intent = new Intent(this, DummyActivity.class);
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private void handleActivityStarted() {
|
|
|
|
Log.w("KeyCachingService", "Incrementing activity count...");
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
AlarmManager alarmManager = (AlarmManager)this.getSystemService(ALARM_SERVICE);
|
2012-07-17 02:49:37 +00:00
|
|
|
alarmManager.cancel(pending);
|
2011-12-20 18:20:44 +00:00
|
|
|
activitiesRunning++;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleActivityStopped() {
|
|
|
|
Log.w("KeyCachingService", "Decrementing activity count...");
|
|
|
|
|
|
|
|
activitiesRunning--;
|
|
|
|
startTimeoutIfAppropriate();
|
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private void handleClearKey() {
|
2014-12-15 20:25:55 +00:00
|
|
|
Log.w("KeyCachingService", "handleClearKey()");
|
|
|
|
KeyCachingService.masterSecret = null;
|
2012-07-17 02:49:37 +00:00
|
|
|
stopForeground(true);
|
|
|
|
|
2013-02-08 19:57:54 +00:00
|
|
|
Intent intent = new Intent(CLEAR_KEY_EVENT);
|
2011-12-20 18:20:44 +00:00
|
|
|
intent.setPackage(getApplicationContext().getPackageName());
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
sendBroadcast(intent, KEY_PERMISSION);
|
2013-02-08 19:57:54 +00:00
|
|
|
|
2013-07-01 17:15:36 +00:00
|
|
|
new AsyncTask<Void, Void, Void>() {
|
2013-02-08 19:57:54 +00:00
|
|
|
@Override
|
2013-07-01 17:15:36 +00:00
|
|
|
protected Void doInBackground(Void... params) {
|
2013-02-08 19:57:54 +00:00
|
|
|
MessageNotifier.updateNotification(KeyCachingService.this, null);
|
2013-07-01 17:15:36 +00:00
|
|
|
return null;
|
2013-02-08 19:57:54 +00:00
|
|
|
}
|
2013-07-01 17:15:36 +00:00
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleDisableService() {
|
2013-07-10 01:26:18 +00:00
|
|
|
if (TextSecurePreferences.isPasswordDisabled(this))
|
2013-07-01 17:15:36 +00:00
|
|
|
stopForeground(true);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-12-11 23:04:32 +00:00
|
|
|
private void handleLocaleChanged() {
|
|
|
|
dynamicLanguage.updateServiceLocale(this);
|
|
|
|
foregroundService();
|
|
|
|
}
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private void startTimeoutIfAppropriate() {
|
2013-07-11 21:58:40 +00:00
|
|
|
boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(this);
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-12-15 20:25:55 +00:00
|
|
|
if ((activitiesRunning == 0) && (KeyCachingService.masterSecret != null) && timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(this)) {
|
2013-07-11 21:58:40 +00:00
|
|
|
long timeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(this);
|
2014-12-13 00:07:02 +00:00
|
|
|
long timeoutMillis = TimeUnit.MINUTES.toMillis(timeoutMinutes);
|
2011-12-20 18:20:44 +00:00
|
|
|
|
|
|
|
Log.w("KeyCachingService", "Starting timeout: " + timeoutMillis);
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
AlarmManager alarmManager = (AlarmManager)this.getSystemService(ALARM_SERVICE);
|
|
|
|
alarmManager.cancel(pending);
|
|
|
|
alarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + timeoutMillis, pending);
|
2012-07-17 02:49:37 +00:00
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-02-25 18:32:42 +00:00
|
|
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
2012-09-09 16:18:17 +00:00
|
|
|
private void foregroundServiceModern() {
|
2014-12-15 20:25:55 +00:00
|
|
|
Log.w("KeyCachingService", "foregrounding KCS");
|
2013-10-12 13:04:16 +00:00
|
|
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
2012-09-09 16:18:17 +00:00
|
|
|
|
2013-12-22 02:44:31 +00:00
|
|
|
builder.setContentTitle(getString(R.string.KeyCachingService_passphrase_cached));
|
|
|
|
builder.setContentText(getString(R.string.KeyCachingService_textsecure_passphrase_cached));
|
|
|
|
builder.setSmallIcon(R.drawable.icon_cached);
|
|
|
|
builder.setWhen(0);
|
2014-02-25 18:32:42 +00:00
|
|
|
builder.setPriority(Notification.PRIORITY_MIN);
|
2013-12-22 02:44:31 +00:00
|
|
|
|
|
|
|
builder.addAction(R.drawable.ic_menu_lock_holo_dark, getString(R.string.KeyCachingService_lock), buildLockIntent());
|
|
|
|
builder.setContentIntent(buildLaunchIntent());
|
|
|
|
|
|
|
|
stopForeground(true);
|
|
|
|
startForeground(SERVICE_RUNNING_ID, builder.build());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void foregroundServiceICS() {
|
|
|
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
|
|
|
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.key_caching_notification);
|
|
|
|
|
|
|
|
remoteViews.setOnClickPendingIntent(R.id.lock_cache_icon, buildLockIntent());
|
2012-09-09 16:18:17 +00:00
|
|
|
|
2013-10-12 13:04:16 +00:00
|
|
|
builder.setSmallIcon(R.drawable.icon_cached);
|
|
|
|
builder.setContent(remoteViews);
|
2013-12-22 02:44:31 +00:00
|
|
|
builder.setContentIntent(buildLaunchIntent());
|
2012-09-09 16:18:17 +00:00
|
|
|
|
|
|
|
stopForeground(true);
|
2013-10-12 13:04:16 +00:00
|
|
|
startForeground(SERVICE_RUNNING_ID, builder.build());
|
2012-09-09 16:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void foregroundServiceLegacy() {
|
2012-09-08 03:03:23 +00:00
|
|
|
Notification notification = new Notification(R.drawable.icon_cached,
|
2012-09-20 02:56:04 +00:00
|
|
|
getString(R.string.KeyCachingService_textsecure_passphrase_cached),
|
2012-09-08 03:03:23 +00:00
|
|
|
System.currentTimeMillis());
|
2012-09-20 02:56:04 +00:00
|
|
|
notification.setLatestEventInfo(getApplicationContext(),
|
|
|
|
getString(R.string.KeyCachingService_passphrase_cached),
|
|
|
|
getString(R.string.KeyCachingService_textsecure_passphrase_cached),
|
2013-12-22 02:44:31 +00:00
|
|
|
buildLaunchIntent());
|
|
|
|
notification.tickerText = null;
|
2012-07-17 02:49:37 +00:00
|
|
|
|
|
|
|
stopForeground(true);
|
|
|
|
startForeground(SERVICE_RUNNING_ID, notification);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2012-09-09 16:18:17 +00:00
|
|
|
private void foregroundService() {
|
2013-07-10 01:26:18 +00:00
|
|
|
if (TextSecurePreferences.isPasswordDisabled(this)) {
|
2013-07-01 17:15:36 +00:00
|
|
|
stopForeground(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-22 02:44:31 +00:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
|
foregroundServiceModern();
|
|
|
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
|
|
|
foregroundServiceICS();
|
|
|
|
} else {
|
|
|
|
foregroundServiceLegacy();
|
|
|
|
}
|
2012-09-09 16:18:17 +00:00
|
|
|
}
|
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private void broadcastNewSecret() {
|
|
|
|
Log.w("service", "Broadcasting new secret...");
|
2013-02-08 19:57:54 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
Intent intent = new Intent(NEW_KEY_EVENT);
|
|
|
|
intent.setPackage(getApplicationContext().getPackageName());
|
|
|
|
|
|
|
|
sendBroadcast(intent, KEY_PERMISSION);
|
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2013-12-22 02:44:31 +00:00
|
|
|
private PendingIntent buildLockIntent() {
|
|
|
|
Intent intent = new Intent(this, KeyCachingService.class);
|
|
|
|
intent.setAction(PASSPHRASE_EXPIRED_EVENT);
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
|
|
|
|
return pendingIntent;
|
|
|
|
}
|
|
|
|
|
|
|
|
private PendingIntent buildLaunchIntent() {
|
2014-12-15 20:25:55 +00:00
|
|
|
Intent intent = new Intent(this, ConversationListActivity.class);
|
2013-12-22 02:44:31 +00:00
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
PendingIntent launchIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
|
|
|
|
return launchIntent;
|
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBinder onBind(Intent arg0) {
|
|
|
|
return binder;
|
|
|
|
}
|
2012-07-17 02:49:37 +00:00
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
public class KeySetBinder extends Binder {
|
2011-12-20 18:20:44 +00:00
|
|
|
public KeyCachingService getService() {
|
|
|
|
return KeyCachingService.this;
|
|
|
|
}
|
|
|
|
}
|
2013-02-11 01:30:51 +00:00
|
|
|
|
|
|
|
public static void registerPassphraseActivityStarted(Context activity) {
|
|
|
|
Intent intent = new Intent(activity, KeyCachingService.class);
|
|
|
|
intent.setAction(KeyCachingService.ACTIVITY_START_EVENT);
|
|
|
|
activity.startService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void registerPassphraseActivityStopped(Context activity) {
|
|
|
|
Intent intent = new Intent(activity, KeyCachingService.class);
|
|
|
|
intent.setAction(KeyCachingService.ACTIVITY_STOP_EVENT);
|
|
|
|
activity.startService(intent);
|
|
|
|
}
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|