Skip to content

Commit 255de6a

Browse files
committed
Dialer: disable Show dialpad automatically for SDK 28 Dialer app
1 parent 116a340 commit 255de6a

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

src/com/ceco/oreo/gravitybox/GravityBox.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
182182
}
183183

184184
if (ModDialer26.PACKAGE_NAMES.contains(lpparam.packageName) && !Utils.isOxygenOsRom()) {
185-
ModDialer26.init(prefs, qhPrefs, lpparam.classLoader, lpparam.packageName);
185+
ModDialer26.init(prefs, qhPrefs, lpparam.classLoader,
186+
lpparam.packageName, lpparam.appInfo.targetSdkVersion);
186187
}
187188

188189
if (lpparam.packageName.equals(ModQsTiles.PACKAGE_NAME) &&

src/com/ceco/oreo/gravitybox/GravityBoxSettings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,8 @@ public void onCreate(Bundle savedInstanceState) {
17901790
PackageInfo pi = null;
17911791
for (String pkg : ModDialer26.PACKAGE_NAMES) {
17921792
pi = Utils.getPackageInfo(getActivity(), pkg);
1793-
if (pi != null) break;
1793+
if (pi != null && pi.applicationInfo.targetSdkVersion < 28) break;
1794+
pi = null;
17941795
}
17951796
if (pi == null) {
17961797
mPrefCatPhone.removePreference(mPrefCatPhoneDialer);

src/com/ceco/oreo/gravitybox/ModDialer26.java

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,39 @@ private static ClassInfo resolveDialpadFragment(ClassLoader cl) {
8888
}
8989

9090
public static void init(final XSharedPreferences prefs, final XSharedPreferences qhPrefs,
91-
final ClassLoader classLoader, final String packageName) {
92-
try {
93-
XposedHelpers.findAndHookMethod(CLASS_DIALTACTS_ACTIVITY, classLoader,
94-
"onResume", new XC_MethodHook() {
95-
@Override
96-
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
97-
prefs.reload();
98-
if (!prefs.getBoolean(GravityBoxSettings.PREF_KEY_DIALER_SHOW_DIALPAD, false)) return;
99-
100-
final String realClassName = param.thisObject.getClass().getName();
101-
Method m = null;
102-
for (String mn : new String[] { "showDialpadFragment", "f" }) {
103-
if (realClassName.equals(CLASS_DIALTACTS_ACTIVITY)) {
104-
m = XposedHelpers.findMethodExactIfExists(
105-
param.thisObject.getClass(), mn, boolean.class);
106-
} else if (realClassName.equals(CLASS_DIALTACTS_ACTIVITY_GOOGLE)) {
107-
m = XposedHelpers.findMethodExactIfExists(
108-
param.thisObject.getClass().getSuperclass(), mn, boolean.class);
91+
final ClassLoader classLoader, final String packageName, int sdkVersion) {
92+
if (sdkVersion < 28) {
93+
try {
94+
XposedHelpers.findAndHookMethod(CLASS_DIALTACTS_ACTIVITY, classLoader,
95+
"onResume", new XC_MethodHook() {
96+
@Override
97+
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
98+
prefs.reload();
99+
if (!prefs.getBoolean(GravityBoxSettings.PREF_KEY_DIALER_SHOW_DIALPAD, false)) return;
100+
101+
final String realClassName = param.thisObject.getClass().getName();
102+
Method m = null;
103+
for (String mn : new String[] { "showDialpadFragment", "f" }) {
104+
if (realClassName.equals(CLASS_DIALTACTS_ACTIVITY)) {
105+
m = XposedHelpers.findMethodExactIfExists(
106+
param.thisObject.getClass(), mn, boolean.class);
107+
} else if (realClassName.equals(CLASS_DIALTACTS_ACTIVITY_GOOGLE)) {
108+
m = XposedHelpers.findMethodExactIfExists(
109+
param.thisObject.getClass().getSuperclass(), mn, boolean.class);
110+
}
111+
if (m != null) break;
112+
}
113+
if (m == null) {
114+
GravityBox.log(TAG, "DialtactsActivity: couldn't identify showDialpadFragment method");
115+
} else {
116+
m.invoke(param.thisObject, false);
117+
if (DEBUG) log("showDialpadFragment() called within " + realClassName);
109118
}
110-
if (m != null) break;
111-
}
112-
if (m == null) {
113-
GravityBox.log(TAG, "DialtactsActivity: couldn't identify showDialpadFragment method");
114-
} else {
115-
m.invoke(param.thisObject, false);
116-
if (DEBUG) log("showDialpadFragment() called within " + realClassName);
117119
}
118-
}
119-
});
120-
} catch (Throwable t) {
121-
GravityBox.log(TAG, "DialtactsActivity: incompatible version of Dialer app", t);
120+
});
121+
} catch (Throwable t) {
122+
GravityBox.log(TAG, "DialtactsActivity: incompatible version of Dialer app", t);
123+
}
122124
}
123125

124126
try {

0 commit comments

Comments
 (0)