summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-04-11 09:05:06 -0700
committerBrian Carlstrom <bdc@google.com>2011-04-22 17:15:31 -0700
commit3e6251dedc92654476c70bdc413f24a4b31ce6a4 (patch)
treeef8d4e42ebb95ab0e877a880f28d53e01a1a5d20 /support
parent93eceb0295188d01d295da4687b09151a82c006e (diff)
downloadplatform_packages_apps_KeyChain-3e6251dedc92654476c70bdc413f24a4b31ce6a4.tar.gz
platform_packages_apps_KeyChain-3e6251dedc92654476c70bdc413f24a4b31ce6a4.tar.bz2
platform_packages_apps_KeyChain-3e6251dedc92654476c70bdc413f24a4b31ce6a4.zip
Adding KeyChainService and KeyChainActivity
Change-Id: I6c862d3e687cf80fb882966adb3245f2244244fe
Diffstat (limited to 'support')
-rw-r--r--support/Android.mk29
-rw-r--r--support/AndroidManifest.xml27
-rw-r--r--support/src/com/android/keychain/tests/support/IKeyChainServiceTestSupport.aidl38
-rw-r--r--support/src/com/android/keychain/tests/support/KeyChainServiceTestSupport.java69
4 files changed, 163 insertions, 0 deletions
diff --git a/support/Android.mk b/support/Android.mk
new file mode 100644
index 0000000..1860584
--- /dev/null
+++ b/support/Android.mk
@@ -0,0 +1,29 @@
+# Copyright 2011, The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_SRC_FILES := src/com/android/keychain/tests/support/IKeyChainServiceTestSupport.aidl
+LOCAL_MODULE := com.android.keychain.tests.support
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_PACKAGE_NAME := KeyChainTestsSupport
+LOCAL_STATIC_JAVA_LIBRARIES := com.android.keychain.tests.support
+LOCAL_CERTIFICATE := platform
+include $(BUILD_PACKAGE)
diff --git a/support/AndroidManifest.xml b/support/AndroidManifest.xml
new file mode 100644
index 0000000..934660a
--- /dev/null
+++ b/support/AndroidManifest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.keychain.tests.support"
+ android:sharedUserId="android.uid.system">
+ <application android:process="system">
+ <service android:name="com.android.keychain.tests.support.KeyChainServiceTestSupport">
+ <intent-filter>
+ <action android:name="com.android.keychain.tests.support.IKeyChainServiceTestSupport"/>
+ </intent-filter>
+ </service>
+ </application>
+</manifest>
diff --git a/support/src/com/android/keychain/tests/support/IKeyChainServiceTestSupport.aidl b/support/src/com/android/keychain/tests/support/IKeyChainServiceTestSupport.aidl
new file mode 100644
index 0000000..cb03429
--- /dev/null
+++ b/support/src/com/android/keychain/tests/support/IKeyChainServiceTestSupport.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.keychain.tests.support;
+
+import android.accounts.Account;
+
+/**
+ * Service that runs as the system user for the use of the
+ * KeyChainServiceTest which needs to run as a regular app user, but
+ * needs to automate some steps only permissable to the system
+ * user. The KeyChainService itself runs as the keychain user and
+ * cannot do these steps itself. In a real application, they user is
+ * prompted to perform these steps via the
+ * com.android.credentials.UNLOCK Intent and
+ * GrantCredentialsPermissionActivity.
+ *
+ * @hide
+ */
+interface IKeyChainServiceTestSupport {
+ boolean keystoreReset();
+ boolean keystorePassword(String oldPassword, String newPassword);
+ boolean keystorePut(in byte[] key, in byte[] value);
+ void revokeAppPermission(in Account account, String authTokenType, int uid);
+ void grantAppPermission(in Account account, String authTokenType, int uid);
+}
diff --git a/support/src/com/android/keychain/tests/support/KeyChainServiceTestSupport.java b/support/src/com/android/keychain/tests/support/KeyChainServiceTestSupport.java
new file mode 100644
index 0000000..46ef6f8
--- /dev/null
+++ b/support/src/com/android/keychain/tests/support/KeyChainServiceTestSupport.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.keychain.tests.support;
+
+import android.accounts.Account;
+import android.accounts.AccountManagerService;
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.security.KeyStore;
+import android.util.Log;
+
+public class KeyChainServiceTestSupport extends Service {
+
+ private static final String TAG = "KeyChainServiceTestSupport";
+
+ private final Object mServiceLock = new Object();
+ private IKeyChainServiceTestSupport mService;
+ private boolean mIsBound;
+
+ private final KeyStore mKeyStore = KeyStore.getInstance();
+ private final AccountManagerService accountManagerService
+ = AccountManagerService.getSingleton();
+
+ private final IKeyChainServiceTestSupport.Stub mIKeyChainServiceTestSupport
+ = new IKeyChainServiceTestSupport.Stub() {
+ @Override public boolean keystoreReset() {
+ Log.d(TAG, "keystoreReset");
+ return mKeyStore.reset();
+ }
+ @Override public boolean keystorePassword(String oldPassword, String newPassword) {
+ Log.d(TAG, "keystorePassword");
+ return mKeyStore.password(oldPassword, newPassword);
+ }
+ @Override public boolean keystorePut(byte[] key, byte[] value) {
+ Log.d(TAG, "keystorePut");
+ return mKeyStore.put(key, value);
+ }
+ @Override public void revokeAppPermission(Account account, String authTokenType, int uid) {
+ Log.d(TAG, "revokeAppPermission");
+ accountManagerService.revokeAppPermission(account, authTokenType, uid);
+ }
+ @Override public void grantAppPermission(Account account, String authTokenType, int uid) {
+ Log.d(TAG, "grantAppPermission");
+ accountManagerService.grantAppPermission(account, authTokenType, uid);
+ }
+ };
+
+ @Override public IBinder onBind(Intent intent) {
+ if (IKeyChainServiceTestSupport.class.getName().equals(intent.getAction())) {
+ return mIKeyChainServiceTestSupport;
+ }
+ return null;
+ }
+}