Revision 8fa39aa6
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/helpers/BlockController.java | ||
---|---|---|
47 | 47 |
|
48 | 48 |
private static final long THRESHHOLD_0 = 3000; |
49 | 49 |
private static final long THRESHHOLD_1 = 25000; |
50 |
private static final long THRESHHOLD_2 = 45000; |
|
50 |
private static final long THRESHHOLD_2 = 5000; |
|
51 |
private static final long THRESHHOLD_3 = 45000; |
|
51 | 52 |
|
52 | 53 |
private static long mPauseTime, mResumeTime; |
53 | 54 |
|
... | ... | |
97 | 98 |
|
98 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
99 | 100 |
// RUBIK_PLACE_3 and TUTORIAL_PLACE_3 are scrambles, those can take up to 20 seconds. |
101 |
// RUBIK_PLACE_4 and TUTORIAL_PLACE_4 are solves, those can (maybe) sometimes take more than 3 seconds. |
|
100 | 102 |
// CONTROL_PLACE_* are the visual tutorials, could take up to 45 seconds. |
101 | 103 |
|
102 | 104 |
private long getThreshhold(int last) |
... | ... | |
105 | 107 |
{ |
106 | 108 |
case RUBIK_PLACE_3 : |
107 | 109 |
case TUTORIAL_PLACE_3: return THRESHHOLD_1; |
110 |
case RUBIK_PLACE_4 : |
|
111 |
case TUTORIAL_PLACE_4: return THRESHHOLD_2; |
|
108 | 112 |
case CONTROL_PLACE_0 : |
109 |
case CONTROL_PLACE_1 : return THRESHHOLD_2;
|
|
113 |
case CONTROL_PLACE_1 : return THRESHHOLD_3;
|
|
110 | 114 |
default : return THRESHHOLD_0; |
111 | 115 |
} |
112 | 116 |
} |
... | ... | |
116 | 120 |
private void checkingThread() |
117 | 121 |
{ |
118 | 122 |
long now = System.currentTimeMillis(); |
119 |
|
|
120 | 123 |
long touchThreshhold = getThreshhold(mLastTouchPlace); |
124 |
long touchBlocked = now-mTouchBlockTime; |
|
121 | 125 |
|
122 |
if( mTouchBlockTime>mPauseTime && now-mTouchBlockTime>touchThreshhold )
|
|
126 |
if( mTouchBlockTime>mPauseTime && touchBlocked>touchThreshhold )
|
|
123 | 127 |
{ |
124 | 128 |
TwistyActivity act = mAct.get(); |
129 |
boolean reallyBlocked = true; |
|
125 | 130 |
|
126 | 131 |
if( act!=null ) |
127 | 132 |
{ |
128 | 133 |
TwistyPreRender pre = act.getTwistyPreRender(); |
129 |
if( pre!=null ) pre.unblockTouch(); |
|
134 |
if( pre!=null ) |
|
135 |
{ |
|
136 |
reallyBlocked = pre.isTouchBlocked(); |
|
137 |
pre.unblockTouch(); |
|
138 |
} |
|
130 | 139 |
} |
131 | 140 |
|
132 |
reportTouchProblem(touchThreshhold);
|
|
141 |
reportTouchProblem(touchBlocked, reallyBlocked);
|
|
133 | 142 |
} |
134 | 143 |
|
135 | 144 |
long uiThreshhold = getThreshhold(mLastUIPlace); |
145 |
long uiBlocked = now-mUIBlockTime; |
|
136 | 146 |
|
137 |
if( mUIBlockTime>mPauseTime && now-mUIBlockTime>uiThreshhold )
|
|
147 |
if( mUIBlockTime>mPauseTime && uiBlocked>uiThreshhold )
|
|
138 | 148 |
{ |
139 | 149 |
TwistyActivity act = mAct.get(); |
150 |
boolean reallyBlocked = true; |
|
140 | 151 |
|
141 | 152 |
if( act!=null ) |
142 | 153 |
{ |
143 | 154 |
TwistyPreRender pre = act.getTwistyPreRender(); |
144 |
if( pre!=null ) pre.unblockUI(); |
|
155 |
if( pre!=null ) |
|
156 |
{ |
|
157 |
reallyBlocked = !pre.isUINotBlocked(); |
|
158 |
pre.unblockUI(); |
|
159 |
} |
|
145 | 160 |
} |
146 | 161 |
|
147 |
reportUIProblem(uiThreshhold);
|
|
162 |
reportUIProblem(uiBlocked, reallyBlocked);
|
|
148 | 163 |
} |
149 | 164 |
} |
150 | 165 |
|
151 | 166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
152 | 167 |
|
153 |
private void reportTouchProblem(long time)
|
|
168 |
private void reportUIProblem(long time, boolean reallyBlocked)
|
|
154 | 169 |
{ |
155 |
String error = "TOUCH BLOCK "+mLastTouchPlace+" blocked for "+time+" milliseconds!";
|
|
170 |
String error = "UI BLOCK "+mLastUIPlace+" blocked for "+time+" milliseconds ("+reallyBlocked+")";
|
|
156 | 171 |
|
157 | 172 |
if( BuildConfig.DEBUG ) |
158 | 173 |
{ |
... | ... | |
162 | 177 |
{ |
163 | 178 |
Exception ex = new Exception(error); |
164 | 179 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
165 |
crashlytics.setCustomKey("type" , "Touch" );
|
|
166 |
crashlytics.setCustomKey("place" , mLastTouchPlace );
|
|
180 |
crashlytics.setCustomKey("pause" , mPauseTime );
|
|
181 |
crashlytics.setCustomKey("resume", mResumeTime );
|
|
167 | 182 |
crashlytics.recordException(ex); |
168 | 183 |
} |
169 | 184 |
} |
170 | 185 |
|
171 | 186 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
172 | 187 |
|
173 |
private void reportUIProblem(long time)
|
|
188 |
private void reportTouchProblem(long time, boolean reallyBlocked)
|
|
174 | 189 |
{ |
175 |
String error = "UI BLOCK "+mLastUIPlace+" blocked for "+time+" milliseconds!";
|
|
190 |
String error = "TOUCH BLOCK "+mLastTouchPlace+" blocked for "+time+" milliseconds ("+reallyBlocked+")";
|
|
176 | 191 |
|
177 | 192 |
if( BuildConfig.DEBUG ) |
178 | 193 |
{ |
... | ... | |
182 | 197 |
{ |
183 | 198 |
Exception ex = new Exception(error); |
184 | 199 |
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); |
185 |
crashlytics.setCustomKey("type" , "UI" );
|
|
186 |
crashlytics.setCustomKey("place" , mLastUIPlace );
|
|
200 |
crashlytics.setCustomKey("pause" , mPauseTime );
|
|
201 |
crashlytics.setCustomKey("resume", mResumeTime );
|
|
187 | 202 |
crashlytics.recordException(ex); |
188 | 203 |
} |
189 | 204 |
} |
Also available in: Unified diff
Improve debugging in BlockController.