Merge "Update the mdpi resource with 2.0 style icons"
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index 03db9ce..94cf714 100644
--- a/src/com/android/settings/DeviceAdminAdd.java
+++ b/src/com/android/settings/DeviceAdminAdd.java
@@ -140,24 +140,25 @@
                     mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
                     setResult(Activity.RESULT_OK);
                     finish();
-                }
-                mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),
-                        new RemoteCallback(mHandler) {
-                    @Override
-                    protected void onResult(Bundle bundle) {
-                        CharSequence msg = bundle != null
-                                ? bundle.getCharSequence(DeviceAdmin.EXTRA_DISABLE_WARNING)
-                                : null;
-                        if (msg == null) {
-                            mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
-                            finish();
-                        } else {
-                            Bundle args = new Bundle();
-                            args.putCharSequence(DeviceAdmin.EXTRA_DISABLE_WARNING, msg);
-                            showDialog(DIALOG_WARNING, args);
+                } else {
+                    mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),
+                            new RemoteCallback(mHandler) {
+                        @Override
+                        protected void onResult(Bundle bundle) {
+                            CharSequence msg = bundle != null
+                                    ? bundle.getCharSequence(DeviceAdmin.EXTRA_DISABLE_WARNING)
+                                    : null;
+                            if (msg == null) {
+                                mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
+                                finish();
+                            } else {
+                                Bundle args = new Bundle();
+                                args.putCharSequence(DeviceAdmin.EXTRA_DISABLE_WARNING, msg);
+                                showDialog(DIALOG_WARNING, args);
+                            }
                         }
-                    }
-                });
+                    });
+                }
             }
         });
     }
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 28a5829..72a0741 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -27,7 +27,6 @@
 import android.content.IntentFilter;
 import android.media.AudioManager;
 import android.os.Bundle;
-import android.os.IMountService;
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.preference.CheckBoxPreference;
diff --git a/src/com/android/settings/ManageApplications.java b/src/com/android/settings/ManageApplications.java
index 0525dab..6de6c9c 100644
--- a/src/com/android/settings/ManageApplications.java
+++ b/src/com/android/settings/ManageApplications.java
@@ -1559,8 +1559,8 @@
              ManageApplications.this.registerReceiver(this, filter);
              // Register for events related to sdcard installation.
              IntentFilter sdFilter = new IntentFilter();
-             sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_AVAILABLE);
-             sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE);
+             sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
+             sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
              ManageApplications.this.registerReceiver(this, sdFilter);
          }
          @Override
@@ -1573,9 +1573,9 @@
                  Uri data = intent.getData();
                  String pkgName = data.getEncodedSchemeSpecificPart();
                  updatePackageList(actionStr, pkgName);
