Skip to content

Commit

Permalink
pff: add PFFInfoDatabase to make spoofed informations persistant and …
Browse files Browse the repository at this point in the history
…setable

- expose functions in Package Manager to get and set the spoofed location

Change-Id: Iaf93189db1413fdf13e3a38d9e408ba524cd2391

Conflicts:
	api/current.txt
	services/java/com/android/server/LocationManagerService.java
  • Loading branch information
guhl authored and guhl committed Jan 8, 2014
1 parent 3a0988d commit 4aa8d0c
Show file tree
Hide file tree
Showing 11 changed files with 467 additions and 8 deletions.
51 changes: 51 additions & 0 deletions api/current.txt
Expand Up @@ -7142,6 +7142,51 @@ package android.content.pm {
field public static final android.os.Parcelable.Creator CREATOR;
}

public class LocationBean implements android.os.Parcelable {
ctor public LocationBean();
ctor public LocationBean(android.os.Parcel);
ctor public LocationBean(java.lang.String, double, double, double);
method public int describeContents();
method public java.lang.Double getAltitude();
method public java.lang.String getDescription();
method public long getId();
method public java.lang.Double getLatitude();
method public java.lang.Double getLongitude();
method public android.content.ContentValues getValues();
method public void readFromParcel(android.os.Parcel);
method public void setAltitude(java.lang.Double);
method public void setDescription(java.lang.String);
method public void setId(long);
method public void setLatitude(java.lang.Double);
method public void setLongitude(java.lang.Double);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;
}

public class PFFInfoDatabase extends android.database.sqlite.SQLiteOpenHelper {
ctor public PFFInfoDatabase(android.content.Context);
method public android.content.pm.LocationBean addDefaultLocation();
method public android.content.pm.LocationBean addLocation(android.content.pm.LocationBean);
method public void deleteLocation(android.content.pm.LocationBean);
method public android.content.pm.LocationBean findLocationByDescription(java.lang.String);
method public android.content.pm.LocationBean findLocationById(long);
method public void onCreate(android.database.sqlite.SQLiteDatabase);
method public void onUpgrade(android.database.sqlite.SQLiteDatabase, int, int);
method public void updateLocation(android.content.pm.LocationBean);
field public static final java.lang.String DB_NAME = "pff_infos";
field public static final int DB_VERSION = 1; // 0x1
field public static final java.lang.String ENCODING_ASCII = "ASCII";
field public static final java.lang.String ENCODING_ISO88591 = "ISO8859_1";
field public static final java.lang.String ENCODING_UTF8 = "UTF-8";
field public static final java.lang.String FIELD_LOCATION_ALTITUDE = "altitude";
field public static final java.lang.String FIELD_LOCATION_DESCRIPTION = "description";
field public static final java.lang.String FIELD_LOCATION_LATITUDE = "latitude";
field public static final java.lang.String FIELD_LOCATION_LONGITUDE = "longitude";
field public static final java.lang.String TABLE_LOCATIONS = "locations";
field public static final java.lang.String TAG;
field public static final java.lang.Object[] dbLock;
}

