如何为我安装的所有APP假冒我的位置?

时间:2016-12-20 01:02:47

标签: android mocking

大家好我想用假冒伪造我的gps位置,但它似乎只在我自己的应用程序中工作,有没有办法为我的所有应用程序执行此操作,例如Google地图应用程序?

THX ..

我目前的课程似乎如此:

lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        myLocation = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (myLocation != null) {
            x = myLocation.getLatitude() + 0.001; //velocidade
            y = myLocation.getAltitude();
        } else {

        }

        final String providerName = "MyFancyGPSProvider";
        lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//Remember to remove your your provider before using it or after.
//In other case it won't be remove till restarting the phone.
        if (lm.getProvider(providerName) != null) {
            lm.removeTestProvider(providerName);
        }
        lm.addTestProvider(providerName, true, false, false, false, true, true, true,
                Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
        lm.setTestProviderEnabled(providerName, true);
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            return;
        }
        lm.requestLocationUpdates(providerName, 0, 0, this);


        // Click listener for W KEY BUTTON
        bt1.button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                x += 1.001;
                Location loc = new Location(providerName);
                loc.setLatitude(x);
                loc.setLongitude(y);
                loc.setAltitude(0);
                loc.setAccuracy(10f);
                loc.setElapsedRealtimeNanos(System.nanoTime());
                loc.setTime(System.currentTimeMillis());
                lm.setTestProviderLocation(providerName, loc);

            }
        });

每按一次按钮。它为我当前的位置增加了+1, onLocationChanged 会正确触发新位置,但它不会改变官方谷歌地图应用中的任何内容

@Override
    public void onLocationChanged(Location location) {
        if(location != null) {
            Log.w("WalkGPS", "lat = " + location.getLatitude() + " long = "+location.getLongitude());
        }
    }

0 个答案:

没有答案