Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zenfone #356

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/com/ceco/gm2/gravitybox/FixCallerIdMms.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@

public class FixCallerIdMms {
public static final String PACKAGE_NAME = "com.android.mms";
public static final String TAG = "GB:FixCallerIdMms";
public static final String CLASS_CONTACTS_CACHE = "com.android.mms.data.Contact$ContactsCache";
public static final String ALT_PACKAGE_NAME = "com.lenovo.ideafriend";
private static final String TAG = "GB:FixCallerIdMms";
private static String CLASS_CONTACTS_CACHE = "com.android.mms.data.Contact$ContactsCache";
private static final int STATIC_KEY_BUFFER_MAXIMUM_LENGTH = 5;
private static final boolean DEBUG = false;

public static void init(final XSharedPreferences prefs, ClassLoader classLoader) {
XposedBridge.log(TAG + ": init");
private static void log(String message) {
XposedBridge.log(TAG + ": " + message);
}

public static void init(final XSharedPreferences prefs, ClassLoader classLoader, String appUri) {
if (DEBUG) log("init (" + appUri + ")");

if (appUri.equals(ALT_PACKAGE_NAME)) {
CLASS_CONTACTS_CACHE = "com.lenovo.ideafriend.mms.android.data.Contact$ContactsCache";
}

try {
final Class<?> contactsCacheClass = XposedHelpers.findClass(CLASS_CONTACTS_CACHE, classLoader);
Expand Down Expand Up @@ -62,9 +71,7 @@ protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
if (resultCount > 0) {
retVal = keyBuffer.toString();
}
if (DEBUG) {
XposedBridge.log(TAG + ": key(" + phoneNumber + "); retVal='" + retVal + "'");
}
if (DEBUG) log("key(" + phoneNumber + "); retVal='" + retVal + "'");
return retVal;
}
});
Expand All @@ -76,10 +83,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
String key = (String) param.getResult();
if (key.length() > STATIC_KEY_BUFFER_MAXIMUM_LENGTH)
key = key.substring(0, key.length() - 1);
if (DEBUG) {
XposedBridge.log(TAG + ": getKey(): original retVal='" + param.getResult() + "'; " +
"new retVal='" + key + "'");
}
if (DEBUG) log("getKey(): original retVal='" + param.getResult() + "'; " +
"new retVal='" + key + "'");
param.setResult(key);
}
});
Expand Down
22 changes: 16 additions & 6 deletions src/com/ceco/gm2/gravitybox/FixMmsWakelock.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

public class FixMmsWakelock {
public static final String PACKAGE_NAME = "com.android.mms";
public static final String ALT_PACKAGE_NAME = "com.lenovo.ideafriend";
private static final String TAG = "GB:FixMmsWakelock";
private static final String CLASS_MMS_RECEIVER = "com.android.mms.transaction.MmsSystemEventReceiver";
private static final String CLASS_SMS_RECEIVER = "com.android.mms.transaction.SmsReceiver";
private static final String CLASS_CB_MNOTIF = "com.android.mms.transaction.CBMessagingNotification";
private static final String CLASS_MNOTIF = "com.android.mms.transaction.MessagingNotification";
private static final String CLASS_NOTIF_PROFILE = "com.android.mms.transaction.MessagingNotification$NotificationProfile";
private static String CLASS_MMS_RECEIVER = "com.android.mms.transaction.MmsSystemEventReceiver";
private static String CLASS_SMS_RECEIVER = "com.android.mms.transaction.SmsReceiver";
private static String CLASS_CB_MNOTIF = "com.android.mms.transaction.CBMessagingNotification";
private static String CLASS_MNOTIF = "com.android.mms.transaction.MessagingNotification";
private static String CLASS_NOTIF_PROFILE = "com.android.mms.transaction.MessagingNotification$NotificationProfile";
private static final boolean DEBUG = false;

private static Unhook mSmsPmHook = null;
Expand All @@ -47,7 +48,16 @@ private static void log(String message) {
XposedBridge.log(TAG + ": " + message);
}

public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) {
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader, String appUri) {
if (DEBUG) log("init (" + appUri + ")");

if (appUri.equals(ALT_PACKAGE_NAME)) {
CLASS_MMS_RECEIVER = "com.lenovo.ideafriend.mms.android.transaction.MmsSystemEventReceiver";
CLASS_SMS_RECEIVER = "com.lenovo.ideafriend.mms.android.transaction.SmsReceiver";
CLASS_CB_MNOTIF = "com.lenovo.ideafriend.mms.android.transaction.CBMessagingNotification";
CLASS_MNOTIF = "com.lenovo.ideafriend.mms.android.transaction.MessagingNotification";
}

try {
final Class<?> mmsReceiverClass = XposedHelpers.findClass(CLASS_MMS_RECEIVER, classLoader);
XposedHelpers.findAndHookMethod(mmsReceiverClass,
Expand Down
18 changes: 12 additions & 6 deletions src/com/ceco/gm2/gravitybox/GravityBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
ModSignalIconHide.init(prefs, lpparam.classLoader);
}

if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_FIX_CALLER_ID_MMS, false) &&
lpparam.packageName.equals(FixCallerIdMms.PACKAGE_NAME)) {
FixCallerIdMms.init(prefs, lpparam.classLoader);
if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_FIX_CALLER_ID_MMS, false)) {
if (lpparam.packageName.equals(FixCallerIdMms.PACKAGE_NAME)) {
FixCallerIdMms.init(prefs, lpparam.classLoader, FixCallerIdMms.PACKAGE_NAME);
} else if (lpparam.packageName.equals(FixCallerIdMms.ALT_PACKAGE_NAME)) {
FixCallerIdMms.init(prefs, lpparam.classLoader, FixCallerIdMms.ALT_PACKAGE_NAME);
}
}

