Backed out changeset 3263cf8aca77 (bug 1033952)

This commit is contained in:
Carsten "Tomcat" Book 2014-12-23 12:13:20 +01:00
Родитель bed900f3b8
Коммит 3892be0a59
14 изменённых файлов: 30 добавлений и 277 удалений

Просмотреть файл

@ -272,7 +272,6 @@ public:
bool CanBeMounted();
bool CanBeFormatted();
bool CanBeShared();
bool IsRemovable();
bool Default();
// Uses XPCOM GetStorageName
@ -323,7 +322,6 @@ private:
nsCOMPtr<nsIFile> mRootDirectory;
nsString mStorageName;
bool mIsShareable;
bool mIsRemovable;
already_AddRefed<nsDOMDeviceStorage> GetStorage(const nsAString& aFullPath,
nsAString& aOutStoragePath);

Просмотреть файл

@ -3337,7 +3337,6 @@ NS_IMPL_RELEASE_INHERITED(nsDOMDeviceStorage, DOMEventTargetHelper)
nsDOMDeviceStorage::nsDOMDeviceStorage(nsPIDOMWindow* aWindow)
: DOMEventTargetHelper(aWindow)
, mIsShareable(false)
, mIsRemovable(false)
, mIsWatchingFile(false)
, mAllowedToWatchFile(false)
{
@ -3384,12 +3383,6 @@ nsDOMDeviceStorage::Init(nsPIDOMWindow* aWindow, const nsAString &aType,
return rv;
}
mIsShareable = !isFake;
bool isRemovable;
rv = vol->GetIsHotSwappable(&isRemovable);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
mIsRemovable = isRemovable;
}
#endif
}
@ -4233,12 +4226,6 @@ nsDOMDeviceStorage::CanBeShared()
return mIsShareable;
}
bool
nsDOMDeviceStorage::IsRemovable()
{
return mIsRemovable;
}
already_AddRefed<Promise>
nsDOMDeviceStorage::GetRoot(ErrorResult& aRv)
{

Просмотреть файл

@ -2153,15 +2153,13 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
const bool& aIsSharing,
const bool& aIsFormatting,
const bool& aIsFake,
const bool& aIsUnmounting,
const bool& aIsRemovable,
const bool& aIsHotSwappable)
const bool& aIsUnmounting)
{
#ifdef MOZ_WIDGET_GONK
nsRefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState,
aMountGeneration, aIsMediaPresent,
aIsSharing, aIsFormatting, aIsFake,
aIsUnmounting, aIsRemovable, aIsHotSwappable);
aIsUnmounting);
nsRefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
if (vs) {
@ -2178,8 +2176,6 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
unused << aIsFormatting;
unused << aIsFake;
unused << aIsUnmounting;
unused << aIsRemovable;
unused << aIsHotSwappable;
#endif
return true;
}

Просмотреть файл

@ -336,9 +336,7 @@ public:
const bool& aIsSharing,
const bool& aIsFormatting,
const bool& aIsFake,
const bool& aIsUnmounting,
const bool& aIsRemovable,
const bool& aIsHotSwappable) MOZ_OVERRIDE;
const bool& aIsUnmounting) MOZ_OVERRIDE;
virtual bool RecvNuwaFork() MOZ_OVERRIDE;

Просмотреть файл

