Repo Created
This commit is contained in:
parent
eb305e2886
commit
a8c22c65db
4784 changed files with 329907 additions and 2 deletions
38
fake-signature/build.gradle
Normal file
38
fake-signature/build.gradle
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
namespace 'org.microg.signature.fake'
|
||||
compileSdk androidCompileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk androidMinSdk
|
||||
targetSdk androidTargetSdk
|
||||
}
|
||||
|
||||
flavorDimensions = ['target']
|
||||
productFlavors {
|
||||
"default" {
|
||||
dimension 'target'
|
||||
}
|
||||
"huawei" {
|
||||
dimension 'target'
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
aidl = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
43
fake-signature/src/huawei/AndroidManifest.xml
Normal file
43
fake-signature/src/huawei/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<application>
|
||||
<receiver
|
||||
android:name="com.huawei.signature.diff.InitReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.PACKAGE_RESTARTED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<provider
|
||||
android:name="com.huawei.signature.diff.InitProvider"
|
||||
android:authorities="${applicationId}.signature.diff.init"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:initOrder="1000" />
|
||||
|
||||
<service
|
||||
android:name="com.huawei.signature.diff.SignatureService"
|
||||
android:process=":signature"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.huawei.signature.diff" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.huawei.signature.diff;
|
||||
|
||||
/**
|
||||
* Interface for Huawei Differentiated Signature Capability
|
||||
* See https://forums.developer.huawei.com/forumPortal/en/topic/0202128603315033024
|
||||
*/
|
||||
interface ISignatureService {
|
||||
String[] querySignature(String packageName, boolean suggested);
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.huawei.signature.diff;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
import org.microg.signature.fake.R;
|
||||
|
||||
public class AppListDatabaseOpenHelper extends SQLiteOpenHelper {
|
||||
private static final String TAG = AppListDatabaseOpenHelper.class.getSimpleName();
|
||||
private static final String DATABASE_NAME = "app_list.db";
|
||||
public static final String TABLE_APPLIST = "applist";
|
||||
public static final String COLUMN_NAME = "name";
|
||||
public static final String COLUMN_FAKE = "fake";
|
||||
private static final int DATABASE_VERSION = 3;
|
||||
private static final String DROP_APP_LIST_TABLE = "DROP TABLE IF EXISTS " + TABLE_APPLIST;
|
||||
private static final String CREATE_APP_LIST_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_APPLIST + "(" +
|
||||
COLUMN_NAME + " VARCHAR(255) PRIMARY KEY, " +
|
||||
COLUMN_FAKE + " INTEGER CHECK(" + COLUMN_FAKE + " >= 0 and " + COLUMN_FAKE + " <= 1)" +
|
||||
")";
|
||||
private final Context context;
|
||||
|
||||
public AppListDatabaseOpenHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
Log.d(TAG, "onCreate");
|
||||
db.execSQL(DROP_APP_LIST_TABLE);
|
||||
db.execSQL(CREATE_APP_LIST_TABLE);
|
||||
initData(db);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(SQLiteDatabase db) {
|
||||
super.onOpen(db);
|
||||
if (!db.isReadOnly()) {
|
||||
initData(db);
|
||||
}
|
||||
}
|
||||
|
||||
private void initData(SQLiteDatabase db) {
|
||||
String[] wantFakeApps = context.getResources().getStringArray(R.array.signature_want_fake);
|
||||
String[] neverFakeApps = context.getResources().getStringArray(R.array.signature_never_fake);
|
||||
if (wantFakeApps.length == 0 && neverFakeApps.length == 0) {
|
||||
return;
|
||||
}
|
||||
for (String app : wantFakeApps) {
|
||||
db.insertWithOnConflict(TABLE_APPLIST, null, generateValues(app, true), SQLiteDatabase.CONFLICT_REPLACE);
|
||||
}
|
||||
for (String app : neverFakeApps) {
|
||||
db.insertWithOnConflict(TABLE_APPLIST, null, generateValues(app, false), SQLiteDatabase.CONFLICT_REPLACE);
|
||||
}
|
||||
}
|
||||
|
||||
private ContentValues generateValues(String packageName, boolean fake) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(COLUMN_NAME, packageName);
|
||||
contentValues.put(COLUMN_FAKE, fake ? 1 : 0);
|
||||
return contentValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
onCreate(db);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.huawei.signature.diff;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import java.util.List;
|
||||
|
||||
public class InitProvider extends ContentProvider {
|
||||
private static final String TAG = "InitProvider";
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
Log.d(TAG, "onCreate");
|
||||
if (!isServiceRunning(getContext(), getContext().getPackageName(), SignatureService.class.getName())) {
|
||||
Intent intent = new Intent(getContext(), SignatureService.class);
|
||||
try {
|
||||
getContext().startService(intent);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isServiceRunning(Context context, String packageName, String serviceName) {
|
||||
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningServiceInfo> serviceInfoList = manager.getRunningServices(Integer.MAX_VALUE);
|
||||
if (serviceInfoList == null) {
|
||||
return false;
|
||||
}
|
||||
for (ActivityManager.RunningServiceInfo info : serviceInfoList) {
|
||||
if (info.service.getPackageName().equals(packageName) && info.service.getClassName().equals(serviceName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.huawei.signature.diff;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* This is to make sure the process is initialized at boot.
|
||||
*/
|
||||
public class InitReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "InitReceiver";
|
||||
|
||||
@SuppressLint("UnsafeProtectedBroadcastReceiver")
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "onReceive");
|
||||
try {
|
||||
context.startService(new Intent(context, SignatureService.class));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.huawei.signature.diff;
|
||||
|
||||
import static com.huawei.signature.diff.AppListDatabaseOpenHelper.COLUMN_NAME;
|
||||
import static com.huawei.signature.diff.AppListDatabaseOpenHelper.TABLE_APPLIST;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import org.microg.signature.fake.R;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Date;
|
||||
|
||||
public class SignatureService extends Service {
|
||||
private static final String TAG = "SignatureService";
|
||||
private SQLiteDatabase database;
|
||||
private AppListDatabaseOpenHelper openHelper;
|
||||
private long start;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
this.openHelper = new AppListDatabaseOpenHelper(this);
|
||||
this.database = openHelper.getWritableDatabase();
|
||||
this.start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.i(TAG, "onStartCommand");
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return binder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
this.openHelper.close();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||
writer.println("Started: " + new Date(start));
|
||||
}
|
||||
|
||||
private final ISignatureService.Stub binder = new ISignatureService.Stub() {
|
||||
|
||||
@Override
|
||||
public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
|
||||
if (Binder.getCallingUid() > 10000) {
|
||||
Log.w(TAG, "Illegal access from app");
|
||||
reply.writeException(new UnsupportedOperationException("Illegal"));
|
||||
return true;
|
||||
}
|
||||
return super.onTransact(code, data, reply, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] querySignature(String packageName, boolean suggested) throws RemoteException {
|
||||
try (Cursor cursor = database.query(TABLE_APPLIST, null, COLUMN_NAME + "=?",
|
||||
new String[]{packageName}, null, null, null)) {
|
||||
switch (cursor.getCount()) {
|
||||
case 0:
|
||||
return getResult(suggested);
|
||||
case 1:
|
||||
if (cursor.moveToFirst()) {
|
||||
int shouldFake = cursor.getInt(1);
|
||||
return getResult(shouldFake == 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("result size: " + cursor.getCount());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
return getResult(false);
|
||||
}
|
||||
|
||||
private String[] getResult(boolean useFakeSignature) {
|
||||
if (useFakeSignature) {
|
||||
return new String[]{getString(R.string.fake_signature),};
|
||||
} else {
|
||||
return new String[]{getString(R.string.real_signature),};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
1159
fake-signature/src/main/AndroidManifest.xml
Normal file
1159
fake-signature/src/main/AndroidManifest.xml
Normal file
File diff suppressed because it is too large
Load diff
39
fake-signature/src/main/res/values/arrays.xml
Normal file
39
fake-signature/src/main/res/values/arrays.xml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ SPDX-FileCopyrightText: 2023 microG Project Team
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string-array name="signature_want_fake">
|
||||
<item>com.google.android.gms</item>
|
||||
<item>com.android.vending</item>
|
||||
<item>com.spotify.music</item>
|
||||
<item>com.getir</item>
|
||||
<item>com.pozitron.iscep</item>
|
||||
<item>com.widgetable.theme.android</item>
|
||||
<item>pro.huobi</item>
|
||||
<item>com.tarparos.phigaea</item>
|
||||
<item>com.artem.scotepio</item>
|
||||
<item>com.sabah.deprembs</item>
|
||||
<item>com.boynergrup.hopi</item>
|
||||
<item>com.belbim.istanbulkart</item>
|
||||
<item>com.a101.plus</item>
|
||||
<item>com.widgetable.theme.android</item>
|
||||
<item>net.wargaming.wot.blitz</item>
|
||||
<item>com.litatom.app</item>
|
||||
<item>com.ataexpress.tiklagelsin</item>
|
||||
<item>tr.com.petrolofisi</item>
|
||||
<item>com.mobisoft.beymen</item>
|
||||
<item>com.unilever.algida</item>
|
||||
<item>com.mobisoft.morhipo</item>
|
||||
<item>com.zzkko</item>
|
||||
<item>com.didilabs.kaavefali</item>
|
||||
<item>com.airbnb.android</item>
|
||||
<item>com.mobillium.papara</item>
|
||||
<item>co.com.fincaraiz.app</item>
|
||||
<item>com.frisby.frisby</item>
|
||||
</string-array>
|
||||
<string-array name="signature_never_fake">
|
||||
<item>com.truecaller</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
14
fake-signature/src/main/res/values/signature.xml
Normal file
14
fake-signature/src/main/res/values/signature.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ SPDX-FileCopyrightText: 2014 microG Project Team
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="fake_signature">
|
||||
308204433082032ba003020102020900c2e08746644a308d300d06092a864886f70d01010405003074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f6964301e170d3038303832313233313333345a170d3336303130373233313333345a3074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f696430820120300d06092a864886f70d01010105000382010d00308201080282010100ab562e00d83ba208ae0a966f124e29da11f2ab56d08f58e2cca91303e9b754d372f640a71b1dcb130967624e4656a7776a92193db2e5bfb724a91e77188b0e6a47a43b33d9609b77183145ccdf7b2e586674c9e1565b1f4c6a5955bff251a63dabf9c55c27222252e875e4f8154a645f897168c0b1bfc612eabf785769bb34aa7984dc7e2ea2764cae8307d8c17154d7ee5f64a51a44a602c249054157dc02cd5f5c0e55fbef8519fbe327f0b1511692c5a06f19d18385f5c4dbc2d6b93f68cc2979c70e18ab93866b3bd5db8999552a0e3b4c99df58fb918bedc182ba35e003c1b4b10dd244a8ee24fffd333872ab5221985edab0fc0d0b145b6aa192858e79020103a381d93081d6301d0603551d0e04160414c77d8cc2211756259a7fd382df6be398e4d786a53081a60603551d2304819e30819b8014c77d8cc2211756259a7fd382df6be398e4d786a5a178a4763074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f6964820900c2e08746644a308d300c0603551d13040530030101ff300d06092a864886f70d010104050003820101006dd252ceef85302c360aaace939bcff2cca904bb5d7a1661f8ae46b2994204d0ff4a68c7ed1a531ec4595a623ce60763b167297a7ae35712c407f208f0cb109429124d7b106219c084ca3eb3f9ad5fb871ef92269a8be28bf16d44c8d9a08e6cb2f005bb3fe2cb96447e868e731076ad45b33f6009ea19c161e62641aa99271dfd5228c5c587875ddb7f452758d661f6cc0cccb7352e424cc4365c523532f7325137593c4ae341f4db41edda0d0b1071a7c440f0fe9ea01cb627ca674369d084bd2fd911ff06cdbf2cfa10dc0f893ae35762919048c7efc64c7144178342f70581c9de573af55b390dd7fdb9418631895d5f759f30112687ff621410c069308a
|
||||
</string>
|
||||
<string name="real_signature">
|
||||
308202ed308201d5a003020102020426ffa009300d06092a864886f70d01010b05003027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a656374301e170d3132313030363132303533325a170d3337303933303132303533325a3027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a65637430820122300d06092a864886f70d01010105000382010f003082010a02820101009a8d2a5336b0eaaad89ce447828c7753b157459b79e3215dc962ca48f58c2cd7650df67d2dd7bda0880c682791f32b35c504e43e77b43c3e4e541f86e35a8293a54fb46e6b16af54d3a4eda458f1a7c8bc1b7479861ca7043337180e40079d9cdccb7e051ada9b6c88c9ec635541e2ebf0842521c3024c826f6fd6db6fd117c74e859d5af4db04448965ab5469b71ce719939a06ef30580f50febf96c474a7d265bb63f86a822ff7b643de6b76e966a18553c2858416cf3309dd24278374bdd82b4404ef6f7f122cec93859351fc6e5ea947e3ceb9d67374fe970e593e5cd05c905e1d24f5a5484f4aadef766e498adf64f7cf04bddd602ae8137b6eea40722d0203010001a321301f301d0603551d0e04160414110b7aa9ebc840b20399f69a431f4dba6ac42a64300d06092a864886f70d01010b0500038201010007c32ad893349cf86952fb5a49cfdc9b13f5e3c800aece77b2e7e0e9c83e34052f140f357ec7e6f4b432dc1ed542218a14835acd2df2deea7efd3fd5e8f1c34e1fb39ec6a427c6e6f4178b609b369040ac1f8844b789f3694dc640de06e44b247afed11637173f36f5886170fafd74954049858c6096308fc93c1bc4dd5685fa7a1f982a422f2a3b36baa8c9500474cf2af91c39cbec1bc898d10194d368aa5e91f1137ec115087c31962d8f76cd120d28c249cf76f4c70f5baa08c70a7234ce4123be080cee789477401965cfe537b924ef36747e8caca62dfefdd1a6288dcb1c4fd2aaa6131a7ad254e9742022cfd597d2ca5c660ce9e41ff537e5a4041e37
|
||||
</string>
|
||||
</resources>
|
||||
Loading…
Add table
Add a link
Reference in a new issue