| /* |
| Copyright (c) 2016, The CyanogenMod Project |
| 2018, The LineageOS Project |
| Copyright (c) 2019-2020 Fairphone B.V. |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions are |
| met: |
| * Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| * Redistributions in binary form must reproduce the above |
| copyright notice, this list of conditions and the following |
| disclaimer in the documentation and/or other materials provided |
| with the distribution. |
| * Neither the name of The Linux Foundation nor the names of its |
| contributors may be used to endorse or promote products derived |
| from this software without specific prior written permission. |
| |
| THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| #include <android-base/file.h> |
| #include <android-base/logging.h> |
| #include <android-base/strings.h> |
| |
| #include "property_service.h" |
| #include "vendor_init.h" |
| |
| #include "init_msm8974.h" |
| |
| using android::base::ERROR; |
| using android::base::INFO; |
| using android::base::ReadFileToString; |
| using android::base::Trim; |
| using android::init::property_set; |
| |
| namespace { |
| |
| void init_gles_properties() |
| { |
| static const char s_OpenGLESv21[] = "131072"; |
| static const char s_OpenGLESv30[] = "196608"; |
| static const std::string s_settings_file = |
| "/data/misc/fairphone/experimental_gles3"; |
| |
| std::string experimental_gles3 = "0"; |
| |
| if (ReadFileToString(s_settings_file, &experimental_gles3)) { |
| experimental_gles3 = Trim(experimental_gles3); |
| if (experimental_gles3 != "0" && experimental_gles3 != "1") { |
| LOG(ERROR) << "Invalid contents in " << s_settings_file << ": " |
| << experimental_gles3 |
| << ". Defaulting property experimental_gles3 to 0"; |
| } |
| else { |
| LOG(INFO) << "Reading experimental_gles3 value of " |
| << experimental_gles3; |
| } |
| } else { |
| LOG(INFO) << "experimental_gles3 property is not set. Defaulting to 0."; |
| } |
| |
| property_set( |
| "ro.opengles.version", |
| experimental_gles3 == "1" ? s_OpenGLESv30 : s_OpenGLESv21); |
| } |
| |
| } |
| |
| void vendor_load_persist_properties() |
| { |
| init_gles_properties(); |
| } |