Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6ea975e authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Implementation of metrics for MMS.

Added a utility method to test if the given application is default mms
application.

Bug: 233259583
Test: atest MmsServiceTests
Change-Id: I1beae190ab42b18191a5d4e3791b53a27645053a
parent 82a9156b
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -1146,4 +1146,35 @@ public final class SmsApplication {
        }
        return null;
    }

    /**
     * Check if a package is default mms app (or equivalent, like bluetooth)
     *
     * @param context context from the calling app
     * @param packageName the name of the package to be checked
     * @return true if the package is default mms app or bluetooth
     */
    @UnsupportedAppUsage
    public static boolean isDefaultMmsApplication(Context context, String packageName) {
        if (packageName == null) {
            return false;
        }
        String defaultMmsPackage = getDefaultMmsApplicationPackageName(context);
        String bluetoothPackageName = context.getResources()
                .getString(com.android.internal.R.string.config_systemBluetoothStack);

        if ((defaultMmsPackage != null && defaultMmsPackage.equals(packageName))
                || bluetoothPackageName.equals(packageName)) {
            return true;
        }
        return false;
    }

    private static String getDefaultMmsApplicationPackageName(Context context) {
        ComponentName component = getDefaultMmsApplication(context, false);
        if (component != null) {
            return component.getPackageName();
        }
        return null;
    }
}