public class PackageInfo implements android.os.Parcelable {
ctor public PackageInfo();
method public int describeContents();
Expand Down Expand Up @@ -7255,6 +7300,9 @@ package android.content.pm {
method public abstract boolean hasSystemFeature(java.lang.String);
method public abstract boolean isRevokeablePermission(java.lang.String);
method public abstract boolean isSafeMode();
method public abstract boolean isSpoofablePermission(java.lang.String);
method public abstract android.content.pm.LocationBean pffGetLocation();
method public abstract void pffSetLocation(android.content.pm.LocationBean);
method public abstract java.util.List<android.content.pm.ResolveInfo> queryBroadcastReceivers(android.content.Intent, int);
method public abstract java.util.List<android.content.pm.ProviderInfo> queryContentProviders(java.lang.String, int, int);
method public abstract java.util.List<android.content.pm.InstrumentationInfo> queryInstrumentation(java.lang.String, int);
Expand Down Expand Up @@ -24110,6 +24158,9 @@ package android.test.mock {
method public boolean hasSystemFeature(java.lang.String);
method public boolean isRevokeablePermission(java.lang.String);
method public boolean isSafeMode();
method public boolean isSpoofablePermission(java.lang.String);
method public android.content.pm.LocationBean pffGetLocation();
method public void pffSetLocation(android.content.pm.LocationBean);
method public java.util.List<android.content.pm.ResolveInfo> queryBroadcastReceivers(android.content.Intent, int);
method public java.util.List<android.content.pm.ProviderInfo> queryContentProviders(java.lang.String, int, int);
method public java.util.List<android.content.pm.InstrumentationInfo> queryInstrumentation(java.lang.String, int);
Expand Down
19 changes: 19 additions & 0 deletions core/java/android/app/ApplicationPackageManager.java
Expand Up @@ -21,6 +21,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pff.LocationBean;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
Expand Down Expand Up @@ -1443,6 +1444,24 @@ public void setRevokedPermissions(String packageName, String[] perms) {
}
}

@Override
public LocationBean pffGetLocation() {
try {
return mPM.pffGetLocation();
} catch (RemoteException e) {
// Should never happen!
}
return null;
}

@Override
public void pffSetLocation(LocationBean loc) {
try {
mPM.pffSetLocation(loc);
} catch (RemoteException e) {
// Should never happen!
}
}

private final ContextImpl mContext;
private final IPackageManager mPM;
Expand Down
3 changes: 3 additions & 0 deletions core/java/android/content/pff/LocationBean.aidl
@@ -0,0 +1,3 @@
package android.content.pff;

parcelable LocationBean;
120 changes: 120 additions & 0 deletions core/java/android/content/pff/LocationBean.java
@@ -0,0 +1,120 @@
package android.content.pff;

import android.content.ContentValues;
import android.os.Parcel;
import android.os.Parcelable;

public class LocationBean implements Parcelable {
private long id = -1;
private String description;
private double latitude;
private double longitude;
private double altitude;

public static final Parcelable.Creator<LocationBean> CREATOR = new Parcelable.Creator<LocationBean>() {

public LocationBean createFromParcel(Parcel in) {
return new LocationBean(in);
}

public LocationBean[] newArray(int size) {
return null;
}

};


public LocationBean() {
}

public LocationBean(Parcel in) {
readFromParcel(in);
}

public LocationBean(String Description, double Longitude, double Latitude, double Altitude){
this.description = Description;
this.longitude = Longitude;
this.latitude = Latitude;
this.altitude = Altitude;
}

public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}

public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}

public Double getLatitude() {
return this.latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}

public Double getLongitude() {
return this.longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}

public Double getAltitude() {
return this.altitude;
}
public void setAltitude(Double altitude) {
this.altitude = altitude;
}

public ContentValues getValues() {
ContentValues values = new ContentValues();

values.put(PFFInfoDatabase.FIELD_LOCATION_DESCRIPTION, description);
values.put(PFFInfoDatabase.FIELD_LOCATION_LONGITUDE, longitude);
values.put(PFFInfoDatabase.FIELD_LOCATION_LATITUDE, latitude);
values.put(PFFInfoDatabase.FIELD_LOCATION_ALTITUDE, altitude);

return values;
}

public boolean equals(Object o) {
if (!(o instanceof LocationBean))
return false;

LocationBean loaction = (LocationBean)o;

if (loaction.getDescription().equals(description)
&& loaction.getLatitude() == latitude
&& loaction.getLongitude() == longitude)
return true;

return false;
}

public int describeContents() {
return 0;
}

public void writeToParcel(Parcel out, int flags) {
out.writeLong(id);
out.writeString(description);
out.writeDouble(latitude);
out.writeDouble(longitude);
out.writeDouble(altitude);
}
public void readFromParcel(Parcel in) {
id = in.readLong();
description = in.readString();
latitude = in.readDouble();
longitude = in.readDouble();
altitude = in.readDouble();
}
}

0 comments on commit 4aa8d0c

Please sign in to comment.