|
| 1 | + |
| 2 | +/* |
| 3 | + Copyright (c) 2018, The Lineage Project. All rights reserved. |
| 4 | + Redistribution and use in source and binary forms, with or without |
| 5 | + modification, are permitted provided that the following conditions are |
| 6 | + met: |
| 7 | + * Redistributions of source code must retain the above copyright |
| 8 | + notice, this list of conditions and the following disclaimer. |
| 9 | + * Redistributions in binary form must reproduce the above |
| 10 | + copyright notice, this list of conditions and the following |
| 11 | + disclaimer in the documentation and/or other materials provided |
| 12 | + with the distribution. |
| 13 | + * Neither the name of The Linux Foundation nor the names of its |
| 14 | + contributors may be used to endorse or promote products derived |
| 15 | + from this software without specific prior written permission. |
| 16 | + THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | + */ |
| 28 | + |
| 29 | +#include <stdlib.h> |
| 30 | +#include <string.h> |
| 31 | +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ |
| 32 | +#include <sys/_system_properties.h> |
| 33 | + |
| 34 | +#include <android-base/file.h> |
| 35 | +#include <android-base/logging.h> |
| 36 | +#include <android-base/strings.h> |
| 37 | +#include <android-base/properties.h> |
| 38 | + |
| 39 | +#include "property_service.h" |
| 40 | +#include "vendor_init.h" |
| 41 | + |
| 42 | +using android::base::GetProperty; |
| 43 | +using android::base::ReadFileToString; |
| 44 | +using android::base::Trim; |
| 45 | + |
| 46 | +void property_override(char const prop[], char const value[]) |
| 47 | +{ |
| 48 | + prop_info *pi; |
| 49 | + |
| 50 | + pi = (prop_info*) __system_property_find(prop); |
| 51 | + if (pi) |
| 52 | + __system_property_update(pi, value, strlen(value)); |
| 53 | + else |
| 54 | + __system_property_add(prop, strlen(prop), value, strlen(value)); |
| 55 | +} |
| 56 | + |
| 57 | +void property_override_dual(char const system_prop[], |
| 58 | + char const vendor_prop[], char const value[]) |
| 59 | +{ |
| 60 | + property_override(system_prop, value); |
| 61 | + property_override(vendor_prop, value); |
| 62 | +} |
| 63 | + |
| 64 | + |
| 65 | +void vendor_load_properties() |
| 66 | +{ |
| 67 | + std::string platform; |
| 68 | + std::string bootloader = GetProperty("ro.bootloader", ""); |
| 69 | + std::string device; |
| 70 | + |
| 71 | + platform = GetProperty("ro.board.platform", ""); |
| 72 | + if (platform != ANDROID_TARGET) |
| 73 | + return; |
| 74 | + |
| 75 | + if (bootloader.find("A320F") != std::string::npos) { |
| 76 | + |
| 77 | + /* SM-A320F */ |
| 78 | + property_override_dual("ro.product.model", "ro.vendor.product.model", "SM-A320F"); |
| 79 | + property_override_dual("ro.product.device", "ro.vendor.product.device", "a3y17ltexx"); |
| 80 | + |
| 81 | + } else if (bootloader.find("A320Y") != std::string::npos) { |
| 82 | + |
| 83 | + /* SM-A320Y */ |
| 84 | + property_override_dual("ro.product.model", "ro.vendor.product.model", "SM-A320Y"); |
| 85 | + property_override_dual("ro.product.device", "ro.vendor.product.device", "a3y17ltelk"); |
| 86 | + |
| 87 | + } else if (bootloader.find("A320FL") != std::string::npos) { |
| 88 | + |
| 89 | + /* SM-A320FL */ |
| 90 | + property_override_dual("ro.product.model", "ro.vendor.product.model", "SM-A320FL"); |
| 91 | + property_override_dual("ro.product.device", "ro.vendor.product.device", "a3xeltexc"); |
| 92 | + |
| 93 | + |
| 94 | + } |
| 95 | + |
| 96 | +} |
0 commit comments