src/third_party/angle/src/common/system_utils.cpp
// Call out to 'getprop' on a shell to get an Android property.  If the value was set, set an
// environment variable with that value.  Return the value of the environment variable.
Call out to 'getprop' on a shell to get an Android property.  If the value was set, set an
environment variable with that value.  Return the value of the environment variable.
Call out to ' getprop ' on a shell to get an Android property . If the value was set set an environment variable with that value . Return the value of the environment variable .
std::string GetEnvironmentVarFromAndroidProperty(const char *variableName, const char *propertyName)
{
#if defined(ANGLE_PLATFORM_ANDROID) && __ANDROID_API__ >= 21
    std::string sanitizedPropertyName = propertyName;
    sanitizedPropertyName.erase(
        std::remove(sanitizedPropertyName.begin(), sanitizedPropertyName.end(), '\''),
        sanitizedPropertyName.end());
    std::string command("getprop '");
    command += sanitizedPropertyName;
    command += "'";
    constexpr int kStreamSize = 64;
    char stream[kStreamSize]  = {};
    FILE *pipe                = popen(command.c_str(), "r");
    if (pipe != nullptr)
    {
        fgets(stream, kStreamSize, pipe);
        pclose(pipe);
    }
    std::string value(stream);
    value.erase(value.find_last_not_of(" \n\r\t") + 1);
    SetEnvironmentVar(variableName, value.c_str());
    return value;
#endif  
    return GetEnvironmentVar(variableName);
}
std :: string GetEnvironmentVarFromAndroidProperty ( const char * variableName , const char * propertyName ) { #if defined ( ANGLE_PLATFORM_ANDROID ) && __ANDROID_API__ >= 21 std :: string sanitizedPropertyName = propertyName ; sanitizedPropertyName . erase ( std :: remove ( sanitizedPropertyName . begin ( ) , sanitizedPropertyName . end ( ) , ' \' ' ) , sanitizedPropertyName . end ( ) ) ; std :: string command ( " " ) ; command += sanitizedPropertyName ; command += " " ; constexpr int kStreamSize = 64 ; char stream [ kStreamSize ] = { } ; FILE * pipe = popen ( command . c_str ( ) , " " ) ; if ( pipe != nullptr ) { fgets ( stream , kStreamSize , pipe ) ; pclose ( pipe ) ; } std :: string value ( stream ) ; value . erase ( value . find_last_not_of ( " \n \r \t " ) + 1 ) ; SetEnvironmentVar ( variableName , value . c_str ( ) ) ; return value ; #endif return GetEnvironmentVar ( variableName ) ; }
Call out to 'getprop' on a shell to get an Android property.
Call out to ' getprop ' on a shell to get an Android property .
// Run the command and open a I/O stream to read the value // Right strip white space // Set the environment variable with the value. // ANGLE_PLATFORM_ANDROID // Return the environment variable's value.