@ -2829,8 +2829,6 @@ ContentParent::Observe(nsISupports* aSubject,
bool isFormatting;
bool isFake;
bool isUnmounting;
bool isRemovable;
bool isHotSwappable;
vol->GetName(volName);
vol->GetMountPoint(mountPoint);
@ -2841,8 +2839,6 @@ ContentParent::Observe(nsISupports* aSubject,
vol->GetIsFormatting(&isFormatting);
vol->GetIsFake(&isFake);
vol->GetIsUnmounting(&isUnmounting);
vol->GetIsRemovable(&isRemovable);
vol->GetIsHotSwappable(&isHotSwappable);
#ifdef MOZ_NUWA_PROCESS
if (!(IsNuwaReady() && IsNuwaProcess()))
@ -2851,7 +2847,7 @@ ContentParent::Observe(nsISupports* aSubject,
unused << SendFileSystemUpdate(volName, mountPoint, state,
mountGeneration, isMediaPresent,
isSharing, isFormatting, isFake,
isUnmounting, isRemovable, isHotSwappable);
isUnmounting);
}
} else if (!strcmp(aTopic, "phone-state-changed")) {
nsString state(aData);

Просмотреть файл

@ -319,8 +319,6 @@ struct VolumeInfo {
bool isFormatting;
bool isFake;
bool isUnmounting;
bool isRemovable;
bool isHotSwappable;
};
struct ClipboardCapabilities {
@ -491,8 +489,7 @@ child:
// VolumeInfo above.
FileSystemUpdate(nsString fsName, nsString mountPoint, int32_t fsState,
int32_t mountGeneration, bool isMediaPresent,
bool isSharing, bool isFormatting, bool isFake,
bool isUnmounting, bool isRemovable, bool isHotSwappable);
bool isSharing, bool isFormatting, bool isFake, bool isUnmounting);
// Ask the Nuwa process to create a new child process.
NuwaFork();

Просмотреть файл

@ -81,8 +81,6 @@ Volume::Volume(const nsCSubstring& aName)
mIsSharing(false),
mIsFormatting(false),
mIsUnmounting(false),
mIsRemovable(false),
mIsHotSwappable(false),
mId(sNextId++)
{
DBG("Volume %s: created", NameStr());
@ -158,78 +156,6 @@ Volume::SetIsUnmounting(bool aIsUnmounting)
sEventObserverList.Broadcast(this);
}
void
Volume::SetIsRemovable(bool aIsRemovable)
{
if (aIsRemovable == mIsRemovable) {
return;
}
mIsRemovable = aIsRemovable;
if (!mIsRemovable) {
mIsHotSwappable = false;
}
LOG("Volume %s: IsRemovable set to %d state %s",
NameStr(), (int)mIsRemovable, StateStr(mState));
sEventObserverList.Broadcast(this);
}
void
Volume::SetIsHotSwappable(bool aIsHotSwappable)
{
if (aIsHotSwappable == mIsHotSwappable) {
return;
}
mIsHotSwappable = aIsHotSwappable;
if (mIsHotSwappable) {
mIsRemovable = true;
}
LOG("Volume %s: IsHotSwappable set to %d state %s",
NameStr(), (int)mIsHotSwappable, StateStr(mState));
sEventObserverList.Broadcast(this);
}
bool
Volume::BoolConfigValue(const nsCString& aConfigValue, bool& aBoolValue)
{
if (aConfigValue.EqualsLiteral("1") ||
aConfigValue.LowerCaseEqualsLiteral("true")) {
aBoolValue = true;
return true;
}
if (aConfigValue.EqualsLiteral("0") ||
aConfigValue.LowerCaseEqualsLiteral("false")) {
aBoolValue = false;
return true;
}
return false;
}
void
Volume::SetConfig(const nsCString& aConfigName, const nsCString& aConfigValue)
{
if (aConfigName.LowerCaseEqualsLiteral("removable")) {
bool value = false;
if (BoolConfigValue(aConfigValue, value)) {
SetIsRemovable(value);
} else {
ERR("Volume %s: invalid value '%s' for configuration '%s'",
NameStr(), aConfigValue.get(), aConfigName.get());
}
return;
}
if (aConfigName.LowerCaseEqualsLiteral("hotswappable")) {
bool value = false;
if (BoolConfigValue(aConfigValue, value)) {
SetIsHotSwappable(value);
} else {
ERR("Volume %s: invalid value '%s' for configuration '%s'",
NameStr(), aConfigValue.get(), aConfigName.get());
}
return;
}
ERR("Volume %s: invalid config '%s'", NameStr(), aConfigName.get());
}
void
Volume::SetMediaPresent(bool aMediaPresent)
{

Просмотреть файл

@ -75,8 +75,6 @@ public:
bool IsSharing() const { return mIsSharing; }
bool IsFormatting() const { return mIsFormatting; }
bool IsUnmounting() const { return mIsUnmounting; }
bool IsRemovable() const { return mIsRemovable; }
bool IsHotSwappable() const { return mIsHotSwappable; }
void SetFakeVolume(const nsACString& aMountPoint);
@ -109,16 +107,11 @@ private:
void SetIsSharing(bool aIsSharing);
void SetIsFormatting(bool aIsFormatting);
void SetIsUnmounting(bool aIsUnmounting);
void SetIsRemovable(bool aIsRemovable);
void SetIsHotSwappable(bool aIsHotSwappable);
void SetState(STATE aNewState);
void SetMediaPresent(bool aMediaPresent);
void SetMountPoint(const nsCSubstring& aMountPoint);
void StartCommand(VolumeCommand* aCommand);
bool BoolConfigValue(const nsCString& aConfigValue, bool& aBoolValue);
void SetConfig(const nsCString& aConfigName, const nsCString& aConfigValue);
void HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer& aTokenizer);
static void UpdateMountLock(const nsACString& aVolumeName,
@ -139,8 +132,6 @@ private:
bool mIsSharing;
bool mIsFormatting;
bool mIsUnmounting;
bool mIsRemovable;
bool mIsHotSwappable;
uint32_t mId; // Unique ID (used by MTP)
static VolumeObserverList sEventObserverList;

Просмотреть файл

@ -168,12 +168,12 @@ void VolumeManager::InitConfig()
//
// The format of the volume.cfg file is as follows:
// create volume-name mount-point
// configure volume-name preference preference-value
// Blank lines and lines starting with the hash character "#" will be ignored.
ScopedCloseFile fp;
int n = 0;
char line[255];
char *command, *volNamePtr, *mountPointPtr, *save_ptr;
const char *filename = "/system/etc/volume.cfg";
if (!(fp = fopen(filename, "r"))) {
LOG("Unable to open volume configuration file '%s' - ignoring", filename);
@ -185,87 +185,27 @@ void VolumeManager::InitConfig()
if (line[0] == '#')
continue;
nsCString commandline(line);
nsCWhitespaceTokenizer tokenizer(commandline);
if (!tokenizer.hasMoreTokens()) {
if (!(command = strtok_r(line, delim, &save_ptr))) {
// Blank line - ignore
continue;
}
nsCString command(tokenizer.nextToken());
if (command.EqualsLiteral("create")) {
if (!tokenizer.hasMoreTokens()) {
if (!strcmp(command, "create")) {
if (!(volNamePtr = strtok_r(nullptr, delim, &save_ptr))) {
ERR("No vol_name in %s line %d", filename, n);
continue;
}
nsCString volName(tokenizer.nextToken());
if (!tokenizer.hasMoreTokens()) {
ERR("No mount point for volume '%s'. %s line %d",
volName.get(), filename, n);
if (!(mountPointPtr = strtok_r(nullptr, delim, &save_ptr))) {
ERR("No mount point for volume '%s'. %s line %d", volNamePtr, filename, n);
continue;
}
nsCString mountPoint(tokenizer.nextToken());
nsCString mountPoint(mountPointPtr);
nsCString volName(volNamePtr);
RefPtr<Volume> vol = FindAddVolumeByName(volName);
vol->SetFakeVolume(mountPoint);
continue;
}
if (command.EqualsLiteral("configure")) {
if (!tokenizer.hasMoreTokens()) {
ERR("No vol_name in %s line %d", filename, n);
continue;
}
nsCString volName(tokenizer.nextToken());
if (!tokenizer.hasMoreTokens()) {
ERR("No configuration name specified for volume '%s'. %s line %d",
volName.get(), filename, n);
continue;
}
nsCString configName(tokenizer.nextToken());
if (!tokenizer.hasMoreTokens()) {
ERR("No value for configuration name '%s'. %s line %d",
configName.get(), filename, n);
continue;
}
nsCString configValue(tokenizer.nextToken());
RefPtr<Volume> vol = FindVolumeByName(volName);
if (vol) {
vol->SetConfig(configName, configValue);
} else {
ERR("Invalid volume name '%s'.", volName.get());
}
continue;
}
ERR("Unrecognized command: '%s'", command.get());
}
}
void
VolumeManager::DefaultConfig()
{
VolumeManager::VolumeArray::size_type numVolumes = VolumeManager::NumVolumes();
if (numVolumes == 0) {
return;
}
if (numVolumes == 1) {
// This is to cover early shipping phones like the Buri,
// which had no internal storage, and only external sdcard.
//
// Phones line the nexus-4 which only have an internal
// storage area will need to have a volume.cfg file with
// removable set to false.
RefPtr<Volume> vol = VolumeManager::GetVolume(0);
vol->SetIsRemovable(true);
vol->SetIsHotSwappable(true);
return;
}
VolumeManager::VolumeArray::index_type volIndex;
for (volIndex = 0; volIndex < numVolumes; volIndex++) {
RefPtr<Volume> vol = VolumeManager::GetVolume(volIndex);
if (!vol->Name().EqualsLiteral("sdcard")) {
vol->SetIsRemovable(true);
vol->SetIsHotSwappable(true);
else {
ERR("Unrecognized command: '%s'", command);
}
}
}
@ -293,7 +233,6 @@ class VolumeListCallback : public VolumeResponseCallback
// We've received the list of volumes. Now read the Volume.cfg
// file to perform customizations, and then tell everybody
// that we're ready for business.
VolumeManager::DefaultConfig();
VolumeManager::InitConfig();
VolumeManager::Dump("READY");
VolumeManager::SetState(VolumeManager::VOLUMES_READY);

Просмотреть файл

@ -138,8 +138,6 @@ protected:
virtual void OnFileCanWriteWithoutBlocking(int aFd);
virtual void OnError();
static void DefaultConfig();
private:
bool OpenSocket();

Просмотреть файл

@ -5,7 +5,7 @@
#include "nsISupports.idl"
#include "nsIVolumeStat.idl"
[scriptable, uuid(946B5334-6EC9-11E4-8689-F3061E5D46B0)]
[scriptable, uuid(9B5E27F4-601C-11E4-B541-3E2D1D5D46B0)]
interface nsIVolume : nsISupports
{
// These MUST match the states from android's system/vold/Volume.h header
@ -86,13 +86,6 @@ interface nsIVolume : nsISupports
// Whether this is a fake volume.
readonly attribute boolean isFake;
// Whether this is a removable volume
readonly attribute boolean isRemovable;
// Whether this is a hot-swappable volume
readonly attribute boolean isHotSwappable;
};
%{C++

Просмотреть файл

@ -59,9 +59,7 @@ nsVolume::nsVolume(const Volume* aVolume)
mIsMediaPresent(aVolume->MediaPresent()),
mIsSharing(aVolume->IsSharing()),
mIsFormatting(aVolume->IsFormatting()),
mIsUnmounting(aVolume->IsUnmounting()),
mIsRemovable(aVolume->IsRemovable()),
mIsHotSwappable(aVolume->IsHotSwappable())
mIsUnmounting(aVolume->IsUnmounting())
{
}
@ -121,18 +119,6 @@ bool nsVolume::Equals(nsIVolume* aVolume)
return false;
}
bool isRemovable;
aVolume->GetIsRemovable(&isRemovable);
if (mIsRemovable != isRemovable) {
return false;
}
bool isHotSwappable;
aVolume->GetIsHotSwappable(&isHotSwappable);
if (mIsHotSwappable != isHotSwappable) {
return false;
}
return true;
}
@ -214,18 +200,6 @@ NS_IMETHODIMP nsVolume::GetIsFake(bool *aIsFake)
return NS_OK;
}
NS_IMETHODIMP nsVolume::GetIsRemovable(bool *aIsRemovable)
{
*aIsRemovable = mIsRemovable;
return NS_OK;
}
NS_IMETHODIMP nsVolume::GetIsHotSwappable(bool *aIsHotSwappable)
{
*aIsHotSwappable = mIsHotSwappable;
return NS_OK;
}
NS_IMETHODIMP nsVolume::Format()
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
@ -303,12 +277,11 @@ nsVolume::LogState() const
{
if (mState == nsIVolume::STATE_MOUNTED) {
LOG("nsVolume: %s state %s @ '%s' gen %d locked %d fake %d "
"media %d sharing %d formatting %d unmounting %d removable %d hotswappable %d",
"media %d sharing %d formatting %d unmounting %d",
NameStr().get(), StateStr(), MountPointStr().get(),
MountGeneration(), (int)IsMountLocked(), (int)IsFake(),
(int)IsMediaPresent(), (int)IsSharing(),
(int)IsFormatting(), (int)IsUnmounting(),
(int)IsRemovable(), (int)IsHotSwappable());
(int)IsFormatting(), (int)IsUnmounting());
return;
}
@ -327,8 +300,6 @@ void nsVolume::Set(nsIVolume* aVolume)
aVolume->GetIsSharing(&mIsSharing);
aVolume->GetIsFormatting(&mIsFormatting);
aVolume->GetIsUnmounting(&mIsUnmounting);
aVolume->GetIsRemovable(&mIsRemovable);
aVolume->GetIsHotSwappable(&mIsHotSwappable);
int32_t volMountGeneration;
aVolume->GetMountGeneration(&volMountGeneration);
@ -406,24 +377,6 @@ nsVolume::SetIsFake(bool aIsFake)
}
}
void
nsVolume::SetIsRemovable(bool aIsRemovable)
{
mIsRemovable = aIsRemovable;
if (!mIsRemovable) {
mIsHotSwappable = false;
}
}
void
nsVolume::SetIsHotSwappable(bool aIsHotSwappable)
{
mIsHotSwappable = aIsHotSwappable;
if (mIsHotSwappable) {
mIsRemovable = true;
}
}
void
nsVolume::SetState(int32_t aState)
{

Просмотреть файл

@ -31,8 +31,7 @@ public:
const int32_t& aState, const int32_t& aMountGeneration,
const bool& aIsMediaPresent, const bool& aIsSharing,
const bool& aIsFormatting, const bool& aIsFake,
const bool& aIsUnmounting, const bool& aIsRemovable,
const bool& aIsHotSwappable)
const bool& aIsUnmounting)
: mName(aName),
mMountPoint(aMountPoint),
mState(aState),
@ -42,9 +41,7 @@ public:
mIsMediaPresent(aIsMediaPresent),
mIsSharing(aIsSharing),
mIsFormatting(aIsFormatting),
mIsUnmounting(aIsUnmounting),
mIsRemovable(aIsRemovable),
mIsHotSwappable(aIsHotSwappable)
mIsUnmounting(aIsUnmounting)
{
}
@ -59,9 +56,7 @@ public:
mIsMediaPresent(false),
mIsSharing(false),
mIsFormatting(false),
mIsUnmounting(false),
mIsRemovable(false),
mIsHotSwappable(false)
mIsUnmounting(false)
{
}
@ -87,8 +82,6 @@ public:
bool IsSharing() const { return mIsSharing; }
bool IsFormatting() const { return mIsFormatting; }
bool IsUnmounting() const { return mIsUnmounting; }
bool IsRemovable() const { return mIsRemovable; }
bool IsHotSwappable() const { return mIsHotSwappable; }
typedef nsTArray<nsRefPtr<nsVolume> > Array;
@ -100,8 +93,6 @@ private:
void UpdateMountLock(bool aMountLocked);
void SetIsFake(bool aIsFake);
void SetIsRemovable(bool aIsRemovable);
void SetIsHotSwappable(bool aIsHotSwappble);
void SetState(int32_t aState);
static void FormatVolumeIOThread(const nsCString& aVolume);
static void MountVolumeIOThread(const nsCString& aVolume);
@ -117,8 +108,6 @@ private:
bool mIsSharing;
bool mIsFormatting;
bool mIsUnmounting;
bool mIsRemovable;
bool mIsHotSwappable;
};
} // system

