Revision d887aa16
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/helpers/BlockController.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.helpers; |
21 | 21 |
|
22 |
import android.app.Activity; |
|
23 |
|
|
24 |
import com.google.firebase.crashlytics.FirebaseCrashlytics; |
|
25 |
|
|
26 | 22 |
import java.util.Timer; |
27 | 23 |
import java.util.TimerTask; |
28 | 24 |
|
25 |
import android.app.Activity; |
|
26 |
|
|
29 | 27 |
import org.distorted.library.message.EffectMessageSender; |
30 |
import org.distorted.objectlib.BuildConfig; |
|
31 | 28 |
import org.distorted.objectlib.main.ObjectPreRender; |
32 | 29 |
|
33 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
34 | 31 |
|
35 | 32 |
public class BlockController |
36 | 33 |
{ |
34 |
public static final int TYPE_UI = 0; |
|
35 |
public static final int TYPE_TOUCH = 1; |
|
36 |
public static final int TYPE_THREAD = 2; |
|
37 |
|
|
37 | 38 |
public static final int PLACE_0 =0; |
38 | 39 |
public static final int PLACE_1 =1; |
39 | 40 |
public static final int PLACE_2 =2; |
... | ... | |
121 | 122 |
if( mTouchBlockTime>mPauseTime && touchBlocked>touchThreshhold ) |
122 | 123 |
{ |
123 | 124 |
boolean running = EffectMessageSender.isRunning(); |
125 |
ObjectLibInterface libInterface = mPre.getInterface(); |
|
124 | 126 |
|
125 | 127 |
if( !running ) |
126 | 128 |
{ |
127 |
reportThreadProblem();
|
|
129 |
libInterface.reportBlockProblem(TYPE_THREAD,0,mPauseTime,mResumeTime,0);
|
|
128 | 130 |
EffectMessageSender.restartThread(); |
129 | 131 |
} |
130 | 132 |
else |
131 | 133 |
{ |
132 |
boolean reallyBlocked = mPre.isTouchBlocked(); |
|
133 | 134 |
mPre.unblockTouch(); |
134 |
reportTouchProblem(touchBlocked, reallyBlocked);
|
|
135 |
libInterface.reportBlockProblem(TYPE_TOUCH,mLastTouchPlace,mPauseTime,mResumeTime,mTouchBlockTime);
|
|
135 | 136 |
} |
136 | 137 |
} |
137 | 138 |
|
... | ... | |
141 | 142 |
if( mUIBlockTime>mPauseTime && uiBlocked>uiThreshhold ) |
142 | 143 |
{ |
143 | 144 |
boolean running = EffectMessageSender.isRunning(); |
145 |
ObjectLibInterface libInterface = mPre.getInterface(); |
|
144 | 146 |
|
145 | 147 |
if( !running ) |
146 | 148 |
{ |
147 |
reportThreadProblem();
|
|
149 |
libInterface.reportBlockProblem(TYPE_THREAD,0,mPauseTime,mResumeTime,0);
|
|
148 | 150 |
EffectMessageSender.restartThread(); |
149 | 151 |
} |
150 | 152 |
else |
151 | 153 |
{ |
152 |
boolean reallyBlocked = !mPre.isUINotBlocked(); |
|
153 | 154 |
mPre.unblockUI(); |
154 |
reportUIProblem(uiBlocked, reallyBlocked);
|
|
155 |
libInterface.reportBlockProblem(TYPE_UI,mLastUIPlace,mPauseTime,mResumeTime,mUIBlockTime);
|
|
155 | 156 |
} |
156 | 157 |
} |
157 | 158 |
} |
158 | 159 |
|
159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
160 |
|
|
161 |
private void reportUIProblem(long time, boolean reallyBlocked) |
|
162 |
{ |
|
163 |
String error = "UI BLOCK "+mLastUIPlace+" blocked for "+time+" milliseconds ("+reallyBlocked+")"; |
|
164 |
|
|
165 |
if( BuildConfig.DEBUG ) |
|
166 |
{ |
|
167 |
android.util.Log.e("D", error); |
|
168 |
} |
|
169 |
else |
|
170 |
{ |
|
171 |
Exception ex = new Exception(error); |
|
172 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
|
173 |
crashlytics.setCustomKey("pause" , mPauseTime ); |
|
174 |
crashlytics.setCustomKey("resume", mResumeTime ); |
|
175 |
crashlytics.recordException(ex); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
180 |
|
|
181 |
private void reportTouchProblem(long time, boolean reallyBlocked) |
|
182 |
{ |
|
183 |
String error = "TOUCH BLOCK "+mLastTouchPlace+" blocked for "+time+" milliseconds ("+reallyBlocked+")"; |
|
184 |
|
|
185 |
if( BuildConfig.DEBUG ) |
|
186 |
{ |
|
187 |
android.util.Log.e("D", error); |
|
188 |
} |
|
189 |
else |
|
190 |
{ |
|
191 |
Exception ex = new Exception(error); |
|
192 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
|
193 |
crashlytics.setCustomKey("pause" , mPauseTime ); |
|
194 |
crashlytics.setCustomKey("resume", mResumeTime ); |
|
195 |
crashlytics.recordException(ex); |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
200 |
|
|
201 |
private void reportThreadProblem() |
|
202 |
{ |
|
203 |
String error = EffectMessageSender.reportState(); |
|
204 |
|
|
205 |
if( BuildConfig.DEBUG ) |
|
206 |
{ |
|
207 |
android.util.Log.e("D", error); |
|
208 |
} |
|
209 |
else |
|
210 |
{ |
|
211 |
Exception ex = new Exception(error); |
|
212 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
|
213 |
crashlytics.setCustomKey("pause" , mPauseTime ); |
|
214 |
crashlytics.setCustomKey("resume", mResumeTime ); |
|
215 |
crashlytics.recordException(ex); |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 | 160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
220 | 161 |
|
221 | 162 |
public void touchBlocked(int place) |
Also available in: Unified diff
Remove dependancies on Firebase from objectlib.
Report such errors to the application via the Interface.