Android Open Source - lost-phone-tracker-app Gps Toggler






From Project

Back to project page lost-phone-tracker-app.

License

The source code is released under:

MIT License

If you think the Android project lost-phone-tracker-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package at.fhj.ase13.mobcomp2.phonetracker;
//from ww w .  j a  v a2 s .  c  o  m
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

/**
 * GPS enabling exploit according to http://stackoverflow.com/questions/4721449/how-can-i-enable-or-disable-the-gps-programmatically-on-android
 */
public class GpsToggler {

    public static void enableGps(Context context) {
        String provider = Settings.Secure.getString(context.getContentResolver(),
                Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

        if (!provider.contains("gps")) { // if gps is disabled
            final Intent poke = new Intent();

            poke.setClassName("com.android.settings",
                    "com.android.settings.widget.SettingsAppWidgetProvider");
            poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
            poke.setData(Uri.parse("3"));
            context. sendBroadcast(poke);
        }
    }

    public static void disableGps(Context context) {
        String provider = Settings.Secure.getString(context.getContentResolver(),
                Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

        if (provider.contains("gps")) { // if gps is enabled
            final Intent poke = new Intent();

            poke.setClassName("com.android.settings",
                    "com.android.settings.widget.SettingsAppWidgetProvider");
            poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
            poke.setData(Uri.parse("3"));
            context.sendBroadcast(poke);
        }
    }
}




Java Source Code List

at.fhj.ase13.mobcomp2.phonetracker.BootReceiver.java
at.fhj.ase13.mobcomp2.phonetracker.GpsToggler.java
at.fhj.ase13.mobcomp2.phonetracker.LogAlarmReceiver.java
at.fhj.ase13.mobcomp2.phonetracker.MainActivity.java
at.fhj.ase13.mobcomp2.phonetracker.PreferenceManager.java
at.fhj.ase13.mobcomp2.phonetracker.SmsBroadcastReceiver.java
at.fhj.ase13.mobcomp2.phonetracker.SmsLocationReporter.java