Adithya R | ba1dcb4 | 2023-12-08 05:53:08 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2023 Paranoid Android |
| 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | */ |
| 6 | |
| 7 | #include <stdlib.h> |
| 8 | #include <string.h> |
| 9 | |
| 10 | #include "system_properties/prop_imitation_hooks.h" |
| 11 | |
| 12 | #define GMS_UNSTABLE "com.google.android.gms.unstable" |
| 13 | |
| 14 | #define PROP_SECURITY_PATCH "ro.build.version.security_patch" |
| 15 | #define PROP_PIH_SECURITY_PATCH "persist.sys.pihooks.security_patch" |
| 16 | |
| 17 | #define PROP_FIRST_API_LEVEL "ro.product.first_api_level" |
| 18 | #define PROP_PIH_FIRST_API_LEVEL "persist.sys.pihooks.first_api_level" |
| 19 | |
| 20 | void PropImitationHooks::OnFind(const char** name) { |
| 21 | if (getprogname() == nullptr || strcmp(getprogname(), GMS_UNSTABLE) != 0) { |
| 22 | return; |
| 23 | } |
| 24 | PIH_LOG("name is %s", *name); |
| 25 | if (strcmp(*name, PROP_SECURITY_PATCH) == 0) { |
| 26 | *name = PROP_PIH_SECURITY_PATCH; |
| 27 | } else if (strcmp(*name, PROP_FIRST_API_LEVEL) == 0) { |
| 28 | *name = PROP_PIH_FIRST_API_LEVEL; |
| 29 | } else { |
| 30 | return; |
| 31 | } |
| 32 | PIH_LOG("name changed to %s", *name); |
| 33 | } |