Neelesh B. Mehta

201 papers B 46Misc 3Journal 107Unranked 45
YearRankTypeTitle / Venue / Authors
2026 J jnl
IEEE Trans. Wirel. Commun.
Sayantan Adhikary, Neelesh B. Mehta
2026 J jnl
IEEE Trans. Mob. Comput.
S. Arthi, Neelesh B. Mehta, Chandramani Singh
2026 J jnl
IEEE Trans. Commun.
Shivani Dhok, Neelesh B. Mehta
2025 J jnl
IEEE Trans. Commun.
Sayantan Adhikary, Neelesh B. Mehta
2025 J jnl
IEEE Trans. Veh. Technol.
S. Sruthy, Neelesh B. Mehta
2025 J jnl
IEEE Trans. Wirel. Commun.
Tenneti Venkata Satya Sreedhar, Neelesh B. Mehta
2025 conf
NCC
Tenneti Venkata Satya Sreedhar, Neelesh B. Mehta
2025 J jnl
IEEE Trans. Wirel. Commun.
Ashok Kumar Reddy Chavva, Neelesh B. Mehta
2025 J jnl
IEEE Trans. Mob. Comput.
Vinay U. Pai, Neelesh B. Mehta, Chandramani Singh
2025 B conf
GLOBECOM
Shivani Dhok, Neelesh B. Mehta
2025 B conf
GLOBECOM
S. Sruthy, Neelesh B. Mehta
2024 Misc conf
ICASSP
Sriram Ganesan, Neelesh B. Mehta, Rimalapudi Sarvendranath
2024 J jnl
IEEE Trans. Wirel. Commun.
Sriram Ganesan, Neelesh B. Mehta, Rimalapudi Sarvendranath
2024 conf
ICC
Suji Naduvilpattu, Neelesh B. Mehta
2024 J jnl
CoRR
Prasoon Raghuwanshi, Onel Luis Alcaraz López, Neelesh B. Mehta, Hirley Alves, Matti Latva-aho
2024 J jnl
IEEE Open J. Commun. Soc.
Prasoon Raghuwanshi, Onel Luis Alcaraz López, Neelesh B. Mehta, Hirley Alves, Matti Latva-aho
2024 J jnl
IEEE Trans. Wirel. Commun.
Suji Naduvilpattu, Neelesh B. Mehta
2024 J jnl
IEEE Trans. Wirel. Commun.
S. Sruthy, Neelesh B. Mehta
2024 B conf
GLOBECOM
S. Arthi, Neelesh B. Mehta
2024 conf
ICC
Vinay U. Pai, Neelesh B. Mehta, Chandramani Singh
2023 B conf
GLOBECOM
Sayantan Adhikary, Neelesh B. Mehta
2023 J jnl
IEEE Trans. Wirel. Commun.
Tenneti Venkata Satya Sreedhar, Neelesh B. Mehta
2023 conf
Q2SWinet
Rushabha Balaji, Neelesh B. Mehta, Chandramani Singh
2023 J jnl
IEEE Trans. Wirel. Commun.
Govindu Saikesava, Neelesh B. Mehta
2023 conf
ICC
S. Sruthy, Neelesh B. Mehta
2022 conf
ICC
Tenneti Venkata Satya Sreedhar, Neelesh B. Mehta
2022 J jnl
IEEE Trans. Wirel. Commun.
Bala Venkata Ramulu Gorantla, Neelesh B. Mehta
2022 conf
ICC
Govindu Saikesava, Neelesh B. Mehta
2022 J jnl
IEEE Trans. Commun.
Suji Naduvilpattu, Neelesh B. Mehta
2022 J jnl
IEEE Wirel. Commun. Lett.
Tenneti Venkata Satya Sreedhar, Neelesh B. Mehta
2021 J jnl
IEEE Trans. Wirel. Commun.
Vineeth Kumar, Neelesh B. Mehta
2021 B conf
GLOBECOM
Sayantan Adhikary, Neelesh B. Mehta
2021 J jnl
IEEE Trans. Wirel. Commun.
Ashok Kumar Reddy Chavva, Neelesh B. Mehta
2021 B conf
CNSM
Samaresh Bera, Neelesh B. Mehta
2021 conf
ICC
Suji Naduvilpattu, Neelesh B. Mehta
2021 J jnl
IEEE Trans. Commun.
Sayan Sen Gupta, Neelesh B. Mehta
2021 J jnl
IEEE Trans. Commun.
Rimalapudi Sarvendranath, Neelesh B. Mehta
2021 B conf
GLOBECOM
Ashok Kumar Reddy Chavva, Neelesh B. Mehta
2021 conf
ICC
Bala Venkata Ramulu Gorantla, Neelesh B. Mehta
2021 J jnl
IEEE Trans. Wirel. Commun.
Rama Kiran, Neelesh B. Mehta
2020 conf
ICC
Sayan Sen Gupta, Neelesh B. Mehta
2020 B conf
GLOBECOM
Vineeth Kumar, Neelesh B. Mehta
2020 J jnl
IEEE Trans. Commun.
Rimalapudi Sarvendranath, Neelesh B. Mehta
2020 B conf
WCNC
Rimalapudi Sarvendranath, Neelesh B. Mehta
2020 J jnl
IEEE Trans. Commun.
Sayan Sen Gupta, Sai Kiran Pallapothu, Neelesh B. Mehta
2020 B conf
GLOBECOM
Rama Kiran, Neelesh B. Mehta
2019 conf
ICC
Bala Venkata Ramulu Gorantla, Neelesh B. Mehta
2019 J jnl
IEEE Trans. Commun.
Rama Kiran, Neelesh B. Mehta, Jestin Thomas
2019 J jnl
IEEE Wirel. Commun. Lett.
Reneeta Sara Isaac, Neelesh B. Mehta
2019 J jnl
IEEE Trans. Wirel. Commun.
Rimalapudi Sarvendranath, Neelesh B. Mehta
2019 J jnl
IEEE Trans. Wirel. Commun.
Vineeth Kumar, Neelesh B. Mehta
2019 B conf
GLOBECOM
Rimalapudi Sarvendranath, Neelesh B. Mehta
2019 J jnl
IEEE Trans. Wirel. Commun.
Bala Venkata Ramulu Gorantla, Neelesh B. Mehta
2019 J jnl
IEEE Trans. Commun.
Sayan Sen Gupta, Neelesh B. Mehta
2019 J jnl
IEEE Commun. Mag.
Michele Zorzi, Diane T. Rover, Periklis Chatzimisios, Neelesh B. Mehta
2018 J jnl
IEEE Trans. Commun.
Reneeta Sara Isaac, Neelesh B. Mehta
2018 conf
ICC
Sai Kiran Pallapothu, Neelesh B. Mehta
2018 conf
ICC
Vineeth Kumar, Neelesh B. Mehta
2018 J jnl
IEEE Trans. Wirel. Commun.
Saikiran Bulusu, Neelesh B. Mehta, Suresh Kalyanasundaram
2018 B conf
GLOBECOM
Sayan Sen Gupta, Neelesh B. Mehta
2018 J jnl
IEEE Trans. Commun.
Rimalapudi Sarvendranath, Neelesh B. Mehta
2017 J jnl
IEEE Trans. Wirel. Commun.
Vineeth Kumar, Neelesh B. Mehta
2017 conf
ICC
Priyanka Das, Neelesh B. Mehta, P. N. Arya
2017 J jnl
IEEE Trans. Veh. Technol.
Amit Kumar Dutta, K. V. S. Hari, Chandra R. Murthy, Neelesh B. Mehta, Lajos Hanzo
2017 B conf
GLOBECOM
Rimalapudi Sarvendranath, Neelesh B. Mehta
2017 J jnl
IEEE Trans. Commun.
Priyanka Das, Neelesh B. Mehta
2017 J jnl
IEEE Trans. Wirel. Commun.
Vikas Kumar Dewangan, Neelesh B. Mehta
2017 J jnl
IEEE Trans. Commun.
Jobin Francis, Neelesh B. Mehta
2016 conf
ICC
Rupesh K. Kona, Neelesh B. Mehta, Jobin Francis
2016 J jnl
IEEE Trans. Wirel. Commun.
Jobin Francis, Neelesh B. Mehta, S. N. Ananya
2016 conf
ICC
Jobin Francis, Neelesh B. Mehta
2016 conf
ICC
M. P. Praveen, Neelesh B. Mehta
2015 B conf
GLOBECOM
S. N. Ananya, Neelesh B. Mehta
2015 J jnl
IEEE Trans. Wirel. Commun.
Jobin Francis, Neelesh B. Mehta
2015 J jnl
IEEE Trans. Commun.
Priyanka Das, Neelesh B. Mehta
2015 conf
ICC
Priyanka Das, Neelesh B. Mehta
2015 J jnl
IEEE Trans. Wirel. Commun.
Parag S. Khairnar, Neelesh B. Mehta
2015 B conf
WiOpt
Jobin Francis, Suresh Kalyanasundaram, Balamurali Natarajan, Rajeev Agrawal, Neelesh B. Mehta
2015 J jnl
IEEE Trans. Wirel. Commun.
Shilpa Rao, Neelesh B. Mehta
2015 J jnl
IEEE Trans. Wirel. Commun.
Priyanka Das, Neelesh B. Mehta, Gagandeep Singh
2015 J jnl
IEEE Trans. Wirel. Commun.
S. N. Ananya, Neelesh B. Mehta
2015 J jnl
IEEE Wirel. Commun. Lett.
Salil Kashyap, Neelesh B. Mehta
2015 J jnl
IEEE Trans. Commun.
Arjun Anand, Neelesh B. Mehta
2015 B conf
GLOBECOM
Priyanka Das, Neelesh B. Mehta
2015 J jnl
IEEE Trans. Wirel. Commun.
Vikas Kumar Dewangan, Neelesh B. Mehta
2014 conf
ICC
B. Sainath, Neelesh B. Mehta
2014 J jnl
IEEE Trans. Commun.
Rimalapudi Sarvendranath, Neelesh B. Mehta
2014 J jnl
IEEE Trans. Commun.
Vikas Kumar Dewangan, Neelesh B. Mehta
2014 J jnl
IEEE Trans. Wirel. Commun.
Jobin Francis, Neelesh B. Mehta
2014 J jnl
IEEE Trans. Wirel. Commun.
Shilpa Rao, Neelesh B. Mehta
2014 B conf
GLOBECOM
Jobin Francis, Neelesh B. Mehta
2014 J jnl
IEEE Trans. Commun.
B. Sainath, Neelesh B. Mehta
2014 Misc conf
COMSNETS
Neelesh B. Mehta, Ramachandran Ramjee, Sanjay Shakkottai
2014 J jnl
IEEE Trans. Wirel. Commun.
Mohammed Shabbir Ali, Neelesh B. Mehta
2014 J jnl
IEEE Trans. Commun.
Salil Kashyap, Neelesh B. Mehta
2014 conf
ICC
Arjun Anand, Neelesh B. Mehta
2014 conf
NCC
S. N. Ananya, Neelesh B. Mehta
2014 conf
GlobalSIP
Shilpa Rao, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Commun.
Sachin Bharadwaj, Neelesh B. Mehta
2013 J jnl
IEEE Veh. Technol. Mag.
Rong Zhang, Li Wang, Gerard Parr, Osianoh Glenn Aliu, Benga Awoseyila, Nader Azarmi, Saleem Bhatti, Eliane L. Bodanese, Hong Chen, Mehrdad Dianati, Amit Kumar Dutta, Michael Fitch, Krishnamurthy Giridhar, Steve Hailes, K. V. S. Hari, Muhammad Ali Imran, Aditya K. Jagannatham, Abhay Karandikar, Santosh Kawade, Mohammed Zafar Ali Khan, Sayee C. Kompalli, Patrick Langdon, Babu Narayanan, Andreas Mauthe, Joseph McGeehan, Neelesh B. Mehta, J. Klutto Milleth, Klaus Moessner, Rakshith Rajashekar, Barathram Ramkumar, Vinay J. Ribeiro, Kasturi Vasudevan, Lajos Hanzo, John Bigham
2013 J jnl
IEEE Trans. Commun.
Rimalapudi Sarvendranath, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Wirel. Commun.
Arpan Mukhopadhyay, Neelesh B. Mehta, Vikram Srinivasan
2013 B conf
GLOBECOM
Jobin Francis, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Commun.
A. Karthik, Neelesh B. Mehta
2013 conf
ICC
A. Karthik, Neelesh B. Mehta
2013 B conf
WCNC
Shilpa Rao, Neelesh B. Mehta
2013 conf
ICC
Vikas Kumar Dewangan, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Commun.
Neelesh B. Mehta, Rajat Talak, Ananda Theertha Suresh
2013 J jnl
IEEE Trans. Wirel. Commun.
Salil Kashyap, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Veh. Technol.
Subhojit Guharoy, Neelesh B. Mehta
2013 B conf
GLOBECOM
Mohammed Shabbir Ali, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Commun.
Rajat Talak, Neelesh B. Mehta
2013 B conf
WCNC
Rimalapudi Sarvendranath, Neelesh B. Mehta
2013 B conf
GLOBECOM
Joyson Sebastian, Neelesh B. Mehta
2013 B conf
GLOBECOM
Salil Kashyap, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Wirel. Commun.
Salil Kashyap, Neelesh B. Mehta
2013 J jnl
IEEE Trans. Commun.
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2013 J jnl
IEEE J. Sel. Top. Signal Process.
Anup Aprem, Chandra R. Murthy, Neelesh B. Mehta
2012 B conf
GLOBECOM
Arpan Mukhopadhyay, Neelesh B. Mehta, Vikram Srinivasan
2012 J jnl
IEEE Trans. Commun.
A. Karthik, Neelesh B. Mehta
2012 conf
ICC
Hassan A. Abou-Saleh, Andreas F. Molisch, Thomas Zemen, Steven D. Blostein, Neelesh B. Mehta
2012 J jnl
IEEE Commun. Mag.
Neelesh B. Mehta, Salil Kashyap, Andreas F. Molisch
2012 J jnl
IEEE Trans. Commun.
Rajat Talak, Neelesh B. Mehta
2012 J jnl
IEEE Trans. Wirel. Commun.
B. Sainath, Neelesh B. Mehta
2012 B conf
GLOBECOM
Subhojit Guharoy, Neelesh B. Mehta
2012 J jnl
IEEE Trans. Wirel. Commun.
Parag S. Khairnar, Neelesh B. Mehta
2012 J jnl
IEEE Trans. Wirel. Commun.
Hassan A. Abou-Saleh, Andreas F. Molisch, Thomas Zemen, Steven D. Blostein, Neelesh B. Mehta
2012 Misc conf
ICCS
B. Sainath, Neelesh B. Mehta
2012 B conf
GLOBECOM
Rimalapudi Sarvendranath, Neelesh B. Mehta
2012 J jnl
J. Commun. Networks
Sennur Ulukus, Kaibin Huang, Rui Zhang, Neelesh B. Mehta, Leandros Tassiulas
2012 B conf
GLOBECOM
Anup Aprem, Chandra R. Murthy, Neelesh B. Mehta
2011 conf
ICC
A. Karthik, Neelesh B. Mehta
2011 J jnl
IEEE Trans. Wirel. Commun.
Sushruth N. Donthi, Neelesh B. Mehta
2011 conf
ACSCC
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2011 B conf
GLOBECOM
Rajat Talak, Neelesh B. Mehta
2011 J jnl
J. Commun.
Sudhanshu Gaur, Geoffrey Ye Li, Li-Chun Wang, Neelesh B. Mehta
2011 J jnl
IEEE Trans. Veh. Technol.
Sushruth N. Donthi, Neelesh B. Mehta
2011 B conf
GLOBECOM
Sachin Bharadwaj, Neelesh B. Mehta
2011 J jnl
IEEE Trans. Wirel. Commun.
Neelesh B. Mehta, Vinod Sharma, Gaurav Bansal
2011 J jnl
IEEE Trans. Wirel. Commun.
Virag Shah, Neelesh B. Mehta, Dilip Bethanabhotla
2011 conf
ICC
Parag S. Khairnar, Neelesh B. Mehta
2011 conf
ACSCC
Neelesh B. Mehta
2011 J jnl
IEEE Trans. Wirel. Commun.
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2011 J jnl
IEEE Trans. Commun.
Jingxian Wu, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2010 conf
ICC
Virag Shah, Neelesh B. Mehta, Raymond Yim
2010 conf
ICC
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2010 J jnl
IEEE Trans. Wirel. Commun.
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2010 J jnl
IEEE Trans. Wirel. Commun.
Sarabjot Singh, Neelesh B. Mehta, Andreas F. Molisch, Abhijit Mukhopadhyay
2010 B conf
GLOBECOM
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2010 J jnl
IEEE Trans. Commun.
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2010 J jnl
IEEE Trans. Commun.
Virag Shah, Neelesh B. Mehta, Raymond Yim
2010 B conf
GLOBECOM
Sushruth N. Donthi, Neelesh B. Mehta
2010 conf
ICC
Gaurav Bansal, Vinod Sharma, Neelesh B. Mehta, Eitan Altman
2010 J jnl
IEEE Trans. Wirel. Commun.
Virag Shah, Neelesh B. Mehta, Raymond Yim
2010 J jnl
IEEE Trans. Wirel. Commun.
Virag Shah, Neelesh B. Mehta, Raymond Yim
2010 conf
ICC
Bhargav Medepally, Neelesh B. Mehta
2010 J jnl
IEEE Trans. Wirel. Commun.
Bhargav Medepally, Neelesh B. Mehta
2009 B conf
GLOBECOM
Neelesh B. Mehta, Sarabjot Singh, Andreas F. Molisch
2009 conf
ICC
Virag Shah, Neelesh B. Mehta, Raymond Yim
2009 J jnl
IEEE Trans. Wirel. Commun.
Raymond Yim, Neelesh B. Mehta, Andreas F. Molisch, Jinyun Zhang
2009 J jnl
IEEE Trans. Autom. Control.
Ritesh Madan, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2009 J jnl
IEEE Trans. Wirel. Commun.
Raymond Yim, Neelesh B. Mehta, Andreas F. Molisch
2009 B conf
GLOBECOM
Bhargav Medepally, Neelesh B. Mehta, Chandra R. Murthy
2009 J jnl
CoRR
Virag Shah, Neelesh B. Mehta, Raymond Yim
2009 conf
ICC
Vinod Kristem, Neelesh B. Mehta, Andreas F. Molisch
2009 B conf
GLOBECOM
Virag Shah, Neelesh B. Mehta, Raymond Yim
2009 J jnl
CoRR
Virag Shah, Neelesh B. Mehta, Raymond Yim
2008 conf
ICC
Chun Nie, Zhifeng Tao, Neelesh B. Mehta, Andreas F. Molisch, Jinyun Zhang, Toshiyuki Kuze, Shivendra S. Panwar
2008 J jnl
IEEE Trans. Wirel. Commun.
Natasha Devroye, Neelesh B. Mehta, Andreas F. Molisch
2008 J jnl
IEEE Trans. Wirel. Commun.
Hongyuan Zhang, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang, Huaiyu Dai
2008 conf
ICC
Raymond Yim, Neelesh B. Mehta, Andreas F. Molisch
2008 B conf
WCNC
Raymond Yim, Neelesh B. Mehta, Andreas F. Molisch, Jinyun Zhang
2008 J jnl
IEEE Trans. Wirel. Commun.
Ritesh Madan, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2008 J jnl
IEEE Trans. Wirel. Commun.
Raymond Yim, Neelesh B. Mehta, Andreas F. Molisch, Jinyun Zhang
2008 B conf
GLOBECOM
Neelesh B. Mehta, Vinod Sharma, Gaurav Bansal
2007 J jnl
IEEE Trans. Wirel. Commun.
Neelesh B. Mehta, Jingxian Wu, Andreas F. Molisch, Jin Zhang
2007 B conf
GLOBECOM
Natasha Devroye, Neelesh B. Mehta, Andreas F. Molisch
2007 conf
ICC
Hongyuan Zhang, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang, Huaiyu Dai
2007 J jnl
IEEE Trans. Commun.
Yabo Li, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2007 J jnl
IEEE Trans. Wirel. Commun.
Andreas F. Molisch, Neelesh B. Mehta, Jonathan S. Yedidia, Jin Zhang
2007 conf
ICC
Jingxian Wu, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2006 conf
ICC
Neelesh B. Mehta, Andreas F. Molisch, Jingxian Wu, Jin Zhang
2006 J jnl
IEEE Trans. Wirel. Commun.
Pallav Sudarshan, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2006 B conf
GLOBECOM
Andreas F. Molisch, Neelesh B. Mehta, Jonathan S. Yedidia, Jinyun Zhang
2006 B conf
GLOBECOM
Ritesh Madan, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2006 J jnl
IEEE Trans. Wirel. Commun.
Neelesh B. Mehta, Andreas F. Molisch, Larry J. Greenstein
2006 B conf
GLOBECOM
Yabo Li, Neelesh B. Mehta, Andreas F. Molisch, Jinyun Zhang
2006 B conf
GLOBECOM
Raymond Yim, Neelesh B. Mehta, Andreas F. Molisch, Jinyun Zhang
2005 B conf
GLOBECOM
Jingxian Wu, Neelesh B. Mehta, Jin Zhang
2005 B conf
GLOBECOM
Neelesh B. Mehta, Andreas F. Molisch, Larry J. Greenstein
2005 B conf
GLOBECOM
Jingxian Wu, Neelesh B. Mehta, Jin Zhang
2004 B conf
GLOBECOM
Pallav Sudarshan, Neelesh B. Mehta, Andreas F. Molisch, Jin Zhang
2003 J jnl
IEEE Trans. Wirel. Commun.
Neelesh B. Mehta, Larry J. Greenstein, Thomas M. Willis, Zoran Kostic
2003 J jnl
IEEE Trans. Wirel. Commun.
Olufunmilola Awoniyi, Neelesh B. Mehta, Larry J. Greenstein
2002 conf
VTC Spring
Neelesh B. Mehta, Larry J. Greenstein, Thomas M. Willis, Zoran Kostic
2002 conf
ICC
Henrik Asplund, Andreas F. Molisch, Martin Steinbauer, Neelesh B. Mehta
2002 J jnl
IEEE Trans. Commun.
Neelesh B. Mehta, Andrea J. Goldsmith
2002 conf
ICC
Xiaoxin Qiu, L. Chang, Zoran Kostic, Thomas M. Willis, Neelesh B. Mehta, Larry J. Greenstein, Kapil K. Chawla, James F. Whitehead, Justin C.-I. Chuang
2000 conf
ICC (1)
Neelesh B. Mehta, Andrea J. Goldsmith
2000 B conf
GLOBECOM
Neelesh B. Mehta, Andrea J. Goldsmith
1999 conf
ICC
Neelesh B. Mehta, Andrea Goldsmith
redb/extractors/apk_extractors/apk_inconsistency_tests.py
← Index redb/extractors/apk_extractors/apk_inconsistency_tests.py python
import inspect
import re
from datetime import datetime, timezone
from typing import Any

