How to disable location or telephony on android box : use the system properties

If you have the sources of your box and you want to disable permanently some services you can use system properties.

first look at there, you’ll see how services are started :

frameworks/base/services/java/com/android/server/SystemServer.java

then you’ll see that most of the services have a boolean related to a system property, for instance location :

 boolean disableLocation = SystemProperties.getBoolean("config.disable_location", false);

and deeper in the file, you’ll see that this boolean is used to disable the service :

 if (!disableLocation) {
               try {
                   Slog.i(TAG, "Location Manager");
                   location = new LocationManagerService(context);
                   ServiceManager.addService(Context.LOCATION_SERVICE, location);

so basically you just have to find your system property file in your device tree, and force the value to true. Use a « find » to get it.

On rockchip device it is easy : the file name is system.prop. This file is used to generate the build.prop in the out folder.

Another way to force system properties is to use the Android.mk and force value with this specific token:

 
 PRODUCT_PROPERTY_OVERRIDES += \
    config.disable_location = true

Enjoy!

IOS – background task and precise geolocation

When trying to work in background with IOS, things get tricky particularly when it requires a good precision update (when the significant update stuff is not enough).

first thing to do : start a background task :

- (void)applicationDidEnterBackground:(UIApplication *)application

{

    bgTask = [application beginBackgroundTaskWithName:@"MyTask" expirationHandler:^{

        // Clean up any unfinished task business by marking where you

        // stopped or ending the task outright.

        [application endBackgroundTask:bgTask];

        bgTask = UIBackgroundTaskInvalid;

    }];

 

    // Start the long-running task and return immediately.

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

 

        // Do the work associated with the task, preferably in chunks.

 

        [application endBackgroundTask:bgTask];

        bgTask = UIBackgroundTaskInvalid;

    });

}

Extracted from apple dev center: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

while the task is running the didUpdateLocation event is correctly handle by the application.

you have only 180 seconds to finish the task before being killed by the OS. use the backgroundTimeRemaining to see how much time is left. Make sure you have finite task and you have the correct background mode setup to avoid being killed before.