Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6be9c162 authored by Marco Nelissen's avatar Marco Nelissen Committed by Android (Google) Code Review
Browse files

Merge "Revert "Do autodetection even if no locale was specified, and use the""

parents 05212067 dea009ab
Loading
Loading
Loading
Loading
+35 −39
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ void MediaScannerClient::beginFile()

bool MediaScannerClient::addStringTag(const char* name, const char* value)
{
    if (mLocaleEncoding != kEncodingNone) {
        // don't bother caching strings that are all ASCII.
        // call handleStringTag directly instead.
        // check to see if value (which should be utf8) has any non-ASCII characters
@@ -84,6 +85,7 @@ bool MediaScannerClient::addStringTag(const char* name, const char* value)
            return true;
        }
        // else fall through
    }

    // autodetection is not necessary, so no need to cache the values
    // pass directly to the client instead
@@ -196,6 +198,7 @@ void MediaScannerClient::convertValues(uint32_t encoding)

void MediaScannerClient::endFile()
{
    if (mLocaleEncoding != kEncodingNone) {
        int size = mNames->size();
        uint32_t encoding = kEncodingAll;

@@ -203,23 +206,16 @@ void MediaScannerClient::endFile()
        for (int i = 0; i < mNames->size(); i++)
            encoding &= possibleEncodings(mValues->getEntry(i));

    // If one of the possible encodings matches the locale encoding, use that.
    // Otherwise, if there is only one possible encoding, use that.
        // if the locale encoding matches, then assume we have a native encoding.
        if (encoding & mLocaleEncoding)
            convertValues(mLocaleEncoding);
    else if ((encoding & (encoding - 1)) == 0)
        convertValues(encoding);
    else {
        // TODO: try harder to disambiguate the encoding, perhaps by looking at
        // other files by same artist, or even the user's entire collection.
        // For now, fall through and insert the strings as they are.
    }

        // finally, push all name/value pairs to the client
        for (int i = 0; i < mNames->size(); i++) {
            if (!handleStringTag(mNames->getEntry(i), mValues->getEntry(i)))
                break;
        }
    }
    // else addStringTag() has done all the work so we have nothing to do

    delete mNames;