mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
remove dependencies from KeyCachingService
This commit is contained in:
@@ -127,10 +127,6 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
||||
recreate();
|
||||
} else if (key.equals(TextSecurePreferences.LANGUAGE_PREF)) {
|
||||
recreate();
|
||||
|
||||
Intent intent = new Intent(this, KeyCachingService.class);
|
||||
intent.setAction(KeyCachingService.LOCALE_CHANGE_EVENT);
|
||||
startService(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
@@ -93,7 +92,6 @@ import org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
||||
import org.thoughtcrime.securesms.contactshare.ContactShareEditActivity;
|
||||
import org.thoughtcrime.securesms.contactshare.ContactUtil;
|
||||
import org.thoughtcrime.securesms.crypto.SecurityEvent;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.DraftDatabase;
|
||||
@@ -121,7 +119,6 @@ import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||
import org.thoughtcrime.securesms.scribbles.ScribbleActivity;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
@@ -204,7 +201,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private AttachmentTypeSelector attachmentTypeSelector;
|
||||
private AttachmentManager attachmentManager;
|
||||
private AudioRecorder audioRecorder;
|
||||
private BroadcastReceiver securityUpdateReceiver;
|
||||
private Stub<EmojiDrawer> emojiDrawerStub;
|
||||
protected HidingLinearLayout quickAttachmentToggle;
|
||||
private QuickAttachmentDrawer quickAttachmentDrawer;
|
||||
@@ -247,7 +243,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
fragment = initFragment(R.id.fragment_content, new ConversationFragment(), dynamicLanguage.getCurrentLocale());
|
||||
|
||||
initializeReceivers();
|
||||
initializeActionBar();
|
||||
initializeViews();
|
||||
initializeResources();
|
||||
@@ -363,7 +358,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
saveDraft();
|
||||
if (securityUpdateReceiver != null) unregisterReceiver(securityUpdateReceiver);
|
||||
dcContext.eventCenter.removeObservers(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
@@ -874,17 +868,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void initializeReceivers() {
|
||||
securityUpdateReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
initializeSecurity(isSecureText, isDefaultSms);
|
||||
calculateCharactersRemaining();
|
||||
}
|
||||
};
|
||||
|
||||
registerReceiver(securityUpdateReceiver,
|
||||
new IntentFilter(SecurityEvent.SECURITY_UPDATE_EVENT),
|
||||
KeyCachingService.KEY_PERMISSION, null);
|
||||
}
|
||||
|
||||
//////// Helper Methods
|
||||
|
||||
@@ -154,7 +154,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_new_chat: createChat(); return true;
|
||||
case R.id.menu_settings: handleDisplaySettings(); return true;
|
||||
case R.id.menu_clear_passphrase: handleClearPassphrase(); return true;
|
||||
case R.id.menu_qr_scan: handleQrScan(); return true;
|
||||
case R.id.menu_qr_show: handleQrShow(); return true;
|
||||
case R.id.menu_deaddrop: handleDeaddrop(); return true;
|
||||
@@ -217,12 +216,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
startActivity(preferencesIntent);
|
||||
}
|
||||
|
||||
private void handleClearPassphrase() {
|
||||
Intent intent = new Intent(this, KeyCachingService.class);
|
||||
intent.setAction(KeyCachingService.CLEAR_KEY_ACTION);
|
||||
startService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
@@ -37,7 +37,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (!isFinishing()) {
|
||||
initializeClearKeyReceiver();
|
||||
onCreate(savedInstanceState, true);
|
||||
}
|
||||
}
|
||||
@@ -67,7 +66,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
protected void onDestroy() {
|
||||
Log.w(TAG, "onDestroy()");
|
||||
super.onDestroy();
|
||||
removeClearKeyReceiver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,25 +140,4 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
if (nextIntent != null) intent.putExtra("next_intent", nextIntent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
private void initializeClearKeyReceiver() {
|
||||
Log.w(TAG, "initializeClearKeyReceiver()");
|
||||
this.clearKeyReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.w(TAG, "onReceive() for clear key event");
|
||||
onMasterSecretCleared();
|
||||
}
|
||||
};
|
||||
|
||||
IntentFilter filter = new IntentFilter(KeyCachingService.CLEAR_KEY_EVENT);
|
||||
registerReceiver(clearKeyReceiver, filter, KeyCachingService.KEY_PERMISSION, null);
|
||||
}
|
||||
|
||||
private void removeClearKeyReceiver(Context context) {
|
||||
if (clearKeyReceiver != null) {
|
||||
context.unregisterReceiver(clearKeyReceiver);
|
||||
clearKeyReceiver = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.thoughtcrime.securesms.crypto;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
|
||||
/**
|
||||
* This class processes key exchange interactions.
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
|
||||
public class SecurityEvent {
|
||||
|
||||
public static final String SECURITY_UPDATE_EVENT = "org.thoughtcrime.securesms.KEY_EXCHANGE_UPDATE";
|
||||
|
||||
public static void broadcastSecurityUpdateEvent(Context context) {
|
||||
Intent intent = new Intent(SECURITY_UPDATE_EVENT);
|
||||
intent.setPackage(context.getPackageName());
|
||||
context.sendBroadcast(intent, KeyCachingService.KEY_PERMISSION);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,9 +21,10 @@ public class PanicResponderListener extends BroadcastReceiver {
|
||||
if (intent != null && !TextSecurePreferences.isPasswordDisabled(context) &&
|
||||
"info.guardianproject.panic.action.TRIGGER".equals(intent.getAction()))
|
||||
{
|
||||
Intent lockIntent = new Intent(context, KeyCachingService.class);
|
||||
lockIntent.setAction(KeyCachingService.CLEAR_KEY_ACTION);
|
||||
context.startService(lockIntent);
|
||||
// as delta is protected with the system credentials,
|
||||
// the current suggestion on "panic" would probably just be to lock the device.
|
||||
// this would also lock delta chat.
|
||||
// however, we leave this class to allow easy changes on this.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user