That fuck shit the fascists are using
at master 77 lines 2.6 kB view raw
1/** 2 * Copyright (C) 2011 Whisper Systems 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17package org.tm.archive; 18 19import android.content.ComponentName; 20import android.content.Context; 21import android.content.Intent; 22import android.content.ServiceConnection; 23import android.os.IBinder; 24 25import org.signal.core.util.logging.Log; 26import org.tm.archive.crypto.MasterSecret; 27import org.tm.archive.service.KeyCachingService; 28 29 30/** 31 * Base Activity for changing/prompting local encryption passphrase. 32 * 33 * @author Moxie Marlinspike 34 */ 35public abstract class PassphraseActivity extends BaseActivity { 36 37 private static final String TAG = Log.tag(PassphraseActivity.class); 38 39 private KeyCachingService keyCachingService; 40 private MasterSecret masterSecret; 41 42 protected void setMasterSecret(MasterSecret masterSecret) { 43 this.masterSecret = masterSecret; 44 Intent bindIntent = new Intent(this, KeyCachingService.class); 45 startService(bindIntent); 46 bindService(bindIntent, serviceConnection, Context.BIND_AUTO_CREATE); 47 } 48 49 protected abstract void cleanup(); 50 51 private ServiceConnection serviceConnection = new ServiceConnection() { 52 @Override 53 public void onServiceConnected(ComponentName className, IBinder service) { 54 keyCachingService = ((KeyCachingService.KeySetBinder)service).getService(); 55 keyCachingService.setMasterSecret(masterSecret); 56 57 PassphraseActivity.this.unbindService(PassphraseActivity.this.serviceConnection); 58 59 masterSecret = null; 60 cleanup(); 61 62 Intent nextIntent = getIntent().getParcelableExtra("next_intent"); 63 if (nextIntent != null) { 64 try { 65 startActivity(nextIntent); 66 } catch (java.lang.SecurityException e) { 67 Log.w(TAG, "Access permission not passed from PassphraseActivity, retry sharing."); 68 } 69 } 70 finish(); 71 } 72 @Override 73 public void onServiceDisconnected(ComponentName name) { 74 keyCachingService = null; 75 } 76 }; 77}