forked from henrichg/PhoneProfilesPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcospravit.txt
More file actions
486 lines (400 loc) · 20.8 KB
/
cospravit.txt
File metadata and controls
486 lines (400 loc) · 20.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
Start eventu:
1. ak je uz event v timeline, cize uz bezi
- odmaze sa - toto zaisti, ze ak event znovaspustim (co je dovolene), tak mevzniknnu duplikaty eventu v timeline
- ak je event prvy v timeline
- TOTO JE CELE ZLE
- poposuvaju sa _fkProfileEndActivated po timeline smerom k prvemu (???)
- po poposuvani ma prvy event v timeline _fkProfileEndActivated nastaveny na _fkProfileStart vymazaneho eventu
takze treba nastavit fkProfileEndActivated na _fkProfileEndActivated vymazaneho eventu
- MA SA SPRAVIT
- nic neposuvame, len updatneme end profile prveho na ten, co ho mal ten odmazany
- ak je event v strede timeline - TOTO JE NOVE
- nic neposuvame, len updatneme end profile toho co bol za vymazanym na start profil eventu pred nim
- ak je event na konci timeline
- netreba robit nic
2. ak je prvy v timeline
- do timeline sa da do _fkProfileEndActivated prave aktivovany profil
2. ak uz v timeline nieco je
- do timeline sa da do _fkProfileEndActivated _fkProfileStart posledneho eventu v timeline
3. event sa proda na koniec timeline
End eventu:
1. ak je uz event v timeline, cize uz bezi, odmaze sa
- ak je event prvy v timeline
- TOTO JE CELE ZLE
- poposuvaju sa _fkProfileEndActivated po timeline smerom k prvemu (???)
- po poposuvani ma prvy event v timeline _fkProfileEndActivated nastaveny na _fkProfileStart vymazaneho eventu
takze treba nastavit fkProfileEndActivated na _fkProfileEndActivated vymazaneho eventu
- MA SA SPRAVIT
- nic neposuvame, len updatneme end profile prveho na ten, co ho mal ten odmazany
- ak je event v strede timeline - TOTO JE NOVE
- nic neposuvame, len updatneme end profile toho co bol za vymazanym na start profil eventu pred nim
- ak je event na konci timeline
- netreba robit nic
2. aktivujeme _fkProfileEndActivated eventu, co skoncil, ale len ak je na konci timeline
--------------------------------------------------------------------------
Vymazavanie eventu z timeline:
P0 - E1 P1 P0, E2 P2 P1, E3 P3 P2, E4 P4 P3
P0 - E2 P2 P1, E3 P3 P2, E4 P4 P3
--------------------------------------------
P0 - E2 P2 P0, E3 P3 P2, E4 P4 P3 - nic neposuvame, len updatneme end profile prveho na ten, co ho mal ten odmazany
P0 - E2 P2 P0, E3 P3 P1, E4 P4 P2 - po starom, cele zle!!!
============================================
P0 - E1 P1 P0, E2 P2 P1, E3 P3 P2, E4 P4 P3
P0 - E1 P1 P0, , E3 P3 P2, E4 P4 P3
--------------------------------------------
P0 - E1 P1 P0, , E3 P3 P1, E4 P4 P3 - nic neposuvame, len updatneme end profile toho co bol za vymazanym na start profil eventu pred nim
============================================
P0 - E1 P1 P0, E2 P2 P1, E3 P3 P2, E4 P4 P3
P0 - E1 P1 P0, E2 P2 P1, E3 P3 P2,
--------------------------------------------
P0 - E1 P1 P0, E2 P2 P1, E3 P3 P2, - nic nerobime
----------------------------------------------------------------------------
Bluetooth
Pravdepodobne budeme musiet rozlisovat bluetooth profile:
Primo zisiti, aky profil je pripojeny sa da len pre
A2DP = Advanced Audio Distribution
HEADSET = Headset
HEALTH = Health Thermometer
Toto nejde zistit, ci je pripojene. Zjavne to tu funguje inac
GATT = Bluetooth Low Energy
GATT_SERVER = Bluetooth Low Energy
Spravme to tak, ze cez broadcast receiver si zistim, co sa pripojilo/odpojilo.
Na toto uz mam receiver BluetoothConnectionBroadcastReceiver.
Ten mi bude ukladat zariadenia, ktore sa pripojili.
Bude to List<BluetoothDevice>.
Ak sa pripoji, pohladam jeho adresu v liste a ak tam nie je, pridame do listu.
List inicializujeme pri prvom starte aplikacie.
!!! Tu moze byt problem, ze nedostanem pri starte ak prave bude nieco pripojene. !!!
Potom spravime scanner. Na to uz mam receiver BluetoothScanAlarmBroadcastReceiver.
Ten bude vyuzivat zoznam pripojenych zariadeni z receivera BluetoothConnectionBroadcastReceiver.
Scanner bude scanovat bluetooth zariadenia.
Ak scanujeme zariadenie, ktore uz je v zozname pripojenych, nezapnemam scan. Ako pri Wifi.
Na scanovanie este treba spravit receiver na prijem najdeneho zariadenia.
Aj tu budeme ukladat zoznam do scanResults.
Tu je problem v tom, ze tu nedostavame naraz cely zoznam, ale postupne jedno zariadenie za druhym.
Cize treba vymysliet mechanizmus dvoch zoznamov.
Jeden bude temporary, ktory sa vymaze na zaciatku scanu a postupne sa bude naplnat.
Druhy sa po ukonceni scanu naplni tym temporary a tenot sa bude pouzivat podobne ako scanResult pri Wifi.
Ak sa odpoji, pohladam jeho adresu a ak tam je, vymazem ho z listu.
------------------------------------
Location
1. Pouzijem GooglePlayService (GPSrv) - GeofenceDetection
2. Geofence je vlastne GPS suradnica + polomer
3. Geogence sa do GPSrv registrovava a odregistrovava
4. Na (de)registraciu je potrebny BroadcastReceiver
---- toto naimplementujem do EventPreferencesFragmentu/aktivity alebo do custom DialogPreference
// Create a new broadcast receiver to receive updates from the listeners and service
mBroadcastReceiver = new GeofenceSampleReceiver();
// Create an intent filter for the broadcast receiver
mIntentFilter = new IntentFilter();
// Action for broadcast Intents that report successful addition of geofences
mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_ADDED);
// Action for broadcast Intents that report successful removal of geofences
mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED);
// Action for broadcast Intents containing various types of geofencing errors
mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCE_ERROR);
// All Location Services sample apps use this category
mIntentFilter.addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES);
// Register the broadcast receiver to receive status updates
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, mIntentFilter);
/**
* Define a Broadcast receiver that receives updates from connection listeners and
* the geofence transition service.
*/
public class GeofenceSampleReceiver extends BroadcastReceiver {
/*
* Define the required method for broadcast receivers
* This method is invoked when a broadcast Intent triggers the receiver
*/
@Override
public void onReceive(Context context, Intent intent) {
// Check the action code and determine what to do
String action = intent.getAction();
// Intent contains information about errors in adding or removing geofences
if (TextUtils.equals(action, GeofenceUtils.ACTION_GEOFENCE_ERROR)) {
handleGeofenceError(context, intent);
// Intent contains information about successful addition or removal of geofences
} else if (
TextUtils.equals(action, GeofenceUtils.ACTION_GEOFENCES_ADDED)
||
TextUtils.equals(action, GeofenceUtils.ACTION_GEOFENCES_REMOVED)) {
handleGeofenceStatus(context, intent);
// Intent contains information about a geofence transition
} else if (TextUtils.equals(action, GeofenceUtils.ACTION_GEOFENCE_TRANSITION)) {
handleGeofenceTransition(context, intent);
// The Intent contained an invalid action
} else {
Log.e(GeofenceUtils.APPTAG, getString(R.string.invalid_action_detail, action));
Toast.makeText(context, R.string.invalid_action, Toast.LENGTH_LONG).show();
}
}
/**
* If you want to display a UI message about adding or removing geofences, put it here.
*
* @param context A Context for this component
* @param intent The received broadcast Intent
*/
private void handleGeofenceStatus(Context context, Intent intent) {
}
/**
* Report geofence transitions to the UI
*
* @param context A Context for this component
* @param intent The Intent containing the transition
*/
private void handleGeofenceTransition(Context context, Intent intent) {
/*
* If you want to change the UI when a transition occurs, put the code
* here. The current design of the app uses a notification to inform the
* user that a transition has occurred.
*/
}
/**
* Report addition or removal errors to the UI, using a Toast
*
* @param intent A broadcast Intent sent by ReceiveTransitionsIntentService
*/
private void handleGeofenceError(Context context, Intent intent) {
String msg = intent.getStringExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS);
Log.e(GeofenceUtils.APPTAG, msg);
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
}
}
5. Treba testnut, ci ma uzivatel nainstalovany GPServ
---- toto budem musiet spravit na boot zariadenia. Problem je, ze je treba aktivitu na to, dokonca FragmentActivity.
Mozno to vyriesim vytvorenim empty aktivity.
/**
* Verify that Google Play services is available before making a request.
*
* @return true if Google Play services is available, otherwise false
*/
private boolean servicesConnected() {
// Check that Google Play services is available
int resultCode =
GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == resultCode) {
// In debug mode, log the status
Log.d(GeofenceUtils.APPTAG, getString(R.string.play_services_available));
// Continue
return true;
// Google Play services was not available for some reason
} else {
// Display an error dialog
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 0);
if (dialog != null) {
ErrorDialogFragment errorFragment = new ErrorDialogFragment();
errorFragment.setDialog(dialog);
errorFragment.show(getSupportFragmentManager(), GeofenceUtils.APPTAG);
}
return false;
}
}
/**
* Define a DialogFragment to display the error dialog generated in
* showErrorDialog.
*/
public static class ErrorDialogFragment extends DialogFragment {
// Global field to contain the error dialog
private Dialog mDialog;
/**
* Default constructor. Sets the dialog field to null
*/
public ErrorDialogFragment() {
super();
mDialog = null;
}
/**
* Set the dialog to display
*
* @param dialog An error dialog
*/
public void setDialog(Dialog dialog) {
mDialog = dialog;
}
/*
* This method must return a Dialog to the DialogFragment.
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return mDialog;
}
}
6. Na samotne zaregistrovanie geofences pouzi class GeofenceRequester z prikladovej aplikacie GeofenceDetection.
- Pridanie listu geofences sa robi metodou addGeofences();
7. Na zrusenie geofences pouzi class GeofenceRemover z prikladovej aplikacie GeofenceDetection
- Vymazanie podmnoziny geofences sa robi metodou removeGeofencesById()
- Vymazanie vsetkcy geofences sa robi metodou removeGeofencesByIntent() - asi rychlejsie ako prva metoda, ktorou sa to da tiez
9. Moze sa stat, ze sa vyvolaju dialogy z GPServ (!!!), tak treba, aby aktivita z ktorej volam add/remove geofences obsahovala
metodu onActivityResult
---- toto fakt netusim, ako vyriesim, ked budem nahadzovat geofences z boot receivera a z EventPreferencesActivity (???)
/*
* Handle results returned to this Activity by other Activities started with
* startActivityForResult(). In particular, the method onConnectionFailed() in
* GeofenceRemover and GeofenceRequester may call startResolutionForResult() to
* start an Activity that handles Google Play services problems. The result of this
* call returns here, to onActivityResult.
* calls
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
// Choose what to do based on the request code
switch (requestCode) {
// If the request code matches the code sent in onConnectionFailed
case GeofenceUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST :
switch (resultCode) {
// If Google Play services resolved the problem
case Activity.RESULT_OK:
// If the request was to add geofences
if (GeofenceUtils.REQUEST_TYPE.ADD == mRequestType) {
// Toggle the request flag and send a new request
mGeofenceRequester.setInProgressFlag(false);
// Restart the process of adding the current geofences
mGeofenceRequester.addGeofences(mCurrentGeofences);
// If the request was to remove geofences
} else if (GeofenceUtils.REQUEST_TYPE.REMOVE == mRequestType ){
// Toggle the removal flag and send a new removal request
mGeofenceRemover.setInProgressFlag(false);
// If the removal was by Intent
if (GeofenceUtils.REMOVE_TYPE.INTENT == mRemoveType) {
// Restart the removal of all geofences for the PendingIntent
mGeofenceRemover.removeGeofencesByIntent(
mGeofenceRequester.getRequestPendingIntent());
// If the removal was by a List of geofence IDs
} else {
// Restart the removal of the geofence list
mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove);
}
}
break;
// If any other result was returned by Google Play services
default:
// Report that Google Play services was unable to resolve the problem.
Log.d(GeofenceUtils.APPTAG, getString(R.string.no_resolution));
}
// If any other request code was received
default:
// Report that this Activity received an unknown requestCode
Log.d(GeofenceUtils.APPTAG,
getString(R.string.unknown_activity_request_code, requestCode));
break;
}
}
10. GeofenceRequester a GeofenceRemover registruju IntentService, ktory sa bude volat vzdy, ak akualna lokacia je v nejakom
geofence.
Ide o class ReceiveTransitionsIntentService z prikladovej aplikacie GeofenceDetection.
----------
Co som zistil:
1. GeofenceSampleReceiver - nie je treba lebo:
a) ACTION_GEOFENCE_ERROR - toto sa da vyriesit osetrenim chyb v
- ReceiveTransitionsIntentService
- GeofenceRequester
- GeofenceRemover
b) ACTION_GEOFENCES_ADDED - toto sa da vyriesit osetrenim v
- GeofenceRequester
c) ACTION_GEOFENCES_REMOVED - toto sa da vyriesit osetrenim v
- GeofenceRemover
d) ACTION_GEOFENCE_TRANSITION - toto sa da vyriesit osetrenim v
- ReceiveTransitionsIntentService
2. Problem je stale z onActivityResult. Z GeofenceRequester a GeofenceRemover je volane toto:
/*
* Google Play services can resolve some errors it detects.
* If the error has a resolution, try sending an Intent to
* start a Google Play services activity that can resolve
* error.
*/
if (connectionResult.hasResolution()) {
try {
// Start an Activity that tries to resolve the error
connectionResult.startResolutionForResult(mActivity,
GeofenceUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST);
/*
* Thrown if Google Play services canceled the original
* PendingIntent
*/
} catch (SendIntentException e) {
// Log the error
e.printStackTrace();
}
}
Toto je potrebne, lebo inac nebudem vediet uzivatelovi zobrazit error dialog, ked sa nieco stane interne v GPSrv.
Problem je, ze je treba aktivitu ako parameter na to.
Mozno to vyriesim vytvorenim empty aktivity.
-----
Stale nemam vyriesene ako zadavat tie geofences
1. Spravim predsa len dialog s mapkou s My Location layer
2. Pod mapou bude seekbar na urcenie radiusu pre geofence
3. Pod seekbarom bude Edit text, ktorym moze pomenovat polohu na mape. Polou ziskam:
- zistenim aktualnej polohy - ak kliknem na My Location button - je na to tl. listener
- ak kliknem niekde na mape - je na to listener
4. Vedla EditTextu bude button na pridanie geofence a jeho update.
5. Pod Edit textom bude compobox (spinner) so aktualnou polohou a vsetkymi geofences, ktore kedy uzivatel zadal.
Cize nemazat geofences ak zmazem event. Uzivatel vyberie zo spinnera 1 lokaciu. Ak uzivatel vyberie lokaciu
nastavi sa na nu mapa, aj Edit text sa nastavi na jeho meno.
6. Vedla comboboxu bude button na vymazanie geofenze, ktory je prave zobrazeny.
-------------------------------------
System.Settings:
notifications_use_ring_volume ---+--> ze by na odlinkovanie zvonenia a notifikacii?
unlink_volumes_together ---------+
mute_streams_affected
mode_ringer_streams_affected
System.Global:
heads_up_notifications_enabled
zen_mode ==== !!!!! TOTO JE ONO A FUNGUJE TO !!!
Len je problem, vyzaduje to root :-/ Hadam to Google opravi a ringer modom sa to bude dat menit, alebo daju dake ine api na to.
0 -> ALL - mode_ringer = 2
1 -> Priority - mode_ringer = 2
2 -> NONE - mode_ringer = 0
----------------------------------------
Wifi/bluetooth scanning
1. WifiScanAlarmBroadcastReceiver:
a) kuknut, ci je pripojene ku wifi (tak ako to je teraz)
b) ak nie je, zavolat service na scan
2. service na scan
a) kuknut state, ako je to v WifiScanAlarmBroadcastReceiver
b) spustit scan alebo nastavit, aby sa scanovalo, tak ako to je v WifiScanAlarmBroadcastReceiver
c) v cykle cakat na getStartScan, tak ko to je v WifiSSIDPreference
d) po cykle nastavit vsetko na false
3. WifiScanBroadcastReceiver nemenit
4. WifiConnectionBroadcastReceiver nemenit
5. WifiStateChangedBroadcastReceiver nemenit
6. WifiSSIDPreference
a) povolit wifi ak je treba
b) netestovat, ci uz scanning bezi
c) nastavit setForceOneWifiScan()
d) zavolat scanning, ktory vola service a cakat ako teraz
e) cakat na ukoncenie scanningu ako teraz
f) nenastavovat scanning shared preferences
-----------------------------------------------
Ringer mode:
ring - ringer_mode=normal, zen_mode=all, volume>0
1. set ringer_mode - set zen_mode=all
2. set_volumes - set vibrate when volume=0
3. set ringer_mode - set zen_mode=all, when volume=0 set volume=1
ring and vibrate - ringer_mode=normal, zen_mode=all, volume>0, vibrate for calls
1. set ringer_mode - set zen_mode=all, vibrate for call
2. set_volumes - set vibrate, when volume=0
3. set ringer_mode - set zen_mode=all, when volume=0 sets volume=1
vibrate - ringer_mode=vibrate, zen_mode=all, volume=0, vibrate for calls
1. set ringer_mode - set zen_mode=all, vibrate for call
2. set_volumes - reset vibrate when volume>0
3. set ringer_mode - set zen_mode=all, set volume=0
silent - ringer_mode=silent, zen_mode=priority, volume=0
1. set ringer_mode - set zen_mode=priority, vibrate for call
2. set_volumes - set vibrate, when volume=0
3. set ringer_mode - set zen_mode=priority, reset vibrate, volume can not by changed!!!
OK, co tak pre Android 5.0 spravit zen mode:
1. Do "Mod zvonenia/vybrovania" pridat "Do not disturb" mod ("Nevyrusovat") (zen mode)
2. Ten pridat dynamicky ak je Android 5.0
3. Pri importe, aj je tento mod v db, zmenit na mod "Silent"
4. Pridat novy ListPreference pre zen mode ("Do not disturb type").
5. Ten bude enablovany len ak je vybraty zen mod
6. Zen mod sa da nastavovat len na rootnutych zariadeniach.
7. Cize ak nie je root, "Do not disturb type" bude disablovany
--------------------
Ako disablovat lockscreen, 2 kroky:
1. nastavit, ze power tlacitko nema lockovat
/data/system/locksettings.db - lockscreen.power_button_instantly_locks (0,1)
len je otazka, ci toto existuje aj na starsich androidoch ako 5.0
2. nastavit lockscreen timeout
Settings.Secure - lock_screen_lock_after_timeout (milisekundy)