Compare commits
91 Commits
Author | SHA1 | Date | |
---|---|---|---|
2d31d46cd2 | |||
3a1a20e688 | |||
24346c056f | |||
e05c8fce30 | |||
e1b15c4c0a | |||
5b99288ea8 | |||
da958920b3 | |||
035e07db89 | |||
90de1612f3 | |||
9d2a87449d | |||
7a8bc6c8f8 | |||
b1e1e15412 | |||
569d4e278a | |||
2729724e93 | |||
64f87bd69f | |||
8d80d0b11f | |||
c045529914 | |||
6799e1e52d | |||
b11bd6dc46 | |||
99a203bde6 | |||
99b736ef36 | |||
415ab22bfc | |||
5bfa7c74d3 | |||
2ba2ff0b35 | |||
3ac6647a25 | |||
18b6b907bf | |||
73762291f1 | |||
49563d8bc5 | |||
0678357048 | |||
b49b4b9b9e | |||
af927d3f19 | |||
73be5df304 | |||
e01102a928 | |||
a21d27b65c | |||
45dc67c609 | |||
c3c2c07b00 | |||
1b573ec296 | |||
95601466ef | |||
07c52eb10a | |||
81aa8a7ef9 | |||
48eb942167 | |||
fe11d0e67b | |||
5fffb0b154 | |||
316db6f887 | |||
17b3d8ac9a | |||
6d58f0330b | |||
1c42bc4def | |||
a3772e3673 | |||
af20fad070 | |||
e510e5d043 | |||
2ebc0bc2dc | |||
3e23c67ad2 | |||
6ff9a08366 | |||
8a90303228 | |||
5b411227d9 | |||
88db36a848 | |||
9b3585c309 | |||
8c38183869 | |||
a1bc86cb81 | |||
3fb12ae743 | |||
f23034639e | |||
ccff6c04fd | |||
48fbadb692 | |||
0594352859 | |||
9aceec38b6 | |||
b925296870 | |||
28b03d2205 | |||
aeb6654550 | |||
82ff6ac311 | |||
74ba88f201 | |||
3144a160d4 | |||
34bfb4660e | |||
8d10a17914 | |||
1edd92ca79 | |||
4b583df6ae | |||
f6d51a7633 | |||
a1791f327b | |||
3d78411738 | |||
72597510f2 | |||
5b371ba3da | |||
751b0c4ce5 | |||
73677d1c33 | |||
ed658c83e6 | |||
|
0b4c58293a | ||
|
5a51ef571a | ||
|
4bd738b206 | ||
4a0473892b | |||
14354ec06f | |||
7eca11ed18 | |||
4c13768500 | |||
e30afc4011 |
1
.idea/gradle.xml
generated
@@ -14,7 +14,6 @@
|
|||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
5
.idea/misc.xml
generated
@@ -4,11 +4,14 @@
|
|||||||
<option name="filePathToZoomLevelMap">
|
<option name="filePathToZoomLevelMap">
|
||||||
<map>
|
<map>
|
||||||
<entry key="app/src/main/res/drawable-v24/dark_round.xml" value="0.4482051282051282" />
|
<entry key="app/src/main/res/drawable-v24/dark_round.xml" value="0.4482051282051282" />
|
||||||
|
<entry key="app/src/main/res/drawable/bg_orange_round.xml" value="0.229" />
|
||||||
|
<entry key="app/src/main/res/drawable/bg_permotion_round.xml" value="0.2495" />
|
||||||
<entry key="app/src/main/res/drawable/button_round.xml" value="0.44871794871794873" />
|
<entry key="app/src/main/res/drawable/button_round.xml" value="0.44871794871794873" />
|
||||||
<entry key="app/src/main/res/drawable/dark_round.xml" value="0.4482051282051282" />
|
<entry key="app/src/main/res/drawable/dark_round.xml" value="0.4482051282051282" />
|
||||||
<entry key="app/src/main/res/drawable/permotion_round.xml" value="0.4482051282051282" />
|
<entry key="app/src/main/res/drawable/permotion_round.xml" value="0.4482051282051282" />
|
||||||
<entry key="app/src/main/res/drawable/red_round.xml" value="0.4482051282051282" />
|
<entry key="app/src/main/res/drawable/red_round.xml" value="0.4482051282051282" />
|
||||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.3586910327241819" />
|
<entry key="app/src/main/res/layout/activity_main.xml" value="0.3413246647704185" />
|
||||||
|
<entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.2495" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
632
LICENSE
@@ -1,107 +1,100 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
# GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Version 3, 19 November 2007
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||||
|
<https://fsf.org/>
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
Everyone is permitted to copy and distribute verbatim copies of this
|
||||||
software and other kinds of works.
|
license document, but changing it is not allowed.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
### Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
share and change all versions of a program--to make sure it remains free
|
share and change all versions of a program--to make sure it remains
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
free software for all its users.
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
have the freedom to distribute copies of free software (and charge for
|
have the freedom to distribute copies of free software (and charge for
|
||||||
them if you wish), that you receive source code or can get it if you
|
them if you wish), that you receive source code or can get it if you
|
||||||
want it, that you can change the software or use pieces of it in new
|
want it, that you can change the software or use pieces of it in new
|
||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
Developers that use our General Public Licenses protect your rights
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
you this License which gives you legal permission to copy, distribute
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
and/or modify the software.
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
A secondary benefit of defending all users' freedom is that
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
improvements made in alternate versions of the program, if they
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
receive widespread use, become available for other developers to
|
||||||
or can get the source code. And you must show them these terms so they
|
incorporate. Many developers of free software are heartened and
|
||||||
know their rights.
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
The GNU Affero General Public License is designed specifically to
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
ensure that, in such cases, the modified source code becomes available
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
An older license, called the Affero General Public License and
|
||||||
that there is no warranty for this free software. For both users' and
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
changed, so that their problems will not be attributed erroneously to
|
released a new version of the Affero GPL which permits relicensing
|
||||||
authors of previous versions.
|
under this license.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
The precise terms and conditions for copying, distribution and
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
### TERMS AND CONDITIONS
|
||||||
|
|
||||||
0. Definitions.
|
#### 0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
"This License" refers to version 3 of the GNU Affero General Public
|
||||||
|
License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
"Copyright" also means copyright-like laws that apply to other kinds
|
||||||
works, such as semiconductor masks.
|
of works, such as semiconductor masks.
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
"recipients" may be individuals or organizations.
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
in a fashion requiring copyright permission, other than the making of
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
an exact copy. The resulting work is called a "modified version" of
|
||||||
earlier work or a work "based on" the earlier work.
|
the earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
A "covered work" means either the unmodified Program or a work based
|
||||||
on the Program.
|
on the Program.
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
To "propagate" a work means to do anything with it that, without
|
||||||
permission, would make you directly or secondarily liable for
|
permission, would make you directly or secondarily liable for
|
||||||
infringement under applicable copyright law, except executing it on a
|
infringement under applicable copyright law, except executing it on a
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
distribution (with or without modification), making available to the
|
distribution (with or without modification), making available to the
|
||||||
public, and in some countries other activities as well.
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
To "convey" a work means any kind of propagation that enables other
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
parties to make or receive copies. Mere interaction with a user
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
through a computer network, with no transfer of a copy, is not
|
||||||
|
conveying.
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
An interactive user interface displays "Appropriate Legal Notices" to
|
||||||
to the extent that it includes a convenient and prominently visible
|
the extent that it includes a convenient and prominently visible
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
tells the user that there is no warranty for the work (except to the
|
tells the user that there is no warranty for the work (except to the
|
||||||
extent that warranties are provided), that licensees may convey the
|
extent that warranties are provided), that licensees may convey the
|
||||||
@@ -109,18 +102,18 @@ work under this License, and how to view a copy of this License. If
|
|||||||
the interface presents a list of user commands or options, such as a
|
the interface presents a list of user commands or options, such as a
|
||||||
menu, a prominent item in the list meets this criterion.
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
1. Source Code.
|
#### 1. Source Code.
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
The "source code" for a work means the preferred form of the work for
|
||||||
for making modifications to it. "Object code" means any non-source
|
making modifications to it. "Object code" means any non-source form of
|
||||||
form of a work.
|
a work.
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
A "Standard Interface" means an interface that either is an official
|
||||||
standard defined by a recognized standards body, or, in the case of
|
standard defined by a recognized standards body, or, in the case of
|
||||||
interfaces specified for a particular programming language, one that
|
interfaces specified for a particular programming language, one that
|
||||||
is widely used among developers working in that language.
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
The "System Libraries" of an executable work include anything, other
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
packaging a Major Component, but which is not part of that Major
|
packaging a Major Component, but which is not part of that Major
|
||||||
Component, and (b) serves only to enable use of the work with that
|
Component, and (b) serves only to enable use of the work with that
|
||||||
@@ -131,7 +124,7 @@ implementation is available to the public in source code form. A
|
|||||||
(if any) on which the executable work runs, or a compiler used to
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
produce the work, or an object code interpreter used to run it.
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
The "Corresponding Source" for a work in object code form means all
|
||||||
the source code needed to generate, install, and (for an executable
|
the source code needed to generate, install, and (for an executable
|
||||||
work) run the object code and to modify the work, including scripts to
|
work) run the object code and to modify the work, including scripts to
|
||||||
control those activities. However, it does not include the work's
|
control those activities. However, it does not include the work's
|
||||||
@@ -144,16 +137,15 @@ linked subprograms that the work is specifically designed to require,
|
|||||||
such as by intimate data communication or control flow between those
|
such as by intimate data communication or control flow between those
|
||||||
subprograms and other parts of the work.
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
The Corresponding Source need not include anything that users can
|
||||||
can regenerate automatically from other parts of the Corresponding
|
regenerate automatically from other parts of the Corresponding Source.
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
The Corresponding Source for a work in source code form is that same
|
||||||
same work.
|
work.
|
||||||
|
|
||||||
2. Basic Permissions.
|
#### 2. Basic Permissions.
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
All rights granted under this License are granted for the term of
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
permission to run the unmodified Program. The output from running a
|
permission to run the unmodified Program. The output from running a
|
||||||
@@ -161,40 +153,40 @@ covered work is covered by this License only if the output, given its
|
|||||||
content, constitutes a covered work. This License acknowledges your
|
content, constitutes a covered work. This License acknowledges your
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
You may make, run and propagate covered works that you do not convey,
|
||||||
convey, without conditions so long as your license otherwise remains
|
without conditions so long as your license otherwise remains in force.
|
||||||
in force. You may convey covered works to others for the sole purpose
|
You may convey covered works to others for the sole purpose of having
|
||||||
of having them make modifications exclusively for you, or provide you
|
them make modifications exclusively for you, or provide you with
|
||||||
with facilities for running those works, provided that you comply with
|
facilities for running those works, provided that you comply with the
|
||||||
the terms of this License in conveying all material for which you do
|
terms of this License in conveying all material for which you do not
|
||||||
not control copyright. Those thus making or running the covered works
|
control copyright. Those thus making or running the covered works for
|
||||||
for you must do so exclusively on your behalf, under your direction
|
you must do so exclusively on your behalf, under your direction and
|
||||||
and control, on terms that prohibit them from making any copies of
|
control, on terms that prohibit them from making any copies of your
|
||||||
your copyrighted material outside their relationship with you.
|
copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
Conveying under any other circumstances is permitted solely under the
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||||
makes it unnecessary.
|
it unnecessary.
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
No covered work shall be deemed part of an effective technological
|
||||||
measure under any applicable law fulfilling obligations under article
|
measure under any applicable law fulfilling obligations under article
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
similar laws prohibiting or restricting circumvention of such
|
similar laws prohibiting or restricting circumvention of such
|
||||||
measures.
|
measures.
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
circumvention of technological measures to the extent such circumvention
|
circumvention of technological measures to the extent such
|
||||||
is effected by exercising rights under this License with respect to
|
circumvention is effected by exercising rights under this License with
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
respect to the covered work, and you disclaim any intention to limit
|
||||||
modification of the work as a means of enforcing, against the work's
|
operation or modification of the work as a means of enforcing, against
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
the work's users, your or third parties' legal rights to forbid
|
||||||
technological measures.
|
circumvention of technological measures.
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
#### 4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
You may convey verbatim copies of the Program's source code as you
|
||||||
receive it, in any medium, provided that you conspicuously and
|
receive it, in any medium, provided that you conspicuously and
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
keep intact all notices stating that this License and any
|
keep intact all notices stating that this License and any
|
||||||
@@ -202,37 +194,35 @@ non-permissive terms added in accord with section 7 apply to the code;
|
|||||||
keep intact all notices of the absence of any warranty; and give all
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
recipients a copy of this License along with the Program.
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
You may charge any price or no price for each copy that you convey,
|
||||||
and you may offer support or warranty protection for a fee.
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
#### 5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
You may convey a work based on the Program, or the modifications to
|
||||||
produce it from the Program, in the form of source code under the
|
produce it from the Program, in the form of source code under the
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
terms of section 4, provided that you also meet all of these
|
||||||
|
conditions:
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
- a) The work must carry prominent notices stating that you modified
|
||||||
it, and giving a relevant date.
|
it, and giving a relevant date.
|
||||||
|
- b) The work must carry prominent notices stating that it is
|
||||||
b) The work must carry prominent notices stating that it is
|
released under this License and any conditions added under
|
||||||
released under this License and any conditions added under section
|
section 7. This requirement modifies the requirement in section 4
|
||||||
7. This requirement modifies the requirement in section 4 to
|
to "keep intact all notices".
|
||||||
"keep intact all notices".
|
- c) You must license the entire work, as a whole, under this
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
License to anyone who comes into possession of a copy. This
|
||||||
License will therefore apply, along with any applicable section 7
|
License will therefore apply, along with any applicable section 7
|
||||||
additional terms, to the whole of the work, and all its parts,
|
additional terms, to the whole of the work, and all its parts,
|
||||||
regardless of how they are packaged. This License gives no
|
regardless of how they are packaged. This License gives no
|
||||||
permission to license the work in any other way, but it does not
|
permission to license the work in any other way, but it does not
|
||||||
invalidate such permission if you have separately received it.
|
invalidate such permission if you have separately received it.
|
||||||
|
- d) If the work has interactive user interfaces, each must display
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
work need not make them do so.
|
work need not make them do so.
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
A compilation of a covered work with other separate and independent
|
||||||
works, which are not by their nature extensions of the covered work,
|
works, which are not by their nature extensions of the covered work,
|
||||||
and which are not combined with it such as to form a larger program,
|
and which are not combined with it such as to form a larger program,
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
@@ -242,19 +232,18 @@ beyond what the individual works permit. Inclusion of a covered work
|
|||||||
in an aggregate does not cause this License to apply to the other
|
in an aggregate does not cause this License to apply to the other
|
||||||
parts of the aggregate.
|
parts of the aggregate.
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
#### 6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
You may convey a covered work in object code form under the terms of
|
||||||
of sections 4 and 5, provided that you also convey the
|
sections 4 and 5, provided that you also convey the machine-readable
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
Corresponding Source under the terms of this License, in one of these
|
||||||
in one of these ways:
|
ways:
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
- a) Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by the
|
(including a physical distribution medium), accompanied by the
|
||||||
Corresponding Source fixed on a durable physical medium
|
Corresponding Source fixed on a durable physical medium
|
||||||
customarily used for software interchange.
|
customarily used for software interchange.
|
||||||
|
- b) Convey the object code in, or embodied in, a physical product
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
(including a physical distribution medium), accompanied by a
|
||||||
written offer, valid for at least three years and valid for as
|
written offer, valid for at least three years and valid for as
|
||||||
long as you offer spare parts or customer support for that product
|
long as you offer spare parts or customer support for that product
|
||||||
@@ -263,16 +252,14 @@ in one of these ways:
|
|||||||
product that is covered by this License, on a durable physical
|
product that is covered by this License, on a durable physical
|
||||||
medium customarily used for software interchange, for a price no
|
medium customarily used for software interchange, for a price no
|
||||||
more than your reasonable cost of physically performing this
|
more than your reasonable cost of physically performing this
|
||||||
conveying of source, or (2) access to copy the
|
conveying of source, or (2) access to copy the Corresponding
|
||||||
Corresponding Source from a network server at no charge.
|
Source from a network server at no charge.
|
||||||
|
- c) Convey individual copies of the object code with a copy of the
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
written offer to provide the Corresponding Source. This
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
only if you received the object code with such an offer, in accord
|
only if you received the object code with such an offer, in accord
|
||||||
with subsection 6b.
|
with subsection 6b.
|
||||||
|
- d) Convey the object code by offering access from a designated
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
Corresponding Source in the same way through the same place at no
|
Corresponding Source in the same way through the same place at no
|
||||||
further charge. You need not require recipients to copy the
|
further charge. You need not require recipients to copy the
|
||||||
@@ -284,38 +271,38 @@ in one of these ways:
|
|||||||
Corresponding Source. Regardless of what server hosts the
|
Corresponding Source. Regardless of what server hosts the
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
available for as long as needed to satisfy these requirements.
|
available for as long as needed to satisfy these requirements.
|
||||||
|
- e) Convey the object code using peer-to-peer transmission,
|
||||||
|
provided you inform other peers where the object code and
|
||||||
|
Corresponding Source of the work are being offered to the general
|
||||||
|
public at no charge under subsection 6d.
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
A separable portion of the object code, whose source code is excluded
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
from the Corresponding Source as a System Library, need not be
|
||||||
included in conveying the object code work.
|
included in conveying the object code work.
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
tangible personal property which is normally used for personal, family,
|
tangible personal property which is normally used for personal,
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
family, or household purposes, or (2) anything designed or sold for
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
incorporation into a dwelling. In determining whether a product is a
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
consumer product, doubtful cases shall be resolved in favor of
|
||||||
product received by a particular user, "normally used" refers to a
|
coverage. For a particular product received by a particular user,
|
||||||
typical or common use of that class of product, regardless of the status
|
"normally used" refers to a typical or common use of that class of
|
||||||
of the particular user or of the way in which the particular user
|
product, regardless of the status of the particular user or of the way
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
in which the particular user actually uses, or expects or is expected
|
||||||
is a consumer product regardless of whether the product has substantial
|
to use, the product. A product is a consumer product regardless of
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
whether the product has substantial commercial, industrial or
|
||||||
the only significant mode of use of the product.
|
non-consumer uses, unless such uses represent the only significant
|
||||||
|
mode of use of the product.
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
"Installation Information" for a User Product means any methods,
|
||||||
procedures, authorization keys, or other information required to install
|
procedures, authorization keys, or other information required to
|
||||||
and execute modified versions of a covered work in that User Product from
|
install and execute modified versions of a covered work in that User
|
||||||
a modified version of its Corresponding Source. The information must
|
Product from a modified version of its Corresponding Source. The
|
||||||
suffice to ensure that the continued functioning of the modified object
|
information must suffice to ensure that the continued functioning of
|
||||||
code is in no case prevented or interfered with solely because
|
the modified object code is in no case prevented or interfered with
|
||||||
modification has been made.
|
solely because modification has been made.
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
If you convey an object code work under this section in, or with, or
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
part of a transaction in which the right of possession and use of the
|
part of a transaction in which the right of possession and use of the
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
@@ -326,23 +313,24 @@ if neither you nor any third party retains the ability to install
|
|||||||
modified object code on the User Product (for example, the work has
|
modified object code on the User Product (for example, the work has
|
||||||
been installed in ROM).
|
been installed in ROM).
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
The requirement to provide Installation Information does not include a
|
||||||
requirement to continue to provide support service, warranty, or updates
|
requirement to continue to provide support service, warranty, or
|
||||||
for a work that has been modified or installed by the recipient, or for
|
updates for a work that has been modified or installed by the
|
||||||
the User Product in which it has been modified or installed. Access to a
|
recipient, or for the User Product in which it has been modified or
|
||||||
network may be denied when the modification itself materially and
|
installed. Access to a network may be denied when the modification
|
||||||
adversely affects the operation of the network or violates the rules and
|
itself materially and adversely affects the operation of the network
|
||||||
protocols for communication across the network.
|
or violates the rules and protocols for communication across the
|
||||||
|
network.
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
in accord with this section must be in a format that is publicly
|
in accord with this section must be in a format that is publicly
|
||||||
documented (and with an implementation available to the public in
|
documented (and with an implementation available to the public in
|
||||||
source code form), and must require no special password or key for
|
source code form), and must require no special password or key for
|
||||||
unpacking, reading or copying.
|
unpacking, reading or copying.
|
||||||
|
|
||||||
7. Additional Terms.
|
#### 7. Additional Terms.
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
License by making exceptions from one or more of its conditions.
|
License by making exceptions from one or more of its conditions.
|
||||||
Additional permissions that are applicable to the entire Program shall
|
Additional permissions that are applicable to the entire Program shall
|
||||||
be treated as though they were included in this License, to the extent
|
be treated as though they were included in this License, to the extent
|
||||||
@@ -351,41 +339,36 @@ apply only to part of the Program, that part may be used separately
|
|||||||
under those permissions, but the entire Program remains governed by
|
under those permissions, but the entire Program remains governed by
|
||||||
this License without regard to the additional permissions.
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
When you convey a copy of a covered work, you may at your option
|
||||||
remove any additional permissions from that copy, or from any part of
|
remove any additional permissions from that copy, or from any part of
|
||||||
it. (Additional permissions may be written to require their own
|
it. (Additional permissions may be written to require their own
|
||||||
removal in certain cases when you modify the work.) You may place
|
removal in certain cases when you modify the work.) You may place
|
||||||
additional permissions on material, added by you to a covered work,
|
additional permissions on material, added by you to a covered work,
|
||||||
for which you have or can give appropriate copyright permission.
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
Notwithstanding any other provision of this License, for material you
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
add to a covered work, you may (if authorized by the copyright holders
|
||||||
that material) supplement the terms of this License with terms:
|
of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
- a) Disclaiming warranty or limiting liability differently from the
|
||||||
terms of sections 15 and 16 of this License; or
|
terms of sections 15 and 16 of this License; or
|
||||||
|
- b) Requiring preservation of specified reasonable legal notices or
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
author attributions in that material or in the Appropriate Legal
|
||||||
Notices displayed by works containing it; or
|
Notices displayed by works containing it; or
|
||||||
|
- c) Prohibiting misrepresentation of the origin of that material,
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
or requiring that modified versions of such material be marked in
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
reasonable ways as different from the original version; or
|
||||||
|
- d) Limiting the use for publicity purposes of names of licensors
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
or authors of the material; or
|
||||||
authors of the material; or
|
- e) Declining to grant rights under trademark law for use of some
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
trade names, trademarks, or service marks; or
|
||||||
|
- f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions
|
||||||
|
of it) with contractual assumptions of liability to the recipient,
|
||||||
|
for any liability that these contractual assumptions directly
|
||||||
|
impose on those licensors and authors.
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
All other non-permissive additional terms are considered "further
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
received it, or any part of it, contains a notice stating that it is
|
received it, or any part of it, contains a notice stating that it is
|
||||||
governed by this License along with a term that is a further
|
governed by this License along with a term that is a further
|
||||||
@@ -395,47 +378,47 @@ License, you may add to a covered work material governed by the terms
|
|||||||
of that license document, provided that the further restriction does
|
of that license document, provided that the further restriction does
|
||||||
not survive such relicensing or conveying.
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
If you add terms to a covered work in accord with this section, you
|
||||||
must place, in the relevant source files, a statement of the
|
must place, in the relevant source files, a statement of the
|
||||||
additional terms that apply to those files, or a notice indicating
|
additional terms that apply to those files, or a notice indicating
|
||||||
where to find the applicable terms.
|
where to find the applicable terms.
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
form of a separately written license, or stated as exceptions;
|
form of a separately written license, or stated as exceptions; the
|
||||||
the above requirements apply either way.
|
above requirements apply either way.
|
||||||
|
|
||||||
8. Termination.
|
#### 8. Termination.
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
You may not propagate or modify a covered work except as expressly
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
modify it is void, and will automatically terminate your rights under
|
modify it is void, and will automatically terminate your rights under
|
||||||
this License (including any patent licenses granted under the third
|
this License (including any patent licenses granted under the third
|
||||||
paragraph of section 11).
|
paragraph of section 11).
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
However, if you cease all violation of this License, then your license
|
||||||
license from a particular copyright holder is reinstated (a)
|
from a particular copyright holder is reinstated (a) provisionally,
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
unless and until the copyright holder explicitly and finally
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
terminates your license, and (b) permanently, if the copyright holder
|
||||||
holder fails to notify you of the violation by some reasonable means
|
fails to notify you of the violation by some reasonable means prior to
|
||||||
prior to 60 days after the cessation.
|
60 days after the cessation.
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
Moreover, your license from a particular copyright holder is
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
violation by some reasonable means, this is the first time you have
|
violation by some reasonable means, this is the first time you have
|
||||||
received notice of violation of this License (for any work) from that
|
received notice of violation of this License (for any work) from that
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
your receipt of the notice.
|
your receipt of the notice.
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
Termination of your rights under this section does not terminate the
|
||||||
licenses of parties who have received copies or rights from you under
|
licenses of parties who have received copies or rights from you under
|
||||||
this License. If your rights have been terminated and not permanently
|
this License. If your rights have been terminated and not permanently
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
material under section 10.
|
material under section 10.
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
#### 9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
You are not required to accept this License in order to receive or run
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
a copy of the Program. Ancillary propagation of a covered work
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
to receive a copy likewise does not require acceptance. However,
|
to receive a copy likewise does not require acceptance. However,
|
||||||
nothing other than this License grants you permission to propagate or
|
nothing other than this License grants you permission to propagate or
|
||||||
@@ -443,14 +426,14 @@ modify any covered work. These actions infringe copyright if you do
|
|||||||
not accept this License. Therefore, by modifying or propagating a
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
#### 10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
Each time you convey a covered work, the recipient automatically
|
||||||
receives a license from the original licensors, to run, modify and
|
receives a license from the original licensors, to run, modify and
|
||||||
propagate that work, subject to this License. You are not responsible
|
propagate that work, subject to this License. You are not responsible
|
||||||
for enforcing compliance by third parties with this License.
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
An "entity transaction" is a transaction transferring control of an
|
||||||
organization, or substantially all assets of one, or subdividing an
|
organization, or substantially all assets of one, or subdividing an
|
||||||
organization, or merging organizations. If propagation of a covered
|
organization, or merging organizations. If propagation of a covered
|
||||||
work results from an entity transaction, each party to that
|
work results from an entity transaction, each party to that
|
||||||
@@ -460,7 +443,7 @@ give under the previous paragraph, plus a right to possession of the
|
|||||||
Corresponding Source of the work from the predecessor in interest, if
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
You may not impose any further restrictions on the exercise of the
|
||||||
rights granted or affirmed under this License. For example, you may
|
rights granted or affirmed under this License. For example, you may
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
rights granted under this License, and you may not initiate litigation
|
rights granted under this License, and you may not initiate litigation
|
||||||
@@ -468,14 +451,14 @@ rights granted under this License, and you may not initiate litigation
|
|||||||
any patent claim is infringed by making, using, selling, offering for
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
sale, or importing the Program or any portion of it.
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
11. Patents.
|
#### 11. Patents.
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
License of the Program or a work on which the Program is based. The
|
License of the Program or a work on which the Program is based. The
|
||||||
work thus licensed is called the contributor's "contributor version".
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
A contributor's "essential patent claims" are all patent claims owned
|
||||||
owned or controlled by the contributor, whether already acquired or
|
or controlled by the contributor, whether already acquired or
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
by this License, of making, using, or selling its contributor version,
|
by this License, of making, using, or selling its contributor version,
|
||||||
but do not include claims that would be infringed only as a
|
but do not include claims that would be infringed only as a
|
||||||
@@ -484,19 +467,19 @@ purposes of this definition, "control" includes the right to grant
|
|||||||
patent sublicenses in a manner consistent with the requirements of
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
this License.
|
this License.
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
patent license under the contributor's essential patent claims, to
|
patent license under the contributor's essential patent claims, to
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
propagate the contents of its contributor version.
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
In the following three paragraphs, a "patent license" is any express
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
(such as an express permission to practice a patent or covenant not to
|
(such as an express permission to practice a patent or covenant not to
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
party means to make such an agreement or commitment not to enforce a
|
party means to make such an agreement or commitment not to enforce a
|
||||||
patent against the party.
|
patent against the party.
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
and the Corresponding Source of the work is not available for anyone
|
and the Corresponding Source of the work is not available for anyone
|
||||||
to copy, free of charge and under the terms of this License, through a
|
to copy, free of charge and under the terms of this License, through a
|
||||||
publicly available network server or other readily accessible means,
|
publicly available network server or other readily accessible means,
|
||||||
@@ -510,7 +493,7 @@ covered work in a country, or your recipient's use of the covered work
|
|||||||
in a country, would infringe one or more identifiable patents in that
|
in a country, would infringe one or more identifiable patents in that
|
||||||
country that you have reason to believe are valid.
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
If, pursuant to or in connection with a single transaction or
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
covered work, and grant a patent license to some of the parties
|
covered work, and grant a patent license to some of the parties
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
@@ -518,157 +501,160 @@ or convey a specific copy of the covered work, then the patent license
|
|||||||
you grant is automatically extended to all recipients of the covered
|
you grant is automatically extended to all recipients of the covered
|
||||||
work and works based on it.
|
work and works based on it.
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
A patent license is "discriminatory" if it does not include within the
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
the non-exercise of one or more of the rights that are specifically
|
||||||
specifically granted under this License. You may not convey a covered
|
granted under this License. You may not convey a covered work if you
|
||||||
work if you are a party to an arrangement with a third party that is
|
are a party to an arrangement with a third party that is in the
|
||||||
in the business of distributing software, under which you make payment
|
business of distributing software, under which you make payment to the
|
||||||
to the third party based on the extent of your activity of conveying
|
third party based on the extent of your activity of conveying the
|
||||||
the work, and under which the third party grants, to any of the
|
work, and under which the third party grants, to any of the parties
|
||||||
parties who would receive the covered work from you, a discriminatory
|
who would receive the covered work from you, a discriminatory patent
|
||||||
patent license (a) in connection with copies of the covered work
|
license (a) in connection with copies of the covered work conveyed by
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
you (or copies made from those copies), or (b) primarily for and in
|
||||||
for and in connection with specific products or compilations that
|
connection with specific products or compilations that contain the
|
||||||
contain the covered work, unless you entered into that arrangement,
|
covered work, unless you entered into that arrangement, or that patent
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
any implied license or other defenses to infringement that may
|
any implied license or other defenses to infringement that may
|
||||||
otherwise be available to you under applicable patent law.
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
#### 12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
covered work so as to satisfy simultaneously your obligations under
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
this License and any other pertinent obligations, then as a
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
consequence you may not convey it at all. For example, if you agree to
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
terms that obligate you to collect a royalty for further conveying
|
||||||
the Program, the only way you could satisfy both those terms and this
|
from those to whom you convey the Program, the only way you could
|
||||||
License would be to refrain entirely from conveying the Program.
|
satisfy both those terms and this License would be to refrain entirely
|
||||||
|
from conveying the Program.
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
#### 13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your
|
||||||
|
version supports such interaction) an opportunity to receive the
|
||||||
|
Corresponding Source of your version by providing access to the
|
||||||
|
Corresponding Source from a network server at no charge, through some
|
||||||
|
standard or customary means of facilitating copying of software. This
|
||||||
|
Corresponding Source shall include the Corresponding Source for any
|
||||||
|
work covered by version 3 of the GNU General Public License that is
|
||||||
|
incorporated pursuant to the following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
under version 3 of the GNU General Public License into a single
|
||||||
combined work, and to convey the resulting work. The terms of this
|
combined work, and to convey the resulting work. The terms of this
|
||||||
License will continue to apply to the part which is the covered work,
|
License will continue to apply to the part which is the covered work,
|
||||||
but the special requirements of the GNU Affero General Public License,
|
but the work with which it is combined will remain governed by version
|
||||||
section 13, concerning interaction through a network will apply to the
|
3 of the GNU General Public License.
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
#### 14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
the GNU General Public License from time to time. Such new versions will
|
of the GNU Affero General Public License from time to time. Such new
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
versions will be similar in spirit to the present version, but may
|
||||||
address new problems or concerns.
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the Program
|
||||||
Program specifies that a certain numbered version of the GNU General
|
specifies that a certain numbered version of the GNU Affero General
|
||||||
Public License "or any later version" applies to it, you have the
|
Public License "or any later version" applies to it, you have the
|
||||||
option of following the terms and conditions either of that numbered
|
option of following the terms and conditions either of that numbered
|
||||||
version or of any later version published by the Free Software
|
version or of any later version published by the Free Software
|
||||||
Foundation. If the Program does not specify a version number of the
|
Foundation. If the Program does not specify a version number of the
|
||||||
GNU General Public License, you may choose any version ever published
|
GNU Affero General Public License, you may choose any version ever
|
||||||
by the Free Software Foundation.
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
If the Program specifies that a proxy can decide which future versions
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
of the GNU Affero General Public License can be used, that proxy's
|
||||||
public statement of acceptance of a version permanently authorizes you
|
public statement of acceptance of a version permanently authorizes you
|
||||||
to choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
Later license versions may give you additional or different
|
||||||
permissions. However, no additional obligations are imposed on any
|
permissions. However, no additional obligations are imposed on any
|
||||||
author or copyright holder as a result of your choosing to follow a
|
author or copyright holder as a result of your choosing to follow a
|
||||||
later version.
|
later version.
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
#### 15. Disclaimer of Warranty.
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||||
|
CORRECTION.
|
||||||
|
|
||||||
16. Limitation of Liability.
|
#### 16. Limitation of Liability.
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||||
SUCH DAMAGES.
|
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
#### 17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
above cannot be given local legal effect according to their terms,
|
above cannot be given local legal effect according to their terms,
|
||||||
reviewing courts shall apply local law that most closely approximates
|
reviewing courts shall apply local law that most closely approximates
|
||||||
an absolute waiver of all civil liability in connection with the
|
an absolute waiver of all civil liability in connection with the
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
copy of the Program in return for a fee.
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
### How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
possible use to the public, the best way to achieve this is to make it
|
possible use to the public, the best way to achieve this is to make it
|
||||||
free software which everyone can redistribute and change under these terms.
|
free software which everyone can redistribute and change under these
|
||||||
|
terms.
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
To do so, attach the following notices to the program. It is safest to
|
||||||
to attach them to the start of each source file to most effectively
|
attach them to the start of each source file to most effectively state
|
||||||
state the exclusion of warranty; and each file should have at least
|
the exclusion of warranty; and each file should have at least the
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
{one line to give the program's name and a brief idea of what it does.}
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
Copyright (C) {year} {name of author}
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU Affero General Public License as
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
published by the Free Software Foundation, either version 3 of the
|
||||||
(at your option) any later version.
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper
|
||||||
|
mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If your software can interact with users remotely through a computer
|
||||||
notice like this when it starts in an interactive mode:
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for
|
||||||
|
the specific requirements.
|
||||||
|
|
||||||
{project} Copyright (C) {year} {fullname}
|
You should also get your employer (if you work as a programmer) or
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
This is free software, and you are welcome to redistribute it
|
necessary. For more information on this, and how to apply and follow
|
||||||
under certain conditions; type `show c' for details.
|
the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
|
52
README.md
@@ -1,23 +1,33 @@
|
|||||||
# TSBattery
|
# TSBattery
|
||||||
|
|
||||||

|
[](https://github.com/fankes/TSBattery)
|
||||||

|
[](https://github.com/fankes/TSBattery/blob/master/LICENSE)
|
||||||

|
[](https://github.com/fankes/TSBattery/releases)
|
||||||
|
[](https://github.com/fankes/TSBattery/releases)
|
||||||
|
[](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases)
|
||||||
|
[](https://t.me/XiaofangInternet)
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<br/>
|
<br/>
|
||||||
TSBattery a new way to save your battery avoid cancer apps hacker it.<br/>
|
A new way to save your battery avoid cancer apps hacker it.<br/>
|
||||||
TSBattery 是一个旨在使 QQ、TIM、微信 变得更省电的开源 Xposed 模块
|
TSBattery 是一个旨在使 QQ、TIM、微信 变得更省电的开源 Xposed 模块。
|
||||||
|
|
||||||
# 开始使用
|
# Developer
|
||||||
|
|
||||||
点击下载最新版本
|
[酷安 @星夜不荟](http://www.coolapk.com/u/876977)
|
||||||
<a href='https://github.com/fankes/TSBattery/releases'></a>
|
|
||||||
<br/><br/>
|
|
||||||
⚠️适配说明:此模块支持原生 Xposed、Lsposed(作用域 QQ、TIM、微信 如果不起作用勾选系统框架)、EdXposed(不推荐)、太极无极(阴和阳)、Pine(梦境模块)
|
|
||||||
|
|
||||||
# 禁止任何商业用途
|
# 适配说明
|
||||||
|
|
||||||
本模块完全开源免费,如果好用你可以打赏支持开发,严禁未经许可进行二改贩卖,违者必惩必究。
|
- 支持并建议使用 <b>LSPosed</b>(若作用域没有自动出现推荐请勾选 QQ、TIM、微信)
|
||||||
|
- 可以使用 <b>~~EdXposed~~</b>,但随时停止支持
|
||||||
|
- <b>太极无极 · 阴</b> 支持性不是很好,建议使用 <b>太极无极 · 阳</b>
|
||||||
|
- 支持 <b>Pine</b>(梦境模块) 但是部分功能有限制
|
||||||
|
- 请不要使用 <b>~~应用转生~~</b>,发生封号情况后果自负
|
||||||
|
|
||||||
|
# 请勿用于非法用途
|
||||||
|
|
||||||
|
- 本模块完全开源免费,如果好用你可以打赏支持开发,但是请不要用于非法用途。
|
||||||
|
- 本模块发布地址仅有 [Xposed-Modules-Repo](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases)、
|
||||||
|
[Release](https://github.com/fankes/TSBattery/releases) 及 [蓝奏云](https://fankes.lanzouy.com/b02zfz3sj),从其他非正规渠道下载到的版本或对您造成任何影响均与我们无关。
|
||||||
|
|
||||||
# 开始贡献
|
# 开始贡献
|
||||||
|
|
||||||
@@ -27,18 +37,24 @@ TSBattery 是一个旨在使 QQ、TIM、微信 变得更省电的开源 Xposed
|
|||||||
|
|
||||||
# 许可证
|
# 许可证
|
||||||
|
|
||||||
- [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.html)
|
- [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html)
|
||||||
|
|
||||||
```
|
```
|
||||||
Copyright (C) 2020-2022 Fankes Studio(qzmmcn@163.com)
|
Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU Affero General Public License as
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
published by the Free Software Foundation, either version 3 of the
|
||||||
(at your option) any later version.
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Powered by [YukiHookAPI](https://github.com/fankes/YukiHookAPI)<br/><br/>
|
||||||
|
版权所有 © 2019-2022 Fankes Studio(qzmmcn@163.com)
|
1
app/.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
/build
|
/build
|
||||||
|
/release
|
@@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
id 'kotlin-android'
|
id 'kotlin-android'
|
||||||
|
id 'com.google.devtools.ksp' version '1.6.10-1.0.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -19,11 +20,18 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.fankes.tsbattery"
|
applicationId "com.fankes.tsbattery"
|
||||||
minSdkVersion 22
|
minSdk 22
|
||||||
//noinspection ExpiredTargetSdkVersion
|
targetSdk 26
|
||||||
targetSdkVersion 26
|
versionCode rootProject.ext.appVersionCode
|
||||||
versionCode 10
|
versionName rootProject.ext.appVersionName
|
||||||
versionName "3.1"
|
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs = [
|
||||||
|
'-Xno-param-assertions',
|
||||||
|
'-Xno-call-assertions',
|
||||||
|
'-Xno-receiver-assertions'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -36,23 +44,39 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = '1.8'
|
jvmTarget = '11'
|
||||||
}
|
}
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 移除无效耗时 lint Task */
|
||||||
|
tasks.whenTaskAdded {
|
||||||
|
task -> if (task.name == "lintVitalRelease") task.enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 移除无效耗时 lint Task */
|
||||||
|
tasks.whenTaskAdded {
|
||||||
|
task -> if (task.name == "lintVitalAnalyzeRelease") task.enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 移除无效耗时 lint Task */
|
||||||
|
tasks.whenTaskAdded {
|
||||||
|
task -> if (task.name == "lintVitalReportRelease") task.enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'de.robv.android.xposed:api:82'
|
compileOnly 'de.robv.android.xposed:api:82'
|
||||||
// 基础依赖包
|
implementation 'com.highcapable.yukihookapi:api:1.0.69'
|
||||||
implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
|
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.69'
|
||||||
// Fragment 快速实现
|
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||||
implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||||
// Kotlin 扩展
|
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
||||||
implementation 'com.gyf.immersionbar:immersionbar-ktx:3.0.0'
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
implementation 'androidx.core:core-ktx:1.7.0'
|
implementation 'androidx.core:core-ktx:1.7.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||||
implementation 'com.google.android.material:material:1.5.0'
|
implementation 'com.google.android.material:material:1.5.0'
|
||||||
|
16
app/proguard-rules.pro
vendored
@@ -27,22 +27,26 @@
|
|||||||
-dontoptimize
|
-dontoptimize
|
||||||
-verbose
|
-verbose
|
||||||
-overloadaggressively
|
-overloadaggressively
|
||||||
-repackageclasses o
|
|
||||||
-allowaccessmodification
|
-allowaccessmodification
|
||||||
-adaptclassstrings
|
-adaptclassstrings
|
||||||
-adaptresourcefilenames
|
-adaptresourcefilenames
|
||||||
-adaptresourcefilecontents
|
-adaptresourcefilecontents
|
||||||
|
|
||||||
#-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
|
-renamesourcefileattribute P
|
||||||
-renamesourcefileattribute H
|
|
||||||
-keepattributes SourceFile,LineNumberTable
|
-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
-keep class android.support**
|
|
||||||
-keep class androidx**
|
|
||||||
|
|
||||||
-keep public class * extends android.app.Activity
|
-keep public class * extends android.app.Activity
|
||||||
-keep public class * extends android.app.Application
|
-keep public class * extends android.app.Application
|
||||||
-keep public class * extends android.app.Service
|
-keep public class * extends android.app.Service
|
||||||
-keep public class * extends android.content.ContentProvider
|
-keep public class * extends android.content.ContentProvider
|
||||||
-keep public class * extends android.app.backup.BackupAgentHelper
|
-keep public class * extends android.app.backup.BackupAgentHelper
|
||||||
-keep public class * extends android.preference.Preference
|
-keep public class * extends android.preference.Preference
|
||||||
|
|
||||||
|
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
||||||
|
public static *** throwUninitializedProperty(...);
|
||||||
|
public static *** throwUninitializedPropertyAccessException(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers class * implements androidx.viewbinding.ViewBinding {
|
||||||
|
*** inflate(android.view.LayoutInflater);
|
||||||
|
}
|
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"artifactType": {
|
|
||||||
"type": "APK",
|
|
||||||
"kind": "Directory"
|
|
||||||
},
|
|
||||||
"applicationId": "com.fankes.tsbattery",
|
|
||||||
"variantName": "release",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "SINGLE",
|
|
||||||
"filters": [],
|
|
||||||
"attributes": [],
|
|
||||||
"versionCode": 10,
|
|
||||||
"versionName": "3.1",
|
|
||||||
"outputFile": "app-release.apk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"elementType": "File"
|
|
||||||
}
|
|
@@ -3,6 +3,16 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.fankes.tsbattery">
|
package="com.fankes.tsbattery">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
|
<!-- 作用域 APP -->
|
||||||
|
<queries>
|
||||||
|
<package android:name="com.tencent.mobileqq" />
|
||||||
|
<package android:name="com.tencent.tim" />
|
||||||
|
<package android:name="com.tencent.mm" />
|
||||||
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".application.TSApplication"
|
android:name=".application.TSApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -13,25 +23,22 @@
|
|||||||
android:theme="@style/Theme.TSBattery"
|
android:theme="@style/Theme.TSBattery"
|
||||||
tools:ignore="AllowBackup">
|
tools:ignore="AllowBackup">
|
||||||
|
|
||||||
<!-- 是否是xposed模块 -->
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="xposedmodule"
|
android:name="xposedmodule"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
|
|
||||||
<!-- 模块描述 -->
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="xposeddescription"
|
android:name="xposeddescription"
|
||||||
android:value="Tencent 社交毒瘤一键省电模块。\n目前支持 QQ、TIM、微信\n开发者:酷安 @星夜不荟" />
|
android:value="Tencent 社交毒瘤一键省电模块。\n目前支持 QQ、TIM、微信\n开发者:酷安 @星夜不荟" />
|
||||||
|
|
||||||
<!-- 最低xposed版本号 -->
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="xposedminversion"
|
android:name="xposedminversion"
|
||||||
android:value="82" />
|
android:value="93" />
|
||||||
|
<meta-data
|
||||||
|
android:name="xposedscope"
|
||||||
|
android:resource="@array/module_scope" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.fankes.tsbattery.ui.MainActivity"
|
android:name="com.fankes.tsbattery.ui.activity.MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
|
||||||
android:screenOrientation="behind">
|
android:screenOrientation="behind">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -46,7 +53,7 @@
|
|||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="behind"
|
android:screenOrientation="behind"
|
||||||
android:targetActivity="com.fankes.tsbattery.ui.MainActivity">
|
android:targetActivity="com.fankes.tsbattery.ui.activity.MainActivity">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
@@ -1 +1 @@
|
|||||||
com.fankes.tsbattery.hook.HookMain
|
com.fankes.tsbattery.hook.HookEntry_YukiHookXposedInit
|
1
app/src/main/assets/yukihookapi_init
Normal file
@@ -0,0 +1 @@
|
|||||||
|
com.fankes.tsbattery.hook.HookEntry
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2021/11/9.
|
* This file is Created by fankes on 2021/11/9.
|
||||||
*/
|
*/
|
||||||
@@ -43,7 +44,7 @@ class TSApplication : Application() {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
/** 设置静态实例 */
|
/** 设置静态实例 */
|
||||||
context = this
|
context = this
|
||||||
/** 禁止系统夜间模式对自己造成干扰 - 模块要什么夜间模式?😅 (其实是我懒) */
|
/** 跟随系统夜间模式 */
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||||
}
|
}
|
||||||
}
|
}
|
37
app/src/main/java/com/fankes/tsbattery/data/DataConst.kt
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/3/28.
|
||||||
|
*/
|
||||||
|
package com.fankes.tsbattery.data
|
||||||
|
|
||||||
|
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||||
|
|
||||||
|
object DataConst {
|
||||||
|
|
||||||
|
val ENABLE_HIDE_ICON = PrefsData("_hide_icon", false)
|
||||||
|
val ENABLE_RUN_INFO = PrefsData("_tip_run_info", false)
|
||||||
|
val ENABLE_NOTIFY_TIP = PrefsData("_tip_in_notify", true)
|
||||||
|
val ENABLE_SETTING_TIP = PrefsData("_tip_in_setting", true)
|
||||||
|
val ENABLE_QQTIM_WHITE_MODE = PrefsData("_qqtim_white_mode", false)
|
||||||
|
val ENABLE_QQTIM_CORESERVICE_BAN = PrefsData("_qqtim_core_service_ban", false)
|
||||||
|
val ENABLE_QQTIM_CORESERVICE_CHILD_BAN = PrefsData("_qqtim_core_service_child_ban", false)
|
||||||
|
val DISABLE_WECHAT_HOOK = PrefsData("_disable_wechat_hook", false)
|
||||||
|
val ENABLE_MODULE_VERSION = PrefsData("_module_version", "")
|
||||||
|
}
|
29
app/src/main/java/com/fankes/tsbattery/hook/HookConst.kt
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2021/11/9.
|
||||||
|
*/
|
||||||
|
package com.fankes.tsbattery.hook
|
||||||
|
|
||||||
|
object HookConst {
|
||||||
|
|
||||||
|
const val QQ_PACKAGE_NAME = "com.tencent.mobileqq"
|
||||||
|
const val TIM_PACKAGE_NAME = "com.tencent.tim"
|
||||||
|
const val WECHAT_PACKAGE_NAME = "com.tencent.mm"
|
||||||
|
}
|
656
app/src/main/java/com/fankes/tsbattery/hook/HookEntry.kt
Normal file
@@ -0,0 +1,656 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/2/15.
|
||||||
|
*/
|
||||||
|
@file:Suppress("IMPLICIT_CAST_TO_ANY")
|
||||||
|
|
||||||
|
package com.fankes.tsbattery.hook
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Service
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.fankes.tsbattery.BuildConfig
|
||||||
|
import com.fankes.tsbattery.data.DataConst
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.QQ_PACKAGE_NAME
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.TIM_PACKAGE_NAME
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.WECHAT_PACKAGE_NAME
|
||||||
|
import com.fankes.tsbattery.ui.activity.MainActivity
|
||||||
|
import com.fankes.tsbattery.utils.factory.showDialog
|
||||||
|
import com.fankes.tsbattery.utils.factory.versionCode
|
||||||
|
import com.fankes.tsbattery.utils.factory.versionName
|
||||||
|
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
||||||
|
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.*
|
||||||
|
import com.highcapable.yukihookapi.hook.log.loggerD
|
||||||
|
import com.highcapable.yukihookapi.hook.log.loggerE
|
||||||
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
|
import com.highcapable.yukihookapi.hook.type.android.*
|
||||||
|
import com.highcapable.yukihookapi.hook.type.java.*
|
||||||
|
import com.highcapable.yukihookapi.hook.xposed.proxy.YukiHookXposedInitProxy
|
||||||
|
|
||||||
|
@InjectYukiHookWithXposed
|
||||||
|
class HookEntry : YukiHookXposedInitProxy {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
/** QQ、TIM 存在的类 */
|
||||||
|
private const val SplashActivityClass = "$QQ_PACKAGE_NAME.activity.SplashActivity"
|
||||||
|
|
||||||
|
/** QQ、TIM 存在的类 */
|
||||||
|
private const val CoreServiceClass = "$QQ_PACKAGE_NAME.app.CoreService"
|
||||||
|
|
||||||
|
/** QQ、TIM 存在的类 */
|
||||||
|
private const val CoreService_KernelServiceClass = "$QQ_PACKAGE_NAME.app.CoreService\$KernelService"
|
||||||
|
|
||||||
|
/** QQ、TIM 新版本存在的类 */
|
||||||
|
private const val FormSimpleItemClass = "$QQ_PACKAGE_NAME.widget.FormSimpleItem"
|
||||||
|
|
||||||
|
/** QQ、TIM 旧版本存在的类 */
|
||||||
|
private const val FormCommonSingleLineItemClass = "$QQ_PACKAGE_NAME.widget.FormCommonSingleLineItem"
|
||||||
|
|
||||||
|
/** 微信存在的类 */
|
||||||
|
private const val LauncherUIClass = "$WECHAT_PACKAGE_NAME.ui.LauncherUI"
|
||||||
|
|
||||||
|
/** 根据多个版本存的不同的类 */
|
||||||
|
private val BaseChatPieClass = VariousClass(
|
||||||
|
"$QQ_PACKAGE_NAME.activity.aio.core.BaseChatPie",
|
||||||
|
"$QQ_PACKAGE_NAME.activity.BaseChatPie"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 这个类 QQ 的 BaseChatPie 是控制聊天界面的
|
||||||
|
*
|
||||||
|
* 里面有两个随机混淆的方法 ⬇
|
||||||
|
*
|
||||||
|
* remainScreenOn、cancelRemainScreenOn
|
||||||
|
*
|
||||||
|
* 这两个方法一个是挂起电源锁常驻亮屏
|
||||||
|
*
|
||||||
|
* 一个是停止常驻亮屏
|
||||||
|
*
|
||||||
|
* 不由分说每个版本混淆的方法名都会变
|
||||||
|
*
|
||||||
|
* 所以说每个版本重新适配 - 也可以提交分支帮我适配
|
||||||
|
*
|
||||||
|
* - ❗Hook 错了方法会造成闪退!
|
||||||
|
* @param version QQ 版本
|
||||||
|
*/
|
||||||
|
private fun PackageParam.hookQQBaseChatPie(version: String) {
|
||||||
|
when (version) {
|
||||||
|
"8.2.11" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bE")
|
||||||
|
interceptBaseChatPie(methodName = "aV")
|
||||||
|
}
|
||||||
|
"8.8.17" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bd")
|
||||||
|
interceptBaseChatPie(methodName = "be")
|
||||||
|
}
|
||||||
|
"8.8.23" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bf")
|
||||||
|
interceptBaseChatPie(methodName = "bg")
|
||||||
|
}
|
||||||
|
/** 8.8.35 贡献者:StarWishsama */
|
||||||
|
"8.8.35", "8.8.38" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bi")
|
||||||
|
interceptBaseChatPie(methodName = "bj")
|
||||||
|
}
|
||||||
|
/** 贡献者:JiZhi-Error */
|
||||||
|
"8.8.50" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bj")
|
||||||
|
interceptBaseChatPie(methodName = "bk")
|
||||||
|
}
|
||||||
|
"8.8.55", "8.8.68", "8.8.80" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bk")
|
||||||
|
interceptBaseChatPie(methodName = "bl")
|
||||||
|
}
|
||||||
|
"8.8.83", "8.8.85" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bl")
|
||||||
|
interceptBaseChatPie(methodName = "bm")
|
||||||
|
}
|
||||||
|
else -> loggerD(msg = "$version not supported!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拦截 [BaseChatPieClass] 的目标方法体封装
|
||||||
|
* @param methodName 方法名
|
||||||
|
*/
|
||||||
|
private fun PackageParam.interceptBaseChatPie(methodName: String) =
|
||||||
|
BaseChatPieClass.hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = methodName
|
||||||
|
returnType = UnitType
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hook 系统电源锁 */
|
||||||
|
private fun PackageParam.hookSystemWakeLock() =
|
||||||
|
PowerManager_WakeLockClass.hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "acquireLocked"
|
||||||
|
returnType = UnitType
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 增加通知栏文本显示守护状态 */
|
||||||
|
private fun PackageParam.hookNotification() =
|
||||||
|
Notification_BuilderClass.hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "setContentText"
|
||||||
|
param(CharSequenceType)
|
||||||
|
}
|
||||||
|
beforeHook {
|
||||||
|
if (prefs.get(DataConst.ENABLE_NOTIFY_TIP))
|
||||||
|
when (firstArgs<CharSequence>()) {
|
||||||
|
"QQ正在后台运行" ->
|
||||||
|
args().set("QQ正在后台运行 - TSBattery 守护中")
|
||||||
|
"TIM正在后台运行" ->
|
||||||
|
args().set("TIM正在后台运行 - TSBattery 守护中")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示模块运行信息 QQ、TIM、微信
|
||||||
|
* @param isQQTIM 是否为 QQ、TIM
|
||||||
|
*/
|
||||||
|
private fun PackageParam.hookModuleRunningInfo(isQQTIM: Boolean) =
|
||||||
|
when {
|
||||||
|
isQQTIM -> SplashActivityClass.hook {
|
||||||
|
/**
|
||||||
|
* Hook 启动界面的第一个 [Activity]
|
||||||
|
* QQ 和 TIM 都是一样的类
|
||||||
|
* 在里面加入提示运行信息的对话框测试模块是否激活
|
||||||
|
*/
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "doOnCreate"
|
||||||
|
param(BundleClass)
|
||||||
|
}
|
||||||
|
afterHook {
|
||||||
|
if (prefs.get(DataConst.ENABLE_RUN_INFO))
|
||||||
|
instance<Activity>().apply {
|
||||||
|
showDialog {
|
||||||
|
title = "TSBattery 已激活"
|
||||||
|
msg = "[提示模块运行信息功能已打开]\n\n" +
|
||||||
|
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
|
||||||
|
"已生效模块版本:${prefs.get(DataConst.ENABLE_MODULE_VERSION)}\n" +
|
||||||
|
"当前模式:${if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
||||||
|
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
||||||
|
"\n\n模块只对挂后台锁屏情况下有省电效果," +
|
||||||
|
"请不要将过多的群提醒,消息通知打开,这样子在使用过程时照样会极其耗电。\n\n" +
|
||||||
|
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
|
||||||
|
"持续常驻使用 QQ、TIM 依然会耗电,任何软件都是如此," +
|
||||||
|
"模块是无法帮你做到前台不耗电的。\n\n" +
|
||||||
|
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
noCancelable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> LauncherUIClass.hook {
|
||||||
|
/**
|
||||||
|
* Hook 启动界面的第一个 [Activity]
|
||||||
|
* 在里面加入提示运行信息的对话框测试模块是否激活
|
||||||
|
*/
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onCreate"
|
||||||
|
param(BundleClass)
|
||||||
|
}
|
||||||
|
afterHook {
|
||||||
|
if (prefs.get(DataConst.ENABLE_RUN_INFO))
|
||||||
|
instance<Activity>().apply {
|
||||||
|
showDialog(isUseBlackTheme = true) {
|
||||||
|
title = "TSBattery 已激活"
|
||||||
|
msg = "[提示模块运行信息功能已打开]\n\n" +
|
||||||
|
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
|
||||||
|
"已生效模块版本:${prefs.get(DataConst.ENABLE_MODULE_VERSION)}\n" +
|
||||||
|
"当前模式:基础省电" +
|
||||||
|
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
||||||
|
"\n\n当前只支持微信的基础省电,即系统电源锁,后续会继续适配微信相关的省电功能(在新建文件夹了)。\n\n" +
|
||||||
|
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
|
||||||
|
"持续常驻使用微信依然会耗电,任何软件都是如此," +
|
||||||
|
"模块是无法帮你做到前台不耗电的。\n\n" +
|
||||||
|
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
noCancelable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook CoreService QQ、TIM
|
||||||
|
* @param isQQ 是否为 QQ - 单独处理
|
||||||
|
*/
|
||||||
|
private fun PackageParam.hookCoreService(isQQ: Boolean) {
|
||||||
|
CoreServiceClass.hook {
|
||||||
|
if (isQQ) {
|
||||||
|
injectMember {
|
||||||
|
method { name = "startTempService" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "startCoreService"
|
||||||
|
param(BooleanType)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onStartCommand"
|
||||||
|
param(IntentClass, IntType, IntType)
|
||||||
|
}
|
||||||
|
replaceTo(any = 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "onCreate" }
|
||||||
|
afterHook {
|
||||||
|
if (prefs.get(DataConst.ENABLE_QQTIM_CORESERVICE_BAN))
|
||||||
|
instance<Service>().apply {
|
||||||
|
stopForeground(true)
|
||||||
|
stopSelf()
|
||||||
|
loggerD(msg = "Shutdown CoreService OK!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CoreService_KernelServiceClass.hook {
|
||||||
|
injectMember {
|
||||||
|
method { name = "onCreate" }
|
||||||
|
afterHook {
|
||||||
|
if (prefs.get(DataConst.ENABLE_QQTIM_CORESERVICE_CHILD_BAN))
|
||||||
|
instance<Service>().apply {
|
||||||
|
stopForeground(true)
|
||||||
|
stopSelf()
|
||||||
|
loggerD(msg = "Shutdown CoreService\$KernelService OK!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onStartCommand"
|
||||||
|
param(IntentClass, IntType, IntType)
|
||||||
|
}
|
||||||
|
replaceTo(any = 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将激活状态插入到设置页面
|
||||||
|
* @param isQQ 是否为 QQ - 单独处理
|
||||||
|
*/
|
||||||
|
private fun PackageParam.hookQQSettingsSettingActivity(isQQ: Boolean) =
|
||||||
|
findClass(name = "$QQ_PACKAGE_NAME.activity.QQSettingSettingActivity").hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "doOnCreate"
|
||||||
|
param(BundleClass)
|
||||||
|
afterHook {
|
||||||
|
/** 是否启用 Hook */
|
||||||
|
if (prefs.get(DataConst.ENABLE_SETTING_TIP).not()) return@afterHook
|
||||||
|
|
||||||
|
/** 当前的顶级 Item 实例 */
|
||||||
|
var formItemRefRoot: View? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用循环筛选
|
||||||
|
* @param target 目标变量名称
|
||||||
|
* @return [View] or null
|
||||||
|
*/
|
||||||
|
fun match(target: String) = runCatching {
|
||||||
|
field {
|
||||||
|
name = target
|
||||||
|
type = FormSimpleItemClass.clazz
|
||||||
|
}.ignoredError().get(instance).cast() ?: field {
|
||||||
|
name = target
|
||||||
|
type = FormCommonSingleLineItemClass.clazz
|
||||||
|
}.ignoredError().get(instance).cast<View?>()
|
||||||
|
}.getOrNull()
|
||||||
|
/** 循环出当前设置界面存在的顶级 Item */
|
||||||
|
arrayOf(
|
||||||
|
"a", "b", "c", "d", "e", "f", "g",
|
||||||
|
"h", "i", "j", "k", "l", "m", "n",
|
||||||
|
"o", "p", "q", "r", "s", "t", "u",
|
||||||
|
"v", "w", "x", "y", "z", "A", "B"
|
||||||
|
).forEach { match(it)?.also { e -> formItemRefRoot = e } }
|
||||||
|
/** 创建一个新的 Item */
|
||||||
|
FormSimpleItemClass.clazz.constructor { param(ContextClass) }.get().newInstance<View>(instance)?.also {
|
||||||
|
it.javaClass.apply {
|
||||||
|
method {
|
||||||
|
name = "setLeftText"
|
||||||
|
param(CharSequenceType)
|
||||||
|
}.get(it).call("TSBattery")
|
||||||
|
method {
|
||||||
|
name = "setRightText"
|
||||||
|
param(CharSequenceType)
|
||||||
|
}.get(it).call(prefs.get(DataConst.ENABLE_MODULE_VERSION))
|
||||||
|
method {
|
||||||
|
name = "setBgType"
|
||||||
|
param(IntType)
|
||||||
|
}.get(it).call(2)
|
||||||
|
}
|
||||||
|
it.setOnClickListener {
|
||||||
|
instance<Activity>().apply {
|
||||||
|
showDialog {
|
||||||
|
title = "TSBattery 守护中"
|
||||||
|
msg = "已生效模块版本:${prefs.get(DataConst.ENABLE_MODULE_VERSION)}\n" +
|
||||||
|
"当前模式:${if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
||||||
|
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
||||||
|
"\n\n模块只对挂后台锁屏情况下有省电效果," +
|
||||||
|
"请不要将过多的群提醒,消息通知打开,这样子在使用过程时照样会极其耗电。\n\n" +
|
||||||
|
"持续常驻使用 QQ、TIM 依然会耗电,任何软件都是如此," +
|
||||||
|
"模块是无法帮你做到前台不耗电的。\n\n" +
|
||||||
|
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
|
||||||
|
confirmButton(text = "打开模块设置") {
|
||||||
|
runCatching {
|
||||||
|
startActivity(Intent().apply {
|
||||||
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
component = ComponentName(
|
||||||
|
BuildConfig.APPLICATION_ID,
|
||||||
|
MainActivity::class.java.name
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}.onFailure { Toast.makeText(context, "启动失败", Toast.LENGTH_SHORT).show() }
|
||||||
|
}
|
||||||
|
cancelButton(text = "关闭")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
var listGroup = formItemRefRoot?.parent as? ViewGroup?
|
||||||
|
val lparam = (if (listGroup?.childCount == 1) {
|
||||||
|
listGroup = listGroup.parent as? ViewGroup
|
||||||
|
(formItemRefRoot?.parent as? View?)?.layoutParams
|
||||||
|
} else formItemRefRoot?.layoutParams) ?: ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
|
||||||
|
/** 将 Item 添加到设置界面 */
|
||||||
|
listGroup?.also { if (isQQ) it.addView(this, lparam) else it.addView(this, 0, lparam) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInit() = configs {
|
||||||
|
debugTag = "TSBattery"
|
||||||
|
isDebug = false
|
||||||
|
isEnableModulePrefsCache = false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHook() = encase {
|
||||||
|
loadApp(QQ_PACKAGE_NAME) {
|
||||||
|
hookSystemWakeLock()
|
||||||
|
hookNotification()
|
||||||
|
hookCoreService(isQQ = true)
|
||||||
|
hookModuleRunningInfo(isQQTIM = true)
|
||||||
|
hookQQSettingsSettingActivity(isQQ = true)
|
||||||
|
if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) return@loadApp
|
||||||
|
/** 通过在 [SplashActivityClass] 里取到应用的版本号 */
|
||||||
|
SplashActivityClass.hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "doOnCreate"
|
||||||
|
param(BundleClass)
|
||||||
|
}
|
||||||
|
afterHook { hookQQBaseChatPie(instance<Activity>().versionName) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 干掉消息收发功能的电源锁
|
||||||
|
* 每个版本的差异暂未做排查
|
||||||
|
* 旧版本理论上没有这个类
|
||||||
|
*/
|
||||||
|
findClass(name = "$QQ_PACKAGE_NAME.msf.service.y").hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "a"
|
||||||
|
param(StringType, LongType)
|
||||||
|
returnType = UnitType
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}.onAllFailure { loggerE(msg = "Hook MsfService Failed $it") }
|
||||||
|
}.ignoredHookClassNotFoundFailure()
|
||||||
|
/**
|
||||||
|
* 干掉自动上传服务的电源锁
|
||||||
|
* 每个版本的差异暂未做排查
|
||||||
|
*/
|
||||||
|
findClass(name = "com.tencent.upload.impl.UploadServiceImpl").hook {
|
||||||
|
injectMember {
|
||||||
|
method { name = "acquireWakeLockIfNot" }
|
||||||
|
intercept()
|
||||||
|
}.onAllFailure { loggerE(msg = "Hook UploadServiceImpl Failed $it") }
|
||||||
|
}.ignoredHookClassNotFoundFailure()
|
||||||
|
/**
|
||||||
|
* Hook 掉一个一像素保活 [Activity] 真的我怎么都想不到讯哥的程序员做出这种事情
|
||||||
|
* 这个东西经过测试会在锁屏的时候吊起来,解锁的时候自动 finish(),无限耍流氓耗电
|
||||||
|
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口的解锁后拉起保活界面,也是毒瘤
|
||||||
|
*/
|
||||||
|
findClass(name = "$QQ_PACKAGE_NAME.activity.QQLSUnlockActivity").hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onCreate"
|
||||||
|
param(BundleClass)
|
||||||
|
}
|
||||||
|
var origDevice = ""
|
||||||
|
beforeHook {
|
||||||
|
/** 由于在 onCreate 里有一行判断只要型号是 xiaomi 的设备就开电源锁,所以说这里临时替换成菊花厂 */
|
||||||
|
origDevice = Build.MANUFACTURER
|
||||||
|
if (Build.MANUFACTURER.lowercase() == "xiaomi")
|
||||||
|
BuildClass.field { name = "MANUFACTURER" }.get().set("HUAWEI")
|
||||||
|
}
|
||||||
|
afterHook {
|
||||||
|
instance<Activity>().finish()
|
||||||
|
/** 这里再把型号替换回去 - 不影响应用变量等 Xposed 模块修改的型号 */
|
||||||
|
BuildClass.field { name = "MANUFACTURER" }.get().set(origDevice)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 这个东西同上
|
||||||
|
* 反正也是一个一像素保活的 [Activity]
|
||||||
|
* 讯哥的程序员真的有你的
|
||||||
|
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口
|
||||||
|
*/
|
||||||
|
findClass("$QQ_PACKAGE_NAME.activity.QQLSActivity\$14", "ktq").hook {
|
||||||
|
injectMember {
|
||||||
|
method { name = "run" }
|
||||||
|
intercept()
|
||||||
|
}.ignoredAllFailure()
|
||||||
|
}.ignoredHookClassNotFoundFailure()
|
||||||
|
/**
|
||||||
|
* 这个是毒瘤核心类
|
||||||
|
* WakeLockMonitor
|
||||||
|
* 这个名字真的起的特别诗情画意
|
||||||
|
* 带给用户的却是 shit 一样的体验
|
||||||
|
* 里面有各种使用 Handler 和 Timer 的各种耗时常驻后台耗电办法持续接收消息
|
||||||
|
* 直接循环全部方法全部干掉
|
||||||
|
* 👮🏻 经过排查 Play 版本没这个类...... Emmmm 不想说啥了
|
||||||
|
*/
|
||||||
|
findClass(name = "com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor").hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onHook"
|
||||||
|
param(StringType, AnyType, AnyArrayClass, AnyType)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "doReport"
|
||||||
|
param(("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor\$WakeLockEntity").clazz, IntType)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "afterHookedMethod"
|
||||||
|
param(("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam").clazz)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "beforeHookedMethod"
|
||||||
|
param(("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam").clazz)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "onAppBackground" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onOtherProcReport"
|
||||||
|
param(BundleClass)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "onProcessRun30Min" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "onProcessBG5Min" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "writeReport"
|
||||||
|
param(BooleanType)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
}.ignoredHookClassNotFoundFailure()
|
||||||
|
/**
|
||||||
|
* 这个是毒瘤核心操作类
|
||||||
|
* 功能同上、全部拦截
|
||||||
|
*/
|
||||||
|
findClass(name = "com.tencent.qapmsdk.qqbattery.QQBatteryMonitor").hook {
|
||||||
|
injectMember {
|
||||||
|
method { name = "start" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "stop" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "handleMessage"
|
||||||
|
param(MessageClass)
|
||||||
|
}
|
||||||
|
replaceToTrue()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "startMonitorInner" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "onAppBackground" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "onAppForeground" }
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "setLogWhite"
|
||||||
|
paramCount = 2
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "setCmdWhite"
|
||||||
|
paramCount = 2
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onWriteLog"
|
||||||
|
param(StringType, StringType)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onCmdRequest"
|
||||||
|
param(StringType)
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "addData"
|
||||||
|
paramCount = 4
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onGpsScan"
|
||||||
|
paramCount = 2
|
||||||
|
}
|
||||||
|
intercept()
|
||||||
|
}
|
||||||
|
}.ignoredHookClassNotFoundFailure()
|
||||||
|
}
|
||||||
|
loadApp(TIM_PACKAGE_NAME) {
|
||||||
|
hookSystemWakeLock()
|
||||||
|
hookNotification()
|
||||||
|
hookCoreService(isQQ = false)
|
||||||
|
hookModuleRunningInfo(isQQTIM = true)
|
||||||
|
hookQQSettingsSettingActivity(isQQ = false)
|
||||||
|
}
|
||||||
|
loadApp(WECHAT_PACKAGE_NAME) {
|
||||||
|
if (prefs.get(DataConst.DISABLE_WECHAT_HOOK)) return@loadApp
|
||||||
|
hookSystemWakeLock()
|
||||||
|
hookModuleRunningInfo(isQQTIM = false)
|
||||||
|
loggerD(msg = "ウイチャット:それが機能するかどうかはわかりませんでした")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,555 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by fankes on 2021/9/4.
|
|
||||||
*/
|
|
||||||
@file:Suppress("DEPRECATION", "SameParameterValue")
|
|
||||||
|
|
||||||
package com.fankes.tsbattery.hook
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.app.Service
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.annotation.Keep
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium.QQ_PACKAGE_NAME
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium.SELF_PACKAGE_NAME
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium.TIM_PACKAGE_NAME
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium.WECHAT_PACKAGE_NAME
|
|
||||||
import com.fankes.tsbattery.utils.XPrefUtils
|
|
||||||
import com.fankes.tsbattery.utils.showDialog
|
|
||||||
import com.fankes.tsbattery.utils.versionCode
|
|
||||||
import com.fankes.tsbattery.utils.versionName
|
|
||||||
import de.robv.android.xposed.*
|
|
||||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@Keep
|
|
||||||
class HookMain : IXposedHookLoadPackage {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
/** 旧版类名 */
|
|
||||||
private const val BASE_CHAT_PIE_LEGACY = "activity.BaseChatPie"
|
|
||||||
|
|
||||||
/** 新版类名 */
|
|
||||||
private const val BASE_CHAT_PIE = "activity.aio.core.BaseChatPie"
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 仅作用于替换的 Hook 方法体 */
|
|
||||||
private val replaceToNull = object : XC_MethodReplacement() {
|
|
||||||
override fun replaceHookedMethod(param: MethodHookParam?): Any? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 仅作用于替换的 Hook 方法体 */
|
|
||||||
private val replaceToTrue = object : XC_MethodReplacement() {
|
|
||||||
override fun replaceHookedMethod(param: MethodHookParam?): Any {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 干掉目标方法体封装
|
|
||||||
* @param clazz 类名缩写
|
|
||||||
* @param name 方法名
|
|
||||||
*/
|
|
||||||
private fun XC_LoadPackage.LoadPackageParam.replaceToNull(clazz: String, name: String) {
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.$clazz",
|
|
||||||
classLoader,
|
|
||||||
name,
|
|
||||||
replaceToNull
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 忽略异常运行
|
|
||||||
* @param it 正常回调
|
|
||||||
*/
|
|
||||||
private fun runWithoutError(error: String, it: () -> Unit) {
|
|
||||||
try {
|
|
||||||
it()
|
|
||||||
} catch (e: Error) {
|
|
||||||
logE("hookFailed: $error", e)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
logE("hookFailed: $error", e)
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
logE("hookFailed: $error", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 这个类 QQ 的 BaseChatPie 是控制聊天界面的
|
|
||||||
* 里面有两个随机混淆的方法 ⬇️
|
|
||||||
* remainScreenOn、cancelRemainScreenOn
|
|
||||||
* 这两个方法一个是挂起电源锁常驻亮屏
|
|
||||||
* 一个是停止常驻亮屏
|
|
||||||
* 不由分说每个版本混淆的方法名都会变
|
|
||||||
* 所以说每个版本重新适配 - 也可以提交分支帮我适配
|
|
||||||
* ⚠️ Hook 错了方法会造成闪退!
|
|
||||||
* @param version QQ 版本
|
|
||||||
*/
|
|
||||||
private fun XC_LoadPackage.LoadPackageParam.hookQQBaseChatPie(version: String) {
|
|
||||||
when (version) {
|
|
||||||
"8.2.11" -> {
|
|
||||||
replaceToNull(BASE_CHAT_PIE_LEGACY, "bE")
|
|
||||||
replaceToNull(BASE_CHAT_PIE_LEGACY, "aV")
|
|
||||||
}
|
|
||||||
"8.8.17" -> {
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bd")
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "be")
|
|
||||||
}
|
|
||||||
"8.8.23" -> {
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bf")
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bg")
|
|
||||||
}
|
|
||||||
/** 8.8.35 贡献者:StarWishsama */
|
|
||||||
"8.8.35", "8.8.38" -> {
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bi")
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bj")
|
|
||||||
}
|
|
||||||
/** 贡献者:JiZhi-Error */
|
|
||||||
"8.8.50" -> {
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bj")
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bk")
|
|
||||||
}
|
|
||||||
"8.8.55", "8.8.68" -> {
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bk")
|
|
||||||
replaceToNull(BASE_CHAT_PIE, "bl")
|
|
||||||
}
|
|
||||||
else -> logD("$version not supported!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print the log
|
|
||||||
* @param content
|
|
||||||
*/
|
|
||||||
private fun logD(content: String) {
|
|
||||||
XposedBridge.log("[TSBattery][D]>$content")
|
|
||||||
Log.d("TSBattery", content)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print the log
|
|
||||||
* @param content
|
|
||||||
*/
|
|
||||||
private fun logE(content: String, e: Throwable? = null) {
|
|
||||||
XposedBridge.log("[TSBattery][E]>$content")
|
|
||||||
XposedBridge.log(e)
|
|
||||||
Log.e("TSBattery", content, e)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Hook 系统电源锁 */
|
|
||||||
private fun XC_LoadPackage.LoadPackageParam.hookSystemWakeLock() {
|
|
||||||
runWithoutError("wakeLock acquire()") {
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"android.os.PowerManager\$WakeLock",
|
|
||||||
classLoader,
|
|
||||||
"acquire",
|
|
||||||
replaceToNull
|
|
||||||
)
|
|
||||||
}
|
|
||||||
runWithoutError("hook wakeLock acquire(time)") {
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"android.os.PowerManager\$WakeLock",
|
|
||||||
classLoader,
|
|
||||||
"acquire",
|
|
||||||
Long::class.java,
|
|
||||||
replaceToNull
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 增加通知栏文本显示守护状态 */
|
|
||||||
private fun XC_LoadPackage.LoadPackageParam.hookNotification() =
|
|
||||||
runWithoutError("Notification") {
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"android.app.Notification\$Builder",
|
|
||||||
classLoader,
|
|
||||||
"setContentText",
|
|
||||||
CharSequence::class.java,
|
|
||||||
object : XC_MethodHook() {
|
|
||||||
override fun beforeHookedMethod(param: MethodHookParam?) {
|
|
||||||
when (param?.args?.get(0) as? CharSequence?) {
|
|
||||||
"QQ正在后台运行" ->
|
|
||||||
param.args?.set(0, "QQ正在后台运行 - TSBattery 守护中")
|
|
||||||
"TIM正在后台运行" ->
|
|
||||||
param.args?.set(0, "TIM正在后台运行 - TSBattery 守护中")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 提示模块运行信息 QQ、TIM、微信 */
|
|
||||||
private fun XC_LoadPackage.LoadPackageParam.hookModuleRunningInfo() =
|
|
||||||
if (packageName != WECHAT_PACKAGE_NAME)
|
|
||||||
runWithoutError("SplashActivity") {
|
|
||||||
/** 判断是否开启提示模块运行信息 */
|
|
||||||
if (XPrefUtils.getBoolean(HookMedium.ENABLE_RUN_INFO))
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.activity.SplashActivity",
|
|
||||||
classLoader,
|
|
||||||
"doOnCreate",
|
|
||||||
Bundle::class.java,
|
|
||||||
object : XC_MethodHook() {
|
|
||||||
|
|
||||||
override fun afterHookedMethod(param: MethodHookParam?) {
|
|
||||||
/**
|
|
||||||
* Hook 启动界面的第一个 [Activity]
|
|
||||||
* QQ 和 TIM 都是一样的类
|
|
||||||
* 在里面加入提示运行信息的对话框测试模块是否激活
|
|
||||||
*/
|
|
||||||
(param?.thisObject as? Activity?)?.apply {
|
|
||||||
showDialog {
|
|
||||||
title = "TSBattery 已激活"
|
|
||||||
msg = "[提示模块运行信息功能已打开]\n\n" +
|
|
||||||
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
|
|
||||||
"已生效模块版本:${XPrefUtils.getString(HookMedium.ENABLE_MODULE_VERSION)}\n" +
|
|
||||||
"当前模式:${if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
|
||||||
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
|
||||||
"\n\n模块只对挂后台锁屏情况下有省电效果,请不要将过多的群提醒,消息通知打开,这样子在使用过程时照样会极其耗电。\n\n" +
|
|
||||||
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
|
|
||||||
"持续常驻使用 QQ 依然会耗电,任何软件都是如此,模块无法帮你做到前台不耗电,永远记住这一点。\n\n" +
|
|
||||||
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
|
|
||||||
confirmButton(text = "我知道了")
|
|
||||||
noCancelable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else
|
|
||||||
runWithoutError("LauncherUI") {
|
|
||||||
/** 判断是否开启提示模块运行信息 */
|
|
||||||
if (XPrefUtils.getBoolean(HookMedium.ENABLE_RUN_INFO))
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$WECHAT_PACKAGE_NAME.ui.LauncherUI",
|
|
||||||
classLoader,
|
|
||||||
"onCreate",
|
|
||||||
Bundle::class.java,
|
|
||||||
object : XC_MethodHook() {
|
|
||||||
|
|
||||||
override fun afterHookedMethod(param: MethodHookParam?) {
|
|
||||||
/**
|
|
||||||
* Hook 启动界面的第一个 [Activity]
|
|
||||||
* 在里面加入提示运行信息的对话框测试模块是否激活
|
|
||||||
*/
|
|
||||||
(param?.thisObject as? Activity?)?.apply {
|
|
||||||
showDialog(isUseBlackTheme = true) {
|
|
||||||
title = "TSBattery 已激活"
|
|
||||||
msg = "[提示模块运行信息功能已打开]\n\n" +
|
|
||||||
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
|
|
||||||
"已生效模块版本:${XPrefUtils.getString(HookMedium.ENABLE_MODULE_VERSION)}\n" +
|
|
||||||
"当前模式:基础省电" +
|
|
||||||
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
|
||||||
"\n\n当前只支持微信的基础省电,即系统电源锁,后续会继续适配微信相关的省电功能(在新建文件夹了)。\n\n" +
|
|
||||||
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
|
|
||||||
"持续常驻使用微信依然会耗电,任何软件都是如此,模块无法帮你做到前台不耗电,永远记住这一点。\n\n" +
|
|
||||||
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
|
|
||||||
confirmButton(text = "我知道了")
|
|
||||||
noCancelable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Hook CoreService QQ、TIM */
|
|
||||||
private fun XC_LoadPackage.LoadPackageParam.hookCoreService() {
|
|
||||||
/** Hook CoreService 指定方法 */
|
|
||||||
if (packageName == QQ_PACKAGE_NAME)
|
|
||||||
runWithoutError("CoreServiceKnownMethods") {
|
|
||||||
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN)) {
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.app.CoreService",
|
|
||||||
classLoader, "startTempService", replaceToNull
|
|
||||||
)
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.app.CoreService",
|
|
||||||
classLoader, "startCoreService", Boolean::class.java, replaceToNull
|
|
||||||
)
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.app.CoreService",
|
|
||||||
classLoader,
|
|
||||||
"onStartCommand",
|
|
||||||
Intent::class.java, Int::class.java, Int::class.java,
|
|
||||||
object : XC_MethodReplacement() {
|
|
||||||
|
|
||||||
override fun replaceHookedMethod(param: MethodHookParam?) = 2
|
|
||||||
})
|
|
||||||
logD("hook CoreService OK!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** Hook CoreService 启动方法 */
|
|
||||||
runWithoutError("CoreService") {
|
|
||||||
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN)) {
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.app.CoreService",
|
|
||||||
classLoader, "onCreate",
|
|
||||||
object : XC_MethodHook() {
|
|
||||||
|
|
||||||
override fun afterHookedMethod(param: MethodHookParam?) {
|
|
||||||
(param?.thisObject as? Service)?.apply {
|
|
||||||
runWithoutError("StopCoreService") {
|
|
||||||
stopForeground(true)
|
|
||||||
stopService(Intent(applicationContext, javaClass))
|
|
||||||
logD("Shutdown CoreService OK!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
logD("hook CoreService [onCreate] OK!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** Hook CoreService$KernelService 启动方法 */
|
|
||||||
runWithoutError("CoreService\$KernelService") {
|
|
||||||
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_CHILD_BAN)) {
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.app.CoreService\$KernelService",
|
|
||||||
classLoader, "onCreate",
|
|
||||||
object : XC_MethodHook() {
|
|
||||||
|
|
||||||
override fun afterHookedMethod(param: MethodHookParam?) {
|
|
||||||
(param?.thisObject as? Service)?.apply {
|
|
||||||
runWithoutError("StopKernelService") {
|
|
||||||
stopForeground(true)
|
|
||||||
stopService(Intent(applicationContext, javaClass))
|
|
||||||
logD("Shutdown CoreService\$KernelService OK!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.app.CoreService\$KernelService",
|
|
||||||
classLoader,
|
|
||||||
"onStartCommand",
|
|
||||||
Intent::class.java, Int::class.java, Int::class.java,
|
|
||||||
object : XC_MethodReplacement() {
|
|
||||||
|
|
||||||
override fun replaceHookedMethod(param: MethodHookParam?) = 2
|
|
||||||
})
|
|
||||||
logD("hook CoreService\$KernelService [onCreate] OK!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
|
||||||
if (lpparam == null) return
|
|
||||||
when (lpparam.packageName) {
|
|
||||||
/** Hook 自身 */
|
|
||||||
SELF_PACKAGE_NAME ->
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$SELF_PACKAGE_NAME.hook.HookMedium",
|
|
||||||
lpparam.classLoader,
|
|
||||||
"isHooked",
|
|
||||||
replaceToTrue
|
|
||||||
)
|
|
||||||
/** Hook TIM */
|
|
||||||
TIM_PACKAGE_NAME ->
|
|
||||||
lpparam.apply {
|
|
||||||
hookSystemWakeLock()
|
|
||||||
hookNotification()
|
|
||||||
hookModuleRunningInfo()
|
|
||||||
hookCoreService()
|
|
||||||
logD("hook Completed!")
|
|
||||||
}
|
|
||||||
/** Hook QQ */
|
|
||||||
QQ_PACKAGE_NAME -> {
|
|
||||||
lpparam.apply {
|
|
||||||
hookSystemWakeLock()
|
|
||||||
hookNotification()
|
|
||||||
hookModuleRunningInfo()
|
|
||||||
hookCoreService()
|
|
||||||
}
|
|
||||||
/** 关闭保守模式后不再仅仅作用于系统电源锁 */
|
|
||||||
if (!XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)) {
|
|
||||||
runWithoutError("BaseChatPie(first time)") {
|
|
||||||
/** 通过在 SplashActivity 里取到应用的版本号 */
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.activity.SplashActivity",
|
|
||||||
lpparam.classLoader,
|
|
||||||
"doOnCreate",
|
|
||||||
Bundle::class.java,
|
|
||||||
object : XC_MethodHook() {
|
|
||||||
|
|
||||||
override fun beforeHookedMethod(param: MethodHookParam?) {
|
|
||||||
val self = param?.thisObject as? Activity ?: return
|
|
||||||
val version = self.versionName
|
|
||||||
runWithoutError("BaseChatPie") { lpparam.hookQQBaseChatPie(version) }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
runWithoutError("WakerLock") {
|
|
||||||
/**
|
|
||||||
* 一个不知道是什么作用的电源锁
|
|
||||||
* 同样直接干掉
|
|
||||||
*/
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"com.tencent.mars.ilink.comm.WakerLock",
|
|
||||||
lpparam.classLoader,
|
|
||||||
"lock", Long::class.java,
|
|
||||||
replaceToNull
|
|
||||||
)
|
|
||||||
}
|
|
||||||
runWithoutError("QQLSActivity") {
|
|
||||||
/**
|
|
||||||
* Hook 掉一个一像素保活 [Activity] 真的我怎么都想不到讯哥的程序员做出这种事情
|
|
||||||
* 这个东西经过测试会在锁屏的时候吊起来,解锁的时候自动 finish(),无限耍流氓耗电
|
|
||||||
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口的解锁后拉起保活界面,也是毒瘤
|
|
||||||
*/
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.activity.QQLSUnlockActivity",
|
|
||||||
lpparam.classLoader,
|
|
||||||
"onCreate", Bundle::class.java,
|
|
||||||
object : XC_MethodHook() {
|
|
||||||
|
|
||||||
private var origDevice = ""
|
|
||||||
|
|
||||||
override fun beforeHookedMethod(param: MethodHookParam?) {
|
|
||||||
/** 由于在 onCreate 里有一行判断只要型号是 xiaomi 的设备就开电源锁,所以说这里临时替换成菊花厂 */
|
|
||||||
origDevice = Build.MANUFACTURER
|
|
||||||
if (Build.MANUFACTURER.toLowerCase(Locale.ROOT) == "xiaomi")
|
|
||||||
XposedHelpers.setStaticObjectField(
|
|
||||||
Build::class.java,
|
|
||||||
"MANUFACTURER",
|
|
||||||
"HUAWEI"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun afterHookedMethod(param: MethodHookParam?) {
|
|
||||||
(param?.thisObject as? Activity)?.finish()
|
|
||||||
/** 这里再把型号替换回去 - 不影响应用变量等 Xposed 模块修改的型号 */
|
|
||||||
XposedHelpers.setStaticObjectField(
|
|
||||||
Build::class.java,
|
|
||||||
"MANUFACTURER",
|
|
||||||
origDevice
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
/**
|
|
||||||
* 这个东西同上
|
|
||||||
* 反正也是一个一像素保活的 [Activity]
|
|
||||||
* 讯哥的程序员真的有你的
|
|
||||||
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口
|
|
||||||
*/
|
|
||||||
XposedHelpers.findAndHookMethod(
|
|
||||||
"$QQ_PACKAGE_NAME.activity.QQLSActivity\$14",
|
|
||||||
lpparam.classLoader,
|
|
||||||
"run",
|
|
||||||
replaceToNull
|
|
||||||
)
|
|
||||||
}
|
|
||||||
runWithoutError("WakerLockMonitor") {
|
|
||||||
/**
|
|
||||||
* 这个是毒瘤核心类
|
|
||||||
* WakeLockMonitor
|
|
||||||
* 这个名字真的起的特别诗情画意
|
|
||||||
* 带给用户的却是 shit 一样的体验
|
|
||||||
* 里面有各种使用 Handler 和 Timer 的各种耗时常驻后台耗电办法持续接收消息
|
|
||||||
* 直接循环全部方法全部干掉
|
|
||||||
* 👮🏻 经过排查 Play 版本没这个类...... Emmmm 不想说啥了
|
|
||||||
*/
|
|
||||||
lpparam.classLoader.loadClass("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor")
|
|
||||||
.apply {
|
|
||||||
val lockClazz =
|
|
||||||
lpparam.classLoader.loadClass("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor\$WakeLockEntity")
|
|
||||||
val hookClazz =
|
|
||||||
lpparam.classLoader.loadClass("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam")
|
|
||||||
val onHook = getDeclaredMethod(
|
|
||||||
"onHook",
|
|
||||||
String::class.java,
|
|
||||||
Any::class.java,
|
|
||||||
java.lang.reflect.Array.newInstance(
|
|
||||||
Any::class.java,
|
|
||||||
0
|
|
||||||
).javaClass,
|
|
||||||
Any::class.java
|
|
||||||
).apply { isAccessible = true }
|
|
||||||
val doReport =
|
|
||||||
getDeclaredMethod(
|
|
||||||
"doReport",
|
|
||||||
lockClazz,
|
|
||||||
Int::class.java
|
|
||||||
).apply {
|
|
||||||
isAccessible = true
|
|
||||||
}
|
|
||||||
val afterHookedMethod =
|
|
||||||
getDeclaredMethod(
|
|
||||||
"afterHookedMethod",
|
|
||||||
hookClazz
|
|
||||||
).apply { isAccessible = true }
|
|
||||||
val beforeHookedMethod =
|
|
||||||
getDeclaredMethod("beforeHookedMethod", hookClazz).apply {
|
|
||||||
isAccessible = true
|
|
||||||
}
|
|
||||||
val onAppBackground =
|
|
||||||
getDeclaredMethod("onAppBackground").apply {
|
|
||||||
isAccessible = true
|
|
||||||
}
|
|
||||||
val onOtherProcReport =
|
|
||||||
getDeclaredMethod(
|
|
||||||
"onOtherProcReport",
|
|
||||||
Bundle::class.java
|
|
||||||
).apply { isAccessible = true }
|
|
||||||
val onProcessRun30Min =
|
|
||||||
getDeclaredMethod("onProcessRun30Min").apply {
|
|
||||||
isAccessible = true
|
|
||||||
}
|
|
||||||
val onProcessBG5Min =
|
|
||||||
getDeclaredMethod("onProcessBG5Min").apply {
|
|
||||||
isAccessible = true
|
|
||||||
}
|
|
||||||
val writeReport =
|
|
||||||
getDeclaredMethod(
|
|
||||||
"writeReport",
|
|
||||||
Boolean::class.java
|
|
||||||
).apply { isAccessible = true }
|
|
||||||
XposedBridge.hookMethod(onHook, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(doReport, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(afterHookedMethod, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(beforeHookedMethod, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(onAppBackground, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(onOtherProcReport, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(onProcessRun30Min, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(onProcessBG5Min, replaceToNull)
|
|
||||||
XposedBridge.hookMethod(writeReport, replaceToNull)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logD("hook Completed!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 微信 */
|
|
||||||
WECHAT_PACKAGE_NAME -> {
|
|
||||||
/** 判断是否关闭 Hook */
|
|
||||||
if (XPrefUtils.getBoolean(HookMedium.DISABLE_WECHAT_HOOK)) return
|
|
||||||
lpparam.apply {
|
|
||||||
hookSystemWakeLock()
|
|
||||||
hookModuleRunningInfo()
|
|
||||||
}
|
|
||||||
// TODO 新建文件夹
|
|
||||||
logD("ウイチャット:それが機能するかどうかはわかりませんでした")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by fankes on 2021/11/9.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.fankes.tsbattery.hook
|
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.annotation.Keep
|
|
||||||
import com.fankes.tsbattery.ui.MainActivity
|
|
||||||
|
|
||||||
@Keep
|
|
||||||
object HookMedium {
|
|
||||||
|
|
||||||
const val ENABLE_HIDE_ICON = "_hide_icon"
|
|
||||||
const val ENABLE_RUN_INFO = "_tip_run_info"
|
|
||||||
const val ENABLE_QQTIM_WHITE_MODE = "_qqtim_white_mode"
|
|
||||||
const val ENABLE_QQTIM_CORESERVICE_BAN = "_qqtim_core_service_ban"
|
|
||||||
const val ENABLE_QQTIM_CORESERVICE_CHILD_BAN = "_qqtim_core_service_child_ban"
|
|
||||||
const val DISABLE_WECHAT_HOOK = "_disable_wechat_hook"
|
|
||||||
const val ENABLE_MODULE_VERSION = "_module_version"
|
|
||||||
|
|
||||||
const val SELF_PACKAGE_NAME = "com.fankes.tsbattery"
|
|
||||||
const val QQ_PACKAGE_NAME = "com.tencent.mobileqq"
|
|
||||||
const val TIM_PACKAGE_NAME = "com.tencent.tim"
|
|
||||||
const val WECHAT_PACKAGE_NAME = "com.tencent.mm"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断模块是否激活
|
|
||||||
* 在 [HookMain] 中 Hook 掉此方法
|
|
||||||
* @return [Boolean] 激活状态
|
|
||||||
*/
|
|
||||||
fun isHooked(): Boolean {
|
|
||||||
Log.d("TSBattery", "isHooked: true")
|
|
||||||
return isExpModuleActive()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 太极激活判断方式
|
|
||||||
* @return [Boolean] 是否激活
|
|
||||||
*/
|
|
||||||
private fun isExpModuleActive(): Boolean {
|
|
||||||
var isExp = false
|
|
||||||
MainActivity.instance?.also {
|
|
||||||
try {
|
|
||||||
val uri = Uri.parse("content://me.weishu.exposed.CP/")
|
|
||||||
var result: Bundle? = null
|
|
||||||
try {
|
|
||||||
result = it.contentResolver.call(uri, "active", null, null)
|
|
||||||
} catch (_: RuntimeException) {
|
|
||||||
// TaiChi is killed, try invoke
|
|
||||||
try {
|
|
||||||
val intent = Intent("me.weishu.exp.ACTION_ACTIVE")
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
it.startActivity(intent)
|
|
||||||
} catch (_: Throwable) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (result == null) result = it.contentResolver.call(uri, "active", null, null)
|
|
||||||
if (result == null) return false
|
|
||||||
isExp = result.getBoolean("active", false)
|
|
||||||
} catch (_: Throwable) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isExp
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,317 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by fankes on 2021/9/4.
|
|
||||||
*/
|
|
||||||
@file:Suppress(
|
|
||||||
"DEPRECATION", "SetTextI18n", "SetWorldReadable", "WorldReadableFiles",
|
|
||||||
"LocalVariableName", "SameParameterValue"
|
|
||||||
)
|
|
||||||
|
|
||||||
package com.fankes.tsbattery.ui
|
|
||||||
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.Handler
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
|
||||||
import androidx.constraintlayout.utils.widget.ImageFilterView
|
|
||||||
import androidx.core.view.isGone
|
|
||||||
import com.fankes.tsbattery.BuildConfig
|
|
||||||
import com.fankes.tsbattery.R
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium.QQ_PACKAGE_NAME
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium.TIM_PACKAGE_NAME
|
|
||||||
import com.fankes.tsbattery.hook.HookMedium.WECHAT_PACKAGE_NAME
|
|
||||||
import com.fankes.tsbattery.utils.FileUtils
|
|
||||||
import com.fankes.tsbattery.utils.isInstall
|
|
||||||
import com.fankes.tsbattery.utils.openSelfSetting
|
|
||||||
import com.fankes.tsbattery.utils.showDialog
|
|
||||||
import com.gyf.immersionbar.ImmersionBar
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
private const val moduleVersion = BuildConfig.VERSION_NAME
|
|
||||||
private const val qqSupportVersion =
|
|
||||||
"8.2.11(Play)、8.8.17、8.8.23、8.8.35、8.8.38、8.8.50、8.8.55、8.8.68 (8.2.11、8.5.5~8.8.68)"
|
|
||||||
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
|
||||||
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
|
||||||
|
|
||||||
/** 声明当前实例 */
|
|
||||||
var instance: MainActivity? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
/** 设置自身实例 */
|
|
||||||
instance = this
|
|
||||||
setContentView(R.layout.activity_main)
|
|
||||||
/** 隐藏系统的标题栏 */
|
|
||||||
supportActionBar?.hide()
|
|
||||||
/** 初始化沉浸状态栏 */
|
|
||||||
ImmersionBar.with(this)
|
|
||||||
.statusBarColor(R.color.white)
|
|
||||||
.autoDarkModeEnable(false)
|
|
||||||
.statusBarDarkFont(true)
|
|
||||||
.navigationBarColor(R.color.white)
|
|
||||||
.navigationBarDarkIcon(true)
|
|
||||||
.fitsSystemWindows(true)
|
|
||||||
.init()
|
|
||||||
/** 判断 Hook 状态 */
|
|
||||||
if (isHooked()) {
|
|
||||||
findViewById<LinearLayout>(R.id.main_lin_status).setBackgroundResource(R.drawable.green_round)
|
|
||||||
findViewById<ImageFilterView>(R.id.main_img_status).setImageResource(R.mipmap.succcess)
|
|
||||||
findViewById<TextView>(R.id.main_text_status).text = "模块已激活"
|
|
||||||
/** 写入激活的模块版本 */
|
|
||||||
putString(HookMedium.ENABLE_MODULE_VERSION, moduleVersion)
|
|
||||||
} else
|
|
||||||
showDialog {
|
|
||||||
title = "模块没有激活"
|
|
||||||
msg = "检测到模块没有激活,模块需要 Xposed 环境依赖," +
|
|
||||||
"同时需要系统拥有 Root 权限(太极阴可以免 Root)," +
|
|
||||||
"请自行查看本页面使用帮助与说明第三条。\n" +
|
|
||||||
"太极、应用转生、梦境(Pine)和第三方 Xposed 激活后" +
|
|
||||||
"可能不会提示激活,若想验证是否激活请打开“提示模块运行信息”自行检查," +
|
|
||||||
"如果生效就代表模块运行正常,这里的激活状态只是一个显示意义上的存在。\n" +
|
|
||||||
"太极(无极)在 MIUI 设备上会提示打开授权,请进行允许,然后再次打开本应用查看激活状态。"
|
|
||||||
confirmButton(text = "我知道了")
|
|
||||||
noCancelable()
|
|
||||||
}
|
|
||||||
/** 设置安装状态 */
|
|
||||||
findViewById<View>(R.id.main_text_qq_noinstall).isGone = QQ_PACKAGE_NAME.isInstall
|
|
||||||
findViewById<View>(R.id.main_text_tim_noinstall).isGone = TIM_PACKAGE_NAME.isInstall
|
|
||||||
findViewById<View>(R.id.main_text_wechat_noinstall).isGone = WECHAT_PACKAGE_NAME.isInstall
|
|
||||||
/** 设置文本 */
|
|
||||||
findViewById<TextView>(R.id.main_text_version).text = "当前版本:$moduleVersion"
|
|
||||||
findViewById<TextView>(R.id.main_text_support_qq).apply {
|
|
||||||
text = qqSupportVersion
|
|
||||||
setOnClickListener {
|
|
||||||
showDialog {
|
|
||||||
title = "兼容的 QQ 版本"
|
|
||||||
msg = qqSupportVersion
|
|
||||||
confirmButton(text = "我知道了")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
findViewById<TextView>(R.id.main_text_support_tim).apply {
|
|
||||||
text = timSupportVersion
|
|
||||||
setOnClickListener {
|
|
||||||
showDialog {
|
|
||||||
title = "兼容的 TIM 版本"
|
|
||||||
msg = timSupportVersion
|
|
||||||
confirmButton(text = "我知道了")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
findViewById<TextView>(R.id.main_text_support_wechat).apply {
|
|
||||||
text = wechatSupportVersion
|
|
||||||
setOnClickListener {
|
|
||||||
showDialog {
|
|
||||||
title = "兼容的微信版本"
|
|
||||||
msg = wechatSupportVersion
|
|
||||||
confirmButton(text = "我知道了")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 初始化 View */
|
|
||||||
val qqTimProtectModeSwitch = findViewById<SwitchCompat>(R.id.qqtim_protect_mode_switch)
|
|
||||||
val qqTimCoreServiceSwitch = findViewById<SwitchCompat>(R.id.shut_core_sv_qqtim_switch)
|
|
||||||
val qqTimCoreServiceKnSwitch = findViewById<SwitchCompat>(R.id.shut_core_sv_kn_qqtim_switch)
|
|
||||||
val wechatDisableHookSwitch = findViewById<SwitchCompat>(R.id.disable_wechat_sv_switch)
|
|
||||||
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
|
||||||
val notifyModuleInfoSwitch = findViewById<SwitchCompat>(R.id.notify_module_info_switch)
|
|
||||||
/** 获取 Sp 存储的信息 */
|
|
||||||
qqTimProtectModeSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)
|
|
||||||
qqTimCoreServiceSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN)
|
|
||||||
qqTimCoreServiceKnSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_CHILD_BAN)
|
|
||||||
wechatDisableHookSwitch.isChecked = getBoolean(HookMedium.DISABLE_WECHAT_HOOK)
|
|
||||||
hideIconInLauncherSwitch.isChecked = getBoolean(HookMedium.ENABLE_HIDE_ICON)
|
|
||||||
notifyModuleInfoSwitch.isChecked = getBoolean(HookMedium.ENABLE_RUN_INFO)
|
|
||||||
qqTimProtectModeSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
|
||||||
putBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE, b)
|
|
||||||
}
|
|
||||||
qqTimCoreServiceSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
|
||||||
putBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN, b)
|
|
||||||
}
|
|
||||||
qqTimCoreServiceKnSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
|
||||||
putBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_CHILD_BAN, b)
|
|
||||||
}
|
|
||||||
wechatDisableHookSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
|
||||||
putBoolean(HookMedium.DISABLE_WECHAT_HOOK, b)
|
|
||||||
}
|
|
||||||
hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
|
||||||
putBoolean(HookMedium.ENABLE_HIDE_ICON, b)
|
|
||||||
packageManager.setComponentEnabledSetting(
|
|
||||||
ComponentName(this@MainActivity, "com.fankes.tsbattery.Home"),
|
|
||||||
if (b) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
|
||||||
PackageManager.DONT_KILL_APP
|
|
||||||
)
|
|
||||||
}
|
|
||||||
notifyModuleInfoSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
|
||||||
putBoolean(HookMedium.ENABLE_RUN_INFO, b)
|
|
||||||
}
|
|
||||||
/** 快捷操作 QQ */
|
|
||||||
findViewById<View>(R.id.quick_qq_button).setOnClickListener { openSelfSetting(QQ_PACKAGE_NAME) }
|
|
||||||
/** 快捷操作 TIM */
|
|
||||||
findViewById<View>(R.id.quick_tim_button).setOnClickListener { openSelfSetting(TIM_PACKAGE_NAME) }
|
|
||||||
/** 快捷操作微信 */
|
|
||||||
findViewById<View>(R.id.quick_wechat_button).setOnClickListener { openSelfSetting(WECHAT_PACKAGE_NAME) }
|
|
||||||
/** 恰饭! */
|
|
||||||
findViewById<View>(R.id.link_with_follow_me).setOnClickListener {
|
|
||||||
try {
|
|
||||||
startActivity(Intent().apply {
|
|
||||||
setPackage("com.coolapk.market")
|
|
||||||
action = "android.intent.action.VIEW"
|
|
||||||
data = Uri.parse("https://www.coolapk.com/u/876977")
|
|
||||||
/** 防止顶栈一样重叠在自己的 APP 中 */
|
|
||||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
})
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Toast.makeText(this, "你可能没有安装酷安", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 项目地址点击事件 */
|
|
||||||
findViewById<View>(R.id.link_with_project_address).setOnClickListener {
|
|
||||||
try {
|
|
||||||
startActivity(Intent().apply {
|
|
||||||
action = "android.intent.action.VIEW"
|
|
||||||
data = Uri.parse("https://github.com/fankes/TSBattery")
|
|
||||||
/** 防止顶栈一样重叠在自己的 APP 中 */
|
|
||||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
})
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Toast.makeText(this, "无法启动系统默认浏览器", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断模块是否激活
|
|
||||||
* @return [Boolean] 激活状态
|
|
||||||
*/
|
|
||||||
private fun isHooked() = HookMedium.isHooked()
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
setWorldReadable()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onRestart() {
|
|
||||||
super.onRestart()
|
|
||||||
setWorldReadable()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPause() {
|
|
||||||
super.onPause()
|
|
||||||
setWorldReadable()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取保存的值
|
|
||||||
* @param key 名称
|
|
||||||
* @return [Boolean] 保存的值
|
|
||||||
*/
|
|
||||||
private fun getBoolean(key: String) =
|
|
||||||
getSharedPreferences(
|
|
||||||
packageName + "_preferences",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
).getBoolean(key, false)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存值
|
|
||||||
* @param key 名称
|
|
||||||
* @param bool 值
|
|
||||||
*/
|
|
||||||
private fun putBoolean(key: String, bool: Boolean) {
|
|
||||||
getSharedPreferences(
|
|
||||||
packageName + "_preferences",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
).edit().putBoolean(key, bool).apply()
|
|
||||||
setWorldReadable()
|
|
||||||
/** 延迟继续设置强制允许 SP 可读可写 */
|
|
||||||
Handler().postDelayed({ setWorldReadable() }, 500)
|
|
||||||
Handler().postDelayed({ setWorldReadable() }, 1000)
|
|
||||||
Handler().postDelayed({ setWorldReadable() }, 1500)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存值
|
|
||||||
* @param key 名称
|
|
||||||
* @param value 值
|
|
||||||
*/
|
|
||||||
private fun putString(key: String, value: String) {
|
|
||||||
getSharedPreferences(
|
|
||||||
packageName + "_preferences",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
).edit().putString(key, value).apply()
|
|
||||||
setWorldReadable()
|
|
||||||
/** 延迟继续设置强制允许 SP 可读可写 */
|
|
||||||
Handler().postDelayed({ setWorldReadable() }, 500)
|
|
||||||
Handler().postDelayed({ setWorldReadable() }, 1000)
|
|
||||||
Handler().postDelayed({ setWorldReadable() }, 1500)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 强制设置 Sp 存储为全局可读可写
|
|
||||||
* 以供模块使用
|
|
||||||
*/
|
|
||||||
private fun setWorldReadable() {
|
|
||||||
try {
|
|
||||||
if (FileUtils.getDefaultPrefFile(this).exists()) {
|
|
||||||
for (file in arrayOf<File>(
|
|
||||||
FileUtils.getDataDir(this),
|
|
||||||
FileUtils.getPrefDir(this),
|
|
||||||
FileUtils.getDefaultPrefFile(this)
|
|
||||||
)) {
|
|
||||||
file.setReadable(true, false)
|
|
||||||
file.setExecutable(true, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (_: Exception) {
|
|
||||||
Toast.makeText(this, "无法写入模块设置,请检查权限\n如果此提示一直显示,请不要双开模块", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
|
||||||
setWorldReadable()
|
|
||||||
super.onBackPressed()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
super.onDestroy()
|
|
||||||
/** 销毁实例防止内存泄漏 */
|
|
||||||
instance = null
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2021/9/4.
|
||||||
|
*/
|
||||||
|
@file:Suppress("SetTextI18n", "LocalVariableName", "SameParameterValue")
|
||||||
|
|
||||||
|
package com.fankes.tsbattery.ui.activity
|
||||||
|
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.view.HapticFeedbackConstants
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.fankes.tsbattery.BuildConfig
|
||||||
|
import com.fankes.tsbattery.R
|
||||||
|
import com.fankes.tsbattery.data.DataConst
|
||||||
|
import com.fankes.tsbattery.databinding.ActivityMainBinding
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.QQ_PACKAGE_NAME
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.TIM_PACKAGE_NAME
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.WECHAT_PACKAGE_NAME
|
||||||
|
import com.fankes.tsbattery.ui.activity.base.BaseActivity
|
||||||
|
import com.fankes.tsbattery.utils.factory.*
|
||||||
|
import com.fankes.tsbattery.utils.tool.GithubReleaseTool
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.isModuleActive
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.isTaiChiModuleActive
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||||
|
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
||||||
|
|
||||||
|
class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
private const val moduleVersion = BuildConfig.VERSION_NAME
|
||||||
|
private const val qqSupportVersion =
|
||||||
|
"8.2.11(Play)、8.8.17、8.8.23、8.8.35、8.8.38、8.8.50、8.8.55、8.8.68、8.8.80、8.8.83、8.8.85 (8.2.11、8.5.5~8.8.85)"
|
||||||
|
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
||||||
|
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
||||||
|
|
||||||
|
/** 预发布的版本标识 */
|
||||||
|
private const val pendingFlag = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
/** 检查更新 */
|
||||||
|
GithubReleaseTool.checkingForUpdate(context = this, moduleVersion) { version, function ->
|
||||||
|
binding.mainTextReleaseVersion.apply {
|
||||||
|
text = "点击更新 $version"
|
||||||
|
isVisible = true
|
||||||
|
setOnClickListener { function() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 判断 Hook 状态 */
|
||||||
|
if (isModuleActive) {
|
||||||
|
binding.mainLinStatus.setBackgroundResource(R.drawable.bg_green_round)
|
||||||
|
binding.mainImgStatus.setImageResource(R.mipmap.ic_success)
|
||||||
|
binding.mainTextStatus.text = "模块已激活"
|
||||||
|
binding.mainTextApiWay.isVisible = true
|
||||||
|
refreshActivateExecutor()
|
||||||
|
/** 写入激活的模块版本 */
|
||||||
|
modulePrefs.put(DataConst.ENABLE_MODULE_VERSION, moduleVersion)
|
||||||
|
} else
|
||||||
|
showDialog {
|
||||||
|
title = "模块没有激活"
|
||||||
|
msg = "检测到模块没有激活,模块需要 Xposed 环境依赖," +
|
||||||
|
"同时需要系统拥有 Root 权限(太极阴可以免 Root)," +
|
||||||
|
"请自行查看本页面使用帮助与说明第三条。\n" +
|
||||||
|
"太极和第三方 Xposed 激活后" +
|
||||||
|
"可能不会提示激活,若想验证是否激活请打开“提示模块运行信息”自行检查," +
|
||||||
|
"或观察 QQ、TIM 的常驻通知是否有“TSBattery 守护中”字样”。\n\n" +
|
||||||
|
"如果生效就代表模块运行正常,若你在未 Root 情况下激活模块,这里的激活状态只是一个显示意义上的存在。\n" +
|
||||||
|
"太极(无极)在 MIUI 设备上会提示打开授权,请进行允许,然后再次打开本模块查看激活状态。"
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
noCancelable()
|
||||||
|
}
|
||||||
|
/** 推荐使用 LSPosed */
|
||||||
|
if (isTaiChiModuleActive)
|
||||||
|
showDialog {
|
||||||
|
title = "兼容性提示"
|
||||||
|
msg = "若你的设备已 Root,推荐使用 LSPosed 激活模块,太极可能会出现模块设置无法保存的问题。"
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
}
|
||||||
|
/** 检测应用转生 */
|
||||||
|
if (("com.bug.xposed").isInstall)
|
||||||
|
showDialog {
|
||||||
|
title = "环境异常"
|
||||||
|
msg = "检测到“应用转生”已被安装,为了保证模块的安全和稳定,请卸载更换其他 Hook 框架后才能继续使用。"
|
||||||
|
confirmButton(text = "退出") { finish() }
|
||||||
|
noCancelable()
|
||||||
|
}
|
||||||
|
/** 设置安装状态 */
|
||||||
|
binding.mainTextQqVer.text = if (QQ_PACKAGE_NAME.isInstall) version(QQ_PACKAGE_NAME) else "未安装"
|
||||||
|
binding.mainTextTimVer.text = if (TIM_PACKAGE_NAME.isInstall) version(TIM_PACKAGE_NAME) else "未安装"
|
||||||
|
binding.mainTextWechatVer.text = if (WECHAT_PACKAGE_NAME.isInstall) version(WECHAT_PACKAGE_NAME) else "未安装"
|
||||||
|
/** 设置文本 */
|
||||||
|
binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag"
|
||||||
|
binding.mainQqItem.setOnClickListener {
|
||||||
|
showDialog {
|
||||||
|
title = "兼容的 QQ 版本"
|
||||||
|
msg = qqSupportVersion
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
}
|
||||||
|
/** 振动提醒 */
|
||||||
|
it.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
|
||||||
|
}
|
||||||
|
binding.mainTimItem.setOnClickListener {
|
||||||
|
showDialog {
|
||||||
|
title = "兼容的 TIM 版本"
|
||||||
|
msg = timSupportVersion
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
}
|
||||||
|
/** 振动提醒 */
|
||||||
|
it.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
|
||||||
|
}
|
||||||
|
binding.mainWechatItem.setOnClickListener {
|
||||||
|
showDialog {
|
||||||
|
title = "兼容的微信版本"
|
||||||
|
msg = wechatSupportVersion
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
}
|
||||||
|
/** 振动提醒 */
|
||||||
|
it.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
|
||||||
|
}
|
||||||
|
/** 获取 Sp 存储的信息 */
|
||||||
|
binding.qqtimProtectModeSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)
|
||||||
|
binding.qqTimCoreServiceSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_QQTIM_CORESERVICE_BAN)
|
||||||
|
binding.qqTimCoreServiceKnSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_QQTIM_CORESERVICE_CHILD_BAN)
|
||||||
|
binding.wechatDisableHookSwitch.isChecked = modulePrefs.get(DataConst.DISABLE_WECHAT_HOOK)
|
||||||
|
binding.hideIconInLauncherSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_HIDE_ICON)
|
||||||
|
binding.notifyModuleInfoSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_RUN_INFO)
|
||||||
|
binding.notifyNotifyTipSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_TIP)
|
||||||
|
binding.settingModuleTipSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_SETTING_TIP)
|
||||||
|
binding.qqtimProtectModeSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.ENABLE_QQTIM_WHITE_MODE, b)
|
||||||
|
snake(msg = "修改需要重启 QQ 以生效")
|
||||||
|
}
|
||||||
|
binding.qqTimCoreServiceSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.ENABLE_QQTIM_CORESERVICE_BAN, b)
|
||||||
|
}
|
||||||
|
binding.qqTimCoreServiceKnSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.ENABLE_QQTIM_CORESERVICE_CHILD_BAN, b)
|
||||||
|
}
|
||||||
|
binding.wechatDisableHookSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.DISABLE_WECHAT_HOOK, b)
|
||||||
|
snake(msg = "修改需要重启微信以生效")
|
||||||
|
}
|
||||||
|
binding.hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.ENABLE_HIDE_ICON, b)
|
||||||
|
packageManager.setComponentEnabledSetting(
|
||||||
|
ComponentName(this@MainActivity, "com.fankes.tsbattery.Home"),
|
||||||
|
if (b) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||||
|
PackageManager.DONT_KILL_APP
|
||||||
|
)
|
||||||
|
}
|
||||||
|
binding.notifyModuleInfoSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.ENABLE_RUN_INFO, b)
|
||||||
|
}
|
||||||
|
binding.notifyNotifyTipSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.ENABLE_NOTIFY_TIP, b)
|
||||||
|
}
|
||||||
|
binding.settingModuleTipSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.put(DataConst.ENABLE_SETTING_TIP, b)
|
||||||
|
}
|
||||||
|
/** 快捷操作 QQ */
|
||||||
|
binding.quickQqButton.setOnClickListener { openSelfSetting(QQ_PACKAGE_NAME) }
|
||||||
|
/** 快捷操作 TIM */
|
||||||
|
binding.quickTimButton.setOnClickListener { openSelfSetting(TIM_PACKAGE_NAME) }
|
||||||
|
/** 快捷操作微信 */
|
||||||
|
binding.quickWechatButton.setOnClickListener { openSelfSetting(WECHAT_PACKAGE_NAME) }
|
||||||
|
/** 项目地址按钮点击事件 */
|
||||||
|
binding.titleGithubIcon.setOnClickListener { openBrowser(url = "https://github.com/fankes/TSBattery") }
|
||||||
|
/** 恰饭! */
|
||||||
|
binding.linkWithFollowMe.setOnClickListener {
|
||||||
|
openBrowser(url = "https://www.coolapk.com/u/876977", packageName = "com.coolapk.market")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 刷新模块激活使用的方式 */
|
||||||
|
private fun refreshActivateExecutor() {
|
||||||
|
when {
|
||||||
|
YukiHookModuleStatus.executorVersion > 0 ->
|
||||||
|
binding.mainTextApiWay.text =
|
||||||
|
"Activated by ${YukiHookModuleStatus.executorName} API ${YukiHookModuleStatus.executorVersion}"
|
||||||
|
isTaiChiModuleActive -> binding.mainTextApiWay.text = "Activated by TaiChi"
|
||||||
|
else -> binding.mainTextApiWay.text = "Activated by anonymous"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/1/30.
|
||||||
|
*/
|
||||||
|
@file:Suppress("UNCHECKED_CAST")
|
||||||
|
|
||||||
|
package com.fankes.tsbattery.ui.activity.base
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import com.fankes.tsbattery.R
|
||||||
|
import com.fankes.tsbattery.utils.factory.isNotSystemInDarkMode
|
||||||
|
import com.gyf.immersionbar.ktx.immersionBar
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
|
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
|
||||||
|
import java.lang.reflect.ParameterizedType
|
||||||
|
|
||||||
|
abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||||
|
|
||||||
|
/** 获取绑定布局对象 */
|
||||||
|
lateinit var binding: VB
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
javaClass.genericSuperclass.also { type ->
|
||||||
|
if (type is ParameterizedType) {
|
||||||
|
binding = (type.actualTypeArguments[0] as Class<VB>).method {
|
||||||
|
name = "inflate"
|
||||||
|
param(LayoutInflaterClass)
|
||||||
|
}.get().invoke<VB>(layoutInflater) ?: error("binding failed")
|
||||||
|
setContentView(binding.root)
|
||||||
|
} else error("binding but got wrong type")
|
||||||
|
}
|
||||||
|
/** 隐藏系统的标题栏 */
|
||||||
|
supportActionBar?.hide()
|
||||||
|
/** 初始化沉浸状态栏 */
|
||||||
|
immersionBar {
|
||||||
|
statusBarColor(R.color.colorThemeBackground)
|
||||||
|
autoDarkModeEnable(true)
|
||||||
|
statusBarDarkFont(isNotSystemInDarkMode)
|
||||||
|
navigationBarColor(R.color.colorThemeBackground)
|
||||||
|
navigationBarDarkIcon(isNotSystemInDarkMode)
|
||||||
|
fitsSystemWindows(true)
|
||||||
|
}
|
||||||
|
/** 装载子类 */
|
||||||
|
onCreate()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 回调 [onCreate] 方法 */
|
||||||
|
abstract fun onCreate()
|
||||||
|
}
|
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/1/8.
|
||||||
|
*/
|
||||||
|
@file:Suppress("SameParameterValue")
|
||||||
|
|
||||||
|
package com.fankes.tsbattery.ui.view
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import androidx.appcompat.widget.SwitchCompat
|
||||||
|
import com.fankes.tsbattery.utils.drawable.drawabletoolbox.DrawableBuilder
|
||||||
|
import com.fankes.tsbattery.utils.factory.dp
|
||||||
|
import com.fankes.tsbattery.utils.factory.isSystemInDarkMode
|
||||||
|
|
||||||
|
class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(context, attrs) {
|
||||||
|
|
||||||
|
private fun toColors(selected: Int, pressed: Int, normal: Int): ColorStateList {
|
||||||
|
val colors = intArrayOf(selected, pressed, normal)
|
||||||
|
val states = arrayOfNulls<IntArray>(3)
|
||||||
|
states[0] = intArrayOf(android.R.attr.state_checked)
|
||||||
|
states[1] = intArrayOf(android.R.attr.state_pressed)
|
||||||
|
states[2] = intArrayOf()
|
||||||
|
return ColorStateList(states, colors)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val thumbColor get() = if (context.isSystemInDarkMode) 0xFF7C7C7C else 0xFFCCCCCC
|
||||||
|
|
||||||
|
init {
|
||||||
|
trackDrawable = DrawableBuilder()
|
||||||
|
.rectangle()
|
||||||
|
.rounded()
|
||||||
|
.solidColor(0xFF656565.toInt())
|
||||||
|
.height(20.dp(context))
|
||||||
|
.cornerRadius(15.dp(context))
|
||||||
|
.build()
|
||||||
|
thumbDrawable = DrawableBuilder()
|
||||||
|
.rectangle()
|
||||||
|
.rounded()
|
||||||
|
.solidColor(Color.WHITE)
|
||||||
|
.size(20.dp(context), 20.dp(context))
|
||||||
|
.cornerRadius(20.dp(context))
|
||||||
|
.strokeWidth(8.dp(context))
|
||||||
|
.strokeColor(Color.TRANSPARENT)
|
||||||
|
.build()
|
||||||
|
trackTintList = toColors(
|
||||||
|
0xFF656565.toInt(),
|
||||||
|
thumbColor.toInt(),
|
||||||
|
thumbColor.toInt()
|
||||||
|
)
|
||||||
|
isSingleLine = true
|
||||||
|
ellipsize = TextUtils.TruncateAt.END
|
||||||
|
}
|
||||||
|
}
|
@@ -1,107 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by fankes on 2022/1/7.
|
|
||||||
*/
|
|
||||||
@file:Suppress("unused")
|
|
||||||
|
|
||||||
package com.fankes.tsbattery.utils
|
|
||||||
|
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.drawable.GradientDrawable
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构造对话框
|
|
||||||
* @param isUseBlackTheme 是否使用深色主题
|
|
||||||
* @param it 对话框方法体
|
|
||||||
*/
|
|
||||||
fun Context.showDialog(isUseBlackTheme: Boolean = false, it: DialogBuilder.() -> Unit) =
|
|
||||||
DialogBuilder(this, isUseBlackTheme).apply(it).show()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对话框构造器
|
|
||||||
* @param context 实例
|
|
||||||
* @param isUseBlackTheme 是否使用深色主题
|
|
||||||
*/
|
|
||||||
class DialogBuilder(private val context: Context, private val isUseBlackTheme: Boolean) {
|
|
||||||
|
|
||||||
private var instance: AlertDialog.Builder? = null // 实例对象
|
|
||||||
|
|
||||||
init {
|
|
||||||
instance = AlertDialog.Builder(
|
|
||||||
context,
|
|
||||||
if (isUseBlackTheme) android.R.style.Theme_Material_Dialog else android.R.style.Theme_Material_Light_Dialog
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 设置对话框不可关闭 */
|
|
||||||
fun noCancelable() = instance?.setCancelable(false)
|
|
||||||
|
|
||||||
/** 设置对话框标题 */
|
|
||||||
var title
|
|
||||||
get() = ""
|
|
||||||
set(value) {
|
|
||||||
instance?.setTitle(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 设置对话框消息内容 */
|
|
||||||
var msg
|
|
||||||
get() = ""
|
|
||||||
set(value) {
|
|
||||||
instance?.setMessage(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置对话框确定按钮
|
|
||||||
* @param text 按钮文本内容
|
|
||||||
* @param it 点击事件
|
|
||||||
*/
|
|
||||||
fun confirmButton(text: String = "确定", it: () -> Unit = {}) =
|
|
||||||
instance?.setPositiveButton(text) { _, _ -> it() }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置对话框取消按钮
|
|
||||||
* @param text 按钮文本内容
|
|
||||||
* @param it 点击事件
|
|
||||||
*/
|
|
||||||
fun cancelButton(text: String = "取消", it: () -> Unit = {}) =
|
|
||||||
instance?.setNegativeButton(text) { _, _ -> it() }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置对话框第三个按钮
|
|
||||||
* @param text 按钮文本内容
|
|
||||||
* @param it 点击事件
|
|
||||||
*/
|
|
||||||
fun neutralButton(text: String = "更多", it: () -> Unit = {}) =
|
|
||||||
instance?.setNeutralButton(text) { _, _ -> it() }
|
|
||||||
|
|
||||||
/** 显示对话框 */
|
|
||||||
internal fun show() = instance?.create()?.apply {
|
|
||||||
window?.setBackgroundDrawable(GradientDrawable(
|
|
||||||
GradientDrawable.Orientation.TOP_BOTTOM,
|
|
||||||
if (isUseBlackTheme) intArrayOf(0xFF2D2D2D.toInt(), 0xFF2D2D2D.toInt())
|
|
||||||
else intArrayOf(Color.WHITE, Color.WHITE)
|
|
||||||
).apply {
|
|
||||||
shape = GradientDrawable.RECTANGLE
|
|
||||||
gradientType = GradientDrawable.LINEAR_GRADIENT
|
|
||||||
cornerRadius = 15.dp(this@DialogBuilder.context)
|
|
||||||
})
|
|
||||||
}?.show()
|
|
||||||
}
|
|
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by zpp0196 on 2019/2/9.
|
|
||||||
*/
|
|
||||||
package com.fankes.tsbattery.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.fankes.tsbattery.BuildConfig;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
|
||||||
public class FileUtils {
|
|
||||||
|
|
||||||
private static final String FILE_PREF_NAME = BuildConfig.APPLICATION_ID + "_preferences.xml";
|
|
||||||
|
|
||||||
public static boolean copyFile(File srcFile, File targetFile) {
|
|
||||||
FileInputStream ins = null;
|
|
||||||
FileOutputStream out = null;
|
|
||||||
try {
|
|
||||||
if (targetFile.exists()) {
|
|
||||||
targetFile.delete();
|
|
||||||
}
|
|
||||||
File targetParent = targetFile.getParentFile();
|
|
||||||
if (!targetParent.exists()) {
|
|
||||||
targetParent.mkdirs();
|
|
||||||
}
|
|
||||||
targetFile.createNewFile();
|
|
||||||
ins = new FileInputStream(srcFile);
|
|
||||||
out = new FileOutputStream(targetFile);
|
|
||||||
byte[] b = new byte[1024];
|
|
||||||
int n;
|
|
||||||
while ((n = ins.read(b)) != -1) {
|
|
||||||
out.write(b, 0, n);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (ins != null) {
|
|
||||||
ins.close();
|
|
||||||
}
|
|
||||||
if (out != null) {
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getDataDir(Context context) {
|
|
||||||
return new File(context.getApplicationInfo().dataDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getPrefDir(Context context) {
|
|
||||||
return new File(getDataDir(context), "shared_prefs");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getDefaultPrefFile(Context context) {
|
|
||||||
return new File(getPrefDir(context), FILE_PREF_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,98 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by fankes on 2022/1/7.
|
|
||||||
*/
|
|
||||||
@file:Suppress("DEPRECATION")
|
|
||||||
|
|
||||||
package com.fankes.tsbattery.utils
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.PackageInfo
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.net.Uri
|
|
||||||
import android.provider.Settings
|
|
||||||
import android.widget.Toast
|
|
||||||
import com.fankes.tsbattery.application.TSApplication.Companion.appContext
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 得到安装包信息
|
|
||||||
* @return [PackageInfo]
|
|
||||||
*/
|
|
||||||
val Context.packageInfo get() = packageManager?.getPackageInfo(packageName, 0) ?: PackageInfo()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断应用是否安装
|
|
||||||
* @return [Boolean]
|
|
||||||
*/
|
|
||||||
val String.isInstall
|
|
||||||
get() =
|
|
||||||
try {
|
|
||||||
appContext.packageManager.getPackageInfo(
|
|
||||||
this,
|
|
||||||
PackageManager.GET_UNINSTALLED_PACKAGES
|
|
||||||
)
|
|
||||||
true
|
|
||||||
} catch (e: Exception) {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 得到版本信息
|
|
||||||
* @return [String]
|
|
||||||
*/
|
|
||||||
val Context.versionName get() = packageInfo.versionName ?: ""
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 得到版本号
|
|
||||||
* @return [Int]
|
|
||||||
*/
|
|
||||||
val Context.versionCode get() = packageInfo.versionCode
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dp 转换为 px
|
|
||||||
* @return [Int]
|
|
||||||
*/
|
|
||||||
val Number.dp get() = (toFloat() * appContext.resources.displayMetrics.density).toInt()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dp 转换为 px
|
|
||||||
* @param context 使用的实例
|
|
||||||
* @return [Float]
|
|
||||||
*/
|
|
||||||
fun Number.dp(context: Context) = toFloat() * context.resources.displayMetrics.density
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 跳转 APP 自身设置界面
|
|
||||||
* @param packageName 包名
|
|
||||||
*/
|
|
||||||
fun Context.openSelfSetting(packageName: String) {
|
|
||||||
try {
|
|
||||||
if (packageName.isInstall)
|
|
||||||
startActivity(Intent().apply {
|
|
||||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
|
||||||
data = Uri.fromParts("package", packageName, null)
|
|
||||||
})
|
|
||||||
else Toast.makeText(this, "你没有安装此应用", Toast.LENGTH_SHORT).show()
|
|
||||||
} catch (_: Exception) {
|
|
||||||
Toast.makeText(this, "启动 $packageName 应用信息失败", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by zpp0196 on 2018/4/11.
|
|
||||||
*/
|
|
||||||
package com.fankes.tsbattery.utils
|
|
||||||
|
|
||||||
import de.robv.android.xposed.XSharedPreferences
|
|
||||||
|
|
||||||
object XPrefUtils {
|
|
||||||
|
|
||||||
fun getBoolean(key: String) = pref.getBoolean(key, false)
|
|
||||||
|
|
||||||
fun getString(key: String) = pref.getString(key, "unknown")
|
|
||||||
|
|
||||||
private val pref: XSharedPreferences
|
|
||||||
get() {
|
|
||||||
val preferences = XSharedPreferences("com.fankes.tsbattery")
|
|
||||||
preferences.makeWorldReadable()
|
|
||||||
preferences.reload()
|
|
||||||
return preferences
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.fankes.tsbattery.utils.drawable.drawabletoolbox
|
package com.fankes.tsbattery.utils.drawable.drawabletoolbox
|
||||||
|
|
||||||
class Constants {
|
class Constants {
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
*
|
*
|
||||||
* This file is part of TSBattery.
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
* This software is distributed in the hope that it will be useful,
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
* Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
|
@@ -0,0 +1,199 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/1/7.
|
||||||
|
*/
|
||||||
|
@file:Suppress("unused", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE")
|
||||||
|
|
||||||
|
package com.fankes.tsbattery.utils.factory
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.drawable.GradientDrawable
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.highcapable.yukihookapi.annotation.DoNotUseField
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
|
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造对话框
|
||||||
|
* @param isUseBlackTheme 是否使用深色主题
|
||||||
|
* @param it 对话框方法体
|
||||||
|
*/
|
||||||
|
fun Context.showDialog(isUseBlackTheme: Boolean = false, it: DialogBuilder.() -> Unit) =
|
||||||
|
DialogBuilder(this, isUseBlackTheme).apply(it).show()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话框构造器
|
||||||
|
* @param context 实例
|
||||||
|
* @param isUseBlackTheme 是否使用深色主题 - 对 AndroidX 风格无效
|
||||||
|
*/
|
||||||
|
class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean) {
|
||||||
|
|
||||||
|
private var instanceAndroidX: androidx.appcompat.app.AlertDialog.Builder? = null // 实例对象
|
||||||
|
private var instanceAndroid: android.app.AlertDialog.Builder? = null // 实例对象
|
||||||
|
|
||||||
|
private var dialogInstance: Dialog? = null // 对话框实例
|
||||||
|
|
||||||
|
@DoNotUseField
|
||||||
|
var customLayoutView: View? = null // 自定义布局
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需要使用 AndroidX 风格对话框
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
private val isUsingAndroidX get() = runCatching { context is AppCompatActivity }.getOrNull() ?: false
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runInSafe { instanceAndroidX = MaterialAlertDialogBuilder(context) }
|
||||||
|
else runInSafe {
|
||||||
|
instanceAndroid = android.app.AlertDialog.Builder(
|
||||||
|
context,
|
||||||
|
if (isUseBlackTheme) android.R.style.Theme_Material_Dialog else android.R.style.Theme_Material_Light_Dialog
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设置对话框不可关闭 */
|
||||||
|
fun noCancelable() {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runInSafe { instanceAndroidX?.setCancelable(false) }
|
||||||
|
else runInSafe { instanceAndroid?.setCancelable(false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设置对话框标题 */
|
||||||
|
var title
|
||||||
|
get() = ""
|
||||||
|
set(value) {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runInSafe { instanceAndroidX?.setTitle(value) }
|
||||||
|
else runInSafe { instanceAndroid?.setTitle(value) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设置对话框消息内容 */
|
||||||
|
var msg
|
||||||
|
get() = ""
|
||||||
|
set(value) {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runInSafe { instanceAndroidX?.setMessage(value) }
|
||||||
|
else runInSafe { instanceAndroid?.setMessage(value) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设置进度条对话框消息内容 */
|
||||||
|
var progressContent
|
||||||
|
get() = ""
|
||||||
|
set(value) {
|
||||||
|
if (customLayoutView == null)
|
||||||
|
customLayoutView = LinearLayout(context).apply {
|
||||||
|
orientation = LinearLayout.HORIZONTAL
|
||||||
|
gravity = Gravity.CENTER or Gravity.START
|
||||||
|
addView(ProgressBar(context))
|
||||||
|
addView(View(context).apply { layoutParams = ViewGroup.LayoutParams(20.dp(context), 5) })
|
||||||
|
addView(TextView(context).apply {
|
||||||
|
tag = "progressContent"
|
||||||
|
text = value
|
||||||
|
})
|
||||||
|
setPadding(20.dp(context), 20.dp(context), 20.dp(context), 20.dp(context))
|
||||||
|
}
|
||||||
|
else customLayoutView?.findViewWithTag<TextView>("progressContent")?.text = value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置对话框自定义布局
|
||||||
|
* @return [ViewBinding]
|
||||||
|
*/
|
||||||
|
inline fun <reified T : ViewBinding> bind() =
|
||||||
|
T::class.java.method {
|
||||||
|
name = "inflate"
|
||||||
|
param(LayoutInflaterClass)
|
||||||
|
}.get().invoke<T>(LayoutInflater.from(context))?.apply {
|
||||||
|
customLayoutView = root
|
||||||
|
} ?: error("binding failed")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置对话框确定按钮
|
||||||
|
* @param text 按钮文本内容
|
||||||
|
* @param it 点击事件
|
||||||
|
*/
|
||||||
|
fun confirmButton(text: String = "确定", it: () -> Unit = {}) {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runInSafe { instanceAndroidX?.setPositiveButton(text) { _, _ -> it() } }
|
||||||
|
else runInSafe { instanceAndroid?.setPositiveButton(text) { _, _ -> it() } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置对话框取消按钮
|
||||||
|
* @param text 按钮文本内容
|
||||||
|
* @param it 点击事件
|
||||||
|
*/
|
||||||
|
fun cancelButton(text: String = "取消", it: () -> Unit = {}) {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runInSafe { instanceAndroidX?.setNegativeButton(text) { _, _ -> it() } }
|
||||||
|
else runInSafe { instanceAndroid?.setNegativeButton(text) { _, _ -> it() } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置对话框第三个按钮
|
||||||
|
* @param text 按钮文本内容
|
||||||
|
* @param it 点击事件
|
||||||
|
*/
|
||||||
|
fun neutralButton(text: String = "更多", it: () -> Unit = {}) {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runInSafe { instanceAndroidX?.setNeutralButton(text) { _, _ -> it() } }
|
||||||
|
else runInSafe { instanceAndroid?.setNeutralButton(text) { _, _ -> it() } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消对话框 */
|
||||||
|
fun cancel() = dialogInstance?.cancel()
|
||||||
|
|
||||||
|
/** 显示对话框 */
|
||||||
|
internal fun show() =
|
||||||
|
if (isUsingAndroidX) runInSafe {
|
||||||
|
instanceAndroidX?.create()?.apply {
|
||||||
|
customLayoutView?.let { setView(it) }
|
||||||
|
dialogInstance = this
|
||||||
|
}?.show()
|
||||||
|
} else runInSafe {
|
||||||
|
instanceAndroid?.create()?.apply {
|
||||||
|
customLayoutView?.let { setView(it) }
|
||||||
|
window?.setBackgroundDrawable(
|
||||||
|
GradientDrawable(
|
||||||
|
GradientDrawable.Orientation.TOP_BOTTOM,
|
||||||
|
if (isUseBlackTheme) intArrayOf(0xFF2D2D2D.toInt(), 0xFF2D2D2D.toInt())
|
||||||
|
else intArrayOf(Color.WHITE, Color.WHITE)
|
||||||
|
).apply {
|
||||||
|
shape = GradientDrawable.RECTANGLE
|
||||||
|
gradientType = GradientDrawable.LINEAR_GRADIENT
|
||||||
|
cornerRadius = 15.dpFloat(this@DialogBuilder.context)
|
||||||
|
})
|
||||||
|
dialogInstance = this
|
||||||
|
}?.show()
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/3/13.
|
||||||
|
*/
|
||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
|
package com.fankes.tsbattery.utils.factory
|
||||||
|
|
||||||
|
import com.highcapable.yukihookapi.hook.log.loggerE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略异常返回值
|
||||||
|
* @param result 回调 - 如果异常为空
|
||||||
|
* @return [T] 发生异常时返回设定值否则返回正常值
|
||||||
|
*/
|
||||||
|
inline fun <T> safeOfNull(result: () -> T): T? = safeOf(default = null, result)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略异常返回值
|
||||||
|
* @param result 回调 - 如果异常为 false
|
||||||
|
* @return [Boolean] 发生异常时返回设定值否则返回正常值
|
||||||
|
*/
|
||||||
|
inline fun safeOfFalse(result: () -> Boolean) = safeOf(default = false, result)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略异常返回值
|
||||||
|
* @param result 回调 - 如果异常为 true
|
||||||
|
* @return [Boolean] 发生异常时返回设定值否则返回正常值
|
||||||
|
*/
|
||||||
|
inline fun safeOfTrue(result: () -> Boolean) = safeOf(default = true, result)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略异常返回值
|
||||||
|
* @param result 回调 - 如果异常为 false
|
||||||
|
* @return [String] 发生异常时返回设定值否则返回正常值
|
||||||
|
*/
|
||||||
|
inline fun safeOfNothing(result: () -> String) = safeOf(default = "", result)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略异常返回值
|
||||||
|
* @param result 回调 - 如果异常为 false
|
||||||
|
* @return [Int] 发生异常时返回设定值否则返回正常值
|
||||||
|
*/
|
||||||
|
inline fun safeOfNan(result: () -> Int) = safeOf(default = 0, result)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略异常返回值
|
||||||
|
* @param default 异常返回值
|
||||||
|
* @param result 正常回调值
|
||||||
|
* @return [T] 发生异常时返回设定值否则返回正常值
|
||||||
|
*/
|
||||||
|
inline fun <T> safeOf(default: T, result: () -> T) = try {
|
||||||
|
result()
|
||||||
|
} catch (_: Throwable) {
|
||||||
|
default
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略异常运行
|
||||||
|
* @param msg 出错输出的消息 - 默认为空
|
||||||
|
* @param block 正常回调
|
||||||
|
*/
|
||||||
|
inline fun <T> T.runInSafe(msg: String = "", block: () -> Unit) {
|
||||||
|
runCatching(block).onFailure { if (msg.isNotBlank()) loggerE(msg = msg, e = it) }
|
||||||
|
}
|
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/1/7.
|
||||||
|
*/
|
||||||
|
@file:Suppress("DEPRECATION", "unused")
|
||||||
|
|
||||||
|
package com.fankes.tsbattery.utils.factory
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageInfo
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Uri
|
||||||
|
import android.provider.Settings
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
|
import com.fankes.tsbattery.application.TSApplication.Companion.appContext
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统深色模式是否开启
|
||||||
|
* @return [Boolean] 是否开启
|
||||||
|
*/
|
||||||
|
val isSystemInDarkMode get() = appContext.isSystemInDarkMode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统深色模式是否没开启
|
||||||
|
* @return [Boolean] 是否开启
|
||||||
|
*/
|
||||||
|
inline val isNotSystemInDarkMode get() = !isSystemInDarkMode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统深色模式是否开启
|
||||||
|
* @return [Boolean] 是否开启
|
||||||
|
*/
|
||||||
|
val Context.isSystemInDarkMode get() = (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统深色模式是否没开启
|
||||||
|
* @return [Boolean] 是否开启
|
||||||
|
*/
|
||||||
|
inline val Context.isNotSystemInDarkMode get() = !isSystemInDarkMode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到安装包信息
|
||||||
|
* @return [PackageInfo]
|
||||||
|
*/
|
||||||
|
val Context.packageInfo get() = packageManager?.getPackageInfo(packageName, 0) ?: PackageInfo()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断应用是否安装
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
val String.isInstall
|
||||||
|
get() = try {
|
||||||
|
appContext.packageManager.getPackageInfo(
|
||||||
|
this,
|
||||||
|
PackageManager.GET_UNINSTALLED_PACKAGES
|
||||||
|
)
|
||||||
|
true
|
||||||
|
} catch (e: Exception) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到版本信息
|
||||||
|
* @return [String]
|
||||||
|
*/
|
||||||
|
val Context.versionName get() = packageInfo.versionName ?: ""
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到版本号
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
val Context.versionCode get() = packageInfo.versionCode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到版本信息与版本号
|
||||||
|
* @param packageName 包名
|
||||||
|
* @return [String]
|
||||||
|
*/
|
||||||
|
fun Context.version(packageName: String) = safeOfNothing {
|
||||||
|
packageManager?.getPackageInfo(packageName, 0)?.let {
|
||||||
|
"${it.versionName}(${it.versionCode})"
|
||||||
|
} ?: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络连接是否正常
|
||||||
|
* @return [Boolean] 网络是否连接
|
||||||
|
*/
|
||||||
|
val isNetWorkSuccess
|
||||||
|
get() = safeOfFalse { appContext.getSystemService<ConnectivityManager>()?.activeNetworkInfo != null }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dp 转换为 pxInt
|
||||||
|
* @param context 使用的实例
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
fun Number.dp(context: Context) = dpFloat(context).toInt()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dp 转换为 pxFloat
|
||||||
|
* @param context 使用的实例
|
||||||
|
* @return [Float]
|
||||||
|
*/
|
||||||
|
fun Number.dpFloat(context: Context) = toFloat() * context.resources.displayMetrics.density
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 弹出 [Toast]
|
||||||
|
* @param msg 提示内容
|
||||||
|
*/
|
||||||
|
fun toast(msg: String) = Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 弹出 [Snackbar]
|
||||||
|
* @param msg 提示内容
|
||||||
|
* @param actionText 按钮文本 - 不写默认取消按钮
|
||||||
|
* @param it 按钮事件回调
|
||||||
|
*/
|
||||||
|
fun Context.snake(msg: String, actionText: String = "", it: () -> Unit = {}) =
|
||||||
|
Snackbar.make((this as Activity).findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG).apply {
|
||||||
|
if (actionText.isBlank()) return@apply
|
||||||
|
setActionTextColor(if (isSystemInDarkMode) Color.BLACK else Color.WHITE)
|
||||||
|
setAction(actionText) { it() }
|
||||||
|
}.show()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转 APP 自身设置界面
|
||||||
|
* @param packageName 包名
|
||||||
|
*/
|
||||||
|
fun Context.openSelfSetting(packageName: String = appContext.packageName) = runCatching {
|
||||||
|
if (packageName.isInstall)
|
||||||
|
startActivity(Intent().apply {
|
||||||
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||||
|
data = Uri.fromParts("package", packageName, null)
|
||||||
|
})
|
||||||
|
else snake(msg = "你没有安装此应用")
|
||||||
|
}.onFailure { toast(msg = "启动 $packageName 应用信息失败") }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动系统浏览器
|
||||||
|
* @param url 网址
|
||||||
|
* @param packageName 指定包名 - 可不填
|
||||||
|
*/
|
||||||
|
fun Context.openBrowser(url: String, packageName: String = "") = runCatching {
|
||||||
|
startActivity(Intent().apply {
|
||||||
|
if (packageName.isNotBlank()) setPackage(packageName)
|
||||||
|
action = Intent.ACTION_VIEW
|
||||||
|
data = Uri.parse(url)
|
||||||
|
/** 防止顶栈一样重叠在自己的 APP 中 */
|
||||||
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
})
|
||||||
|
}.onFailure {
|
||||||
|
if (packageName.isNotBlank()) snake(msg = "启动 $packageName 失败")
|
||||||
|
else snake(msg = "启动系统浏览器失败")
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
|
||||||
|
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/TSBattery
|
||||||
|
*
|
||||||
|
* This software is non-free but opensource software: you can redistribute it
|
||||||
|
* and/or modify it under the terms of the GNU Affero General Public License
|
||||||
|
* as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* and eula along with this software. If not, see
|
||||||
|
* <https://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/3/20.
|
||||||
|
*/
|
||||||
|
package com.fankes.tsbattery.utils.tool
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import com.fankes.tsbattery.utils.factory.*
|
||||||
|
import okhttp3.*
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.io.IOException
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 Github Release 最新版本工具类
|
||||||
|
*/
|
||||||
|
object GithubReleaseTool {
|
||||||
|
|
||||||
|
/** 仓库作者 */
|
||||||
|
private const val REPO_AUTHOR = "fankes"
|
||||||
|
|
||||||
|
/** 仓库名称 */
|
||||||
|
private const val REPO_NAME = "TSBattery"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新版本信息
|
||||||
|
* @param context 实例
|
||||||
|
* @param version 当前版本
|
||||||
|
* @param it 成功后回调 - ([String] 最新版本,[Function] 更新对话框方法体)
|
||||||
|
*/
|
||||||
|
fun checkingForUpdate(context: Context, version: String, it: (String, () -> Unit) -> Unit) = checkingInternetConnect(context) {
|
||||||
|
OkHttpClient().newBuilder().build().newCall(
|
||||||
|
Request.Builder()
|
||||||
|
.url("https://api.github.com/repos/$REPO_AUTHOR/$REPO_NAME/releases/latest")
|
||||||
|
.get()
|
||||||
|
.build()
|
||||||
|
).enqueue(object : Callback {
|
||||||
|
override fun onFailure(call: Call, e: IOException) {}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call, response: Response) = runInSafe {
|
||||||
|
JSONObject(response.body?.string() ?: "").apply {
|
||||||
|
GithubReleaseBean(
|
||||||
|
name = getString("name"),
|
||||||
|
htmlUrl = getString("html_url"),
|
||||||
|
content = getString("body"),
|
||||||
|
date = getString("published_at").replace(oldValue = "T", newValue = " ").replace(oldValue = "Z", newValue = "")
|
||||||
|
).apply {
|
||||||
|
fun showUpdate() = context.showDialog {
|
||||||
|
title = "最新版本 $name"
|
||||||
|
msg = "发布于 $date\n\n" +
|
||||||
|
"更新日志\n\n" + content
|
||||||
|
confirmButton(text = "更新") { context.openBrowser(htmlUrl) }
|
||||||
|
cancelButton()
|
||||||
|
}
|
||||||
|
if (name != version) (context as? Activity?)?.runOnUiThread {
|
||||||
|
showUpdate()
|
||||||
|
it(name) { showUpdate() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查网络连接情况
|
||||||
|
* @param context 实例
|
||||||
|
* @param it 已连接回调
|
||||||
|
*/
|
||||||
|
private fun checkingInternetConnect(context: Context, it: () -> Unit) = runInSafe {
|
||||||
|
if (isNetWorkSuccess)
|
||||||
|
OkHttpClient().newBuilder().build().newCall(
|
||||||
|
Request.Builder()
|
||||||
|
.url("https://www.baidu.com")
|
||||||
|
.get()
|
||||||
|
.build()
|
||||||
|
).enqueue(object : Callback {
|
||||||
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
(context as? Activity?)?.runOnUiThread {
|
||||||
|
context.showDialog {
|
||||||
|
title = "网络不可用"
|
||||||
|
msg = "模块的联网权限可能已被禁用,请开启联网权限以定期检查更新。"
|
||||||
|
confirmButton(text = "去开启") { context.openSelfSetting() }
|
||||||
|
cancelButton()
|
||||||
|
noCancelable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call, response: Response) = runInSafe {
|
||||||
|
(context as? Activity?)?.runOnUiThread { runInSafe { it() } }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Github Release bean
|
||||||
|
* @param name 版本名称
|
||||||
|
* @param htmlUrl 网页地址
|
||||||
|
* @param content 更新日志
|
||||||
|
* @param date 发布时间
|
||||||
|
*/
|
||||||
|
private data class GithubReleaseBean(
|
||||||
|
var name: String,
|
||||||
|
var htmlUrl: String,
|
||||||
|
var content: String,
|
||||||
|
var date: String
|
||||||
|
) : Serializable
|
||||||
|
}
|
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021. Fankes Studio(qzmmcn@163.com)
|
|
||||||
*
|
|
||||||
* This file is part of TSBattery.
|
|
||||||
*
|
|
||||||
* TSBattery is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* TSBattery is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This file is Created by fankes on 2022/1/8.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@file:Suppress("SameParameterValue")
|
|
||||||
|
|
||||||
package com.fankes.tsbattery.view
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.ColorStateList
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
|
||||||
import com.fankes.tsbattery.utils.dp
|
|
||||||
import com.fankes.tsbattery.utils.drawable.drawabletoolbox.DrawableBuilder
|
|
||||||
|
|
||||||
class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(context, attrs) {
|
|
||||||
|
|
||||||
private fun toColors(selected: Int, pressed: Int, normal: Int): ColorStateList {
|
|
||||||
val colors = intArrayOf(selected, pressed, normal)
|
|
||||||
val states = arrayOfNulls<IntArray>(3)
|
|
||||||
states[0] = intArrayOf(android.R.attr.state_checked)
|
|
||||||
states[1] = intArrayOf(android.R.attr.state_pressed)
|
|
||||||
states[2] = intArrayOf()
|
|
||||||
return ColorStateList(states, colors)
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
trackDrawable = DrawableBuilder()
|
|
||||||
.rectangle()
|
|
||||||
.rounded()
|
|
||||||
.solidColor(0xFF656565.toInt())
|
|
||||||
.height(20.dp)
|
|
||||||
.cornerRadius(15.dp)
|
|
||||||
.build()
|
|
||||||
thumbDrawable = DrawableBuilder()
|
|
||||||
.rectangle()
|
|
||||||
.rounded()
|
|
||||||
.solidColor(Color.WHITE)
|
|
||||||
.size(20.dp, 20.dp)
|
|
||||||
.cornerRadius(20.dp)
|
|
||||||
.strokeWidth(2.dp)
|
|
||||||
.strokeColor(Color.TRANSPARENT)
|
|
||||||
.build()
|
|
||||||
trackTintList = toColors(
|
|
||||||
0xFF656565.toInt(),
|
|
||||||
0xFFCCCCCC.toInt(),
|
|
||||||
0xFFCCCCCC.toInt()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
6
app/src/main/res/drawable-night/bg_dark_round.xml
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#66A6A6A6" />
|
||||||
|
<corners android:radius="15dp" />
|
||||||
|
</shape>
|
6
app/src/main/res/drawable-night/bg_permotion_round.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#666E6E6E" />
|
||||||
|
<corners android:radius="15dp" />
|
||||||
|
</shape>
|
6
app/src/main/res/drawable/bg_orange_round.xml
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FF7043" />
|
||||||
|
<corners android:radius="15dp" />
|
||||||
|
</shape>
|
Before Width: | Height: | Size: 201 KiB After Width: | Height: | Size: 201 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_bug.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_github.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_help.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_home.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_tim_icon.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_yukihookapi.png
Normal file
After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 3.3 KiB |
6
app/src/main/res/values-night/color.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorThemeBackground">#FF2D2D2D</color>
|
||||||
|
<color name="colorTextDark">#FFCFCFCF</color>
|
||||||
|
<color name="colorTextGray">#FFD3D3D3</color>
|
||||||
|
</resources>
|
@@ -1,6 +1,6 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.TSBattery" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="Theme.TSBattery" parent="Theme.Material3.DayNight">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
<item name="colorPrimary">@color/purple_200</item>
|
<item name="colorPrimary">@color/purple_200</item>
|
||||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
8
app/src/main/res/values/array.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string-array name="module_scope">
|
||||||
|
<item>com.tencent.mobileqq</item>
|
||||||
|
<item>com.tencent.tim</item>
|
||||||
|
<item>com.tencent.mm</item>
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
6
app/src/main/res/values/color.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorThemeBackground">#FFFFFFFF</color>
|
||||||
|
<color name="colorTextDark">#FF777777</color>
|
||||||
|
<color name="colorTextGray">#FF323B42</color>
|
||||||
|
</resources>
|
@@ -1,6 +1,6 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.TSBattery" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="Theme.TSBattery" parent="Theme.Material3.DayNight">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
<item name="colorPrimary">@color/purple_500</item>
|
<item name="colorPrimary">@color/purple_500</item>
|
||||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
32
build.gradle
@@ -1,30 +1,12 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
plugins {
|
||||||
buildscript {
|
id 'com.android.application' version '7.1.2' apply false
|
||||||
ext.kotlin_version = "1.6.10"
|
id 'com.android.library' version '7.1.2' apply false
|
||||||
repositories {
|
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
|
||||||
google()
|
|
||||||
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
|
||||||
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
|
||||||
maven { url "https://www.jitpack.io" }
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "com.android.tools.build:gradle:7.0.4"
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
|
||||||
// in the individual module build.gradle files
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
ext {
|
||||||
repositories {
|
appVersionName = "3.6"
|
||||||
google()
|
appVersionCode = 14
|
||||||
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
|
||||||
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
|
||||||
maven { url "https://www.jitpack.io" }
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Sat Sep 04 04:05:23 CST 2021
|
#Mon Feb 14 23:27:58 CST 2022
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
@@ -1,2 +1,18 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
maven { url "https://api.xposed.info/" }
|
||||||
|
maven { url "https://s01.oss.sonatype.org/content/repositories/releases" }
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
rootProject.name = "TSBattery"
|
rootProject.name = "TSBattery"
|
||||||
include ':app'
|
include ':app'
|
||||||
|