Просмотреть файл

@ -210,9 +210,7 @@ nsVolumeService::CreateOrGetVolumeByPath(const nsAString& aPath, nsIVolume** aRe
false /* isSharing */,
false /* isFormatting */,
true /* isFake */,
false /* isUnmounting */,
false /* isRemovable */,
false /* isHotSwappable*/);
false /* isUnmounting*/);
vol.forget(aResult);
return NS_OK;
}
@ -302,9 +300,7 @@ nsVolumeService::GetVolumesFromParent()
volInfo.isSharing(),
volInfo.isFormatting(),
volInfo.isFake(),
volInfo.isUnmounting(),
volInfo.isRemovable(),
volInfo.isHotSwappable());
volInfo.isUnmounting());
UpdateVolume(vol, false);
}
}
@ -429,9 +425,7 @@ nsVolumeService::CreateFakeVolume(const nsAString& name, const nsAString& path)
false /* isSharing */,
false /* isFormatting */,
true /* isFake */,
false /* isUnmounting */,
false /* isRemovable */,
false /* isHotSwappable */);
false /* isUnmounting */);
vol->LogState();
UpdateVolume(vol.get());
return NS_OK;
@ -481,12 +475,11 @@ public:
{
MOZ_ASSERT(NS_IsMainThread());
DBG("UpdateVolumeRunnable::Run '%s' state %s gen %d locked %d "
"media %d sharing %d formatting %d unmounting %d removable %d hotswappable %d",
"media %d sharing %d formatting %d unmounting %d",
mVolume->NameStr().get(), mVolume->StateStr(),
mVolume->MountGeneration(), (int)mVolume->IsMountLocked(),
(int)mVolume->IsMediaPresent(), mVolume->IsSharing(),
mVolume->IsFormatting(), mVolume->IsUnmounting(),
(int)mVolume->IsRemovable(), (int)mVolume->IsHotSwappable());
mVolume->IsFormatting(), mVolume->IsUnmounting());
mVolumeService->UpdateVolume(mVolume);
mVolumeService = nullptr;
@ -503,12 +496,11 @@ void
nsVolumeService::UpdateVolumeIOThread(const Volume* aVolume)
{
DBG("UpdateVolumeIOThread: Volume '%s' state %s mount '%s' gen %d locked %d "
"media %d sharing %d formatting %d unmounting %d removable %d hotswappable %d",
"media %d sharing %d formatting %d unmounting %d",
aVolume->NameStr(), aVolume->StateStr(), aVolume->MountPoint().get(),
aVolume->MountGeneration(), (int)aVolume->IsMountLocked(),
(int)aVolume->MediaPresent(), (int)aVolume->IsSharing(),
(int)aVolume->IsFormatting(), (int)mVolume->IsUnmounting(),
(int)aVolume->IsRemovable(), (int)mVolume->IsHotSwappable());
(int)aVolume->IsFormatting(), (int)mVolume->IsUnmounting());
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
NS_DispatchToMainThread(new UpdateVolumeRunnable(this, aVolume));
}