Android contains a permission called 'ACCESS_LOCATION_EXTRA_COMMANDS'. Normal location commands would involve accessing coarse/fine location. Does anyone know what kind of extra commands this permission allows the app to access ?
Thanks.
I only know of 1 command which can be uses when you have a slow GPS fix:
((LocationManager)YourActivity.this.getSystemService("location")).sendExtraCommand("gps", "delete_aiding_data", null);
and in the Manifest:
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
According to a rough search in Android source code, it indicate that LocationManager.sendExtraCommand() need this permission exactly.
Documentation: sendExtraCommand(java.lang.String, java.lang.String, android.os.Bundle)
Go to https://cs.android.com/android/platform/superproject/+/master:frameworks/base/services/core/java/com/android/server/location/provider/AbstractLocationProvider.java;drc=master;bpv=1;bpt=1;l=353, click on onExtraCommand if you don't see the "References" panel at the bottom, scroll down to "Overriden By", and click on each implementation to see what commands it supports.
Here's a list of commands supported by GnssLocationProvider (since all of the other implementations seem to do nothing or delegate to another one):
delete_aiding_data: calls deleteAidingData
force_time_injection: calls requestUtcTime
force_psds_injection: sends a DOWNLOAD_PSDS_DATA message if mSupportsPsds is true
request_power_stats: calls requestPowerStats
Related
I am trying to create a custom FollowMe mission by sending a vehicle's GPS data on Android studio. i can send the vehicle coordinates,but the updateFollowingTarget gives a timeout error.I'm using mavic 2 zoom and dji sdk v1.14 .Did someone manage to fix this issue.
Thanks in advance.
It's a bug. It always returns timeout.
Just dont care about the error and it will work.
But it speed limited to like 15km/h so dont expect to much from it.
Edited (Do you know another function that i can use to follow a vehicle's GPS signal):
Yes, it involves more programming though.
You have to use virtualstick to control the drone. This is the only way to control the drone programmatically.
I have done it here, follows a tracker app running on a phone on my head:
https://www.youtube.com/watch?v=i3axYfIOHTY
Im working on a python api for dji. In that framework the top level code looks like below. The virtualstick calls are inside move_towards():
while True:
tracker_location = api.tracker.get_location()
drone_target_location = copy.deepcopy(tracker_location).move_to(Changeable.radius.get_value(), Changeable.bearing.get_value())
drone_location = api.drone.get_location()
course_to_tracker = drone_location.get_course(tracker_location)
heading = api.drone.smooth_heading(course_to_tracker)
drone_target_distance, drone_speed, course = api.drone.move_towards(drone_target_location, height=current_altitude, heading=heading, lowest_altitude=Changeable.lowest_altitude.get_value(), deadzone=[Changeable.dead_zone0.get_value(), Changeable.dead_zone1.get_value()], k_distance=[float(Changeable.k_dist0.get_value()), float(Changeable.k_dist1.get_value())], speed_deadzone=Changeable.speed_deadzone.get_value())
Background:
I have a working game where user can start matches through Google's standard interface. 2-4 players works fine.
I have created a custom interface where players can connect as "Friends" and from that interface start matches.
Issue:
When I manually calling Games.TurnBasedMultiplayer.createMatch for 2 players, it works most of the time.
Function is called in the end of onSignInSucceeded.
(I would prefere to call this in onActivityResult (as the default interface does) but then I'm not connected...)
When I call it for 3-4 players, it never works.
The callback returns GamesStatusCodes.STATUS_NETWORK_ERROR_OPERATION_FAILED.
Observation It seems also to differ depending on the persons Goolge IDs, some starts with G follows by numbers and some only have the numbers (not starting with G).
public void onSignInSucceeded() {
....
TurnBasedMatchConfig tbmc = TurnBasedMatchConfig.builder().addInvitedPlayers(myinvitees).setAutoMatchCriteria(autoMatchCriteria).build();
Games.TurnBasedMultiplayer.createMatch(getApiClient(), tbmc).setResultCallback( new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
#Override
public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
processResult(result);
}
});
Where myinvitees is an ArrayList with GoogleIDs of my opponents
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
Edit:
Did some smaller changes but in general I have the same behavior.
Some times the games starting (with up to 4 players) but it seems to prefer the IDs starting with "G"...
So after moving the check if a request for starting a match exist to onSignInSucceeded(), it seems that Google have done something with the GoogleID I'm pulling from the players.
Newer users with ID that startas with G(and a lot of numbers) seems to work but not a mix of old once (that does not start with G) and the new.
I have a system app (signed with platform keys), and this app is injecting events. It is using uinput and tries to use /dev/input/eventN (where N is a number) as well.
If I run the code as root (i.e. with su), the code can obviously open /dev/input/eventN and can inject events in there. If the code is run from the system app, I get permission denied when opening /dev/input/eventN with open("/dev/input/event1", O_RDWR). Uinput works fine, however, even in system app.
The permissions requested by the system app are:
<uses-permission android:name="android.permission.READ_FRAME_BUFFER"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.INJECT_EVENTS"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.BIND_INPUT_METHOD"
tools:ignore="ProtectedPermissions"/>
For what it's worth, this system app also reads screen, and is able to do so. So it is very strange it is not able to open with r/w /dev/input/eventN.
You might wonder what's wrong with uinput if that works. The problem with uinput is that I have problems injecting touch events. Specifically, I can not "click" (tap). I can drag, swipe, inject keyboard events, but clicking (tapping) just does not work. It seems as if it is stuck with long press. It does not register the final event, where ABS_MT_TRACKING_ID is set to 0xffffffff.
The code I'm using for "click" (tap) is:
// pointer down
send_event(EV_ABS, ABS_MT_SLOT, 0);
send_event(EV_ABS, ABS_MT_TRACKING_ID, m_tracking_id++ % 65535);
send_event(EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PEN);
// pointer coordinates
send_event(EV_ABS, ABS_MT_POSITION_X, x);
send_event(EV_ABS, ABS_MT_POSITION_Y, y);
send_event(EV_ABS, ABS_MT_TOUCH_MAJOR, m_tracking_id % 2 ? 0x3c : 0x30);
send_event(EV_ABS, ABS_MT_PRESSURE, m_tracking_id % 2 ? 20 : 25);
send_event(EV_SYN, SYN_REPORT);
// pointer up
send_event(EV_ABS, ABS_MT_TRACKING_ID, -1);
send_event(EV_SYN, SYN_REPORT);
I am using Android's MediaRouter / Presentation API (the support.v7 version).
Everything works fine so far. The only thing that doesn't is:
When I quit my activity (e.g.teardown & remove the callbacks), everything still works fine.
However, when starting this activity (the previous mediarouter-activity was forcefully finished, thus onPause/onDestroy was called FOR SURE => so those callbacks in there are gone too, as also shown in my debug messages) again at some later point in time, the callbacks get created and added and everything. Just, that there is no more onRouteAdded called, only onProviderChanged (With the default provider and thus useless).
It does always work like that (with wifi display [miracast], emulated secondary display, chromecast secondary display..). Are there any resolutions which are not in the examples?
Would you like to look at some code? Which special cases? (Can't post it all..)
I couldn't find anything so far, thanks for your help, in advance.
If you change the Google Cast sample app to support MediaRouter.Callback:
https://github.com/googlecast/CastPresentation-android
Then I'm getting the onRouteAdded called every time.
Using getSelectedRoute()instead of the RouteInfo (which is provided by the callbacks) did the job for me.
MediaRouter.RouteInfo selectedRoute = getHelper().getMediaRouter().getSelectedRoute();
if(provider != null && getCurrentRoute() != null && getCurrentRoute().equals(selectedRoute)){
Log.d(TAG, "only provider changes, dont do anything");
return false;
}
if (selectedRoute != null) {
setCurrentRoute(selectedRoute);
}
return updateContents();
this is definetly weird (as the rest of the code looks exactly as in the provided google android developer samples), but it works.
I know this problem was resolved over 1 year ago, but probably it isn't the perfect solution. Maybe it will be useful for somebody else.
I had similar problem with exactly the same symptoms (no more onRouteAdded called). In my situation it was caused by improperly implemented deactivation of MediaRouter: to deactivate it properly you should not only remove all of callbacks, but select default MediaRoute as well.
if (!mMediaRouter.getDefaultRoute().isSelected()) {
mMediaRouter.getDefaultRoute().select();
}
since android 4.2 google put a appops function into the Settings app ,but after a few weeks ,they close the entrance of this function, and they only close the entrance,the function code is also can be found in frameworks/base/services/java/com/android/server/appopsservice.java 。
But in the source code , I found there are two functions for check whether the operation can get the permission. one is startOperation() and another is noteOperation(), through reading the remark , i know that : startOperation is for a long-term permission check,and must call finishOperation after the operation is done. but the noteOperation is for a short-term.though i knew this but i also can't tell which time i should use startOperation and which time i should chose noteOperation .
Did anyone read this soucecode, and plz give me some suggesstion.
thank you in advance.
well , after a few days late , I found the answer finally.
the difference between startop and noteop is :
startop is prepare for some opereation that will work for a long time ,like gps,like vibrator and so on , you can start monitor a permission use startop and end monitor that use finishop , remember , finishop must be called after you end the monitor.
noteop is just for the short term operation , for example : check whether the app has the permission to send sms or receiver sms.
Obviously ,above is the difference between this two methods.
last but not least : ****