Skip to content

Commit

Permalink
Add a switch to spoof Android ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipppppppppp committed Feb 23, 2024
1 parent f6b6c18 commit 6fbc90e
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
79 changes: 78 additions & 1 deletion app/src/main/java/io/github/chipppppppppp/lime/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.app.Application;
import android.app.Notification;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
Expand All @@ -14,6 +15,7 @@
import android.graphics.Canvas;
import android.net.Uri;
import android.os.Process;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.customtabs.CustomTabsIntent;
import android.view.Gravity;
Expand All @@ -28,6 +30,7 @@
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

import android.app.AndroidAppHelper;
Expand Down Expand Up @@ -71,18 +74,92 @@ public void handleLoadPackage(@NonNull XC_LoadPackage.LoadPackageParam lparam) t
if (!lparam.packageName.equals(PACKAGE)) return;

final XSharedPreferences xModulePrefs = new XSharedPreferences(MODULE, "options");
final XSharedPreferences xPackagePrefs = new XSharedPreferences(PACKAGE, MODULE + "-options");
XSharedPreferences xPrefs;
if (xModulePrefs.getBoolean("unembed_options", false)) {
xPrefs = xModulePrefs;
} else {
xPrefs = new XSharedPreferences(PACKAGE, MODULE + "-options");
xPrefs = xPackagePrefs;
}
for (LimeOptions.Option option : limeOptions.options) {
option.checked = xPrefs.getBoolean(option.name, option.checked);
}

Class<?> hookTarget;

if (xPackagePrefs.getBoolean("spoof_android_id", false)) {
XposedHelpers.findAndHookMethod(Settings.Secure.class, "getString", ContentResolver.class, String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (param.args[1].toString().equals(Settings.Secure.ANDROID_ID)) {
param.setResult("0000000000000000");
}
}
});
}

hookTarget = lparam.classLoader.loadClass("com.linecorp.registration.ui.RegistrationActivity");
XposedBridge.hookAllMethods(hookTarget, "onCreate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Activity activity = (Activity) param.thisObject;


ViewGroup viewGroup = (ViewGroup) ((ViewGroup) activity.findViewById(2131427495)).getChildAt(1);

Method mAddAddAssertPath = AssetManager.class.getDeclaredMethod("addAssetPath", String.class);
mAddAddAssertPath.setAccessible(true);
mAddAddAssertPath.invoke(activity.getResources().getAssets(), MODULE_PATH);

SharedPreferences prefs = activity.getSharedPreferences(MODULE + "-options", Context.MODE_PRIVATE);

FrameLayout frameLayout = new FrameLayout(activity);
frameLayout.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));

Switch switchView = new Switch(activity);
switchView.setText(activity.getString(R.string.switch_spoof_android_id));
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.CENTER;
switchView.setLayoutParams(layoutParams);

AlertDialog.Builder builder = new AlertDialog.Builder(activity)
.setTitle(activity.getString(R.string.options_title))
.setCancelable(false);

TextView textView = new TextView(activity);
textView.setText(R.string.spoof_android_id_risk);
textView.setPadding(Utils.dpToPx(20, activity), Utils.dpToPx(20, activity), Utils.dpToPx(20, activity), Utils.dpToPx(20, activity));
builder.setView(textView);

builder.setPositiveButton(activity.getString(R.string.positive), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(activity.getApplicationContext(), activity.getString(R.string.restarting), Toast.LENGTH_SHORT).show();
activity.finish();
}
});

AlertDialog dialog = builder.create();

switchView.setChecked(prefs.getBoolean("spoof_android_id", false));
switchView.setOnCheckedChangeListener((buttonView, isChecked) -> {
prefs.edit().putBoolean("spoof_android_id", isChecked).apply();
if (isChecked) dialog.show();
else {
Toast.makeText(activity.getApplicationContext(), activity.getString(R.string.restarting), Toast.LENGTH_SHORT).show();
activity.finish();
}
});

frameLayout.addView(switchView);
viewGroup.addView(frameLayout);
}
});

if (!xModulePrefs.getBoolean("unembed_options", false)) {
hookTarget = lparam.classLoader.loadClass("com.linecorp.line.settings.main.LineUserMainSettingsFragment");
XposedBridge.hookAllMethods(hookTarget, "onViewCreated", new XC_MethodHook() {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<string name="module_not_enabled_text">モジュールが有効化されていません!</string>
<string name="options_title">設定</string>
<string name="restarting">アプリを再起動しています...</string>
<string name="switch_spoof_android_id">複数デバイスログイン (Android ID を偽装)</string>
<string name="spoof_android_id_risk">Android ID の偽装は自己責任です</string>
<string name="switch_unembed_options">設定を LINE に埋め込まない (設定は同期されません)</string>
<string name="switch_delete_voom">VOOM アイコンを削除</string>
<string name="switch_delete_wallet">ウォレットアイコンを削除</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<string name="module_not_enabled_text">Module not enabled!</string>
<string name="options_title">Options</string>
<string name="restarting">Restarting now...</string>
<string name="switch_spoof_android_id">Multiple device login (spoof Android ID)</string>
<string name="spoof_android_id_risk">Spoofing Android ID is at your own risk</string>
<string name="switch_unembed_options">Do not embed options in LINE (options will not be synchronized)</string>
<string name="switch_delete_voom">Delete the VOOM icon</string>
<string name="switch_delete_wallet">Delete the wallet icon</string>
Expand Down

0 comments on commit 6fbc90e

Please sign in to comment.