|
| 1 | +// Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +#include "impeller/toolkit/android/shadow_realm.h" |
| 6 | + |
| 7 | +#include <sys/system_properties.h> |
| 8 | + |
| 9 | +namespace impeller::android { |
| 10 | + |
| 11 | +constexpr std::string_view kAndroidHuawei = "android-huawei"; |
| 12 | + |
| 13 | +bool ShadowRealm::ShouldDisableAHB() { |
| 14 | + char clientidbase[PROP_VALUE_MAX]; |
| 15 | + __system_property_get("ro.com.google.clientidbase", clientidbase); |
| 16 | + |
| 17 | + auto api_level = android_get_device_api_level(); |
| 18 | + char first_api_level[PROP_VALUE_MAX]; |
| 19 | + __system_property_get("ro.product.first_api_level", first_api_level); |
| 20 | + |
| 21 | + return ShouldDisableAHBInternal(clientidbase, first_api_level, api_level); |
| 22 | +} |
| 23 | + |
| 24 | +// static |
| 25 | +bool ShadowRealm::ShouldDisableAHBInternal(std::string_view clientidbase, |
| 26 | + std::string_view first_api_level, |
| 27 | + uint32_t api_level) { |
| 28 | + // Most devices that have updated to API 29 don't seem to correctly |
| 29 | + // support AHBs: https://github.com/flutter/flutter/issues/157113 |
| 30 | + if (first_api_level.compare("28") == 0 || |
| 31 | + first_api_level.compare("27") == 0 || |
| 32 | + first_api_level.compare("26") == 0 || |
| 33 | + first_api_level.compare("25") == 0 || |
| 34 | + first_api_level.compare("24") == 0) { |
| 35 | + return true; |
| 36 | + } |
| 37 | + // From local testing, neither the swapchain nor AHB import works, see also: |
| 38 | + // https://github.com/flutter/flutter/issues/154068 |
| 39 | + if (clientidbase == kAndroidHuawei && api_level <= 29) { |
| 40 | + return true; |
| 41 | + } |
| 42 | + return false; |
| 43 | +} |
| 44 | + |
| 45 | +} // namespace impeller::android |
0 commit comments