/platforms/`.
18 | 3. Copy, paste and replace the downloaded hidden API file into this directory, e.g. `android-30/android.jar`.
19 | 4. Change `compileSdkVersion` and `targetSdkVersion` to 35 (for example).
20 | 5. Finally, rebuild your project.
21 |
22 | Note: Higher `compileSdkVersion` and `targetSdkVersion` will be better.
23 |
24 | ## Resources Helper
25 | 
26 |
27 | If you plan to use only Android internal resources rather than internal classes or methods, do:
28 |
29 | ````gradle
30 | dependencies {
31 | implementation 'com.anggrayudi:android-hidden-api:X.Y'
32 | }
33 | ````
34 |
35 | Where `X.Y` is the library version: 
36 |
37 | All versions can be found [here](https://oss.sonatype.org/#nexus-search;gav~com.anggrayudi~android-hidden-api~~~~kw,versionexpand).
38 | To use `SNAPSHOT` version, you need to add this URL to the root Gradle:
39 |
40 | ```groovy
41 | allprojects {
42 | repositories {
43 | google()
44 | mavenCentral()
45 | // add this line
46 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
47 | }
48 | }
49 | ```
50 |
51 | Here's some example of accessing internal resources:
52 |
53 | ```java
54 | String accept = InternalAccessor.getString("accept");
55 | float sbar_height = InternalAccessor.getDimension("status_bar_height");
56 | int notif_color = InternalAccessor.getColor("config_defaultNotificationColor");
57 | ```
58 |
59 | ## Contributing
60 |
61 | If you have your own custom `android.jar` and want to add it to
62 | [Google Drive](https://drive.google.com/drive/folders/17oMwQ0xBcSGn159mgbqxcXXEcneUmnph),
63 | please create an issue. I will upload it.
64 |
65 | ## License
66 |
67 | Copyright 2015-2025 Anggrayudi Hardiannico A.
68 |
69 | Licensed under the Apache License, Version 2.0 (the "License");
70 | you may not use this file except in compliance with the License.
71 | You may obtain a copy of the License at
72 |
73 | http://www.apache.org/licenses/LICENSE-2.0
74 |
75 | Unless required by applicable law or agreed to in writing, software
76 | distributed under the License is distributed on an "AS IS" BASIS,
77 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
78 | See the License for the specific language governing permissions and
79 | limitations under the License.
80 |
81 |
82 | [1]: https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction
83 | [2]: https://github.com/anggrayudi/android-hidden-api/issues/9
84 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2 |
3 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
4 |
5 | buildscript {
6 | ext.kotlin_version = '2.0.21'
7 | repositories {
8 | google()
9 | mavenCentral()
10 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
11 | }
12 |
13 | dependencies {
14 | classpath 'com.android.tools.build:gradle:8.8.0'
15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16 | classpath 'com.vanniktech:gradle-maven-publish-plugin:0.22.0'
17 | classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.8.20'
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | google()
24 | mavenCentral()
25 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
26 | }
27 |
28 | //Support @JvmDefault
29 | tasks.withType(KotlinCompile).configureEach {
30 | kotlinOptions {
31 | freeCompilerArgs = ['-Xjvm-default=all', '-opt-in=kotlin.RequiresOptIn']
32 | jvmTarget = '1.8'
33 | }
34 | }
35 | }
36 |
37 | subprojects {
38 | if (name != 'sample') {
39 | apply plugin: "com.vanniktech.maven.publish"
40 |
41 | repositories {
42 | maven {
43 | url = version.toString().endsWith("SNAPSHOT")
44 | ? 'https://oss.sonatype.org/content/repositories/snapshots/'
45 | : 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
46 | }
47 | }
48 | }
49 |
50 | afterEvaluate {
51 | android {
52 | compileSdkVersion 35
53 |
54 | defaultConfig {
55 | minSdkVersion 21
56 | targetSdkVersion 35
57 | versionCode 1
58 | versionName "$VERSION_NAME"
59 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
60 | vectorDrawables.useSupportLibrary = true
61 | }
62 |
63 | compileOptions {
64 | sourceCompatibility JavaVersion.VERSION_1_8
65 | targetCompatibility JavaVersion.VERSION_1_8
66 | }
67 |
68 | buildFeatures {
69 | buildConfig true
70 | }
71 | }
72 | configurations.configureEach {
73 | resolutionStrategy {
74 | // Force Kotlin to use current version
75 | force "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
76 | force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
77 | force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
78 | force "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
79 | force "org.jetbrains.kotlin:kotlin-android-extensions-runtime:$kotlin_version"
80 | }
81 | }
82 | // global dependencies for all modules
83 | dependencies {
84 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
85 | testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
86 | }
87 | }
88 | }
89 |
90 | tasks.register('clean', Delete) {
91 | delete rootProject.layout.buildDirectory
92 | }
93 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2G
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 | # For publishing:
23 | GROUP=com.anggrayudi
24 | POM_ARTIFACT_ID=android-hidden-api
25 | VERSION_NAME=35.0-SNAPSHOT
26 | RELEASE_SIGNING_ENABLED=false
27 | SONATYPE_AUTOMATIC_RELEASE=true
28 | SONATYPE_HOST=DEFAULT
29 | POM_NAME=android-hidden-api
30 | POM_DESCRIPTION=A library that provides access to Android hidden APIs and internal resources.
31 | POM_INCEPTION_YEAR=2015
32 | POM_URL=https://github.com/anggrayudi/android-hidden-api
33 | POM_LICENSE_NAME=The Apache Software License, Version 2.0
34 | POM_LICENSE_URL=https://github.com/anggrayudi/android-hidden-api/blob/master/LICENSE
35 | POM_LICENSE_DIST=https://www.apache.org/licenses/LICENSE-2.0.txt
36 | POM_SCM_URL=https://github.com/anggrayudi/android-hidden-api
37 | POM_SCM_CONNECTION=scm:git:git://github.com/anggrayudi/android-hidden-api.git
38 | POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com:anggrayudi/android-hidden-api.git
39 | POM_DEVELOPER_ID=anggrayudi
40 | POM_DEVELOPER_NAME=Anggrayudi H
41 | POM_DEVELOPER_URL=https://github.com/anggrayudi/
42 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 17 15:08:39 WIB 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin or MSYS, switch paths to Windows format before running java
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=`expr $i + 1`
158 | done
159 | case $i in
160 | 0) set -- ;;
161 | 1) set -- "$args0" ;;
162 | 2) set -- "$args0" "$args1" ;;
163 | 3) set -- "$args0" "$args1" "$args2" ;;
164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=`save "$@"`
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | exec "$JAVACMD" "$@"
184 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/resources-helper/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/resources-helper/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | group = 'com.anggrayudi'
5 | archivesBaseName = 'android-hidden-api'
6 | version = "$VERSION_NAME"
7 |
8 | android {
9 | namespace 'com.anggrayudi.hiddenapi'
10 |
11 | buildTypes {
12 | release {
13 | minifyEnabled false
14 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
15 | }
16 | debug {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | // Testing
25 | testImplementation 'junit:junit:4.13.2'
26 | testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
27 |
28 | implementation 'androidx.appcompat:appcompat:1.7.0'
29 | implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
30 | }
31 |
--------------------------------------------------------------------------------
/resources-helper/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/resources-helper/consumer-rules.pro
--------------------------------------------------------------------------------
/resources-helper/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/resources-helper/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/resources-helper/src/main/java/com/anggrayudi/hiddenapi/InternalAccessor.java:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.res.Resources;
5 | import android.content.res.XmlResourceParser;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Build;
8 |
9 | import androidx.annotation.NonNull;
10 |
11 | import java.io.InputStream;
12 | import java.lang.reflect.Method;
13 |
14 | /**
15 | * Created by Anggrayudi on 11/03/2016.
16 | * A utility class that provides access to all resources in com.android.internal.R
17 | * class.
18 | * This class does not use Java reflection anymore, and certainly safe.
19 | */
20 | @SuppressWarnings({"EmptyCatchBlock"})
21 | public final class InternalAccessor {
22 |
23 | /*
24 | // These are primitive classes which are available since API 7
25 | private static final Class> anim = com.android.internal.R.anim.class;
26 | private static final Class> array = com.android.internal.R.array.class;
27 | private static final Class> attr = com.android.internal.R.attr.class;
28 | private static final Class> bool = com.android.internal.R.bool.class;
29 | private static final Class> color = com.android.internal.R.color.class;
30 | private static final Class> dimen = com.android.internal.R.dimen.class;
31 | private static final Class> drawable = com.android.internal.R.drawable.class;
32 | private static final Class> id = com.android.internal.R.id.class;
33 | private static final Class> integer = com.android.internal.R.integer.class;
34 | private static final Class> layout = com.android.internal.R.layout.class;
35 | private static final Class> plurals = com.android.internal.R.plurals.class;
36 | private static final Class> raw = com.android.internal.R.raw.class;
37 | private static final Class> string = com.android.internal.R.string.class;
38 | private static final Class> style = com.android.internal.R.style.class;
39 | private static final Class> styleable = com.android.internal.R.styleable.class;
40 | private static final Class> xml = com.android.internal.R.xml.class;
41 |
42 | // These are up to date classes and may not available in API 10
43 | private static final Class> fraction = com.android.internal.R.fraction.class;
44 | private static final Class> interpolator = com.android.internal.R.interpolator.class;
45 | private static final Class> menu = com.android.internal.R.menu.class;
46 | private static final Class> mipmap = com.android.internal.R.mipmap.class;
47 | private static final Class> transition = com.android.internal.R.transition.class;
48 | */
49 |
50 | public static final String ANIM = "anim";
51 |
52 | public static final String ARRAY = "array";
53 |
54 | public static final String ATTR = "attr";
55 |
56 | public static final String BOOL = "bool";
57 |
58 | public static final String COLOR = "color";
59 |
60 | public static final String DIMEN = "dimen";
61 |
62 | public static final String DRAWABLE = "drawable";
63 |
64 | public static final String ID = "id";
65 |
66 | public static final String INTEGER = "integer";
67 |
68 | public static final String LAYOUT = "layout";
69 |
70 | public static final String PLURALS = "plurals";
71 |
72 | public static final String RAW = "raw";
73 |
74 | public static final String STRING = "string";
75 |
76 | public static final String STYLE = "style";
77 |
78 | public static final String STYLEABLE = "styleable";
79 |
80 | public static final String XML = "xml";
81 |
82 | public static final String FRACTION = "fraction";
83 |
84 | public static final String INTERPOLATOR = "interpolator";
85 |
86 | public static final String MENU = "menu";
87 |
88 | public static final String MIPMAP = "mipmap";
89 |
90 | public static final String TRANSITION = "transition";
91 |
92 | private InternalAccessor() {
93 | }
94 |
95 | /**
96 | * Pick resource id from com.android.internal.R
97 | *
98 | * @param clas for example = string, drawable, color, style, id, attr
.
99 | * And they will be wrote as com.android.internal.R.drawable
100 | * @param resName for example = cancel, ic_launcher, activity_main
101 | * @return internal resource id in integer, for example: com.android.internal.R.xml
102 | * .audio_assets
103 | * returns 17891329
in integer.
104 | */
105 | public static int getResourceId(@NonNull String clas, @NonNull String resName) {
106 | int id = Resources.getSystem().getIdentifier(resName, clas, "android");
107 | if (id == 0)
108 | throw new Resources.NotFoundException("Cannot find '" + clas + "' for '" + resName +
109 | "', or this resource currently is not available for API " + Build.VERSION.SDK_INT);
110 | return id;
111 | }
112 |
113 | /**
114 | * Pick Animation resources from com.android.internal.R.anim
115 | *
116 | * @param resName for example = snackbar_in, abc_fade_in
117 | * @return internal XmlResourceParser
animation
118 | */
119 | public static XmlResourceParser getAnimation(@NonNull String resName) {
120 | return Resources.getSystem().getAnimation(getResourceId(ANIM, resName));
121 | }
122 |
123 | /**
124 | * Pick boolean
resources from com.android.internal.R.bool
125 | *
126 | * @return internal boolean
127 | */
128 | public static boolean getBoolean(@NonNull String resName) {
129 | return Resources.getSystem().getBoolean(getResourceId(BOOL, resName));
130 | }
131 |
132 | /**
133 | * Pick color resources from com.android.internal.R.color
134 | *
135 | * @return internal color
136 | */
137 | public static int getColor(@NonNull String resName) {
138 | return Resources.getSystem().getColor(getResourceId(COLOR, resName));
139 | }
140 |
141 | /**
142 | * Pick dimension resources from com.android.internal.R.dimen
143 | *
144 | * @return internal dimension
145 | */
146 | public static float getDimension(@NonNull String resName) {
147 | return Resources.getSystem().getDimension(getResourceId(DIMEN, resName));
148 | }
149 |
150 | /**
151 | * Pick Drawable
resources from com.android.internal.R.drawable
152 | *
153 | * @return internal Drawable
154 | */
155 | @SuppressLint("UseCompatLoadingForDrawables")
156 | public static Drawable getDrawable(@NonNull String resName) {
157 | return Resources.getSystem().getDrawable(getResourceId(DRAWABLE, resName));
158 | }
159 |
160 | /**
161 | * Pick Drawable
resources from com.android.internal.R.drawable
162 | *
163 | * @return internal Drawable
164 | */
165 | @SuppressLint("UseCompatLoadingForDrawables")
166 | public static Drawable getDrawable(@NonNull String resName, Resources.Theme theme) {
167 | return Resources.getSystem().getDrawable(getResourceId(DRAWABLE, resName), theme);
168 | }
169 |
170 | /**
171 | * Pick fractional unit resources from com.android.internal.R.fraction
172 | *
173 | * @return internal fractional unit
174 | */
175 | public static float getFraction(@NonNull String resName, int base, int pbase) {
176 | return Resources.getSystem().getFraction(getResourceId(FRACTION, resName), base, pbase);
177 | }
178 |
179 | /**
180 | * Pick Integer
resources from com.android.internal.R.integer
181 | *
182 | * @return internal Integer
183 | */
184 | public static int getInteger(@NonNull String resName) {
185 | return Resources.getSystem().getInteger(getResourceId(INTEGER, resName));
186 | }
187 |
188 | /**
189 | * Pick layout resources from com.android.internal.R.layout
190 | *
191 | * @return internal XmlResourceParser
layout
192 | */
193 | public static XmlResourceParser getLayout(@NonNull String resName) {
194 | return Resources.getSystem().getLayout(getResourceId(LAYOUT, resName));
195 | }
196 |
197 | /**
198 | * Pick menu resources from com.android.internal.R.menu
199 | *
200 | * @return internal XmlResourceParser
menu
201 | */
202 | public static XmlResourceParser getMenu(@NonNull String resName) {
203 | return Resources.getSystem().getLayout(getResourceId(MENU, resName));
204 | }
205 |
206 | /**
207 | * Pick mipmap drawable resources from com.android.internal.R.mipmap
208 | *
209 | * @return internal Drawable
mipmap
210 | */
211 | @SuppressLint("UseCompatLoadingForDrawables")
212 | public static Drawable getMipmap(@NonNull String resName) {
213 | return Resources.getSystem().getDrawable(getResourceId(MIPMAP, resName));
214 | }
215 |
216 | /**
217 | * Pick mipmap drawable resources from com.android.internal.R.mipmap
218 | *
219 | * @return internal Drawable
mipmap
220 | */
221 | @SuppressLint("UseCompatLoadingForDrawables")
222 | public static Drawable getMipmap(@NonNull String resName, Resources.Theme theme) {
223 | return Resources.getSystem().getDrawable(getResourceId(MIPMAP, resName), theme);
224 | }
225 |
226 | /**
227 | * Pick RAW resources from com.android.internal.R.raw
228 | *
229 | * @return internal InputStream
raw
230 | */
231 | public static InputStream getRaw(@NonNull String resName) {
232 | return Resources.getSystem().openRawResource(getResourceId(RAW, resName));
233 | }
234 |
235 | /**
236 | * Pick Integer
array resources from com.android.internal.R.array
237 | *
238 | * @return internal Integer
array
239 | */
240 | public static int[] getIntArray(@NonNull String resName) {
241 | return Resources.getSystem().getIntArray(getResourceId(ARRAY, resName));
242 | }
243 |
244 | /**
245 | * Pick String
array resources from com.android.internal.R.array
246 | *
247 | * @param resName for example = emailAddressTypes
248 | * @return internal String
array
249 | */
250 | public static String[] getStringArray(@NonNull String resName) {
251 | return Resources.getSystem().getStringArray(getResourceId(ARRAY, resName));
252 | }
253 |
254 | /**
255 | * Pick string resources from com.android.internal.R.string
256 | *
257 | * @param resName for example = accept, cancel, upload_file, find_on_page
258 | * @return internal String
259 | */
260 | public static String getString(@NonNull String resName) {
261 | return Resources.getSystem().getString(getResourceId(STRING, resName));
262 | }
263 |
264 | /**
265 | * Pick XML resources from com.android.internal.R.xml
266 | *
267 | * @return internal XmlResourceParser
XML
268 | */
269 | public static XmlResourceParser getXml(@NonNull String resName) {
270 | return Resources.getSystem().getXml(getResourceId(XML, resName));
271 | }
272 |
273 | /**
274 | * Check whether a class exists, and do your action when it's return true
.
275 | *
276 | * @param className class name with its package, e.g. android.content.Intent
277 | * @return true if the class exists
278 | */
279 | public static boolean isClassExists(String className) {
280 | try {
281 | Class.forName(className);
282 | return true;
283 | } catch (ClassNotFoundException e) {
284 | return false;
285 | }
286 | }
287 |
288 | /**
289 | * Check whether a method exists within its class. An example for this method is:
290 | *
291 | * boolean methodExists = InternalAccessor.isMethodExists("android.content.Intent", "putExtra", String.class, Integer.class);
292 | * if (methodExists){
293 | * ...
294 | * }
295 | *
296 | * where putExtra()
has two types of parameter, i.e. String
and
297 | * Integer
.
298 | * If you look at the source code, you'll see that the real method is: putExtra(String
299 | * name, int value)
.
300 | * See {@link InternalAccessor#isMethodExists(String, String)}
301 | *
302 | * @param className class name with its package, e.g. android.content.Intent
303 | * @param methodName method name within its class, e.g. putExtra
304 | * @param parameterTypes class of the method's parameter type, e.g. for putExtra(String
305 | * name, int value)
,
306 | * you should type String.class, Integer.class
307 | * @return true
if the method exists, false
otherwise or the class
308 | * could not be found
309 | */
310 | public static boolean isMethodExists(String className, String methodName,
311 | Class>... parameterTypes) {
312 | try {
313 | Class> cls = Class.forName(className);
314 | cls.getMethod(methodName, parameterTypes);
315 | return true;
316 | } catch (ClassNotFoundException | NoSuchMethodException e) {
317 | return false;
318 | }
319 | }
320 |
321 | /**
322 | * Check whether a method exists without checking its parameter types. This is similar with
323 | * {@link InternalAccessor#isMethodExists(String, String, Class[])}
324 | *
325 | * @param className class name with its package, e.g. android.content.Intent
326 | * @param methodName method name within its class, e.g. putExtra
327 | * @return true
if the method exists, false
otherwise or the class
328 | * could not be found
329 | */
330 | public static boolean isMethodExists(String className, String methodName) {
331 | try {
332 | Class> cls = Class.forName(className);
333 | for (Method method : cls.getDeclaredMethods())
334 | if (method.getName().equals(methodName))
335 | return true;
336 | } catch (ClassNotFoundException e) {
337 | }
338 | return false;
339 | }
340 |
341 | /**
342 | * @deprecated since we don't use Context
and Java reflection to get the internal
343 | * resources, so using this
344 | * Builder
is redundant. Get them directly without storing to this class or {@link
345 | * ResourcesHolder}
346 | */
347 | public static class Builder {
348 |
349 | final boolean saveToResourcesHolder;
350 |
351 | ResourcesHolder holder = new ResourcesHolder();
352 |
353 | /**
354 | * @param saveToResourcesHolder determine whether once we get the value also store it to
355 | * ResourcesHolder
automatically. The key for
356 | * every data stored to
357 | * ResourcesHolder
always uses
358 | * resName
359 | * argument of the method.
360 | */
361 | public Builder(boolean saveToResourcesHolder) {
362 | this.saveToResourcesHolder = saveToResourcesHolder;
363 | }
364 |
365 | public ResourcesHolder getResourcesHolder() {
366 | return holder;
367 | }
368 |
369 | /**
370 | * Replacement for {@link InternalAccessor#getAnimation(String)}
371 | */
372 | public XmlResourceParser getAnimation(@NonNull String resName) {
373 | XmlResourceParser anim = InternalAccessor.getAnimation(resName);
374 | if (saveToResourcesHolder)
375 | holder.put(resName, anim);
376 | return anim;
377 | }
378 |
379 | /**
380 | * Replacement for {@link InternalAccessor#getBoolean(String)}
381 | */
382 | public boolean getBoolean(@NonNull String resName) {
383 | boolean bol = InternalAccessor.getBoolean(resName);
384 | if (saveToResourcesHolder)
385 | holder.put(resName, bol);
386 | return bol;
387 | }
388 |
389 | /**
390 | * Replacement for {@link InternalAccessor#getColor(String)}
391 | */
392 | public int getColor(@NonNull String resName) {
393 | int color = InternalAccessor.getColor(resName);
394 | if (saveToResourcesHolder)
395 | holder.put(resName, color);
396 | return color;
397 | }
398 |
399 | /**
400 | * Replacement for {@link InternalAccessor#getDimension(String)}
401 | */
402 | public float getDimension(@NonNull String resName) {
403 | float dimens = InternalAccessor.getDimension(resName);
404 | if (saveToResourcesHolder)
405 | holder.put(resName, dimens);
406 | return dimens;
407 | }
408 |
409 | /**
410 | * Replacement for {@link InternalAccessor#getDrawable(String)}
411 | */
412 | public Drawable getDrawable(@NonNull String resName) {
413 | Drawable drawable = InternalAccessor.getDrawable(resName);
414 | if (saveToResourcesHolder)
415 | holder.put(resName, drawable);
416 | return drawable;
417 | }
418 |
419 | /**
420 | * Replacement for {@link InternalAccessor#getFraction(String, int, int)}
421 | */
422 | public float getFraction(@NonNull String resName, int base, int pbase) {
423 | float fract = InternalAccessor.getFraction(resName, base, pbase);
424 | if (saveToResourcesHolder)
425 | holder.put(resName, fract);
426 | return fract;
427 | }
428 |
429 | /**
430 | * Replacement for {@link InternalAccessor#getInteger(String)}
431 | */
432 | public int getInteger(@NonNull String resName) {
433 | int integer = InternalAccessor.getInteger(resName);
434 | if (saveToResourcesHolder)
435 | holder.put(resName, integer);
436 | return integer;
437 | }
438 |
439 | /**
440 | * Replacement for {@link InternalAccessor#getLayout(String)}
441 | */
442 | public XmlResourceParser getLayout(@NonNull String resName) {
443 | XmlResourceParser layout = InternalAccessor.getLayout(resName);
444 | if (saveToResourcesHolder)
445 | holder.put(resName, layout);
446 | return layout;
447 | }
448 |
449 | /**
450 | * Replacement for {@link InternalAccessor#getMenu(String)}
451 | */
452 | public XmlResourceParser getMenu(@NonNull String resName) {
453 | XmlResourceParser menu = InternalAccessor.getMenu(resName);
454 | if (saveToResourcesHolder)
455 | holder.put(resName, menu);
456 | return menu;
457 | }
458 |
459 | /**
460 | * Replacement for {@link InternalAccessor#getMipmap(String)}
461 | */
462 | public Drawable getMipmap(@NonNull String resName) {
463 | Drawable mipmap = InternalAccessor.getMipmap(resName);
464 | if (saveToResourcesHolder)
465 | holder.put(resName, mipmap);
466 | return mipmap;
467 | }
468 |
469 | /**
470 | * Replacement for {@link InternalAccessor#getRaw(String)}
471 | */
472 | public InputStream getRaw(@NonNull String resName) {
473 | InputStream stream = InternalAccessor.getRaw(resName);
474 | if (saveToResourcesHolder)
475 | holder.put(resName, stream);
476 | return stream;
477 | }
478 |
479 | /**
480 | * Replacement for {@link InternalAccessor#getIntArray(String)}
481 | */
482 | public int[] getIntArray(@NonNull String resName) {
483 | int[] ints = InternalAccessor.getIntArray(resName);
484 | if (saveToResourcesHolder)
485 | holder.put(resName, ints);
486 | return ints;
487 | }
488 |
489 | /**
490 | * Replacement for {@link InternalAccessor#getStringArray(String)}
491 | */
492 | public String[] getStringArray(@NonNull String resName) {
493 | String[] strings = InternalAccessor.getStringArray(resName);
494 | if (saveToResourcesHolder)
495 | holder.put(resName, strings);
496 | return strings;
497 | }
498 |
499 | /**
500 | * Replacement for {@link InternalAccessor#getString(String)}
501 | */
502 | public String getString(@NonNull String resName) {
503 | String string = InternalAccessor.getString(resName);
504 | if (saveToResourcesHolder)
505 | holder.put(resName, string);
506 | return string;
507 | }
508 |
509 | /**
510 | * Replacement for {@link InternalAccessor#getXml(String)}
511 | */
512 | public XmlResourceParser getXml(@NonNull String resName) {
513 | XmlResourceParser xml = InternalAccessor.getXml(resName);
514 | if (saveToResourcesHolder)
515 | holder.put(resName, xml);
516 | return xml;
517 | }
518 | }
519 | }
520 |
--------------------------------------------------------------------------------
/resources-helper/src/main/java/com/anggrayudi/hiddenapi/ResourcesHolder.java:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Parcel;
6 | import android.os.Parcelable;
7 | import android.util.Log;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.localbroadcastmanager.content.LocalBroadcastManager;
11 |
12 | import java.util.Arrays;
13 | import java.util.HashMap;
14 | import java.util.Map;
15 | import java.util.Set;
16 | import java.util.TreeMap;
17 |
18 | /**
19 | * Created by Anggrayudi on 11/03/2016.
20 | * Since version 0.0.5 the uses of this class is diverted. You don't need to avoid Java reflection by storing
21 | * the internal resources you just retrieved to {@link ResourcesHolder} and send them via Broadcast, because this version
22 | * does not use Java reflection anymore. Instead, you can use this class to store any objects you
23 | * might need in other classes (like passing objects from activity to service) and send them via Broadcast.
24 | *
25 | * Obsolete documentation (v0.0.4 and lower)
26 | * A class that holds internal resources which are retrieved by {@link InternalAccessor}.
27 | * We need to hold the resources we just retrieved, because InternalAccessor
uses reflection,
28 | * and Java reflection may slow down user's machine performance. Using reflection every time you reflect the
29 | * same value is not a good practice. So, use this class instead.
30 | * Also, you can use this class to holds non-internal resources, according to your needs.
31 | *
32 | *
An example to use this class is:
33 | *
34 | * ResourcesHolder holder = new ResourcesHolder()
35 | * .putString("my_string_key", InternalAccessor.getString("accept"))
36 | * .putResourceId("my_res_id_key", InternalAccessor.getResourceId("drawable", "loading_tile_android");
37 | *
38 | * // Retrieve the values from another place
39 | * holder.getString("my_string_key");
40 | * holder.getResourceId("my_res_id_key");
41 | *
42 | * // If you plan to send 'holder' to another class via BroadcastReceiver or LocalBroadcastManager
43 | * Intent intent = new Intent(ResourcesHolder.ACTION_SEND_RESOURCES_HOLDER);
44 | * intent.putExtra("holder", holder);
45 | *
46 | * // send via LocalBroadcastManager
47 | * LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
48 | *
49 | * // send via BroadcastReceiver
50 | * sendBroadcast(intent);
51 | *
52 | * // Instead, you can do this in simple way
53 | * holder.sendBroadcast(this, "holder");
54 | * // or with this
55 | * holder.sendViaLocalBroadcastManager(this, "holder");
56 | *
57 | */
58 | public class ResourcesHolder implements Parcelable {
59 | public static final String ACTION_SEND_RESOURCES_HOLDER = "com.anggrayudi.hiddenapi.ACTION_SEND_RESOURCES_HOLDER";
60 | public static final Creator CREATOR = new Creator() {
61 | @Override
62 | public ResourcesHolder createFromParcel(Parcel in) {
63 | return new ResourcesHolder(in);
64 | }
65 |
66 | @Override
67 | public ResourcesHolder[] newArray(int size) {
68 | return new ResourcesHolder[size];
69 | }
70 | };
71 | private static final String TAG = "ResourcesHolder";
72 | private HashMap mValues = new HashMap<>();
73 |
74 | public ResourcesHolder() {
75 | }
76 |
77 | @SuppressWarnings("unchecked")
78 | private ResourcesHolder(Parcel in) {
79 | mValues = (HashMap) in.readValue(HashMap.class.getClassLoader());
80 | }
81 |
82 | public ResourcesHolder put(String key, short value) {
83 | mValues.put(key, value);
84 | return this;
85 | }
86 |
87 | public ResourcesHolder put(String key, byte value) {
88 | mValues.put(key, value);
89 | return this;
90 | }
91 |
92 | public ResourcesHolder put(String key, char value) {
93 | mValues.put(key, value);
94 | return this;
95 | }
96 |
97 | public ResourcesHolder put(String key, boolean value) {
98 | mValues.put(key, value);
99 | return this;
100 | }
101 |
102 | public ResourcesHolder put(String key, int value) {
103 | mValues.put(key, value);
104 | return this;
105 | }
106 |
107 | public ResourcesHolder put(String key, long value) {
108 | mValues.put(key, value);
109 | return this;
110 | }
111 |
112 | public ResourcesHolder put(String key, float value) {
113 | mValues.put(key, value);
114 | return this;
115 | }
116 |
117 | public ResourcesHolder put(String key, double value) {
118 | mValues.put(key, value);
119 | return this;
120 | }
121 |
122 | public ResourcesHolder put(String key, String value) {
123 | mValues.put(key, value);
124 | return this;
125 | }
126 |
127 | /**
128 | * An additional method to holds an Object
, for non-primitive data types. For example
129 | * Drawable, XmlResourceParser,
etc. To retrieve it back to the original object,
130 | * cast it to its origin class. You also can store an array here. An example of using this method is:
131 | *
132 | * List<String> strs = new ArrayList<>();
133 | * strs.add("FOO");
134 | * strs.add("BXY");
135 | *
136 | * Person[] persons = {new Person(), null, new Person()};
137 | *
138 | * XmlResourceParser parser = getResources().getXml(R.xml.preferences);
139 | *
140 | * ResourcesHolder holder = new ResourcesHolder()
141 | * .put("arrayInt", new int[]{9, 8, 5})
142 | * .put("arrayStringList", strs)
143 | * .put("arrayPerson", persons)
144 | * .put("my_parser", parser);
145 | *
146 | * // Then, retrieve them back to the original form
147 | * int[] ints = holder.getAsIntArray("arrayInt");
148 | * //noinspection unchecked
149 | * strs = (List<String>) holder.getAsObject("arrayStringList");
150 | * // cast them to the original class
151 | * persons = (Person[]) holder.getAsObject("arrayPerson");
152 | * parser = (XmlResourceParser) holder.getAsObject("my_parser");
153 | *
154 | */
155 | public ResourcesHolder put(String key, Object object) {
156 | mValues.put(key, object);
157 | return this;
158 | }
159 |
160 | public short getAsShort(String key) {
161 | return isCompatibleCast(key, Short.class) ? (short) mValues.get(key) : 0;
162 | }
163 |
164 | public byte getAsByte(String key) {
165 | return isCompatibleCast(key, Byte.class) ? (byte) mValues.get(key) : 0;
166 | }
167 |
168 | public char getAsChar(String key) {
169 | return isCompatibleCast(key, Character.class) ? (char) mValues.get(key) : '\u0000';
170 | }
171 |
172 | public boolean getAsBoolean(String key) {
173 | return isCompatibleCast(key, Boolean.class) && (boolean) mValues.get(key);
174 | }
175 |
176 | /**
177 | * Some resources use this data type, they are color, resourceId
and integerResource
.
178 | * You also can get any integer here.
179 | */
180 | public int getAsInteger(String key) {
181 | return isCompatibleCast(key, Integer.class) ? (int) mValues.get(key) : 0;
182 | }
183 |
184 | public long getAsLong(String key) {
185 | return isCompatibleCast(key, Long.class) ? (long) mValues.get(key) : 0;
186 | }
187 |
188 | /**
189 | * Some resources use this data type, they are dimension
and fraction
.
190 | * You also can get any float
here.
191 | */
192 | public float getAsFloat(String key) {
193 | return isCompatibleCast(key, Float.class) ? (float) mValues.get(key) : 0;
194 | }
195 |
196 | public double getAsDouble(String key) {
197 | return isCompatibleCast(key, Double.class) ? (double) mValues.get(key) : 0;
198 | }
199 |
200 | public String getAsString(String key) {
201 | return isCompatibleCast(key, String.class) ? (String) mValues.get(key) : null;
202 | }
203 |
204 | public short[] getAsShortArray(String key) {
205 | return isCompatibleCast(key, short[].class) ? (short[]) mValues.get(key) : null;
206 | }
207 |
208 | public byte[] getAsByteArray(String key) {
209 | return isCompatibleCast(key, byte[].class) ? (byte[]) mValues.get(key) : null;
210 | }
211 |
212 | public char[] getAsCharArray(String key) {
213 | return isCompatibleCast(key, char[].class) ? (char[]) mValues.get(key) : null;
214 | }
215 |
216 | public boolean[] getAsBooleanArray(String key) {
217 | return isCompatibleCast(key, boolean[].class) ? (boolean[]) mValues.get(key) : null;
218 | }
219 |
220 | public int[] getAsIntArray(String key) {
221 | return isCompatibleCast(key, int[].class) ? (int[]) mValues.get(key) : null;
222 | }
223 |
224 | public long[] getAsLongArray(String key) {
225 | return isCompatibleCast(key, long[].class) ? (long[]) mValues.get(key) : null;
226 | }
227 |
228 | public float[] getAsFloatArray(String key) {
229 | return isCompatibleCast(key, float[].class) ? (float[]) mValues.get(key) : null;
230 | }
231 |
232 | public double[] getAsDoubleArray(String key) {
233 | return isCompatibleCast(key, double[].class) ? (double[]) mValues.get(key) : null;
234 | }
235 |
236 | public String[] getAsStringArray(String key) {
237 | return isCompatibleCast(key, String[].class) ? (String[]) mValues.get(key) : null;
238 | }
239 |
240 | /**
241 | * Get any values that is stored as Object
, i.e. for non-primitive data types.
242 | * They can be an array or an instance from a class.
243 | */
244 | public Object getAsObject(String key) {
245 | return mValues.get(key);
246 | }
247 |
248 | /**
249 | * This method equals with {@link Context#sendBroadcast(Intent)}. Notice that the Intent
250 | * uses {@link ResourcesHolder#ACTION_SEND_RESOURCES_HOLDER} action. So that, register your
251 | * BroadcastReceiver
with that action to make it able to receive the extra from Intent
.
252 | * See {@link ResourcesHolder#sendViaLocalBroadcastManager(Context, String)}
253 | *
254 | * @param key key for the Intent
255 | */
256 | public void sendBroadcast(Context context, @NonNull String key) {
257 | Intent intent = new Intent(ACTION_SEND_RESOURCES_HOLDER);
258 | intent.putExtra(key, this);
259 | context.sendBroadcast(intent);
260 | }
261 |
262 | /**
263 | * Send ResourcesHolder
instance to another class via LocalBroadcastManager
.
264 | * Make sure that the BroadcastReceiver
is registered with
265 | * {@link ResourcesHolder#ACTION_SEND_RESOURCES_HOLDER} action.
266 | *
267 | * @param key key for the Intent
268 | */
269 | public void sendViaLocalBroadcastManager(Context context, @NonNull String key) {
270 | Intent intent = new Intent(ACTION_SEND_RESOURCES_HOLDER);
271 | intent.putExtra(key, this);
272 | LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
273 | }
274 |
275 | /**
276 | * Clear all values that is saved in this class.
277 | */
278 | public void clear() {
279 | mValues.clear();
280 | }
281 |
282 | public int size() {
283 | return mValues.size();
284 | }
285 |
286 | public boolean containsKey(String key) {
287 | return mValues.containsKey(key);
288 | }
289 |
290 | /**
291 | * Remove a value by key.
292 | */
293 | public void remove(String key) {
294 | mValues.remove(key);
295 | }
296 |
297 | /**
298 | * Sort ResourcesHolder
by keys.
299 | *
300 | * @param descending or set to false
to make it ascending
301 | */
302 | public void sort(boolean descending) {
303 | TreeMap treeMap = new TreeMap<>(mValues);
304 | if (descending) {
305 | treeMap.descendingMap();
306 | }
307 | mValues.clear();
308 | mValues.putAll(treeMap);
309 | }
310 |
311 | /**
312 | * Returns a set of all of the keys and values
313 | *
314 | * @return a set of all of the keys and values
315 | */
316 | public Set> valueSet() {
317 | return mValues.entrySet();
318 | }
319 |
320 | /**
321 | * Returns a set of all of the keys
322 | *
323 | * @return a set of all of the keys
324 | */
325 | public Set keySet() {
326 | return mValues.keySet();
327 | }
328 |
329 | /**
330 | * Print all values that is saved via put*(Key, Value)
method.
331 | */
332 | public void printAll() {
333 | for (Map.Entry entry : mValues.entrySet()) {
334 |
335 | Object value = entry.getValue();
336 | String toPrint = value.toString();
337 |
338 | if (value.getClass().isArray()) {
339 | if (value instanceof boolean[])
340 | toPrint = Arrays.toString((boolean[]) value);
341 | else if (value instanceof int[])
342 | toPrint = Arrays.toString((int[]) value);
343 | else if (value instanceof long[])
344 | toPrint = Arrays.toString((long[]) value);
345 | else if (value instanceof float[])
346 | toPrint = Arrays.toString((float[]) value);
347 | else if (value instanceof double[])
348 | toPrint = Arrays.toString((double[]) value);
349 | else if (value instanceof String[])
350 | toPrint = Arrays.toString((String[]) value);
351 | else if (value instanceof short[])
352 | toPrint = Arrays.toString((short[]) value);
353 | else if (value instanceof byte[])
354 | toPrint = Arrays.toString((byte[]) value);
355 | else if (value instanceof char[])
356 | toPrint = Arrays.toString((char[]) value);
357 | }
358 | Log.d(TAG, "key = " + entry.getKey() + ", value = " + toPrint);
359 | }
360 | }
361 |
362 | /**
363 | * Determine whether an Object
is able to be casted to another class.
364 | *
365 | * @return true
if the object is able to be casted.
366 | */
367 | private boolean isCompatibleCast(String key, Class> classToCast) {
368 | Object obj = mValues.get(key);
369 | try {
370 | if (mValues.get(key) instanceof Number && obj == null) {
371 | Log.e(TAG, "Cannot cast null value to a " + classToCast.getSimpleName() + " number format.");
372 | return false;
373 | }
374 |
375 | classToCast.cast(obj);
376 | return true;
377 | } catch (ClassCastException e) {
378 | Log.e(TAG, "Cannot cast object value from " + obj + " to " + classToCast.getSimpleName() + " for key '" + key + "'", e);
379 | return false;
380 | }
381 | }
382 |
383 | @Override
384 | public int describeContents() {
385 | return 0;
386 | }
387 |
388 | @Override
389 | public void writeToParcel(Parcel dest, int flags) {
390 | dest.writeValue(mValues);
391 | }
392 | }
393 |
--------------------------------------------------------------------------------
/resources-helper/src/test/java/com/anggrayudi/hiddenapi/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * @see [Testing documentation](http://d.android.com/tools/testing)
10 | */
11 | class ExampleUnitTest {
12 |
13 | @Test
14 | fun addition_isCorrect() {
15 | Assert.assertEquals(4, 2 + 2.toLong())
16 | }
17 | }
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | namespace 'com.anggrayudi.hiddenapi.sample'
7 |
8 | defaultConfig {
9 | multiDexEnabled true
10 | }
11 |
12 | signingConfigs {
13 | debug {
14 | keyAlias 'androiddebugkey'
15 | keyPassword 'android'
16 | storePassword 'android'
17 | storeFile file("${System.properties['user.home']}${File.separator}.android${File.separator}debug.keystore")
18 | }
19 | }
20 |
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25 | signingConfig signingConfigs.debug
26 | }
27 | }
28 |
29 | lintOptions {
30 | abortOnError false
31 | }
32 |
33 | buildFeatures {
34 | viewBinding = true
35 | }
36 |
37 | flavorDimensions = ["librarySource"]
38 | productFlavors {
39 | local {
40 | dimension "librarySource"
41 | getIsDefault().set(true)
42 | }
43 | maven {
44 | dimension "librarySource"
45 | configurations.all {
46 | // Check for updates every build
47 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
48 | }
49 | }
50 | }
51 | }
52 |
53 | dependencies {
54 | // Testing
55 | testImplementation 'junit:junit:4.13.2'
56 |
57 | implementation fileTree(dir: 'libs', include: ['*.jar'])
58 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
59 | implementation 'androidx.multidex:multidex:2.0.1'
60 | implementation 'androidx.appcompat:appcompat:1.7.0'
61 | implementation "androidx.core:core-ktx:1.15.0"
62 | implementation 'com.jakewharton.timber:timber:5.0.1'
63 |
64 | implementation project(':resources-helper')
65 | // If you want to modify this library's source code, set build variant to 'local'.
66 | // localImplementation project(':resources-helper')
67 | // mavenImplementation("com.anggrayudi:android-hidden-api:$VERSION_NAME") { changing = true }
68 | }
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
10 |
11 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/anggrayudi/hiddenapi/sample/Adapter.kt:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi.sample
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.BaseAdapter
8 | import android.widget.TextView
9 |
10 | /** Created by Anggrayudi on 11/03/2016. */
11 | class Adapter(private val models: List = emptyList()) : BaseAdapter() {
12 |
13 | private class ViewHolder(val source: TextView, val result: TextView, val desc: TextView)
14 |
15 | override fun getCount() = models.size
16 |
17 | override fun getItem(position: Int) = models[position]
18 |
19 | override fun getItemId(position: Int) = position.toLong()
20 |
21 | override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
22 | var view = convertView
23 | if (view == null) {
24 | val inflater =
25 | parent.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
26 | view = inflater.inflate(R.layout.list_layout, parent, false)
27 | view.tag =
28 | ViewHolder(
29 | view.findViewById(R.id.source),
30 | view.findViewById(R.id.result),
31 | view.findViewById(R.id.desc),
32 | )
33 | }
34 | val holder = view!!.tag as ViewHolder
35 | val (source, result, description) = models[position]
36 | holder.source.text = source
37 | holder.result.visibility = if (result.isNullOrEmpty()) View.GONE else View.VISIBLE
38 | holder.result.text = "Result = $result"
39 | holder.desc.visibility = if (description.isNullOrEmpty()) View.GONE else View.VISIBLE
40 | holder.desc.text = description
41 | return view
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/anggrayudi/hiddenapi/sample/App.kt:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi.sample
2 |
3 | import androidx.multidex.MultiDexApplication
4 | import timber.log.Timber
5 |
6 | /**
7 | * Created on 17/01/25
8 | *
9 | * @author Anggrayudi Hardiannico A.
10 | */
11 | class App : MultiDexApplication() {
12 |
13 | override fun onCreate() {
14 | super.onCreate()
15 | Timber.plant(Timber.DebugTree())
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/anggrayudi/hiddenapi/sample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi.sample
2 |
3 | // import android.net.wifi.WifiLinkLayerStats
4 | import android.content.Intent
5 | import android.net.Uri
6 | import android.os.Build
7 | import android.os.Bundle
8 | import android.text.Editable
9 | import android.view.MenuItem
10 | import android.widget.AdapterView.OnItemClickListener
11 | import androidx.appcompat.app.AppCompatActivity
12 | import com.anggrayudi.hiddenapi.InternalAccessor
13 | import com.anggrayudi.hiddenapi.sample.databinding.ActivityMainBinding
14 | import timber.log.Timber
15 |
16 | /**
17 | * Created by Anggrayudi on 11/03/2016.
18 | *
19 | * An example class for Hidden API.
20 | *
21 | * If you plan to use only Android internal resources rather than internal classes or methods, just
22 | * add
`compile 'com.anggrayudi:android-hidden-api:30.0'`
library to your app's
23 | * module without need to replace `android.jar`. This version does not use Java reflection anymore,
24 | * and certainly safe. See the [Usage](https://github.com/anggrayudi/android-hidden-api#usage).
25 | */
26 | class MainActivity : AppCompatActivity() {
27 |
28 | private lateinit var binding: ActivityMainBinding
29 |
30 | override fun onCreate(savedInstanceState: Bundle?) {
31 | super.onCreate(savedInstanceState)
32 | binding = ActivityMainBinding.inflate(layoutInflater)
33 | setContentView(binding.root)
34 | setSupportActionBar(binding.toolbar)
35 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
36 |
37 | // Test if Editable included in custom android.jar
38 | var editable: Editable
39 |
40 | val items =
41 | mutableListOf(
42 | // Model(
43 | // /*
44 | // formatShortElapsedTime method will show error 'Cannot resolve
45 | // symbol'
46 | // if you don't use custom android.jar
47 | // Since custom android.jar v28, some methods are no longer
48 | // accessible. I
49 | // don't know why.
50 | // Android Studio will say, "formatShortElapsedTime has private
51 | // access".
52 | // A workaround is you HAVE TO copy this static method into your own
53 | // code.
54 | // */
55 | // "Formatter.formatShortElapsedTime(this, 100000000)",
56 | // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
57 | // Formatter.formatShortElapsedTime(this, 100000000) else null,
58 | // """
59 | // Accessing hidden method. This method only available for API 21+.
60 | // If
61 | // you run it on a device with API 20 and lower,
62 | // you'll get java.lang.NoSuchMethodError exception.
63 | // """.trimIndent()
64 | // ),
65 | Model(
66 | "com.android.internal.R.string.accept",
67 | description =
68 | "Accessing hidden String resource. We cannot access internal resources directly. " +
69 | "Sometimes, IDE says 'error: cannot find symbol variable accept' " +
70 | "once you run the app, or your app picks wrong resource id. If you want to have the internal resources, " +
71 | "copy them to your project or use InternalAccessor utility class. Below are the example.",
72 | ),
73 | Model(
74 | "InternalAccessor.getString(\"accept\")",
75 | InternalAccessor.getString("accept"),
76 | "Accessing hidden String resource. Because above method is not working, " +
77 | "so we need to use InternalAccessor.getString() method.",
78 | ),
79 | )
80 | items.add(
81 | Model(
82 | "InternalAccessor.getDimension(\"status_bar_height\")",
83 | InternalAccessor.getDimension("status_bar_height").toString(),
84 | "Accessing hidden dimension resource.",
85 | )
86 | )
87 | items.add(
88 | Model(
89 | "InternalAccessor.getColor(\"config_defaultNotificationColor\")",
90 | InternalAccessor.getColor("config_defaultNotificationColor").toString(),
91 | "Accessing hidden color resource.",
92 | )
93 | )
94 | items.add(
95 | Model(
96 | "Info",
97 | description =
98 | "For more information, download this app's source code on " +
99 | "https://github.com/anggrayudi/android-hidden-api",
100 | )
101 | )
102 |
103 | binding.listView.adapter = Adapter(items)
104 | binding.listView.onItemClickListener = OnItemClickListener { _, _, position, _ ->
105 | if (position == items.size - 1) {
106 | startActivity(
107 | Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/anggrayudi/android-hidden-api"))
108 | )
109 | }
110 | }
111 |
112 | if (Build.VERSION.SDK_INT >= 22) {
113 | /*
114 | Accessing WifiLinkLayerStats that is a hidden class.
115 | If you want to find out which API was built to, just type method, resource or class name
116 | to search box on http://jcs.mobile-utopia.com/servlet/Source?type=s&q=WifiLinkLayerStats
117 | And then, look at 'Category' column.
118 |
119 | WifiLinkLayerStats method will show error 'Cannot resolve symbol' if you don't use custom android.jar
120 | For source code: http://jcs.mobile-utopia.com/jcs/7601_WifiLinkLayerStats.java
121 | */
122 | // var wifiLinkLayer: WifiLinkLayerStats
123 | }
124 |
125 | // If you want to check whether WifiLinkLayerStats exists without checking API level, you
126 | // can
127 | // call:
128 | val isClassExists = InternalAccessor.isClassExists("android.net.wifi.WifiLinkLayerStats")
129 | Timber.d("isClassExists = $isClassExists")
130 |
131 | // Check whether a method exists
132 | val isMethodExists = InternalAccessor.isMethodExists("android.content.Intent", "getExtra")
133 | Timber.d("isMethodExists = $isMethodExists")
134 |
135 | // This will retrieve resource id named accelerate_cubic in
136 | // com.android.internal.R.interpolator
137 | // class.
138 | Timber.d(
139 | "interpolator.accelerate_cubic = %s",
140 | InternalAccessor.getResourceId(InternalAccessor.INTERPOLATOR, "accelerate_cubic"),
141 | )
142 | Timber.d(
143 | "plurals.duration_hours = %s",
144 | InternalAccessor.getResourceId(InternalAccessor.PLURALS, "last_num_days"),
145 | )
146 | Timber.d(
147 | "transition.no_transition = %s",
148 | InternalAccessor.getResourceId(InternalAccessor.TRANSITION, "no_transition"),
149 | )
150 |
151 | /*
152 | DEPRECATED EXAMPLE OF InternalAccessor.Builder
153 |
154 | // Using InternalAccessor with other code styling
155 | InternalAccessor.Builder builder = new InternalAccessor.Builder(true);
156 | boolean b = builder.getBoolean("config_sip_wifi_only");
157 | String accept = builder.getString("accept");
158 |
159 | // Because we set true to 'saveToResourcesHolder' in the Builder constructor, every value we got always
160 | // saved to ResourcesHolder automatically. We can retrieve the holder now:
161 | ResourcesHolder accessorHolder = builder.getResourcesHolder();
162 | b = accessorHolder.getAsBoolean("config_sip_wifi_only");
163 | accept = accessorHolder.getAsString("accept");
164 | */
165 | }
166 |
167 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
168 | if (item.itemId == android.R.id.home) finish()
169 | return super.onOptionsItemSelected(item)
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/anggrayudi/hiddenapi/sample/Model.kt:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi.sample
2 |
3 | /** Created by Anggrayudi on 11/03/2016. */
4 | data class Model(val source: String, val result: String? = null, val description: String? = null)
5 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/anggrayudi/hiddenapi/sample/Receiver.kt:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi.sample
2 |
3 | import android.content.BroadcastReceiver
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.widget.Toast
7 | import androidx.core.content.IntentCompat
8 | import com.anggrayudi.hiddenapi.ResourcesHolder
9 |
10 | /** Created by Anggrayudi on 12/03/2016. */
11 | class Receiver : BroadcastReceiver() {
12 |
13 | override fun onReceive(context: Context, intent: Intent) {
14 | Toast.makeText(context, "ResourceHolder is received. See detail on LogCat.", Toast.LENGTH_SHORT)
15 | .show()
16 | val holder =
17 | IntentCompat.getParcelableExtra(intent, "holder", ResourcesHolder::class.java) ?: return
18 | holder.sort(true)
19 | holder.printAll()
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
24 |
25 |
32 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/list_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
25 |
26 |
33 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anggrayudi/android-hidden-api/773d56dc82a162d342a9efd43c4d64fb23d515c8/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #795548
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Hidden APIs
3 | These are example from hidden API. To view the usage for
4 | hidden class, see the code in MainActivity.
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/test/java/com/anggrayudi/hiddenapi/sample/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.anggrayudi.hiddenapi.sample
2 |
3 | import org.junit.Assert
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * @see [Testing documentation](http://d.android.com/tools/testing)
10 | */
11 | class ExampleUnitTest {
12 |
13 | @Test
14 | fun addition_isCorrect() {
15 | Assert.assertEquals(4, 2 + 2.toLong())
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':resources-helper', ':sample'
--------------------------------------------------------------------------------