[
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published\n    by the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<https://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "META-INF/com/google/android/update-binary",
    "content": "#!/sbin/sh\n\n#################\n# Initialization\n#################\n\numask 022\n\n# echo before loading util_functions\nui_print() { echo \"$1\"; }\n\nrequire_new_magisk() {\n  ui_print \"*******************************\"\n  ui_print \" Please install Magisk v20.4+! \"\n  ui_print \"*******************************\"\n  exit 1\n}\n\n#########################\n# Load util_functions.sh\n#########################\n\nOUTFD=$2\nZIPFILE=$3\n\nmount /data 2>/dev/null\n\n[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk\n. /data/adb/magisk/util_functions.sh\n[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk\n\ninstall_module\nexit 0\n"
  },
  {
    "path": "META-INF/com/google/android/updater-script",
    "content": "#MAGISK\n"
  },
  {
    "path": "README.md",
    "content": "## A Magisk module for maximizing the digital audio fidelity by reducing jitters on audio outputs (USB DACs, Bluetooth a2dp, DLNA, etc.)\n\nSo many music lovers abandon audio quality on smart phones and DAP's by believing its causes are delivered from analog components. However, the most crucial cuase of it is actually less than 50 Hz jitter (i.e., the standard deviation of actual audio data rate with a low-pass filter; usually converting into time-domain) on digital audio outputs that generates very short reverb or foggy sound like distortion on analog audio outputs. Although larger than 50 Hz (shorter than 20 msec. interval) jitter can be easily reduced under the hearable level by a PLL (Phase Locked Loop) in DAC's, the other (especially less than 10 Hz or longer than 100 msec. interval) modulates and distorts audio outputs by fluctuating the master clock in a DAC through the PLL. For further explanation, see my another magisk module [\"Audio jitter silencer\"](https://github.com/Magisk-Modules-Alt-Repo/audio-jitter-silencer).\n\nFor maximizing the audio fidelity, this module reduces less than 50 Hz (longer than 20 msec interval) jitters on digital audio outputs by optimizing kenel tunables (CPU & GPU  governors, thermal control, CPU hotplug, I/O scheduler, Virtual memory), Selinux mode, WIFI parameters, etc. as follows,\n\n* For Reducing Jitters:\n    <ol type=\"1\">\n    <li>CPU & GPU governor<br>\n        change their governors to \"performance\" (additionally fixed at the max frequency).</li>\n    <li>I/O scheduler<br>\n        scheduler preference: \"deadline\" (\"cfq\" if \"deadline\" doesn't exist); optimize its tunables.</li>\n    <li>Virtual memory<br>\n        change \"swappiness\" to 0%, \"laptop mode\" to 1, etc.</li>\n    <li>Thermal Control<br>\n        disable Qcomm \"core control\" and stop thermal servers (e.g., \"thermald\", \"thermal-engine\", \"thermal\", \"mi_thermald\", etc.).</li>\n    <li>CPU hotplug<br>\n        stop \"MPDecision\" server (if exists).</li>\n    <li>Disable MediaTek EAS+ scheduler<br>\n        ```echo '1' > \"/proc/cpufreq/cpufreq_sched_disable\"```</li>\n    <li>Doze<br>\n        stop the Android doze server.</li>\n    <li>Selinux mode<br>\n        change the mode to \"permissive\".</li>\n    <li>Adaptive battery saving features<br>\n        disable wifi suspend optimizations, the adaptive battery management, the adaptive charging management and the adaptive connectivity management.</li>\n    <li>Kill effect chains<br>\n        force ignoring ```/vendor/etc/audio_effects.xml``` to disable equalizers, virtualizers, reverb's, visualizer, echo cancelers, automatic gain controls, etc. (very few vulnerable equalizers may crash by this killing, but please ignore it)</li>\n    <li>Disable the android built-in spatial audio feature (A13 or higher; especially Tensor devices)<br/>\n         bypass an otiose audio pass.</li>\n    <li>Disable aocd service<br/>\n        disable \"aocd server\" generating significant jitter on audio outputs, esp. on USB.</li>\n    <li>Disable pre-installed Moto Dolby and Digital Wellbeing features<br/>\n        hide their apps (no modifications); please manually uninstall Digital Wellbeing app if remaining as a usual app.</li>\n    <li>Disable Logd service<br/>\n        disable \"logd server\", \"traced server\" and \"traced_probes server\" interfering jitter on audio outputs.</li>\n    <li>Disable camera service<br/>\n        disable \"camera server\" interfering jitter on audio outputs.</li>\n    </ol>\n<br/>\n\n* For Convenience and Audio Quality:\n    <ol type=\"1\">\n    <li> Disable DRC (Dynamic Range Control, i.e., a kind of compression)<br/>\n        modify ```/vendor/etc/*/audio_policy_configuration*.xml``` to disable DRC if DRC has been enabled on a stock firmware.</li>\n    <li>Volume steps<br/>\n        change the number of steps in media volume to 100 steps (0.4~0.7dB per step).</li>\n    <li>Disables the sound dose feature of the mixer<br/>\n        Not to defocuse the shape of sound images, also reduce jitter.</li>\n    <li>Resampling quality<br/>\n        change AudioFlinger's resampling quality from the AOSP standard one (stop band attenuation 90dB & cut off 100% of the Nyquist frequency & half filter length 32) to a very mastering quality (194dB & 98% & 520, 179dB & 99% & 408, 167dB & 106% & 368 or 160db & 91% & 480 (or 320 for low performance devices), i.e., no resampling distortion in a real sense even though the 160dB targeted attenuation is not accomplished in the AOSP implementation). However, install <a href=\"https://github.com/Magisk-Modules-Alt-Repo/resampling-for-cheapies\">\"Resampling for cheapies\" module</a> together to override these resampling settings if you intend to use LDAC bluetooth earphones or DAC's under $30.</li>\n    <li>Adjust a USB transfer period of the USB HAL driver (not the Qcomm hardware offload USB driver, but including ones of Tensor and MTK devices)<br/>\n        for directly reducing the jitter of a PLL in a DAC (even in an asynchronous mode); Use <a href=\"https://github.com/yzyhk904/USB_SampleRate_Changer\">\"USB_SampleRate_Changer\"</a> or <a href=\"https://github.com/Magisk-Modules-Alt-Repo/audio-samplerate-changer\">\"Audio Samplerate Changer\"</a> to switch from the usual hardware offload USB driver to the USB HAL one.</li>\n    <li>Set an audio scheduling tunable \"vendor.audio.adm.buffering.ms\" \"2\"<br/>\n         to reduce jitter on all audio outputs.</li>\n    <li>Nullify volume listener libraries in \"soundfx\" folders  for disabling slight compression (maybe a peak limiter only on Qcomm devices).</li>\n    <li>Set 192kHz & 32bit mode (max., but automatic for lower capability DAC's) for all the USB audio outputs (including non- Hi-Res audio tracks) of Tensor devices exceptionally<br/>\n         because Tensor devices lower audio quality extremely for lower sample rates and bit depths, though the quality of in-DAC over-sampling filters is much worse than that of the re-sampling filter used by this module and the filters lower the quality particularly for input of lower sample rates as usual.\n</li>\n    </ol>\n<br/><br/>\n\n* Don't forget to install [\"Audio jitter silencer\"](https://github.com/Magisk-Modules-Alt-Repo/audio-jitter-silencer) together and uninstall \"Digital Wellbeing\" app (for reducing very large jitters which this module cannot reduce by itself)! And uninstall [\"Audio misc. settings\"](https://github.com/Magisk-Modules-Alt-Repo/audio-misc-settings) and [\"DRC remover\"](https://github.com/Magisk-Modules-Alt-Repo/drc-remover) if they have already been installed, because all their functions are included in this module. Additionally if your device uses a Tensor SoC, uninstall [\"USB Samplerate Unlocker\"](https://github.com/Magisk-Modules-Alt-Repo/usb-samplerate-unlocker) for the same reason.\n\n* Don't use Am@zon music using a much worse internal re-sampler which bypasses the mastering quality re-sampling in the OS mixer (audioFlinger). Other music streaming services don't use such an internal re-sampler, as far as I know.\n\n* This module has been tested on LineageOS and crDroid ROM's, and phh GSI's (Android 10 ~ 16, Qualcomm & MediaTek SoC, and Arm32 & Arm64 combinations). For users of Motorola and Xiaomi stock ROM's, try to install a GSI through DSU and this module together once, then you could know how much the ROM's degrade audio quality probably for adapting to regulations.\n\n* Note: Entry class USB DAC's usually adopt an interface chip communicating with the adaptive mode or the synchronous one defined in the USB audio standard. As in these modes an Android host controller sends audio sampling rate clock signals to the DAC, jitter generated at the host side affects the audio quality of the DAC tremendously. Higher class DAC's communicate with the asynchronous mode (also defined in the standard) to a host controller, but they actually use a PLL to reduce jitter from the host not to stutter even in heavy jitter situations. As this result, they behave as the adaptive mode with a feedback loop to dynamically adjust the host side sampling clock signals while referring a DAC side clock in a real sense, so even with asynchronous mode they are more or less affected by host side jitter. You can see the mode of your USB DAC by opening \"/proc/asound/card1/stream0\" on your phone while playing music. Please see a word in parentheses at \"Endpoint:\" lines; \"SYNC\", \"ADAPTIVE\" or \"ASYNC\" means that your DAC uses \"synchronous\", \"adaptive\" or \"asynchronous\" mode to communicate to your phone, respectively. Moreover, almost all audio peripherals, e.g., bluetooth earphones, internal DAC's, network audio devices have a PLL in themselves and are affected by host side jitter for the same reason.\n\n* I recommend expert users not to install [\"Audio jitter silencer\"](https://github.com/Magisk-Modules-Alt-Repo/audio-jitter-silencer), but manually to disable \"Manage apps automatically\" in \"Battery manager\" (or \"Adaptive battery\" of \"Adaptive preferences\") in the battery section (needless to say, don't enable battery savers, performance limiters and the like), turn off \"Adaptive connectivity\" in the Network & internet section (if exists), and changing \"Battery optimization\" from \"Optimize\" to \"Don't optimize\" (or change \"Battery usage\" from \"Optimized\" to \"Unrestricted\") for following app's manually through the settings UI of Android OS (to lower less than 10Hz jitter making extremely short reverb or foggy sound like distortion) even though disabling the Android doze itself: music (streaming) player apps, their licensing apps (if exist), \"AirMusic\" (if exists), \"AirMusic  Recording Service\" (system app; if exists), equalizer apps (if exist), \"Bluetooth\" (system app), \"Bluetooth MIDI Service\" (system app), \"MTP Host\" (system app), \"NFC Service\" (system app; if exists), \"Magisk\" (if exists), System WebView apps (system app), Browser apps, \"PhhTrebleApp\" (system app; if exists), \"Android Services Library\" (system app), \"Android Shared Library\" (system app), \"Android System\" (system app), \"System UI\" (system app), \"Input Devices\" (system app), {Gesture, 3 Button, 2  Button} Navigation Bar apps (which you are using only; system app), \"crDroid System\" (system app; if exists), \"LineageOS System\" (system app; if exists), launcher app, \"Google Play Store\" (system app), \"Google Play services\" (system app), \"Styles & wallpaper\" or the like (system app), {Lineage, crDroid, Arrow, etc.} themes app (system app; if exists),  \"AOSP panel\" (system app; if exists), \"OmniJaws\" (system app; if exists), \"OmniStyle\" (system app; if exists), \"Active Edge Service\" (system app; if exists), \"Android Device Security Module\" (system app; if exists), \"Call Management\" (system app; if exists), \"Phone\" (system app; if exists), \"Phone Calls\" (system app; if exists), \"Phone Services\" (system app; if exists), \"Phone and Messaging Storage\" (system app; if exists), \"Storage Manager\" (system app), \"Default\" (system app; if exists), \"Default StatusBar\" (system app; if exists), \"Wfd Service\" (system app; if exists), \"Wallpaper\" or the like (system app), \"Adreno Graphics Drivers\" (system app; if exists), \"com.android.providers.media\" (system app), \"Files by Google\" (system app; if exists), \"Google Play Services for AR\" (system app; if exists), \"Google Services Framework\" (system app), \"Waterfall cutout\" (system app), \"Punch Hole cutout\" (system app), \"Network Manager\" (system app), \"Companion Device Manager\" (system app), \"Intent Filter Verification Service\" (system app), \"Calendar\", camera apps, keyboard app, kernel adiutors (if exist), etc. And uninstall \"Digital Wellbeing\" (system app; if it exists) itself or change \"Battery usage\" from \"Optimized\" to \"Restricted\" (this is very harmful for audio like camera servers). Because \"Audio jitter silencer\" isn't complete and needs some maintenance after its installation.\n\n* See also my companion script [\"USB_SampleRate_Changer\"](https://github.com/yzyhk904/USB_SampleRate_Changer) to change the sample rate of the USB (HAL) audio class driver and a 3.5mm jack on the fly like Bluetooth LDAC or Windows mixer to enjoy high resolution sound or to reduce resampling distortion (actually pre-echo, ringing and intermodulation) ultimately, and its simplified Magisk module version [\"Audio Samplerate Changer\"](https://github.com/Magisk-Modules-Alt-Repo/audio-samplerate-changer).\n\n* Tips: If you use \"AirMusic\" to transmit audio data, I recommend setting around 4599 msec additional delay to reduce jitter distortion on the AirMusic panel to display target device(s).\n\n* Note1: Please remember that this module will stop the thermal control (including CPU core controls, CPU hotplugs and thermal services), the \"logd server\" and the \"camera server\" (interfering jitter on audio outputs), disable SELinux enforcing mode and doze (battery saver while idling) on your device. If you like to enable these features, modify variables in \"service.sh\", respectively. Especially, note that the \"Youtube\" app became recetly to need the camera server for launching for some unexplained reason.\n\n* Note2: If you prefer (too sensitive?) Bluetooth earphones to wired headphones and DLNA renderers, set \"DisableClearestTone\" variable to be \"yes\" in \"service.sh\".\n\n* Appendix A. Examples of Re-sampling Parameters:\n    \n    \n    | Stop band attenuation (dB) | Half filter length | Cut-off (%) | Stop band (%) | Memo |\n    | ---: | ---: | ---: | ---: | ---- |\n    | 90 | 32 | 100 | | AOSP default |\n    | This mod. parameters: | - | - | - | - |\n    | 159 | 320 | 92 | | Low Performance devices under A12 |\n    | 159 | 480 | 92 | | High Performance devices under A12 |\n    | 165 | 360 | | 104 | Low Performance devices for A12 and later |\n    | 179 | 408 | | 99 | High Performance devices for A12 and later, and Galaxy S4 |\n    | 194 | 520 | | 98 | Very High Performance devices |\n    | External examples: | - | - | - | - |\n    | 100 | 29 | (91) | 109 | AK4493 (Sharp roll-off N-fold over-sampling) |\n    | 150 | 42 | (91) | 109 | AK4191EQ (Sharp roll-off N-fold over-sampling) |\n    | 120 | 35 | (97) | 110 | ES9038PRO (Fast roll-off N-fold over-sampling) |\n    | vary 50 ~ 118 | 34 | 96 | (398) | ES9039PRO (Fast roll-off N-fold over-sampling) |\n    | 110 | 40 | (96) | 109 | CS43131 (Fast roll-off N-fold over-sampling) |\n    | 110 | 40 | (96) | 109 | CS43198 (Fast roll-off N-fold over-sampling) |\n    | 98 | 130 | 98.5 | | MacOS Leopard (guess) |\n    | 159 | 240 | | 99 | iZotope, No-Alias (guess) |\n    | 100 | 64 | | 99 | SoX HQ linear phase (guess) |\n    | 170 | 520 | | 99 | SoX VHQ linear phase (guess) |\n\n<br/>\n<br/>\n\n## DISCLAIMER\n\n* I am not responsible for any damage that may occur to your device, so it is your own choice whether to attempt this module or not.\n\n##\n"
  },
  {
    "path": "changelog.md",
    "content": "## Change logs\n\n# v2.5.16\n* Tuned I/O scheduling parameters for POCO F6, POCO F3, Motorola G54's and Pixel 6's \n\n# v2.5.15\n* Added a USB DAC workaround for A17 beta3 of Pixel 6's for greater than 192 kHz samplerates; they have a bug that cannot detect any appropriate sample rate and depth of a USB DAC, but they can or may work for USB DAC's having a XMOS digital interface chip if specifying any sample rate and depth\n\n# v2.5.14\n* Optimized I/O scheduler tunables for MTK Dimensity\n* Changed the USB audio driver for Pixel 6's so as to use the USB HAL audio driver instead of the USB audio offload driver\n* Changed re-sampling parameters for Pixel 6's to use the same for cheapies\n* Fixed a bug that greater than 96 kHz sample rates had not been unlocked\n\n# v2.5.13\n* Nullifying the volume listener for no compressing audio (maybe a peak limiter) on Motorola devices\n* Changed an error message for no Magisk mirrors\n* Stop AOCXD daemon on Tensor devices\n\n# v2.5.12\n* Tuned for POCO F3 and other \"kona\" board devices by adjusteding their core control parameters\n* Improved and fixed GPU boosting for recent Qcomm and Mtk SoC's\n* Fixed the audio policy configuration template for Tensor devices\n\n# v2.5.11\n* Tuned for POCO F6 (optimized for the ISIS kernel)\n* Tuned for POCO F6 (optimized for the stock kernel, but not for the ISIS kernel)\n* Tuned for POCO F3 (Android 15)\n* Fixed for InfiR kernel about VM tunables\n\n# v2.5.10\n* Adapted to run with my new module \"Audio Samplerate Changer\"\n\n# v2.5.9\n* Optimized I/O scheduler tunables for POCO F6\n* Added a support for Tensor G4 (zumapro)\n* Tuned I/O scheduler tunables especially for \"resampling-for-cheapies\"\n* Fixed an always 192 kHz USB  audio output mode for Pixel 8 and 9 series\n* Changed the USB offload driver configuration of Tensor devices to be automatic max. detection\n* Changed a mirroring warning for incompatible Magisk v28.0; Please use [Compatible magisk-mirroring](https://github.com/Magisk-Modules-Alt-Repo/compatible-magisk-mirroring) and Magisk v28.0 together\n* Added better re-sampling parameters for very high performance devices\n\n# v2.5.8\n* Added disabling Dolby control support for USB DAC's on HyperOS not to reboot\n* Excluded \"MotorolaSettingsProvider\" on Motorala devices only for avoiding their bootloop\n* Changed the USB period_us from 2250 usec to 2000 usec to optimize for 48 kHz Opus tracks (recent majority)\n* Adjusted jitter optimizations and others for YTM's format change from AAC (141; 44.1 kHz & 256 kbps cbr stereo) to Opus (774; 48 kHz & 256 kbps vbr stereo)\n* Added new props \"audio.safemedia.force=false\" and \"audio.safemedia.csd.force=false\"\n* Fixed above disabling Dolby control support (manufacturer mismatch)\n\n# v2.5.7\n* Changed head ahead buffer sizes from 16960 kB to 17000 kB to reduce I/O jitter\n* Adjusted NrRequests of I/O scheduling\n* Changed dirty_ratio and dirty_background_ration to be 100 to reduce jitter\n* Adjusted re-sampling parameters for old devices\n* Changed adjustSoC_mq for A14 and later clover not to round I/O parameters\n* Adjusted cfq I/O parameters for SDM69x devices\n* Changed the way how to get the actual audio policy file path in the service phase because some ROM's fail to execute \"dumpsys\" in the phase\n\n# v2.5.6\n* Added \"compatible Magisk-mirroring\" message for incompatible Magisk variants\n\n# v2.5.5\n* Tuned the USB period size for SDM845 devices (2500 usec to 2250 usec)\n* Tuned the USB period size for other devices (to 2250 usec)\n* Fixed logically wrong selinux prop settings (no meaning for magisk's magic mount mechanism)\n* Added checking incompatible Magisk variants\n\n# v2.5.4\n* Tuned the USB period size for Tensor devices (2625 usec to 2250 usec)\n* Fixed for Pixel 8's\n\n# v2.5.3\n* Changed the re-sampling parameters for Galaxy S4 to the general purpose ones (optimized for 3.5mm jack; not USB DAC's)\n* Reduced I/O scheduling jitter on Tensor and SDM660 devices\n* Reduced CFQ I/O scheduling jitter on Qcomm devices\n\n# v2.5.2\n* Tuned tunables of I/O scheduler\n* Added warning messages for unneeded magisk modules\n\n# v2.5.1\n* Stopped Tensor device's AOC daemon for reducing significant jitter\n* Optimized \"extras/jitter-reducer.sh\" for reducing I/O scheduling jitter on Tensor devices\n\n# v2.5.0\n* Optimized for Tensor devices by tuning GPU & I/O scheduling and replacing their stock audio policy configuration\n* Hid preinstalled \"Digital Wellbeing\" feature for reducing significant jitter (please uninstall this manually if remaining as a usual app)\n\n# v2.4.2\n* Optimized \"extras/jitter-reducer.sh\" for reducing I/O scheduling jitter\n* \"extras/jitter-reducer.sh\" now confirms and sets the cpu scaling max freq to its available max (sometimes the scaling max freq has been lowered before by a controller on some devices)\n\n# v2.4.1\n* Added support for ColorOS (experimental)\n\n# v2.4.0\n* Fixed some SELinux related bugs for Magisk v26.0's new magic mount feature\n* Diabled pre-installed Moto Dolby features for reducing large jitter caused by them\n\n# v2.3.2\n* Added support for Tensor devices to bypass their spatial audio feature for reducing jitter distortion\n\n# v2.3.1\n* Added support for MTK A12 vendor primary audio HAL for reducing USB audio jitter\n* Fixed a bug of DRC removing on phh GSI's (umounted in the boot process of phh GSI's)\n\n# v2.3.0\n* Nullified volume listener libraries in \"soundfx\" folders for disabling slight compression (maybe a peak limiter only on Qcomm devices).\nTuned for \"mq-deadline\", \"kyber\" and \"none\" I/O scheduler (latest kernel common schedulers?)\n* Added support to the Nyx kernel 4.19\n* Restructured source codes to be sharable with the jitter-reducer.sh in USB_SampleRate_Changer, audio-misc-settings and drc-remover\n\n# v2.2.1\n* Adjusted a USB transfer period of the USB HAL driver for reducing jitter\n\n# v2.2.0\n* Tuned kernel tunables by assuming an audio scheduling tunable \"vendor.audio.adm.buffering.ms\" to be \"2\"\n* Adjusted a USB period to reduce jitter\n\n# v2.1.8\n* Disabled the Android doze system itself for reducing jitter considerably even though battery optimizations of app's are effective\n* Tuned kernel tunables for SDM 8 series, MTK Dimensity's and Galaxy S4 (LineageOS 18.1)\n\n# v2.1.7\n* Changed resampling parameters for A12 or later (not having an aliasing processing bug)\n* Tuned I/O scheduler tunables\n\n# v2.1.6\n* Improved tunable values of the deadline I/O scheduler\n\n# v2.1.5\n* Fixed a bug that DRC was not detected when updating from an old module\n* Tuned parameters of the I/O scheduler\n\n# v2.1.4\n* Resampling quality changes from attenuation 140dB & length 320 to 160dB & 480\n\n# v2.1.2\n* Improved AudioFlinger's resampling quality (stopband 140dB, cutoff 91%)\n\n# v2.1.1\n* Enhanced the vm jitter reducer to handle \"swap_ratio\" and \"swap_ratio_enable\" for Snapdradons\n* Optimized tunables of the I/O jitter reducer\n* Added LICENSE\n\n# v2.1.0\n* The GPU frequency became to be fixed really at the max frequency for Qualcomm Soc and MediaTek SoC\n* I/O scheduler tunables were optimized for audio clearness\n\n# v2.0.5\n* nr_requests was optimized\n\n# v2.0.4\n* Optimized I/O jitter reducer and fixed a bug disabling effects framework under PHH GSI's\n\n# v2.0.2\n* I/O tunables improved\n\n# v2.0.1\n* Initial public release\n\n# v2.0.0\n* Initial public pre-release\n* Supported audio policy configuration XML files for \"disable a2dp offload\", \"force-disable a2dp offload\", and so on\n\n# v1.4.0\n* Moved scattered functions into \"functions.sh\" together, and treated IO Schedulers more rigorously\n\n# v1.3.0\n* Realme support (/proc/sys/vm/direct_swappiness)\n\n# v1.2.0\n* Stopped camera servers interfering in jitters on audio outputs, and reformatted source codes\n\n# v1.1.0\n* Stopped the EAS+ scheduling feature for MediaTek CPUs\n\n# v1.0.0\n* Initial limited release\n\n##\n"
  },
  {
    "path": "customize-functions.sh",
    "content": "#!/system/bin/sh\n\n# Check whether Magisk magic mount compatible or not\nfunction isMagiskMountCompatible()\n{\n    local tmp=\"$(magisk --path)\"\n    if [ -z \"$tmp\" ]; then\n        return 1\n    elif [ -d \"${tmp}/.magisk/mirror/vendor\" ]; then\n        return 0\n    else\n        return 1\n    fi\n}\n\n# Get the active audio policy configuration fille from the audioserever\nfunction getActivePolicyFile()\n{\n    dumpsys media.audio_policy | awk ' \n        /^ Config source: / {\n            print $3\n        }' \n}\n\n# Extract the file name of an audio_policy_volumes.xml\nfunction getVolumeFile()\n{\n    if [ $# -gt 0  -a  -r \"$1\" ]; then\n        grep -m 1 -e '<xi:include[[:space:]]*href[[:space:]]*=[[:space:]]*\".*audio_policy_volumes.*\\.xml\"' \"$1\" | awk -F '\"' '{ print $2 }'\n    else\n        return 1\n    fi\n}\n\n# Extract the file name of a default_volume_tables.xml\nfunction getDefaultVolumeFile()\n{\n    if [ $# -gt 0  -a  -r \"$1\" ]; then\n        grep -m 1 -e '<xi:include[[:space:]]*href[[:space:]]*=[[:space:]]*\".*default_volume_tables.*\\.xml\"' \"$1\" | awk -F '\"' '{ print $2 }'\n    else\n        return 1\n    fi\n}\n\nfunction stopDRC()\n{\n    # stopDRC has two args specifying a main audio policy configuration XML file (eg. audio_policy_configuration.xml) and its dummy one to be overridden\n\n     if [ $# -eq 2  -a  -r \"$1\"  -a  -w \"$2\" ]; then\n        # Copy and override an original audio_policy_configuration.xml to its dummy file\n        cp -f \"$1\" \"$2\"\n        # Change audio_policy_configuration.xml file to remove DRC\n        sed -i 's/speaker_drc_enabled[:space:]*=[:space:]*\"true\"/speaker_drc_enabled=\"false\"/' \"$2\"\n    fi\n}\n\n# Get the actual audio configuration XML file name, even for Xiaomi, OnePlus, etc.  stock devices\n#    that may overlay another file on the dummy mount point file\n\nfunction getActualConfigXML()\n{\n    if [ $# -eq 1 ]; then\n        local dir=${1%/*}\n        local fname=${1##*/}\n        local sname=${fname%.*}\n        \n        if [ -r \"${dir}/${sname}_sec.xml\" ]; then\n            echo \"${dir}/${sname}_sec.xml\"\n        elif [ -e \"${dir}_qssi\"  -a  -r \"${dir}_qssi/${fname}\" ]; then\n            # OnePlus stock pattern\n            echo \"${dir}_qssi/${fname}\"\n        elif [ \"${dir##*/}\"  = \"sku_`getprop ro.board.platform`\"  -a  -r \"${dir%/*}/${fname}\" ]; then\n            # OnePlus stock pattern2\n            echo \"${dir%/*}/${fname}\"\n        elif [ -r \"${dir}/audio/${fname}\" ]; then\n            # Xiaomi stock pattern\n            echo \"${dir}/audio/${fname}\"\n        elif [ -r \"${dir}/${sname}_base.xml\" ]; then\n            echo \"${dir}/${sname}_base.xml\"\n        else\n            echo \"$1\"\n        fi\n    fi\n}\n\nfunction toHexLE()\n{\n    if [ $# -eq 1  -a  $1 -gt 0 ]; then\n        printf \"%2.2x%2.2x%2.2x%2.2x\" $(( $1 % 256 ))  $(( $1 / 256 % 256 ))  $(( $1 / 256 / 256 % 256 ))  $(( $1 / 256 / 256 / 256 % 256 ))\n        return 0\n    else\n        return 1\n    fi\n}\n\nfunction toHexLineLE()\n{\n    if [ $# -eq 1 ]; then\n        local i\n        for i in $1; do\n            toHexLE $i\n        done\n        return 0\n    else\n        return 1\n    fi\n}\n\nfunction toHexString()\n{\n    if [ $# -ge 1 ]; then\n        local tmp\n        tmp=`echo -n \"$1\" | xxd -p | tr -d ' \\n'`\n        if [ $# -eq 2 ]; then\n            if [ ${#tmp} -ge $2 ]; then\n                echo -n ${tmp:0:$2}\n            else\n                local strt=`expr ${#tmp} + 1`\n                echo -n \"$tmp\"\n                for i in `seq $strt $2` ; do\n                    echo -n \"0\"\n                done\n            fi\n        else\n            echo -n \"$tmp\"\n        fi\n    else\n      return 1\n    fi\n}\n\n# Patch libalsautils.so and audio_usb_aoc.so (Tensor's offload USB driver) to map a property string to another\n#   arg1: original libalsautils.so file;  arg2: patched libalsautils.so file; \nfunction patchMapProperty()\n{\n    local orig_prop='ro.audio.usb.period_us'\n    local new_prop='vendor.audio.usb.perio'\n    \n    if [ $# -eq 2  -a  -r \"$1\" ]; then\n      local pat1=`toHexString \"$orig_prop\"`\n      local pat2=`toHexString \"$new_prop\" ${#pat1}`\n      \n      xxd -p <\"$1\" | tr -d ' \\n' | sed -e \"s/$pat1/$pat2/\" \\\n          | awk 'BEGIN {\n                 foldWidth=60\n                 getline buf\n                 len=length(buf)\n                 for (i=1; i <= len; i+=foldWidth) {\n                     if (i + foldWidth - 1 <= len)\n                         print substr(buf, i, foldWidth)\n                     else\n                         print substr(buf, i, len)\n                 }\n                 exit\n             }'  \\\n         | xxd -r -p >\"$2\"\n      return $?\n    else\n      return 1\n    fi\n}\n\n# Patch libalsautils.so to clear the 96kHz lock of USB audio class drivers\n#   arg1: original libalsautils.so file;  arg2: patched libalsautils.so file; \n#     optional arg3: \"max\" (clearing upto 768kHz), \"full\" (clearing upto 386kHz), \"default\" or others (clearing upto 192kHz)\nfunction patchClearLock()\n{\n    local orig_rates='96000  88200  192000  176400  48000  44100  32000  24000  22050  16000  12000  11025  8000'\n    local new_rates='192000  176400  96000  88200  48000  44100  32000  24000  22050  16000  12000  11025  8000'\n    \n    if [ $# -ge 2  -a  -r \"$1\" ]; then\n        if [ $# -gt 2 ]; then\n            case \"$3\" in\n                \"max\" )\n                    new_rates='768000  705600  384000  352800  192000  176400  96000  88200  48000  44100  24000  16000  8000'\n                    ;;\n                \"full\" )\n                    new_rates='384000  352800  192000  176400  96000  88200  48000  44100  32000  24000  16000  12000  8000'\n                    ;;\n                \"default\" | * )\n                    ;;\n          esac\n      fi\n\n        local pat1=`toHexLineLE \"$orig_rates\"`\n        local pat2=`toHexLineLE \"$new_rates\"`\n      \n        # A workaroud for a SELinux permission bug on Android 12\n        local prop1=`toHexString \"ro.audio.usb.period_us\"`\n        local prop2=`toHexString \"vendor.audio.usb.perio\"`\n      \n        xxd -p <\"$1\" | tr -d ' \\n' | sed -e \"s/$prop1/$prop2/\" -e \"s/$pat1/$pat2/\" \\\n            | awk 'BEGIN {\n                foldWidth=60\n                getline buf\n                len=length(buf)\n                for (i=1; i <= len; i+=foldWidth) {\n                    if (i + foldWidth - 1 <= len)\n                        print substr(buf, i, foldWidth)\n                    else\n                        print substr(buf, i, len)\n                }\n                exit\n              }'  \\\n            | xxd -r -p >\"$2\"\n            \n        return $?\n        \n    else\n        \n        return 1\n    fi\n}\n\n# Patch audio_usb_aoc.so file to clear the 192kHz lock of USB audio class Tensor offload drivers\n#   arg1: original audio_usb_aoc.so file;  arg2: patched audio_usb_aoc.so file; \nfunction patchClearTensorOffloadLock()\n{\n    local orig_rates='192000  96000  48000  44100  32000  24000  22050  16000  12000  11025  8000'\n    local new_rates='768000  705600  384000  352800  192000  176400  96000  88200  48000  44100  8000'\n\n    if [ $# -ge 2  -a  -r \"$1\" ]; then\n        local pat1=`toHexLineLE \"$orig_rates\"`\n        local pat2=`toHexLineLE \"$new_rates\"`\n\n        # A workaroud for a SELinux permission bug on Android 12\n        local prop1=`toHexString \"ro.audio.usb.period_us\"`\n        local prop2=`toHexString \"vendor.audio.usb.perio\"`\n\n        # sample rate limiter at 192kHz\n        local ul1=`toHexLineLE \"192000\"`\n        local ul2=`toHexLineLE \"768000\"`\n          \n#        Don't work yet. Need more inviestigations\n#        xxd -p <\"$1\" | tr -d ' \\n' | sed -e \"s/$prop1/$prop2/\" -e \"s/$ul1/$ul2/\" -e \"s/$pat1/$pat2/\" \\\n        xxd -p <\"$1\" | tr -d ' \\n' | sed -e \"s/$prop1/$prop2/\" \\\n            | awk 'BEGIN {\n                 foldWidth=60\n                 getline buf\n                 len=length(buf)\n                 for (i=1; i <= len; i+=foldWidth) {\n                     if (i + foldWidth - 1 <= len)\n                         print substr(buf, i, foldWidth)\n                     else\n                         print substr(buf, i, len)\n                 }\n                 exit\n               }'  \\\n             | xxd -r -p >\"$2\"\n             \n        return $?\n        \n    else\n        return 1\n    fi\n}\n\nfunction makeLibraries()\n{\n    local MAGISKPATH=\"$(magisk --path)\"\n    local d lname\n    \n    for d in \"lib\" \"lib64\"; do\n        for lname in \"libalsautils.so\" \"libalsautilsv2.so\" \"audio_usb_aoc.so\"; do\n            if [ -r \"${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}\" ]; then\n                mkdir -p \"${MODPATH}/system/vendor/${d}\"\n                patchMapProperty \"${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}\" \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chmod 644 \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chcon u:object_r:vendor_file:s0 \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chown root:root \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chmod -R a+rX \"${MODPATH}/system/vendor/${d}\"\n                if [ -z \"${REPLACEFILES}\" ]; then\n                    REPLACEFILES=\"/system/vendor/${d}/${lname}\"\n                else\n                    REPLACEFILES=\"${REPLACEFILES} /system/vendor/${d}/${lname}\"\n                fi\n            fi\n        done        \n    done\n    \n}\n\nfunction makeUnlockedLibraries()\n{\n    local MAGISKPATH=\"$(magisk --path)\"\n    local d lname\n    \n    for d in \"lib\" \"lib64\"; do\n        for lname in \"libalsautils.so\" \"libalsautilsv2.so\"; do\n            if [ -r \"${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}\" ]; then\n                mkdir -p \"${MODPATH}/system/vendor/${d}\"\n                patchClearLock \"${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}\" \"${MODPATH}/system/vendor/${d}/${lname}\" \"max\"\n                chmod 644 \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chcon u:object_r:vendor_file:s0 \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chown root:root \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chmod -R a+rX \"${MODPATH}/system/vendor/${d}\"\n                if [ -z \"${REPLACEFILES}\" ]; then\n                    REPLACEFILES=\"/system/vendor/${d}/${lname}\"\n                else\n                    REPLACEFILES=\"${REPLACEFILES} /system/vendor/${d}/${lname}\"\n                fi\n            fi\n        done        \n        for lname in \"audio_usb_aoc.so\"; do\n            if [ -r \"${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}\" ]; then\n                mkdir -p \"${MODPATH}/system/vendor/${d}\"\n                patchClearTensorOffloadLock \"${MAGISKPATH}/.magisk/mirror/vendor/${d}/${lname}\" \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chmod 644 \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chcon u:object_r:vendor_file:s0 \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chown root:root \"${MODPATH}/system/vendor/${d}/${lname}\"\n                chmod -R a+rX \"${MODPATH}/system/vendor/${d}\"\n                if [ -z \"${REPLACEFILES}\" ]; then\n                    REPLACEFILES=\"/system/vendor/${d}/${lname}\"\n                else\n                    REPLACEFILES=\"${REPLACEFILES} /system/vendor/${d}/${lname}\"\n                fi\n            fi\n        done        \n    done\n    \n}\n\n# Replace system property values for old Androids and some low performance SoC's\n\nfunction loosenedMessage()\n{\n    local freq=\"96kHz\"\n    if [ $# -gt 0 ]; then\n        freq=\"$1\"\n    fi\n    \n    ui_print \"\"\n    ui_print \"****************************************************************\"\n    ui_print \" Loosened the USB jitter level for more than $freq USB outputs! \"\n    ui_print \"   (\\\"USB Samplerate Unlocker\\\" was detected) \"\n    ui_print \"****************************************************************\"\n    ui_print \"\"\n}\n\nfunction replaceSystemProps_VHPerf()\n{\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop-workaround\"\n   \n    sed -i \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=.*$/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=44100/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.stopband=.*$/ro\\.audio\\.resampler\\.psd\\.stopband=194/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.halflength=.*$/ro\\.audio\\.resampler\\.psd\\.halflength=520/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.tbwcheat=.*$/ro\\.audio\\.resampler\\.psd\\.tbwcheat=98/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=.*$/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=44100/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.stopband=.*$/ro\\.audio\\.resampler\\.psd\\.stopband=194/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.halflength=.*$/ro\\.audio\\.resampler\\.psd\\.halflength=520/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.tbwcheat=.*$/ro\\.audio\\.resampler\\.psd\\.tbwcheat=98/' \\\n            \"$MODPATH/system.prop-workaround\"\n}\n\nfunction replaceSystemProps_Old()\n{\n    if [ -e \"${MODPATH%/*/*}/modules/usb-samplerate-unlocker\"  -o  -e \"${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker\" ]; then\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2250/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2250/' \\\n                \"$MODPATH/system.prop\"\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2250/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2250/' \\\n                \"$MODPATH/system.prop-workaround\"\n        \n        loosenedMessage\n        \n    else\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2250/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2250/' \\\n                \"$MODPATH/system.prop\"\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2250/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2250/' \\\n                \"$MODPATH/system.prop-workaround\"\n    \n    fi\n    \n    sed -i \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=.*$/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=48000/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.stopband=.*$/ro\\.audio\\.resampler\\.psd\\.stopband=165/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.halflength=.*$/ro\\.audio\\.resampler\\.psd\\.halflength=360/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.tbwcheat=.*$/ro\\.audio\\.resampler\\.psd\\.tbwcheat=104/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.halflength=.*$/ro\\.audio\\.resampler\\.psd\\.halflength=320/' \\\n            \"$MODPATH/system.prop-workaround\"\n\n}\n\nfunction replaceSystemProps_S4()\n{\n    if [ -e \"${MODPATH%/*/*}/modules/usb-samplerate-unlocker\"  -o  -e \"${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker\" ]; then\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=5000/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=5000/' \\\n                \"$MODPATH/system.prop\"\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=5000/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=5000/' \\\n                \"$MODPATH/system.prop-workaround\"\n        \n        loosenedMessage\n        \n    else\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=3875/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=3875/' \\\n                \"$MODPATH/system.prop\"\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=3875/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=3875/' \\\n                \"$MODPATH/system.prop-workaround\"\n\n    fi\n    \n    sed -i \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=.*$/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=48000/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.stopband=.*$/ro\\.audio\\.resampler\\.psd\\.stopband=165/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.halflength=.*$/ro\\.audio\\.resampler\\.psd\\.halflength=360/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.tbwcheat=.*$/ro\\.audio\\.resampler\\.psd\\.tbwcheat=104/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.halflength=.*$/ro\\.audio\\.resampler\\.psd\\.halflength=320/' \\\n            \"$MODPATH/system.prop-workaround\"\n}\n\nfunction replaceSystemProps_Kona()\n{\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=4000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=4000/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=4000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=4000/' \\\n            \"$MODPATH/system.prop-workaround\"\n}\n\nfunction replaceSystemProps_SDM845()\n{\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop-workaround\"\n}\n\nfunction replaceSystemProps_SDM()\n{\n    # Do nothing even if \"usb-samplerate-unlocker\" exists\n    :\n}\n\nfunction replaceSystemProps_MTK_Dimensity()\n{\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop-workaround\"\n}\n\nfunction replaceSystemProps_Tensor()\n{\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop\"\n    sed -i \\\n        -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n        -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n            \"$MODPATH/system.prop-workaround\"\n            \n    sed -i \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=.*$/ro\\.audio\\.resampler\\.psd\\.enable_at_samplerate=48000/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.stopband=.*$/ro\\.audio\\.resampler\\.psd\\.stopband=194/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.halflength=.*$/ro\\.audio\\.resampler\\.psd\\.halflength=520/' \\\n        -e 's/ro\\.audio\\.resampler\\.psd\\.tbwcheat=.*$/ro\\.audio\\.resampler\\.psd\\.tbwcheat=83/' \\\n            \"$MODPATH/system.prop\"\n}\n\nfunction replaceSystemProps_Others()\n{\n    if [ -e \"${MODPATH%/*/*}/modules/usb-samplerate-unlocker\"  -o  -e \"${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker\" ]; then\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n                \"$MODPATH/system.prop\"\n        sed -i \\\n            -e 's/vendor\\.audio\\.usb\\.perio=.*$/vendor\\.audio\\.usb\\.perio=2000/' \\\n            -e 's/vendor\\.audio\\.usb\\.out\\.period_us=.*$/vendor\\.audio\\.usb\\.out\\.period_us=2000/' \\\n                \"$MODPATH/system.prop-workaround\"\n        \n        loosenedMessage\n        \n    fi\n    \n}\n\n# HyperOS v2.0 and Motorola stock OS v15.0 cannot increase the number of volume steps\n\nfunction deleteSystemProps_for_some_Stocks()\n{\n    local Moto=\"`getprop ro.mot.build.customerid`\"\n    local MIUI=\"`getprop ro.miui.ui.version.code`\"\n    local AndroidVersion=\"`getprop ro.system.build.version.release`\"\n\n    if [  -n \"$MIUI\"  -a  \"$MIUI\" -ge 14 ] || [ -n \"$Moto\"  -a  \"$AndroidVersion\" -ge 15 ]; then\n        sed -i \\\n            -e '/^ro\\.config\\.media_vol_steps=/d' \\\n                \"$MODPATH/system.prop\"\n        sed -i \\\n            -e '/^ro\\.config\\.media_vol_steps=/d' \\\n                \"$MODPATH/system.prop-workaround\"\n        \n    fi\n    \n}\n\nfunction stopSpatializer()\n{\n    # stopSpatializer has two args specifying an audio policy configuration XML file (eg. bluetooth_audio_policy_configuration_7_0.xml) \n    #   and its dummy one to be overridden\n\n    if [ $# -eq 2  -a  -r \"$1\"  -a  -w \"$2\" ]; then\n        # Copy and override an original audio_policy_configuration.xml to its dummy file\n        cp -f \"$1\" \"$2\"\n        # Change an audio_policy_configuration.xml file to remove Spatializer\n        sed -i 's/flags[:space:]*=[:space:]*\"AUDIO_OUTPUT_FLAG_SPATIALIZER\"//' \"$2\"\n    fi\n}\n\nfunction deSpatializeAudioPolicyConfig()\n{\n    if [ $# -ne 1  -o  -z \"$1\"  -o  ! -r \"$1\" ]; then\n        return 1\n    fi\n    local MAGISKPATH=\"$(magisk --path)\"\n    local configXML=\"$1\"\n    \n    # Don't use \"$MAGISKPATH/.magisk/mirror/system${configXML}\" instead of \"$MAGISKPATH/.magisk/mirror${configXML}\".\n    # In some cases, the former may link to overlaied \"${configXML}\" by Magisk itself (not original mirrored \"${configXML}\").\n    local mirrorConfigXML=\"$MAGISKPATH/.magisk/mirror${configXML}\"\n\n    if [ -n \"$configXML\"  -a  -r \"$mirrorConfigXML\" ]; then\n        grep -e \"flags[[:space:]]*=[[:space:]]*\\\"AUDIO_OUTPUT_FLAG_SPATIALIZER\\\"\" \"$mirrorConfigXML\" >\"/dev/null\" 2>&1\n        if [ \"$?\" -eq 0 ]; then\n            local modConfigXML=\"$MODPATH/system${configXML}\"\n            mkdir -p \"${modConfigXML%/*}\"\n            touch \"$modConfigXML\"\n            stopSpatializer \"$mirrorConfigXML\" \"$modConfigXML\"\n            chmod 644 \"$modConfigXML\"\n            chcon u:object_r:vendor_configs_file:s0 \"$modConfigXML\"\n            chown root:root \"$modConfigXML\"\n            chmod -R a+rX \"${modConfigXML%/*}\"\n            if [ -z \"$REPLACEFILES\" ]; then\n                REPLACEFILES=\"/system${configXML}\"\n            else\n                REPLACEFILES=\"$REPLACEFILES /system${configXML}\"\n            fi\n        fi\n    fi\n}\n\nfunction disablePrivApps()\n{\n    if [ $# -ne 1  -o  -z \"$1\" ]; then\n        return 1\n    fi\n\n    local MAGISKPATH=\"$(magisk --path)\"\n    local dir mdir\n    local PrivApps=\"$1\"\n    \n    for dir in $PrivApps; do\n        if [ -d \"${MAGISKPATH}/.magisk/mirror${dir}\" ]; then\n            case \"${dir}\" in\n                /system/* )\n                    dir=\"${dir#/system}\"\n                ;;\n            esac\n            mdir=\"${MODPATH}/system${dir}\"\n            mkdir -p \"$mdir\"\n            chmod a+rx \"$mdir\"\n            if [ -z \"$REPLACE\" ]; then\n                REPLACE=\"/system${dir}\"\n            else\n                REPLACE=\"${REPLACE} /system${dir}\"\n            fi\n        fi\n    done\n}\n\nfunction ui_print_replacelist()\n{\n    local f\n    for f in $1; do\n        ui_print \"- Replace target file: $f\"\n    done\n}\n"
  },
  {
    "path": "customize.sh",
    "content": "#!/system/bin/sh\n\n[ -z \"$(magisk --path)\" ] && alias magisk='ksu-magisk'\n\n. \"$MODPATH/customize-functions.sh\"\n\nif ! isMagiskMountCompatible; then\n    abort '  ***\n  Aborted by no magisk-mirrors (even including kernelSUs):\n    Try again after reawaking the mirrors\n        by installing my another magisk/kernelSU module\n        \"Compatible Magisk-mirroring\" and rebooting\n\n  ***'\nfi\n\nMAGISKTMP=\"$(magisk --path)/.magisk\"\n\n# Note: Don't use \"${MAGISKTMP}/mirror/system/vendor/*\" instaed of \"${MAGISKTMP}/mirror/vendor/*\".\n# In some cases, the former may link to overlaied \"/system/vendor\" by Magisk itself (not mirrored original one).\n\nREPLACE=\"\"\nREPLACEFILES=\"\"\n\n# Check if on a Tensor (except zumapro) device or not\ncase \"`getprop ro.board.platform`\" in\n    gs* | \"zuma\" )\n        tensorFlag=1\n        ;;\n    * )\n        tensorFlag=0\n        ;;\nesac\n\nif [ \"$tensorFlag\" -eq 1 ]; then\n    # Unlocks the limiter of Tensor device's USB offload driver from 96kHz to 192kHz\n    fname=\"/system/vendor/etc/audio_platform_configuration.xml\"\n    if [ -r \"$fname\" ]; then\n        mkdir -p \"${MODPATH}${fname%/*}\"\n        sed -e 's|min_rate=\"[1-9][0-9]*\"|min_rate=\"44100\"|g' \\\n            -e 's|\"MaxSamplingRate=[1-9][0-9]*,|\"MaxSamplingRate=192000,|' \\\n                <\"${MAGISKTMP}/mirror${fname#/system}\" >\"${MODPATH}${fname}\"\n        touch \"${MODPATH}${fname}\"\n        chmod 644 \"${MODPATH}${fname}\"\n        chcon u:object_r:vendor_configs_file:s0 \"${MODPATH}${fname}\"\n        chown root:root \"${MODPATH}${fname}\"\n        chmod -R a+rX \"${MODPATH}${fname%/*}\"\n        if [ -z \"${REPLACEFILES}\" ]; then\n            REPLACEFILES=\"${fname}\"\n        else\n            REPLACEFILES=\"${REPLACEFILES} ${fname}\"\n        fi\n    fi\n    \nfi\n\n# If detecting DRC-enabled or Tensor SoC, then make a DRC-less or Tensor specifically tuned config file and overlay\n#\n# Set the active configuration file name retrieved from the audio policy server\nconfigXML=\"`getActivePolicyFile`\"\n\n# configXML is usually placed under \"/vendor/etc\" (or \"/vendor/etc/audio\"), but\n# \"/my_product/etc\" and \"/odm/etc\" are used on ColorOS (RealmeUI) and OxygenOS(?)\ncase \"$configXML\" in\n    /vendor/etc/* | /my_product/etc/* | /odm/etc/* | /system/etc/* | /product/etc/* )\n        if [ -n \"$MAGISKTMP\"  -a  -r \"${MAGISKTMP}/mirror${configXML}\" ]; then\n            mirrorConfigXML=\"${MAGISKTMP}/mirror${configXML}\"\n        else\n            mirrorConfigXML=\"$configXML\"\n        fi\n        mirrorConfigXML=\"`getActualConfigXML \\\"${mirrorConfigXML}\\\"`\"\n        case \"${configXML}\" in\n            /system/* )\n                configXML=\"${configXML#/system}\"\n            ;;\n        esac\n        modConfigXML=\"$MODPATH/system${configXML}\"\n        \n        # If DRC enabled, modify audio policy configuration to stopt DRC\n        grep -e \"speaker_drc_enabled[[:space:]]*=[[:space:]]*\\\"true\\\"\" $mirrorConfigXML >\"/dev/null\" 2>&1\n        if [ \"$?\" -eq 0 ]; then\n            drcFlag=1\n        else\n            drcFlag=0\n        fi\n        \n        if [ \"$drcFlag\" -eq 1  -o  \"$tensorFlag\" -eq 1 ]; then\n            mkdir -p \"${modConfigXML%/*}\"\n            touch \"$modConfigXML\"\n            if [ \"$drcFlag\" -eq 1 ]; then\n                stopDRC \"$mirrorConfigXML\" \"$modConfigXML\"\n            else\n                DRC_enabled=\"false\"\n                USB_module=\"usbv2\"\n                BT_module=\"bluetooth\"\n                SampleRatePrimary=\"48000\"\n                AudioFormatPrimary=\"AUDIO_FORMAT_PCM_32_BIT\"\n                VolumeFile=$(getVolumeFile \"$mirrorConfigXML\")\n                templateFile=\"$MODPATH/templates/offload_hifi_playback_template.xml\"\n                \n                if [ -z \"$VolumeFile\" ]; then\n                    VolumeFile=\"/vendor/etc/audio_policy_volumes.xml\"\n                fi\n                DefaultVolumeFile=$(getDefaultVolumeFile \"$mirrorConfigXML\")\n                if [ -z \"$DefaultVolumeFile\" ]; then\n                    DefaultVolumeFile=\"/vendor/etc/default_volume_tables.xml\"\n                fi\n\n                if [ \"`getprop ro.build.version.codename`\" = \"CinnamonBun\" ]; then\n                    # A17 beta3 of Pixel 6's have a bug that cannot detect any appropriate sample rate and depth of a DAC\n                    # But they can or may work for DAC's having a XMOS digital interface chip if specifying any sample rate and depth\n                    templateFile=\"$MODPATH/templates/bypass_offload_safer_template.xml\"\n                    SampleRatePrimary=\"768000\"\n                elif [ \"`getprop ro.build.date.utc`\" -ge \"1762519080\" ]; then\n                    # A USB HAL driver bug has been fixed since Dec. 2025\n                    templateFile=\"$MODPATH/templates/bypass_offload_template.xml\"\n                fi\n                \n                sed   -e \"s|%DRC_ENABLED%|$DRC_enabled|\" -e \"s|%USB_MODULE%|$USB_module|\" -e \"s|%BT_MODULE%|$BT_module|\" \\\n                        -e \"s|%SAMPLING_RATE%|$SampleRatePrimary|\" -e \"s|%AUDIO_FORMAT%|$AudioFormatPrimary|\" \\\n                        -e \"s|%VOLUME_FILE%|$VolumeFile|\" -e \"s|%DEFAULT_VOLUME_FILE%|$DefaultVolumeFile|\" \\\n                        \"$templateFile\" >\"$modConfigXML\"\n            fi\n            chmod 644 \"$modConfigXML\"\n            chcon u:object_r:vendor_configs_file:s0 \"$modConfigXML\"\n            chown root:root \"$modConfigXML\"\n            chmod -R a+rX \"${modConfigXML%/*}\"\n            REPLACEFILES=\"/system${configXML} $REPLACEFILES\"\n            \n            # If \"${configXML}\" isn't symbolically linked to \"$/system/{configXML}\", \n            #   disable Magisk's \"magic mount\" and mount \"${configXML}\" by this module itself in \"service.sh\"\n            if [ ! -e \"/system${configXML}\" ]; then\n                touch \"$MODPATH/skip_mount\"\n            fi\n        fi\n        ;;\n    \"N/A\" )\n        # AIDL only devices or ones in some trouble\n        ;;\n    * )\n        ;;\nesac\n\n# Make patched ALSA utility libraries for \"ro.audio.usb.period_us\"\nmakeUnlockedLibraries\n\n# Remove post-A13 (especially Tensor's) spatial audio flags in an audio configuration file for avoiding errors\ndeSpatializeAudioPolicyConfig \"/vendor/etc/bluetooth_audio_policy_configuration_7_0.xml\"\n\n# Disabe pre-installed Moto Dolby faetures and Wellbeing for reducing very large jitter caused by them\n#   Excluded \"MotorolaSettingsProvider\" on Motorala devices for avoiding bootloop\nif [ \"`getprop ro.product.manufacturer`\" = \"motorola\" ]; then\n    disablePrivApps \"\n/system_ext/priv-app/MotoDolbyDax3\n/system_ext/priv-app/daxService\n/system_ext/priv-app/DaxUI\n/system_ext/app/MotoSignatureApp\n/product/priv-app/WellbeingPrebuilt\n/product/priv-app/Wellbeing\n/system_ext/priv-app/WellbeingPrebuilt\n/system_ext/priv-app/Wellbeing\n\"\nelse\n    disablePrivApps \"\n/system_ext/priv-app/MotoDolbyDax3\n/system_ext/priv-app/MotorolaSettingsProvider\n/system_ext/priv-app/daxService\n/system_ext/priv-app/DaxUI\n/system_ext/app/MotoSignatureApp\n/product/priv-app/WellbeingPrebuilt\n/product/priv-app/Wellbeing\n/system_ext/priv-app/WellbeingPrebuilt\n/system_ext/priv-app/Wellbeing\n\"\nfi\n\nif \"$IS64BIT\"; then\n    board=\"`getprop ro.board.platform`\"\n    case \"$board\" in\n        zuma* | \"pineapple\" )\n            replaceSystemProps_VHPerf\n            ;;\n        \"kona\" | \"kalama\" | \"shima\" | \"yupik\" )\n            replaceSystemProps_Kona\n            ;;\n        \"sdm845\" )\n            replaceSystemProps_SDM845\n            ;;\n        gs* )\n            replaceSystemProps_Tensor\n            ;;\n        \"sdm660\" | \"bengal\" | \"holi\" )\n            replaceSystemProps_SDM\n            ;;\n        mt68* )\n            replaceSystemProps_MTK_Dimensity\n            ;;\n        mt67[56]? )\n            replaceSystemProps_Others\n            ;;\n        * )\n            replaceSystemProps_Others\n            ;;\n    esac\n\n    deleteSystemProps_for_some_Stocks\n\nelse\n    if [ \"`getprop ro.build.product`\" = \"jfltexx\" ]; then\n        replaceSystemProps_S4\n    else\n        replaceSystemProps_Old\n    fi\n\nfi\n\n# AudioFlinger's resampler has a bug on an Android OS of which version is less than 12.\n# This bug makes the resampler to distort audible audio output by wrong aliasing processing\n#   when specifying a transition band around or higher than the Nyquist frequency\n\nif [ \"`getprop ro.system.build.version.release`\" -lt \"12\"  -a  \"`getprop ro.system.build.date.utc`\" -lt \"1648632000\" ]; then\n    mv -f \"$MODPATH/system.prop-workaround\" \"$MODPATH/system.prop\"\nelse\n    rm -f \"$MODPATH/system.prop-workaround\"\nfi\n\n# Warning unneeded magisk modules\n\nif [ -e \"${MODPATH%/*/*}/modules/audio-misc-settings\" ]; then\n    ui_print \"\"\n    ui_print \"****************************************************************\"\n    ui_print \" Uninstall \\\"Audio misc. settings\\\" manually later; this module includes all its features\"\n    ui_print \"****************************************************************\"\n    ui_print \"\"\nfi\nif [ -e \"${MODPATH%/*/*}/modules/drc-remover\" ]; then\n    ui_print \"\"\n    ui_print \"****************************************************************\"\n    ui_print \" Uninstall \\\"DRC remover\\\" manually later; this module includes all its features\"\n    ui_print \"****************************************************************\"\n    ui_print \"\"\nfi\nif [ \"$tensorFlag\" -eq 1  -a  -e \"${MODPATH%/*/*}/modules/usb-samplerate-unlocker\" ]; then\n    ui_print \"\"\n    ui_print \"****************************************************************\"\n    ui_print \" Uninstall \\\"USB Samplerate Unlocker\\\" manually later; this module includes all its features\"\n    ui_print \"****************************************************************\"\n    ui_print \"\"\nfi\nif [ \"$tensorFlag\" -eq 1  -a  -e \"${MODPATH%/*/*}/modules/audio-samplerate-changer\" ]; then\n    ui_print \"\"\n    ui_print \"****************************************************************\"\n    ui_print \" Uninstall \\\"Audio Samplerate Changer\\\" manually later; this module includes all its features\"\n    ui_print \"****************************************************************\"\n    ui_print \"\"\nfi\n \nrm -f \"$MODPATH/customize-functions.sh\" \"$MODPATH/LICENSE\" \"$MODPATH/README.md\" \"$MODPATH/changelog.md\"\nrm -rf \"$MODPATH/templates\"\nui_print_replacelist \"$REPLACEFILES\"\n"
  },
  {
    "path": "jitter-reducer-functions.shlib",
    "content": "#!/system/bin/sh\n\nfunction forceOnlineCPUs()\n{\n    local i st en\n    IFS=\"-\" read st en <\"/sys/devices/system/cpu/present\"\n    if [ -n \"$st\"  -a  -n \"$en\"  -a \"$st\" -ge 0  -a  \"$en\" -ge 0 ]; then\n        for i in `seq $st $en`; do\n            if [ -e \"/sys/devices/system/cpu/cpu$i/online\" ]; then\n                chmod 644 \"/sys/devices/system/cpu/cpu$i/online\"\n                echo '1' >\"/sys/devices/system/cpu/cpu$i/online\"\n            fi\n        done\n    fi\n}\n\nfunction searchDefaultCpuGovernor()\n{\n    # Search default CPU governor\n    local gov=\"\"\n    local i\n    for i in `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors`; do\n        if [ \"$i\" = \"walt\"  -o  \"$i\" = \"sugov_ext\"  -o  \"$i\" = \"sched_pixel\"  -o  \"$i\" = \"schedutil\" ]; then\n            gov=\"$i\"\n            break;\n        elif [ ! \"$gov\" = \"schedplus\" ]; then\n             if [ \"$i\" = \"schedplus\" ]; then\n                gov=\"$i\"\n            elif [ ! \"$gov\" = \"interactive\" ]; then\n                gov=\"$i\"\n            fi\n        fi\n    done\n    if [ -z \"$gov\" ]; then\n        gov=\"performance\"\n    fi\n    echo \"$gov\"\n}\n\nfunction reduceSelinuxJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n        \n        if [ $flag -gt 0 ]; then\n            setenforce 0\n        elif [ $flag -lt 0 ]; then\n            if [ \"`getprop ro.build.product`\" = \"jfltexx\"  -a   \"`getprop ro.system.build.version.release`\" -ge \"12\" ]; then\n                echo \"Warning: ignored trying to change Selinux mode\" 1>&2\n            else\n                setenforce 1\n            fi\n            \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            echo \"  Selinux mode: `getenforce`\"\n        fi\n    else\n        return 1\n    fi\n}\n\nfunction reduceThermalJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n        \n        if [ $flag -gt 0 ]; then   \n         \n            # Stop thermal core control\n            if [ -w \"/sys/module/msm_thermal/core_control/enabled\" ]; then\n                echo '0' > \"/sys/module/msm_thermal/core_control/enabled\"\n            fi\n            if [ -r \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                local i st en\n                IFS=\"-\" read st en <\"/sys/devices/system/cpu/present\"\n                if [ -n \"$st\"  -a  -n \"$en\"  -a \"$st\" -ge 0  -a  \"$en\" -ge 0 ]; then\n                    if [ -w \"/sys/devices/system/cpu/cpu7/core_ctl/enable\" ]; then\n                        # SD850 or higher type core control\n                        local ncpu_remained=7\n                        \n                        echo '1'  > \"/sys/devices/system/cpu/cpu7/core_ctl/enable\"\n                        echo '1'  > \"/sys/devices/system/cpu/cpu7/core_ctl/min_cpus\"\n                        echo '55'  > \"/sys/devices/system/cpu/cpu7/core_ctl/busy_down_thres\"\n                        echo '0'  > \"/sys/devices/system/cpu/cpu7/core_ctl/busy_up_thres\"\n                        echo '2900'  > \"/sys/devices/system/cpu/cpu7/core_ctl/offline_delay_ms\"\n                        echo '0'  > \"/sys/devices/system/cpu/cpu7/core_ctl/enable\"\n                        if [ -w \"/sys/devices/system/cpu/cpu3/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu3/core_ctl/enable\"\n                            # min_cpus cannot be set to be 4, so 3\n                            echo '3'  > \"/sys/devices/system/cpu/cpu3/core_ctl/min_cpus\"\n                            echo '55 55 55'  > \"/sys/devices/system/cpu/cpu3/core_ctl/busy_down_thres\"\n                            echo '0 0 0'  > \"/sys/devices/system/cpu/cpu3/core_ctl/busy_up_thres\"\n                            echo '2900'  > \"/sys/devices/system/cpu/cpu3/core_ctl/offline_delay_ms\"\n                            echo '0'  > \"/sys/devices/system/cpu/cpu3/core_ctl/enable\"\n                            ncpu_remained=3\n                        elif [ -w \"/sys/devices/system/cpu/cpu4/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu4/core_ctl/enable\"\n                            echo '3'  > \"/sys/devices/system/cpu/cpu4/core_ctl/min_cpus\"\n                            echo '55 55 55'  > \"/sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres\"\n                            echo '0 0 0'  > \"/sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres\"\n                            echo '2900'  > \"/sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms\"\n                            echo '0'  > \"/sys/devices/system/cpu/cpu4/core_ctl/enable\"\n                            ncpu_remained=4\n                        fi\n                        if [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                            echo \"$ncpu_remained\"  > \"/sys/devices/system/cpu/cpu0/core_ctl/min_cpus\"\n                            echo '55 55 55 55'  > \"/sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres\"\n                            echo '0 0 0 0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres\"\n                            echo '2900'  > \"/sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms\"\n                            echo '0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                        fi\n                    elif [ -w \"/sys/devices/system/cpu/cpu6/core_ctl/enable\" ]; then\n                        # Dimensity type core control\n                        echo '1'  > \"/sys/devices/system/cpu/cpu6/core_ctl/enable\"\n                        echo '2'  > \"/sys/devices/system/cpu/cpu6/core_ctl/min_cpus\"\n                        echo '0'  > \"/sys/devices/system/cpu/cpu6/core_ctl/enable\"\n                        if [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                            echo '6'  > \"/sys/devices/system/cpu/cpu0/core_ctl/min_cpus\"\n                            echo '0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                        fi\n                    elif [ -w \"/sys/devices/system/cpu/cpu4/core_ctl/enable\" ]; then\n                        # SD840 or lower type core control\n                        echo '1'  > \"/sys/devices/system/cpu/cpu4/core_ctl/enable\"\n                        echo '4'  > \"/sys/devices/system/cpu/cpu4/core_ctl/min_cpus\"\n                        echo '0'  > \"/sys/devices/system/cpu/cpu4/core_ctl/enable\"\n                        if [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                            echo '4'  > \"/sys/devices/system/cpu/cpu0/core_ctl/min_cpus\"\n                            echo '0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                        fi\n                    elif [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                        # unknown type core control\n                        echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                        echo '4'  > \"/sys/devices/system/cpu/cpu0/core_ctl/min_cpus\"\n                        echo '0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                    fi\n                fi\n            fi\n            # Stop the MPDecision (CPU hotplug)\n            if [ \"`getprop init.svc.mpdecision`\" = \"running\" ]; then\n                setprop ctl.stop mpdecision\n                forceOnlineCPUs\n            elif [ \"`getprop init.svc.mpdecision`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.mpdecision`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                    forceOnlineCPUs\n                fi\n            elif [ \"`getprop init.svc.vendor.mpdecision`\" = \"running\" ]; then\n                setprop ctl.stop vendor.mpdecision\n                forceOnlineCPUs\n            elif [ \"`getprop init.svc.vendor.mpdecision`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.vendor.mpdecision`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                    forceOnlineCPUs\n                fi\n            fi\n            # Stop the thermal server\n            if [ \"`getprop init.svc.thermal`\" = \"running\" ]; then\n                setprop ctl.stop thermal\n            elif [ \"`getprop init.svc.thermal`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.thermal`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            elif [ \"`getprop init.svc.vendor.thermal`\" = \"running\" ]; then\n                setprop ctl.stop vendor.thermal\n            elif [ \"`getprop init.svc.vendor.thermal`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.vendor.thermal`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            \n            # Stop MTK thermald and thermal_core\n            if [ \"`getprop init.svc.thermald`\" = \"running\" ]; then\n                setprop ctl.stop thermald\n            elif [ \"`getprop init.svc.thermald`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.thermald`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            if [ \"`getprop init.svc.thermal_core`\" = \"running\" ]; then\n                setprop ctl.stop thermal_core\n            elif [ \"`getprop init.svc.thermal_core`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.thermal_core`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n\n            # Stop the mi_thermald server\n            if [ \"`getprop init.svc.mi_thermald`\" = \"running\" ]; then\n                setprop ctl.stop mi_thermald\n            elif [ \"`getprop init.svc.mi_thermald`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.mi_thermald`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            elif [ \"`getprop init.svc.vendor.mi_thermald`\" = \"running\" ]; then\n                setprop ctl.stop vendor.mi_thermald\n            elif [ \"`getprop init.svc.vendor.mi_thermald`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.vendor.mi_thermald`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            # Stop the thermal-engine server\n            if [ \"`getprop init.svc.thermal-engine`\" = \"running\" ]; then\n                setprop ctl.stop thermal-engine\n            elif [ \"`getprop init.svc.thermal-engine`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.thermal-engine`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            elif [ \"`getprop init.svc.vendor.thermal-engine`\" = \"running\" ]; then\n                setprop ctl.stop vendor.thermal-engine\n            elif [ \"`getprop init.svc.vendor.thermal-engine`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.vendor.thermal-engine`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            # For MediaTek CPU's\n            if [ -w \"/proc/cpufreq/cpufreq_sched_disable\" ]; then\n                echo '1' > \"/proc/cpufreq/cpufreq_sched_disable\"\n                forceOnlineCPUs\n            fi\n        \n        elif [ $flag -lt 0 ]; then\n        \n            # Start thermal core control\n             if [ -w \"/sys/module/msm_thermal/core_control/enabled\" ]; then\n                echo '1' > \"/sys/module/msm_thermal/core_control/enabled\"\n            fi\n            if [ -r \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                local st en\n                IFS=\"-\" read st en <\"/sys/devices/system/cpu/present\"\n                if [ -n \"$st\"  -a  -n \"$en\"  -a \"$st\" -ge 0  -a  \"$en\" -ge 0 ]; then\n                    if [ -w \"/sys/devices/system/cpu/cpu7/core_ctl/enable\" ]; then\n                        local ncpu_remained=7\n                        # SD850 or higher type core control\n                        echo '1'  > \"/sys/devices/system/cpu/cpu7/core_ctl/enable\"\n                        echo '0'  > \"/sys/devices/system/cpu/cpu7/core_ctl/min_cpus\"\n                        echo '30'  > \"/sys/devices/system/cpu/cpu7/core_ctl/busy_down_thres\"\n                        echo '60'  > \"/sys/devices/system/cpu/cpu7/core_ctl/busy_up_thres\"\n                        echo '100'  > \"/sys/devices/system/cpu/cpu7/core_ctl/offline_delay_ms\"\n                        if [ -w \"/sys/devices/system/cpu/cpu3/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu3/core_ctl/enable\"\n                            echo '3'  > \"/sys/devices/system/cpu/cpu3/core_ctl/min_cpus\"\n                            echo '30 30 30'  > \"/sys/devices/system/cpu/cpu3/core_ctl/busy_down_thres\"\n                            echo '60 60 60'  > \"/sys/devices/system/cpu/cpu3/core_ctl/busy_up_thres\"\n                            echo '100'  > \"/sys/devices/system/cpu/cpu3/core_ctl/offline_delay_ms\"\n                            ncpu_remained=3\n                        elif [ -w \"/sys/devices/system/cpu/cpu4/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu4/core_ctl/enable\"\n                            echo '2'  > \"/sys/devices/system/cpu/cpu4/core_ctl/min_cpus\"\n                            echo '30 30 30'  > \"/sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres\"\n                            echo '60 60 60'  > \"/sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres\"\n                            echo '100'  > \"/sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms\"\n                            ncpu_remained=4\n                        fi\n                        if [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                            echo \"$ncpu_remained\"  > \"/sys/devices/system/cpu/cpu0/core_ctl/min_cpus\"\n                            echo '0 0 0 0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres\"\n                            echo '0 0 0 0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres\"\n                            echo '100'  > \"/sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms\"\n                            echo '0'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                        fi\n                    elif [ -w \"/sys/devices/system/cpu/cpu6/core_ctl/enable\" ]; then\n                        # Dimensity type core control\n                        echo '1'  > \"/sys/devices/system/cpu/cpu6/core_ctl/enable\"\n                        if [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                        fi\n                    elif [ -w \"/sys/devices/system/cpu/cpu4/core_ctl/enable\" ]; then\n                        # SD840 or lower type core control\n                        echo '1'  > \"/sys/devices/system/cpu/cpu4/core_ctl/enable\"\n                        echo '1'  > \"/sys/devices/system/cpu/cpu4/core_ctl/min_cpus\"\n                        if [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                            echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                            echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/min_cpus\"\n                        fi\n                    elif [ -w \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                        # unknown type core control\n                        echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                        echo '1'  > \"/sys/devices/system/cpu/cpu0/core_ctl/min_cpus\"\n                    fi\n                fi\n            fi\n            # Start the MPDecision (CPU hotplug)\n            if [ \"`getprop init.svc.mpdecision`\" = \"stopped\" ]; then\n                setprop ctl.start mpdecision\n                forceOnlineCPUs\n            elif [ \"`getprop init.svc.vendor.mpdecision`\" = \"stopped\" ]; then\n                setprop ctl.start vendor.mpdecision\n                forceOnlineCPUs\n            fi\n            # Start the thermal server\n            if [ \"`getprop init.svc.thermal`\" = \"stopped\" ]; then\n                setprop ctl.start thermal\n            elif [ \"`getprop init.svc.vendor.thermal`\" = \"stopped\" ]; then\n                setprop ctl.start vendor.thermal\n            fi\n            # Start the MTK thermald and thermal_core server\n            if [ \"`getprop init.svc.thermald`\" = \"stopped\" ]; then\n                setprop ctl.start thermald\n            fi\n            if [ \"`getprop init.svc.thermal_core`\" = \"stopped\" ]; then\n                setprop ctl.start thermal_core\n            fi\n            # Start the mi_thermald server\n            if [ \"`getprop init.svc.mi_thermald`\" = \"stopped\" ]; then\n                setprop ctl.start mi_thermald\n            elif [ \"`getprop init.svc.vendor.mi_thermald`\" = \"stopped\" ]; then\n                setprop ctl.start vendor.mi_thermald\n            fi\n            # Start the thermal-engine server\n            if [ \"`getprop init.svc.thermal-engine`\" = \"stopped\" ]; then\n                setprop ctl.start thermal-engine\n            elif [ \"`getprop init.svc.vendor.thermal-engine`\" = \"stopped\" ]; then\n                setprop ctl.start vendor.thermal-engine\n            fi\n            # For MediaTek CPU's\n            if [ -w \"/proc/cpufreq/cpufreq_sched_disable\" ]; then\n                val=\"`searchDefaultCpuGovernor`\"\n                if [ \"$val\" = \"schedutil\"  -a  \"`getprop ro.vendor.build.version.release`\" -lt \"11\" ]; then\n                    echo \"    Notice: EAS hasn't been enabled, so skipping thermal MTK EAS+ enabling\" 1>&2\n                else\n                    echo '0' > \"/proc/cpufreq/cpufreq_sched_disable\"\n                fi\n            fi\n        \n        fi\n      \n        if [ $printStatus -gt 0 ]; then\n            local found=0\n            \n            # Qualcomm Core control\n            if [ -w \"/sys/module/msm_thermal/core_control/enabled\" ]; then\n                if [ \"`cat /sys/module/msm_thermal/core_control/enabled`\" -eq 0 ]; then\n                    echo \"  Thermal msm_thermal: disabled\"\n                else\n                    echo \"  Thermal msm_thermal: enabled\"\n                fi\n                found=1\n            fi\n            if [ -r \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                local i st en ctl_enabled=0\n                IFS=\"-\" read st en <\"/sys/devices/system/cpu/present\"\n                if [ -n \"$st\"  -a  -n \"$en\"  -a \"$st\" -ge 0  -a  \"$en\" -ge 0 ]; then\n                    if [ -r \"/sys/devices/system/cpu/cpu7/core_ctl/enable\" ]; then\n                        read ctl_enabled <\"/sys/devices/system/cpu/cpu7/core_ctl/enable\"\n                    elif [ -r \"/sys/devices/system/cpu/cpu6/core_ctl/enable\" ]; then\n                        read ctl_enabled <\"/sys/devices/system/cpu/cpu6/core_ctl/enable\"\n                    elif [ -r \"/sys/devices/system/cpu/cpu4/core_ctl/enable\" ]; then\n                        read ctl_enabled <\"/sys/devices/system/cpu/cpu4/core_ctl/enable\"\n                    elif [ -r \"/sys/devices/system/cpu/cpu0/core_ctl/enable\" ]; then\n                        read ctl_enabled <\"/sys/devices/system/cpu/cpu0/core_ctl/enable\"\n                    fi\n                    if [ \"$ctl_enabled\" -gt 0 ]; then\n                        echo \"  Thermal core_ctl: enabled\"\n                    else\n                        echo \"  Thermal core_ctl: disabled\"\n                    fi\n                    found=1\n                fi\n            fi\n            if [ -n \"`getprop init.svc.thermal`\" ]; then\n                echo \"  Thermal server: `getprop init.svc.thermal`\"\n                found=1\n            elif [ -n \"`getprop init.svc.vendor.thermal`\" ]; then\n                echo \"  Thermal server: `getprop init.svc.vendor.thermal`\"\n                found=1\n            fi\n            if [ -n \"`getprop init.svc.thermald`\" ]; then\n                echo \"  Thermal MTK thermald: `getprop init.svc.thermald`\"\n                found=1\n            fi\n            if [ -n \"`getprop init.svc.thermal_core`\" ]; then\n                echo \"  Thermal MTK thermal_core: `getprop init.svc.thermal_core`\"\n                found=1\n            fi\n            if [ -n \"`getprop init.svc.mi_thermald`\" ]; then\n                echo \"  Thermal mi_thermald: `getprop init.svc.mi_thermald`\"\n                found=1\n            elif [ -n \"`getprop init.svc.vendor.mi_thermald`\" ]; then\n                echo \"  Thermal mi_thermald: `getprop init.svc.vendor.mi_thermald`\"\n                found=1\n            fi\n            if [ -n \"`getprop init.svc.thermal-engine`\" ]; then\n                echo \"  Thermal thermal-engine: `getprop init.svc.thermal-engine`\"\n                found=1\n            elif [ -n \"`getprop init.svc.vendor.thermal-engine`\" ]; then\n                echo \"  Thermal thermal-engine: `getprop init.svc.vendor.thermal-engine`\"\n                found=1\n            fi\n\n            # MPDecision\n            if [ -n \"`getprop init.svc.mpdecision`\" ]; then\n                echo \"  Thermal MPDecision: `getprop init.svc.mpdecision`\"\n                found=1\n            elif [ -n \"`getprop init.svc.vendor.mpdecision`\" ]; then\n                echo \"  Thermal MPDecision: `getprop init.svc.vendor.mpdecision`\"\n                found=1\n            fi\n\n            # MediaTek EAS+ scheduling\n            if [ -r \"/proc/cpufreq/cpufreq_sched_disable\" ]; then\n                set `cat /proc/cpufreq/cpufreq_sched_disable`\n                val=$3\n                if [ \"$val\" -eq '1' ]; then\n                    echo \"  Thermal MTK EAS+: stopped\"\n                else\n                    echo \"  Thermal MTK EAS+: running\"\n                fi\n                found=1\n            fi\n            \n            if [ $found -eq 0 ]; then\n                echo \"  Thermal control: N/A\"\n            fi\n        # End of status print section\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction reduceDozeJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n\n        if [ $flag -gt 0 ]; then\n            # Disable Doze of the device\n            dumpsys deviceidle disable all 1>\"/dev/null\" 2>&1\n        elif [ $flag -lt 0 ]; then\n            # Enable Doze of the device\n            dumpsys deviceidle enable all 1>\"/dev/null\" 2>&1\n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            if [ \"`dumpsys deviceidle enabled all`\" -gt 0 ]; then\n                echo \"  Doze battery saver: enabled\"\n            else\n                echo \"  Doze battery saver: disabled\"\n            fi\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction getQcomGpuFreq()\n{\n    local isMax=\"0\"\n    \n    if [ $# -eq 1  -a  \"$1\" = \"max\" ]; then\n        isMax=\"1\"\n    fi\n    \n    if [ -r \"/sys/class/kgsl/kgsl-3d0/gpu_available_frequencies\"  -a  -r \"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\" ]; then\n        local tab x y freq=\"\"\n        \n        read tab <\"/sys/class/kgsl/kgsl-3d0/gpu_available_frequencies\"\n        if [ -z \"$tab\" ]; then\n            return 1\n        fi\n        set $tab 1>\"/dev/null\" 2>&1\n        \n        if [ \"$isMax\" -eq 1 ]; then\n            freq=\"$1\"\n        elif [ -r \"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\" ]; then\n            read x <\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n            read y <\"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\"\n            if [ \"$y\" -lt \"$x\" ]; then\n                x=\"$y\"\n            fi\n            if [ \"$x\" -lt $# ]; then\n                shift $x\n            fi\n            freq=\"$1\"\n        else\n            # no estimation possible, so check the current real GPU clock\n            read freq <\"/sys/class/kgsl/kgsl-3d0/gpuclk\"\n        fi\n        \n        if [ -n \"$freq\" ]; then\n            echo \"$freq\"\n            return 0\n        else\n            return 1\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction getMtkGpuFreqKhz()\n{\n    local isMax=\"0\"\n    \n    if [ $# -eq 1  -a  \"$1\" = \"max\" ]; then\n        isMax=\"1\"\n    fi\n    \n    if [ -r \"/proc/gpufreq/gpufreq_opp_dump\" ]; then\n        local x1 x2 x3 x4 x5 freq=\"\" IFS=\" ,\"\n        \n        if [ \"$isMax\" -eq 1 ]; then\n            read x1 x2 x3 x4 x5 <\"/proc/gpufreq/gpufreq_opp_dump\"\n            freq=\"$x4\"\n        else\n            while read x1 x2 x3 x4 x5; do\n                freq=\"$x4\"\n            done <\"/proc/gpufreq/gpufreq_opp_dump\"\n        fi\n        \n        if [ -n \"$freq\" ]; then\n            echo \"$freq\"\n            return 0\n        else\n            return 1\n        fi\n        \n    elif [ -r \"/proc/gpufreqv2/gpu_working_opp_table\"  -a  \"$isMax\" -eq 1 ]; then\n        local x1 x2 x3 x4 freq=\"\" IFS=\" ,\"\n        \n        read x1 x2 x3 x4 <\"/proc/gpufreqv2/gpu_working_opp_table\"\n        freq=\"$x3\"\n        \n        if [ -n \"$freq\" ]; then\n            echo \"$freq\"\n            return 0\n        else\n            return 1\n        fi\n        \n    elif [ -r \"/proc/gpufreqv2/gpufreq_status\" ]; then\n        local x1 x2 x3 x4 x5 x6 x7 freq=\"\" IFS=\" ,\"\n       \n       { \n            read\n            read x1 x2 x3 x4 x5 x6\n            freq=\"$x5\"\n            \n            if [ -n \"$freq\" ]; then\n                echo \"$freq\"\n                return 0\n            else\n                return 1\n            fi\n        } <\"/proc/gpufreqv2/gpufreq_status\"\n        return 0\n\n    else\n        return 1\n    fi\n}\n\nfunction getTensorGpuFreqKhz()\n{\n    local isMax=\"0\"\n    \n    if [ $# -eq 1  -a  \"$1\" = \"max\" ]; then\n        isMax=\"1\"\n    elif [ $# -eq 1  -a  \"$1\" = \"min\" ]; then\n        isMax=\"-1\"\n    fi\n    \n    if [ -r \"/sys/devices/platform/1c500000.mali/available_frequencies\" ]; then\n        local tab x freq=\"\"\n        \n        read tab <\"/sys/devices/platform/1c500000.mali/available_frequencies\"\n        if [ -z \"$tab\" ]; then\n            return 1\n        fi\n        set $tab 1>\"/dev/null\" 2>&1\n        \n        if [ \"$isMax\" -eq 1 ]; then\n            freq=\"$1\"\n        elif [ \"$isMax\" -eq -1 ]; then\n            freq=\"$(eval echo '$'{$#})\"\n        else\n            # return the current GPU clock\n            read freq <\"/sys/devices/platform/1c500000.mali/cur_freq\"\n        fi\n        \n        if [ -n \"$freq\" ]; then\n            echo \"$freq\"\n            return 0\n        else\n            return 1\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction isMtkGpuFreqFixed()\n{\n    if [ -r \"/proc/gpufreq/gpufreq_opp_freq\" ]; then\n        local x1 x2 x3 x4 x5\n        read x1 x2 x3 x4 x5 <\"/proc/gpufreq/gpufreq_opp_freq\"\n        if [ \"$x5\" = \"enabled\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [ -r \"/proc/gpufreqv2/fix_target_opp_index\" ]; then\n        local x1 x2 x3 x4 x5 x6\n        read x1 x2 x3 x4 x5 x6 <\"/proc/gpufreqv2/fix_target_opp_index\"\n        if [ \"$x6\" = \"disabled\" ]; then\n            return 1\n        else\n            return 0\n        fi\n    else\n        return 1\n    fi\n}\n\nfunction validGpuGovernor()\n{\n    if [ $# -eq 2  -a  -r \"$1\" ]; then\n        local lst\n        local gov=\"$2\"\n        local i\n        lst=\"`cat <\\\"$1\\\"`\"\n        for i in $lst; do\n            if [ \"$i\" = \"$gov\" ]; then\n                return 0\n            fi\n        done\n        return 1\n    else\n        return 1\n    fi\n}\n\nfunction getGpuBusmonPath()\n{\n    local x\n    \n    if [ -e \"/sys/class/devfreq/soc:qcom,kgsl-busmon\" ]; then\n        x=\"/sys/class/devfreq/soc:qcom,kgsl-busmon\"\n    elif [ -e \"/sys/class/devfreq/kgsl-busmon\" ]; then\n        x=\"/sys/class/devfreq/kgsl-busmon\"\n     else\n        x=\"\"\n     fi\n     echo \"$x\"\n     return 0\n}\n\nfunction reduceGovernorJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n        local x\n\n        if [ $flag -gt 0 ]; then\n        \n            # CPU governor\n            # prevent CPU offline stuck by forcing online between double  governor writing \n            local i st en\n            IFS=\"-\" read st en <\"/sys/devices/system/cpu/present\"\n            if [ -n \"$st\"  -a  -n \"$en\"  -a \"$st\" -ge 0  -a  \"$en\" -ge 0 ]; then\n                for i in `seq $st $en`; do\n                    if [ -e \"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\" ]; then\n                        chmod 644 \"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\"\n                        echo 'performance' >\"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\"\n                        chmod 644 \"/sys/devices/system/cpu/cpu$i/online\"\n                        echo '1' >\"/sys/devices/system/cpu/cpu$i/online\"\n                        # Set the cpu max freq to the scaling_max_freq because some devices sometimes set it to be lower\n                        read x <\"/sys/devices/system/cpu/cpu$i/cpufreq/cpuinfo_max_freq\"\n                        chmod 644 \"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq\"\n                        echo \"$x\" >\"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq\"\n                        echo 'performance' >\"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\"\n                    fi\n                done\n            fi\n\n            # Support for the Nyx kernel and others; Disable a workqueue power efficient featute\n            if [ -e \"/sys/module/workqueue/parameters/power_efficient\" ]; then\n                chmod 644 \"/sys/module/workqueue/parameters/power_efficient\"\n                echo 'N' >\"/sys/module/workqueue/parameters/power_efficient\"\n            fi\n\n            # GPU's\n            if [ -w \"/sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor\" ]; then\n                # For old Qcomm GPU's\n                echo 'performance' >\"/sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor\"\n                if [ -w \"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\" ]; then\n                    # Set the min power level to be maximum\n                    read x <\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                    if [ \"$x\" -ne 0 ]; then\n                        echo \"0\" >\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                    fi\n                fi\n            elif [ -w \"/sys/class/kgsl/kgsl-3d0/devfreq/governor\" ]; then\n                # For Qcomm GPU's\n                if validGpuGovernor \"/sys/class/kgsl/kgsl-3d0/devfreq/available_governors\" \"performance\"; then\n                    # Check whether \"performance\" governor exists or not because some Qcomm recent GPU's don't have the governor\n                    echo 'performance' >\"/sys/class/kgsl/kgsl-3d0/devfreq/governor\"\n                    sleep 0.1\n                fi\n                if [ -w \"/sys/class/kgsl/kgsl-3d0/devfreq/min_freq\" ]; then\n                    # Set the min freq\n                    read x <\"/sys/class/kgsl/kgsl-3d0/devfreq/max_freq\"\n                    if [ \"$x\" -ne 0 ]; then\n                        echo \"$x\" >\"/sys/class/kgsl/kgsl-3d0/devfreq/min_freq\"\n                    fi\n                fi\n                if [ -w \"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\" ]; then\n                    # Set the min power level to be maximum\n                    read x <\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                    if [ \"$x\" -ne 0 ]; then\n                        echo \"0\" >\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                    fi\n                fi\n                if [ -w \"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\" ]; then\n                    # Set the default power level to be maximum\n                    read x <\"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\"\n                    if [ \"$x\" -ne 0 ]; then\n                        echo \"0\" >\"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\"\n                    fi\n                fi\n                # For some Qcomm GPU's, because they revert the governor after setting min_pwrlevel several times\n                if validGpuGovernor \"/sys/class/kgsl/kgsl-3d0/devfreq/available_governors\" \"performance\"; then\n                    for i in `seq 1 9`; do\n                        x=\"`echo \\\"scale=1;${i}/10\\\" | bc`\"\n                        sleep $x\n                        read x <\"/sys/class/kgsl/kgsl-3d0/devfreq/governor\"\n                        if [ \"$x\" = \"performance\" ]; then\n                            break\n                        fi\n                        echo 'performance' >\"/sys/class/kgsl/kgsl-3d0/devfreq/governor\"\n                    done\n                fi\n                if [ -w \"/sys/class/kgsl/kgsl-3d0/throttling\" ]; then\n                        echo \"0\" >\"/sys/class/kgsl/kgsl-3d0/throttling\"\n                fi\n                if [ -w \"/sys/class/devfreq/soc:qcom,gpubw/min_freq\" ]; then\n                    # Set the min freq\n                    read x <\"/sys/class/devfreq/soc:qcom,gpubw/max_freq\"\n                    if [ \"$x\" -ne 0 ]; then\n                        echo \"$x\" >\"/sys/class/devfreq/soc:qcom,gpubw/min_freq\"\n                    fi\n                fi\n                local busmon=\"`getGpuBusmonPath`\"\n                if [ -w \"${busmon}/min_freq\" ]; then\n                    # Set the min freq\n                    read x <\"${busmon}/max_freq\"\n                    if [ \"$x\" -ne 0 ]; then\n                        echo \"$x\" >\"${busmon}/min_freq\"\n                    fi\n                    echo \"performance\" >\"${busmon}/governor\"\n                fi\n            elif [ -w \"/proc/gpufreq/gpufreq_opp_freq\" ]; then\n                # Maximum fixed frequency setting for MediaTek GPU's\n                local freq=\"`getMtkGpuFreqKhz \\\"max\\\"`\"\n                if [ -n \"$freq\" ]; then\n                    echo \"$freq\" >\"/proc/gpufreq/gpufreq_opp_freq\"\n                fi\n            elif [ -w \"/proc/gpufreqv2/fix_target_opp_index\" ]; then\n                # Maximum fixed frequency (index 0) setting for MediaTek GPU's\n                echo \"0\" >\"/proc/gpufreqv2/fix_target_opp_index\"\n            elif [ -w \"/sys/devices/platform/1c500000.mali/hint_min_freq\" ]; then\n                # Maximum fixed frequency setting for Tensor GPU's\n                # This makes audio quality poor really, so is avoided\n                local freq=\"`getTensorGpuFreqKhz \\\"max\\\"`\"\n                if [ -n \"$freq\" ]; then\n                    #echo \"$freq\" >\"/sys/devices/platform/1c500000.mali/hint_min_freq\"\n                    :\n                fi\n            fi\n            \n        elif [ $flag -lt 0 ]; then\n\n            # CPU's governor\n            local gov=\"`searchDefaultCpuGovernor`\"\n            # prevent CPU offline stuck by forcing online between double  governor writing\n            local i st en\n            IFS=\"-\" read st en <\"/sys/devices/system/cpu/present\"\n            if [ -n \"$st\"  -a  -n \"$en\"  -a \"$st\" -ge 0  -a  \"$en\" -ge 0 ]; then\n                for i in `seq $st $en`; do\n                    if [ -e \"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\" ]; then\n                        chmod 644 \"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\"\n                        echo \"$gov\" >\"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\"\n                        chmod 644 \"/sys/devices/system/cpu/cpu$i/online\"\n                        echo '1' >\"/sys/devices/system/cpu/cpu$i/online\"\n                        echo \"$gov\" >\"/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor\"\n                    fi\n                done\n            fi\n            \n            # Support for the Nyx kernel and others; Revert a workqueue power efficient featute\n            if [ -e \"/sys/module/workqueue/parameters/power_efficient\" ]; then\n                chmod 644 \"/sys/module/workqueue/parameters/power_efficient\"\n                echo 'Y' >\"/sys/module/workqueue/parameters/power_efficient\"\n            fi\n\n            # GPU's\n            if [ -w \"/sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor\" ]; then\n                # Default GPU governor for old Qcomm GPU's\n                if [ \"`getprop ro.build.product`\" = \"jfltexx\"  -a   \"`getprop ro.system.build.version.release`\" -ge \"12\" ]; then\n                    echo 'performance' >\"/sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor\"\n                else\n                    echo 'ondemand' >\"/sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor\"\n                fi\n                if [ -r \"/sys/class/kgsl/kgsl-3d0/num_pwrlevels\"  -a  -w \"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\" ]; then\n                    # Set the min power level to be minimum\n                    local x=\"4\"\n                    local tmp\n                    read x <\"/sys/class/kgsl/kgsl-3d0/num_pwrlevels\"\n                    x=\"`expr $x - 1`\"\n                    if [ -n \"$x\" ]; then\n                        read tmp <\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                        if [ \"$tmp\" -ne \"$x\" ]; then\n                            echo \"$x\" >\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                        fi\n                    fi\n                fi\n            elif [ -w \"/sys/class/kgsl/kgsl-3d0/devfreq/governor\" ]; then\n                local x\n                # Default GPU governor for Qcomm GPU's\n                echo 'msm-adreno-tz' >\"/sys/class/kgsl/kgsl-3d0/devfreq/governor\"\n                sleep 0.1\n                if [ -r \"/sys/class/kgsl/kgsl-3d0/num_pwrlevels\"  -a  -w \"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\" ]; then\n                    # Set the min power level to be minimum\n                    x=\"6\"\n                    local tmp\n                    read x <\"/sys/class/kgsl/kgsl-3d0/num_pwrlevels\"\n                    x=\"`expr $x - 1`\"\n                    if [ -n \"$x\" ]; then\n                        read tmp <\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                        if [ \"$tmp\" -ne \"$x\" ]; then\n                            echo \"$x\" >\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                        fi\n                    fi\n                fi\n                if [ -r \"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"  -a  -w \"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\" ]; then\n                    read x <\"/sys/class/kgsl/kgsl-3d0/min_pwrlevel\"\n                    if [ -n \"$x\" ]; then\n                        echo \"$x\" >\"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\"\n                    fi\n                fi\n                if [ -w \"/sys/class/kgsl/kgsl-3d0/devfreq/min_freq\" ]; then\n                    # Set the min freq to the lowest\n                    echo \"0\" >\"/sys/class/kgsl/kgsl-3d0/devfreq/min_freq\"\n                fi\n\n                # For some Qcomm GPU's, because they revert the governor after setting min_pwrlevel several times\n                for i in `seq 1 9`; do\n                    x=\"`echo \\\"scale=1;${i}/10\\\" | bc`\"\n                    sleep $x\n                    read x <\"/sys/class/kgsl/kgsl-3d0/devfreq/governor\"\n                    if [ \"$x\" = \"msm-adreno-tz\" ]; then\n                        break\n                    fi\n                    echo 'msm-adreno-tz' >\"/sys/class/kgsl/kgsl-3d0/devfreq/governor\"\n                done\n                if [ -w \"/sys/class/kgsl/kgsl-3d0/throttling\" ]; then\n                        echo \"1\" >\"/sys/class/kgsl/kgsl-3d0/throttling\"\n                fi\n                if [ -w \"/sys/class/devfreq/soc:qcom,gpubw/min_freq\" ]; then\n                    echo \"0\" >\"/sys/class/devfreq/soc:qcom,gpubw/min_freq\"\n                fi\n                local busmon=\"`getGpuBusmonPath`\"\n                if [ -w \"${busmon}/min_freq\" ]; then\n                    # Set the min freq\n                    echo \"0\" >\"${busmon}/min_freq\"\n                    echo \"gpubw_mon\" >\"${busmon}/governor\"\n                fi\n            elif [ -w \"/proc/gpufreq/gpufreq_opp_freq\" ]; then\n                # Variable frequency setting for MediaTek GPU's\n                echo '0' >\"/proc/gpufreq/gpufreq_opp_freq\"\n            elif [ -w \"/proc/gpufreqv2/fix_target_opp_index\" ]; then\n                # Variable frequency (index -1) setting for MediaTek GPU's\n                echo \"-1\" >\"/proc/gpufreqv2/fix_target_opp_index\"\n            elif [ -w \"/sys/devices/platform/1c500000.mali/hint_min_freq\" ]; then\n                # Variable frequency setting for Tensor GPU's\n                local freq=\"`getTensorGpuFreqKhz \\\"min\\\"`\"\n                if [ -n \"$freq\" ]; then\n                    echo \"$freq\" >\"/sys/devices/platform/1c500000.mali/hint_min_freq\"\n                fi\n            fi\n            \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            #CPU Governor\n            if [ -r \"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor\" ]; then\n                # Support for the Nyx kernel and others; Print the status of a workqueue power efficient featute\n                if [ -r \"/sys/module/workqueue/parameters/power_efficient\" ]; then\n                    local pf\n                    read pf <\"/sys/module/workqueue/parameters/power_efficient\"\n                    if [ \"$pf\" = \"Y\" ]; then\n                        pf=\"yes\"\n                    else\n                        pf=\"no\"\n                    fi\n                    echo \"  Gov. CPU: `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` (wq psave: $pf)\"\n                else\n                    echo \"  Gov. CPU: `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`\"\n                fi\n            fi\n            \n            if [ -r \"/sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor\" ]; then\n                # For old Qcomm GPU Governor\n                local freq gov\n                read gov <\"/sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor\"\n                if [ \"$gov\" = \"performance\" ]; then\n                    freq=\"`getQcomGpuFreq \\\"max\\\"`\"\n                    freq=\"`expr $freq / 1000000`MHz\"\n                    echo \"  Gov. GPU: performance (fixed: $freq)\"\n                else\n                    freq=\"`getQcomGpuFreq \\\"typical\\\"`\"\n                    freq=\"`expr $freq / 1000000`Mhz\"\n                    echo \"  Gov. GPU: $gov (typ.: $freq)\"\n                fi\n            elif [ -w \"/sys/class/kgsl/kgsl-3d0/devfreq/governor\" ]; then\n                # For Qcomm GPU Governor\n                local freq gov def_pwrl\n                read gov <\"/sys/class/kgsl/kgsl-3d0/devfreq/governor\"\n                if [ -r \"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\" ]; then\n                    read def_pwrl <\"/sys/class/kgsl/kgsl-3d0/default_pwrlevel\"\n                else\n                    def_pwrl=\"1\"\n                fi\n                if [ \"$gov\" = \"performance\"  -o  \"$def_pwrl\" -eq 0 ]; then\n                    freq=\"`getQcomGpuFreq \\\"max\\\"`\"\n                    freq=\"`expr $freq / 1000000`MHz\"\n                    echo \"  Gov. GPU: $gov (fixed: $freq)\"\n                else\n                    freq=\"`getQcomGpuFreq \\\"typical\\\"`\"\n                    freq=\"`expr $freq / 1000000`MHz\"\n                    echo \"  Gov. GPU: $gov (typ.: $freq)\"\n                fi\n            elif [ -r \"/proc/gpufreq/gpufreq_opp_freq\"  -o  -r \"/proc/gpufreqv2/gpu_working_opp_table\" ]; then\n                # For getting MediaTek GPU settings\n                local freq\n                if isMtkGpuFreqFixed; then\n                    freq=\"`getMtkGpuFreqKhz \\\"max\\\"`\"\n                    freq=\"`expr $freq / 1000`MHz\"\n                    echo \"  Gov. GPU: max freq (fixed: $freq)\"\n                else\n                    freq=\"`getMtkGpuFreqKhz \\\"typical\\\"`\"\n                    freq=\"`expr $freq / 1000`MHz\"\n                    echo \"  Gov. GPU: variable freq (typ.: $freq)\"\n                fi\n            elif [ -r \"/sys/devices/platform/1c500000.mali/cur_freq\" ]; then\n                # Get the current Tensor GPU frequency\n                local freq=\"`getTensorGpuFreqKhz`\"\n                if [ \"$freq\" = \"`getTensorGpuFreqKhz \\\"max\\\"`\" ]; then\n                    freq=\"`expr $freq / 1000`MHz\"\n                    echo \"  Gov. GPU: max freq (fixed: $freq)\"\n                else\n                    freq=\"`expr $freq / 1000`MHz\"\n                    echo \"  Gov. GPU: variable freq (typ.: $freq)\"\n                fi\n            fi\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction reduceLogdJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n\n        if [ $flag -gt 0 ]; then\n        \n            # Stop the Logd servers\n            if [ \"`getprop init.svc.logd`\" = \"running\" ]; then\n                setprop ctl.stop logd\n            elif [ \"`getprop init.svc.logd`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.logd`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            if [ \"`getprop init.svc.traced`\" = \"running\" ]; then\n                setprop ctl.stop traced\n            elif [ \"`getprop init.svc.traced`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.traced`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            if [ \"`getprop init.svc.traced_probes`\" = \"running\" ]; then\n                setprop ctl.stop traced_probes\n            elif [ \"`getprop init.svc.traced_probes`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.traced_probes`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            \n        elif [ $flag -lt 0 ]; then\n        \n            # Start the Logd servers\n            if [ \"`getprop init.svc.traced_probes`\" = \"stopped\" ]; then\n                setprop ctl.start traced_probes\n            elif [ \"`getprop init.svc.traced_probes`\" = \"stopping\" ]; then\n                setprop ctl.restart traced_probes\n            fi\n            if [ \"`getprop init.svc.traced`\" = \"stopped\" ]; then\n                setprop ctl.start traced\n            elif [ \"`getprop init.svc.traced`\" = \"stopping\" ]; then\n                setprop ctl.restart traced\n            fi\n            if [ \"`getprop init.svc.logd`\" = \"stopped\" ]; then\n                setprop ctl.start logd\n            elif [ \"`getprop init.svc.logd`\" = \"stopping\" ]; then\n                setprop ctl.restart logd\n            fi\n            \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            local val=\"`getprop init.svc.logd`\"\n            if [ -n  \"$val\" ]; then\n                echo \"  Logd main server: $val\"\n            fi\n            val=\"`getprop init.svc.traced`\"\n            if [ -n  \"$val\" ]; then\n                echo \"  Logd traced server: $val\"\n            fi\n            val=\"`getprop init.svc.traced_probes`\"\n            if [ -n  \"$val\" ]; then\n                echo \"  Logd traced_probes server: $val\"\n            fi\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction reduceCameraJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n\n        if [ $flag -gt 0 ]; then\n        \n            # Stop the camera servers\n            if [ \"`getprop init.svc.qcamerasvr`\" = \"running\" ]; then\n                setprop ctl.stop qcamerasvr\n            elif [ \"`getprop init.svc.qcamerasvr`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.qcamerasvr`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            if [ \"`getprop init.svc.vendor.qcamerasvr`\" = \"running\" ]; then\n                setprop ctl.stop vendor.qcamerasvr\n            elif [ \"`getprop init.svc.vendor.qcamerasvr`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.vendor.qcamerasvr`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            if [ \"`getprop init.svc.cameraserver`\" = \"running\" ]; then\n                setprop ctl.stop cameraserver\n            elif [ \"`getprop init.svc.cameraserver`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.cameraserver`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            if [ \"`getprop init.svc.camerasloganserver`\" = \"running\" ]; then\n                setprop ctl.stop camerasloganserver\n            elif [ \"`getprop init.svc.camerasloganserver`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.camerasloganserver`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            if [ \"`getprop init.svc.camerahalserver`\" = \"running\" ]; then\n                setprop ctl.stop camerahalserver\n            elif [ \"`getprop init.svc.camerahalserver`\" = \"stopping\" ]; then\n                local pid=\"`getprop init.svc_debug_pid.camerahalserver`\"\n                if [ -n \"$pid\" ]; then\n                    kill -HUP $pid 1>\"/dev/null\" 2>&1\n                fi\n            fi\n            \n        elif [ $flag -lt 0 ]; then\n        \n            # Start the camera servers\n            if [ \"`getprop init.svc.qcamerasvr`\" = \"stopped\" ]; then\n                setprop ctl.start qcamerasvr\n            elif [ \"`getprop init.svc.qcamerasvr`\" = \"stopping\" ]; then\n                setprop ctl.restart qcamerasvr\n            fi\n            if [ \"`getprop init.svc.vendor.qcamerasvr`\" = \"stopped\" ]; then\n                setprop ctl.start vendor.qcamerasvr\n            elif [ \"`getprop init.svc.vendor.qcamerasvr`\" = \"stopping\" ]; then\n                setprop ctl.restart vendor.qcamerasvr\n            fi\n            if [ \"`getprop init.svc.cameraserver`\" = \"stopped\" ]; then\n                setprop ctl.start cameraserver\n            fi\n            if [ \"`getprop init.svc.camerasloganserver`\" = \"stopped\" ]; then\n                setprop ctl.start camerasloganserver\n            fi\n            if [ \"`getprop init.svc.camerahalserver`\" = \"stopped\" ]; then\n                setprop ctl.start camerahalserver\n            fi\n            \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            local val=\"`getprop init.svc.qcamerasvr`\"\n            if [ -n  \"$val\" ]; then\n                echo \"  Qcom camera server: $val\"\n                return 0\n            fi\n            val=\"`getprop init.svc.vendor.qcamerasvr`\"\n            if [ -n  \"$val\" ]; then\n                echo \"  Qcom camera server: $val\"\n                return 0\n            fi\n            val=\"`getprop init.svc.cameraserver`\"\n            if [ -n  \"$val\" ]; then\n                echo \"  Camera server: $val\"\n                return 0\n            fi\n        fi\n        \n    else\n        return 1\n    fi\n}\n\n# choose the best I/O scheduler for very Hifi audio outputs, and output it into the standard output\nfunction chooseBestIOScheduler()\n{\n    if [ $# -eq 1  -a  -r \"$1\" ]; then\n        local x scheds ret_val=\"\"\n  \n        scheds=\"`tr -d '[]' <\\\"$1\\\"`\"\n        for x in $scheds; do\n            case \"$x\" in\n                \"deadline\" ) ret_val=\"deadline\"; break ;;\n                \"mq-deadline\" ) ret_val=\"mq-deadline\"; break ;;\n                \"kyber\" ) ret_val=\"kyber\" ;;\n                \"cfq\" ) if [ \"$ret_val\" != \"kyber\" ]; then ret_val=\"cfq\"; fi ;;\n                \"noop\" | \"none\" ) if [ \"$ret_val\" != \"cfq\"  -o  \"$ret_val\" != \"kyber\" ]; then ret_val=\"$x\"; fi ;;\n                * ) ;;\n            esac\n        done\n        echo \"$ret_val\"\n        return 0\n    else\n        return 1\n    fi\n}\n\nfunction selectedScheduler()\n{\n    if [ $# -eq 1  -a  -r \"$1\" ]; then\n        local sched=\"`cat \\\"$1\\\"`\"\n        if [ -n \"$sched\" ]; then\n            local val\n            val=`expr \"$sched\" : '[^[]*\\[\\([^]]*\\)\\]'`\n            echo \"$val\"\n            return 0\n        else\n            return 1\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction validScheduler()\n{\n    if [ $# -eq 2  -a  -r \"$1\" ]; then\n        local lst\n        local sched=\"$2\"\n        local i\n        lst=\"`tr -d '[]' <\\\"$1\\\"`\"\n        for i in $lst; do\n            if [ \"$i\" = \"$sched\" ]; then\n                return 0\n            fi\n        done\n        return 1\n    else\n        return 1\n    fi\n}\n\nfunction nth()\n{\n    if [ $# -eq 2  -a  -n \"$1\" ]; then\n    \n        if [ -n \"$2\"  -a  \"$2\" -gt 0 ]; then\n        \n            local v\n            local i=1\n            \n            for v in $1; do\n                if [ \"$2\" -eq \"$i\" ]; then\n                    echo \"$v\"\n                    return 0\n                else\n                    i=\"`expr $i + 1`\"\n                fi\n            done\n            return 1\n            \n        else\n        \n            retrun 1\n            \n        fi\n        \n    else\n    \n        return 1\n        \n    fi\n}\n\nfunction getSocModelName()\n{\n    local modelName=\"`getprop ro.board.platform`\"\n    case \"$modelName\" in\n            sd* | msm* | exynos* | mt* | gs* )\n                echo \"$modelName\"\n                return 0\n                ;;\n            zuma* )\n                echo \"gs301\"\n                return 0\n                ;;\n            * )\n                case \"`getprop ro.boot.hardware`\" in\n                    qcom )\n                        # High performance Qcomm SoC devices tend to have code names\n                        # (not real SoC name, but compatible name in this library)\n                        case \"$modelName\" in\n                            \"kona\" | \"kalama\" | \"shima\" | \"yupik\" )\n                                echo \"sdm870\"\n                                ;;\n                            \"bengal\" )\n                                echo \"sdm680\"\n                                ;;\n                            \"holi\" )\n                                echo \"sdm680\"\n                                ;;\n                            \"pineapple\" )\n                                echo \"sm8635\"\n                                ;;\n                            * )\n                                 if [ -r \"/sys/devices/system/cpu/cpu7/core_ctl/enable\" ]; then\n                                    echo \"sdm855\"\n                                 else\n                                    echo \"sdm845\"\n                                 fi\n                                ;;\n                        esac\n                        return 0\n                        ;;\n                    * )\n                        echo \"unknown\"\n                        return 0\n                        ;;\n                esac\n                ;;\n    esac\n    \n    return 1\n}\n\nfunction adjustForSoC()\n{\n    if [ $# -eq 1  -a  -n \"$1\"  -a  \"$1\" -ge 0 ]; then\n        case \"`getSocModelName`\" in\n            sdm* | msm* | sd* | exynos* )\n                echo \"`expr  '(' $1 / 10 ')' '*' 10 + '(' '(' $1 % 10 ')' / 3 ')' '*' 3`\"\n                ;;\n            mt6* )\n                echo \"`expr '(' '(' $1 + 1 ')' / 4 ')' '*' 4`\"\n                ;;\n            * )\n                echo \"$1\"\n                ;;\n        esac\n        return 0\n        \n    else\n        return 1\n        \n    fi\n}\n\nfunction adjustForSoC_mq()\n{\n    if [ $# -eq 1  -a  -n \"$1\"  -a  \"$1\" -ge 0 ]; then\n        local kername=\"`uname -r`\"\n        kername=${kername#*-}\n\n        case  \"$kername\" in\n            perf* | android* )\n                # Round to multiples of 4; for Xiaomi Bengal and Google kernels\n                echo \"`expr  '(' '(' $1 + 2 ')' / 4 ')' '*' 4`\"\n                return 0\n                ;;\n            SouthWest* | Nyx* )\n                # for Nyx and SouthWest kernels (100Hz)\n                if [ \"$1\" -ge 250 ]; then\n                    # Round off (<7) and up (>=7)\n                    echo \"`expr  '(' '(' $1 + 3 ')' / 10 ')' '*' 10`\"\n                else\n                    # Round down\n                    echo \"`expr  '(' '(' $1 + 0 ')' / 10 ')' '*' 10`\"\n                fi\n                return 0\n                ;;\n            * )\n               if [ \"`getprop ro.build.product`\" = \"clover\"  -a  \"`getprop ro.build.version.release`\" -ge \"14\" ]; then\n                    # Not Round for A14 and later (1000Hz kernels)\n                    echo \"$1\"\n                else\n                    adjustForSoC \"$1\"\n                fi\n                 return 0\n                ;;\n        esac\n        return 0\n        \n    else\n        return 1\n        \n    fi\n}\n\nfunction adjustSchedulerParameter()\n{\n    if [ $# -eq 3 ]; then\n        \n        if [ \"$1\" = \"deadline\"  -a  -n \"$2\"  -a  -n \"$3\" ]; then\n            case \"$2\" in\n                \"read_expire\" )\n                    echo \"`adjustForSoC \\\"$3\\\"`\"\n                    ;;\n                \"write_expire\" )\n                    echo \"`adjustForSoC \\\"$3\\\"`\"\n                    ;;\n                * )\n                    echo \"$3\"\n                    ;;\n            esac\n        elif [ \"$1\" = \"mq-deadline\"  -a  -n \"$2\"  -a  -n \"$3\" ]; then\n            case \"$2\" in\n                \"read_expire\" )\n                    echo \"`adjustForSoC_mq \\\"$3\\\"`\"\n                    ;;\n                \"write_expire\" )\n                    echo \"`adjustForSoC_mq \\\"$3\\\"`\"\n                    ;;\n                * )\n                    echo \"$3\"\n                    ;;\n            esac\n        else\n            echo \"$3\"\n        fi\n        return 0\n        \n    else\n        \n        return 1\n        \n    fi\n}\n\nfunction getSchedulerParams()\n{\n    if [ $# -eq 1 ]; then\n        case \"$1\" in\n            \"deadline\" | \"mq-deadline\" )\n                echo \"fifo_batch front_merges read_expire write_expire writes_starved\"\n                ;;\n            \"cfq\" )\n                echo \"back_seek_penalty fifo_expire_async fifo_expire_sync group_idle low_latency quantum slice_async slice_async_rq \\\n                    slice_async_us slice_idle slice_sync target_latency\"\n                ;;\n            \"kyber\" )\n                echo \"read_lat_nsec write_lat_nsec\"\n                ;;\n            \"noop\" | \"none\" | * )\n                echo \"\"\n                ;;\n        esac\n        return 0\n    else\n        return 1\n    fi\n}\n\nfunction getSchedulerValues()\n{\n    if [ $# -eq 2 ]; then\n        case \"$1\" in\n            \"deadline\" | \"mq-deadline\" )\n                #   fifo_batch front_merges read_expire write_expire writes_starved\n                case \"$2\" in\n                    \"light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )\n                                echo \"71 0 28 496 0\"\n                                ;;\n                            sdm8* )\n                                echo \"73 0 24 484 0\"\n                                ;;\n                            * )\n                                echo \"64 0 32 504 0\"\n                                ;;\n                        esac\n                        ;;\n                    \"m-light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )\n                                echo \"92 0 36 516 0\"\n                                ;;\n                            sdm8* )\n                                echo \"92 0 36 516 0\"\n                                ;;\n                            sdm* | msm* | sd* | exynos* )\n                                echo \"92 0 36 516 0\"\n                                ;;\n                            mt68* )\n                                echo \"92 0 36 516 0\"\n                                ;;\n                            mt67[7-9]? )\n                                echo \"92 0 36 516 0\"\n                                ;;\n                            * )\n                                echo \"92 0 36 516 0\"\n                                ;;\n                        esac\n                        ;;\n                    \"boost\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* )\n                                echo \"139 0 36 516 0\"\n                                ;;\n                            sdm8[5-9]* | sdm9* )\n                                echo \"145 0 36 516 0\"\n                                ;;\n                            gs* )\n                                echo \"145 0 36 516 0\"\n                                ;;\n                            sdm8* )\n                                echo \"133 0 36 516 0\"\n                                ;;\n                            sdm* | msm* | sd* | exynos* )\n                                echo \"133 0 38 517 0\"\n                                ;;\n                            mt68* )\n                                echo \"149 0 36 516 0\"\n                                ;;\n                            mt67[7-9]? )\n                                echo \"139 0 36 516 0\"\n                                ;;\n                            * )\n                                echo \"139 0 36 516 0\"\n                                ;;\n                        esac\n                        ;;\n                    \"medium\" | *)\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm8[5-9]* | sdm9* )\n                                echo \"127 0 36 516 0\"\n                                ;;\n                            gs* )\n                                echo \"127 0 36 516 0\"\n                                ;;\n                            sdm8* )\n                                echo \"127 0 36 516 0\"\n                                ;;\n                            sdm* | msm* | sd* | exynos* )\n                                echo \"127 0 38 517 0\"\n                                ;;\n                            mt68* )\n                                echo \"127 0 36 516 0\"\n                                ;;\n                            mt67[7-9]? )\n                                echo \"127 0 36 516 0\"\n                                ;;\n                            * )\n                                echo \"127 0 36 516 0\"\n                                ;;\n                        esac\n                        ;;\n                esac\n                ;;\n                \n            \"cfq\" )\n                #   back_seek_penalty fifo_expire_async fifo_expire_sync group_idle low_latency quantum slice_async slice_async_rq\n                #       slice_async_us slice_idle slice_sync target_latency\n                case \"$2\" in\n                    \"light\" )\n                        echo \"1 3 3 0 1 1 3 46 3000 0 3 3\"\n                        ;;\n                    \"m-light\" )\n                        echo \"1 3 3 0 1 1 3 51 3000 0 3 3\"\n                        ;;\n                    \"boost\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | mt68* | gs* | sd* | exynos* )\n                                echo \"1 1 1 0 1 1 0 77 877 0 1 1\"\n                                ;;\n                            * )\n                                echo \"1 3 3 0 1 1 3 59 3000 0 3 3\"\n                                ;;\n                        esac\n                        ;;\n                    \"medium\" | * )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | mt68* | gs* | sd* | exynos* )\n                                echo \"1 1 1 0 1 1 0 77 877 0 1 1\"\n                                ;;\n                            * )\n                                echo \"1 3 3 0 1 1 3 59 3000 0 3 3\"\n                                ;;\n                        esac\n                        ;;\n                esac\n                ;;\n                \n            \"kyber\" )\n                #  read_lat_nsec write_lat_nsec\n                echo \"1000001 1000001\"\n                ;;\n                \n            \"noop\" | \"none\" | * )\n                echo \"\"\n                ;;\n                \n        esac\n        return 0\n    else\n        return 1\n    fi\n}\n\nfunction getSchedulerNrRequests()\n{\n    if [ $# -eq 2 ]; then\n        \n        case \"$1\" in\n            \"mq-deadline\" | \"kyber\" | \"bfq\" )\n                case \"`getSocModelName`\" in\n                    sm[6-8]* )\n                        echo \"2031\"\n                        ;;\n                    gs* )\n                        echo \"2031\"\n                        ;;\n                    mt68* )\n                        echo \"2031\"\n                        ;;\n                    * )\n                        echo \"2031\"\n                        ;;\n                esac\n                ;;\n                \n            \"none\" )\n                echo \"31\"\n                ;;\n                \n            \"deadline\" )\n                case \"$2\" in\n                    \"light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )\n                                echo \"80645\"\n                                ;;\n                            sdm8* )\n                                echo \"80000\"\n                                ;;\n                            sdm* | msm* | sd* | exynos* )\n                                echo \"81660\"\n                                ;;\n                            * )\n                                echo \"78550\"\n                                ;;\n                        esac\n                        ;;\n                    \"m-light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )\n                                echo \"86170\"\n                                ;;\n                            sdm8* )\n                                echo \"86164\"\n                                ;;\n                            sdm* | msm* | sd* | exynos* )\n                                echo \"86170\"\n                                ;;\n                            mt68* )\n                                echo \"86174\"\n                                ;;\n                            mt67[6-9]? )\n                                echo \"86172\"\n                                ;;\n                            * )\n                                echo \"86172\"\n                                ;;\n                        esac\n                        ;;\n                    \"boost\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* )\n                                echo \"86181\"\n                                ;;\n                            sdm8[5-9]* | sdm9* )\n                                echo \"86179\"\n                                ;;\n                            gs* )\n                                echo \"86181\"\n                                ;;\n                            sdm8* )\n                                echo \"86193\"\n                                ;;\n                            sdm* | msm* | sd* | exynos* )\n                                echo \"86193\"\n                                ;;\n                            mt68* )\n                                echo \"86181\"\n                                ;;\n                            mt67[7-9]? )\n                                echo \"86181\"\n                                ;;\n                            * )\n                                echo \"86181\"\n                                ;;\n                        esac\n                        ;;\n                    \"medium\" | * )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )\n                                echo \"86179\"\n                                ;;\n                            sdm8* )\n                                echo \"86179\"\n                                ;;\n                            sdm* | msm* | sd* | exynos* )\n                                echo \"86179\"\n                                ;;\n                            mt68* )\n                                echo \"86179\"\n                                ;;\n                            mt67[6-9]? )\n                                echo \"86179\"\n                                ;;\n                            * )\n                                echo \"86179\"\n                                ;;\n                        esac\n                        ;;\n                esac\n                ;;\n                \n            \"cfq\" )\n                case \"$2\" in\n                    \"light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"86021\"\n                                ;;\n                            * )\n                                echo \"86021\"\n                                ;;\n                        esac\n                        ;;\n                    \"m-light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"86164\"\n                                ;;\n                            * )\n                                echo \"86164\"\n                                ;;\n                        esac\n                        ;;\n                    \"boost\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"86172\"\n                                ;;\n                            * )\n                                echo \"86172\"\n                                ;;\n                        esac\n                        ;;\n                    \"medium\" | * )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"86172\"\n                                ;;\n                            * )\n                                echo \"86172\"\n                                ;;\n                        esac\n                        ;;\n                esac\n                ;;\n            \n            \"noop\" | * )\n                case \"$2\" in\n                    \"light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"80645\"\n                                ;;\n                            * )\n                                echo \"80645\"\n                                ;;\n                        esac\n                        ;;\n                    \"m-light\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"86164\"\n                                ;;\n                            * )\n                                echo \"86164\"\n                                ;;\n                        esac\n                        ;;\n                    \"boost\" )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"86172\"\n                                ;;\n                            * )\n                                echo \"86172\"\n                                ;;\n                        esac\n                        ;;\n                    \"medium\" | * )\n                        case \"`getSocModelName`\" in\n                            sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )\n                                echo \"86172\"\n                                ;;\n                            * )\n                                echo \"86172\"\n                                ;;\n                        esac\n                        ;;\n                esac\n               ;;\n                \n        esac\n        return 0\n    else\n        return 1\n    fi\n}\n\nfunction reduceIoJitter() \n{\n    if [ $# -eq 4 ]; then\n        local flag=\"$1\"\n        local ioScheduler=\"$2\"\n        local toneMode=\"$3\"\n        local printStatus=\"$4\"\n\n        if [ $flag -gt 0 ]; then\n        \n            local sched params vals nr_requests\n            local i p v j\n            for i in sda mmcblk0 mmcblk1; do\n                if [ -d \"/sys/block/$i/queue\" ]; then\n                    if [ -z \"$ioScheduler\"  -o  \"$ioScheduler\" = \"*\" ]; then\n                        sched=\"`chooseBestIOScheduler \\\"/sys/block/$i/queue/scheduler\\\"`\"\n                    else\n                        sched=\"$ioScheduler\"\n                    fi\n                    if validScheduler \"/sys/block/$i/queue/scheduler\" \"$sched\"; then\n                        \n                        params=\"`getSchedulerParams \\\"$sched\\\"`\"\n                        vals=\"`getSchedulerValues \\\"$sched\\\" \\\"$toneMode\\\"`\"\n                        nr_requests=\"`getSchedulerNrRequests \\\"$sched\\\" \\\"$toneMode\\\"`\"\n                        echo \"$sched\" >\"/sys/block/$i/queue/scheduler\"\n                        echo '17000' >\"/sys/block/$i/queue/read_ahead_kb\"\n                        echo '0' >\"/sys/block/$i/queue/iostats\"\n                        echo '0' >\"/sys/block/$i/queue/add_random\"\n                        echo '2' >\"/sys/block/$i/queue/rq_affinity\"\n                        echo '2' >\"/sys/block/$i/queue/nomerges\"\n                        echo \"$nr_requests\" >\"/sys/block/$i/queue/nr_requests\"\n                        # waiting for kenel tunables syncing\n                        sleep 0.05\n                        read v <\"/sys/block/$i/queue/nr_requests\"\n                        if [ \"$nr_requests\" -ne \"$v\" ]; then\n                            # If exceeding its max value, then use a safe kenel value (for multi-queue schedulers) within 2048 (except its \"none\" scheduler)\n                            if [ \"$sched\" = \"none\" ]; then\n                                echo \"31\" >\"/sys/block/$i/queue/nr_requests\"\n                            else\n                                echo \"2031\" >\"/sys/block/$i/queue/nr_requests\"\n                            fi\n                        fi\n                        \n                        # For 5.10 or later Kernels\n                        if [ \"$sched\" = \"mq-deadline\" ]; then\n                            if [ -w \"/sys/block/$i/queue/iosched/async_depth\" ]; then\n                                case \"`getSocModelName`\" in\n                                    sm[6-8]* )\n                                        echo '30' >\"/sys/block/$i/queue/iosched/async_depth\"\n                                        ;;\n                                    gs* )\n                                        echo '30' >\"/sys/block/$i/queue/iosched/async_depth\"\n                                        ;;\n                                    mt68* )\n                                        echo '30' >\"/sys/block/$i/queue/iosched/async_depth\"\n                                        ;;\n                                    * )\n                                        echo '30' >\"/sys/block/$i/queue/iosched/async_depth\"\n                                        ;;\n                                esac\n                            fi\n                            if [ -w \"/sys/block/$i/queue/iosched/prio_aging_expire\" ]; then\n                                case \"`getSocModelName`\" in\n                                    sm[6-8]* )\n                                        echo '6903164' >\"/sys/block/$i/queue/iosched/prio_aging_expire\"\n                                        ;;\n                                    gs* )\n                                        echo '6903164' >\"/sys/block/$i/queue/iosched/prio_aging_expire\"\n                                        ;;\n                                    * )\n                                        echo '6903152' >\"/sys/block/$i/queue/iosched/prio_aging_expire\"\n                                        ;;\n                                esac\n                            elif [ -w \"/sys/block/$i/queue/iosched/aging_expire\" ]; then\n                                # for MTK Dimensity\n                                echo '6903164' >\"/sys/block/$i/queue/iosched/aging_expire\"\n                            fi\n                        fi\n                        \n                        j=1\n                        for p in $params; do\n                            v=\"`nth \\\"$vals\\\" \\\"$j\\\"`\"\n                            v=\"`adjustSchedulerParameter \\\"$sched\\\" \\\"$p\\\" \\\"$v\\\"`\"\n                            if [ -w \"/sys/block/$i/queue/iosched/$p\"  -a  -n \"$v\"  -a  \"$v\" -ge 0 ]; then\n                                echo \"$v\" >\"/sys/block/$i/queue/iosched/$p\"\n                            fi\n                            j=\"`expr $j + 1`\"\n                        done\n                        \n                    else\n                        \n                        local sched_lst=\"`tr -d '[]'  <\\\"/sys/block/$i/queue/scheduler\\\"`\"\n                        echo \"Warning: ignoring wrong I/O scheduler (\\\"$sched\\\") settings for block device \\\"/dev/$i\\\".\" 1>&2\n                        echo \"  available I/O schedulers: $sched_lst\" 1>&2\n                        \n                    fi\n                fi\n            done\n            \n        elif [ $flag -lt 0 ]; then\n        \n            for i in sda mmcblk0 mmcblk1; do\n                if [ -d \"/sys/block/$i/queue\" ]; then\n                    if validScheduler \"/sys/block/$i/queue/scheduler\" \"noop\"; then\n                        echo 'noop' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif validScheduler \"/sys/block/$i/queue/scheduler\" \"none\"; then\n                        echo 'none' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    fi\n                    \n                    local kerVersion=\"`uname -r`\"\n                    kerVersion=${kerVersion%%.*}\n                    if [ \"`getprop ro.build.product`\" = \"jfltexx\" ] && validScheduler \"/sys/block/$i/queue/scheduler\" \"deadline\"; then\n                        echo 'deadline' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif [ \"$kerVersion\" -ge 6 ] && validScheduler \"/sys/block/$i/queue/scheduler\" \"mq-deadline\"; then\n                        echo 'mq-deadline' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif validScheduler \"/sys/block/$i/queue/scheduler\" \"ssg\"; then\n                        echo 'ssg' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif [ \"`getprop ro.soc.manufacturer`\" = \"Mediatek\"  -a  \"$kerVersion\" -eq 5 ] \\\n                          && validScheduler \"/sys/block/$i/queue/scheduler\" \"mq-deadline\"; then\n                        echo 'mq-deadline' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif validScheduler \"/sys/block/$i/queue/scheduler\" \"cfq\"; then\n                        echo 'cfq' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif validScheduler \"/sys/block/$i/queue/scheduler\" \"bfq\"; then\n                        echo 'bfq' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif validScheduler \"/sys/block/$i/queue/scheduler\" \"mq-deadline\"; then\n                        echo 'mq-deadline' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif validScheduler \"/sys/block/$i/queue/scheduler\" \"kyber\"; then\n                        echo 'kyber' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    elif validScheduler \"/sys/block/$i/queue/scheduler\" \"deadline\"; then\n                        echo 'deadline' >\"/sys/block/$i/queue/scheduler\"\n                        sleep 0.05\n                    fi\n                    \n                    echo '1' >\"/sys/block/$i/queue/iostats\"\n                    echo '0' >\"/sys/block/$i/queue/add_random\"\n                    echo '1' >\"/sys/block/$i/queue/rq_affinity\"\n                    echo '0' >\"/sys/block/$i/queue/nomerges\"\n                    \n                    case \"`getSocModelName`\" in\n                        sm[6-8]* | sdm8[5-9]* | sdm9* | sdm66* )\n                            echo '512' >\"/sys/block/$i/queue/read_ahead_kb\"\n                            echo '128' >\"/sys/block/$i/queue/nr_requests\"\n                            ;;\n                        gs* )\n                            echo '128' >\"/sys/block/$i/queue/read_ahead_kb\"\n                            echo '64' >\"/sys/block/$i/queue/nr_requests\"\n                            ;;\n                        * )\n                            if [ \"`getprop ro.build.product`\" = \"jfltexx\"  -a   \"`getprop ro.system.build.version.release`\" -ge \"12\" ]; then\n                                echo '512' >\"/sys/block/$i/queue/read_ahead_kb\"\n                            else\n                                echo '128' >\"/sys/block/$i/queue/read_ahead_kb\"\n                            fi\n                            \n                            echo '128' >\"/sys/block/$i/queue/nr_requests\"\n                            ;;\n                    esac\n                fi\n            done\n            \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            local i j val lst\n            for i in sda mmcblk0 mmcblk1; do\n                if [ -d \"/sys/block/$i/queue\" ]; then\n                    val=\"`selectedScheduler \\\"/sys/block/$i/queue/scheduler\\\"`\"\n                    echo \"  I/O scheduler: $val\"\n                    lst=\"`ls \\\"/sys/block/$i/queue/iosched/\\\"*`\" 2>\"/dev/null\"\n                    if [ -n \"$lst\" ]; then\n                        echo \"    {\"\n                        for j in $lst; do\n                            val=\"`cat \\\"$j\\\"`\"\n                            echo \"      ${j##*/}: $val\"\n                        done\n                        echo \"    }\"\n                    fi\n                    val=\"`cat \\\"/sys/block/$i/queue/read_ahead_kb\\\"`\"\n                    echo \"  I/O read ahead size: $val KB\"\n                    val=\"`cat \\\"/sys/block/$i/queue/iostats\\\"`\"\n                    echo \"  I/O iostat: $val\"\n                    val=\"`cat \\\"/sys/block/$i/queue/rq_affinity\\\"`\"\n                    echo \"  I/O rq affinity: $val\"\n                    val=\"`cat \\\"/sys/block/$i/queue/nomerges\\\"`\"\n                    echo \"  I/O nomerges: $val\"\n                    val=\"`cat \\\"/sys/block/$i/queue/nr_requests\\\"`\"\n                    echo \"  I/O nr requests: $val\"\n                    break\n                fi\n            done\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction reduceVmJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n\n        if [ $flag -gt 0 ]; then\n        \n            if [ -w \"/proc/sys/vm/swappiness\" ]; then\n                echo '0' >\"/proc/sys/vm/swappiness\"\n            fi\n            if [ -w \"/proc/sys/vm/direct_swappiness\" ]; then\n                echo '0' >\"/proc/sys/vm/direct_swappiness\"\n            fi\n            if [ -w \"/proc/sys/vm/dirty_ratio\" ]; then\n                echo '100' >\"/proc/sys/vm/dirty_ratio\"\n            fi\n            if [ -w \"/proc/sys/vm/dirty_background_ratio\" ]; then\n                echo '100' >\"/proc/sys/vm/dirty_background_ratio\"\n            elif [ -w \"/proc/sys/vm/dirty_background_ratio_nosys\" ]; then\n                echo '100' >\"/proc/sys/vm/dirty_background_ratio_nosys\"\n            fi\n            if [ -w \"/proc/sys/vm/dirty_expire_centisecs\" ]; then\n                echo '1201001' >\"/proc/sys/vm/dirty_expire_centisecs\"\n            elif [ -w \"/proc/sys/vm/dirty_expire_centisecs_nosys\" ]; then\n                echo '1201001' >\"/proc/sys/vm/dirty_expire_centisecs_nosys\"\n            fi\n            echo '221001' >\"/proc/sys/vm/dirty_writeback_centisecs\"\n            echo '1' >\"/proc/sys/vm/laptop_mode\"\n            if [ -w \"/proc/sys/vm/swap_ratio\" ]; then\n                echo '0' >\"/proc/sys/vm/swap_ratio\"\n            fi\n            if [ -w \"/proc/sys/vm/swap_ratio_enable\" ]; then\n                echo '1' >\"/proc/sys/vm/swap_ratio_enable\"\n            fi\n            \n        elif [ $flag -lt 0 ]; then\n        \n            if [ -w \"/proc/sys/vm/swappiness\" ]; then\n                echo '60' >\"/proc/sys/vm/swappiness\"\n            fi\n            if [ -w \"/proc/sys/vm/direct_swappiness\" ]; then\n                echo '60' >\"/proc/sys/vm/direct_swappiness\"\n            fi\n            if [ -w \"/proc/sys/vm/dirty_ratio\" ]; then\n                echo '20' >\"/proc/sys/vm/dirty_ratio\"\n            fi\n            if [ -w \"/proc/sys/vm/dirty_background_ratio\" ]; then\n                echo '10' >\"/proc/sys/vm/dirty_background_ratio\"\n            elif [ -w \"/proc/sys/vm/dirty_background_ratio_nosys\" ]; then\n                echo '10' >\"/proc/sys/vm/dirty_background_ratio_nosys\"\n            fi\n            if [ -w \"/proc/sys/vm/dirty_expire_centisecs\" ]; then\n                echo '200' >\"/proc/sys/vm/dirty_expire_centisecs\"\n                echo '500' >\"/proc/sys/vm/dirty_writeback_centisecs\"\n            elif [ -w \"/proc/sys/vm/dirty_expire_centisecs_nosys\" ]; then\n                echo '3000' >\"/proc/sys/vm/dirty_expire_centisecs_nosys\"\n                echo '0' >\"/proc/sys/vm/dirty_writeback_centisecs\"\n            fi\n            echo '0' >\"/proc/sys/vm/laptop_mode\"\n            if [ -w \"/proc/sys/vm/swap_ratio\" ]; then\n                echo '100' >\"/proc/sys/vm/swap_ratio\"\n            fi\n            if [ -w \"/proc/sys/vm/swap_ratio_enable\" ]; then\n                echo '0' >\"/proc/sys/vm/swap_ratio_enable\"\n            fi\n            \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            # I don't know the reason, but \"read val <'/proc/sys/vm/swappiness'\", etc. cannot get its whole value (only first one character)\n            local val\n            if [ -r \"/proc/sys/vm/swappiness\" ]; then\n                val=\"`cat /proc/sys/vm/swappiness`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM swappiness: $val\"\n                fi\n            fi\n            if [ -r \"/proc/sys/vm/direct_swappiness\" ]; then\n                val=\"`cat /proc/sys/vm/direct_swappiness`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM direct_swappiness: $val\"\n                fi\n            fi\n            if [ -r \"/proc/sys/vm/dirty_ratio\" ]; then\n                val=\"`cat /proc/sys/vm/dirty_ratio`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM dirty ratio: $val\"\n                fi\n            fi\n            if [ -r \"/proc/sys/vm/dirty_background_ratio\" ]; then\n                val=\"`cat /proc/sys/vm/dirty_background_ratio`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM dirty background ratio: $val\"\n                fi\n            elif [ -r \"/proc/sys/vm/dirty_background_ratio_nosys\" ]; then\n                val=\"`cat /proc/sys/vm/dirty_background_ratio_nosys`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM dirty background ratio (nosys): $val\"\n                fi\n            fi\n            if [ -r \"/proc/sys/vm/dirty_expire_centisecs\" ]; then\n                val=\"`cat /proc/sys/vm/dirty_expire_centisecs`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM dirty expire centisecs: $val\"\n                fi\n            elif [ -r \"/proc/sys/vm/dirty_expire_centisecs_nosys\" ]; then\n                val=\"`cat /proc/sys/vm/dirty_expire_centisecs_nosys`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM dirty expire centisecs (nosys): $val\"\n                fi\n            fi\n            val=\"`cat /proc/sys/vm/dirty_writeback_centisecs`\"\n            if [ -n \"$val\" ]; then\n                echo \"  VM dirty writeback centisecs: $val\"\n            fi\n            val=\"`cat /proc/sys/vm/laptop_mode`\"\n            if [ \"$val\" = \"1\" ]; then\n                echo \"  VM laptop mode: on\"\n            else\n                echo \"  VM laptop mode: off\"\n            fi\n            if [ -r \"/proc/sys/vm/swap_ratio\" ]; then\n                val=\"`cat /proc/sys/vm/swap_ratio`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM swap_ratio: $val\"\n                fi\n            fi\n            if [ -r \"/proc/sys/vm/swap_ratio_enable\" ]; then\n                val=\"`cat /proc/sys/vm/swap_ratio_enable`\"\n                if [ -n \"$val\" ]; then\n                    echo \"  VM swap_ratio_enable: $val\"\n                fi\n            fi\n            # End of print status\n        fi\n        \n    else\n        return 1\n    fi\n}\n\nfunction reloadAudioserver()\n{\n    # wait for system boot completion and audiosever boot up\n    local i\n    for i in `seq 1 3` ; do\n        if [ \"`getprop sys.boot_completed`\" = \"1\"  -a  -n \"`getprop init.svc.audioserver`\" ]; then\n            break\n        fi\n        sleep 0.9\n    done\n\n    if [ -n \"`getprop init.svc.audioserver`\" ]; then\n\n        setprop ctl.restart audioserver\n        sleep 0.2\n        if [ \"`getprop init.svc.audioserver`\" != \"running\" ]; then\n            # workaround for Android 12 old devices hanging up the audioserver after \"setprop ctl.restart audioserver\" is executed\n            local pid=\"`getprop init.svc_debug_pid.audioserver`\"\n            if [ -n \"$pid\" ]; then\n                kill -HUP $pid 1>\"/dev/null\" 2>&1\n            fi\n            for i in `seq 1 10` ; do\n                sleep 0.2\n                if [ \"`getprop init.svc.audioserver`\" = \"running\" ]; then\n                    break\n                elif [ $i -eq 10 ]; then\n                    echo \"audioserver reload failed!\" 1>&2\n                    return 1\n                fi\n            done\n        fi\n        return 0\n        \n    else\n        echo \"audioserver is not found!\" 1>&2 \n        return 1\n    fi\n}\n\nfunction which_resetprop_command()\n{\n    type resetprop 1>\"/dev/null\" 2>&1\n    if [ $? -eq 0 ]; then\n        echo \"resetprop\"\n    else\n        type resetprop_phh 1>\"/dev/null\" 2>&1\n        if [ $? -eq 0 ]; then\n            echo \"resetprop_phh\"\n        else\n            return 1\n        fi\n    fi\n    return 0\n}\n\nfunction reduceEffectJitter()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n        local val\n\n        if [ $flag -gt 0 ]; then\n            resetprop_command=\"`which_resetprop_command`\"\n            if [ -n \"$resetprop_command\" ]; then\n                # Workaround for recent Pixel Firmwares (not to reboot when resetprop'ing)\n                \"$resetprop_command\" --delete ro.audio.ignore_effects 1>\"/dev/null\" 2>&1\n                # End of workaround\n                \n                \"$resetprop_command\" ro.audio.ignore_effects true\n                # support for Tensor devices, etc.\n                val=\"`getprop ro.audio.spatializer_enabled`\"\n                if [ -n \"$val\"  -a  \"$val\" = \"true\" ]; then\n                    # Workaround for recent Pixel Firmwares (not to reboot when resetprop'ing)\n                    \"$resetprop_command\" --delete ro.audio.spatializer_enabled 1>\"/dev/null\" 2>&1\n                    # End of workaround\n                    \n                    \"$resetprop_command\" ro.audio.spatializer_enabled false\n                fi\n                # Stop Tensor device's AOC daemon for reducing significant jitter\n                if [ \"`getprop init.svc.aocd`\" = \"running\" ]; then\n                    setprop ctl.stop aocd\n                fi\n                # Stop Tensor device's AOCX daemon for reducing significant jitter\n                if [ \"`getprop init.svc.aocxd`\" = \"running\" ]; then\n                    setprop ctl.stop aocxd\n                fi\n                reloadAudioserver\n            else\n                return 2\n            fi\n        elif [ $flag -lt 0 ]; then\n            resetprop_command=\"`which_resetprop_command`\"\n            if [ -n \"$resetprop_command\" ]; then\n                \"$resetprop_command\" --delete ro.audio.ignore_effects\n                # support for Tensor devices, etc.\n                val=\"`getprop ro.audio.spatializer_enabled`\"\n                if [ -n \"$val\"  -a  \"$val\" = \"false\" ]; then\n                    # Workaround for recent Pixel Firmwares (not to reboot when resetprop'ing)\n                    \"$resetprop_command\" --delete ro.audio.spatializer_enabled 1>\"/dev/null\" 2>&1\n                    # End of workaround\n                    \n                    \"$resetprop_command\" ro.audio.spatializer_enabled true\n                fi\n                if [ \"`getprop init.svc.aocd`\" = \"stopped\" ]; then\n                    setprop ctl.start aocd\n                fi\n                if [ \"`getprop init.svc.aocxd`\" = \"stopped\" ]; then\n                    setprop ctl.start aocxd\n                fi\n                reloadAudioserver\n            else\n                return 2\n            fi\n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            val=\"`getprop ro.audio.ignore_effects`\"\n            if [ -n \"$val\"  -a  \"$val\" = \"true\" ]; then\n                echo \"  Effects framework: disabled\"\n            else\n                echo \"  Effects framework: enabled\"\n            fi\n            \n            val=\"`getprop init.svc.aocd`\"\n            if [ -n \"$val\"  ]; then\n                echo \"  Effects AOC server: $val\"\n            fi\n            val=\"`getprop init.svc.aocxd`\"\n            if [ -n \"$val\"  ]; then\n                echo \"  Effects AOCX server: $val\"\n            fi\n            \n        fi\n        \n        return 0\n        \n    else\n        return 1\n    fi\n}\n\nfunction restartWifi()\n{\n    local val=\"`settings get global wifi_on`\"\n    \n    if [ -n \"$val\"  -a  \"$val\" != \"0\" ]; then\n        svc wifi disable\n        svc wifi enable\n    fi\n}\n\nfunction reduceWifiJitter ()\n{\n    if [ $# -eq 3 ]; then\n        local flag=\"$1\"\n        local restartFlag=\"$2\"\n        local printStatus=\"$3\"\n\n        if [ $flag -gt 0 ]; then\n        \n            # Reducing wifi jitter by suspend wifi optimizations\n            settings put global wifi_suspend_optimizations_enabled 0 1>\"/dev/null\" 2>&1\n            settings put secure adaptive_connectivity_enabled 0 1>\"/dev/null\" 2>&1\n            if [ \"$restartFlag\" = \"Restart\" ]; then\n                restartWifi\n            fi\n            \n        elif [ $flag -lt 0 ]; then\n        \n            # Revert wifi jitter by suspend wifi optimizations\n            settings delete global wifi_suspend_optimizations_enabled 1>\"/dev/null\" 2>&1\n            settings delete secure adaptive_connectivity_enabled 1>\"/dev/null\" 2>&1\n            if [ \"$restartFlag\" = \"Restart\" ]; then\n                restartWifi\n            fi\n        \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            local val=\"`settings get global wifi_suspend_optimizations_enabled`\"\n            if [ -n \"$val\"  -a  \"$val\" = \"0\" ]; then\n                echo \"  Wifi suspend optimizations: disabled\"\n            else\n                echo \"  Wifi suspend optimizations: enabled\"\n            fi\n            val=\"`settings get secure adaptive_connectivity_enabled`\"\n            if [ -n \"$val\"  -a  \"$val\" = \"0\" ]; then\n                echo \"  Wifi adaptive connectivity: disabled\"\n            else\n                echo \"  Wifi adaptive connectivity: enabled\"\n            fi\n        fi\n\n    else\n        return 1\n    fi\n}\n\nfunction reduceBatteryJitter ()\n{\n    if [ $# -eq 2 ]; then\n        local flag=\"$1\"\n        local printStatus=\"$2\"\n\n        if [ $flag -gt 0 ]; then\n        \n            # Reducing battery jitters\n            settings put global adaptive_battery_management_enabled 0 1>\"/dev/null\" 2>&1\n            settings put secure adaptive_charging_enabled 0 1>\"/dev/null\" 2>&1\n            \n        elif [ $flag -lt 0 ]; then\n        \n            # Revert battery jitters\n            settings delete global adaptive_battery_management_enabled 1>\"/dev/null\" 2>&1\n            settings delete secure adaptive_charging_enabled 1>\"/dev/null\" 2>&1\n        \n        fi\n        \n        if [ $printStatus -gt 0 ]; then\n            local val=\"`settings get global adaptive_battery_management_enabled`\"\n            if [ -n \"$val\"  -a  \"$val\" = \"0\" ]; then\n                echo \"  Battery adaptive management: disabled\"\n            else\n                echo \"  Battery adaptive management: enabled\"\n            fi\n            val=\"`settings get secure adaptive_charging_enabled`\"\n            if [ -n \"$val\"  -a  \"$val\" = \"0\" ]; then\n                echo \"  Battery adaptive charging: disabled\"\n            else\n                echo \"  Battery adaptive charging: enabled\"\n            fi\n        fi\n\n    else\n        return 1\n    fi\n}\n"
  },
  {
    "path": "module.prop",
    "content": "id=hifi-maximizer-mod\nname=Hifi Maximizer\nversion=v2.5.16\nversionCode=2516\nauthor=zyhk\ndescription=A module for maximizing the digital audio fidelity by reducing jitters on audio outputs (USB DACs, Bluetooth a2dp, DLNA, etc.)\n"
  },
  {
    "path": "post-fs-data.sh",
    "content": "#!/system/bin/sh\n\n# Do NOT assume where your module will be located.\n# ALWAYS use $MODDIR if you need to know where this script and module is placed.\n# This will make sure your module will still work if Magisk change its mount point in the future\n  MODDIR=${0%/*}\n\n# This script will be executed in post-fs-data mode\n\nif [ \\( -e \"${MODDIR%/*/*}/modules/usb-samplerate-unlocker\"  -a  ! -e \"${MODDIR%/*/*}/modules/usb-samplerate-unlocker/disable\" \\) \\\n        -o  -e \"${MODDIR%/*/*}/modules_update/usb-samplerate-unlocker\" ] || \\\n    [ \\( -e \"${MODDIR%/*/*}/modules/audio-samplerate-changer\"  -a  ! -e \"${MODDIR%/*/*}/modules/audio-samplerate-changer/disable\" \\) \\\n        -o  -e \"${MODDIR%/*/*}/modules_update/audio-samplerate-changer\" ]; then\n        \n    # If usb-samplerate-unlock or audio-samplerate-changer exists, save related libraries and file(s) elsewhere\n    # becausethey will do the same thing in themselves.\n    for d in \"lib\" \"lib64\"; do\n        for lname in \"libalsautils.so\" \"libalsautilsv2.so\"; do\n            if [ -r \"${MODDIR}/system/vendor/${d}/${lname}\" ]; then\n                mkdir -p \"${MODDIR}/save/vendor/${d}\"\n                mv \"${MODDIR}/system/vendor/${d}/${lname}\" \"${MODDIR}/save/vendor/${d}/${lname}\"\n            fi\n        done        \n    done\n    \n    for fname in \"audio_platform_configuration.xml\"; do\n        if [ -r \"${MODDIR}/system/vendor/etc/${fname}\" ]; then\n            mkdir -p \"${MODDIR}/save/vendor/etc\"\n            mv \"${MODDIR}/system/vendor/etc/${fname}\" \"${MODDIR}/save/vendor/etc/${fname}\"\n        fi\n    done\n    \nelse\n\n    # If usb-samplerate-unlock doesn't exist, restore related libraries and file(s) from their saved folders.\n    for d in \"lib\" \"lib64\"; do\n        for lname in \"libalsautils.so\" \"libalsautilsv2.so\"; do\n            if [ -r \"${MODDIR}/save/vendor/${d}/${lname}\"  -a  -e \"${MODDIR}/system/vendor/${d}\" ]; then\n                mv \"${MODDIR}/save/vendor/${d}/${lname}\" \"${MODDIR}/system/vendor/${d}/${lname}\"\n                chmod 644 \"${MODDIR}/system/vendor/${d}/${lname}\"\n            fi\n        done        \n    done\n\n    for fname in \"audio_platform_configuration.xml\"; do\n        if [ -r \"${MODDIR}/save/vendor/etc/${fname}\"  -a  -e \"${MODDIR}/system/vendor/etc\" ]; then\n            mv \"${MODDIR}/save/vendor/etc/${fname}\" \"${MODDIR}/system/vendor/etc/${fname}\"\n            chmod 644 \"${MODDIR}/system/vendor/etc/${fname}\"\n        fi\n    done\n\nfi\n"
  },
  {
    "path": "service-functions.sh",
    "content": "#!/system/bin/sh\n\nfunction reloadAudioServer()\n{\n    if [ -n \"`getprop init.svc.audioserver`\" ]; then\n        setprop ctl.restart audioserver\n        sleep 1.2\n        if [ \"`getprop init.svc.audioserver`\" != \"running\" ]; then\n            # workaround for Android 12 old devices hanging up the audioserver after \"setprop ctl.restart audioserver\" is executed\n            local pid=\"`getprop init.svc_debug_pid.audioserver`\"\n            if [ -n \"$pid\" ]; then\n                kill -HUP $pid 1>\"/dev/null\" 2>&1\n            fi\n        fi\n    fi\n}\n\n# Sleep some secs needed for Audioserver's preparation\nfunction waitAudioServer()\n{\n    # wait for system boot completion and audiosever boot up\n    sleep 11\n    local i\n    for i in `seq 1 10` ; do\n        if [ \"`getprop sys.boot_completed`\" = \"1\"  -a  -n \"`getprop init.svc.audioserver`\" ]; then\n            break\n        fi\n        sleep $i\n    done\n}\n\n# A rewritten version because some ROM's fail to execute \"dumpsys media.audio_policy\" on the service phase\n#  arg1 : Magisk's module folder path, typically \"/data/adb/modules/<module name>\"\nfunction remountFiles()\n{\n    local modPath flist x deletePat forceReload=0\n    \n    if [ $# -eq 1  -a  -e \"$1\" ]; then\n        modPath=\"$1\"\n    else\n        return\n    fi\n    \n    deletePat=$(echo \"${modPath}/system\" | sed -e 's/\\//\\\\\\//g')\n    \n    # Get absolute paths for Magisk's magic mount, then remount by itself\n    flist=\"`find \\\"${modPath}/system\\\" -type f | sed -e \\\"s/$deletePat//\\\"`\"\n\n    # Check if the audio policy XML file and others mounted by Magisk is still unmounted.\n    # Some Qcomm devices from Xiaomi, OnePlus, etc. overlays another on it in a boot process\n    # and phh GSI's on Qcomm devices unmount it for the phh settings of the GSI's.\n\n    for x in $flist; do\n        if [ -e \"${modPath}/skip_mount\"  -a  \"${x##*/}\" = \".replace\" ]; then\n            # Mount a directory instead of \".replace\" file if skipping Magisk's magic mount\n            mount -o bind \"${modPath}/system${x%/.replace}\" \"${x%/.replace}\"\n            forceReload=1\n        elif [ -r \"$x\"  -a  -r \"${modPath}/system${x}\" ]; then\n            cmp \"$x\" \"${modPath}/system${x}\" >\"/dev/null\" 2>&1\n            if [ \"$?\" -ne 0 ]; then\n                umount \"$x\" >\"/dev/null\" 2>&1\n                umount \"$x\" >\"/dev/null\" 2>&1\n                mount -o bind \"${modPath}/system${x}\" \"$x\"\n                forceReload=1\n            fi\n        fi\n    done\n    \n    if [ \"$forceReload\" -gt 0 ]; then\n        # Since this library file may be shared multiple modules, it is needed to disperse the timing of each module not to collide\n        sleep $(expr $RANDOM % 20)\n        reloadAudioServer\n    fi\n}\n"
  },
  {
    "path": "service-optimizer.sh",
    "content": "#!/system/bin/sh\n\n# MODDIR=${0%/*} will be inherited from the parent sh module\n\n# This script functions will be used in services mode\n\n. \"$MODDIR/jitter-reducer-functions.shlib\"\n\nfunction disableAdaptiveFeatures()\n{\n    # Reducing jitter by battery draining and charging manager, and 5G data manager\n    settings put global adaptive_battery_management_enabled 0\n    settings put secure adaptive_charging_enabled 0\n    settings put secure adaptive_connectivity_enabled 0\n    # Reducing wifi jitter by suspend wifi optimizations\n    settings put global wifi_suspend_optimizations_enabled 0\n}\n\nfunction setVolumeMediaSteps()\n{\n    # Volume medial steps to be 100 if a volume steps facility is used\n    settings put system volume_steps_music 100\n}\n\nfunction forceIgnoreAudioEffects()\n{\n    local force_restart_server=0\n\n    if [ \"`getprop persist.sys.phh.disable_audio_effects`\" = \"0\" ]; then\n        # Workaround for recent Pixel Firmwares (not to reboot when resetprop'ing)\n        resetprop --delete ro.audio.ignore_effects 1>\"/dev/null\" 2>&1\n        # End of workaround\n        resetprop ro.audio.ignore_effects true\n        force_restart_server=1\n    fi\n    \n    # Stop Tensor device's AOC daemons for reducing significant jitter\n    if [ \"`getprop init.svc.aocd`\" = \"running\" ]; then\n        setprop ctl.stop aocd\n        force_restart_server=1\n    fi\n    if [ \"`getprop init.svc.aocxd`\" = \"running\" ]; then\n        setprop ctl.stop aocxd\n        force_restart_server=1\n    fi\n\n    # Nullifying the volume listener for no compressing audio (maybe a peak limiter)\n    #   for Qcomm devices only?\n    if [ -r \"/vendor/lib/soundfx/libvolumelistener.so\" ]; then\n        mount -o bind \"/dev/null\" \"/vendor/lib/soundfx/libvolumelistener.so\"\n        force_restart_server=1\n    fi\n    if [ -r \"/vendor/lib64/soundfx/libvolumelistener.so\" ]; then\n        mount -o bind \"/dev/null\" \"/vendor/lib64/soundfx/libvolumelistener.so\"\n        force_restart_server=1\n    fi\n\n    #   for Motorola devices only?\n    if [ -r \"/vendor/lib/soundfx/libdlbvol.so\" ]; then\n        mount -o bind \"/dev/null\" \"/vendor/lib/soundfx/libdlbvol.so\"\n        force_restart_server=1\n    fi\n    if [ -r \"/vendor/lib64/soundfx/libdlbvol.so\" ]; then\n        mount -o bind \"/dev/null\" \"/vendor/lib64/soundfx/libdlbvol.so\"\n        force_restart_server=1\n    fi\n\n    if [ \"$force_restart_server\" = \"1\"  -o  \"`getprop ro.system.build.version.release`\" -ge \"12\" ]; then\n        reloadAudioServer       \n    fi\n}\n\n# This function has six arguments:\n# 1. Enable $1:thermal core control, $2:Camera service (interfering in jitters on audio outputs), $3:Selinux enforcing, $4:Doze (battery optimizations)\n#     and $5:Logd service or not, respectively (\"yes\" or \"no\")\n# 2. Disable $6:clearest tone (\"yes\" or \"no\"), perhaps for sensitive Bluetooth earphones.\n\nfunction optimizeOS()\n{  \n    if [ $# -neq 6 ]; then\n        exit 1\n    fi\n\n    if [ \"$1\" = \"no\" ]; then\n        reduceThermalJitter 1 0\n    fi\n    if [ \"$2\" = \"no\" ]; then\n        reduceCameraJitter 1 0\n    fi\n    if [ \"$3\" = \"no\" ]; then\n        reduceSelinuxJitter 1 0\n    fi\n    if [ \"$4\" = \"no\" ]; then\n        reduceDozeJitter 1 0\n    fi\n    if [ \"$5\" = \"no\" ]; then\n        reduceLogdJitter 1 0\n    fi\n    reduceGovernorJitter 1 0\n    if [ \"$6\" = \"no\" ]; then\n        reduceIoJitter 1 '*' 'boost' 0\n    else\n        reduceIoJitter 1 '*' 'medium' 0\n    fi\n    reduceVmJitter 1 0\n    forceIgnoreAudioEffects\n    disableAdaptiveFeatures\n    setVolumeMediaSteps\n}\n"
  },
  {
    "path": "service.sh",
    "content": "#!/system/bin/sh\n# Do NOT assume where your module will be located. ALWAYS use $MODDIR if you need to know where this script and module is placed.\n# This will make sure your module will still work if Magisk change its mount point in the future\n# no longer assume \"$MAGISKTMP=/sbin/.magisk\" if Android 11 or later\n#\n# This script will be executed in service mode\n#\n\nMODDIR=${0%/*}\n# MAGISKPATH=$(magisk --path)\n# MAGISKTMP=$MAGISKPATH/.magisk\n\n. \"$MODDIR/service-functions.sh\"\n. \"$MODDIR/service-optimizer.sh\"\n\n#\n\n# 1. Enable thermal control, Camera service (interfering in jitters on audio outputs), Selinux enforcing, Doze (battery optimizations)\n#     and Logd service or not, respectively (\"yes\" or \"no\").\n# 2. Disable clearest tone (\"yes\" or \"no\"), perhaps for sensitive Bluetooth earphones.\n\nEnableThermalControl=\"no\"\nEnableCameraService=\"no\"\nEnableSelinuxEnforcing=\"no\"\nEnableDoze=\"no\"\nEnableLogdService=\"no\"\n\nDisableClearestTone=\"no\"\n\n# sleep more than 30 secs (waitAudioServer) needed for \"settings\" commands \n#   to become effective and another kernel tunables setting process completion in an orphan process\n\n(((waitAudioServer; remountFile \"$MODDIR\"; optimizeOS $EnableThermalControl $EnableCameraService $EnableSelinuxEnforcing \\\n                        $EnableDoze $EnableLogdService $DisableClearestTone)  0<&- &>\"/dev/null\" &) &)\n"
  },
  {
    "path": "system.prop",
    "content": "ro.config.media_vol_steps=100\naudio.safemedia.bypass=true\naudio.safemedia.force=false\naudio.safemedia.csd.force=false\nro.audio.ignore_effects=true\nro.audio.spatializer_enabled=false\nro.vendor.audio.dolby.dax.support=false\nvendor.audio.dolby.control.support=false\nvendor.audio.usb.perio=2000\nvendor.audio.usb.out.period_us=2000\nvendor.audio.usb.out.period_count=2\nvendor.audio_hal.period_size=120\nvendor.audio_hal.period_multiplier=1\nvendor.audio.adm.buffering.ms=2\npersist.bluetooth.sbc_hd_higher_bitrate=1\naf.resampler.quality=7\nro.audio.resampler.psd.enable_at_samplerate=44100\nro.audio.resampler.psd.stopband=179\nro.audio.resampler.psd.halflength=408\nro.audio.resampler.psd.tbwcheat=99\n"
  },
  {
    "path": "system.prop-workaround",
    "content": "ro.config.media_vol_steps=100\naudio.safemedia.bypass=true\naudio.safemedia.force=false\naudio.safemedia.csd.force=false\nro.audio.ignore_effects=true\nro.audio.spatializer_enabled=false\nro.vendor.audio.dolby.dax.support=false\nvendor.audio.dolby.control.support=false\nvendor.audio.usb.perio=2000\nvendor.audio.usb.out.period_us=2000\nvendor.audio.usb.out.period_count=2\nvendor.audio_hal.period_size=120\nvendor.audio_hal.period_multiplier=1\nvendor.audio.adm.buffering.ms=2\npersist.bluetooth.sbc_hd_higher_bitrate=1\naf.resampler.quality=7\nro.audio.resampler.psd.enable_at_samplerate=44100\nro.audio.resampler.psd.stopband=159\nro.audio.resampler.psd.halflength=480\nro.audio.resampler.psd.cutoff_percent=92\n"
  },
  {
    "path": "templates/bypass_offload_safer_template.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<!-- Copyright (C) 2020 The Android Open Source Project\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n          http://www.apache.org/licenses/LICENSE-2.0\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<audioPolicyConfiguration version=\"7.0\" xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n    <globalConfiguration speaker_drc_enabled=\"%DRC_ENABLED%\" call_screen_mode_supported=\"false\"/>\n    <modules>\n        <!-- Primary Audio HAL -->\n        <module name=\"primary\" halVersion=\"2.0\">\n            <attachedDevices>\n                <item>Speaker</item>\n                <item>Speaker Safe</item>\n                <item>Earpiece</item>\n                <item>Built-In Mic</item>\n                <item>Built-In Back Mic</item>\n                <item>Telephony Tx</item>\n                <item>Voice Call And Telephony Rx</item>\n                <item>Echo Ref In</item>\n            </attachedDevices>\n            <defaultOutputDevice>Speaker</defaultOutputDevice>\n            <mixPorts>\n                <mixPort name=\"primary output\" role=\"source\" flags=\"AUDIO_OUTPUT_FLAG_PRIMARY AUDIO_OUTPUT_FLAG_FAST\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"deep buffer\" role=\"source\" flags=\"AUDIO_OUTPUT_FLAG_DEEP_BUFFER\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"haptic\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A\"/>\n                </mixPort>\n                <mixPort name=\"incall playback\" role=\"source\"\n                         flags=\"AUDIO_OUTPUT_FLAG_INCALL_MUSIC\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"voice call tx\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"voip_rx\" role=\"source\"\n                         flags=\"AUDIO_OUTPUT_FLAG_VOIP_RX\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                           samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"primary input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO AUDIO_CHANNEL_INDEX_MASK_3\"/>\n                </mixPort>\n                <mixPort name=\"hotword input\" role=\"sink\" flags=\"AUDIO_INPUT_FLAG_HW_HOTWORD\" maxActiveCount=\"0\" >\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"8000 11025 12000 16000 22050 24000 32000 44100 48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"incall capture\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"voice call rx\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"voip_tx\" role=\"sink\"\n                         flags=\"AUDIO_INPUT_FLAG_VOIP_TX\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"fast input\" role=\"sink\" flags=\"AUDIO_INPUT_FLAG_RAW AUDIO_INPUT_FLAG_FAST\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"hifi_input\" role=\"sink\"/>\n                <mixPort name=\"echo_ref_input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <!-- Output devices declaration, i.e. Sink DEVICE PORT -->\n                <devicePort tagName=\"Earpiece\" type=\"AUDIO_DEVICE_OUT_EARPIECE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Speaker\" type=\"AUDIO_DEVICE_OUT_SPEAKER\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Speaker Safe\" type=\"AUDIO_DEVICE_OUT_SPEAKER_SAFE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headset\" type=\"AUDIO_DEVICE_OUT_WIRED_HEADSET\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headphones\" type=\"AUDIO_DEVICE_OUT_WIRED_HEADPHONE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Headset\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Car Kit\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Telephony Tx\" type=\"AUDIO_DEVICE_OUT_TELEPHONY_TX\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Aux Digital\" type=\"AUDIO_DEVICE_OUT_AUX_DIGITAL\" role=\"sink\">\n                </devicePort>\n                <!-- Input devices declaration, i.e. Source DEVICE PORT -->\n                <devicePort tagName=\"Built-In Mic\" type=\"AUDIO_DEVICE_IN_BUILTIN_MIC\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Built-In Back Mic\" type=\"AUDIO_DEVICE_IN_BACK_MIC\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headset Mic\" type=\"AUDIO_DEVICE_IN_WIRED_HEADSET\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Headset Mic\" type=\"AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"USB Device In\" type=\"AUDIO_DEVICE_IN_USB_DEVICE\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"USB Headset In\" type=\"AUDIO_DEVICE_IN_USB_HEADSET\" role=\"source\">\n                </devicePort>\n                <!-- AUDIO_DEVICE_IN_VOICE_CALL and AUDIO_DEVICE_IN_TELEPHONY_RX are in the same value -->\n                <devicePort tagName=\"Voice Call And Telephony Rx\" type=\"AUDIO_DEVICE_IN_VOICE_CALL\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Echo Ref In\" type=\"AUDIO_DEVICE_IN_ECHO_REFERENCE\" role=\"source\">\n                </devicePort>\n            </devicePorts>\n            <!-- route declaration, i.e. list all available sources for a given sink -->\n            <routes>\n                <route type=\"mix\" sink=\"Speaker\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Speaker Safe\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Earpiece\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Wired Headset\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Wired Headphones\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Aux Digital\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO Headset\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO Car Kit\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Telephony Tx\" sources=\"incall playback,voice call tx\"/>\n                <route type=\"mix\" sink=\"primary input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"hotword input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"incall capture\" sources=\"Voice Call And Telephony Rx\"/>\n                <route type=\"mix\" sink=\"voice call rx\" sources=\"Voice Call And Telephony Rx\"/>\n                <route type=\"mix\" sink=\"voip_tx\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"fast input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In\"/>\n                <route type=\"mix\" sink=\"hifi_input\" sources=\"USB Device In,USB Headset In\"/>\n                <route type=\"mix\" sink=\"echo_ref_input\" sources=\"Echo Ref In\"/>\n            </routes>\n        </module>\n\n        <!-- Bluetooth Audio HAL -->\n        <module name=\"%BT_MODULE%\" halVersion=\"2.0\">\n            <mixPorts>\n                <mixPort name=\"a2dp output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"a2dp input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"le audio output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"le audio input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <devicePort tagName=\"BT A2DP Out\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP Headphones\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP Speaker\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP In\" type=\"AUDIO_DEVICE_IN_BLUETOOTH_A2DP\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Out\" type=\"AUDIO_DEVICE_OUT_BLE_HEADSET\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Speaker\" type=\"AUDIO_DEVICE_OUT_BLE_SPEAKER\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Broadcast\" type=\"AUDIO_DEVICE_OUT_BLE_BROADCAST\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BLE Headset In\" type=\"AUDIO_DEVICE_IN_BLE_HEADSET\" role=\"source\"/>\n            </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"BT A2DP Out\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"BT A2DP Headphones\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"BT A2DP Speaker\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"a2dp input\"\n                       sources=\"BT A2DP In\"/>\n                <route type=\"mix\" sink=\"BT BLE Out\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"BT BLE Speaker\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"BT BLE Broadcast\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"le audio input\"\n                       sources=\"BLE Headset In\"/>\n            </routes>\n        </module>\n\n        <!-- Usb Audio HAL -->\n        <module name=\"%USB_MODULE%\" halVersion=\"2.0\">\n            <mixPorts>\n                <mixPort name=\"usb_accessory output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"usb_device output\" role=\"source\">\n                    <profile name=\"\" format=\"%AUDIO_FORMAT%\"\n                             samplingRates=\"%SAMPLING_RATE%\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <devicePort tagName=\"USB Host Out\" type=\"AUDIO_DEVICE_OUT_USB_ACCESSORY\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"USB Device Out\" type=\"AUDIO_DEVICE_OUT_USB_DEVICE\" role=\"sink\">\n                    <profile name=\"\" format=\"%AUDIO_FORMAT%\"\n                             samplingRates=\"%SAMPLING_RATE%\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"USB Headset Out\" type=\"AUDIO_DEVICE_OUT_USB_HEADSET\" role=\"sink\">\n                    <profile name=\"\" format=\"%AUDIO_FORMAT%\"\n                             samplingRates=\"%SAMPLING_RATE%\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n           </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"USB Host Out\"\n                       sources=\"usb_accessory output\"/>\n                <route type=\"mix\" sink=\"USB Device Out\"\n                       sources=\"usb_device output\"/>\n                <route type=\"mix\" sink=\"USB Headset Out\"\n                       sources=\"usb_device output\"/>\n             </routes>\n        </module>\n\n        <!-- Remote Submix Audio HAL -->\n        <module name=\"r_submix\" halVersion=\"2.0\">\n            <attachedDevices>\n                <item>Remote Submix In</item>\n            </attachedDevices>\n            <mixPorts>\n                <mixPort name=\"r_submix output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"r_submix input\" role=\"sink\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n           </mixPorts>\n           <devicePorts>\n               <devicePort tagName=\"Remote Submix Out\" type=\"AUDIO_DEVICE_OUT_REMOTE_SUBMIX\"  role=\"sink\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n               </devicePort>\n               <devicePort tagName=\"Remote Submix In\" type=\"AUDIO_DEVICE_IN_REMOTE_SUBMIX\"  role=\"source\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </devicePort>\n            </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"Remote Submix Out\"\n                       sources=\"r_submix output\"/>\n                <route type=\"mix\" sink=\"r_submix input\"\n                       sources=\"Remote Submix In\"/>\n            </routes>\n        </module>\n\n    </modules>\n    <!-- End of Modules section -->\n\n    <!-- Volume section -->\n\n    <xi:include href=\"%VOLUME_FILE%\"/>\n    <xi:include href=\"%DEFAULT_VOLUME_FILE%\"/>\n\n    <!-- End of Volume section -->\n</audioPolicyConfiguration>\n"
  },
  {
    "path": "templates/bypass_offload_template.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<!-- Copyright (C) 2020 The Android Open Source Project\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n          http://www.apache.org/licenses/LICENSE-2.0\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<audioPolicyConfiguration version=\"7.0\" xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n    <globalConfiguration speaker_drc_enabled=\"%DRC_ENABLED%\" call_screen_mode_supported=\"false\" />\n    <modules>\n        <!-- Primary Audio HAL -->\n        <module name=\"primary\" halVersion=\"2.0\">\n            <attachedDevices>\n                <item>Speaker</item>\n                <item>Speaker Safe</item>\n                <item>Earpiece</item>\n                <item>Built-In Mic</item>\n                <item>Built-In Back Mic</item>\n                <item>Telephony Tx</item>\n                <item>Voice Call And Telephony Rx</item>\n                <item>Echo Ref In</item>\n            </attachedDevices>\n            <defaultOutputDevice>Speaker</defaultOutputDevice>\n            <mixPorts>\n                <mixPort name=\"primary output\" role=\"source\" flags=\"AUDIO_OUTPUT_FLAG_PRIMARY AUDIO_OUTPUT_FLAG_FAST\"\n                         recommendedMuteDurationMs=\"40\">\n                    <profile name=\"\" format=\"%AUDIO_FORMAT%\"\n                             samplingRates=\"%SAMPLING_RATE%\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"deep buffer\" role=\"source\" flags=\"AUDIO_OUTPUT_FLAG_DEEP_BUFFER\">\n                    <profile name=\"\" format=\"%AUDIO_FORMAT%\"\n                             samplingRates=\"%SAMPLING_RATE%\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"haptic\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A\" />\n                </mixPort>\n                <mixPort name=\"incall playback\" role=\"source\"\n                         flags=\"AUDIO_OUTPUT_FLAG_INCALL_MUSIC\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\" />\n                </mixPort>\n                <mixPort name=\"voice call tx\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\" />\n                </mixPort>\n                <mixPort name=\"voip_rx\" role=\"source\"\n                         flags=\"AUDIO_OUTPUT_FLAG_VOIP_RX\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                           samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"primary input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO AUDIO_CHANNEL_INDEX_MASK_3\"/>\n                </mixPort>\n                <mixPort name=\"hotword input\" role=\"sink\" flags=\"AUDIO_INPUT_FLAG_HW_HOTWORD\" maxActiveCount=\"0\" >\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"8000 11025 12000 16000 22050 24000 32000 44100 48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"incall capture\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"voice call rx\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"voip_tx\" role=\"sink\"\n                         flags=\"AUDIO_INPUT_FLAG_VOIP_TX\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"fast input\" role=\"sink\" flags=\"AUDIO_INPUT_FLAG_RAW AUDIO_INPUT_FLAG_FAST\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"hifi_input\" role=\"sink\" />\n                <mixPort name=\"echo_ref_input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <!-- Output devices declaration, i.e. Sink DEVICE PORT -->\n                <devicePort tagName=\"Earpiece\" type=\"AUDIO_DEVICE_OUT_EARPIECE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Speaker\" type=\"AUDIO_DEVICE_OUT_SPEAKER\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Speaker Safe\" type=\"AUDIO_DEVICE_OUT_SPEAKER_SAFE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headset\" type=\"AUDIO_DEVICE_OUT_WIRED_HEADSET\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headphones\" type=\"AUDIO_DEVICE_OUT_WIRED_HEADPHONE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Headset\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Car Kit\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Telephony Tx\" type=\"AUDIO_DEVICE_OUT_TELEPHONY_TX\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Aux Digital\" type=\"AUDIO_DEVICE_OUT_AUX_DIGITAL\" role=\"sink\">\n                </devicePort>\n                <!-- Input devices declaration, i.e. Source DEVICE PORT -->\n                <devicePort tagName=\"Built-In Mic\" type=\"AUDIO_DEVICE_IN_BUILTIN_MIC\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Built-In Back Mic\" type=\"AUDIO_DEVICE_IN_BACK_MIC\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headset Mic\" type=\"AUDIO_DEVICE_IN_WIRED_HEADSET\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Headset Mic\" type=\"AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"USB Device In\" type=\"AUDIO_DEVICE_IN_USB_DEVICE\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"USB Headset In\" type=\"AUDIO_DEVICE_IN_USB_HEADSET\" role=\"source\">\n                </devicePort>\n                <!-- AUDIO_DEVICE_IN_VOICE_CALL and AUDIO_DEVICE_IN_TELEPHONY_RX are in the same value -->\n                <devicePort tagName=\"Voice Call And Telephony Rx\" type=\"AUDIO_DEVICE_IN_VOICE_CALL\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Echo Ref In\" type=\"AUDIO_DEVICE_IN_ECHO_REFERENCE\" role=\"source\">\n                </devicePort>\n            </devicePorts>\n            <!-- route declaration, i.e. list all available sources for a given sink -->\n            <routes>\n                <route type=\"mix\" sink=\"Speaker\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Speaker Safe\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Earpiece\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Wired Headset\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Wired Headphones\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Aux Digital\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO Headset\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO Car Kit\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Telephony Tx\" sources=\"incall playback,voice call tx\" />\n                <route type=\"mix\" sink=\"primary input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"hotword input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"incall capture\" sources=\"Voice Call And Telephony Rx\" />\n                <route type=\"mix\" sink=\"voice call rx\" sources=\"Voice Call And Telephony Rx\" />\n                <route type=\"mix\" sink=\"voip_tx\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"fast input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In\"/>\n                <route type=\"mix\" sink=\"hifi_input\" sources=\"USB Device In,USB Headset In\" />\n                <route type=\"mix\" sink=\"echo_ref_input\" sources=\"Echo Ref In\"/>\n            </routes>\n        </module>\n\n        <!-- Bluetooth Audio HAL -->\n        <module name=\"%BT_MODULE%\" halVersion=\"2.0\">\n            <mixPorts>\n                <mixPort name=\"a2dp output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"a2dp input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"le audio output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"le audio input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <devicePort tagName=\"BT A2DP Out\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP Headphones\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP Speaker\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP In\" type=\"AUDIO_DEVICE_IN_BLUETOOTH_A2DP\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Out\" type=\"AUDIO_DEVICE_OUT_BLE_HEADSET\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Speaker\" type=\"AUDIO_DEVICE_OUT_BLE_SPEAKER\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Broadcast\" type=\"AUDIO_DEVICE_OUT_BLE_BROADCAST\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BLE Headset In\" type=\"AUDIO_DEVICE_IN_BLE_HEADSET\" role=\"source\"/>\n            </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"BT A2DP Out\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"BT A2DP Headphones\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"BT A2DP Speaker\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"a2dp input\"\n                       sources=\"BT A2DP In\"/>\n                <route type=\"mix\" sink=\"BT BLE Out\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"BT BLE Speaker\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"BT BLE Broadcast\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"le audio input\"\n                       sources=\"BLE Headset In\"/>\n            </routes>\n        </module>\n\n        <!-- Usb Audio HAL -->\n        <module name=\"%USB_MODULE%\" halVersion=\"2.0\">\n            <mixPorts>\n                <mixPort name=\"usb_accessory output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"usb_device output\" role=\"source\">\n                    <profile name=\"\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <devicePort tagName=\"USB Host Out\" type=\"AUDIO_DEVICE_OUT_USB_ACCESSORY\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"USB Device Out\" type=\"AUDIO_DEVICE_OUT_USB_DEVICE\" role=\"sink\">\n                    <profile name=\"\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"USB Headset Out\" type=\"AUDIO_DEVICE_OUT_USB_HEADSET\" role=\"sink\">\n                    <profile name=\"\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n           </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"USB Host Out\"\n                       sources=\"usb_accessory output\"/>\n                <route type=\"mix\" sink=\"USB Device Out\"\n                       sources=\"usb_device output\"/>\n                <route type=\"mix\" sink=\"USB Headset Out\"\n                       sources=\"usb_device output\"/>\n             </routes>\n        </module>\n\n        <!-- Remote Submix Audio HAL -->\n        <module name=\"r_submix\" halVersion=\"2.0\">\n            <attachedDevices>\n                <item>Remote Submix In</item>\n            </attachedDevices>\n            <mixPorts>\n                <mixPort name=\"r_submix output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"r_submix input\" role=\"sink\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n           </mixPorts>\n           <devicePorts>\n               <devicePort tagName=\"Remote Submix Out\" type=\"AUDIO_DEVICE_OUT_REMOTE_SUBMIX\"  role=\"sink\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n               </devicePort>\n               <devicePort tagName=\"Remote Submix In\" type=\"AUDIO_DEVICE_IN_REMOTE_SUBMIX\"  role=\"source\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </devicePort>\n            </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"Remote Submix Out\"\n                       sources=\"r_submix output\"/>\n                <route type=\"mix\" sink=\"r_submix input\"\n                       sources=\"Remote Submix In\"/>\n            </routes>\n        </module>\n\n    </modules>\n    <!-- End of Modules section -->\n\n    <!-- Volume section -->\n\n    <xi:include href=\"%VOLUME_FILE%\"/>\n    <xi:include href=\"%DEFAULT_VOLUME_FILE%\"/>\n\n    <!-- End of Volume section -->\n</audioPolicyConfiguration>\n"
  },
  {
    "path": "templates/offload_hifi_playback_template.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<!-- Copyright (C) 2020 The Android Open Source Project\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n          http://www.apache.org/licenses/LICENSE-2.0\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<audioPolicyConfiguration version=\"7.0\" xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n    <globalConfiguration speaker_drc_enabled=\"%DRC_ENABLED%\" call_screen_mode_supported=\"false\" />\n    <modules>\n        <!-- Primary Audio HAL -->\n        <module name=\"primary\" halVersion=\"2.0\">\n            <attachedDevices>\n                <item>Speaker</item>\n                <item>Speaker Safe</item>\n                <item>Earpiece</item>\n                <item>Built-In Mic</item>\n                <item>Built-In Back Mic</item>\n                <item>Telephony Tx</item>\n                <item>Voice Call And Telephony Rx</item>\n                <item>Echo Ref In</item>\n            </attachedDevices>\n            <defaultOutputDevice>Speaker</defaultOutputDevice>\n            <mixPorts>\n                <mixPort name=\"primary output\" role=\"source\" flags=\"AUDIO_OUTPUT_FLAG_PRIMARY AUDIO_OUTPUT_FLAG_FAST\">\n                    <profile name=\"\" format=\"%AUDIO_FORMAT%\"\n                             samplingRates=\"%SAMPLING_RATE%\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"deep buffer\" role=\"source\" flags=\"AUDIO_OUTPUT_FLAG_DEEP_BUFFER\">\n                    <profile name=\"\" format=\"%AUDIO_FORMAT%\"\n                             samplingRates=\"%SAMPLING_RATE%\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"haptic\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A\" />\n                </mixPort>\n                <mixPort name=\"usb_playback\" role=\"source\">\n                    <profile name=\"\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"incall playback\" role=\"source\"\n                         flags=\"AUDIO_OUTPUT_FLAG_INCALL_MUSIC\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\" />\n                </mixPort>\n                <mixPort name=\"voice call tx\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\" />\n                </mixPort>\n                <mixPort name=\"voip_rx\" role=\"source\"\n                         flags=\"AUDIO_OUTPUT_FLAG_VOIP_RX\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                           samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"primary input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO AUDIO_CHANNEL_INDEX_MASK_3\"/>\n                </mixPort>\n                <mixPort name=\"hotword input\" role=\"sink\" flags=\"AUDIO_INPUT_FLAG_HW_HOTWORD\" maxActiveCount=\"0\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"8000 11025 12000 16000 22050 24000 32000 44100 48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"incall capture\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"voice call rx\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"voip_tx\" role=\"sink\"\n                         flags=\"AUDIO_INPUT_FLAG_VOIP_TX\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_IN_MONO\"/>\n                </mixPort>\n                <mixPort name=\"fast input\" role=\"sink\" flags=\"AUDIO_INPUT_FLAG_RAW AUDIO_INPUT_FLAG_FAST\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"hifi_input\" role=\"sink\" />\n                <mixPort name=\"echo_ref_input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <!-- Output devices declaration, i.e. Sink DEVICE PORT -->\n                <devicePort tagName=\"Earpiece\" type=\"AUDIO_DEVICE_OUT_EARPIECE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Speaker\" type=\"AUDIO_DEVICE_OUT_SPEAKER\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Speaker Safe\" type=\"AUDIO_DEVICE_OUT_SPEAKER_SAFE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headset\" type=\"AUDIO_DEVICE_OUT_WIRED_HEADSET\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headphones\" type=\"AUDIO_DEVICE_OUT_WIRED_HEADPHONE\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Headset\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Car Kit\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Aux Digital\" type=\"AUDIO_DEVICE_OUT_AUX_DIGITAL\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Telephony Tx\" type=\"AUDIO_DEVICE_OUT_TELEPHONY_TX\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"Proxy\" type=\"AUDIO_DEVICE_OUT_PROXY\" role=\"sink\">\n                </devicePort>\n                <devicePort tagName=\"USB Device Out\" type=\"AUDIO_DEVICE_OUT_USB_DEVICE\" role=\"sink\">\n                    <profile name=\"\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"USB Headset Out\" type=\"AUDIO_DEVICE_OUT_USB_HEADSET\" role=\"sink\">\n                    <profile name=\"\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <!-- Input devices declaration, i.e. Source DEVICE PORT -->\n                <devicePort tagName=\"Built-In Mic\" type=\"AUDIO_DEVICE_IN_BUILTIN_MIC\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Built-In Back Mic\" type=\"AUDIO_DEVICE_IN_BACK_MIC\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Wired Headset Mic\" type=\"AUDIO_DEVICE_IN_WIRED_HEADSET\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"BT SCO Headset Mic\" type=\"AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"USB Device In\" type=\"AUDIO_DEVICE_IN_USB_DEVICE\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"USB Headset In\" type=\"AUDIO_DEVICE_IN_USB_HEADSET\" role=\"source\">\n                </devicePort>\n                <!-- AUDIO_DEVICE_IN_VOICE_CALL and AUDIO_DEVICE_IN_TELEPHONY_RX are in the same value -->\n                <devicePort tagName=\"Voice Call And Telephony Rx\" type=\"AUDIO_DEVICE_IN_VOICE_CALL\" role=\"source\">\n                </devicePort>\n                <devicePort tagName=\"Echo Ref In\" type=\"AUDIO_DEVICE_IN_ECHO_REFERENCE\" role=\"source\">\n                </devicePort>\n            </devicePorts>\n            <!-- route declaration, i.e. list all available sources for a given sink -->\n            <routes>\n                <route type=\"mix\" sink=\"Speaker\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Speaker Safe\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Earpiece\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Wired Headset\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Wired Headphones\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Aux Digital\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"Proxy\"\n                       sources=\"primary output,deep buffer\"/>\n                <route type=\"mix\" sink=\"BT SCO\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO Headset\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"BT SCO Car Kit\"\n                       sources=\"primary output,deep buffer,haptic,voip_rx\"/>\n                <route type=\"mix\" sink=\"USB Device Out\"\n                       sources=\"usb_playback\"/>\n                <route type=\"mix\" sink=\"USB Headset Out\"\n                       sources=\"usb_playback\"/>\n                <route type=\"mix\" sink=\"Telephony Tx\" sources=\"incall playback,voice call tx\"/>\n                <route type=\"mix\" sink=\"primary input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"hotword input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"incall capture\" sources=\"Voice Call And Telephony Rx\"/>\n                <route type=\"mix\" sink=\"voice call rx\" sources=\"Voice Call And Telephony Rx\"/>\n                <route type=\"mix\" sink=\"voip_tx\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In,BT SCO Headset Mic\"/>\n                <route type=\"mix\" sink=\"fast input\"\n                       sources=\"Built-In Mic,Built-In Back Mic,Wired Headset Mic,USB Device In,USB Headset In\"/>\n                <route type=\"mix\" sink=\"hifi_input\" sources=\"USB Device In,USB Headset In\"/>\n                <route type=\"mix\" sink=\"echo_ref_input\" sources=\"Echo Ref In\"/>\n            </routes>\n        </module>\n\n        <!-- Bluetooth Audio HAL -->\n        <module name=\"%BT_MODULE%\" halVersion=\"2.0\">\n            <mixPorts>\n                <mixPort name=\"a2dp output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"a2dp input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"le audio output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"le audio input\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <devicePort tagName=\"BT A2DP Out\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP Headphones\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP Speaker\" type=\"AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT A2DP In\" type=\"AUDIO_DEVICE_IN_BLUETOOTH_A2DP\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"48000\"\n                             channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Out\" type=\"AUDIO_DEVICE_OUT_BLE_HEADSET\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Speaker\" type=\"AUDIO_DEVICE_OUT_BLE_SPEAKER\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BT BLE Broadcast\" type=\"AUDIO_DEVICE_OUT_BLE_BROADCAST\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_32_BIT\"\n                             samplingRates=\"48000\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n                <devicePort tagName=\"BLE Headset In\" type=\"AUDIO_DEVICE_IN_BLE_HEADSET\" role=\"source\"/>\n            </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"BT A2DP Out\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"BT A2DP Headphones\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"BT A2DP Speaker\"\n                       sources=\"a2dp output\"/>\n                <route type=\"mix\" sink=\"a2dp input\"\n                       sources=\"BT A2DP In\"/>\n                <route type=\"mix\" sink=\"BT BLE Out\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"BT BLE Speaker\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"BT BLE Broadcast\"\n                       sources=\"le audio output\"/>\n                <route type=\"mix\" sink=\"le audio input\"\n                       sources=\"BLE Headset In\"/>\n            </routes>\n        </module>\n\n        <!-- Usb Audio HAL -->\n        <module name=\"%USB_MODULE%\" halVersion=\"2.0\">\n            <mixPorts>\n                <mixPort name=\"usb_accessory output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n            </mixPorts>\n            <devicePorts>\n                <devicePort tagName=\"USB Host Out\" type=\"AUDIO_DEVICE_OUT_USB_ACCESSORY\" role=\"sink\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </devicePort>\n            </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"USB Host Out\"\n                       sources=\"usb_accessory output\"/>\n            </routes>\n        </module>\n\n        <!-- Remote Submix Audio HAL -->\n        <module name=\"r_submix\" halVersion=\"2.0\">\n            <attachedDevices>\n                <item>Remote Submix In</item>\n            </attachedDevices>\n            <mixPorts>\n                <mixPort name=\"r_submix output\" role=\"source\">\n                    <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                             samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n                </mixPort>\n                <mixPort name=\"r_submix input\" role=\"sink\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </mixPort>\n           </mixPorts>\n           <devicePorts>\n               <devicePort tagName=\"Remote Submix Out\" type=\"AUDIO_DEVICE_OUT_REMOTE_SUBMIX\"  role=\"sink\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_OUT_STEREO\"/>\n               </devicePort>\n               <devicePort tagName=\"Remote Submix In\" type=\"AUDIO_DEVICE_IN_REMOTE_SUBMIX\"  role=\"source\">\n                   <profile name=\"\" format=\"AUDIO_FORMAT_PCM_16_BIT\"\n                            samplingRates=\"44100\" channelMasks=\"AUDIO_CHANNEL_IN_STEREO\"/>\n                </devicePort>\n            </devicePorts>\n            <routes>\n                <route type=\"mix\" sink=\"Remote Submix Out\"\n                       sources=\"r_submix output\"/>\n                <route type=\"mix\" sink=\"r_submix input\"\n                       sources=\"Remote Submix In\"/>\n            </routes>\n        </module>\n\n    </modules>\n    <!-- End of Modules section -->\n\n    <!-- Volume section -->\n\n    <xi:include href=\"%VOLUME_FILE%\"/>\n    <xi:include href=\"%DEFAULT_VOLUME_FILE%\"/>\n\n    <!-- End of Volume section -->\n</audioPolicyConfiguration>\n"
  },
  {
    "path": "uninstall.sh",
    "content": "#!/system/bin/sh\n# Do NOT assume where your module will be located. ALWAYS use $MODDIR if you need to know where this script and module is placed.\n# This will make sure your module will still work if Magisk change its mount point in the future\n# no longer assume \"$MAGISKTMP=/sbin/.magisk\" if Android 11 or later\n#\n\nMODDIR=${0%/*}\n# MAGISKPATH=$(magisk --path)\n# MAGISKTMP=$MAGISKPATH/.magisk\n\nfunction enableAdaptiveFeatures()\n{\n    # Enable adaptive fearure for battery savers\n    settings delete global adaptive_battery_management_enabled\n    settings delete secure adaptive_charging_enabled\n    settings delete secure adaptive_connectivity_enabled\n    settings delete global wifi_suspend_optimizations_enabled\n}\n\nfunction unsetVolumeMediaSteps()\n{\n    # Delete volume media steps key\n    settings delete system volume_steps_music\n}\n\n#\n\n# sleep 20 secs needed for settings commans to be effective in an orphan process\n\n(((sleep 20; enableAdaptiveFeatures; unsetVolumeMediaSteps) 0<&- &>\"/dev/null\" &) &)\n"
  }
]