Merge "Updating the WebView accessibility key bindings after discussion with the access-eng team" into honeycomb
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index 6e04587..ce3d2a3 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -43,7 +43,6 @@
 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;
@@ -52,13 +51,11 @@
 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;
@@ -453,6 +450,7 @@
             mAccount = account;
         }
 
+        @Override
         public void run() throws RemoteException {
             try {
                 mAuthenticator.hasFeatures(this, mAccount, mFeatures);
@@ -461,6 +459,7 @@
             }
         }
 
+        @Override
         public void onResult(Bundle result) {
             IAccountManagerResponse response = getResponseAndClose();
             if (response != null) {
@@ -486,6 +485,7 @@
             }
         }
 
+        @Override
         protected String toDebugString(long now) {
             return super.toDebugString(now) + ", hasFeatures"
                     + ", " + mAccount
@@ -531,15 +531,18 @@
             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)) {
@@ -832,16 +835,19 @@
         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);
@@ -912,6 +918,7 @@
 
             new Session(response, account.type, expectActivityLaunch,
                     false /* stripAuthTokenFromResult */) {
+                @Override
                 protected String toDebugString(long now) {
                     if (loginOptions != null) loginOptions.keySet();
                     return super.toDebugString(now) + ", getAuthToken"
@@ -921,6 +928,7 @@
                             + ", 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.
@@ -931,6 +939,7 @@
                     }
                 }
 