from redb.extractors.enum import Tag
from redb.extractors.apk_extractor import APKExtractor
from redb.models.dataclasses import APKInconsistencyTests

# Emulator detection indicator strings
EMULATOR_INDICATORS = {
    "generic", "sdk", "google_sdk", "Emulator",
    "goldfish", "ranchu", "Andy", "Genymotion",
    "BlueStacks", "nox", "ttVM_Hdragon",
}

# Root detection indicator strings
ROOT_INDICATORS = {
    "/system/app/Superuser.apk",
    "/system/xbin/su",
    "/system/bin/su",
    "com.noshufou.android.su",
    "com.thirdparty.superuser",
    "eu.chainfire.supersu",
    "com.koushikdutta.superuser",
    "com.topjohnwu.magisk",
}

# Standard DEX filename pattern
STANDARD_DEX_PATTERN = re.compile(r"^classes\d*\.dex$")


class APKInconsistencyTestsExtractor(APKExtractor):

    def __init__(
        self, filepath, log, exporters=None, index_prefix=None,
        known_benign=False, known_malicious=False,
        apk=None,
    ):
        super().__init__(
            filepath, log, exporters, index_prefix,
            known_benign, known_malicious, apk,
        )
        self.test_results = None
        self.log.debug(inspect.currentframe().f_code.co_name)

    def tag(self):
        return Tag.APK_INCONSISTENCY_TESTS.value

    def _test_zip_bomb(self):
        """Check if any ZIP entry has compression ratio > 100:1."""
        try:
            zf = self._get_zip_file()
            if not zf:
                return None
            with zf:
                for info in zf.infolist():
                    if info.compress_size > 0:
                        ratio = info.file_size / info.compress_size
                        if ratio > 100:
                            return True
            return False
        except Exception as e:
            self.log.warning(f"Error in zip bomb test: {e}")
            return None

    def _test_zip_duplicate_entries(self):
        """Check for duplicate filenames in ZIP directory."""
        try:
            zf = self._get_zip_file()
            if not zf:
                return None
            with zf:
                names = [info.filename for info in zf.infolist()]
                return len(names) != len(set(names))
        except Exception as e:
            self.log.warning(f"Error in duplicate entries test: {e}")
            return None

    def _test_zip_path_traversal(self):
        """Check for path traversal (../) in ZIP entry names."""
        try:
            for f in self._list_files():
                if ".." in f or f.startswith("/"):
                    return True
            return False
        except Exception as e:
            self.log.warning(f"Error in path traversal test: {e}")
            return None

    def _test_zip_suspicious_timestamps(self):
        """Check for timestamps at epoch (1980) or in the future."""
        try:
            zf = self._get_zip_file()
            if not zf:
                return None
            now = datetime.now()
            with zf:
                for info in zf.infolist():
                    try:
                        dt = datetime(*info.date_time)
                        if dt.year <= 1980 or dt > now:
                            return True
                    except (ValueError, TypeError):
                        continue
            return False
        except Exception as e:
            self.log.warning(f"Error in suspicious timestamps test: {e}")
            return None

    def _test_hidden_dex_files(self):
        """Check for DEX files not matching classes*.dex pattern."""
        try:
            for f in self._list_files():
                if f.endswith(".dex"):
                    basename = f.split("/")[-1]
                    if not STANDARD_DEX_PATTERN.match(basename):
                        return True
            return False
        except Exception as e:
            self.log.warning(f"Error in hidden DEX files test: {e}")
            return None

    def _test_manifest_component_mismatch(self):
        """Check for declared components that don't exist in DEX."""
        try:
            if not self._is_valid_apk():
                return None

            # Get all class names from DEX
            dex_classes = set()
            try:
                from androguard.core.dex import DEX
                for dex_data in (self.apk.get_all_dex() or []):
                    try:
                        d = DEX(dex_data)
                        for cls in d.get_classes():
                            name = cls.get_name()
                            if name:
                                # Convert "Lcom/example/Foo;" to "com.example.Foo"
                                dex_classes.add(
                                    name[1:-1].replace("/", ".") if name.startswith("L") else name
                                )
                    except Exception:
                        continue
            except Exception:
                return None

            if not dex_classes:
                return None

            # Check manifest components against DEX classes
            components = []
            try:
                components.extend(self.apk.get_activities() or [])
                components.extend(self.apk.get_services() or [])
                components.extend(self.apk.get_receivers() or [])
                components.extend(self.apk.get_providers() or [])
            except Exception:
                return None

            for comp in components:
                if comp and comp not in dex_classes:
                    # Component might use a shorthand; check with package prefix
                    package = self.apk.get_package() or ""
                    full_name = package + comp if comp.startswith(".") else comp
                    if full_name not in dex_classes:
                        return True

            return False
        except Exception as e:
            self.log.warning(f"Error in manifest component mismatch test: {e}")
            return None

    def _test_debuggable_release(self):
        """Check android:debuggable=true combined with a release signature."""
        try:
            if not self._is_valid_apk():
                return None

            is_debuggable = self.apk.get_attribute_value(
                "application", "debuggable"
            ) == "true"

            if not is_debuggable:
                return False

            # Check if it has a signing certificate (release builds have certs)
            try:
                certs = self.apk.get_certificates()
                if certs and len(certs) > 0:
                    return True
            except Exception:
                pass

            return False
        except Exception as e:
            self.log.warning(f"Error in debuggable release test: {e}")
            return None

    def _get_dex_strings(self):
        """Get all string constants from DEX files."""
        all_strings = set()
        try:
            from androguard.core.dex import DEX
            for dex_data in (self.apk.get_all_dex() or []):
                try:
                    d = DEX(dex_data)
                    for s in d.get_strings():
                        if s:
                            all_strings.add(s)
                except Exception:
                    continue
        except Exception:
            pass
        return all_strings

    def _test_emulator_detection_strings(self):
        """Check for emulator detection patterns in DEX strings."""
        try:
            if not self._is_valid_apk():
                return None

            dex_strings = self._get_dex_strings()
            for indicator in EMULATOR_INDICATORS:
                for s in dex_strings:
                    if indicator in s:
                        return True
            return False
        except Exception as e:
            self.log.warning(f"Error in emulator detection test: {e}")
            return None

    def _test_debugger_detection(self):
        """Check for debugger detection API calls in DEX."""
        try:
            if not self._is_valid_apk():
                return None

            dex_strings = self._get_dex_strings()
            debugger_patterns = {
                "isDebuggerConnected",
                "waitingForDebugger",
                "Debug.isDebuggerConnected",
            }
            for pattern in debugger_patterns:
                for s in dex_strings:
                    if pattern in s:
                        return True
            return False
        except Exception as e:
            self.log.warning(f"Error in debugger detection test: {e}")
            return None

    def _test_root_detection(self):
        """Check for root detection patterns in DEX."""
        try:
            if not self._is_valid_apk():
                return None

            dex_strings = self._get_dex_strings()
            for indicator in ROOT_INDICATORS:
                for s in dex_strings:
                    if indicator in s:
                        return True
            return False
        except Exception as e:
            self.log.warning(f"Error in root detection test: {e}")
            return None

    def extract(self):
        if not self._is_valid_apk():
            self.log.error(f"Invalid APK for {self.hash.sha256}")
            return None

        self.test_results = APKInconsistencyTests(
            test_zip_bomb=self._test_zip_bomb(),
            test_zip_duplicate_entries=self._test_zip_duplicate_entries(),
            test_zip_path_traversal=self._test_zip_path_traversal(),
            test_zip_suspicious_timestamps=self._test_zip_suspicious_timestamps(),
            test_hidden_dex_files=self._test_hidden_dex_files(),
            test_manifest_component_mismatch=self._test_manifest_component_mismatch(),
            test_debuggable_release=self._test_debuggable_release(),
            test_emulator_detection_strings=self._test_emulator_detection_strings(),
            test_debugger_detection=self._test_debugger_detection(),
            test_root_detection=self._test_root_detection(),
        )
        return self.test_results

    def _bool_to_nullable(self, val):
        """Convert bool/None to ClickHouse Nullable(UInt8)."""
        if val is None:
            return None
        return int(val)

    def prepare_export_data(self, exporter_type: str) -> Any:
        if exporter_type == "ClickHouseExporter":
            if not self.test_results:
                return None

            current_time = datetime.now(timezone.utc)
            t = self.test_results

            data = [[
                self.sha256,
                self._bool_to_nullable(t.test_zip_bomb),
                self._bool_to_nullable(t.test_zip_duplicate_entries),
                self._bool_to_nullable(t.test_zip_path_traversal),
                self._bool_to_nullable(t.test_zip_suspicious_timestamps),
                self._bool_to_nullable(t.test_hidden_dex_files),
                self._bool_to_nullable(t.test_manifest_component_mismatch),
                self._bool_to_nullable(t.test_debuggable_release),
                self._bool_to_nullable(t.test_emulator_detection_strings),
                self._bool_to_nullable(t.test_debugger_detection),
                self._bool_to_nullable(t.test_root_detection),
                current_time,
            ]]

            column_names = [
                'sha256',
                'test_zip_bomb', 'test_zip_duplicate_entries',
                'test_zip_path_traversal', 'test_zip_suspicious_timestamps',
                'test_hidden_dex_files', 'test_manifest_component_mismatch',
                'test_debuggable_release', 'test_emulator_detection_strings',
                'test_debugger_detection', 'test_root_detection',
                'analysis_date',
            ]

            column_type_names = [
                'FixedString(64)',
                'Nullable(UInt8)', 'Nullable(UInt8)',
                'Nullable(UInt8)', 'Nullable(UInt8)',
                'Nullable(UInt8)', 'Nullable(UInt8)',
                'Nullable(UInt8)', 'Nullable(UInt8)',
                'Nullable(UInt8)', 'Nullable(UInt8)',
                "DateTime64(3, 'UTC')",
            ]

            return (data, column_names, column_type_names)

    def get_clickhouse_table(self) -> str:
        return "redb_apk_inconsistency_tests"