Flutter Impeller
shadow_realm.cc
Go to the documentation of this file.
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 
6 
7 #include <sys/system_properties.h>
8 
9 namespace impeller::android {
10 
11 constexpr std::string_view kAndroidHuawei = "android-huawei";
12 
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 == "28" || first_api_level == "27" ||
31  first_api_level == "26" || first_api_level == "25" ||
32  first_api_level == "24") {
33  return true;
34  }
35  // From local testing, neither the swapchain nor AHB import works, see also:
36  // https://github.com/flutter/flutter/issues/154068
37  if (clientidbase == kAndroidHuawei && api_level <= 29) {
38  return true;
39  }
40  return false;
41 }
42 
43 } // namespace impeller::android
impeller::android::ShadowRealm::ShouldDisableAHB
static bool ShouldDisableAHB()
Whether the device should disable any usage of Android Hardware Buffers regardless of stated support.
Definition: shadow_realm.cc:13
impeller::android::ShadowRealm::ShouldDisableAHBInternal
static bool ShouldDisableAHBInternal(std::string_view clientidbase, std::string_view first_api_level, uint32_t api_level)
Definition: shadow_realm.cc:25
impeller::android
Definition: choreographer.cc:9
shadow_realm.h
impeller::android::kAndroidHuawei
constexpr std::string_view kAndroidHuawei
Definition: shadow_realm.cc:11