+                @Override
                 public void onResult(Bundle result) {
                     if (result != null) {
                         if (result.containsKey(AccountManager.KEY_AUTH_TOKEN_LABEL)) {
@@ -1075,11 +1084,13 @@
         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
@@ -1110,9 +1121,11 @@
         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;
@@ -1142,9 +1155,11 @@
         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"
@@ -1174,9 +1189,11 @@
         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;
@@ -1200,6 +1217,7 @@
             mFeatures = features;
         }
 
+        @Override
         public void run() throws RemoteException {
             mAccountsOfType = getAccountsByTypeFromCache(mAccountType);
             // check whether each account matches the requested features
@@ -1234,6 +1252,7 @@
             }
         }
 
+        @Override
         public void onResult(Bundle result) {
             mNumResults++;
             if (result == null) {
@@ -1272,6 +1291,7 @@
         }
 
 
+        @Override
         protected String toDebugString(long now) {
             return super.toDebugString(now) + ", getAccountsByTypeAndFeatures"
                     + ", " + (mFeatures != null ? TextUtils.join(",", mFeatures) : null);
@@ -1594,6 +1614,7 @@
             super(looper);
         }
 
+        @Override
         public void handleMessage(Message msg) {
             switch (msg.what) {
                 case MESSAGE_TIMED_OUT:
@@ -1608,13 +1629,7 @@
     }
 
     private static String getDatabaseName() {
-        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;
-        }
+        return DATABASE_NAME;
     }
 
     private class DatabaseHelper extends SQLiteOpenHelper {
@@ -1837,6 +1852,7 @@
         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 c8ca6189..ef1db35 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -20,10 +20,6 @@
 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;
@@ -37,9 +33,9 @@
 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;
@@ -48,8 +44,12 @@
 import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.TimeZone;
 import java.util.List;
+import java.util.TimeZone;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
 
 /**
  * Singleton that tracks the sync data and overall sync
@@ -319,7 +319,7 @@
         }
         // This call will return the correct directory whether Encrypted File Systems is
         // enabled or not.
-        File dataDir = Environment.getSecureDataDirectory();
+        File dataDir = Environment.getDataDirectory();
         sSyncStorageEngine = new SyncStorageEngine(context, dataDir);
     }
 
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index bb0ed6a..68840d9 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -270,16 +270,6 @@
     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.
      *
@@ -469,6 +459,7 @@
     }
 
 
+    @Override
     public String toString() {
         return "ApplicationInfo{"
             + Integer.toHexString(System.identityHashCode(this))
@@ -479,6 +470,7 @@
         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 b2937ba..b4177d6 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -16,6 +16,8 @@
 
 package android.content.pm;
 
+import com.android.internal.util.XmlUtils;
+
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.IntentFilter;
@@ -32,9 +34,6 @@
 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;
@@ -49,6 +48,9 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
 /**
  * Package archive parsing
  *
@@ -1573,12 +1575,6 @@
             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);
@@ -2863,6 +2859,7 @@
             }
         }
         
+        @Override
         public String toString() {
             return "Package{"
                 + Integer.toHexString(System.identityHashCode(this))
@@ -3003,11 +3000,13 @@
             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))
@@ -3028,11 +3027,13 @@
             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))
@@ -3119,11 +3120,13 @@
             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))
@@ -3153,11 +3156,13 @@
             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))
@@ -3194,11 +3199,13 @@
             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))
@@ -3232,11 +3239,13 @@
             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))
@@ -3270,6 +3279,7 @@
             activity = _activity;
         }
 
+        @Override
         public String toString() {
             return "ActivityIntentInfo{"
                 + Integer.toHexString(System.identityHashCode(this))
@@ -3284,6 +3294,7 @@
             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 4f188f8..c36031e 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,46 +47,6 @@
         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");
 
diff --git a/core/java/android/os/storage/IMountService.java b/core/java/android/os/storage/IMountService.java
index 23ed31f..b9d4711 100644
--- a/core/java/android/os/storage/IMountService.java
+++ b/core/java/android/os/storage/IMountService.java
@@ -603,6 +603,23 @@
                 }
                 return _result;
             }
+
+            public int encryptStorage(String password) throws RemoteException {
+                Parcel _data = Parcel.obtain();
+                Parcel _reply = Parcel.obtain();
+                int _result;
+                try {
+                    _data.writeInterfaceToken(DESCRIPTOR);
+                    _data.writeString(password);
+                    mRemote.transact(Stub.TRANSACTION_encryptStorage, _data, _reply, 0);
+                    _reply.readException();
+                    _result = _reply.readInt();
+                } finally {
+                    _reply.recycle();
+                    _data.recycle();
+                }
+                return _result;
+            }
         }
 
         private static final String DESCRIPTOR = "IMountService";
@@ -661,6 +678,8 @@
 
         static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26;
 
+        static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27;
+
         /**
          * Cast an IBinder object into an IMountService interface, generating a
          * proxy if needed.
@@ -950,6 +969,14 @@
                     reply.writeInt(result);
                     return true;
                 }
+                case TRANSACTION_encryptStorage: {
+                    data.enforceInterface(DESCRIPTOR);
+                    String password = data.readString();
+                    int result = encryptStorage(password);
+                    reply.writeNoException();
+                    reply.writeInt(result);
+                    return true;
+                }
             }
             return super.onTransact(code, data, reply, flags);
         }
@@ -1114,4 +1141,9 @@
      * Decrypts any encrypted volumes.
      */
     public int decryptStorage(String password) throws RemoteException;
+
+    /**
+     * Encrypts storage.
+     */
+    public int encryptStorage(String password) throws RemoteException;
 }
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index 31bc3fc..539a696 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -717,6 +717,8 @@
 
     private void onDiscoverServicesResult(String deviceObjectPath, boolean result) {
         String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath);
+        if (address == null) return;
+
         // We don't parse the xml here, instead just query Bluez for the properties.
         if (result) {
             mBluetoothService.updateRemoteDevicePropertiesCache(address);
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index bccde8d..2e38743 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -2323,7 +2323,7 @@
         }
 
         if (mPositionScroller != null) {
-            removeCallbacks(mPositionScroller);
+            mPositionScroller.stop();
         }
 
         if (mClearScrollingCache != null) {
@@ -2353,6 +2353,9 @@
                 // let the fling runnable report it's new state which
                 // should be idle
                 mFlingRunnable.endFling();
+                if (mPositionScroller != null) {
+                    mPositionScroller.stop();
+                }
                 if (mScrollY != 0) {
                     mScrollY = 0;
                     finishGlows();
@@ -2720,6 +2723,9 @@
                 if (mFlingRunnable != null) {
                     mFlingRunnable.endFling();
                 }
+                if (mPositionScroller != null) {
+                    mPositionScroller.stop();
+                }
 
                 if (mScrollY != 0) {
                     mScrollY = 0;
@@ -2760,6 +2766,9 @@
             switch (mTouchMode) {
             case TOUCH_MODE_OVERFLING: {
                 mFlingRunnable.endFling();
+                if (mPositionScroller != null) {
+                    mPositionScroller.stop();
+                }
                 mTouchMode = TOUCH_MODE_OVERSCROLL;
                 mMotionY = mLastY = (int) ev.getY();
                 mMotionCorrection = 0;
@@ -3102,6 +3111,9 @@
                             if (mFlingRunnable != null) {
                                 mFlingRunnable.endFling();
                             }
+                            if (mPositionScroller != null) {
+                                mPositionScroller.stop();
+                            }
                         }
                     }
                 } else {
@@ -3508,6 +3520,11 @@
                 } else {
                     mEdgeGlowBottom.onAbsorb(vel);
                 }
+            } else {
+                mTouchMode = TOUCH_MODE_REST;
+                if (mPositionScroller != null) {
+                    mPositionScroller.stop();
+                }
             }
             invalidate();
             post(this);
@@ -3526,9 +3543,6 @@
 
             removeCallbacks(this);
             removeCallbacks(mCheckFlywheel);
-            if (mPositionScroller != null) {
-                removeCallbacks(mPositionScroller);
-            }
 
             reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
             clearScrollingCache();
@@ -3679,6 +3693,8 @@
         }
 
         void start(int position) {
+            stop();
+
             final int firstPos = mFirstPosition;
             final int lastPos = firstPos + getChildCount() - 1;
 
@@ -3707,6 +3723,8 @@
         }
 
         void start(int position, int boundPosition) {
+            stop();
+
             if (boundPosition == INVALID_POSITION) {
                 start(position);
                 return;
@@ -3770,6 +3788,8 @@
         }
 
         void startWithOffset(int position, int offset, int duration) {
+            stop();
+
             mTargetPos = position;
             mOffsetFromTop = offset;
             mBoundPos = INVALID_POSITION;
@@ -3947,11 +3967,22 @@
                 final int position = mTargetPos;
                 final int lastPos = firstPos + childCount - 1;
 
+                int viewTravelCount = 0;
                 if (position < firstPos) {
-                    smoothScrollBy(-getHeight(), mScrollDuration);
+                    viewTravelCount = firstPos - position + 1;
+                } else if (position > lastPos) {
+                    viewTravelCount = position - lastPos;
+                }
+
+                // Estimate how many screens we should travel
+                final float screenTravelCount = (float) viewTravelCount / childCount;
+
+                final float modifier = Math.min(Math.abs(screenTravelCount), 1.f);
+                if (position < firstPos) {
+                    smoothScrollBy((int) (-getHeight() * modifier), mScrollDuration);
                     post(this);
                 } else if (position > lastPos) {
-                    smoothScrollBy(getHeight(), mScrollDuration);
+                    smoothScrollBy((int) (getHeight() * modifier), mScrollDuration);
                     post(this);
                 } else {
                     // On-screen, just scroll.
@@ -4067,12 +4098,26 @@
         if (mFlingRunnable == null) {
             mFlingRunnable = new FlingRunnable();
         }
+
         // No sense starting to scroll if we're not going anywhere
-        if (distance != 0) {
+        final int firstPos = mFirstPosition;
+        final int childCount = getChildCount();
+        final int lastPos = firstPos + childCount;
+        final int topLimit = getPaddingTop();
+        final int bottomLimit = getHeight() - getPaddingBottom();
+
+        if (distance == 0 ||
+                firstPos == INVALID_POSITION ||
+                (firstPos == 0 && getChildAt(0).getTop() == topLimit && distance < 0) ||
+                (lastPos == mItemCount - 1 &&
+                        getChildAt(childCount - 1).getBottom() == bottomLimit && distance > 0)) {
+            mFlingRunnable.endFling();
+            if (mPositionScroller != null) {
+                mPositionScroller.stop();
+            }
+        } else {
             reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
             mFlingRunnable.startScroll(distance, duration);
-        } else {
-            mFlingRunnable.endFling();
         }
     }
 
@@ -4519,7 +4564,9 @@
 
         mResurrectToPosition = INVALID_POSITION;
         removeCallbacks(mFlingRunnable);
-        removeCallbacks(mPositionScroller);
+        if (mPositionScroller != null) {
+            mPositionScroller.stop();
+        }
         mTouchMode = TOUCH_MODE_REST;
         clearScrollingCache();
         mSpecificTop = selectedTop;
diff --git a/core/java/android/widget/QuickContactBadge.java b/core/java/android/widget/QuickContactBadge.java
index bc89507..5f3d21f 100644
--- a/core/java/android/widget/QuickContactBadge.java
+++ b/core/java/android/widget/QuickContactBadge.java
@@ -112,6 +112,16 @@
         mBadgeBackground = getBackground();
     }
 
+    @Override
+    protected void drawableStateChanged() {
+        super.drawableStateChanged();
+        Drawable d = mOverlay;
+        if (d != null && d.isStateful()) {
+            d.setState(getDrawableState());
+            invalidate();
+        }
+    }
+
     private void init() {
         mQueryHandler = new QueryHandler(mContext.getContentResolver());
         setOnClickListener(this);
@@ -130,7 +140,8 @@
     protected void onDraw(Canvas canvas) {
         super.onDraw(canvas);
 
-        if (mOverlay == null || mOverlay.getIntrinsicWidth() == 0 || mOverlay.getIntrinsicHeight() == 0) {
+        if (mOverlay == null || mOverlay.getIntrinsicWidth() == 0 ||
+                mOverlay.getIntrinsicHeight() == 0) {
             return; // nothing to draw
         }
 
diff --git a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
index 2dba67b..5a3e2b1 100644
--- a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 5ff6212..d86c9e2 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -94,13 +94,6 @@
          included in the system image. Third-party apps cannot use it.</em> -->
     <attr name="allowClearUserData" format="boolean" />
 
-    <!-- Option to let applications specify that user data should
-         never be encrypted if an Encrypted File System solution
-         is enabled. Specifically, this is an "opt-out" feature, meaning
-         that, by default, user data will be encrypted if the EFS feature
-         is enabled. -->
-    <attr name="neverEncrypt" format="boolean" />
-
     <!-- Option to indicate this application is only for testing purposes.
          For example, it may expose functionality or data outside of itself
          that would cause a security hole, but is useful for testing.  This
@@ -777,7 +770,6 @@
         <attr name="killAfterRestore" />
         <attr name="restoreNeedsApplication" />
         <attr name="restoreAnyVersion" />
-        <attr name="neverEncrypt" />
         <!-- Declare that this applicationn can't participate in the normal
              state save/restore mechanism.  Since it is not able to save and
              restore its state on demand,
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 6b309e1..b15121a 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -479,26 +479,67 @@
         mBitmapOptions.inScaled = false;
     }
 
-    static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mc, int usage) {
+    /**
+     *
+     * @param type renderscript type describing data layout
+     * @param mips specifies desired mipmap behaviour for the
+     *             allocation
+     * @param usage bit field specifying how the allocation is
+     *              utilized
+     */
+    static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) {
         rs.validate();
         if (type.getID() == 0) {
             throw new RSInvalidStateException("Bad Type");
         }
-        int id = rs.nAllocationCreateTyped(type.getID(), mc.mID, usage);
+        int id = rs.nAllocationCreateTyped(type.getID(), mips.mID, usage);
         if (id == 0) {
             throw new RSRuntimeException("Allocation creation failed.");
         }
         return new Allocation(id, rs, type, usage);
     }
 
+    /**
+     * Creates a renderscript allocation with the size specified by
+     * the type and no mipmaps generated by default
+     *
+     * @param rs
+     * @param type renderscript type describing data layout
+     * @param usage bit field specifying how the allocation is
+     *              utilized
+     *
+     * @return allocation
+     */
     static public Allocation createTyped(RenderScript rs, Type type, int usage) {
         return createTyped(rs, type, MipmapControl.MIPMAP_NONE, usage);
     }
 
+    /**
+     * Creates a renderscript allocation for use by the script with
+     * the size specified by the type and no mipmaps generated by
+     * default
+     *
+     * @param rs
+     * @param type renderscript type describing data layout
+     *
+     * @return allocation
+     */
     static public Allocation createTyped(RenderScript rs, Type type) {
         return createTyped(rs, type, MipmapControl.MIPMAP_NONE, USAGE_SCRIPT);
     }
 
+    /**
+     * Creates a renderscript allocation with a specified number of
+     * given elements
+     *
+     * @param rs
+     * @param e describes what each element of an allocation is
+     * @param count specifies the number of element in the allocation
+     * @param usage bit field specifying how the allocation is
+     *              utilized
+     *
+     * @return allocation
+     */
     static public Allocation createSized(RenderScript rs, Element e,
                                          int count, int usage) {
         rs.validate();
@@ -513,6 +554,16 @@
         return new Allocation(id, rs, t, usage);
     }
 
+    /**
+     * Creates a renderscript allocation with a specified number of
+     * given elements
+     *
+     * @param rs
+     * @param e describes what each element of an allocation is
+     * @param count specifies the number of element in the allocation
+     *
+     * @return allocation
+     */
     static public Allocation createSized(RenderScript rs, Element e, int count) {
         return createSized(rs, e, count, USAGE_SCRIPT);
     }
@@ -544,6 +595,19 @@
         return tb.create();
     }
 
+    /**
+     * Creates a renderscript allocation from a bitmap
+     *
+     * @param rs
+     * @param b bitmap source for the allocation data
+     * @param mips specifies desired mipmap behaviour for the
+     *             allocation
+     * @param usage bit field specifying how the allocation is
+     *              utilized
+     *
+     * @return renderscript allocation containing bitmap data
+     *
+     */
     static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
                                               MipmapControl mips,
                                               int usage) {
@@ -557,23 +621,35 @@
         return new Allocation(id, rs, t, usage);
     }
 
+    /**
+     * Creates a non-mipmapped renderscript allocation to use as a
+     * graphics texture
+     *
+     * @param rs
+     * @param b bitmap source for the allocation data
+     *
+     * @return renderscript allocation containing bitmap data
+     *
+     */
     static public Allocation createFromBitmap(RenderScript rs, Bitmap b) {
         return createFromBitmap(rs, b, MipmapControl.MIPMAP_NONE,
                                 USAGE_GRAPHICS_TEXTURE);
     }
 
     /**
-    * Creates a cubemap allocation from a bitmap containing the
-    * horizontal list of cube faces. Each individual face must be
-    * the same size and power of 2
-    *
-    * @param rs
-    * @param b bitmap with cubemap faces layed out in the following
-    *          format: right, left, top, bottom, front, back
-    * @param mips specifies desired mipmap behaviour for the cubemap
-    * @param usage bitfield specifying how the cubemap is utilized
-    *
-    **/
+     * Creates a cubemap allocation from a bitmap containing the
+     * horizontal list of cube faces. Each individual face must be
+     * the same size and power of 2
+     *
+     * @param rs
+     * @param b bitmap with cubemap faces layed out in the following
+     *          format: right, left, top, bottom, front, back
+     * @param mips specifies desired mipmap behaviour for the cubemap
+     * @param usage bit field specifying how the cubemap is utilized
+     *
+     * @return allocation containing cubemap data
+     *
+     */
     static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
                                                      MipmapControl mips,
                                                      int usage) {
@@ -608,12 +684,43 @@
         return new Allocation(id, rs, t, usage);
     }
 
+    /**
+     * Creates a non-mipmapped cubemap allocation for use as a
+     * graphics texture from a bitmap containing the horizontal list
+     * of cube faces. Each individual face must be the same size and
+     * power of 2
+     *
+     * @param rs
+     * @param b bitmap with cubemap faces layed out in the following
+     *          format: right, left, top, bottom, front, back
+     *
+     * @return allocation containing cubemap data
+     *
+     */
     static public Allocation createCubemapFromBitmap(RenderScript rs,
                                                      Bitmap b) {
         return createCubemapFromBitmap(rs, b, MipmapControl.MIPMAP_NONE,
                                        USAGE_GRAPHICS_TEXTURE);
     }
 
+    /**
+     * Creates a cubemap allocation from 6 bitmaps containing
+     * the cube faces. All the faces must be the same size and
+     * power of 2
+     *
+     * @param rs
+     * @param xpos cubemap face in the positive x direction
+     * @param xneg cubemap face in the negative x direction
+     * @param ypos cubemap face in the positive y direction
+     * @param yneg cubemap face in the negative y direction
+     * @param zpos cubemap face in the positive z direction
+     * @param zneg cubemap face in the negative z direction
+     * @param mips specifies desired mipmap behaviour for the cubemap
+     * @param usage bit field specifying how the cubemap is utilized
+     *
+     * @return allocation containing cubemap data
+     *
+     */
     static public Allocation createCubemapFromCubeFaces(RenderScript rs,
                                                         Bitmap xpos,
                                                         Bitmap xneg,
@@ -663,6 +770,23 @@
         return cubemap;
     }
 
+    /**
+     * Creates a non-mipmapped cubemap allocation for use as a
+     * graphics texture from 6 bitmaps containing
+     * the cube faces. All the faces must be the same size and
+     * power of 2
+     *
+     * @param rs
+     * @param xpos cubemap face in the positive x direction
+     * @param xneg cubemap face in the negative x direction
+     * @param ypos cubemap face in the positive y direction
+     * @param yneg cubemap face in the negative y direction
+     * @param zpos cubemap face in the positive z direction
+     * @param zneg cubemap face in the negative z direction
+     *
+     * @return allocation containing cubemap data
+     *
+     */
     static public Allocation createCubemapFromCubeFaces(RenderScript rs,
                                                         Bitmap xpos,
                                                         Bitmap xneg,
@@ -675,6 +799,21 @@
                                           USAGE_GRAPHICS_TEXTURE);
     }
 
+    /**
+     * Creates a renderscript allocation from the bitmap referenced
+     * by resource id
+     *
+     * @param rs
+     * @param res application resources
+     * @param id resource id to load the data from
+     * @param mips specifies desired mipmap behaviour for the
+     *             allocation
+     * @param usage bit field specifying how the allocation is
+     *              utilized
+     *
+     * @return renderscript allocation containing resource data
+     *
+     */
     static public Allocation createFromBitmapResource(RenderScript rs,
                                                       Resources res,
                                                       int id,
@@ -688,6 +827,17 @@
         return alloc;
     }
 
+    /**
+     * Creates a non-mipmapped renderscript allocation to use as a
+     * graphics texture from the bitmap referenced by resource id
+     *
+     * @param rs
+     * @param res application resources
+     * @param id resource id to load the data from
+     *
+     * @return renderscript allocation containing resource data
+     *
+     */
     static public Allocation createFromBitmapResource(RenderScript rs,
                                                       Resources res,
                                                       int id) {
@@ -696,6 +846,16 @@
                                         USAGE_GRAPHICS_TEXTURE);
     }
 
