Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Add defaced GSF ID, source refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vipere committed Jul 5, 2013
1 parent efba183 commit 967c4ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 215 deletions.
4 changes: 4 additions & 0 deletions src/biz/bokhorst/xprivacy/PrivacyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ public static Object getDefacedProp(String name) {
return octets; // Hidden network
}

// Google services framework ID
if (name.equals("GSF_ID"))
return 0xDEFACE;

// XSystemProperties: "net.hostname"
return cDeface;
}
Expand Down
232 changes: 17 additions & 215 deletions src/biz/bokhorst/xprivacy/XContentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@

import android.annotation.SuppressLint;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
import android.database.CharArrayBuffer;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;

import de.robv.android.xposed.XC_MethodHook.MethodHookParam;

Expand Down Expand Up @@ -60,18 +56,24 @@ protected void after(MethodHookParam param) throws Throwable {
Uri uri = (Uri) param.args[0];
if (mUriStart == null || uri.toString().startsWith(mUriStart)) {

// Google services provider: block only android_id
if (uri.toString().toLowerCase().startsWith("content://com.google.android.gsf.gservices")) {
List<String> selectionArgs = Arrays.asList((String[]) param.args[3]);
if (!Util.containsIgnoreCase(selectionArgs, "android_id"))
return;
}

// Return empty cursor
Cursor cursor = (Cursor) param.getResult();
if (cursor != null)
if (isRestricted(param, mProviderName))
param.setResult(new XCursor(cursor));
if (cursor != null) {
if (isRestricted(param, mProviderName)) {

// Google services provider: block only android_id
if (uri.toString().toLowerCase().startsWith("content://com.google.android.gsf.gservices")) {
List<String> selectionArgs = Arrays.asList((String[]) param.args[3]);
if (Util.containsIgnoreCase(selectionArgs, "android_id")) {
MatrixCursor c = new MatrixCursor(cursor.getColumnNames());
c.addRow(new Object[] {"android_id", PrivacyManager.getDefacedProp("GSF_ID")});
param.setResult(c);
}
}
else
param.setResult(new MatrixCursor(cursor.getColumnNames()));
}
}
}
}

Expand All @@ -83,204 +85,4 @@ protected boolean isRestricted(MethodHookParam param) throws Throwable {
return getRestricted(context, uid, true);
}

private class XCursor implements Cursor {

private Cursor mCursor;

public XCursor(Cursor cursor) {
mCursor = cursor;
}

@Override
public void close() {
mCursor.close();
}

@Override
public void copyStringToBuffer(int arg0, CharArrayBuffer arg1) {
mCursor.copyStringToBuffer(arg0, arg1);
}

@Override
@Deprecated
public void deactivate() {
mCursor.deactivate();
}

@Override
public byte[] getBlob(int arg0) {
return mCursor.getBlob(arg0);
}

@Override
public int getColumnCount() {
return mCursor.getColumnCount();
}

@Override
public int getColumnIndex(String arg0) {
return mCursor.getColumnIndex(arg0);
}

@Override
public int getColumnIndexOrThrow(String arg0) throws IllegalArgumentException {
return mCursor.getColumnIndexOrThrow(arg0);
}

@Override
public String getColumnName(int arg0) {
return mCursor.getColumnName(arg0);
}

@Override
public String[] getColumnNames() {
return mCursor.getColumnNames();
}

@Override
public int getCount() {
return 0;
}

@Override
public double getDouble(int arg0) {
return mCursor.getDouble(arg0);
}

@Override
public Bundle getExtras() {
return mCursor.getExtras();
}

@Override
public float getFloat(int arg0) {
return mCursor.getFloat(arg0);
}

@Override
public int getInt(int arg0) {
return mCursor.getInt(0);
}

@Override
public long getLong(int arg0) {
return mCursor.getLong(arg0);
}

@Override
public int getPosition() {
return mCursor.getPosition();
}

@Override
public short getShort(int arg0) {
return mCursor.getShort(arg0);
}

@Override
public String getString(int arg0) {
return mCursor.getString(arg0);
}

@Override
public int getType(int arg0) {
return mCursor.getType(arg0);
}

@Override
public boolean getWantsAllOnMoveCalls() {
return mCursor.getWantsAllOnMoveCalls();
}

@Override
public boolean isAfterLast() {
return mCursor.isAfterLast();
}

@Override
public boolean isBeforeFirst() {
return mCursor.isBeforeFirst();
}

@Override
public boolean isClosed() {
return mCursor.isClosed();
}

@Override
public boolean isFirst() {
return mCursor.isFirst();
}

@Override
public boolean isLast() {
return mCursor.isLast();
}

@Override
public boolean isNull(int arg0) {
return mCursor.isNull(arg0);
}

@Override
public boolean move(int arg0) {
return false;
}

@Override
public boolean moveToFirst() {
return false;
}

@Override
public boolean moveToLast() {
return false;
}

@Override
public boolean moveToNext() {
return false;
}

@Override
public boolean moveToPosition(int arg0) {
return false;
}

@Override
public boolean moveToPrevious() {
return false;
}

@Override
public void registerContentObserver(ContentObserver arg0) {
}

@Override
public void registerDataSetObserver(DataSetObserver arg0) {
}

@Override
@Deprecated
public boolean requery() {
return mCursor.requery();
}

@Override
public Bundle respond(Bundle arg0) {
return Bundle.EMPTY;
}

@Override
public void setNotificationUri(ContentResolver arg0, Uri arg1) {
}

@Override
public void unregisterContentObserver(ContentObserver arg0) {
}

@Override
public void unregisterDataSetObserver(DataSetObserver arg0) {
}
}
}

0 comments on commit 967c4ea

Please sign in to comment.