summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorJason parks <jparks@google.com>2011-01-13 14:15:43 -0600
committerJason parks <jparks@google.com>2011-01-13 14:15:43 -0600
commita3cdaa5337fa573c4c61770195d6232c2e587090 (patch)
tree99aa62f3acc658a587c2d8a3c33107cf92281dbb /core/java/android
parentc15c7a79a69733bd21d6548fd74c2874fdabe7e8 (diff)
Revert "Remove the APIs for the old encryption scheme."
This reverts commit 1125d780a8b61703b8eb28c5c77dac5f3f0022dd.
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/accounts/AccountManagerService.java36
-rw-r--r--core/java/android/content/SyncStorageEngine.java14
-rw-r--r--core/java/android/content/pm/ApplicationInfo.java12
-rw-r--r--core/java/android/content/pm/PackageParser.java29
-rw-r--r--core/java/android/os/Environment.java44
5 files changed, 78 insertions, 57 deletions
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index ce3d2a3f886c..6e045877aa9d 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -43,6 +43,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Binder;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -51,11 +52,13 @@ import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
+import android.os.SystemProperties;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
+import java.io.File;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -450,7 +453,6 @@ public class AccountManagerService
mAccount = account;
}
- @Override
public void run() throws RemoteException {
try {
mAuthenticator.hasFeatures(this, mAccount, mFeatures);
@@ -459,7 +461,6 @@ public class AccountManagerService
}
}
- @Override
public void onResult(Bundle result) {
IAccountManagerResponse response = getResponseAndClose();
if (response != null) {
@@ -485,7 +486,6 @@ public class AccountManagerService
}
}
- @Override
protected String toDebugString(long now) {
return super.toDebugString(now) + ", hasFeatures"
+ ", " + mAccount
@@ -531,18 +531,15 @@ public class AccountManagerService
mAccount = account;
}
- @Override
protected String toDebugString(long now) {
return super.toDebugString(now) + ", removeAccount"
+ ", account " + mAccount;
}
- @Override
public void run() throws RemoteException {
mAuthenticator.getAccountRemovalAllowed(this, mAccount);
}
- @Override
public void onResult(Bundle result) {
if (result != null && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT)
&& !result.containsKey(AccountManager.KEY_INTENT)) {
@@ -835,19 +832,16 @@ public class AccountManagerService
try {
new Session(response, account.type, false,
false /* stripAuthTokenFromResult */) {
- @Override
protected String toDebugString(long now) {
return super.toDebugString(now) + ", getAuthTokenLabel"
+ ", " + account
+ ", authTokenType " + authTokenType;
}
- @Override
public void run() throws RemoteException {
mAuthenticator.getAuthTokenLabel(this, authTokenType);
}
- @Override
public void onResult(Bundle result) {
if (result != null) {
String label = result.getString(AccountManager.KEY_AUTH_TOKEN_LABEL);
@@ -918,7 +912,6 @@ public class AccountManagerService
new Session(response, account.type, expectActivityLaunch,
false /* stripAuthTokenFromResult */) {
- @Override
protected String toDebugString(long now) {
if (loginOptions != null) loginOptions.keySet();
return super.toDebugString(now) + ", getAuthToken"
@@ -928,7 +921,6 @@ public class AccountManagerService
+ ", notifyOnAuthFailure " + notifyOnAuthFailure;
}
- @Override
public void run() throws RemoteException {
// If the caller doesn't have permission then create and return the
// "grant permission" intent instead of the "getAuthToken" intent.
@@ -939,7 +931,6 @@ public class AccountManagerService
}
}
- @Override
public void onResult(Bundle result) {
if (result != null) {
if (result.containsKey(AccountManager.KEY_AUTH_TOKEN_LABEL)) {
@@ -1084,13 +1075,11 @@ public class AccountManagerService
try {
new Session(response, accountType, expectActivityLaunch,
true /* stripAuthTokenFromResult */) {
- @Override
public void run() throws RemoteException {
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
options);
}
- @Override
protected String toDebugString(long now) {
return super.toDebugString(now) + ", addAccount"
+ ", accountType " + accountType
@@ -1121,11 +1110,9 @@ public class AccountManagerService
try {
new Session(response, account.type, expectActivityLaunch,
true /* stripAuthTokenFromResult */) {
- @Override
public void run() throws RemoteException {
mAuthenticator.confirmCredentials(this, account, options);
}
- @Override
protected String toDebugString(long now) {
return super.toDebugString(now) + ", confirmCredentials"
+ ", " + account;
@@ -1155,11 +1142,9 @@ public class AccountManagerService
try {
new Session(response, account.type, expectActivityLaunch,
true /* stripAuthTokenFromResult */) {
- @Override
public void run() throws RemoteException {
mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions);
}
- @Override
protected String toDebugString(long now) {
if (loginOptions != null) loginOptions.keySet();
return super.toDebugString(now) + ", updateCredentials"
@@ -1189,11 +1174,9 @@ public class AccountManagerService
try {
new Session(response, accountType, expectActivityLaunch,
true /* stripAuthTokenFromResult */) {
- @Override
public void run() throws RemoteException {
mAuthenticator.editProperties(this, mAccountType);
}
- @Override
protected String toDebugString(long now) {
return super.toDebugString(now) + ", editProperties"
+ ", accountType " + accountType;
@@ -1217,7 +1200,6 @@ public class AccountManagerService
mFeatures = features;
}
- @Override
public void run() throws RemoteException {
mAccountsOfType = getAccountsByTypeFromCache(mAccountType);
// check whether each account matches the requested features
@@ -1252,7 +1234,6 @@ public class AccountManagerService
}
}
- @Override
public void onResult(Bundle result) {
mNumResults++;
if (result == null) {
@@ -1291,7 +1272,6 @@ public class AccountManagerService
}
- @Override
protected String toDebugString(long now) {
return super.toDebugString(now) + ", getAccountsByTypeAndFeatures"
+ ", " + (mFeatures != null ? TextUtils.join(",", mFeatures) : null);
@@ -1614,7 +1594,6 @@ public class AccountManagerService
super(looper);
}
- @Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_TIMED_OUT:
@@ -1629,7 +1608,13 @@ public class AccountManagerService
}
private static String getDatabaseName() {
- return DATABASE_NAME;
+ if(Environment.isEncryptedFilesystemEnabled()) {
+ // Hard-coded path in case of encrypted file system
+ return Environment.getSystemSecureDirectory().getPath() + File.separator + DATABASE_NAME;
+ } else {
+ // Regular path in case of non-encrypted file system
+ return DATABASE_NAME;
+ }
}
private class DatabaseHelper extends SQLiteOpenHelper {
@@ -1852,7 +1837,6 @@ public class AccountManagerService
return false;
}
- @Override
protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
final boolean isCheckinRequest = scanArgs(args, "--checkin") || scanArgs(args, "-c");
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java
index ef1db356fa26..c8ca61898319 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -20,6 +20,10 @@ import com.android.internal.os.AtomicFile;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastXmlSerializer;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
import android.accounts.Account;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
@@ -33,9 +37,9 @@ import android.os.Parcel;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.util.Log;
-import android.util.Pair;
import android.util.SparseArray;
import android.util.Xml;
+import android.util.Pair;
import java.io.File;
import java.io.FileInputStream;
@@ -44,12 +48,8 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.TimeZone;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlSerializer;
+import java.util.List;
/**
* Singleton that tracks the sync data and overall sync
@@ -319,7 +319,7 @@ public class SyncStorageEngine extends Handler {
}
// This call will return the correct directory whether Encrypted File Systems is
// enabled or not.
- File dataDir = Environment.getDataDirectory();
+ File dataDir = Environment.getSecureDataDirectory();
sSyncStorageEngine = new SyncStorageEngine(context, dataDir);
}
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 68840d9a1d08..bb0ed6af77da 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -270,6 +270,16 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
/**
+ * Value for {@link #flags}: this is true if the application has set
+ * its android:neverEncrypt to true, false otherwise. It is used to specify
+ * that this package specifically "opts-out" of a secured file system solution,
+ * and will always store its data in-the-clear.
+ *
+ * {@hide}
+ */
+ public static final int FLAG_NEVER_ENCRYPT = 1<<30;
+
+ /**
* Value for {@link #flags}: Set to true if the application has been
* installed using the forward lock option.
*
@@ -459,7 +469,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
}
- @Override
public String toString() {
return "ApplicationInfo{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -470,7 +479,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
return 0;
}
- @Override
public void writeToParcel(Parcel dest, int parcelableFlags) {
super.writeToParcel(dest, parcelableFlags);
dest.writeString(taskAffinity);
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index b4177d6af742..b2937babef0b 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -16,8 +16,6 @@
package android.content.pm;
-import com.android.internal.util.XmlUtils;
-
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -34,6 +32,9 @@ import android.util.Config;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
+import com.android.internal.util.XmlUtils;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
import java.io.BufferedInputStream;
import java.io.File;
@@ -48,9 +49,6 @@ import java.util.Iterator;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
/**
* Package archive parsing
*
@@ -1575,6 +1573,12 @@ public class PackageParser {
ai.flags |= ApplicationInfo.FLAG_TEST_ONLY;
}
+ if (sa.getBoolean(
+ com.android.internal.R.styleable.AndroidManifestApplication_neverEncrypt,
+ false)) {
+ ai.flags |= ApplicationInfo.FLAG_NEVER_ENCRYPT;
+ }
+
String str;
str = sa.getNonConfigurationString(
com.android.internal.R.styleable.AndroidManifestApplication_permission, 0);
@@ -2859,7 +2863,6 @@ public class PackageParser {
}
}
- @Override
public String toString() {
return "Package{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3000,13 +3003,11 @@ public class PackageParser {
info = _info;
}
- @Override
public void setPackageName(String packageName) {
super.setPackageName(packageName);
info.packageName = packageName;
}
- @Override
public String toString() {
return "Permission{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3027,13 +3028,11 @@ public class PackageParser {
info = _info;
}
- @Override
public void setPackageName(String packageName) {
super.setPackageName(packageName);
info.packageName = packageName;
}
- @Override
public String toString() {
return "PermissionGroup{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3120,13 +3119,11 @@ public class PackageParser {
info.applicationInfo = args.owner.applicationInfo;
}
- @Override
public void setPackageName(String packageName) {
super.setPackageName(packageName);
info.packageName = packageName;
}
- @Override
public String toString() {
return "Activity{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3156,13 +3153,11 @@ public class PackageParser {
info.applicationInfo = args.owner.applicationInfo;
}
- @Override
public void setPackageName(String packageName) {
super.setPackageName(packageName);
info.packageName = packageName;
}
- @Override
public String toString() {
return "Service{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3199,13 +3194,11 @@ public class PackageParser {
this.syncable = existingProvider.syncable;
}
- @Override
public void setPackageName(String packageName) {
super.setPackageName(packageName);
info.packageName = packageName;
}
- @Override
public String toString() {
return "Provider{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3239,13 +3232,11 @@ public class PackageParser {
info = _info;
}
- @Override
public void setPackageName(String packageName) {
super.setPackageName(packageName);
info.packageName = packageName;
}
- @Override
public String toString() {
return "Instrumentation{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3279,7 +3270,6 @@ public class PackageParser {
activity = _activity;
}
- @Override
public String toString() {
return "ActivityIntentInfo{"
+ Integer.toHexString(System.identityHashCode(this))
@@ -3294,7 +3284,6 @@ public class PackageParser {
service = _service;
}
- @Override
public String toString() {
return "ServiceIntentInfo{"
+ Integer.toHexString(System.identityHashCode(this))
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index c36031e094a7..4f188f8576d4 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -16,11 +16,11 @@
package android.os;
+import java.io.File;
+
import android.content.res.Resources;
import android.os.storage.IMountService;
-import java.io.File;
-
/**
* Provides access to environment variables.
*/
@@ -47,6 +47,46 @@ public class Environment {
return ROOT_DIRECTORY;
}
+ /**
+ * Gets the system directory available for secure storage.
+ * If Encrypted File system is enabled, it returns an encrypted directory (/data/secure/system).
+ * Otherwise, it returns the unencrypted /data/system directory.
+ * @return File object representing the secure storage system directory.
+ * @hide
+ */
+ public static File getSystemSecureDirectory() {
+ if (isEncryptedFilesystemEnabled()) {
+ return new File(SECURE_DATA_DIRECTORY, "system");
+ } else {
+ return new File(DATA_DIRECTORY, "system");
+ }
+ }
+
+ /**
+ * Gets the data directory for secure storage.
+ * If Encrypted File system is enabled, it returns an encrypted directory (/data/secure).
+ * Otherwise, it returns the unencrypted /data directory.
+ * @return File object representing the data directory for secure storage.
+ * @hide
+ */
+ public static File getSecureDataDirectory() {
+ if (isEncryptedFilesystemEnabled()) {
+ return SECURE_DATA_DIRECTORY;
+ } else {
+ return DATA_DIRECTORY;
+ }
+ }
+
+ /**
+ * Returns whether the Encrypted File System feature is enabled on the device or not.
+ * @return <code>true</code> if Encrypted File System feature is enabled, <code>false</code>
+ * if disabled.
+ * @hide
+ */
+ public static boolean isEncryptedFilesystemEnabled() {
+ return SystemProperties.getBoolean(SYSTEM_PROPERTY_EFS_ENABLED, false);
+ }
+
private static final File DATA_DIRECTORY
= getDirectory("ANDROID_DATA", "/data");