diff options
| author | 2010-07-19 16:09:40 -0700 | |
|---|---|---|
| committer | 2010-07-19 16:09:40 -0700 | |
| commit | 2ef1cea44008d7afb5ed91cfbccc9df5288f83ca (patch) | |
| tree | 3d6e2d77d79e610052494da6a29f0344cda9c674 | |
| parent | 121d7d86d2c82457ed8f74460c3a435ee2f1160f (diff) | |
| parent | 03559753ce0c6105b9357d6050aa4cddb9112ac2 (diff) | |
Merge "Add support for emulating external storage on devices with no SD card"
| -rw-r--r-- | core/res/res/values/config.xml | 7 | ||||
| -rw-r--r-- | services/java/com/android/server/MountService.java | 25 |
2 files changed, 26 insertions, 6 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index ec0d83c03189..98b0a287b80d 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -72,6 +72,13 @@ when there's no network connection. If the scan doesn't timeout, use zero --> <integer name="config_radioScanningTimeout">0</integer> + <!-- Set to true if the location returned Environment.getExternalStorageDirectory() + is actually a subdirectory of the internal storage. + If this is set then Environment.getExternalStorageState() will always return + MEDIA_MOUNTED and Intent.ACTION_MEDIA_MOUNTED will be broadcast at boot time + for backward compatibility with apps that require external storage. --> + <bool name="config_emulateExternalStorage">false</bool> + <!-- XXXXX NOTE THE FOLLOWING RESOURCES USE THE WRONG NAMING CONVENTION. Please don't copy them, copy anything else. --> diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index d7b92ec0ae71..ef5e9cc1f614 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -127,6 +127,8 @@ class MountService extends IMountService.Stub private boolean mBooted = false; private boolean mReady = false; private boolean mSendUmsConnectedOnBoot = false; + // true if we should fake MEDIA_MOUNTED state for external storage + private boolean mEmulateExternalStorage = false; /** * Private hash of currently mounted secure containers. @@ -319,7 +321,9 @@ class MountService extends IMountService.Stub String path = Environment.getExternalStorageDirectory().getPath(); String state = getVolumeState(path); - if (state.equals(Environment.MEDIA_UNMOUNTED)) { + if (mEmulateExternalStorage) { + notifyVolumeStateChange(null, path, VolumeState.NoMedia, VolumeState.Mounted); + } else if (state.equals(Environment.MEDIA_UNMOUNTED)) { int rc = doMountVolume(path); if (rc != StorageResultCode.OperationSucceeded) { Slog.e(TAG, String.format("Boot-time mount failed (%d)", rc)); @@ -390,11 +394,13 @@ class MountService extends IMountService.Stub Slog.w(TAG, String.format("Duplicate state transition (%s -> %s)", mLegacyState, state)); return; } - // Update state on PackageManager - if (Environment.MEDIA_UNMOUNTED.equals(state)) { - mPms.updateExternalMediaStatus(false, false); - } else if (Environment.MEDIA_MOUNTED.equals(state)) { - mPms.updateExternalMediaStatus(true, false); + // Update state on PackageManager, but only of real events + if (!mEmulateExternalStorage) { + if (Environment.MEDIA_UNMOUNTED.equals(state)) { + mPms.updateExternalMediaStatus(false, false); + } else if (Environment.MEDIA_MOUNTED.equals(state)) { + mPms.updateExternalMediaStatus(true, false); + } } String oldState = mLegacyState; mLegacyState = state; @@ -894,6 +900,13 @@ class MountService extends IMountService.Stub public MountService(Context context) { mContext = context; + mEmulateExternalStorage = context.getResources().getBoolean( + com.android.internal.R.bool.config_emulateExternalStorage); + if (mEmulateExternalStorage) { + Slog.d(TAG, "using emulated external storage"); + mLegacyState = Environment.MEDIA_MOUNTED; + } + // XXX: This will go away soon in favor of IMountServiceObserver mPms = (PackageManagerService) ServiceManager.getService("package"); |