blob: 39b29f9a0f8f20358e7fa8986c441ec4de7f5945 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package org.sufficientlysecure.keychain.crypto_provider;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.util.Log;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class RegisterActivity extends Activity {
public static final String ACTION_REGISTER = "com.android.crypto.REGISTER";
public static final String EXTRA_PACKAGE_NAME = "packageName";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handleActions(getIntent());
}
protected void handleActions(Intent intent) {
String action = intent.getAction();
Bundle extras = intent.getExtras();
if (extras == null) {
extras = new Bundle();
}
final String callingPackageName = this.getCallingPackage();
/**
* com.android.crypto actions
*/
if (ACTION_REGISTER.equals(action)) {
setContentView(R.layout.register_crypto_consumer_activity);
Button allowButton = (Button) findViewById(R.id.register_crypto_consumer_allow);
Button disallowButton = (Button) findViewById(R.id.register_crypto_consumer_disallow);
allowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ProviderHelper.addCryptoConsumer(RegisterActivity.this, callingPackageName);
Intent data = new Intent();
data.putExtra(EXTRA_PACKAGE_NAME, "org.sufficientlysecure.keychain");
setResult(RESULT_OK, data);
finish();
}
});
disallowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setResult(RESULT_CANCELED);
finish();
}
});
} else {
Log.e(Constants.TAG, "Please use com.android.crypto.REGISTER as intent action!");
finish();
}
}
}
|