Documentation for the Unreal C++ Plugin
Loading...
Searching...
No Matches
ApexSDKAndroid_UPL.xml
Go to the documentation of this file.
1<?xml version="1.0" encoding="utf-8"?>
2
3<root xmlns:android="http://schemas.android.com/apk/res/android">
4 <init>
5 <log text="PixoLauncherAndroid init"/>
6 <setStringFromProperty result="HostString" ini="Engine" section="/Script/AndroidRuntimeSettings.AndroidRuntimeSettings" property="PackageName" default="com.pixovr.blank"/>
7 <log text="$S(HostString)"/>
8 </init>
9
10 <prebuildCopies>
11 <log text="Copying all the Java files."/>
12 <copyDir src="$S(PluginDir)/Java" dst="$S(BuildDir)" />
13 </prebuildCopies>
14
15 <proguardAdditions>
16 <insert>
17 </insert>
18 </proguardAdditions>
19
20 <resourceCopies>
21 </resourceCopies>
22
23 <androidManifestUpdates>
24 <addAttribute tag="application" name="android:requestLegacyExternalStorage" value="true" />
25 <addPermission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
26 <addPermission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
27 <addPermission android:name="android.permission.READ_PHONE_STATE"/>
28 <addPermission android:name="android.permission.ACCESS_WIFI_STATE"/>
29 <addPermission android:name="android.permission.QUERY_ALL_PACKAGES"/>
30 <addElements tag="application">
31 </addElements>
32 <addAttribute tag="application" name="android:sharedUserId" value="android.uid.system"/>
33
34 <loopElements tag="activity">
35 <setStringFromAttribute result="activityName" tag="$" name="android:name"/>
36 <setBoolIsEqual result="bGameActivity" arg1="$S(activityName)" arg2="com.epicgames.ue4.GameActivity"/>
37 <if condition="bGameActivity">
38 <true>
39 <setElement result="DataElement" value="data" />
40 <addAttribute tag="$DataElement" name="android:scheme" value="pixovr" />
41 <addAttribute tag="$DataElement" name="android:host" value="$S(HostString)" />
42 <setElement result="IntentFilter" value="intent-filter" />
43 <addElements tag="$IntentFilter">
44 <action android:name="android.intent.action.VIEW" />
45 <category android:name="android.intent.category.DEFAULT" />
46 <category android:name="android.intent.category.BROWSABLE" />
47 </addElements>
48 <addElement tag="$IntentFilter" name="DataElement" />
49 <addElement tag="$" name="IntentFilter" />
50 </true>
51 </if>
52 </loopElements>
53 <replace find="[HostString]" with="$S(HostString)"/>
54
55 </androidManifestUpdates>
56
57 <gameActivityImportAdditions>
58 <insert>
59 import com.managexr.getserialsample.*;
60 import com.Pixo.PixoPlatform.*;
61 import android.util.Log;
62 import android.Manifest.permission;
63 import android.net.wifi.WifiManager;
64 import android.net.wifi.WifiInfo;
65 import java.net.NetworkInterface;
66 </insert>
67 </gameActivityImportAdditions>
68
69 <gameActivityClassAdditions>
70 <insert>
71 private final static String TAG = "ApexSDKAndroid: ";
72 private String SerialNumber = "";
73
74 public void AndroidThunkJava_OpenURL(String URL)
75 {
76 AndroidThunkJava_LaunchURL(URL);
77 AndroidThunkJava_ForceQuit();
78 }
79
80 public boolean AndroidThunkJava_Launch(String packageName, String[] extraKey, String[] extraValue)
81 {
82 Log.debug(TAG + " AndroidThunkJava_Launch");
83 Intent intent;
84 String intentAction = "";
85 String intentComponent = "";
86
87 int intentActionIndex = packageName.indexOf(":");
88 if (intentActionIndex >= 0)
89 {
90 intentAction = packageName.substring(intentActionIndex + 1);
91 packageName = packageName.substring(0, intentActionIndex);
92
93 intentActionIndex = intentAction.indexOf(":");
94 if (intentActionIndex >= 0)
95 {
96 intentComponent = intentAction.substring(intentActionIndex + 1);
97 intentAction = intentAction.substring(0, intentActionIndex);
98 }
99 }
100
101 if (!AndroidThunkJava_IsPackageInstalled(packageName))
102 {
103 return false;
104 }
105
106 if (intentAction.equals(""))
107 {
108 Log.debug(TAG + "Does not have intent!");
109
110 intent = getPackageManager().getLaunchIntentForPackage(packageName);
111 if (intent == null)
112 {
113 return false;
114 }
115 }
116 else
117 {
118 Log.debug(TAG + "Has intent!");
119 intent = new Intent(intentAction);
120 if (intent == null)
121 {
122 return false;
123 }
124 intent.setPackage(packageName);
125 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
126 }
127
128 if (extraKey.length > 0)
129 {
130 for(int extraIndex = 0; extraKey.length > extraIndex; extraIndex++)
131 {
132 Log.debug(TAG + extraKey[extraIndex] + " - " + extraValue[extraIndex]);
133 intent.putExtra(extraKey[extraIndex], extraValue[extraIndex]);
134 }
135 }
136
137 if (!intentComponent.equals(""))
138 {
139 intent.setComponent(new android.content.ComponentName(packageName, intentComponent));
140 }
141
142 if (intent.resolveActivity(getPackageManager()) != null)
143 {
144 startActivity(intent);
145 AndroidThunkJava_ForceQuit();
146 return true;
147 }
148
149 return false;
150 }
151
152 public String AndroidThunkJava_GetIntentData()
153 {
154 Log.debug(TAG + "AndroidThunkJava_GetIntentData");
155 Intent intent = getIntent();
156 String action = intent.getAction();
157 Uri data = intent.getData();
158 String dataString = "";
159 if(data != null)
160 {
161 dataString = data.toString();
162 }
163 Log.debug(TAG + "Data: " + dataString);
164 Log.debug(TAG + "Action: " + action);
165
166 return dataString;
167 }
168
169 public String AndroidThunkJava_GetApplicationExtra(String InExtraName)
170 {
171 Log.debug(TAG + "AndroidThunkJava_GetApplicationExtra: " + InExtraName);
172 Intent AppIntent = getIntent();
173 Bundle AppExtras = AppIntent.getExtras();
174
175 String ExtraString = "";
176
177 if (AppExtras != null)
178 {
179 Log.debug(TAG + "Getting extras.");
180 ExtraString = AppExtras.getString(InExtraName);
181 Log.debug(TAG + "Got extra as: " + ExtraString);
182 }
183
184 return ExtraString;
185 }
186
187 public String AndroidThunkJava_GetDeviceSerialNumber()
188 {
189 Log.error("GAOCA: Getting device serial number.");
190 return SerialNumber;
191 }
192
193 public String AndroidThunkJava_GetMacAddress()
194 {
195 Log.error("GAOCA: Getting mac address.");
196 return PixoUtilities.getMacAddress();
197 }
198 </insert>
199 </gameActivityClassAdditions>
200
201 <gameActivityOnPauseAdditions>
202 <insert>
203 </insert>
204 </gameActivityOnPauseAdditions>
205
206 <gameActivityOnResumeAdditions>
207 <insert>
208 </insert>
209 </gameActivityOnResumeAdditions>
210
211 <gameActivityOnCreateAdditions>
212 <insert>
213
214 if (PermissionHelper.checkPermission("android.permission.QUERY_ALL_PACKAGES") == false) {
215 String[] permissions = {"android.permission.QUERY_ALL_PACKAGES"};
216 PermissionHelper.acquirePermissions(permissions);
217 Log.debug("GAOCA: Acquired query all packages permission.");
218 }
219
220 if (PermissionHelper.checkPermission("android.permission.ACCESS_WIFI_STATE") == false) {
221 String[] permissions = {"android.permission.ACCESS_WIFI_STATE"};
222 PermissionHelper.acquirePermissions(permissions);
223 Log.debug("GAOCA: Acquired access wifi state permission.");
224 }
225
226 MXRAdminAppMessenger mxrAdminAppMessenger = new MXRAdminAppMessenger(this);
227 mxrAdminAppMessenger.onSerialUpdated((serial)->{
228 Log.error("GAOCA: SN# - " + serial);
229 SerialNumber = serial;
230 });
231
232 Log.error("GAOCA: Post acquired permission.");
233 Log.debug("GAOCA: " + AndroidThunkJava_GetMacAddress());
234 </insert>
235 </gameActivityOnCreateAdditions>
236
237 <gameActivityOnActivityResultAdditions>
238 <insert>
239 </insert>
240 </gameActivityOnActivityResultAdditions>
241
242 <buildGradleAdditions>
243 <insert>
244 android {
245 compileOptions {
246 sourceCompatibility JavaVersion.VERSION_1_8
247 targetCompatibility JavaVersion.VERSION_1_8
248 }
249 }
250
251 dependencies {
252 implementation 'org.apache.commons:commons-lang3:3.0'
253 }
254 </insert>
255 </buildGradleAdditions>
256</root>