if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_FIX_CALENDAR, false) &&
Expand All @@ -147,9 +150,12 @@ public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
FixDevOptions.init(prefs, lpparam.classLoader);
}

if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_FIX_MMS_WAKELOCK, false) &&
lpparam.packageName.equals(FixMmsWakelock.PACKAGE_NAME)) {
FixMmsWakelock.init(prefs, lpparam.classLoader);
if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_FIX_MMS_WAKELOCK, false)) {
if (lpparam.packageName.equals(FixMmsWakelock.PACKAGE_NAME)) {
FixMmsWakelock.init(prefs, lpparam.classLoader, FixMmsWakelock.PACKAGE_NAME);
} else if (lpparam.packageName.equals(FixMmsWakelock.ALT_PACKAGE_NAME)) {
FixMmsWakelock.init(prefs, lpparam.classLoader, FixMmsWakelock.ALT_PACKAGE_NAME);
}
}

if (lpparam.packageName.equals(ModAudioSettings.PACKAGE_NAME)) {
Expand Down
7 changes: 5 additions & 2 deletions src/com/ceco/gm2/gravitybox/GravityBoxSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public class GravityBoxSettings extends Activity implements GravityBoxResultRece
public static final String PREF_KEY_CRT_OFF_EFFECT = "pref_crt_off_effect";
public static final String PREF_KEY_UNPLUG_TURNS_ON_SCREEN = "pref_unplug_turns_on_screen";
public static final String PREF_KEY_ENGINEERING_MODE = "pref_engineering_mode";
public static final String APP_MESSAGING = "com.android.mms";
public static final String STOCK_APP_MESSAGING = "com.android.mms";
public static final String ALT_APP_MESSAGING = "com.lenovo.ideafriend";
public static final String APP_ENGINEERING_MODE = "com.mediatek.engineermode";
public static final String APP_ENGINEERING_MODE_CLASS = "com.mediatek.engineermode.EngineerMode";
public static final String PREF_KEY_DUAL_SIM_RINGER = "pref_dual_sim_ringer";
Expand Down Expand Up @@ -942,8 +943,10 @@ public void onCreate(Bundle savedInstanceState) {
mPrefCatMedia.removePreference(mPrefLinkVolumes);
mPrefCatFixes.removePreference(mPrefFixCallerIDPhone);
}
if (!isAppInstalled(APP_MESSAGING)) {
if (!isAppInstalled(STOCK_APP_MESSAGING)) {
mPrefCatPhone.removePreference(mPrefCatPhoneMessaging);
}
if (!isAppInstalled(STOCK_APP_MESSAGING) && !isAppInstalled(ALT_APP_MESSAGING)) {
mPrefCatFixes.removePreference(mPrefFixCallerIDMms);
mPrefCatFixes.removePreference(mPrefFixMmsWakelock);
}
Expand Down