+    /**
+     * Creates a renderscript allocation containing string data
+     * encoded in UTF-8 format
+     *
+     * @param rs
+     * @param str string to create the allocation from
+     * @param usage bit field specifying how the allocaiton is
+     *              utilized
+     *
+     */
     static public Allocation createFromString(RenderScript rs,
                                               String str,
                                               int usage) {
diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java
index 0e2227e..d79900e 100644
--- a/graphics/java/android/renderscript/ProgramStore.java
+++ b/graphics/java/android/renderscript/ProgramStore.java
@@ -22,16 +22,61 @@
 
 
 /**
+ * ProgarmStore contains a set of parameters that control how
+ * the graphics hardware handles writes to the framebuffer.
+ *
+ * It could be used to:
+ *   - enable/diable depth testing
+ *   - specify wheather depth writes are performed
+ *   - setup various blending modes for use in effects like
+ *     transparency
+ *   - define write masks for color components written into the
+ *     framebuffer
  *
  **/
 public class ProgramStore extends BaseObj {
+    /**
+    * Specifies the function used to determine whether a fragment
+    * will be drawn during the depth testing stage in the rendering
+    * pipeline by comparing its value with that already in the depth
+    * buffer. DepthFunc is only valid when depth buffer is present
+    * and depth testing is enabled
+    */
     public enum DepthFunc {
+
+        /**
+        * Always drawn
+        */
         ALWAYS (0),
+        /**
+        * Drawn if the incoming depth value is less than that in the
+        * depth buffer
+        */
         LESS (1),
+        /**
+        * Drawn if the incoming depth value is less or equal to that in
+        * the depth buffer
+        */
         LESS_OR_EQUAL (2),
+        /**
+        * Drawn if the incoming depth value is greater than that in the
+        * depth buffer
+        */
         GREATER (3),
+        /**
+        * Drawn if the incoming depth value is greater or equal to that
+        * in the depth buffer
+        */
         GREATER_OR_EQUAL (4),
+        /**
+        * Drawn if the incoming depth value is equal to that in the
+        * depth buffer
+        */
         EQUAL (5),
+        /**
+        * Drawn if the incoming depth value is not equal to that in the
+        * depth buffer
+        */
         NOT_EQUAL (6);
 
         int mID;
@@ -40,6 +85,14 @@
         }
     }
 
+    /**
+    * Specifies the functions used to combine incoming pixels with
+    * those already in the frame buffer.
+    *
+    * BlendSrcFunc describes how the coefficient used to scale the
+    * source pixels during the blending operation is computed
+    *
+    */
     public enum BlendSrcFunc {
         ZERO (0),
         ONE (1),
@@ -57,6 +110,15 @@
         }
     }
 
+    /**
+    * Specifies the functions used to combine incoming pixels with
+    * those already in the frame buffer.
+    *
+    * BlendDstFunc describes how the coefficient used to scale the
+    * pixels already in the framebuffer is computed during the
+    * blending operation
+    *
+    */
     public enum BlendDstFunc {
         ZERO (0),
         ONE (1),
@@ -78,6 +140,17 @@
         super(id, rs);
     }
 
+    /**
+    * Returns a pre-defined program store object with the following
+    * characteristics:
+    *  - incoming pixels are drawn if their depth value is less than
+    *    the stored value in the depth buffer. If the pixel is
+    *    drawn, its value is also stored in the depth buffer
+    *  - incoming pixels override the value stored in the color
+    *    buffer if it passes the depth test
+    *
+    *  @param rs
+    **/
     public static ProgramStore BLEND_NONE_DEPTH_TEST(RenderScript rs) {
         if(rs.mProgramStore_BLEND_NONE_DEPTH_TEST == null) {
             ProgramStore.Builder builder = new ProgramStore.Builder(rs);
@@ -89,6 +162,16 @@
         }
         return rs.mProgramStore_BLEND_NONE_DEPTH_TEST;
     }
+    /**
+    * Returns a pre-defined program store object with the following
+    * characteristics:
+    *  - incoming pixels always pass the depth test and their value
+    *    is not stored in the depth buffer
+    *  - incoming pixels override the value stored in the color
+    *    buffer
+    *
+    *  @param rs
+    **/
     public static ProgramStore BLEND_NONE_DEPTH_NONE(RenderScript rs) {
         if(rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH == null) {
             ProgramStore.Builder builder = new ProgramStore.Builder(rs);
@@ -100,7 +183,19 @@
         }
         return rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH;
     }
-
+    /**
+    * Returns a pre-defined program store object with the following
+    * characteristics:
+    *  - incoming pixels are drawn if their depth value is less than
+    *    the stored value in the depth buffer. If the pixel is
+    *    drawn, its value is also stored in the depth buffer
+    *  - if the incoming (Source) pixel passes depth test, its value
+    *    is combined with the stored color (Dest) using the
+    *    following formula
+    *  Final.RGB = Source.RGB * Source.A + Dest.RGB * (1 - Source.A)
+    *
+    *  @param rs
+    **/
     public static ProgramStore BLEND_ALPHA_DEPTH_TEST(RenderScript rs) {
         if(rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST == null) {
             ProgramStore.Builder builder = new ProgramStore.Builder(rs);
@@ -112,6 +207,17 @@
         }
         return rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST;
     }
+    /**
+    * Returns a pre-defined program store object with the following
+    * characteristics:
+    *  - incoming pixels always pass the depth test and their value
+    *    is not stored in the depth buffer
+    *  - incoming pixel's value is combined with the stored color
+    *    (Dest) using the following formula
+    *  Final.RGB = Source.RGB * Source.A + Dest.RGB * (1 - Source.A)
+    *
+    *  @param rs
+    **/
     public static ProgramStore BLEND_ALPHA_DEPTH_NONE(RenderScript rs) {
         if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH == null) {
             ProgramStore.Builder builder = new ProgramStore.Builder(rs);
@@ -124,6 +230,11 @@
         return rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH;
     }
 
+    /**
+    * Builder class for ProgramStore object. If the builder is left
+    * empty, the equivalent of BLEND_NONE_DEPTH_NONE would be
+    * returned
+    */
     public static class Builder {
         RenderScript mRS;
         DepthFunc mDepthFunc;
@@ -148,16 +259,41 @@
             mBlendDst = BlendDstFunc.ZERO;
         }
 
