├── .gitattributes
├── .gitignore
├── .gitmodules
├── AndroidManifest.xml
├── README.md
├── build.xml
├── jni
├── Android.mk
├── Application.mk
├── dl_internal.h
├── dobby.cpp
├── dobby.h
├── dobby_public.h
├── main.cpp
├── main.h
└── substrate.h
├── libs
└── fmod.jar
├── prebuilts
└── tinysubstrate-bin
│ ├── Android.mk
│ └── libgenericlauncher_tinysubstrate.so
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-ldpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── layout
│ └── testbutton.xml
└── values
│ └── strings.xml
└── src
├── .gitignore
└── com
├── byteandahalf
└── genericlauncher
│ ├── GenericLauncher.java
│ ├── NativeHandler.java
│ ├── RedirectPackageManager.java
│ ├── TestButton.java
│ ├── Utils.java
│ ├── WrappedPackageManager.java
│ └── ui
│ └── LauncherActivity.java
└── mojang
├── android
└── net
│ ├── HTTPClientManager.java
│ ├── HTTPRequest.java
│ ├── HTTPResponse.java
│ └── NoCertSSLSocketFactory.java
└── minecraftpe
├── HardwareInformation.java
├── MainActivity.java
└── store
├── NativeStoreListener.java
├── Product.java
├── Purchase.java
├── Store.java
├── StoreFactory.java
└── StoreListener.java
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # vim swap file
6 |
7 | *.swp
8 |
9 | # files for the dex VM
10 | *.dex
11 |
12 | # Java class files
13 | *.class
14 |
15 | # generated files
16 | bin/
17 | gen/
18 | obj/
19 | libs/armeabi-v7a/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Eclipse project files
25 | .classpath
26 | .project
27 | .settings/
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Intellij project files
33 | *.iml
34 | *.ipr
35 | *.iws
36 | .idea/
37 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "jni/substrate"]
2 | path = jni/substrate
3 | url = git://git.saurik.com/substrate.git
4 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
22 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | GenericLauncher
2 | ================
3 |
4 | A base for Minecraft PE hacked clients. Starts you off with a basic launcher base that you can use to build off of. Currently just starts up and plays MCPE like normal, make it do what you want.
5 |
6 | Take the code, and do what you want with it. It's a base for anyone to use. Change the package name, don't give me cradit, I don't care.
7 |
8 |
9 | A few thanks to @zhuowei. This app is a barebones base of his app, BlockLauncher.
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
40 |
41 |
42 |
43 |
47 |
48 |
60 |
61 |
62 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | LOCAL_LDLIBS := -llog
4 | LOCAL_MODULE := genericlauncher
5 | LOCAL_SRC_FILES := main.cpp dobby.cpp
6 |
7 | LOCAL_SHARED_LIBRARIES := tinysubstrate-bin
8 |
9 | include $(BUILD_SHARED_LIBRARY)
10 |
11 | $(call import-add-path, prebuilts)
12 |
13 | $(call import-module, tinysubstrate-bin)
14 |
--------------------------------------------------------------------------------
/jni/Application.mk:
--------------------------------------------------------------------------------
1 |
2 | APP_ABI := armeabi-v7a
3 | APP_PLATFORM := android-14
4 | APP_CFLAGS := -O2 -std=gnu99 -Wall
5 | APP_CPPFLAGS += -frtti -std=c++11
6 |
7 | APP_STL := gnustl_shared
--------------------------------------------------------------------------------
/jni/dl_internal.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | extern "C" {
3 | #endif
4 |
5 | typedef struct {
6 | char name[128];
7 | const void* phdr;
8 | int phnum;
9 | unsigned entry;
10 | unsigned base;
11 | unsigned size;
12 | } soinfo2;
13 |
14 | #ifdef __cplusplus
15 | }
16 | #endif
17 |
--------------------------------------------------------------------------------
/jni/dobby.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2008, 2009 The Android Open Source Project
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * * Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * * Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 | * SUCH DAMAGE.
27 | */
28 |
29 | #include
30 | #include
31 |
32 | static Elf_Sym* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name) {
33 | Elf_Sym* symtab = si->symtab;
34 | const char* strtab = si->strtab;
35 |
36 | for (unsigned n = si->bucket[hash % si->nbucket]; n != 0; n = si->chain[n]) {
37 | Elf_Sym* s = symtab + n;
38 | if (strcmp(strtab + s->st_name, name)) continue;
39 |
40 | /* only concern ourselves with global and weak symbol definitions */
41 | switch (ELF_ST_BIND(s->st_info)) {
42 | case STB_GLOBAL:
43 | case STB_WEAK:
44 | if (s->st_shndx == SHN_UNDEF) {
45 | continue;
46 | }
47 | return s;
48 | }
49 | }
50 |
51 | return NULL;
52 | }
53 |
54 | static unsigned elfhash(const char* _name) {
55 | const unsigned char* name = (const unsigned char*) _name;
56 | unsigned h = 0, g;
57 |
58 | while(*name) {
59 | h = (h << 4) + *name++;
60 | g = h & 0xf0000000;
61 | h ^= g;
62 | h ^= g >> 24;
63 | }
64 | return h;
65 | }
66 |
67 | /* This is used by dlsym(3). It performs symbol lookup only within the
68 | specified soinfo object and not in any of its dependencies.
69 |
70 | TODO: Only looking in the specified soinfo seems wrong. dlsym(3) says
71 | that it should do a breadth first search through the dependency
72 | tree. This agrees with the ELF spec (aka System V Application
73 | Binary Interface) where in Chapter 5 it discuss resolving "Shared
74 | Object Dependencies" in breadth first search order.
75 | */
76 | Elf_Sym* dlsym_handle_lookup(soinfo* si, const char* name) {
77 | return soinfo_elf_lookup(si, elfhash(name), name);
78 | }
79 |
80 | void* dobby_dlsym(void* handle, const char* symbol) {
81 |
82 | soinfo* found = NULL;
83 | Elf_Sym* sym = NULL;
84 | found = reinterpret_cast(handle);
85 | sym = dlsym_handle_lookup(found, symbol);
86 |
87 | if (sym != NULL) {
88 | return reinterpret_cast(sym->st_value + found->base/*load_bias*/);
89 | }
90 | __android_log_print(ANDROID_LOG_ERROR, "Dobby", "Failed when looking up %s\n", symbol);
91 | return NULL;
92 | }
93 |
--------------------------------------------------------------------------------
/jni/dobby.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2008 The Android Open Source Project
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * * Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * * Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 | * SUCH DAMAGE.
27 | */
28 |
29 | #ifndef _LINKER_H_
30 | #define _LINKER_H_
31 |
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | #include
38 |
39 | #include "dobby_public.h"
40 |
41 | // Returns the address of the page containing address 'x'.
42 | #define PAGE_START(x) ((x) & PAGE_MASK)
43 |
44 | // Returns the offset of address 'x' in its page.
45 | #define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)
46 |
47 | // Returns the address of the next page after address 'x', unless 'x' is
48 | // itself at the start of a page.
49 | #define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1))
50 |
51 | // Magic shared structures that GDB knows about.
52 |
53 | struct link_map_t {
54 | uintptr_t l_addr;
55 | char* l_name;
56 | uintptr_t l_ld;
57 | link_map_t* l_next;
58 | link_map_t* l_prev;
59 | };
60 |
61 | // Values for r_debug->state
62 | enum {
63 | RT_CONSISTENT,
64 | RT_ADD,
65 | RT_DELETE
66 | };
67 |
68 | struct r_debug {
69 | int32_t r_version;
70 | link_map_t* r_map;
71 | void (*r_brk)(void);
72 | int32_t r_state;
73 | uintptr_t r_ldbase;
74 | };
75 |
76 | #define FLAG_LINKED 0x00000001
77 | #define FLAG_EXE 0x00000004 // The main executable
78 | #define FLAG_LINKER 0x00000010 // The linker itself
79 |
80 | #define SOINFO_NAME_LEN 128
81 |
82 | typedef void (*linker_function_t)();
83 |
84 | // Android uses REL for 32-bit but only uses RELA for 64-bit.
85 | #if defined(__LP64__)
86 | #define USE_RELA 1
87 | #endif
88 |
89 | struct soinfo {
90 | public:
91 | char name[SOINFO_NAME_LEN];
92 | const Elf_Phdr* phdr;
93 | size_t phnum;
94 | Elf_Addr entry;
95 | Elf_Addr base;
96 | unsigned size;
97 |
98 | #ifndef __LP64__
99 | uint32_t unused1; // DO NOT USE, maintained for compatibility.
100 | #endif
101 |
102 | Elf_Dyn* dynamic;
103 |
104 | #ifndef __LP64__
105 | uint32_t unused2; // DO NOT USE, maintained for compatibility
106 | uint32_t unused3; // DO NOT USE, maintained for compatibility
107 | #endif
108 |
109 | soinfo* next;
110 | unsigned flags;
111 |
112 | const char* strtab;
113 | Elf_Sym* symtab;
114 |
115 | size_t nbucket;
116 | size_t nchain;
117 | unsigned* bucket;
118 | unsigned* chain;
119 |
120 | #if !defined(__LP64__)
121 | // This is only used by 32-bit MIPS, but needs to be here for
122 | // all 32-bit architectures to preserve binary compatibility.
123 | unsigned* plt_got;
124 | #endif
125 |
126 | #if defined(USE_RELA)
127 | Elf_Rela* plt_rela;
128 | size_t plt_rela_count;
129 |
130 | Elf_Rela* rela;
131 | size_t rela_count;
132 | #else
133 | Elf_Rel* plt_rel;
134 | size_t plt_rel_count;
135 |
136 | Elf_Rel* rel;
137 | size_t rel_count;
138 | #endif
139 |
140 | linker_function_t* preinit_array;
141 | size_t preinit_array_count;
142 |
143 | linker_function_t* init_array;
144 | size_t init_array_count;
145 | linker_function_t* fini_array;
146 | size_t fini_array_count;
147 |
148 | linker_function_t init_func;
149 | linker_function_t fini_func;
150 |
151 | #if defined(__arm__)
152 | // ARM EABI section used for stack unwinding.
153 | unsigned* ARM_exidx;
154 | size_t ARM_exidx_count;
155 | #elif defined(__mips__)
156 | unsigned mips_symtabno;
157 | unsigned mips_local_gotno;
158 | unsigned mips_gotsym;
159 | #endif
160 |
161 | size_t ref_count;
162 | link_map_t link_map;
163 |
164 | bool constructors_called;
165 |
166 | // When you read a virtual address from the ELF file, add this
167 | // value to get the corresponding address in the process' address space.
168 | Elf_Addr load_bias;
169 |
170 | #if !defined(__LP64__)
171 | bool has_text_relocations;
172 | #endif
173 | bool has_DT_SYMBOLIC;
174 |
175 | void CallConstructors();
176 | void CallDestructors();
177 | void CallPreInitConstructors();
178 |
179 | private:
180 | void CallArray(const char* array_name, linker_function_t* functions, size_t count, bool reverse);
181 | void CallFunction(const char* function_name, linker_function_t function);
182 | };
183 |
184 | extern soinfo libdl_info;
185 |
186 | void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
187 | soinfo* do_dlopen(const char* name, int flags);
188 | int do_dlclose(soinfo* si);
189 |
190 | Elf_Sym* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start);
191 | soinfo* find_containing_library(const void* addr);
192 |
193 | Elf_Sym* dladdr_find_symbol(soinfo* si, const void* addr);
194 | Elf_Sym* dlsym_handle_lookup(soinfo* si, const char* name);
195 |
196 | void debuggerd_init();
197 | extern "C" void notify_gdb_of_libraries();
198 |
199 | char* linker_get_error_buffer();
200 | size_t linker_get_error_buffer_size();
201 |
202 | #endif
203 |
--------------------------------------------------------------------------------
/jni/dobby_public.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | extern "C" {
3 | #endif
4 | void* dobby_dlsym(void* handle, const char* symbol);
5 | #ifdef __cplusplus
6 | }
7 | #endif
8 |
--------------------------------------------------------------------------------
/jni/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | #include
16 |
17 | /*
18 | Put some typedefs and structs here
19 | */
20 | typedef void Level;
21 | typedef void Player;
22 | typedef void Minecraft;
23 | typedef void MinecraftClient;
24 | typedef Player LocalPlayer;
25 |
26 | bool HEY_FUNCTIONS_HOOKED_ALREADY_BRO = false;
27 |
28 | JavaVM* javaVM;
29 | jclass nativehandler_class;
30 |
31 | static std::string (*hk_Common_getGameVersionString_real)();
32 | static void (*hk_MinecraftClient_init_real)(MinecraftClient*);
33 | static bool (*hk_Minecraft_isModded_real)(Minecraft*);
34 |
35 | void MSHookFunction(void* symbol, void* hook, void** real);
36 |
37 | static Minecraft* minecraft_inst;
38 | static MinecraftClient* mcclient_inst;
39 | static LocalPlayer* localplayer_inst;
40 | static Level* level_inst = NULL;
41 |
42 | std::string hk_Common_getGameVersionString_hook() {
43 | // If the world hasn't loaded yet, print the usual version number(for the title screen)
44 | // else, return a blank string so the version watermark is absent in game.
45 | if (level_inst == NULL) { // Since I deleted the hook that gave Level a definition, Level will be always null
46 | return "v0.14.0";
47 | } else {
48 | return " ";
49 | }
50 | }
51 |
52 | void hk_MinecraftClient_init_hook(MinecraftClient* client) {
53 | __android_log_print(ANDROID_LOG_INFO, "GenericLauncher", "MinecraftClient::init");
54 | mcclient_inst = client;
55 | hk_MinecraftClient_init_real(client);
56 | }
57 |
58 | bool hk_Minecraft_isModded_hook(Minecraft* mc) {
59 | return true;
60 | }
61 |
62 | JNIEXPORT jint JNICALL Java_net_zhuoweizhang_pokerface_PokerFace_mprotect(JNIEnv* env, jclass clazz, jlong addr, jlong len, jint prot) {
63 | return mprotect((void *)(uintptr_t) addr, len, prot);
64 | }
65 |
66 | JNIEXPORT jlong JNICALL Java_net_zhuoweizhang_pokerface_PokerFace_sysconf(JNIEnv* env, jclass clazz, jint name) {
67 | long result = sysconf(name);
68 | return result;
69 | }
70 |
71 | JNIEXPORT void JNICALL Java_com_byteandahalf_genericlauncher_NativeHandler_nativeSetupHooks(JNIEnv* env, jclass clazz) {
72 | __android_log_print(ANDROID_LOG_INFO, "GenericLauncher", "SetupHook");
73 | // Let's not call every hook 3.000.000 times, OK?
74 | if(HEY_FUNCTIONS_HOOKED_ALREADY_BRO == true) return;
75 |
76 | void *handle;
77 | handle = dlopen("libminecraftpe.so", RTLD_LAZY);
78 | soinfo2* weakhandle = (soinfo2*) dlopen("libminecraftpe.so", RTLD_LAZY);
79 |
80 | void* hk_Common_getGameVersionString = dlsym(handle, "_ZN6Common20getGameVersionStringEv");
81 | MSHookFunction(hk_Common_getGameVersionString, (void*) &hk_Common_getGameVersionString_hook, (void**) &hk_Common_getGameVersionString_real);
82 |
83 | void* hk_MinecraftClient_init = dlsym(handle, "_ZN15MinecraftClient4initEv");
84 | MSHookFunction(hk_MinecraftClient_init, (void*) &hk_MinecraftClient_init_hook, (void**) &hk_MinecraftClient_init_real);
85 |
86 | void* hk_Minecraft_isModded = dlsym(handle, "_ZN9Minecraft8isModdedEv");
87 | MSHookFunction(hk_Minecraft_isModded, (void*) &hk_Minecraft_isModded_hook, (void**) &hk_Minecraft_isModded_real);
88 |
89 | dlerror();
90 |
91 | jclass clz = env->FindClass("com/byteandahalf/genericlauncher/NativeHandler");
92 | nativehandler_class = (jclass) env->NewGlobalRef(clz); // No idea why I have to cast to a jclass
93 |
94 | HEY_FUNCTIONS_HOOKED_ALREADY_BRO = true;
95 |
96 | const char* myerror = dlerror();
97 | if (myerror != NULL) {
98 | __android_log_print(ANDROID_LOG_ERROR, "HALP", "Hooking errors: %s\n", myerror);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/jni/main.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_byteandahalf_genericlauncher_NativeHandler */
4 |
5 | #ifndef _Included_com_byteandahalf_genericlauncher_NativeHandler
6 | #define _Included_com_byteandahalf_genericlauncher_NativeHandler
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: com_byteandahalf_genericlauncher_NativeHandler
12 | * Method: nativeSetupHooks
13 | * Signature: ()V
14 | */
15 | JNIEXPORT void JNICALL Java_com_byteandahalf_genericlauncher_NativeHandler_nativeSetupHooks
16 | (JNIEnv *, jclass);
17 |
18 | #ifdef __cplusplus
19 | }
20 | #endif
21 | #endif
22 |
--------------------------------------------------------------------------------
/jni/substrate.h:
--------------------------------------------------------------------------------
1 | /* Cydia Substrate - Powerful Code Insertion Platform
2 | * Copyright (C) 2008-2011 Jay Freeman (saurik)
3 | */
4 |
5 | /* GNU Lesser General Public License, Version 3 {{{ */
6 | /*
7 | * Substrate is free software: you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the
9 | * Free Software Foundation, either version 3 of the License, or (at your
10 | * option) any later version.
11 | *
12 | * Substrate is distributed in the hope that it will be useful, but WITHOUT
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 | * License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public License
18 | * along with Substrate. If not, see .
19 | **/
20 | /* }}} */
21 |
22 | #ifndef SUBSTRATE_H_
23 | #define SUBSTRATE_H_
24 |
25 | #ifdef __APPLE__
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 | #include
30 | #ifdef __cplusplus
31 | }
32 | #endif
33 |
34 | #include
35 | #include
36 | #endif
37 |
38 | #include
39 | #include
40 |
41 | #define _finline \
42 | inline __attribute__((__always_inline__))
43 | #define _disused \
44 | __attribute__((__unused__))
45 |
46 | #define _extern \
47 | extern "C" __attribute__((__visibility__("default")))
48 |
49 | #ifdef __cplusplus
50 | #define _default(value) = value
51 | #else
52 | #define _default(value)
53 | #endif
54 |
55 | #ifdef __cplusplus
56 | extern "C" {
57 | #endif
58 |
59 | bool MSHookProcess(pid_t pid, const char *library);
60 |
61 | typedef const void *MSImageRef;
62 |
63 | MSImageRef MSGetImageByName(const char *file);
64 | void *MSFindSymbol(MSImageRef image, const char *name);
65 |
66 | void MSHookFunction(void *symbol, void *replace, void **result);
67 |
68 | #ifdef __APPLE__
69 | #ifdef __arm__
70 | __attribute__((__deprecated__))
71 | IMP MSHookMessage(Class _class, SEL sel, IMP imp, const char *prefix _default(NULL));
72 | #endif
73 | void MSHookMessageEx(Class _class, SEL sel, IMP imp, IMP *result);
74 | #endif
75 |
76 | #ifdef SubstrateInternal
77 | typedef void *SubstrateAllocatorRef;
78 | typedef struct __SubstrateProcess *SubstrateProcessRef;
79 | typedef struct __SubstrateMemory *SubstrateMemoryRef;
80 |
81 | SubstrateProcessRef SubstrateProcessCreate(SubstrateAllocatorRef allocator, pid_t pid);
82 | void SubstrateProcessRelease(SubstrateProcessRef process);
83 |
84 | SubstrateMemoryRef SubstrateMemoryCreate(SubstrateAllocatorRef allocator, SubstrateProcessRef process, void *data, size_t size);
85 | void SubstrateMemoryRelease(SubstrateMemoryRef memory);
86 | #endif
87 |
88 | #ifdef __cplusplus
89 | }
90 | #endif
91 |
92 | #ifdef __cplusplus
93 |
94 | #ifdef SubstrateInternal
95 | struct SubstrateHookMemory {
96 | SubstrateMemoryRef handle_;
97 |
98 | SubstrateHookMemory(SubstrateProcessRef process, void *data, size_t size) :
99 | handle_(SubstrateMemoryCreate(NULL, NULL, data, size))
100 | {
101 | }
102 |
103 | ~SubstrateHookMemory() {
104 | if (handle_ != NULL)
105 | SubstrateMemoryRelease(handle_);
106 | }
107 | };
108 | #endif
109 |
110 | #ifdef __APPLE__
111 |
112 | namespace etl {
113 |
114 | template
115 | struct Case {
116 | static char value[Case_ + 1];
117 | };
118 |
119 | typedef Case Yes;
120 | typedef Case No;
121 |
122 | namespace be {
123 | template
124 | static Yes CheckClass_(void (Checked_::*)());
125 |
126 | template
127 | static No CheckClass_(...);
128 | }
129 |
130 | template
131 | struct IsClass {
132 | void gcc32();
133 |
134 | static const bool value = (sizeof(be::CheckClass_(0).value) == sizeof(Yes::value));
135 | };
136 |
137 | }
138 |
139 | #ifdef __arm__
140 | template
141 | __attribute__((__deprecated__))
142 | static inline Type_ *MSHookMessage(Class _class, SEL sel, Type_ *imp, const char *prefix = NULL) {
143 | return reinterpret_cast(MSHookMessage(_class, sel, reinterpret_cast(imp), prefix));
144 | }
145 | #endif
146 |
147 | template
148 | static inline void MSHookMessage(Class _class, SEL sel, Type_ *imp, Type_ **result) {
149 | return MSHookMessageEx(_class, sel, reinterpret_cast(imp), reinterpret_cast(result));
150 | }
151 |
152 | template
153 | static inline Type_ &MSHookIvar(id self, const char *name) {
154 | Ivar ivar(class_getInstanceVariable(object_getClass(self), name));
155 | void *pointer(ivar == NULL ? NULL : reinterpret_cast(self) + ivar_getOffset(ivar));
156 | return *reinterpret_cast(pointer);
157 | }
158 |
159 | #define MSAddMessage0(_class, type, arg0) \
160 | class_addMethod($ ## _class, @selector(arg0), (IMP) &$ ## _class ## $ ## arg0, type);
161 | #define MSAddMessage1(_class, type, arg0) \
162 | class_addMethod($ ## _class, @selector(arg0:), (IMP) &$ ## _class ## $ ## arg0 ## $, type);
163 | #define MSAddMessage2(_class, type, arg0, arg1) \
164 | class_addMethod($ ## _class, @selector(arg0:arg1:), (IMP) &$ ## _class ## $ ## arg0 ## $ ## arg1 ## $, type);
165 | #define MSAddMessage3(_class, type, arg0, arg1, arg2) \
166 | class_addMethod($ ## _class, @selector(arg0:arg1:arg2:), (IMP) &$ ## _class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $, type);
167 | #define MSAddMessage4(_class, type, arg0, arg1, arg2, arg3) \
168 | class_addMethod($ ## _class, @selector(arg0:arg1:arg2:arg3:), (IMP) &$ ## _class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $ ## arg3 ## $, type);
169 | #define MSAddMessage5(_class, type, arg0, arg1, arg2, arg3, arg4) \
170 | class_addMethod($ ## _class, @selector(arg0:arg1:arg2:arg3:arg4:), (IMP) &$ ## _class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $ ## arg3 ## $ ## arg4 ## $, type);
171 | #define MSAddMessage6(_class, type, arg0, arg1, arg2, arg3, arg4, arg5) \
172 | class_addMethod($ ## _class, @selector(arg0:arg1:arg2:arg3:arg4:arg5:), (IMP) &$ ## _class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $ ## arg3 ## $ ## arg4 ## $ ## arg5 ## $, type);
173 |
174 | #define MSHookMessage0(_class, arg0) \
175 | MSHookMessage($ ## _class, @selector(arg0), MSHake(_class ## $ ## arg0))
176 | #define MSHookMessage1(_class, arg0) \
177 | MSHookMessage($ ## _class, @selector(arg0:), MSHake(_class ## $ ## arg0 ## $))
178 | #define MSHookMessage2(_class, arg0, arg1) \
179 | MSHookMessage($ ## _class, @selector(arg0:arg1:), MSHake(_class ## $ ## arg0 ## $ ## arg1 ## $))
180 | #define MSHookMessage3(_class, arg0, arg1, arg2) \
181 | MSHookMessage($ ## _class, @selector(arg0:arg1:arg2:), MSHake(_class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $))
182 | #define MSHookMessage4(_class, arg0, arg1, arg2, arg3) \
183 | MSHookMessage($ ## _class, @selector(arg0:arg1:arg2:arg3:), MSHake(_class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $ ## arg3 ## $))
184 | #define MSHookMessage5(_class, arg0, arg1, arg2, arg3, arg4) \
185 | MSHookMessage($ ## _class, @selector(arg0:arg1:arg2:arg3:arg4:), MSHake(_class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $ ## arg3 ## $ ## arg4 ## $))
186 | #define MSHookMessage6(_class, arg0, arg1, arg2, arg3, arg4, arg5) \
187 | MSHookMessage($ ## _class, @selector(arg0:arg1:arg2:arg3:arg4:arg5:), MSHake(_class ## $ ## arg0 ## $ ## arg1 ## $ ## arg2 ## $ ## arg3 ## $ ## arg4 ## $ ## arg5 ## $))
188 |
189 | #define MSRegister_(name, dollar, colon) \
190 | static class C_$ ## name ## $ ## dollar { public: _finline C_$ ## name ## $ ##dollar() { \
191 | MSHookMessage($ ## name, @selector(colon), MSHake(name ## $ ## dollar)); \
192 | } } V_$ ## name ## $ ## dollar; \
193 |
194 | #define MSIgnore_(name, dollar, colon)
195 |
196 | #define MSMessage_(extra, type, _class, name, dollar, colon, call, args...) \
197 | static type _$ ## name ## $ ## dollar(Class _cls, type (*_old)(_class, SEL, ## args, ...), type (*_spr)(struct objc_super *, SEL, ## args, ...), _class self, SEL _cmd, ## args); \
198 | MSHook(type, name ## $ ## dollar, _class self, SEL _cmd, ## args) { \
199 | Class const _cls($ ## name); \
200 | type (* const _old)(_class, SEL, ## args, ...) = reinterpret_cast(_ ## name ## $ ## dollar); \
201 | typedef type (*msgSendSuper_t)(struct objc_super *, SEL, ## args, ...); \
202 | msgSendSuper_t const _spr(::etl::IsClass::value ? reinterpret_cast(&objc_msgSendSuper_stret) : reinterpret_cast(&objc_msgSendSuper)); \
203 | return _$ ## name ## $ ## dollar call; \
204 | } \
205 | extra(name, dollar, colon) \
206 | static _finline type _$ ## name ## $ ## dollar(Class _cls, type (*_old)(_class, SEL, ## args, ...), type (*_spr)(struct objc_super *, SEL, ## args, ...), _class self, SEL _cmd, ## args)
207 |
208 | /* for((x=1;x!=7;++x)){ echo -n "#define MSMessage${x}_(extra, type, _class, name";for((y=0;y!=x;++y));do echo -n ", sel$y";done;for((y=0;y!=x;++y));do echo -n ", type$y, arg$y";done;echo ") \\";echo -n " MSMessage_(extra, type, _class, name,";for((y=0;y!=x;++y));do if [[ $y -ne 0 ]];then echo -n " ##";fi;echo -n " sel$y ## $";done;echo -n ", ";for((y=0;y!=x;++y));do echo -n "sel$y:";done;echo -n ", (_cls, _old, _spr, self, _cmd";for((y=0;y!=x;++y));do echo -n ", arg$y";done;echo -n ")";for((y=0;y!=x;++y));do echo -n ", type$y arg$y";done;echo ")";} */
209 |
210 | #define MSMessage0_(extra, type, _class, name, sel0) \
211 | MSMessage_(extra, type, _class, name, sel0, sel0, (_cls, _old, _spr, self, _cmd))
212 | #define MSMessage1_(extra, type, _class, name, sel0, type0, arg0) \
213 | MSMessage_(extra, type, _class, name, sel0 ## $, sel0:, (_cls, _old, _spr, self, _cmd, arg0), type0 arg0)
214 | #define MSMessage2_(extra, type, _class, name, sel0, sel1, type0, arg0, type1, arg1) \
215 | MSMessage_(extra, type, _class, name, sel0 ## $ ## sel1 ## $, sel0:sel1:, (_cls, _old, _spr, self, _cmd, arg0, arg1), type0 arg0, type1 arg1)
216 | #define MSMessage3_(extra, type, _class, name, sel0, sel1, sel2, type0, arg0, type1, arg1, type2, arg2) \
217 | MSMessage_(extra, type, _class, name, sel0 ## $ ## sel1 ## $ ## sel2 ## $, sel0:sel1:sel2:, (_cls, _old, _spr, self, _cmd, arg0, arg1, arg2), type0 arg0, type1 arg1, type2 arg2)
218 | #define MSMessage4_(extra, type, _class, name, sel0, sel1, sel2, sel3, type0, arg0, type1, arg1, type2, arg2, type3, arg3) \
219 | MSMessage_(extra, type, _class, name, sel0 ## $ ## sel1 ## $ ## sel2 ## $ ## sel3 ## $, sel0:sel1:sel2:sel3:, (_cls, _old, _spr, self, _cmd, arg0, arg1, arg2, arg3), type0 arg0, type1 arg1, type2 arg2, type3 arg3)
220 | #define MSMessage5_(extra, type, _class, name, sel0, sel1, sel2, sel3, sel4, type0, arg0, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \
221 | MSMessage_(extra, type, _class, name, sel0 ## $ ## sel1 ## $ ## sel2 ## $ ## sel3 ## $ ## sel4 ## $, sel0:sel1:sel2:sel3:sel4:, (_cls, _old, _spr, self, _cmd, arg0, arg1, arg2, arg3, arg4), type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4)
222 | #define MSMessage6_(extra, type, _class, name, sel0, sel1, sel2, sel3, sel4, sel5, type0, arg0, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \
223 | MSMessage_(extra, type, _class, name, sel0 ## $ ## sel1 ## $ ## sel2 ## $ ## sel3 ## $ ## sel4 ## $ ## sel5 ## $, sel0:sel1:sel2:sel3:sel4:sel5:, (_cls, _old, _spr, self, _cmd, arg0, arg1, arg2, arg3, arg4, arg5), type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)
224 |
225 | #define MSInstanceMessage0(type, _class, args...) MSMessage0_(MSIgnore_, type, _class *, _class, ## args)
226 | #define MSInstanceMessage1(type, _class, args...) MSMessage1_(MSIgnore_, type, _class *, _class, ## args)
227 | #define MSInstanceMessage2(type, _class, args...) MSMessage2_(MSIgnore_, type, _class *, _class, ## args)
228 | #define MSInstanceMessage3(type, _class, args...) MSMessage3_(MSIgnore_, type, _class *, _class, ## args)
229 | #define MSInstanceMessage4(type, _class, args...) MSMessage4_(MSIgnore_, type, _class *, _class, ## args)
230 | #define MSInstanceMessage5(type, _class, args...) MSMessage5_(MSIgnore_, type, _class *, _class, ## args)
231 | #define MSInstanceMessage6(type, _class, args...) MSMessage6_(MSIgnore_, type, _class *, _class, ## args)
232 |
233 | #define MSClassMessage0(type, _class, args...) MSMessage0_(MSIgnore_, type, Class, $ ## _class, ## args)
234 | #define MSClassMessage1(type, _class, args...) MSMessage1_(MSIgnore_, type, Class, $ ## _class, ## args)
235 | #define MSClassMessage2(type, _class, args...) MSMessage2_(MSIgnore_, type, Class, $ ## _class, ## args)
236 | #define MSClassMessage3(type, _class, args...) MSMessage3_(MSIgnore_, type, Class, $ ## _class, ## args)
237 | #define MSClassMessage4(type, _class, args...) MSMessage4_(MSIgnore_, type, Class, $ ## _class, ## args)
238 | #define MSClassMessage5(type, _class, args...) MSMessage5_(MSIgnore_, type, Class, $ ## _class, ## args)
239 | #define MSClassMessage6(type, _class, args...) MSMessage6_(MSIgnore_, type, Class, $ ## _class, ## args)
240 |
241 | #define MSInstanceMessageHook0(type, _class, args...) MSMessage0_(MSRegister_, type, _class *, _class, ## args)
242 | #define MSInstanceMessageHook1(type, _class, args...) MSMessage1_(MSRegister_, type, _class *, _class, ## args)
243 | #define MSInstanceMessageHook2(type, _class, args...) MSMessage2_(MSRegister_, type, _class *, _class, ## args)
244 | #define MSInstanceMessageHook3(type, _class, args...) MSMessage3_(MSRegister_, type, _class *, _class, ## args)
245 | #define MSInstanceMessageHook4(type, _class, args...) MSMessage4_(MSRegister_, type, _class *, _class, ## args)
246 | #define MSInstanceMessageHook5(type, _class, args...) MSMessage5_(MSRegister_, type, _class *, _class, ## args)
247 | #define MSInstanceMessageHook6(type, _class, args...) MSMessage6_(MSRegister_, type, _class *, _class, ## args)
248 |
249 | #define MSClassMessageHook0(type, _class, args...) MSMessage0_(MSRegister_, type, Class, $ ## _class, ## args)
250 | #define MSClassMessageHook1(type, _class, args...) MSMessage1_(MSRegister_, type, Class, $ ## _class, ## args)
251 | #define MSClassMessageHook2(type, _class, args...) MSMessage2_(MSRegister_, type, Class, $ ## _class, ## args)
252 | #define MSClassMessageHook3(type, _class, args...) MSMessage3_(MSRegister_, type, Class, $ ## _class, ## args)
253 | #define MSClassMessageHook4(type, _class, args...) MSMessage4_(MSRegister_, type, Class, $ ## _class, ## args)
254 | #define MSClassMessageHook5(type, _class, args...) MSMessage5_(MSRegister_, type, Class, $ ## _class, ## args)
255 | #define MSClassMessageHook6(type, _class, args...) MSMessage6_(MSRegister_, type, Class, $ ## _class, ## args)
256 |
257 | #define MSOldCall(args...) \
258 | _old(self, _cmd, ## args)
259 | #define MSSuperCall(args...) \
260 | _spr(& (struct objc_super) {self, class_getSuperclass(_cls)}, _cmd, ## args)
261 |
262 | #define MSIvarHook(type, name) \
263 | type &name(MSHookIvar(self, #name))
264 |
265 | #define MSClassHook(name) \
266 | @class name; \
267 | static Class $ ## name = objc_getClass(#name);
268 | #define MSMetaClassHook(name) \
269 | @class name; \
270 | static Class $$ ## name = object_getClass($ ## name);
271 |
272 | #endif/*__APPLE__*/
273 |
274 | template
275 | static inline void MSHookFunction(Type_ *symbol, Type_ *replace, Type_ **result) {
276 | return MSHookFunction(
277 | reinterpret_cast(symbol),
278 | reinterpret_cast(replace),
279 | reinterpret_cast(result)
280 | );
281 | }
282 |
283 | template
284 | static inline void MSHookFunction(Type_ *symbol, Type_ *replace) {
285 | return MSHookFunction(symbol, replace, reinterpret_cast(NULL));
286 | }
287 |
288 | template
289 | static inline void MSHookSymbol(Type_ *&value, const char *name, MSImageRef image = NULL) {
290 | value = reinterpret_cast(MSFindSymbol(image, name));
291 | }
292 |
293 | template
294 | static inline void MSHookFunction(const char *name, Type_ *replace, Type_ **result = NULL) {
295 | Type_ *symbol;
296 | MSHookSymbol(symbol, name);
297 | return MSHookFunction(symbol, replace, result);
298 | }
299 |
300 | #endif
301 |
302 | #define MSHook(type, name, args...) \
303 | _disused static type (*_ ## name)(args); \
304 | static type $ ## name(args)
305 |
306 | #ifdef __cplusplus
307 | #define MSHake(name) \
308 | &$ ## name, &_ ## name
309 | #else
310 | #define MSHake(name) \
311 | &$ ## name, (void **) &_ ## name
312 | #endif
313 |
314 | #define MSInitialize \
315 | __attribute__((__constructor__)) static void _MSInitialize(void)
316 |
317 | #define Foundation_f "/System/Library/Frameworks/Foundation.framework/Foundation"
318 | #define UIKit_f "/System/Library/Frameworks/UIKit.framework/UIKit"
319 | #define JavaScriptCore_f "/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore"
320 | #define IOKit_f "/System/Library/Frameworks/IOKit.framework/IOKit"
321 |
322 | #endif//SUBSTRATE_H_
323 |
--------------------------------------------------------------------------------
/libs/fmod.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byteandahalf/GenericLauncher/bc8a2a3e0c14b4dc5750f47fb2949b812c95bcd8/libs/fmod.jar
--------------------------------------------------------------------------------
/prebuilts/tinysubstrate-bin/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 | LOCAL_MODULE := tinysubstrate-bin
5 | LOCAL_SRC_FILES := libgenericlauncher_tinysubstrate.so
6 | include $(PREBUILT_SHARED_LIBRARY)
--------------------------------------------------------------------------------
/prebuilts/tinysubstrate-bin/libgenericlauncher_tinysubstrate.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byteandahalf/GenericLauncher/bc8a2a3e0c14b4dc5750f47fb2949b812c95bcd8/prebuilts/tinysubstrate-bin/libgenericlauncher_tinysubstrate.so
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-22
15 |
16 | android.library=false
17 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byteandahalf/GenericLauncher/bc8a2a3e0c14b4dc5750f47fb2949b812c95bcd8/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byteandahalf/GenericLauncher/bc8a2a3e0c14b4dc5750f47fb2949b812c95bcd8/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byteandahalf/GenericLauncher/bc8a2a3e0c14b4dc5750f47fb2949b812c95bcd8/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byteandahalf/GenericLauncher/bc8a2a3e0c14b4dc5750f47fb2949b812c95bcd8/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/testbutton.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | GenericLauncher
4 | GenericLauncher
5 |
--------------------------------------------------------------------------------
/src/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 | obj/
15 | libs/armeabi-v7a/
16 |
17 | # Local configuration file (sdk path, etc)
18 | local.properties
19 |
20 | # Eclipse project files
21 | .classpath
22 | .project
23 | .settings/
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Intellij project files
29 | *.iml
30 | *.ipr
31 | *.iws
32 | .idea/
33 |
--------------------------------------------------------------------------------
/src/com/byteandahalf/genericlauncher/GenericLauncher.java:
--------------------------------------------------------------------------------
1 | package com.byteandahalf.genericlauncher;
2 |
3 | import android.app.Application;
4 |
5 | public class GenericLauncher extends Application {
6 | @Override
7 | public void onCreate() {
8 | Utils.setContext(getApplicationContext());
9 | super.onCreate();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/com/byteandahalf/genericlauncher/NativeHandler.java:
--------------------------------------------------------------------------------
1 | package com.byteandahalf.genericlauncher;
2 |
3 | import java.lang.reflect.*;
4 | import java.nio.ByteBuffer;
5 |
6 | public class NativeHandler {
7 |
8 | /** Page can be read. */
9 | public static final int PROT_READ = 0x1;
10 | /** Page can be executed. */
11 | public static final int PROT_WRITE = 0x2;
12 | /** Page can be executed. */
13 | public static final int PROT_EXEC = 0x4;
14 | /** Page cannot be accessed. */
15 | public static final int PROT_NONE = 0x0;
16 |
17 | /** Query parameter for the memory page size, used for sysconf. */
18 | public static final int _SC_PAGESIZE = 0x0027;
19 |
20 | public static native int mprotect(long addr, long len, int prot);
21 |
22 | /** Get system configuration. Is here because Libcore is available on (some old?) Gingerbread versions */
23 | public static native long sysconf(int name);
24 |
25 |
26 | public static void init() {
27 | nativeSetupHooks();
28 | }
29 |
30 | public static ByteBuffer createDirectByteBuffer(long address, long length) throws Exception {
31 | Constructor cons = Class.forName("java.nio.ReadWriteDirectByteBuffer").getDeclaredConstructor(Integer.TYPE, Integer.TYPE);
32 | cons.setAccessible(true);
33 | return (ByteBuffer) cons.newInstance((int) address, (int) length);
34 | }
35 |
36 | public static native void nativeSetupHooks();
37 |
38 | static {
39 | //System.loadLibrary("gnustl_shared");
40 | System.loadLibrary("genericlauncher_tinysubstrate");
41 | System.loadLibrary("genericlauncher");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/byteandahalf/genericlauncher/RedirectPackageManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2008 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mojang.minecraftpe;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.ComponentName;
21 | import android.content.Intent;
22 | import android.content.IntentFilter;
23 | import android.content.pm.ActivityInfo;
24 | import android.content.pm.ApplicationInfo;
25 | import android.content.pm.FeatureInfo;
26 | import android.content.pm.InstrumentationInfo;
27 | import android.content.pm.PackageInfo;
28 | import android.content.pm.PackageInstaller;
29 | import android.content.pm.PackageManager;
30 | import android.content.pm.PermissionGroupInfo;
31 | import android.content.pm.PermissionInfo;
32 | import android.content.pm.ProviderInfo;
33 | import android.content.pm.ResolveInfo;
34 | import android.content.pm.ServiceInfo;
35 | import android.content.res.Resources;
36 | import android.content.res.XmlResourceParser;
37 | import android.graphics.Rect;
38 | import android.graphics.drawable.Drawable;
39 | import android.os.Build;
40 | import android.os.UserHandle;
41 |
42 | import java.util.List;
43 |
44 | public class RedirectPackageManager extends PackageManager {
45 |
46 | protected PackageManager wrapped;
47 | protected String nativeLibraryDir;
48 |
49 | public RedirectPackageManager(PackageManager wrapped, String nativeLibraryDir) {
50 | this.wrapped = wrapped;
51 | this.nativeLibraryDir = nativeLibraryDir;
52 | }
53 |
54 | @TargetApi(Build.VERSION_CODES.GINGERBREAD)
55 | @Override
56 | public ActivityInfo getActivityInfo(ComponentName className, int flags) throws NameNotFoundException {
57 | ActivityInfo retval = wrapped.getActivityInfo(className, flags);
58 | retval.applicationInfo.nativeLibraryDir = nativeLibraryDir;
59 | return retval;
60 | }
61 |
62 | @Override
63 | public PackageInstaller getPackageInstaller() {
64 | return wrapped.getPackageInstaller();
65 | }
66 |
67 | @Override
68 | public CharSequence getUserBadgedLabel(CharSequence label, UserHandle user){ return wrapped.getUserBadgedLabel(label,user);
69 | }
70 |
71 | @Override
72 | public Drawable getUserBadgedDrawableForDensity(Drawable drawable, UserHandle user, Rect badgeLocation, int badgeDensity) {
73 | return wrapped.getUserBadgedDrawableForDensity(drawable,user,badgeLocation,badgeDensity);
74 | }
75 |
76 | @Override
77 | public Drawable getUserBadgedIcon(Drawable icon, UserHandle user) {
78 | return wrapped.getUserBadgedIcon(icon,user);
79 | }
80 |
81 | @Override
82 | public Drawable getApplicationBanner(String packageName)
83 | throws NameNotFoundException {
84 | return wrapped.getApplicationBanner(packageName);
85 | }
86 |
87 | @Override
88 | public Drawable getApplicationBanner(ApplicationInfo info) {
89 | return wrapped.getApplicationBanner(info);
90 | }
91 |
92 | @Override
93 | public Drawable getActivityBanner(Intent intent)
94 | throws NameNotFoundException {
95 | return wrapped.getActivityBanner(intent);
96 | }
97 |
98 | @Override
99 | public Drawable getActivityBanner(ComponentName activityName)
100 | throws NameNotFoundException{
101 | return wrapped.getActivityBanner(activityName);
102 | }
103 |
104 | @Override
105 | public Intent getLeanbackLaunchIntentForPackage(String packageName) {
106 | return wrapped.getLeanbackLaunchIntentForPackage(packageName);
107 | }
108 |
109 | public PackageInfo getPackageInfo(String packageName, int flags)
110 | throws NameNotFoundException {
111 | return wrapped.getPackageInfo(packageName, flags);
112 | }
113 |
114 | @Override
115 | public String[] currentToCanonicalPackageNames(String[] names) {
116 | return wrapped.currentToCanonicalPackageNames(names);
117 | }
118 |
119 | @Override
120 | public String[] canonicalToCurrentPackageNames(String[] names) {
121 | return wrapped.canonicalToCurrentPackageNames(names);
122 | }
123 |
124 | @Override
125 | public Intent getLaunchIntentForPackage(String packageName) {
126 | return wrapped.getLaunchIntentForPackage(packageName);
127 | }
128 |
129 | @Override
130 | public int[] getPackageGids(String packageName) throws NameNotFoundException {
131 | return wrapped.getPackageGids(packageName);
132 | }
133 |
134 | @Override
135 | public PermissionInfo getPermissionInfo(String name, int flags)
136 | throws NameNotFoundException {
137 | return wrapped.getPermissionInfo(name, flags);
138 | }
139 |
140 | @Override
141 | public List queryPermissionsByGroup(String group, int flags)
142 | throws NameNotFoundException {
143 | return wrapped.queryPermissionsByGroup(group, flags);
144 | }
145 |
146 | @Override
147 | public PermissionGroupInfo getPermissionGroupInfo(String name,
148 | int flags) throws NameNotFoundException {
149 | return wrapped.getPermissionGroupInfo(name, flags);
150 | }
151 |
152 | @Override
153 | public List getAllPermissionGroups(int flags) {
154 | return wrapped.getAllPermissionGroups(flags);
155 | }
156 |
157 | @Override
158 | public ApplicationInfo getApplicationInfo(String packageName, int flags)
159 | throws NameNotFoundException {
160 | return wrapped.getApplicationInfo(packageName, flags);
161 | }
162 |
163 | @Override
164 | public ActivityInfo getReceiverInfo(ComponentName className, int flags)
165 | throws NameNotFoundException {
166 | return wrapped.getReceiverInfo(className, flags);
167 | }
168 |
169 | @Override
170 | public ServiceInfo getServiceInfo(ComponentName className, int flags)
171 | throws NameNotFoundException {
172 | return wrapped.getServiceInfo(className, flags);
173 | }
174 |
175 | @Override
176 | public ProviderInfo getProviderInfo(ComponentName className, int flags)
177 | throws NameNotFoundException {
178 | return wrapped.getProviderInfo(className, flags);
179 | }
180 |
181 | @Override
182 | public List getInstalledPackages(int flags) {
183 | return wrapped.getInstalledPackages(flags);
184 | }
185 |
186 | @Override
187 | public int checkPermission(String permName, String pkgName) {
188 | return wrapped.checkPermission(permName, pkgName);
189 | }
190 |
191 | @Override
192 | public boolean addPermission(PermissionInfo info) {
193 | return wrapped.addPermission(info);
194 | }
195 |
196 | @Override
197 | public boolean addPermissionAsync(PermissionInfo info) {
198 | return wrapped.addPermissionAsync(info);
199 | }
200 |
201 | @Override
202 | public void removePermission(String name) {
203 | wrapped.removePermission(name);
204 | }
205 |
206 | @Override
207 | public int checkSignatures(String pkg1, String pkg2) {
208 | return wrapped.checkSignatures(pkg1, pkg2);
209 | }
210 |
211 | @Override
212 | public int checkSignatures(int uid1, int uid2) {
213 | return wrapped.checkSignatures(uid1, uid2);
214 | }
215 |
216 | @Override
217 | public String[] getPackagesForUid(int uid) {
218 | return wrapped.getPackagesForUid(uid);
219 | }
220 |
221 | @Override
222 | public String getNameForUid(int uid) {
223 | return wrapped.getNameForUid(uid);
224 | }
225 |
226 | @Override
227 | public List getInstalledApplications(int flags) {
228 | return wrapped.getInstalledApplications(flags);
229 | }
230 |
231 | @Override
232 | public ResolveInfo resolveActivity(Intent intent, int flags) {
233 | return wrapped.resolveActivity(intent, flags);
234 | }
235 |
236 | @Override
237 | public List queryIntentActivities(Intent intent, int flags) {
238 | return wrapped.queryIntentActivities(intent, flags);
239 | }
240 |
241 | @Override
242 | public List queryIntentActivityOptions(ComponentName caller,
243 | Intent[] specifics, Intent intent, int flags) {
244 | return wrapped.queryIntentActivityOptions(caller, specifics, intent, flags);
245 | }
246 |
247 | @Override
248 | public List queryBroadcastReceivers(Intent intent, int flags) {
249 | return wrapped.queryBroadcastReceivers(intent, flags);
250 | }
251 |
252 | @Override
253 | public ResolveInfo resolveService(Intent intent, int flags) {
254 | return wrapped.resolveService(intent, flags);
255 | }
256 |
257 | @Override
258 | public List queryIntentServices(Intent intent, int flags) {
259 | return wrapped.queryIntentServices(intent, flags);
260 | }
261 |
262 | @Override
263 | public ProviderInfo resolveContentProvider(String name, int flags) {
264 | return wrapped.resolveContentProvider(name, flags);
265 | }
266 |
267 | @Override
268 | public List queryContentProviders(String processName, int uid, int flags) {
269 | return wrapped.queryContentProviders(processName, uid, flags);
270 | }
271 |
272 | @Override
273 | public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags)
274 | throws NameNotFoundException {
275 | return wrapped.getInstrumentationInfo(className, flags);
276 | }
277 |
278 | @Override
279 | public List queryInstrumentation(
280 | String targetPackage, int flags) {
281 | return wrapped.queryInstrumentation(targetPackage, flags);
282 | }
283 |
284 | @Override
285 | public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) {
286 | return wrapped.getDrawable(packageName, resid, appInfo);
287 | }
288 |
289 | @Override
290 | public Drawable getActivityIcon(ComponentName activityName)
291 | throws NameNotFoundException {
292 | return wrapped.getActivityIcon(activityName);
293 | }
294 |
295 | @Override
296 | public Drawable getActivityIcon(Intent intent) throws NameNotFoundException {
297 | return wrapped.getActivityIcon(intent);
298 | }
299 |
300 | @Override
301 | public Drawable getDefaultActivityIcon() {
302 | return wrapped.getDefaultActivityIcon();
303 | }
304 |
305 | @Override
306 | public Drawable getApplicationIcon(ApplicationInfo info) {
307 | return wrapped.getApplicationIcon(info);
308 | }
309 |
310 | @Override
311 | public Drawable getApplicationIcon(String packageName) throws NameNotFoundException {
312 | return wrapped.getApplicationIcon(packageName);
313 | }
314 |
315 | @Override
316 | public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException {
317 | return wrapped.getActivityLogo(activityName);
318 | }
319 |
320 | @Override
321 | public Drawable getActivityLogo(Intent intent) throws NameNotFoundException {
322 | return wrapped.getActivityLogo(intent);
323 | }
324 |
325 | @Override
326 | public Drawable getApplicationLogo(ApplicationInfo info) {
327 | return wrapped.getApplicationLogo(info);
328 | }
329 |
330 | @Override
331 | public Drawable getApplicationLogo(String packageName) throws NameNotFoundException {
332 | return wrapped.getApplicationLogo(packageName);
333 | }
334 |
335 | @Override
336 | public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) {
337 | return wrapped.getText(packageName, resid, appInfo);
338 | }
339 |
340 | @Override
341 | public XmlResourceParser getXml(String packageName, int resid,
342 | ApplicationInfo appInfo) {
343 | return wrapped.getXml(packageName, resid, appInfo);
344 | }
345 |
346 | @Override
347 | public CharSequence getApplicationLabel(ApplicationInfo info) {
348 | return wrapped.getApplicationLabel(info);
349 | }
350 |
351 | @Override
352 | public Resources getResourcesForActivity(ComponentName activityName)
353 | throws NameNotFoundException {
354 | return wrapped.getResourcesForActivity(activityName);
355 | }
356 |
357 | @Override
358 | public Resources getResourcesForApplication(ApplicationInfo app) throws NameNotFoundException {
359 | return wrapped.getResourcesForApplication(app);
360 | }
361 |
362 | @Override
363 | public Resources getResourcesForApplication(String appPackageName)
364 | throws NameNotFoundException {
365 | return wrapped.getResourcesForApplication(appPackageName);
366 | }
367 |
368 | @Override
369 | public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
370 | return wrapped.getPackageArchiveInfo(archiveFilePath, flags);
371 | }
372 |
373 | @Override
374 | public String getInstallerPackageName(String packageName) {
375 | return wrapped.getInstallerPackageName(packageName);
376 | }
377 |
378 | @SuppressWarnings("deprecation")
379 | @Override
380 | public void addPackageToPreferred(String packageName) {
381 | wrapped.addPackageToPreferred(packageName);
382 | }
383 |
384 | @SuppressWarnings("deprecation")
385 | @Override
386 | public void removePackageFromPreferred(String packageName) {
387 | wrapped.removePackageFromPreferred(packageName);
388 | }
389 |
390 | @Override
391 | public List getPreferredPackages(int flags) {
392 | return wrapped.getPreferredPackages(flags);
393 | }
394 |
395 | @Override
396 | public void setComponentEnabledSetting(ComponentName componentName,
397 | int newState, int flags) {
398 | wrapped.setComponentEnabledSetting(componentName, newState, flags);
399 | }
400 |
401 | @Override
402 | public int getComponentEnabledSetting(ComponentName componentName) {
403 | return wrapped.getComponentEnabledSetting(componentName);
404 | }
405 |
406 | @Override
407 | public void setApplicationEnabledSetting(String packageName, int newState, int flags) {
408 | wrapped.setApplicationEnabledSetting(packageName, newState, flags);
409 | }
410 |
411 | @Override
412 | public int getApplicationEnabledSetting(String packageName) {
413 | return wrapped.getApplicationEnabledSetting(packageName);
414 | }
415 |
416 | @SuppressWarnings("deprecation")
417 | @Override
418 | public void addPreferredActivity(IntentFilter filter,
419 | int match, ComponentName[] set, ComponentName activity) {
420 | wrapped.addPreferredActivity(filter, match, set, activity);
421 | }
422 |
423 | @Override
424 | public void clearPackagePreferredActivities(String packageName) {
425 | wrapped.clearPackagePreferredActivities(packageName);
426 | }
427 |
428 | @Override
429 | public int getPreferredActivities(List outFilters,
430 | List outActivities, String packageName) {
431 | return wrapped.getPreferredActivities(outFilters, outActivities, packageName);
432 | }
433 |
434 | @Override
435 | public String[] getSystemSharedLibraryNames() {
436 | return wrapped.getSystemSharedLibraryNames();
437 | }
438 |
439 | @Override
440 | public FeatureInfo[] getSystemAvailableFeatures() {
441 | return wrapped.getSystemAvailableFeatures();
442 | }
443 |
444 | @Override
445 | public boolean hasSystemFeature(String name) {
446 | return wrapped.hasSystemFeature(name);
447 | }
448 |
449 | @Override
450 | public boolean isSafeMode() {
451 | return wrapped.isSafeMode();
452 | }
453 |
454 | @Override
455 | public List getPackagesHoldingPermissions(String[] permissions, int flags) {
456 | return wrapped.getPackagesHoldingPermissions(permissions, flags);
457 | }
458 |
459 | @Override
460 | public List queryIntentContentProviders(Intent intent, int flags) {
461 | return wrapped.queryIntentContentProviders(intent, flags);
462 | }
463 |
464 | @Override
465 | public void verifyPendingInstall(int id, int verificationCode) {
466 | wrapped.verifyPendingInstall(id, verificationCode);
467 | }
468 |
469 | @Override
470 | public void extendVerificationTimeout(int id, int verificationCodeAtTimeout,
471 | long millisecondsToDelay) {
472 | wrapped.extendVerificationTimeout(id, verificationCodeAtTimeout, millisecondsToDelay);
473 | }
474 |
475 | @Override
476 | public void setInstallerPackageName(String targetPackage, String installerPackageName) {
477 | wrapped.setInstallerPackageName(targetPackage, installerPackageName);
478 | }
479 | }
480 |
--------------------------------------------------------------------------------
/src/com/byteandahalf/genericlauncher/TestButton.java:
--------------------------------------------------------------------------------
1 | package com.byteandahalf.genericlauncher;
2 |
3 | import android.app.*;
4 | import android.content.*;
5 | import android.graphics.drawable.*;
6 | import android.view.*;
7 | import android.widget.*;
8 |
9 | public class TestButton extends PopupWindow {
10 |
11 | public Button mainButton;
12 |
13 | public TestButton(Activity activity) {
14 | super(activity);
15 | setContentView(activity.getLayoutInflater().inflate(R.layout.testbutton, null));
16 | mainButton = (Button) getContentView().findViewById(R.id.testbutton);
17 | setBackgroundDrawable(new ColorDrawable(0x77ffffff));
18 | setWidth(100);
19 | setHeight(50);
20 | mainButton.setWidth(100);
21 | mainButton.setHeight(50);
22 | }
23 |
24 | public void show(View parentView) {
25 | showAtLocation(parentView, Gravity.RIGHT | Gravity.TOP, 0, 0);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/byteandahalf/genericlauncher/Utils.java:
--------------------------------------------------------------------------------
1 | package com.byteandahalf.genericlauncher;
2 |
3 | import java.io.File;
4 | import java.lang.reflect.Field;
5 |
6 | import android.content.Context;
7 | import android.content.SharedPreferences;
8 | import android.preference.PreferenceManager;
9 | import android.content.res.Configuration;
10 | import android.content.res.Resources;
11 | import android.util.DisplayMetrics;
12 |
13 | import java.util.Arrays;
14 | import java.util.Collection;
15 | import java.util.HashSet;
16 | import java.util.Locale;
17 | import java.util.Set;
18 |
19 | import com.mojang.minecraftpe.MainActivity;
20 |
21 | public class Utils {
22 | protected static Context mContext = null;
23 |
24 | public static void setContext(Context context) {
25 | mContext = context;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/com/byteandahalf/genericlauncher/WrappedPackageManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2008 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.byteandahalf.genericlauncher;
18 |
19 | import android.content.ComponentName;
20 | import android.content.Intent;
21 | import android.content.IntentFilter;
22 | import android.content.pm.ActivityInfo;
23 | import android.content.pm.ApplicationInfo;
24 | import android.content.pm.FeatureInfo;
25 | import android.content.pm.InstrumentationInfo;
26 | import android.content.pm.PackageInfo;
27 | import android.content.pm.PackageInstaller;
28 | import android.content.pm.PackageManager;
29 | import android.content.pm.PermissionGroupInfo;
30 | import android.content.pm.PermissionInfo;
31 | import android.content.pm.ProviderInfo;
32 | import android.content.pm.ResolveInfo;
33 | import android.content.pm.ServiceInfo;
34 | import android.content.res.Resources;
35 | import android.content.res.XmlResourceParser;
36 | import android.graphics.Rect;
37 | import android.graphics.drawable.Drawable;
38 | import android.os.UserHandle;
39 |
40 | import java.util.List;
41 |
42 | /**
43 | * A mock {@link android.content.pm.PackageManager} class. All methods are functional.
44 | * Override it to provide the operations that you need.
45 | */
46 | public class WrappedPackageManager extends PackageManager {
47 |
48 | protected PackageManager wrapped;
49 |
50 | public WrappedPackageManager(PackageManager wrapped) {
51 | this.wrapped = wrapped;
52 | }
53 |
54 | @Override
55 | public PackageInstaller getPackageInstaller() {
56 | return wrapped.getPackageInstaller();
57 | }
58 |
59 | @Override
60 | public CharSequence getUserBadgedLabel(CharSequence label, UserHandle user){ return wrapped.getUserBadgedLabel(label,user);
61 | }
62 |
63 | @Override
64 | public Drawable getUserBadgedDrawableForDensity(Drawable drawable, UserHandle user, Rect badgeLocation, int badgeDensity) {
65 | return wrapped.getUserBadgedDrawableForDensity(drawable,user,badgeLocation,badgeDensity);
66 | }
67 |
68 | @Override
69 | public Drawable getUserBadgedIcon(Drawable icon, UserHandle user) {
70 | return wrapped.getUserBadgedIcon(icon,user);
71 | }
72 |
73 | @Override
74 | public Drawable getApplicationBanner(String packageName)
75 | throws NameNotFoundException {
76 | return wrapped.getApplicationBanner(packageName);
77 | }
78 |
79 | @Override
80 | public Drawable getApplicationBanner(ApplicationInfo info) {
81 | return wrapped.getApplicationBanner(info);
82 | }
83 |
84 | @Override
85 | public Drawable getActivityBanner(Intent intent)
86 | throws NameNotFoundException {
87 | return wrapped.getActivityBanner(intent);
88 | }
89 |
90 | @Override
91 | public Drawable getActivityBanner(ComponentName activityName)
92 | throws NameNotFoundException{
93 | return wrapped.getActivityBanner(activityName);
94 | }
95 |
96 | @Override
97 | public Intent getLeanbackLaunchIntentForPackage(String packageName) {
98 | return wrapped.getLeanbackLaunchIntentForPackage(packageName);
99 | }
100 |
101 | @Override
102 | public PackageInfo getPackageInfo(String packageName, int flags)
103 | throws NameNotFoundException {
104 | return wrapped.getPackageInfo(packageName, flags);
105 | }
106 |
107 | @Override
108 | public String[] currentToCanonicalPackageNames(String[] names) {
109 | return wrapped.currentToCanonicalPackageNames(names);
110 | }
111 |
112 | @Override
113 | public String[] canonicalToCurrentPackageNames(String[] names) {
114 | return wrapped.canonicalToCurrentPackageNames(names);
115 | }
116 |
117 | @Override
118 | public Intent getLaunchIntentForPackage(String packageName) {
119 | return wrapped.getLaunchIntentForPackage(packageName);
120 | }
121 |
122 | @Override
123 | public int[] getPackageGids(String packageName) throws NameNotFoundException {
124 | return wrapped.getPackageGids(packageName);
125 | }
126 |
127 | @Override
128 | public PermissionInfo getPermissionInfo(String name, int flags)
129 | throws NameNotFoundException {
130 | return wrapped.getPermissionInfo(name, flags);
131 | }
132 |
133 | @Override
134 | public List queryPermissionsByGroup(String group, int flags)
135 | throws NameNotFoundException {
136 | return wrapped.queryPermissionsByGroup(group, flags);
137 | }
138 |
139 | @Override
140 | public PermissionGroupInfo getPermissionGroupInfo(String name,
141 | int flags) throws NameNotFoundException {
142 | return wrapped.getPermissionGroupInfo(name, flags);
143 | }
144 |
145 | @Override
146 | public List getAllPermissionGroups(int flags) {
147 | return wrapped.getAllPermissionGroups(flags);
148 | }
149 |
150 | @Override
151 | public ApplicationInfo getApplicationInfo(String packageName, int flags)
152 | throws NameNotFoundException {
153 | return wrapped.getApplicationInfo(packageName, flags);
154 | }
155 |
156 | @Override
157 | public ActivityInfo getActivityInfo(ComponentName className, int flags)
158 | throws NameNotFoundException {
159 | return wrapped.getActivityInfo(className, flags);
160 | }
161 |
162 | @Override
163 | public ActivityInfo getReceiverInfo(ComponentName className, int flags)
164 | throws NameNotFoundException {
165 | return wrapped.getReceiverInfo(className, flags);
166 | }
167 |
168 | @Override
169 | public ServiceInfo getServiceInfo(ComponentName className, int flags)
170 | throws NameNotFoundException {
171 | return wrapped.getServiceInfo(className, flags);
172 | }
173 |
174 | @Override
175 | public ProviderInfo getProviderInfo(ComponentName className, int flags)
176 | throws NameNotFoundException {
177 | return wrapped.getProviderInfo(className, flags);
178 | }
179 |
180 | @Override
181 | public List getInstalledPackages(int flags) {
182 | return wrapped.getInstalledPackages(flags);
183 | }
184 |
185 | @Override
186 | public int checkPermission(String permName, String pkgName) {
187 | return wrapped.checkPermission(permName, pkgName);
188 | }
189 |
190 | @Override
191 | public boolean addPermission(PermissionInfo info) {
192 | return wrapped.addPermission(info);
193 | }
194 |
195 | @Override
196 | public boolean addPermissionAsync(PermissionInfo info) {
197 | return wrapped.addPermissionAsync(info);
198 | }
199 |
200 | @Override
201 | public void removePermission(String name) {
202 | wrapped.removePermission(name);
203 | }
204 |
205 | @Override
206 | public int checkSignatures(String pkg1, String pkg2) {
207 | return wrapped.checkSignatures(pkg1, pkg2);
208 | }
209 |
210 | @Override
211 | public int checkSignatures(int uid1, int uid2) {
212 | return wrapped.checkSignatures(uid1, uid2);
213 | }
214 |
215 | @Override
216 | public String[] getPackagesForUid(int uid) {
217 | return wrapped.getPackagesForUid(uid);
218 | }
219 |
220 | @Override
221 | public String getNameForUid(int uid) {
222 | return wrapped.getNameForUid(uid);
223 | }
224 |
225 | @Override
226 | public List getInstalledApplications(int flags) {
227 | return wrapped.getInstalledApplications(flags);
228 | }
229 |
230 | @Override
231 | public ResolveInfo resolveActivity(Intent intent, int flags) {
232 | return wrapped.resolveActivity(intent, flags);
233 | }
234 |
235 | @Override
236 | public List queryIntentActivities(Intent intent, int flags) {
237 | return wrapped.queryIntentActivities(intent, flags);
238 | }
239 |
240 | @Override
241 | public List queryIntentActivityOptions(ComponentName caller,
242 | Intent[] specifics, Intent intent, int flags) {
243 | return wrapped.queryIntentActivityOptions(caller, specifics, intent, flags);
244 | }
245 |
246 | @Override
247 | public List queryBroadcastReceivers(Intent intent, int flags) {
248 | return wrapped.queryBroadcastReceivers(intent, flags);
249 | }
250 |
251 | @Override
252 | public ResolveInfo resolveService(Intent intent, int flags) {
253 | return wrapped.resolveService(intent, flags);
254 | }
255 |
256 | @Override
257 | public List queryIntentServices(Intent intent, int flags) {
258 | return wrapped.queryIntentServices(intent, flags);
259 | }
260 |
261 | @Override
262 | public ProviderInfo resolveContentProvider(String name, int flags) {
263 | return wrapped.resolveContentProvider(name, flags);
264 | }
265 |
266 | @Override
267 | public List queryContentProviders(String processName, int uid, int flags) {
268 | return wrapped.queryContentProviders(processName, uid, flags);
269 | }
270 |
271 | @Override
272 | public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags)
273 | throws NameNotFoundException {
274 | return wrapped.getInstrumentationInfo(className, flags);
275 | }
276 |
277 | @Override
278 | public List queryInstrumentation(
279 | String targetPackage, int flags) {
280 | return wrapped.queryInstrumentation(targetPackage, flags);
281 | }
282 |
283 | @Override
284 | public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) {
285 | return wrapped.getDrawable(packageName, resid, appInfo);
286 | }
287 |
288 | @Override
289 | public Drawable getActivityIcon(ComponentName activityName)
290 | throws NameNotFoundException {
291 | return wrapped.getActivityIcon(activityName);
292 | }
293 |
294 | @Override
295 | public Drawable getActivityIcon(Intent intent) throws NameNotFoundException {
296 | return wrapped.getActivityIcon(intent);
297 | }
298 |
299 | @Override
300 | public Drawable getDefaultActivityIcon() {
301 | return wrapped.getDefaultActivityIcon();
302 | }
303 |
304 | @Override
305 | public Drawable getApplicationIcon(ApplicationInfo info) {
306 | return wrapped.getApplicationIcon(info);
307 | }
308 |
309 | @Override
310 | public Drawable getApplicationIcon(String packageName) throws NameNotFoundException {
311 | return wrapped.getApplicationIcon(packageName);
312 | }
313 |
314 | @Override
315 | public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException {
316 | return wrapped.getActivityLogo(activityName);
317 | }
318 |
319 | @Override
320 | public Drawable getActivityLogo(Intent intent) throws NameNotFoundException {
321 | return wrapped.getActivityLogo(intent);
322 | }
323 |
324 | @Override
325 | public Drawable getApplicationLogo(ApplicationInfo info) {
326 | return wrapped.getApplicationLogo(info);
327 | }
328 |
329 | @Override
330 | public Drawable getApplicationLogo(String packageName) throws NameNotFoundException {
331 | return wrapped.getApplicationLogo(packageName);
332 | }
333 |
334 | @Override
335 | public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) {
336 | return wrapped.getText(packageName, resid, appInfo);
337 | }
338 |
339 | @Override
340 | public XmlResourceParser getXml(String packageName, int resid,
341 | ApplicationInfo appInfo) {
342 | return wrapped.getXml(packageName, resid, appInfo);
343 | }
344 |
345 | @Override
346 | public CharSequence getApplicationLabel(ApplicationInfo info) {
347 | return wrapped.getApplicationLabel(info);
348 | }
349 |
350 | @Override
351 | public Resources getResourcesForActivity(ComponentName activityName)
352 | throws NameNotFoundException {
353 | return wrapped.getResourcesForActivity(activityName);
354 | }
355 |
356 | @Override
357 | public Resources getResourcesForApplication(ApplicationInfo app) throws NameNotFoundException {
358 | return wrapped.getResourcesForApplication(app);
359 | }
360 |
361 | @Override
362 | public Resources getResourcesForApplication(String appPackageName)
363 | throws NameNotFoundException {
364 | return wrapped.getResourcesForApplication(appPackageName);
365 | }
366 |
367 | @Override
368 | public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
369 | return wrapped.getPackageArchiveInfo(archiveFilePath, flags);
370 | }
371 |
372 | @Override
373 | public String getInstallerPackageName(String packageName) {
374 | return wrapped.getInstallerPackageName(packageName);
375 | }
376 |
377 | @Override
378 | public void addPackageToPreferred(String packageName) {
379 | wrapped.addPackageToPreferred(packageName);
380 | }
381 |
382 | @Override
383 | public void removePackageFromPreferred(String packageName) {
384 | wrapped.removePackageFromPreferred(packageName);
385 | }
386 |
387 | @Override
388 | public List getPreferredPackages(int flags) {
389 | return wrapped.getPreferredPackages(flags);
390 | }
391 |
392 | @Override
393 | public void setComponentEnabledSetting(ComponentName componentName,
394 | int newState, int flags) {
395 | wrapped.setComponentEnabledSetting(componentName, newState, flags);
396 | }
397 |
398 | @Override
399 | public int getComponentEnabledSetting(ComponentName componentName) {
400 | return wrapped.getComponentEnabledSetting(componentName);
401 | }
402 |
403 | @Override
404 | public void setApplicationEnabledSetting(String packageName, int newState, int flags) {
405 | wrapped.setApplicationEnabledSetting(packageName, newState, flags);
406 | }
407 |
408 | @Override
409 | public int getApplicationEnabledSetting(String packageName) {
410 | return wrapped.getApplicationEnabledSetting(packageName);
411 | }
412 |
413 | @Override
414 | public void addPreferredActivity(IntentFilter filter,
415 | int match, ComponentName[] set, ComponentName activity) {
416 | wrapped.addPreferredActivity(filter, match, set, activity);
417 | }
418 |
419 | @Override
420 | public void clearPackagePreferredActivities(String packageName) {
421 | wrapped.clearPackagePreferredActivities(packageName);
422 | }
423 |
424 | @Override
425 | public int getPreferredActivities(List outFilters,
426 | List outActivities, String packageName) {
427 | return wrapped.getPreferredActivities(outFilters, outActivities, packageName);
428 | }
429 |
430 | @Override
431 | public String[] getSystemSharedLibraryNames() {
432 | return wrapped.getSystemSharedLibraryNames();
433 | }
434 |
435 | @Override
436 | public FeatureInfo[] getSystemAvailableFeatures() {
437 | return wrapped.getSystemAvailableFeatures();
438 | }
439 |
440 | @Override
441 | public boolean hasSystemFeature(String name) {
442 | return wrapped.hasSystemFeature(name);
443 | }
444 |
445 | @Override
446 | public boolean isSafeMode() {
447 | return wrapped.isSafeMode();
448 | }
449 |
450 | @Override
451 | public List getPackagesHoldingPermissions(String[] permissions, int flags) {
452 | return wrapped.getPackagesHoldingPermissions(permissions, flags);
453 | }
454 |
455 | @Override
456 | public List queryIntentContentProviders(Intent intent, int flags) {
457 | return wrapped.queryIntentContentProviders(intent, flags);
458 | }
459 |
460 | @Override
461 | public void verifyPendingInstall(int id, int verificationCode) {
462 | wrapped.verifyPendingInstall(id, verificationCode);
463 | }
464 |
465 | @Override
466 | public void extendVerificationTimeout(int id, int verificationCodeAtTimeout,
467 | long millisecondsToDelay) {
468 | wrapped.extendVerificationTimeout(id, verificationCodeAtTimeout, millisecondsToDelay);
469 | }
470 |
471 | @Override
472 | public void setInstallerPackageName(String targetPackage, String installerPackageName) {
473 | wrapped.setInstallerPackageName(targetPackage, installerPackageName);
474 | }
475 | }
476 |
--------------------------------------------------------------------------------
/src/com/byteandahalf/genericlauncher/ui/LauncherActivity.java:
--------------------------------------------------------------------------------
1 | package com.byteandahalf.genericlauncher.ui;
2 |
3 | public class LauncherActivity extends com.mojang.minecraftpe.MainActivity {
4 | }
5 |
--------------------------------------------------------------------------------
/src/com/mojang/android/net/HTTPClientManager.java:
--------------------------------------------------------------------------------
1 | package com.mojang.android.net;
2 |
3 | import android.util.Log;
4 | import org.apache.http.HttpVersion;
5 | import org.apache.http.client.HttpClient;
6 | import org.apache.http.conn.params.ConnManagerParams;
7 | import org.apache.http.conn.scheme.PlainSocketFactory;
8 | import org.apache.http.conn.scheme.Scheme;
9 | import org.apache.http.conn.scheme.SchemeRegistry;
10 | import org.apache.http.impl.client.DefaultHttpClient;
11 | import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
12 | import org.apache.http.params.BasicHttpParams;
13 | import org.apache.http.params.HttpParams;
14 | import org.apache.http.params.HttpProtocolParams;
15 |
16 | public class HTTPClientManager
17 | {
18 | static HTTPClientManager instance = new HTTPClientManager();
19 | HttpClient mHTTPClient = null;
20 | String mHttpClient;
21 |
22 | private HTTPClientManager() {
23 | BasicHttpParams params = new BasicHttpParams();
24 | HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
25 | HttpProtocolParams.setContentCharset(params, "utf-8");
26 | ConnManagerParams.setTimeout(params, 30000L);
27 | params.setBooleanParameter("http.protocol.expect-continue", false);
28 | SchemeRegistry localSchemeRegistry = new SchemeRegistry();
29 | localSchemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
30 | try
31 | {
32 | localSchemeRegistry.register(new Scheme("https", NoCertSSLSocketFactory.createDefault(), 443));
33 | this.mHTTPClient = new DefaultHttpClient(new ThreadSafeClientConnManager(params, localSchemeRegistry), params);
34 | return;
35 | }
36 | catch (Exception exception)
37 | {
38 | exception.printStackTrace();
39 | Log.e("MCPE_ssl", "Couldn't create SSLSocketFactory");
40 | }
41 | }
42 |
43 | public static HttpClient getHTTPClient() {
44 | return instance.mHTTPClient;
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/src/com/mojang/android/net/HTTPRequest.java:
--------------------------------------------------------------------------------
1 | package com.mojang.android.net;
2 |
3 | import java.io.IOException;
4 | import java.io.UnsupportedEncodingException;
5 | import java.security.InvalidParameterException;
6 | import org.apache.http.HttpEntity;
7 | import org.apache.http.HttpResponse;
8 | import org.apache.http.StatusLine;
9 | import org.apache.http.client.ClientProtocolException;
10 | import org.apache.http.client.HttpClient;
11 | import org.apache.http.client.methods.HttpDelete;
12 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
13 | import org.apache.http.client.methods.HttpGet;
14 | import org.apache.http.client.methods.HttpPost;
15 | import org.apache.http.client.methods.HttpPut;
16 | import org.apache.http.client.methods.HttpRequestBase;
17 | import org.apache.http.conn.ConnectTimeoutException;
18 | import org.apache.http.entity.StringEntity;
19 | import org.apache.http.params.BasicHttpParams;
20 | import org.apache.http.params.HttpConnectionParams;
21 | import org.apache.http.util.EntityUtils;
22 |
23 | import android.util.Log;
24 |
25 | public class HTTPRequest
26 | {
27 | String mCookieData = "";
28 | HttpRequestBase mHTTPRequest = null;
29 | String mRequestBody = "";
30 | String mRequestContentType = "text/plain";
31 | HTTPResponse mResponse = new HTTPResponse();
32 | String mURL = "";
33 |
34 | private void addBodyToRequest(HttpEntityEnclosingRequestBase paramHttpEntityEnclosingRequestBase)
35 | {
36 | if (this.mRequestBody != "") {}
37 | try
38 | {
39 | StringEntity localStringEntity = new StringEntity(this.mRequestBody);
40 | localStringEntity.setContentType(this.mRequestContentType);
41 | paramHttpEntityEnclosingRequestBase.setEntity(localStringEntity);
42 | paramHttpEntityEnclosingRequestBase.addHeader("Content-Type", this.mRequestContentType);
43 | return;
44 | }
45 | catch (UnsupportedEncodingException exception)
46 | {
47 | exception.printStackTrace();
48 | }
49 | }
50 |
51 | private void addHeaders()
52 | {
53 | this.mHTTPRequest.addHeader("User-Agent", "MCPE/Android");
54 | BasicHttpParams localBasicHttpParams = new BasicHttpParams();
55 | HttpConnectionParams.setConnectionTimeout(localBasicHttpParams, 3000);
56 | this.mHTTPRequest.setParams(localBasicHttpParams);
57 | if ((this.mCookieData != null) && (this.mCookieData.length() > 0)) {
58 | this.mHTTPRequest.addHeader("Cookie", this.mCookieData);
59 | }
60 | this.mHTTPRequest.addHeader("Charset", "utf-8");
61 | }
62 |
63 | private void createHTTPRequest(String request) {
64 | if (request.equals("DELETE"))
65 | {
66 | this.mHTTPRequest = new HttpDelete(this.mURL);
67 | return;
68 | }
69 | if (request.equals("PUT"))
70 | {
71 | HttpPut put = new HttpPut(this.mURL);
72 | addBodyToRequest(put);
73 | this.mHTTPRequest = put;
74 | return;
75 | }
76 | if (request.equals("GET")) {
77 | this.mHTTPRequest = new HttpGet(this.mURL);
78 | return;
79 | }
80 | if (request.equals("POST")) {
81 | HttpPost post = new HttpPost(this.mURL);
82 | addBodyToRequest(post);
83 | this.mHTTPRequest = post;
84 | return;
85 | }
86 |
87 | throw new InvalidParameterException("Unknown request method " + request);
88 | }
89 |
90 | public void abort()
91 | {
92 | try
93 | {
94 | this.mResponse.setStatus(2);
95 | if (this.mHTTPRequest != null) {
96 | this.mHTTPRequest.abort();
97 | }
98 | return;
99 | }
100 | finally
101 | {
102 | Log.e("GenericLauncher","HTTPRequest.abort");
103 | //localObject = ;
104 | //throw ((Throwable)localObject);
105 | }
106 | }
107 |
108 | public HTTPResponse send(String paramString) {
109 | createHTTPRequest(paramString);
110 | addHeaders();
111 | if (this.mResponse.getStatus() == 2) {
112 | return this.mResponse;
113 | }
114 | try
115 | {
116 | HttpResponse response = HTTPClientManager.getHTTPClient().execute(this.mHTTPRequest);
117 | mResponse.setResponseCode(response.getStatusLine().getStatusCode());
118 | HttpEntity localHttpEntity = response.getEntity();
119 | this.mResponse.setBody(EntityUtils.toString(localHttpEntity));
120 | this.mResponse.setStatus(1);
121 | this.mResponse.setHeaders(response.getAllHeaders());
122 | return this.mResponse;
123 | }
124 | catch (ConnectTimeoutException connectTimeoutException)
125 | {
126 | this.mResponse.setStatus(3);
127 | this.mHTTPRequest = null;
128 | return this.mResponse;
129 | }
130 | catch (ClientProtocolException clientProtocolException)
131 | {
132 | clientProtocolException.printStackTrace();
133 | }
134 | catch (IOException ioException)
135 | {
136 | ioException.printStackTrace();
137 | }
138 | return null;
139 | }
140 |
141 | public void setContentType(String contentType) {
142 | this.mRequestContentType = contentType;
143 | }
144 |
145 | public void setCookieData(String cookieData) {
146 | this.mCookieData = cookieData;
147 | }
148 |
149 | public void setRequestBody(String requestBody) {
150 | this.mRequestBody = requestBody;
151 | }
152 |
153 | public void setURL(String url) {
154 | this.mURL = url;
155 | }
156 | }
157 |
158 |
--------------------------------------------------------------------------------
/src/com/mojang/android/net/HTTPResponse.java:
--------------------------------------------------------------------------------
1 | package com.mojang.android.net;
2 |
3 | import org.apache.http.Header;
4 |
5 | public class HTTPResponse
6 | {
7 | public static final int ABORTED = 2;
8 | public static final int DONE = 1;
9 | public static final int IN_PROGRESS = 0;
10 | public static final int TIME_OUT = 3;
11 | String body = "";
12 | Header[] headers;
13 | int responseCode = -100;
14 | int status = 0;
15 |
16 | public String getBody() {
17 | return this.body;
18 | }
19 |
20 | public Header[] getHeaders() {
21 | return this.headers;
22 | }
23 |
24 | public int getResponseCode() {
25 | return this.responseCode;
26 | }
27 |
28 | public int getStatus() {
29 | return this.status;
30 | }
31 |
32 | public void setBody(String body) {
33 | this.body = body;
34 | }
35 |
36 | public void setHeaders(Header[] headers) {
37 | this.headers = headers;
38 | }
39 |
40 | public void setResponseCode(int code) {
41 | this.responseCode = code;
42 | }
43 |
44 | public void setStatus(int status) {
45 | this.status = status;
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/src/com/mojang/android/net/NoCertSSLSocketFactory.java:
--------------------------------------------------------------------------------
1 | package com.mojang.android.net;
2 |
3 | import java.io.IOException;
4 | import java.net.Socket;
5 | import java.net.UnknownHostException;
6 | import java.security.KeyManagementException;
7 | import java.security.KeyStore;
8 | import java.security.KeyStoreException;
9 | import java.security.NoSuchAlgorithmException;
10 | import java.security.UnrecoverableKeyException;
11 | import java.security.cert.CertificateException;
12 | import java.security.cert.X509Certificate;
13 | import javax.net.ssl.SSLContext;
14 | import javax.net.ssl.TrustManager;
15 | import javax.net.ssl.X509TrustManager;
16 |
17 | import org.apache.http.conn.ssl.SSLSocketFactory;
18 |
19 | public class NoCertSSLSocketFactory
20 | extends SSLSocketFactory {
21 |
22 | private SSLContext sslContext = SSLContext.getInstance("TLS");
23 |
24 | public NoCertSSLSocketFactory(KeyStore paramKeyStore)
25 | throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
26 | super(paramKeyStore);
27 | X509TrustManager trustManager = new X509TrustManager()
28 | {
29 | public void checkClientTrusted(X509Certificate[] paramAnonymousArrayOfX509Certificate, String paramAnonymousString)
30 | throws CertificateException
31 | {}
32 |
33 | public void checkServerTrusted(X509Certificate[] paramAnonymousArrayOfX509Certificate, String paramAnonymousString)
34 | throws CertificateException
35 | {}
36 |
37 | public X509Certificate[] getAcceptedIssuers()
38 | {
39 | return null;
40 | }
41 | };
42 | this.sslContext.init(null, new TrustManager[] { trustManager }, null);
43 | }
44 |
45 | public static NoCertSSLSocketFactory createDefault()
46 | throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, UnrecoverableKeyException {
47 | KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
48 | keystore.load(null, null);
49 | NoCertSSLSocketFactory factory = new NoCertSSLSocketFactory(keystore);
50 | factory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
51 | return factory;
52 | }
53 |
54 | public Socket createSocket()
55 | throws IOException {
56 | return this.sslContext.getSocketFactory().createSocket();
57 | }
58 |
59 | public Socket createSocket(Socket paramSocket, String paramString, int paramInt, boolean paramBoolean)
60 | throws IOException, UnknownHostException {
61 | return this.sslContext.getSocketFactory().createSocket(paramSocket, paramString, paramInt, paramBoolean);
62 | }
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/HardwareInformation.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.os.Build;
5 | import android.os.Build.VERSION;
6 | import java.io.BufferedReader;
7 | import java.io.File;
8 | import java.io.FileReader;
9 | import java.util.HashMap;
10 | import java.util.Locale;
11 | import java.util.Map;
12 | import java.util.regex.Matcher;
13 | import java.util.regex.Pattern;
14 |
15 | @SuppressLint({"DefaultLocale"})
16 | public class HardwareInformation
17 | {
18 | private static final CPUInfo cpuInfo = getCPUInfo();
19 |
20 | public static String getAndroidVersion()
21 | {
22 | return "Android " + Build.VERSION.RELEASE;
23 | }
24 |
25 | public static String getCPUFeatures()
26 | {
27 | return cpuInfo.getCPULine("Features");
28 | }
29 |
30 | public static CPUInfo getCPUInfo()
31 | {
32 | new StringBuffer();
33 | HashMap localHashMap = new HashMap();
34 | int j = 0;
35 | int k = 0;
36 | int i = 0;
37 | if (new File("/proc/cpuinfo").exists()) {
38 | j = k;
39 | }
40 | try
41 | {
42 | BufferedReader localBufferedReader = new BufferedReader(new FileReader(new File("/proc/cpuinfo")));
43 | j = k;
44 | Pattern localPattern = Pattern.compile("(\\w*)\\s*:\\s([^\\n]*)");
45 | for (;;)
46 | {
47 | j = i;
48 | Object localObject = localBufferedReader.readLine();
49 | if (localObject == null) {
50 | break;
51 | }
52 | j = i;
53 | localObject = localPattern.matcher((CharSequence)localObject);
54 | j = i;
55 | if (((Matcher)localObject).find())
56 | {
57 | j = i;
58 | if (((Matcher)localObject).groupCount() == 2)
59 | {
60 | j = i;
61 | if (!localHashMap.containsKey(((Matcher)localObject).group(1)))
62 | {
63 | j = i;
64 | localHashMap.put(((Matcher)localObject).group(1), ((Matcher)localObject).group(2));
65 | }
66 | j = i;
67 | if (((Matcher)localObject).group(1).contentEquals("processor")) {
68 | i += 1;
69 | }
70 | }
71 | }
72 | }
73 | j = i;
74 | if (localBufferedReader != null)
75 | {
76 | j = i;
77 | localBufferedReader.close();
78 | j = i;
79 | }
80 | }
81 | catch (Exception localException)
82 | {
83 | for (;;)
84 | {
85 | localException.printStackTrace();
86 | }
87 | }
88 | return new CPUInfo(localHashMap, j);
89 | }
90 |
91 | public static String getCPUName()
92 | {
93 | return cpuInfo.getCPULine("Hardware");
94 | }
95 |
96 | public static String getCPUType()
97 | {
98 | int currentapiVersion = android.os.Build.VERSION.SDK_INT;
99 | if (currentapiVersion < 21){
100 | return Build.CPU_ABI;
101 | }
102 | else {
103 | return Build.SUPPORTED_ABIS.toString();
104 | }
105 | }
106 |
107 | public static String getDeviceModelName()
108 | {
109 | String str1 = Build.MANUFACTURER;
110 | String str2 = Build.MODEL;
111 | if (str2.startsWith(str1)) {
112 | return str2.toUpperCase();
113 | }
114 | return str1.toUpperCase() + " " + str2;
115 | }
116 |
117 | public static String getLocale()
118 | {
119 | return Locale.getDefault().toString();
120 | }
121 |
122 | public static int getNumCores()
123 | {
124 | return cpuInfo.getNumberCPUCores();
125 | }
126 |
127 | public static class CPUInfo
128 | {
129 | private final Map cpuLines;
130 | private final int numberCPUCores;
131 |
132 | public CPUInfo(Map paramMap, int paramInt)
133 | {
134 | this.cpuLines = paramMap;
135 | this.numberCPUCores = paramInt;
136 | }
137 |
138 | String getCPULine(String paramString)
139 | {
140 | if (this.cpuLines.containsKey(paramString)) {
141 | return (String)this.cpuLines.get(paramString);
142 | }
143 | return "";
144 | }
145 |
146 | int getNumberCPUCores()
147 | {
148 | return this.numberCPUCores;
149 | }
150 | }
151 | }
152 |
153 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.lang.reflect.Field;
9 | import java.nio.ByteBuffer;
10 | import java.text.DateFormat;
11 | import java.util.ArrayList;
12 | import java.util.Date;
13 | import java.util.Locale;
14 | import java.util.UUID;
15 |
16 | import android.media.AudioManager;
17 | import android.os.Build;
18 | import android.os.Build.VERSION;
19 | import android.os.Bundle;
20 | import android.os.Environment;
21 | import android.os.Vibrator;
22 | import android.app.NativeActivity;
23 | import android.content.Context;
24 | import android.content.Intent;
25 | import android.content.SharedPreferences;
26 | import android.content.pm.ApplicationInfo;
27 | import android.content.pm.PackageInfo;
28 | import android.content.pm.PackageManager;
29 | import android.graphics.Bitmap;
30 | import android.graphics.BitmapFactory;
31 | import android.graphics.drawable.ColorDrawable;
32 | import android.net.Uri;
33 | import android.preference.PreferenceManager;
34 | import android.text.Editable;
35 | import android.text.InputType;
36 | import android.text.Selection;
37 | import android.text.Spannable;
38 | import android.text.TextWatcher;
39 | import android.util.DisplayMetrics;
40 | import android.util.Log;
41 | import android.view.*;
42 | import android.view.inputmethod.EditorInfo;
43 | import android.view.inputmethod.InputMethodManager;
44 | import android.widget.*;
45 |
46 | import android.app.ActivityManager;
47 | import android.app.ActivityManager.MemoryInfo;
48 |
49 | import org.fmod.FMOD;
50 |
51 | import com.byteandahalf.genericlauncher.*; // import ALL the things
52 | import com.byteandahalf.genericlauncher.NativeHandler;
53 |
54 |
55 | public class MainActivity extends NativeActivity {
56 |
57 | public static final int UI_HOVER_BUTTON_TEST = 0;
58 |
59 | PackageInfo packageInfo;
60 | ApplicationInfo appInfo;
61 | String libraryDir;
62 | String libraryLocation;
63 | boolean canAccessAssets = false;
64 | Context apkContext = null;
65 | DisplayMetrics metrics;
66 |
67 | boolean mcpePackage = false;
68 |
69 | public static ByteBuffer minecraftLibBuffer = null;
70 | public static MainActivity activity = null;
71 |
72 |
73 | @Override
74 | protected void onCreate(Bundle savedInstanceState) {
75 | activity = this;
76 |
77 | try {
78 | packageInfo = getPackageManager().getPackageInfo(
79 | "com.mojang.minecraftpe", 0);
80 | appInfo = packageInfo.applicationInfo;
81 | libraryDir = appInfo.nativeLibraryDir;
82 | libraryLocation = libraryDir + "/libminecraftpe.so";
83 | System.out.println("libminecraftpe.so is located at " + libraryDir);
84 | canAccessAssets = !appInfo.sourceDir
85 | .equals(appInfo.publicSourceDir);
86 | // int minecraftVersionCode = packageInfo.versionCode;
87 |
88 | if (this.getPackageName().equals("com.mojang.minecraftpe")) {
89 | apkContext = this;
90 | } else {
91 | apkContext = createPackageContext("com.mojang.minecraftpe",
92 | Context.CONTEXT_IGNORE_SECURITY);
93 | }
94 | Log.d("GenericLauncher","Load library fmod !");
95 | System.load(libraryDir+"/libfmod.so");
96 | Log.d("GenericLauncher","Load minecraftpe !");
97 | System.load(libraryLocation);
98 |
99 | FMOD.init(this);
100 | if(!FMOD.checkInit()) {
101 | Log.e("GenericLauncher","Failed to init fmod");
102 | } else {
103 | //Log.d("GenericLauncher","fmod init sucessful");
104 | }
105 |
106 | metrics = new DisplayMetrics();
107 | getWindowManager().getDefaultDisplay().getMetrics(metrics);
108 | setVolumeControlStream(AudioManager.STREAM_MUSIC);
109 | addLibraryDirToPath(libraryDir);
110 | mcpePackage = true;
111 | super.onCreate(savedInstanceState);
112 |
113 | try {
114 |
115 | NativeHandler.init();
116 |
117 | } catch(Exception e) {
118 | e.printStackTrace();
119 | }
120 |
121 | getWindow().getDecorView().post(new Runnable() {
122 | public void run() {
123 | setupTestButton();
124 | }
125 | });
126 |
127 | nativeRegisterThis();
128 | mcpePackage = false;
129 |
130 | int flag = Build.VERSION.SDK_INT >= 19 ? 0x40000000 : 0x08000000; // FLAG_NEEDS_MENU_KEY
131 | getWindow().addFlags(flag);
132 | } catch (Exception e) {
133 | e.printStackTrace();
134 | finish();
135 | }
136 |
137 | }
138 |
139 | public String getExternalStoragePath() {
140 | return Environment.getExternalStorageDirectory().getAbsolutePath();
141 | }
142 |
143 | public String getLocale() {
144 | return HardwareInformation.getLocale();
145 | }
146 |
147 | public int getAndroidVersion() {
148 | return Build.VERSION.SDK_INT;
149 | }
150 |
151 | boolean hasHardwareChanged() {
152 | return false;
153 | }
154 |
155 | boolean isTablet() {
156 | return (getResources().getConfiguration().screenLayout & 0xF) ==4;
157 | }
158 |
159 | public boolean isFirstSnooperStart() {
160 | return PreferenceManager.getDefaultSharedPreferences(this).getString("snooperId","").isEmpty();
161 | }
162 |
163 | public String createUUID() {
164 | return UUID.randomUUID().toString().replaceAll("-","");
165 | }
166 |
167 | public String getDeviceId() {
168 | SharedPreferences sharedPreferences =
169 | PreferenceManager.getDefaultSharedPreferences(this);
170 | String id = sharedPreferences.getString("snooperId", "");
171 | if (id.isEmpty()) {
172 | id = createUUID();
173 | SharedPreferences.Editor edit=sharedPreferences.edit();
174 | edit.putString("snooperId",id);
175 | edit.commit();
176 | }
177 | return id;
178 | }
179 |
180 |
181 | public String getDeviceModel() {
182 | String str1 = Build.MANUFACTURER;
183 | String str2 = Build.MODEL;
184 | if (str2.startsWith(str1))
185 | return str2.toUpperCase();
186 | return str1.toUpperCase() + " " + str2;
187 | }
188 |
189 | private File[] addToFileList(File[] files, File toAdd) {
190 | for (File f : files) {
191 | if (f.equals(toAdd)) {
192 | // System.out.println("Already added path to list");
193 | return files;
194 | }
195 | }
196 | File[] retval = new File[files.length + 1];
197 | System.arraycopy(files, 0, retval, 1, files.length);
198 | retval[0] = toAdd;
199 | return retval;
200 | }
201 |
202 | public static Field getDeclaredFieldRecursive(Class> clazz, String name) {
203 | if (clazz == null)
204 | return null;
205 | try {
206 | return clazz.getDeclaredField(name);
207 | } catch (NoSuchFieldException nsfe) {
208 | return getDeclaredFieldRecursive(clazz.getSuperclass(), name);
209 | }
210 | }
211 |
212 | private void addLibraryDirToPath(String path) {
213 | try {
214 | ClassLoader classLoader = getClassLoader();
215 | Class extends ClassLoader> clazz = classLoader.getClass();
216 | Field field = getDeclaredFieldRecursive(clazz, "pathList");
217 | field.setAccessible(true);
218 | Object pathListObj = field.get(classLoader);
219 | Class extends Object> pathListClass = pathListObj.getClass();
220 | Field natfield = getDeclaredFieldRecursive(pathListClass,
221 | "nativeLibraryDirectories");
222 | natfield.setAccessible(true);
223 | File[] fileList = (File[]) natfield.get(pathListObj);
224 | File[] newList = addToFileList(fileList, new File(path));
225 | if (fileList != newList)
226 | natfield.set(pathListObj, newList);
227 | // check
228 | // System.out.println("Class loader shenanigans: " +
229 | // ((PathClassLoader) getClassLoader()).findLibrary("minecraftpe"));
230 | } catch (Exception e) {
231 | e.printStackTrace();
232 | }
233 | }
234 |
235 | @Override
236 | public PackageManager getPackageManager() {
237 | if (mcpePackage) {
238 | return new RedirectPackageManager(super.getPackageManager(), libraryDir);
239 | }
240 | return super.getPackageManager();
241 | }
242 |
243 | public native void nativeRegisterThis();
244 |
245 | public native void nativeUnregisterThis();
246 |
247 | public native void nativeTypeCharacter(String character);
248 |
249 | public native void nativeSuspend();
250 |
251 | public native void nativeSetTextboxText(String text);
252 |
253 | public native void nativeBackPressed();
254 |
255 | public native void nativeBackSpacePressed();
256 |
257 | public native void nativeReturnKeyPressed();
258 |
259 | public void buyGame() {
260 | }
261 |
262 | public int checkLicense() {
263 | return 0;
264 | }
265 |
266 | public void onBackPressed() {}
267 |
268 | public void displayDialog(int dialogId) {
269 | Log.d("GenericLauncher", "[displayDialog] Dialog ID:" + dialogId);
270 | }
271 |
272 | public String getDateString(int time) {
273 | System.out.println("getDateString: " + time);
274 | return DateFormat.getDateInstance(DateFormat.SHORT, Locale.US).format(
275 | new Date(((long) time) * 1000));
276 | }
277 |
278 | public byte[] getFileDataBytes(String name) {
279 | System.out.println("Get file data: " + name);
280 | try {
281 | if (name.isEmpty())
282 | return null;
283 | InputStream is = null;
284 | if (name.charAt(0) == '/')
285 | is = new FileInputStream(new File(name));
286 | else
287 | is = getInputStreamForAsset(name);
288 | if (is == null) {
289 | Log.e("GenericLauncher",
290 | "FILE IS NULL!");
291 | return null;
292 | }
293 | // can't always find length - use the method from
294 | // http://www.velocityreviews.com/forums/t136788-store-whole-inputstream-in-a-string.html
295 | // instead
296 | ByteArrayOutputStream bout = new ByteArrayOutputStream();
297 | byte[] buffer = new byte[1024];
298 | while (true) {
299 | int len = is.read(buffer);
300 | if (len < 0) {
301 | break;
302 | }
303 | bout.write(buffer, 0, len);
304 | }
305 | byte[] retval = bout.toByteArray();
306 |
307 | return retval;
308 | } catch (Exception e) {
309 | e.printStackTrace();
310 | return null;
311 | }
312 | }
313 |
314 | //public ArrayList texturePacks = new ArrayList();
315 |
316 | protected InputStream getInputStreamForAsset(String name) {
317 | try {
318 |
319 | /*for (int i = 0; i < texturePacks.size(); i++) {
320 | try {
321 | InputStream is = texturePacks.get(i).getInputStream(name);
322 | if (is != null)
323 | return is;
324 | } catch (IOException e) {
325 | }
326 | }*/
327 |
328 | return getLocalInputStreamForAsset(name);
329 | } catch (Exception e) {
330 | e.printStackTrace();
331 | return null;
332 | }
333 | }
334 |
335 | protected InputStream getLocalInputStreamForAsset(String name) {
336 | //Log.d("GenericLauncher","getStreamAsset "+name);
337 | InputStream is = null;
338 | try {
339 | /*
340 | * if (forceFallback) { return getAssets().open(name); }
341 | */
342 | try {
343 | if (name.charAt(0) == '/')
344 | is =new FileInputStream(new File(name));
345 | else
346 | is = apkContext.getAssets().open(name);
347 | } catch (Exception e) {
348 | e.printStackTrace();
349 | // System.out.println("Attempting to load fallback");
350 | is = getAssets().open(name);
351 | }
352 | if (is == null) {
353 | System.out.println("Can't find it in the APK");
354 | is = getAssets().open(name);
355 | }
356 | return is;
357 | } catch (Exception e) {
358 | e.printStackTrace();
359 | return null;
360 | }
361 | }
362 |
363 | public int[] getImageData(String name, boolean wtf) {
364 | if (!wtf) {
365 | Log.w("GenericLauncher","I must return null?");
366 | }
367 | System.out.println("Get image data: " + name);
368 | try {
369 | InputStream is = getInputStreamForAsset(name);
370 | if (is == null) {
371 | Log.e("GenericLauncher", "IMAGE IS NULL!");
372 | return null;
373 | }
374 | Bitmap bmp = BitmapFactory.decodeStream(is);
375 | int[] retval = new int[(bmp.getWidth() * bmp.getHeight()) + 2];
376 | retval[0] = bmp.getWidth();
377 | retval[1] = bmp.getHeight();
378 | bmp.getPixels(retval, 2, bmp.getWidth(), 0, 0, bmp.getWidth(),
379 | bmp.getHeight());
380 | is.close();
381 | bmp.recycle();
382 |
383 | return retval;
384 | } catch (Exception e) {
385 | e.printStackTrace();
386 | return null;
387 | }
388 | /* format: width, height, each integer a pixel */
389 | /* 0 = white, full transparent */
390 | }
391 |
392 | public String[] getOptionStrings() {
393 | Log.e("GenericLauncher", "OptionStrings");
394 | return new String[] {};
395 | }
396 |
397 | public void launchUri(String uri) {
398 | startActivity(new Intent("android.intent.action.View",
399 | Uri.parse(uri)));
400 | }
401 |
402 | void pickImage(long paramLong) {
403 | Log.e("GenericLauncher","pickImage");
404 | }
405 |
406 | public float getPixelsPerMillimeter() {
407 | float val = ((float) metrics.densityDpi) / 25.4f;
408 | System.out.println("Pixels per mm: " + val);
409 | return val;
410 |
411 | }
412 |
413 | public String getPlatformStringVar(int a) {
414 | System.out.println("getPlatformStringVar: " + a);
415 | return "";
416 | }
417 |
418 | public float getKeyboardHeight() {
419 | Log.w("GenericLauncher","Bad implemented getKeyboardHeight");
420 | return (float) getScreenHeight()/2;
421 | }
422 |
423 | public int getScreenHeight() {
424 | return metrics.heightPixels;
425 | }
426 |
427 | public int getScreenWidth() {
428 | return metrics.widthPixels;
429 | }
430 |
431 | public int getUserInputStatus() {
432 | Log.e("GenericLauncher", "User input status");
433 | return 0;
434 | }
435 |
436 | public String[] getUserInputString() {
437 | Log.e("GenericLauncher", "User input string");
438 | return new String[] {};
439 | }
440 |
441 | public boolean hasBuyButtonWhenInvalidLicense() {
442 | return false;
443 | }
444 |
445 | /** Seems to be called whenever displayDialog is called. Not on UI thread. */
446 | public void initiateUserInput(int a) {
447 | System.out.println("initiateUserInput: " + a);
448 | }
449 |
450 | public boolean isNetworkEnabled(boolean a) {
451 | System.out.println("Network?:" + a);
452 | return true;
453 | }
454 |
455 | public boolean isTouchscreen() {
456 | return true;
457 | }
458 |
459 | public void postScreenshotToFacebook(String name, int firstInt,
460 | int secondInt, int[] thatArray) {
461 | }
462 |
463 | public void quit() {
464 | finish();
465 | }
466 |
467 | public void setIsPowerVR(boolean powerVR) {
468 | System.out.println("PowerVR: " + powerVR);
469 | }
470 |
471 | public void tick() {
472 | }
473 |
474 | public void vibrate(int duration) {
475 | ((Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE))
476 | .vibrate(duration);
477 | }
478 |
479 | public boolean supportsNonTouchscreen() {
480 | boolean xperia = false;
481 | boolean play = false;
482 | String[] data = new String[3];
483 | data[0] = Build.MODEL.toLowerCase(Locale.ENGLISH);
484 | data[1] = Build.DEVICE.toLowerCase(Locale.ENGLISH);
485 | data[2] = Build.PRODUCT.toLowerCase(Locale.ENGLISH);
486 | for (String s : data) {
487 | if (s.indexOf("xperia") >= 0)
488 | xperia = true;
489 | if (s.indexOf("play") >= 0)
490 | play = true;
491 | }
492 | return xperia && play;
493 | }
494 |
495 | public int getKeyFromKeyCode(int keyCode, int metaState, int deviceId) {
496 | KeyCharacterMap characterMap = KeyCharacterMap.load(deviceId);
497 | return characterMap.get(keyCode, metaState);
498 | }
499 |
500 | public static void saveScreenshot(String name, int firstInt, int secondInt,
501 | int[] thatArray) {
502 | }
503 |
504 | public void showKeyboard(final String mystr, final int maxLength,
505 | final boolean mybool,final boolean isNumber) {
506 | this.runOnUiThread(new Runnable() {
507 | public void run() {
508 | showHiddenTextbox(mystr, maxLength, mybool,isNumber);
509 | }
510 | });
511 | }
512 |
513 | public void hideKeyboard() {
514 | this.runOnUiThread(new Runnable() {
515 | public void run() {
516 | dismissHiddenTextbox();
517 | }
518 | });
519 | }
520 |
521 | public void updateTextboxText(final String text) {
522 | if (hiddenTextView == null)
523 | return;
524 | hiddenTextView.post(new Runnable() {
525 | public void run() {
526 | hiddenTextView.setText(text);
527 | }
528 | });
529 | }
530 |
531 | PopupWindow hiddenTextWindow;
532 | EditText hiddenTextView;
533 | Boolean hiddenTextDismissAfterOneLine = false;
534 |
535 | private class PopupTextWatcher implements TextWatcher,
536 | TextView.OnEditorActionListener {
537 | public void afterTextChanged(Editable e) {
538 | nativeSetTextboxText(e.toString());
539 |
540 | }
541 |
542 | public void beforeTextChanged(CharSequence c, int start, int count,
543 | int after) {
544 | }
545 |
546 | public void onTextChanged(CharSequence c, int start, int count,
547 | int after) {
548 | }
549 |
550 | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
551 | if (hiddenTextDismissAfterOneLine) {
552 | hiddenTextWindow.dismiss();
553 | } else {
554 | nativeReturnKeyPressed();
555 | }
556 | return true;
557 | }
558 | }
559 |
560 | public void showHiddenTextbox(String text, int maxLength,
561 | boolean dismissAfterOneLine,boolean isNumber) {
562 | int IME_FLAG_NO_FULLSCREEN = 0x02000000;
563 | if (hiddenTextWindow == null) {
564 | hiddenTextView = new EditText(this);
565 | PopupTextWatcher whoWatchesTheWatcher = new PopupTextWatcher();
566 | hiddenTextView.addTextChangedListener(whoWatchesTheWatcher);
567 | hiddenTextView.setOnEditorActionListener(whoWatchesTheWatcher);
568 | hiddenTextView.setSingleLine(true);
569 | hiddenTextView.setImeOptions(EditorInfo.IME_ACTION_NEXT
570 | | EditorInfo.IME_FLAG_NO_EXTRACT_UI
571 | | IME_FLAG_NO_FULLSCREEN);
572 | hiddenTextView.setInputType(InputType.TYPE_CLASS_TEXT);
573 | LinearLayout linearLayout = new LinearLayout(this);
574 | linearLayout.addView(hiddenTextView);
575 | hiddenTextWindow = new PopupWindow(linearLayout);
576 | hiddenTextWindow.setWindowLayoutMode(
577 | ViewGroup.LayoutParams.WRAP_CONTENT,
578 | ViewGroup.LayoutParams.WRAP_CONTENT);
579 | hiddenTextWindow.setFocusable(true);
580 | hiddenTextWindow
581 | .setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
582 | hiddenTextWindow.setBackgroundDrawable(new ColorDrawable());
583 | // To get back button handling for free
584 | hiddenTextWindow.setClippingEnabled(false);
585 | hiddenTextWindow.setTouchable(false);
586 | hiddenTextWindow.setOutsideTouchable(true);
587 | // These flags were taken from a dumpsys window output of Mojang's
588 | // window
589 | hiddenTextWindow
590 | .setOnDismissListener(new PopupWindow.OnDismissListener() {
591 | public void onDismiss() {
592 | nativeBackPressed();
593 | }
594 | });
595 | }
596 |
597 | if (isNumber) {
598 | hiddenTextView.setInputType(InputType.TYPE_CLASS_NUMBER);
599 | }
600 | hiddenTextView.setText(text);
601 | Selection.setSelection((Spannable) hiddenTextView.getText(),
602 | text.length());
603 | this.hiddenTextDismissAfterOneLine = dismissAfterOneLine;
604 |
605 | hiddenTextWindow.showAtLocation(this.getWindow().getDecorView(),
606 | Gravity.LEFT | Gravity.TOP, -10000, 0);
607 | hiddenTextView.requestFocus();
608 | showKeyboardView();
609 | }
610 |
611 | protected void onDestroy() {
612 | FMOD.close();
613 | nativeUnregisterThis();
614 | super.onDestroy();
615 | System.exit(0);
616 | }
617 |
618 | public void dismissHiddenTextbox() {
619 | if (hiddenTextWindow == null)
620 | return;
621 | hiddenTextWindow.dismiss();
622 | hideKeyboardView();
623 | }
624 |
625 | public void showKeyboardView() {
626 | Log.i("GenericLauncher", "Show keyboard view");
627 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
628 | imm.showSoftInput(getWindow().getDecorView(),
629 | InputMethodManager.SHOW_FORCED);
630 | }
631 |
632 | protected void hideKeyboardView() {
633 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
634 | imm.hideSoftInputFromWindow(this.getWindow().getDecorView()
635 | .getWindowToken(), 0);
636 | }
637 |
638 | public int abortWebRequest(int requestId) {
639 | Log.i("GenericLauncher", "Abort web request: " + requestId);
640 | return 0;
641 | }
642 |
643 | public String getRefreshToken() {
644 | Log.i("GenericLauncher", "Get Refresh token");
645 | return "";
646 | }
647 |
648 | public String getSession() {
649 | Log.i("GenericLauncher", "Get Session");
650 | return "";
651 | }
652 |
653 | public String getWebRequestContent(int requestId) {
654 | Log.e("GenericLauncher", "Get web request content: " + requestId);
655 | return "";
656 | }
657 |
658 | public int getWebRequestStatus(int requestId) {
659 | Log.e("GenericLauncher", "Get web request status: " + requestId);
660 | return 0;
661 | }
662 |
663 | public void openLoginWindow() {
664 | Log.e("GenericLauncher", "Open login window");
665 | }
666 |
667 | public void setRefreshToken(String token) {
668 | }
669 |
670 | public void setSession(String session) {
671 | }
672 |
673 | public void webRequest(int requestId, long timestamp, String url,
674 | String method, String cookies) {
675 | Log.e("GenericLauncher", "webRequest");
676 | }
677 |
678 | // signature change in 0.7.3
679 | public void webRequest(int requestId, long timestamp, String url,
680 | String method, String cookies, String extraParam) {
681 | Log.e("GenericLauncher", "webRequest");
682 | }
683 |
684 | public String getAccessToken() {
685 | Log.i("GenericLauncher", "Get access token");
686 | return "";
687 | }
688 |
689 | public String getClientId() {
690 | Log.i("GenericLauncher", "Get client ID");
691 | return "";
692 | }
693 |
694 | public String getProfileId() {
695 | Log.i("GenericLauncher", "Get profile ID");
696 | return "";
697 | }
698 |
699 | public String getProfileName() {
700 | Log.i("GenericLauncher", "Get profile name");
701 | return "";
702 | }
703 |
704 | public void statsTrackEvent(String firstEvent, String secondEvent) {
705 | Log.i("GenericLauncher", "Stats track: " + firstEvent + ":" + secondEvent);
706 | }
707 |
708 | public void statsUpdateUserData(String firstEvent, String secondEvent) {
709 | Log.i("GenericLauncher", "Stats update user data: " + firstEvent + ":"
710 | + secondEvent);
711 | }
712 |
713 | public boolean isDemo() {
714 | Log.i("GenericLauncher", "Is demo");
715 | return false;
716 | }
717 |
718 | public void setLoginInformation(String accessToken, String clientId,
719 | String profileUuid, String profileName) {
720 | Log.i("GenericLauncher", "setLoginInformation");
721 | }
722 |
723 | public void clearLoginInformation() {
724 | Log.i("GenericLauncher", "Clear login info");
725 | }
726 |
727 | public String[] getBroadcastAddresses() {
728 | return new String[]{};
729 | }
730 |
731 | public long getTotalMemory() {
732 | ActivityManager localActivityManager = (ActivityManager)getSystemService("activity");
733 | ActivityManager.MemoryInfo localMemoryInfo = new ActivityManager.MemoryInfo();
734 | localActivityManager.getMemoryInfo(localMemoryInfo);
735 | return localMemoryInfo.availMem;
736 | }
737 |
738 | public void setupTestButton() {
739 | TestButton button = new TestButton(this);
740 | button.show(getWindow().getDecorView());
741 | button.mainButton.setOnClickListener(new View.OnClickListener() {
742 | public void onClick(View v) {
743 | System.out.println("What does the fox say?");
744 | }
745 | });
746 |
747 | }
748 | }
749 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/store/NativeStoreListener.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe.store;
2 |
3 | public class NativeStoreListener
4 | implements StoreListener
5 | {
6 | long mStoreListener;
7 |
8 | public NativeStoreListener(long paramLong)
9 | {
10 | this.mStoreListener = paramLong;
11 | }
12 |
13 | public native void onPurchaseCanceled(long paramLong, String paramString);
14 |
15 | public void onPurchaseCanceled(String paramString)
16 | {
17 | onPurchaseCanceled(this.mStoreListener, paramString);
18 | }
19 |
20 | public native void onPurchaseFailed(long paramLong, String paramString);
21 |
22 | public void onPurchaseFailed(String paramString)
23 | {
24 | onPurchaseFailed(this.mStoreListener, paramString);
25 | }
26 |
27 | public native void onPurchaseSuccessful(long paramLong, String paramString);
28 |
29 | public void onPurchaseSuccessful(String paramString)
30 | {
31 | onPurchaseSuccessful(this.mStoreListener, paramString);
32 | }
33 |
34 | public void onQueryProductsFail()
35 | {
36 | onQueryProductsFail(this.mStoreListener);
37 | }
38 |
39 | public native void onQueryProductsFail(long paramLong);
40 |
41 | public native void onQueryProductsSuccess(long paramLong, Product[] paramArrayOfProduct);
42 |
43 | public void onQueryProductsSuccess(Product[] paramArrayOfProduct)
44 | {
45 | onQueryProductsSuccess(this.mStoreListener, paramArrayOfProduct);
46 | }
47 |
48 | public void onQueryPurchasesFail()
49 | {
50 | onQueryPurchasesFail(this.mStoreListener);
51 | }
52 |
53 | public native void onQueryPurchasesFail(long paramLong);
54 |
55 | public native void onQueryPurchasesSuccess(long paramLong, Purchase[] paramArrayOfPurchase);
56 |
57 | public void onQueryPurchasesSuccess(Purchase[] paramArrayOfPurchase)
58 | {
59 | onQueryPurchasesSuccess(this.mStoreListener, paramArrayOfPurchase);
60 | }
61 |
62 | public native void onStoreInitialized(long paramLong, boolean paramBoolean);
63 |
64 | public void onStoreInitialized(boolean paramBoolean)
65 | {
66 | onStoreInitialized(this.mStoreListener, paramBoolean);
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/store/Product.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe.store;
2 |
3 | public class Product
4 | {
5 | public String mId;
6 | public String mPrice;
7 |
8 | public Product(String paramString1, String paramString2)
9 | {
10 | this.mId = paramString1;
11 | this.mPrice = paramString2;
12 | }
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/store/Purchase.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe.store;
2 |
3 | public class Purchase
4 | {
5 | public String mProductId;
6 |
7 | public Purchase(String paramString)
8 | {
9 | this.mProductId = paramString;
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/store/Store.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe.store;
2 |
3 | import android.util.Log;
4 |
5 | public class Store
6 | {
7 | private StoreListener listener;
8 |
9 | public Store(StoreListener paramStoreListener)
10 | {
11 | this.listener = paramStoreListener;
12 | }
13 |
14 | public void destructor()
15 | {
16 | Log.i("GenericLauncher","Store: Destructor");
17 | }
18 |
19 | public String getStoreId()
20 | {
21 | Log.i("GenericLauncher","Store: Get store ID");
22 | return "Placeholder store ID";
23 | }
24 |
25 | public void purchase(String paramString)
26 | {
27 | Log.i("GenericLauncher","Store: Purchase " + paramString);
28 | }
29 |
30 | public void queryProducts(String[] paramArrayOfString)
31 | {
32 | Log.i("GenericLauncher","Store: Query products");
33 | }
34 |
35 | public void queryPurchases()
36 | {
37 | Log.i("GenericLauncher","Store: Query purchases");
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/store/StoreFactory.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe.store;
2 |
3 | import com.mojang.minecraftpe.MainActivity;
4 |
5 | import android.util.Log;
6 |
7 | public class StoreFactory
8 | {
9 | public static Store createAmazonAppStore(StoreListener paramStoreListener) {
10 | return new Store(paramStoreListener);
11 | }
12 |
13 | public static Store createGooglePlayStore(String s, StoreListener listener) {
14 | return new Store(listener);
15 | }
16 |
17 | public static Store createSamsungAppStore(StoreListener storeListener) {
18 | return new Store(storeListener);
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/src/com/mojang/minecraftpe/store/StoreListener.java:
--------------------------------------------------------------------------------
1 | package com.mojang.minecraftpe.store;
2 |
3 | public abstract interface StoreListener
4 | {
5 | /*public abstract void onPurchaseCanceled(String paramString);
6 |
7 | public abstract void onPurchaseFailed(String paramString);
8 |
9 | public abstract void onPurchaseSuccessful(String paramString);
10 |
11 | public abstract void onQueryProductsFail();
12 |
13 | public abstract void onQueryProductsSuccess(Product[] paramArrayOfProduct);
14 |
15 | public abstract void onQueryPurchasesFail();
16 |
17 | public abstract void onQueryPurchasesSuccess(Purchase[] paramArrayOfPurchase);
18 |
19 | public abstract void onStoreInitialized(boolean paramBoolean);*/
20 | }
21 |
22 |
--------------------------------------------------------------------------------