Skip to content

Commit

Permalink
添加重连fcm按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
kooritea committed Sep 8, 2022
1 parent 52841fb commit 8399bef
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import com.kooritea.fcmfix.util.XposedUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand All @@ -27,6 +34,7 @@ public class ReconnectManagerFix extends XposedModule {

public ReconnectManagerFix(XC_LoadPackage.LoadPackageParam loadPackageParam) {
super(loadPackageParam);
this.addReConnectButton();
this.startHookGcmServiceStart();
}

Expand Down Expand Up @@ -254,4 +262,25 @@ protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
}
editor.apply();
}

private void addReConnectButton(){
XposedHelpers.findAndHookMethod("com.google.android.gms.gcm.GcmChimeraDiagnostics", loadPackageParam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
ViewGroup viewGroup = ((Window)XposedHelpers.callMethod(param.thisObject, "getWindow")).getDecorView().findViewById(android.R.id.content);
LinearLayout linearLayout = (LinearLayout)viewGroup.getChildAt(0);
LinearLayout linearLayout2 = (LinearLayout)linearLayout.getChildAt(0);
Button button = new Button((ContextWrapper)param.thisObject);
button.setText("RECONNECT");
linearLayout2.addView(button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.sendBroadcast(new Intent("com.google.android.intent.action.GCM_RECONNECT"));
printLog("Send broadcast GCM_RECONNECT");
}
});
}
});
}
}

0 comments on commit 8399bef

Please sign in to comment.