+        /**
+        * Specifies the depth testing behavior
+        *
+        * @param func function used for depth testing
+        *
+        * @return this
+        */
         public Builder setDepthFunc(DepthFunc func) {
             mDepthFunc = func;
             return this;
         }
 
+        /**
+        * Enables writes into the depth buffer
+        *
+        * @param enable specifies whether depth writes are
+        *         enabled or disabled
+        *
+        * @return this
+        */
         public Builder setDepthMaskEnabled(boolean enable) {
             mDepthMask = enable;
             return this;
         }
 
+        /**
+        * Enables writes into the color buffer
+        *
+        * @param r specifies whether red channel is written
+        * @param g specifies whether green channel is written
+        * @param b specifies whether blue channel is written
+        * @param a specifies whether alpha channel is written
+        *
+        * @return this
+        */
         public Builder setColorMaskEnabled(boolean r, boolean g, boolean b, boolean a) {
             mColorMaskR = r;
             mColorMaskG = g;
@@ -166,12 +302,31 @@
             return this;
         }
 
+        /**
+        * Specifies how incoming pixels are combined with the pixels
+        * stored in the framebuffer
+        *
+        * @param src specifies how the source blending factor is
+        *            computed
+        * @param dst specifies how the destination blending factor is
+        *            computed
+        *
+        * @return this
+        */
         public Builder setBlendFunc(BlendSrcFunc src, BlendDstFunc dst) {
             mBlendSrc = src;
             mBlendDst = dst;
             return this;
         }
 
+        /**
+        * Enables dithering
+        *
+        * @param enable specifies whether dithering is enabled or
+        *               disabled
+        *
+        * @return this
+        */
         public Builder setDitherEnabled(boolean enable) {
             mDither = enable;
             return this;
@@ -192,6 +347,9 @@
             return new ProgramStore(id, rs);
         }
 
+        /**
+        * Creates a program store from the current state of the builder
+        */
         public ProgramStore create() {
             mRS.validate();
             return internalCreate(mRS, this);
diff --git a/include/storage/IMountService.h b/include/storage/IMountService.h
index 68ccd95..472d8e5 100644
--- a/include/storage/IMountService.h
+++ b/include/storage/IMountService.h
@@ -67,6 +67,7 @@
     virtual bool isObbMounted(const String16& filename) = 0;
     virtual bool getMountedObbPath(const String16& filename, String16& path) = 0;
     virtual int32_t decryptStorage(const String16& password) = 0;
+    virtual int32_t encryptStorage(const String16& password) = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk
index c2e58b6..d8d70c6 100644
--- a/libs/rs/Android.mk
+++ b/libs/rs/Android.mk
@@ -27,6 +27,10 @@
 input_data_file := $(LOCAL_PATH)/rslib.bc
 slangdata_output_var_name := rs_runtime_lib_bc
 LOCAL_MODULE := librslib_rt
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+
 LOCAL_MODULE_TAGS := optional
 include frameworks/compile/slang/SlangData.mk
 include $(BUILD_STATIC_LIBRARY)
diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
index e5900fd..aa4cf2d 100644
--- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
+++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
@@ -55,6 +55,9 @@
     gamma = (float3)g;
 }
 
+//sliao
+uchar3 convert2uchar3(float3 xyz);
+
 void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
     uchar4 *output = (uchar4 *)v_out;
     const FilterStruct *fs = (const FilterStruct *)usrData;
@@ -84,7 +87,7 @@
         temp = pow(temp, (float3)gamma);
     temp = clamp(temp * outWMinOutB + outBlack, 0.f, 255.f);
 
-    output->xyz = convert_uchar3(temp);
+    output->xyz = convert2uchar3(temp);
     //output->w = input->w;
 }
 
diff --git a/libs/rs/rslib.bc b/libs/rs/rslib.bc
index 1897c3b..761e765 100644
--- a/libs/rs/rslib.bc
+++ b/libs/rs/rslib.bc
Binary files differ
diff --git a/libs/storage/IMountService.cpp b/libs/storage/IMountService.cpp
index a7ab824..7fbf67a 100644
--- a/libs/storage/IMountService.cpp
+++ b/libs/storage/IMountService.cpp
@@ -49,6 +49,7 @@
     TRANSACTION_getMountedObbPath,
     TRANSACTION_isExternalStorageEmulated,
     TRANSACTION_decryptStorage,
+    TRANSACTION_encryptStorage,
 };
 
 class BpMountService: public BpInterface<IMountService>
@@ -505,7 +506,7 @@
         path = reply.readString16();
         return true;
     }
-    
+
     int32_t decryptStorage(const String16& password)
     {
         Parcel data, reply;
@@ -522,6 +523,23 @@
         }
         return reply.readInt32();
     }
+
+    int32_t encryptStorage(const String16& password)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
+        data.writeString16(password);
+        if (remote()->transact(TRANSACTION_encryptStorage, data, &reply) != NO_ERROR) {
+            LOGD("encryptStorage could not contact remote\n");
+            return -1;
+        }
+        int32_t err = reply.readExceptionCode();
+        if (err < 0) {
+            LOGD("encryptStorage caught exception %d\n", err);
+            return err;
+        }
+        return reply.readInt32();
+    }
 };
 
 IMPLEMENT_META_INTERFACE(MountService, "IMountService");
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 6b438bf..8929393 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -400,6 +400,7 @@
         private long mLastModified;
         private long mFileSize;
         private String mWriter;
+        private int mCompilation;
 
         public FileCacheEntry beginFile(String path, String mimeType, long lastModified,
                 long fileSize, boolean isDirectory) {
@@ -509,6 +510,7 @@
             mPath = path;
             mLastModified = lastModified;
             mWriter = null;
+            mCompilation = 0;
 
             return entry;
         }
@@ -620,6 +622,8 @@
                 mDuration = parseSubstring(value, 0, 0);
             } else if (name.equalsIgnoreCase("writer") || name.startsWith("writer;")) {
                 mWriter = value.trim();
+            } else if (name.equalsIgnoreCase("compilation")) {
+                mCompilation = parseSubstring(value, 0, 0);
             }
         }
 
@@ -670,6 +674,7 @@
                 }
                 map.put(Audio.Media.TRACK, mTrack);
                 map.put(Audio.Media.DURATION, mDuration);
+                map.put(Audio.Media.COMPILATION, mCompilation);
             }
             return map;
         }
diff --git a/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java b/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java
index eeafd5a..3b53194 100644
--- a/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java
+++ b/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java
@@ -28,7 +28,6 @@
 import android.net.vpn.VpnState;
 import android.os.Environment;
 import android.os.IBinder;
-import android.os.SystemProperties;
 import android.util.Log;
 
 import java.io.File;
@@ -56,7 +55,7 @@
     private static String getStateFilePath() {
         // This call will return the correcu directory whether Encrypted FS is enabled or not
         // Disabled: /data/misc/vpn/.states   Enabled: /data/secure/misc/vpn/.states
-	return Environment.getSecureDataDirectory().getPath() + STATES_FILE_RELATIVE_PATH;
+        return Environment.getDataDirectory().getPath() + STATES_FILE_RELATIVE_PATH;
     }
 
     private final IBinder mBinder = new IVpnService.Stub() {
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index cb1d775..3b0a6d5 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -16,6 +16,11 @@
 
 package com.android.server;
 
+import com.android.internal.backup.BackupConstants;
+import com.android.internal.backup.IBackupTransport;
+import com.android.internal.backup.LocalTransport;
+import com.android.server.PackageManagerBackupAgent.Metadata;
+
 import android.app.ActivityManagerNative;
 import android.app.AlarmManager;
 import android.app.AppGlobals;
@@ -23,10 +28,10 @@
 import android.app.IApplicationThread;
 import android.app.IBackupAgent;
 import android.app.PendingIntent;
-import android.app.backup.RestoreSet;
 import android.app.backup.IBackupManager;
 import android.app.backup.IRestoreObserver;
 import android.app.backup.IRestoreSession;
+import android.app.backup.RestoreSet;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -38,8 +43,8 @@
 import android.content.pm.IPackageManager;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
-import android.content.pm.Signature;
 import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.Signature;
 import android.net.Uri;
 import android.os.Binder;
 import android.os.Bundle;
@@ -61,11 +66,6 @@
 import android.util.SparseArray;
 import android.util.SparseIntArray;
 
-import com.android.internal.backup.BackupConstants;
-import com.android.internal.backup.IBackupTransport;
-import com.android.internal.backup.LocalTransport;
-import com.android.server.PackageManagerBackupAgent.Metadata;
-
 import java.io.EOFException;
 import java.io.File;
 import java.io.FileDescriptor;
@@ -145,6 +145,7 @@
             fullBackup = isFull;
         }
 
+        @Override
         public String toString() {
             return "BackupRequest{app=" + appInfo + " full=" + fullBackup + "}";
         }
@@ -271,6 +272,7 @@
             super(looper);
         }
 
