Skip to content

Instantly share code, notes, and snippets.

@fletchto99 fletchto99/index.js
Created Nov 20, 2016

Embed
What would you like to do?
Pebble App sandbox escape, malicious application
Pebble.addEventListener('ready', function() {
console.log("Hello from the evil app");
});
#include <pebble.h>
static Window *s_window;
static TextLayer *s_text_layer;
static int clicks = 1;
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
clicks++;
persist_write_int(1, clicks);
}
static void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
}
static void init(void) {
// Create a window and get information about the window
persist_write_int(1, clicks);
s_window = window_create();
window_set_click_config_provider(s_window, click_config_provider);
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_bounds(window_layer);
// Create a text layer and set the text
s_text_layer = text_layer_create(bounds);
text_layer_set_text(s_text_layer, "Test 1!");
// Set the font and text alignment
text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
// Add the text layer to the window
layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_text_layer));
// Enable text flow and paging on the text layer, with a slight inset of 10, for round screens
text_layer_enable_screen_text_flow_and_paging(s_text_layer, 10);
// Push the window, setting the window animation to 'true'
window_stack_push(s_window, true);
// App Logging!
APP_LOG(APP_LOG_LEVEL_DEBUG, "Just pushed a window!");
}
static void deinit(void) {
// Destroy the text layer
text_layer_destroy(s_text_layer);
// Destroy the window
window_destroy(s_window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.