//static bool MediaAnalyticsItem::isEnabled() { int enabled = property_get_int32(MediaAnalyticsItem::EnabledProperty, -1); if (enabled == -1) { enabled = property_get_int32(MediaAnalyticsItem::EnabledPropertyPersist, -1); } if (enabled == -1) { enabled = MediaAnalyticsItem::EnabledProperty_default; } if (enabled <= 0) { return false; } return true; }
static void calculate_max_cpu_freq() { int32_t is_svelte = property_get_int32(SVELTE_PROP, 0); if (is_svelte) { char prop_buffer[PROPERTY_VALUE_MAX]; int len = property_get(SVELTE_MAX_FREQ_PROP, prop_buffer, LOW_POWER_MAX_FREQ); max_cpu_freq = strndup(prop_buffer, len); len = property_get(SVELTE_LOW_POWER_MAX_FREQ_PROP, prop_buffer, LOW_POWER_MAX_FREQ); low_power_max_cpu_freq = strndup(prop_buffer, len); } }
void DrawProfiler::createData() { if (mData) return; mDataSize = property_get_int32(PROPERTY_PROFILE_MAXFRAMES, DEFAULT_MAX_FRAMES); if (mDataSize <= 0) mDataSize = 1; if (mDataSize > 4096) mDataSize = 4096; // Reasonable maximum mData = (FrameTimingData*) calloc(mDataSize, sizeof(FrameTimingData)); mRects = new float*[NUM_ELEMENTS]; for (int i = 0; i < NUM_ELEMENTS; i++) { // 4 floats per rect mRects[i] = (float*) calloc(mDataSize, 4 * sizeof(float)); } mCurrentFrame = 0; }
// Check whether the given command line matches one of the comma-separated // values listed in the app_cmdlines property. static bool atrace_is_cmdline_match(const char* cmdline) { int count = property_get_int32("debug.atrace.app_number", 0); char buf[PROPERTY_KEY_MAX]; char value[PROPERTY_VALUE_MAX]; for (int i = 0; i < count; i++) { snprintf(buf, sizeof(buf), "debug.atrace.app_%d", i); property_get(buf, value, ""); if (strcmp(value, cmdline) == 0) { return true; } } return false; }
TEST_F(PropertiesTest, GetInt32) { const int32_t DEFAULT_VALUE = INT32_C(0xDEADBEEF); const std::string intMaxString = ToString(INT32_MAX); const std::string intStringOverflow = intMaxString + "0"; const std::string intMinString = ToString(INT32_MIN); const std::string intStringUnderflow = intMinString + "0"; const char* setValues[] = { // base 10 "1", "2", "12345", "-1", "-2", "-12345", // base 16 "0xFF", "0x0FF", "0xC0FFEE", "0Xf00", // base 8 "0", "01234", "07", // corner cases " 2", "2 ", "+0", "-0", " +0 ", intMaxString.c_str(), intMinString.c_str(), // failing cases NULL, "", " ", " ", "hello", " true ", "y", intStringOverflow.c_str(), intStringUnderflow.c_str(), }; int32_t getValues[] = { // base 10 1, 2, 12345, -1, -2, -12345, // base 16 0xFF, 0x0FF, 0xC0FFEE, 0Xf00, // base 8 0, 01234, 07, // corner cases 2, 2, 0, 0, 0, INT32_MAX, INT32_MIN, // failing cases DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE, }; ASSERT_EQ(arraysize(setValues), arraysize(getValues)); for (size_t i = 0; i < arraysize(setValues); ++i) { ASSERT_OK(property_set(PROPERTY_TEST_KEY, setValues[i])); int32_t val = property_get_int32(PROPERTY_TEST_KEY, DEFAULT_VALUE); EXPECT_PRED_FORMAT2(AssertEqualHex, getValues[i], val) << "Property was set to '" << setValues[i] << "'"; } }
void ScreenRecoveryUI::Init() { gr_init(); density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f; is_large_ = gr_fb_height() > PixelsFromDp(800); gr_font_size(&char_width_, &char_height_); text_rows_ = gr_fb_height() / char_height_; text_cols_ = gr_fb_width() / char_width_; text_ = Alloc2d(text_rows_, text_cols_ + 1); file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1); menu_ = Alloc2d(text_rows_, text_cols_ + 1); text_col_ = text_row_ = 0; text_top_ = 1; LoadBitmap("icon_error", &error_icon); LoadBitmap("progress_empty", &progressBarEmpty); LoadBitmap("progress_fill", &progressBarFill); LoadBitmap("stage_empty", &stageMarkerEmpty); LoadBitmap("stage_fill", &stageMarkerFill); // Background text for "installing_update" could be "installing update" // or "installing security update". It will be set after UI init according // to commands in BCB. installing_text = nullptr; LoadLocalizedBitmap("erasing_text", &erasing_text); LoadLocalizedBitmap("no_command_text", &no_command_text); LoadLocalizedBitmap("error_text", &error_text); LoadAnimation(); pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this); RecoveryUI::Init(); }