+        @Override
         public void handleMessage(Message msg) {
 
             switch (msg.what) {
@@ -443,7 +445,7 @@
                 Settings.Secure.BACKUP_AUTO_RESTORE, 1) != 0;
         // If Encrypted file systems is enabled or disabled, this call will return the
         // correct directory.
-        mBaseStateDir = new File(Environment.getSecureDataDirectory(), "backup");
+        mBaseStateDir = new File(Environment.getDataDirectory(), "backup");
         mBaseStateDir.mkdirs();
         mDataDir = Environment.getDownloadCacheDirectory();
 
@@ -533,6 +535,7 @@
     }
 
     private class RunBackupReceiver extends BroadcastReceiver {
+        @Override
         public void onReceive(Context context, Intent intent) {
             if (RUN_BACKUP_ACTION.equals(intent.getAction())) {
                 synchronized (mQueueLock) {
@@ -569,6 +572,7 @@
     }
 
     private class RunInitializeReceiver extends BroadcastReceiver {
+        @Override
         public void onReceive(Context context, Intent intent) {
             if (RUN_INITIALIZE_ACTION.equals(intent.getAction())) {
                 synchronized (mQueueLock) {
@@ -812,6 +816,7 @@
 
     // ----- Track installation/removal of packages -----
     BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+        @Override
         public void onReceive(Context context, Intent intent) {
             if (DEBUG) Slog.d(TAG, "Received broadcast " + intent);
 
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index a3d8ac9..2321e30 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -849,7 +849,8 @@
                     usedNetworkType = ConnectivityManager.TYPE_MOBILE_MMS;
                 } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_SUPL)) {
                     usedNetworkType = ConnectivityManager.TYPE_MOBILE_SUPL;
-                } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN)) {
+                } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN) ||
+                        TextUtils.equals(feature, Phone.FEATURE_ENABLE_DUN_ALWAYS)) {
                     usedNetworkType = ConnectivityManager.TYPE_MOBILE_DUN;
                 } else if (TextUtils.equals(feature, Phone.FEATURE_ENABLE_HIPRI)) {
                     usedNetworkType = ConnectivityManager.TYPE_MOBILE_HIPRI;
@@ -870,6 +871,8 @@
                     return 1;
                 }
                 callTeardown = true;
+            } else {
+                if (DBG) log("not a known feature - dropping");
             }
         }
         if (DBG) log("Doing network teardown");
diff --git a/services/java/com/android/server/Installer.java b/services/java/com/android/server/Installer.java
index 85eca60..1028b89 100644
--- a/services/java/com/android/server/Installer.java
+++ b/services/java/com/android/server/Installer.java
@@ -17,16 +17,13 @@
 package com.android.server;
 
 import android.content.pm.PackageStats;
-import android.net.LocalSocketAddress;
 import android.net.LocalSocket;
-import android.util.Config;
+import android.net.LocalSocketAddress;
 import android.util.Slog;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.Socket;
-
 
 class Installer {
     private static final String TAG = "Installer";
@@ -101,7 +98,7 @@
 		int len;
 		buflen = 0;
 		if (!readBytes(buf, 2)) return false;
-		len = (((int) buf[0]) & 0xff) | ((((int) buf[1]) & 0xff) << 8);
+		len = ((buf[0]) & 0xff) | (((buf[1]) & 0xff) << 8);
 		if ((len < 1) || (len > 1024)) {
             Slog.e(TAG,"invalid reply length ("+len+")");
 			disconnect();
@@ -166,17 +163,11 @@
 		}
 	}
 