-             } else if (Intent.ACTION_MEDIA_RESOURCES_AVAILABLE.equals(actionStr) ||
-                     Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE.equals(actionStr)) {
-                 boolean available = Intent.ACTION_MEDIA_RESOURCES_AVAILABLE.equals(actionStr);
+             } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(actionStr) ||
+                     Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(actionStr)) {
+                 boolean available = Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(actionStr);
                  String pkgList[] = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
                  if (pkgList == null || pkgList.length == 0) {
                      // Ignore
diff --git a/src/com/android/settings/MediaFormat.java b/src/com/android/settings/MediaFormat.java
index 40ae0d7..71d2766 100644
--- a/src/com/android/settings/MediaFormat.java
+++ b/src/com/android/settings/MediaFormat.java
@@ -23,7 +23,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
-import android.os.IMountService;
+import android.os.storage.IMountService;
 import android.os.ServiceManager;
 import android.os.SystemProperties;
 import android.os.Environment;
diff --git a/src/com/android/settings/SdCardSettings.java b/src/com/android/settings/SdCardSettings.java
index 4a83843..2ff5d8a 100644
--- a/src/com/android/settings/SdCardSettings.java
+++ b/src/com/android/settings/SdCardSettings.java
@@ -24,9 +24,10 @@
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.Environment;
-import android.os.IMountService;
 import android.os.ServiceManager;
 import android.os.StatFs;
+import android.os.storage.StorageManager;
+import android.os.storage.IMountService;
 import android.text.format.Formatter;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -45,6 +46,7 @@
 
         setContentView(R.layout.sdcard_settings_screen);
 
+        mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
         mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
 
         mRemovedLayout = findViewById(R.id.removed);
@@ -105,10 +107,7 @@
     private void update() {
 
         try {
-            String path = Environment.getExternalStorageDirectory().getPath();
-            mMassStorage.setChecked(
-                    mMountService.getVolumeShared(
-                            Environment.getExternalStorageDirectory().getPath(), "ums"));
+            mMassStorage.setChecked(mStorageManager.isUsbMassStorageEnabled());
         } catch (Exception ex) {
         }
 
@@ -158,11 +157,9 @@
         public void onClick(View v) {
             try {
                 if (mMassStorage.isChecked()) {
-                    mMountService.shareVolume(
-                            Environment.getExternalStorageDirectory().getPath(), "ums");
+                    mStorageManager.enableUsbMassStorage();
                 } else {
-                    mMountService.unshareVolume(
-                            Environment.getExternalStorageDirectory().getPath(), "ums");
+                    mStorageManager.disableUsbMassStorage();
                 }
             } catch (Exception ex) {
             }
@@ -194,7 +191,8 @@
         }
     };
 
-    private IMountService   mMountService;
+    private StorageManager mStorageManager;
+    private IMountService mMountService;
 
     private CheckBox    mMassStorage;
 
diff --git a/src/com/android/settings/SoundSettings.java b/src/com/android/settings/SoundSettings.java
index fb78a80..52947ac 100644
--- a/src/com/android/settings/SoundSettings.java
+++ b/src/com/android/settings/SoundSettings.java
@@ -25,7 +25,6 @@
 import android.content.IntentFilter;
 import android.media.AudioManager;
 import android.os.Bundle;
-import android.os.IMountService;
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.preference.CheckBoxPreference;
@@ -59,8 +58,6 @@
 
     private CheckBoxPreference mSilent;
 
-    private IMountService mMountService = null;
-
     /*
      * If we are currently in one of the silent modes (the ringer mode is set to either
      * "silent mode" or "vibrate mode"), then toggling the "Phone vibrate"
@@ -95,8 +92,6 @@
 
         mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
 
-        mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
-
         addPreferencesFromResource(R.xml.sound_settings);
 
         if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) {
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 7e22375..04eebb1 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -25,11 +25,11 @@
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.Environment;
-import android.os.IMountService;
+import android.os.storage.IMountService;
 import android.os.ServiceManager;
 import android.os.StatFs;
-import android.storage.StorageManager;
-import android.storage.StorageEventListener;
+import android.os.storage.StorageManager;
+import android.os.storage.StorageEventListener;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
@@ -95,19 +95,9 @@
     }
 
     StorageEventListener mStorageListener = new StorageEventListener() {
-        public void onShareAvailabilityChanged(String method, boolean available) {
-        }
 
-        public void onMediaInserted(String label, String path, int major, int minor) {
-            updateMemoryStatus();
-        }
-
-        public void onMediaRemoved(String label, String path, int major, int minor, boolean clean) {
-            updateMemoryStatus();
-        }
-
-        public void onVolumeStateChanged(
-                String label, String path, String oldState, String newState) {
+        @Override
+        public void onStorageStateChanged(String path, String oldState, String newState) {
             updateMemoryStatus();
         }
     };
@@ -166,9 +156,8 @@
                 Log.e(TAG, "Mount service is null, can't unmount");
             }
         } catch (RemoteException ex) {
-            // Failed for some reason, try to update UI to actual state
-            updateMemoryStatus();
         }
+        updateMemoryStatus();
     }
 
     private void mount() {
@@ -180,9 +169,8 @@
                 Log.e(TAG, "Mount service is null, can't mount");
             }
         } catch (RemoteException ex) {
-            // Failed for some reason, try to update UI to actual state
-            updateMemoryStatus();
         }
+        updateMemoryStatus();
     }
 
     private void updateMemoryStatus() {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index ed170f4..e06dcd4 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -25,6 +25,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.net.NetworkInfo;
+import android.net.NetworkInfo.DetailedState;
 import android.net.wifi.ScanResult;
 import android.net.wifi.SupplicantState;
 import android.net.wifi.WifiConfiguration;
@@ -71,7 +72,7 @@
     private ProgressCategory mAccessPoints;
     private Preference mAddNetwork;
 
-    private NetworkInfo.DetailedState mLastState;
+    private DetailedState mLastState;
     private WifiInfo mLastInfo;
     private int mLastPriority;
 
@@ -426,8 +427,8 @@
         }
     }
 
-    private void updateConnectionState(NetworkInfo.DetailedState state) {
-        if (state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
+    private void updateConnectionState(DetailedState state) {
+        if (state == DetailedState.OBTAINING_IPADDR) {
             mScanner.pause();
         } else {
             mScanner.resume();
@@ -441,6 +442,11 @@
         for (int i = mAccessPoints.getPreferenceCount() - 1; i >= 0; --i) {
             ((AccessPoint) mAccessPoints.getPreference(i)).update(mLastInfo, mLastState);
         }
+
+        if (mResetNetworks && (state == DetailedState.CONNECTED ||
+                state == DetailedState.DISCONNECTED || state == DetailedState.FAILED)) {
+            enableNetworks();
+        }
     }
 
     private void updateWifiState(int state) {