-    public int install(String name, boolean useEncryptedFilesystem, int uid, int gid) {
+    public int install(String name, int uid, int gid) {
         StringBuilder builder = new StringBuilder("install");
         builder.append(' ');
         builder.append(name);
         builder.append(' ');
-        if (useEncryptedFilesystem) {
-            builder.append('1');
-        } else {
-            builder.append('0');
-        }
-        builder.append(' ');
         builder.append(uid);
         builder.append(' ');
         builder.append(gid);
@@ -209,57 +200,34 @@
         return execute(builder.toString());
     }
 
-    public int remove(String name, boolean useEncryptedFilesystem) {
+    public int remove(String name) {
         StringBuilder builder = new StringBuilder("remove");
         builder.append(' ');
         builder.append(name);
-        builder.append(' ');
-        if (useEncryptedFilesystem) {
-            builder.append('1');
-        } else {
-            builder.append('0');
-        }
         return execute(builder.toString());
     }
 
-    public int rename(String oldname, String newname, boolean useEncryptedFilesystem) {
+    public int rename(String oldname, String newname) {
         StringBuilder builder = new StringBuilder("rename");
         builder.append(' ');
         builder.append(oldname);
         builder.append(' ');
         builder.append(newname);
-        builder.append(' ');
-        if (useEncryptedFilesystem) {
-            builder.append('1');
-        } else {
-            builder.append('0');
-        }
         return execute(builder.toString());
     }
 
-    public int deleteCacheFiles(String name, boolean useEncryptedFilesystem) {
+    public int deleteCacheFiles(String name) {
         StringBuilder builder = new StringBuilder("rmcache");
         builder.append(' ');
         builder.append(name);
         builder.append(' ');
-        if (useEncryptedFilesystem) {
-            builder.append('1');
-        } else {
-            builder.append('0');
-        }
         return execute(builder.toString());
     }
     
-    public int clearUserData(String name, boolean useEncryptedFilesystem) {
+    public int clearUserData(String name) {
         StringBuilder builder = new StringBuilder("rmuserdata");
         builder.append(' ');
         builder.append(name);
-        builder.append(' ');
-        if (useEncryptedFilesystem) {
-            builder.append('1');
-        } else {
-            builder.append('0');
-        }
         return execute(builder.toString());
     }
     
@@ -292,8 +260,8 @@
         return execute(builder.toString());
     }
     
-    public int getSizeInfo(String pkgName, String apkPath,
-            String fwdLockApkPath, PackageStats pStats, boolean useEncryptedFilesystem) {
+    public int getSizeInfo(String pkgName, String apkPath, String fwdLockApkPath,
+            PackageStats pStats) {
         StringBuilder builder = new StringBuilder("getsize");
         builder.append(' ');
         builder.append(pkgName);
@@ -301,12 +269,6 @@
         builder.append(apkPath);
         builder.append(' ');
         builder.append(fwdLockApkPath != null ? fwdLockApkPath : "!");
-        builder.append(' ');
-        if (useEncryptedFilesystem) {
-            builder.append('1');
-        } else {
-            builder.append('0');
-        }
 
         String s = transaction(builder.toString());
         String res[] = s.split(" ");
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index bf81457..d6804f9 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -1653,6 +1653,29 @@
         return 0;
     }
 
+    public int encryptStorage(String password) {
+        if (password == null) {
+            throw new IllegalArgumentException("password cannot be null");
+        }
+
+        // TODO: Enforce a permission
+
+        waitForReady();
+
+        if (DEBUG_EVENTS) {
+            Slog.i(TAG, "decrypting storage...");
+        }
+
+        try {
+            mConnector.doCommand(String.format("cryptfs enablecrypto wipe %s", password));
+        } catch (NativeDaemonConnectorException e) {
+            // Encryption failed
+            return e.getCode();
+        }
+
+        return 0;
+    }
+
     private void addObbStateLocked(ObbState obbState) throws RemoteException {
         final IBinder binder = obbState.getBinder();
         List<ObbState> obbStates = mObbMounts.get(binder);
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index b196f74..286463d 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -16,6 +16,10 @@
 
 package com.android.server;
 
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+
 import com.android.internal.app.IMediaContainerService;
 import com.android.internal.app.ResolverActivity;
 import com.android.internal.content.NativeLibraryHelper;
@@ -24,22 +28,18 @@
 import com.android.internal.util.JournaledFile;
 import com.android.internal.util.XmlUtils;
 
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlSerializer;
-
 import android.app.ActivityManagerNative;
 import android.app.IActivityManager;
 import android.app.admin.IDevicePolicyManager;
 import android.app.backup.IBackupManager;
-import android.content.Context;
 import android.content.ComponentName;
+import android.content.Context;
 import android.content.IIntentReceiver;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.IntentSender;
-import android.content.ServiceConnection;
 import android.content.IntentSender.SendIntentException;
+import android.content.ServiceConnection;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.ComponentInfo;
@@ -54,13 +54,10 @@
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageInfoLite;
 import android.content.pm.PackageManager;
-import android.content.pm.PackageStats;
-import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
-import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
-import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
 import android.content.pm.PackageParser;
-import android.content.pm.PermissionInfo;
+import android.content.pm.PackageStats;
 import android.content.pm.PermissionGroupInfo;
+import android.content.pm.PermissionInfo;
 import android.content.pm.ProviderInfo;
 import android.content.pm.ResolveInfo;
 import android.content.pm.ServiceInfo;
@@ -70,24 +67,30 @@
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Debug;
+import android.os.Environment;
+import android.os.FileObserver;
+import android.os.FileUtils;
+import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.IBinder;
 import android.os.Looper;
 import android.os.Message;
 import android.os.Parcel;
-import android.os.RemoteException;
-import android.os.Environment;
-import android.os.FileObserver;
-import android.os.FileUtils;
-import android.os.Handler;
 import android.os.ParcelFileDescriptor;
 import android.os.Process;
+import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.SystemClock;
 import android.os.SystemProperties;
-import android.provider.Settings;
 import android.security.SystemKeyStore;
-import android.util.*;
+import android.util.Config;
+import android.util.DisplayMetrics;
+import android.util.EventLog;
+import android.util.Log;
+import android.util.LogPrinter;
+import android.util.Slog;
+import android.util.SparseArray;
+import android.util.Xml;
 import android.view.Display;
 import android.view.WindowManager;
 
@@ -114,15 +117,17 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipOutputStream;
 
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
 /**
  * Keep track of all those .apks everywhere.
  * 
@@ -430,6 +435,7 @@
             super(looper);
         }
         
+        @Override
         public void handleMessage(Message msg) {
             try {
                 doHandleMessage(msg);
@@ -571,7 +577,7 @@
                     // Send broadcasts
                     for (int i = 0; i < size; i++) {
                         sendPackageChangedBroadcast(packages[i], true,
-                                (ArrayList<String>)components[i], uids[i]);
+                                components[i], uids[i]);
                     }
                     Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
                     break;
@@ -964,9 +970,7 @@
                             + " no longer exists; wiping its data";
                     reportSettingsProblem(Log.WARN, msg);
                     if (mInstaller != null) {
-                        // XXX how to set useEncryptedFSDir for packages that
-                        // are not encrypted?
-                        mInstaller.remove(ps.name, true);
+                            mInstaller.remove(ps.name);
                     }
                 }
             }
@@ -1050,8 +1054,7 @@
     void cleanupInstallFailedPackage(PackageSetting ps) {
         Slog.i(TAG, "Cleaning up incompletely installed app: " + ps.name);
         if (mInstaller != null) {
-            boolean useSecureFS = useEncryptedFilesystemForPackage(ps.pkg);
-            int retCode = mInstaller.remove(ps.name, useSecureFS);
+            int retCode = mInstaller.remove(ps.name);
             if (retCode < 0) {
                 Slog.w(TAG, "Couldn't remove app data directory for package: "
                            + ps.name + ", retcode=" + retCode);
@@ -2079,12 +2082,12 @@
         synchronized (mPackages) {
             String pkgName = intent.getPackage();
             if (pkgName == null) {
-                return (List<ResolveInfo>)mActivities.queryIntent(intent,
+                return mActivities.queryIntent(intent,
                         resolvedType, flags);
             }
             PackageParser.Package pkg = mPackages.get(pkgName);
             if (pkg != null) {
-                return (List<ResolveInfo>) mActivities.queryIntentForPackage(intent,
+                return mActivities.queryIntentForPackage(intent,
                         resolvedType, flags, pkg.activities);
             }
             return null;
@@ -2269,12 +2272,12 @@
         synchronized (mPackages) {
             String pkgName = intent.getPackage();
             if (pkgName == null) {
-                return (List<ResolveInfo>)mReceivers.queryIntent(intent,
+                return mReceivers.queryIntent(intent,
                         resolvedType, flags);
             }
             PackageParser.Package pkg = mPackages.get(pkgName);
             if (pkg != null) {
-                return (List<ResolveInfo>) mReceivers.queryIntentForPackage(intent,
+                return mReceivers.queryIntentForPackage(intent,
                         resolvedType, flags, pkg.receivers);
             }
             return null;
@@ -2312,12 +2315,12 @@
         synchronized (mPackages) {
             String pkgName = intent.getPackage();
             if (pkgName == null) {
-                return (List<ResolveInfo>)mServices.queryIntent(intent,
+                return mServices.queryIntent(intent,
                         resolvedType, flags);
             }
             PackageParser.Package pkg = mPackages.get(pkgName);
             if (pkg != null) {
-                return (List<ResolveInfo>)mServices.queryIntentForPackage(intent,
+                return mServices.queryIntentForPackage(intent,
                         resolvedType, flags, pkg.services);
             }
             return null;
@@ -2416,6 +2419,7 @@
     /**
      * @deprecated
      */
+    @Deprecated
     public void querySyncProviders(List outNames, List outInfo) {
         synchronized (mPackages) {
             Iterator<Map.Entry<String, PackageParser.Provider>> i
@@ -2780,11 +2784,6 @@
         return performed ? DEX_OPT_PERFORMED : DEX_OPT_SKIPPED;
     }
 
-    private static boolean useEncryptedFilesystemForPackage(PackageParser.Package pkg) {
-        return Environment.isEncryptedFilesystemEnabled() &&
-                ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_NEVER_ENCRYPT) == 0);
-    }
-    
     private boolean verifyPackageUpdate(PackageSetting oldPkg, PackageParser.Package newPkg) {
         if ((oldPkg.pkgFlags&ApplicationInfo.FLAG_SYSTEM) == 0) {
             Slog.w(TAG, "Unable to update from " + oldPkg.name
@@ -2801,14 +2800,7 @@
     }
 
     private File getDataPathForPackage(PackageParser.Package pkg) {
-        boolean useEncryptedFSDir = useEncryptedFilesystemForPackage(pkg);
-        File dataPath;
-        if (useEncryptedFSDir) {
-            dataPath = new File(mSecureAppDataDir, pkg.packageName);
-        } else {
-            dataPath = new File(mAppDataDir, pkg.packageName);
-        }
-        return dataPath;
+        return new File(mAppDataDir, pkg.packageName);
     }
     
     private PackageParser.Package scanPackageLI(PackageParser.Package pkg,
@@ -3157,7 +3149,6 @@
             pkg.applicationInfo.dataDir = dataPath.getPath();
         } else {
             // This is a normal package, need to make its data directory.
-            boolean useEncryptedFSDir = useEncryptedFilesystemForPackage(pkg);
             dataPath = getDataPathForPackage(pkg);
             
             boolean uidError = false;
@@ -3174,7 +3165,7 @@
                         // If this is a system app, we can at least delete its
                         // current data so the application will still work.
                         if (mInstaller != null) {
-                            int ret = mInstaller.remove(pkgName, useEncryptedFSDir);
+                            int ret = mInstaller.remove(pkgName);
                             if (ret >= 0) {
                                 // Old data gone!
                                 String msg = "System package " + pkg.packageName
@@ -3185,7 +3176,7 @@
                                 recovered = true;
 
                                 // And now re-install the app.
-                                ret = mInstaller.install(pkgName, useEncryptedFSDir, pkg.applicationInfo.uid,
+                                ret = mInstaller.install(pkgName, pkg.applicationInfo.uid,
                                         pkg.applicationInfo.uid);
                                 if (ret == -1) {
                                     // Ack should not happen!
@@ -3226,7 +3217,7 @@
                     Log.v(TAG, "Want this data dir: " + dataPath);
                 //invoke installer to do the actual installation
                 if (mInstaller != null) {
-                    int ret = mInstaller.install(pkgName, useEncryptedFSDir, pkg.applicationInfo.uid,
+                    int ret = mInstaller.install(pkgName, pkg.applicationInfo.uid,
                             pkg.applicationInfo.uid);
                     if(ret < 0) {
                         // Error from installer
@@ -4047,6 +4038,7 @@
     
     private final class ActivityIntentResolver
             extends IntentResolver<PackageParser.ActivityIntentInfo, ResolveInfo> {
+        @Override
         public List queryIntent(Intent intent, String resolvedType, boolean defaultOnly) {
             mFlags = defaultOnly ? PackageManager.MATCH_DEFAULT_ONLY : 0;
             return super.queryIntent(intent, resolvedType, defaultOnly);
@@ -4206,6 +4198,7 @@
 
     private final class ServiceIntentResolver
             extends IntentResolver<PackageParser.ServiceIntentInfo, ResolveInfo> {
+        @Override
         public List queryIntent(Intent intent, String resolvedType, boolean defaultOnly) {
             mFlags = defaultOnly ? PackageManager.MATCH_DEFAULT_ONLY : 0;
             return super.queryIntent(intent, resolvedType, defaultOnly);
@@ -4301,7 +4294,7 @@
         @Override
         protected ResolveInfo newResult(PackageParser.ServiceIntentInfo filter,
                 int match) {
-            final PackageParser.ServiceIntentInfo info = (PackageParser.ServiceIntentInfo)filter;
+            final PackageParser.ServiceIntentInfo info = filter;
             if (!mSettings.isEnabledLP(info.service.info, mFlags)) {
                 return null;
             }
@@ -4462,6 +4455,7 @@
             mIsRom = isrom;
         }
 
+        @Override
         public void onEvent(int event, String path) {
             String removedPackage = null;
             int removedUid = -1;
@@ -4846,6 +4840,7 @@
          * policy if needed and then create install arguments based
          * on the install location.
          */
+        @Override
         public void handleStartCopy() throws RemoteException {
             int ret = PackageManager.INSTALL_SUCCEEDED;
             boolean fwdLocked = (flags & PackageManager.INSTALL_FORWARD_LOCK) != 0;
@@ -4955,6 +4950,7 @@
             }
         }
 
+        @Override
         public void handleStartCopy() throws RemoteException {
             mRet = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
             // Check for storage space on target medium
@@ -5084,6 +5080,7 @@
             libraryPath = new File(dataDir, LIB_DIR_NAME).getPath();
         }
 
+        @Override
         boolean checkFreeStorage(IMediaContainerService imcs) throws RemoteException {
             try {
                 mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
@@ -5094,10 +5091,12 @@
             }
         }
 
+        @Override
         String getCodePath() {
             return codeFileName;
         }
 
+        @Override
         void createCopyFile() {
             installDir = isFwdLocked() ? mDrmAppPrivateInstallDir : mAppInstallDir;
             codeFileName = createTempPackageFile(installDir).getPath();
@@ -5105,6 +5104,7 @@
             created = true;
         }
 
+        @Override
         int copyApk(IMediaContainerService imcs, boolean temp) throws RemoteException {
             if (temp) {
                 // Generate temp file name
@@ -5148,6 +5148,7 @@
             return ret;
         }
 
+        @Override
         int doPreInstall(int status) {
             if (status != PackageManager.INSTALL_SUCCEEDED) {
                 cleanUp();
@@ -5155,6 +5156,7 @@
             return status;
         }
 
+        @Override
         boolean doRename(int status, final String pkgName, String oldCodePath) {
             if (status != PackageManager.INSTALL_SUCCEEDED) {
                 cleanUp();
@@ -5179,6 +5181,7 @@
             }
         }
 
+        @Override
         int doPostInstall(int status) {
             if (status != PackageManager.INSTALL_SUCCEEDED) {
                 cleanUp();
@@ -5186,6 +5189,7 @@
             return status;
         }
 
+        @Override
         String getResourcePath() {
             return resourceFileName;
         }
@@ -5230,6 +5234,7 @@
             return ret;
         }
 
+        @Override
         void cleanUpResourcesLI() {
             String sourceDir = getCodePath();
             if (cleanUp() && mInstaller != null) {
@@ -5262,6 +5267,7 @@
             return true;
         }
 
+        @Override
         boolean doPostDeleteLI(boolean delete) {
             // XXX err, shouldn't we respect the delete flag?
             cleanUpResourcesLI();
@@ -5306,10 +5312,12 @@
             this.cid = cid;
         }
 
+        @Override
         void createCopyFile() {
             cid = getTempContainerId();
         }
 
+        @Override
         boolean checkFreeStorage(IMediaContainerService imcs) throws RemoteException {
             try {
                 mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
@@ -5320,6 +5328,7 @@
             }
         }
 
+        @Override
         int copyApk(IMediaContainerService imcs, boolean temp) throws RemoteException {
             if (temp) {
                 createCopyFile();
@@ -5358,6 +5367,7 @@
             return libraryPath;
         }
 
+        @Override
         int doPreInstall(int status) {
             if (status != PackageManager.INSTALL_SUCCEEDED) {
                 // Destroy container
@@ -5377,6 +5387,7 @@
             return status;
         }
 
+        @Override
         boolean doRename(int status, final String pkgName,
                 String oldCodePath) {
             String newCacheId = getNextCodePath(oldCodePath, pkgName, "/" + RES_FILE_NAME);
@@ -5428,6 +5439,7 @@
             packagePath = new File(cachePath, RES_FILE_NAME).getPath();
         }
 
+        @Override
         int doPostInstall(int status) {
             if (status != PackageManager.INSTALL_SUCCEEDED) {
                 cleanUp();
@@ -5446,6 +5458,7 @@
             PackageHelper.destroySdDir(cid);
         }
 
+        @Override
         void cleanUpResourcesLI() {
             String sourceFile = getCodePath();
             // Remove dex file
@@ -5476,6 +5489,7 @@
             return cid.substring(0, idx);
         }
 
+        @Override
         boolean doPostDeleteLI(boolean delete) {
             boolean ret = false;
             boolean mounted = PackageHelper.isContainerMounted(cid);
@@ -6261,9 +6275,8 @@
             deletedPs = mSettings.mPackages.get(packageName);
         }
         if ((flags&PackageManager.DONT_DELETE_DATA) == 0) {
-            boolean useEncryptedFSDir = useEncryptedFilesystemForPackage(p);
             if (mInstaller != null) {
-                int retCode = mInstaller.remove(packageName, useEncryptedFSDir);
+                int retCode = mInstaller.remove(packageName);
                 if (retCode < 0) {
                     Slog.w(TAG, "Couldn't remove app data or cache directory for package: "
                                + packageName + ", retcode=" + retCode);
@@ -6516,10 +6529,9 @@
                 Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
                 return false;
             }
-            useEncryptedFSDir = useEncryptedFilesystemForPackage(p);
         }
         if (mInstaller != null) {
-            int retCode = mInstaller.clearUserData(packageName, useEncryptedFSDir);
+            int retCode = mInstaller.clearUserData(packageName);
             if (retCode < 0) {
                 Slog.w(TAG, "Couldn't remove cache files for package: "
                         + packageName);
@@ -6570,9 +6582,8 @@
             Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
             return false;
         }
-        boolean useEncryptedFSDir = useEncryptedFilesystemForPackage(p);
         if (mInstaller != null) {
-            int retCode = mInstaller.deleteCacheFiles(packageName, useEncryptedFSDir);
+            int retCode = mInstaller.deleteCacheFiles(packageName);
             if (retCode < 0) {
                 Slog.w(TAG, "Couldn't remove cache files for package: "
                            + packageName);
@@ -6634,10 +6645,8 @@
             }
             publicSrcDir = isForwardLocked(p) ? applicationInfo.publicSourceDir : null;
         }
-        boolean useEncryptedFSDir = useEncryptedFilesystemForPackage(p);
         if (mInstaller != null) {
-            int res = mInstaller.getSizeInfo(packageName, p.mPath,
-                    publicSrcDir, pStats, useEncryptedFSDir);
+            int res = mInstaller.getSizeInfo(packageName, p.mPath, publicSrcDir, pStats);
             if (res < 0) {
                 return false;
             } else {
@@ -7443,6 +7452,7 @@
             protectionLevel = PermissionInfo.PROTECTION_SIGNATURE;
         }
         
+        @Override
         public String toString() {
             return "BasePermission{"
                 + Integer.toHexString(System.identityHashCode(this))
@@ -7739,6 +7749,7 @@
             mSetComponents = myComponents;
         }
 
+        @Override
         public void writeToXml(XmlSerializer serializer) throws IOException {
             final int NS = mSetClasses != null ? mSetClasses.length : 0;
             serializer.attribute(null, "name", mShortActivity);
@@ -7792,8 +7803,7 @@
             this.pkgFlags = pkgFlags & (
                     ApplicationInfo.FLAG_SYSTEM |
                     ApplicationInfo.FLAG_FORWARD_LOCK |
-                    ApplicationInfo.FLAG_EXTERNAL_STORAGE |
-                    ApplicationInfo.FLAG_NEVER_ENCRYPT);
+                    ApplicationInfo.FLAG_EXTERNAL_STORAGE);
         }
     }
 
@@ -7937,7 +7947,7 @@
         }
 
         public void copyFrom(PackageSetting base) {
-            super.copyFrom((PackageSettingBase) base);
+            super.copyFrom(base);
 
             userId = base.userId;
             sharedUser = base.sharedUser;
@@ -8750,7 +8760,7 @@
                         sb.setLength(0);
                         sb.append(ai.packageName);
                         sb.append(" ");
-                        sb.append((int)ai.uid);
+                        sb.append(ai.uid);
                         sb.append(isDebug ? " 1 " : " 0 ");
                         sb.append(dataPath);
                         sb.append("\n");
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index e881523..eb14180 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -43,6 +43,7 @@
 import com.android.internal.telephony.IPhoneStateListener;
 import com.android.internal.telephony.DefaultPhoneNotifier;
 import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.ServiceStateTracker;
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.server.am.BatteryStatsService;
 
@@ -103,7 +104,7 @@
 
     private int mDataConnectionNetworkType;
 
-    private int mOtaspMode;
+    private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN;
 
     static final int PHONE_STATE_PERMISSION_MASK =
                 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index fc1b2c4..134b91e 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -1165,7 +1165,7 @@
                             IConnectivityManager.Stub.asInterface(b);
                     try {
                         service.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
-                                (mDunRequired? Phone.FEATURE_ENABLE_DUN :
+                                (mDunRequired? Phone.FEATURE_ENABLE_DUN_ALWAYS :
                                              Phone.FEATURE_ENABLE_HIPRI));
                     } catch (Exception e) {
                         return false;
@@ -1354,10 +1354,11 @@
         }
 
         class TetherModeAliveState extends TetherMasterUtilState {
-            boolean mTryCell = WAIT_FOR_NETWORK_TO_SETTLE;
+            boolean mTryCell = !WAIT_FOR_NETWORK_TO_SETTLE;
             @Override
             public void enter() {
-                mTryCell = WAIT_FOR_NETWORK_TO_SETTLE;  // first pass lets just see what we have.
+                mTryCell = !WAIT_FOR_NETWORK_TO_SETTLE; // better try something first pass
+                                                        // or crazy tests cases will fail
                 chooseUpstreamType(mTryCell);
                 mTryCell = !mTryCell;
                 turnOnMasterTetherSettings(); // may transition us out
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
index 737342f..2343dd8 100644
--- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -358,7 +358,7 @@
         return new ArrayList<DataConnection>(mDataConnections.values());
     }
 
-    protected boolean isApnTypeActive(String type) {
+    public boolean isApnTypeActive(String type) {
         // TODO: support simultaneous with List instead
         return mActiveApn != null && mActiveApn.canHandleType(type);
     }
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index 1e77589..a1d5121 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -610,7 +610,8 @@
             // If we're out of service, open TCP sockets may still work
             // but no data will flow
             ret = DataState.DISCONNECTED;
-        } else if (mDataConnection.isApnTypeEnabled(apnType) == false) {
+        } else if (mDataConnection.isApnTypeEnabled(apnType) == false ||
+                mDataConnection.isApnTypeActive(apnType) == false) {
             ret = DataState.DISCONNECTED;
         } else {
             switch (mDataConnection.getState()) {
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index 628f11a..e8ad0f2 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -300,7 +300,8 @@
             // If we're out of service, open TCP sockets may still work
             // but no data will flow
             ret = DataState.DISCONNECTED;
-        } else if (mDataConnection.isApnTypeEnabled(apnType) == false) {
+        } else if (mDataConnection.isApnTypeEnabled(apnType) == false ||
+                mDataConnection.isApnTypeActive(apnType) == false) {
             ret = DataState.DISCONNECTED;
         } else { /* mSST.gprsState == ServiceState.STATE_IN_SERVICE */
             switch (mDataConnection.getState()) {
diff --git a/tests/DumpRenderTree/assets/run_layout_tests.py b/tests/DumpRenderTree/assets/run_layout_tests.py
index ceac5d2..21c02ec 100755
--- a/tests/DumpRenderTree/assets/run_layout_tests.py
+++ b/tests/DumpRenderTree/assets/run_layout_tests.py
@@ -4,8 +4,8 @@
 
   First, you need to get an SD card or sdcard image that has layout tests on it.
   Layout tests are in following directory:
-    /sdcard/android/layout_tests
-  For example, /sdcard/android/layout_tests/fast
+    /sdcard/webkit/layout_tests
+  For example, /sdcard/webkit/layout_tests/fast
 
   Usage:
     Run all tests under fast/ directory:
@@ -22,7 +22,7 @@
   use --refresh-test-list option *once* to re-generate test list on the card.
 
   Some other options are:
-    --rebaseline generates expected layout tests results under /sdcard/android/expected_result/
+    --rebaseline generates expected layout tests results under /sdcard/webkit/expected_result/
     --time-out-ms (default is 8000 millis) for each test
     --adb-options="-e" passes option string to adb
     --results-directory=..., (default is ./layout-test-results) directory name under which results are stored.
@@ -57,8 +57,8 @@
     output: adb_cmd string
   """
 
-  # pull /sdcard/android/running_test.txt, if the content is "#DONE", it's done
-  shell_cmd_str = adb_cmd + " shell cat /sdcard/android/running_test.txt"
+  # pull /sdcard/webkit/running_test.txt, if the content is "#DONE", it's done
+  shell_cmd_str = adb_cmd + " shell cat /sdcard/webkit/running_test.txt"
   adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
   return adb_output.strip() == "#DONE"
 
@@ -207,7 +207,7 @@
     # Get the running_test.txt
     logging.error("DumpRenderTree crashed, output:\n" + adb_output)
 
-    shell_cmd_str = adb_cmd + " shell cat /sdcard/android/running_test.txt"
+    shell_cmd_str = adb_cmd + " shell cat /sdcard/webkit/running_test.txt"
     crashed_test = ""
     while not crashed_test:
       (crashed_test, err) = subprocess.Popen(
diff --git a/tests/DumpRenderTree/assets/run_page_cycler.py b/tests/DumpRenderTree/assets/run_page_cycler.py
index 8b8fb38..692f32e 100755
--- a/tests/DumpRenderTree/assets/run_page_cycler.py
+++ b/tests/DumpRenderTree/assets/run_page_cycler.py
@@ -6,7 +6,7 @@
 
   Usage:
     Run a single page cycler test:
-      run_page_cycler.py "file:///sdcard/android/page_cycler/moz/start.html?auto=1\&iterations=10"
+      run_page_cycler.py "file:///sdcard/webkit/page_cycler/moz/start.html\?auto=1\&iterations=10"
 """
 
 import logging
@@ -32,7 +32,7 @@
 
   # Include all tests if none are specified.
   if not args:
-    print "need a URL, e.g. file:///sdcard/android/page_cycler/moz/start.html"
+    print "need a URL, e.g. file:///sdcard/webkit/page_cycler/moz/start.html\?auto=1\&iterations=10"
     sys.exit(1)
   else:
     path = ' '.join(args);
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
index 73d7363..4a47a0e 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
@@ -181,7 +181,7 @@
     }
 
     protected void setupPath() {
-        mPath = Environment.getExternalStorageDirectory() + "/android/layout_tests";
+        mPath = Environment.getExternalStorageDirectory() + "/webkit/layout_tests";
         mBaseLength = mPath.length();
     }
 
@@ -189,7 +189,7 @@
     protected int mBaseLength;
     protected String mFocusFile;
     protected int mFocusIndex;
-    
+
     private final static int OPEN_DIRECTORY = 0;
     private final static int RUN_TESTS = 1;
 
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
index 5d34e25..b7d2c26 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
@@ -35,15 +35,15 @@
     private static final String LOGTAG = "FsUtils";
     static final String EXTERNAL_DIR = Environment.getExternalStorageDirectory().toString();
     static final String HTTP_TESTS_PREFIX =
-        EXTERNAL_DIR + "/android/layout_tests/http/tests/";
+        EXTERNAL_DIR + "/webkit/layout_tests/http/tests/";
     static final String HTTPS_TESTS_PREFIX =
-        EXTERNAL_DIR + "/android/layout_tests/http/tests/ssl/";
+        EXTERNAL_DIR + "/webkit/layout_tests/http/tests/ssl/";
     static final String HTTP_LOCAL_TESTS_PREFIX =
-        EXTERNAL_DIR + "/android/layout_tests/http/tests/local/";
+        EXTERNAL_DIR + "/webkit/layout_tests/http/tests/local/";
     static final String HTTP_MEDIA_TESTS_PREFIX =
-        EXTERNAL_DIR + "/android/layout_tests/http/tests/media/";
+        EXTERNAL_DIR + "/webkit/layout_tests/http/tests/media/";
     static final String HTTP_WML_TESTS_PREFIX =
-        EXTERNAL_DIR + "/android/layout_tests/http/tests/wml/";
+        EXTERNAL_DIR + "/webkit/layout_tests/http/tests/wml/";
 
     private FsUtils() {
         //no creation of instances
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
index 8aa3c69..050b779 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
@@ -129,11 +129,11 @@
     static final int DEFAULT_TIMEOUT_IN_MILLIS = 5000;
 
     static final String EXTERNAL_DIR = Environment.getExternalStorageDirectory().toString();
-    static final String LAYOUT_TESTS_ROOT = EXTERNAL_DIR + "/android/layout_tests/";
-    static final String LAYOUT_TESTS_RESULT_DIR = EXTERNAL_DIR + "/android/layout_tests_results/";
-    static final String ANDROID_EXPECTED_RESULT_DIR = EXTERNAL_DIR + "/android/expected_results/";
-    static final String LAYOUT_TESTS_LIST_FILE = EXTERNAL_DIR + "/android/layout_tests_list.txt";
-    static final String TEST_STATUS_FILE = EXTERNAL_DIR + "/android/running_test.txt";
+    static final String LAYOUT_TESTS_ROOT = EXTERNAL_DIR + "/webkit/layout_tests/";
+    static final String LAYOUT_TESTS_RESULT_DIR = EXTERNAL_DIR + "/webkit/layout_tests_results/";
+    static final String ANDROID_EXPECTED_RESULT_DIR = EXTERNAL_DIR + "/webkit/expected_results/";
+    static final String LAYOUT_TESTS_LIST_FILE = EXTERNAL_DIR + "/webkit/layout_tests_list.txt";
+    static final String TEST_STATUS_FILE = EXTERNAL_DIR + "/webkit/running_test.txt";
     static final String LAYOUT_TESTS_RESULTS_REFERENCE_FILES[] = {
           "results/layout_tests_passed.txt",
           "results/layout_tests_failed.txt",
diff --git a/tests/DumpRenderTree2/assets/run_layout_tests.py b/tests/DumpRenderTree2/assets/run_layout_tests.py
index 0dfd229..3b8c09a 100755
--- a/tests/DumpRenderTree2/assets/run_layout_tests.py
+++ b/tests/DumpRenderTree2/assets/run_layout_tests.py
@@ -42,6 +42,7 @@
   cmd += "-w com.android.dumprendertree2/com.android.dumprendertree2.scriptsupport.ScriptTestRunner"
 
   logging.info("Running the tests...")
+  logging.debug("Command = %s" % cmd)
   (stdoutdata, stderrdata) = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
   if re.search("^INSTRUMENTATION_STATUS_CODE: -1", stdoutdata, re.MULTILINE) != None:
     logging.info("Failed to run the tests. Is DumpRenderTree2 installed on the device?")
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java
index 6c33a21..5360e3d 100644
--- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java
+++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java
@@ -68,8 +68,8 @@
     public void loadTestExpectations() {
         URL url = null;
         try {
-            url = new URL(ForwarderManager.getHostSchemePort(false) + "LayoutTests/" +
-                    TEST_EXPECTATIONS_TXT_PATH);
+            url = new URL(ForwarderManager.getHostSchemePort(false) +
+                    "LayoutTests/" + TEST_EXPECTATIONS_TXT_PATH);
         } catch (MalformedURLException e) {
             assert false;
         }
@@ -78,9 +78,14 @@
             InputStream inputStream = null;
             BufferedReader bufferedReader = null;
             try {
-                bufferedReader = new BufferedReader(new StringReader(new String(
-                        FsUtils.readDataFromUrl(url))));
-
+                byte[] httpAnswer = FsUtils.readDataFromUrl(url);
+                if (httpAnswer == null) {
+                    Log.w(LOG_TAG, "loadTestExpectations(): File not found: " +
+                            TEST_EXPECTATIONS_TXT_PATH);
+                    return;
+                }
+                bufferedReader = new BufferedReader(new StringReader(
+                        new String(httpAnswer)));
                 String line;
                 String entry;
                 String[] parts;
@@ -113,7 +118,8 @@
                     path = trimTrailingSlashIfPresent(parts[0]);
 
                     /** Split on whitespace */
-                    tokens = new HashSet<String>(Arrays.asList(parts[1].split("\\s", 0)));
+                    tokens = new HashSet<String>(Arrays.asList(
+                            parts[1].split("\\s", 0)));
 
                     /** Chose the right collections to add to */
                     if (tokens.contains(TOKEN_CRASH)) {
@@ -138,8 +144,6 @@
                     bufferedReader.close();
                 }
             }
-        } catch (FileNotFoundException e) {
-            Log.w(LOG_TAG, "reloadConfiguration(): File not found: " + e.getMessage());
         } catch (IOException e) {
             Log.e(LOG_TAG, "url=" + url, e);
         }
diff --git a/vpn/java/android/net/vpn/VpnManager.java b/vpn/java/android/net/vpn/VpnManager.java
index ce40b5d..60fecc2 100644
--- a/vpn/java/android/net/vpn/VpnManager.java
+++ b/vpn/java/android/net/vpn/VpnManager.java
@@ -16,15 +16,12 @@
 
 package android.net.vpn;
 
-import java.io.File;
-
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.os.Environment;
-import android.os.SystemProperties;
 import android.util.Log;
 
 /**
@@ -86,7 +83,7 @@
     // TODO(oam): Test VPN when EFS is enabled (will do later)...
     public static String getProfilePath() {
         // This call will return the correct path if Encrypted FS is enabled or not.
-        return Environment.getSecureDataDirectory().getPath() + PROFILES_PATH;
+        return Environment.getDataDirectory().getPath() + PROFILES_PATH;
     }
 
     /**
@@ -124,7 +121,7 @@
      */
     public VpnProfile createVpnProfile(VpnType type, boolean customized) {
         try {
-            VpnProfile p = (VpnProfile) type.getProfileClass().newInstance();
+            VpnProfile p = type.getProfileClass().newInstance();
             p.setCustomized(customized);
             return p;
         } catch (InstantiationException e) {