Init: PawletOS config APK

This commit is contained in:
oxmc
2026-06-08 03:55:11 -07:00
commit d6895db925
27 changed files with 998 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.gradle/
build/
local.properties
*.iml
.idea/

11
Android.bp Normal file
View File

@@ -0,0 +1,11 @@
android_app {
name: "PawletConfig",
srcs: [],
resource_dirs: ["res"],
certificate: "platform",
sdk_version: "current",
privileged: false,
optimize: {
enabled: false,
},
}

91
AndroidManifest.xml Normal file
View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Required if/when activated as device owner -->
<uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" />
<application
android:label="PawletConfig">
<!--
No-op activity required for icon pack discovery.
Launchers query for packages with these intent filters.
-->
<activity
android:name=".IconPackActivity"
android:exported="true"
android:label="PawletOS Icons"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- ADW / Nova / Lawnchair icon pack discovery -->
<intent-filter>
<action android:name="org.adw.launcher.THEMES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.novalauncher.THEME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Applies config on first boot after install / update -->
<receiver
android:name=".ConfigReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<!--
Partner customization receiver — discovered by Lawnchair via
com.android.launcher3.util.Partner (MATCH_SYSTEM_ONLY query).
Only active when this APK is installed as a system app (ROM build).
Lawnchair reads res/xml/partner_default_layout.xml from this package.
-->
<receiver
android:name=".PartnerCustomizationReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.launcher3.action.PARTNER_CUSTOMIZATION" />
</intent-filter>
</receiver>
<!--
ContentProvider serving partner_default_layout.xml to Lawnchair.
Works even as a user app — ConfigProvisioner writes
Settings.Secure["launcher3.layout.provider"] = "app.pawlet.config.layout"
and Lawnchair reads the layout from this provider.
-->
<provider
android:name=".LayoutProvider"
android:authorities="app.pawlet.config.layout"
android:exported="true"
android:readPermission="android.permission.READ_LAUNCHER_LAYOUTS" />
<!--
Device admin receiver — required for Device Owner mode.
Activation is intentionally NOT done automatically; see ConfigReceiver.
To activate:
adb shell dpm set-device-owner app.pawlet.config/.PawletDeviceAdminReceiver
-->
<receiver
android:name=".PawletDeviceAdminReceiver"
android:exported="true"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
</application>
</manifest>

53
build.gradle Normal file
View File

@@ -0,0 +1,53 @@
plugins {
id 'com.android.application' version '8.7.3'
id 'org.jetbrains.kotlin.android' version '2.0.21'
}
android {
namespace 'app.pawlet.config'
compileSdk 36
defaultConfig {
applicationId 'app.pawlet.config'
minSdk 29
targetSdk 36
versionCode 1
versionName "1.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
java.srcDirs = ['src']
kotlin.srcDirs = ['src']
}
}
buildFeatures {
buildConfig false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.debug
}
debug {
minifyEnabled false
}
}
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.0.21'
}

2
gradle.properties Normal file
View File

@@ -0,0 +1,2 @@
android.suppressUnsupportedCompileSdk=36
android.useAndroidX=true

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

251
gradlew vendored Normal file
View File

@@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

94
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

0
res/mipmap-mdpi/.gitkeep Normal file
View File

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Default home screen layout served to Lawnchair via LayoutProvider.
Edit this file to change the default home screen on first launch.
-->
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto">
<favorite
launcher:packageName="com.vivaldi.browser"
launcher:className="com.vivaldi.browser.ChromeTabbedActivity"
launcher:screen="0"
launcher:x="0"
launcher:y="0" />
<favorite
launcher:packageName="com.android.settings"
launcher:className="com.android.settings.Settings"
launcher:screen="0"
launcher:x="1"
launcher:y="0" />
</favorites>

22
res/values/attrs.xml Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Launcher3 workspace attribute declarations — required for AAPT2 to compile
default_workspace.xml as a standalone APK. These mirror the definitions in
Launcher3's res/values/attrs.xml and are used only for resource compilation;
the actual attribute semantics are interpreted by the launcher at runtime.
-->
<resources>
<declare-styleable name="Favorite">
<attr name="packageName" format="string" />
<attr name="className" format="string" />
<attr name="screen" format="integer" />
<attr name="x" format="integer" />
<attr name="y" format="integer" />
<attr name="spanX" format="integer" />
<attr name="spanY" format="integer" />
<attr name="icon" format="reference" />
<attr name="title" format="string" />
<attr name="uri" format="string" />
<attr name="container" format="integer" />
</declare-styleable>
</resources>

0
res/xml/.gitkeep Normal file
View File

28
res/xml/appfilter.xml Normal file
View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Icon pack mappings. Add an <item> for each app icon you want to replace.
component: ComponentInfo{packageName/fully.qualified.ClassName}
drawable: name of the PNG/WebP file in res/drawable-nodpi/ (without extension)
Example:
<item component="ComponentInfo{com.android.settings/com.android.settings.Settings}"
drawable="ic_settings" />
Drop the corresponding ic_settings.png into res/drawable-nodpi/.
-->
<resources>
<!-- Settings -->
<!--
<item component="ComponentInfo{com.android.settings/com.android.settings.Settings}"
drawable="ic_settings" />
-->
<!-- Vivaldi Browser -->
<!--
<item component="ComponentInfo{com.vivaldi.browser/com.vivaldi.browser.ChromeTabbedActivity}"
drawable="ic_vivaldi" />
-->
</resources>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Default home screen layout.
Each <favorite> places an app on the home screen.
Attributes:
packageName / className — target app component
screen — screen index (0 = first page)
x / y — grid cell (0,0 = top-left)
spanX / spanY — cell span (1 = single cell)
-->
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto">
<!-- Row 0: browser -->
<favorite
launcher:packageName="com.vivaldi.browser"
launcher:className="com.vivaldi.browser.ChromeTabbedActivity"
launcher:screen="0"
launcher:x="0"
launcher:y="0" />
<!-- Row 0: settings -->
<favorite
launcher:packageName="com.android.settings"
launcher:className="com.android.settings.Settings"
launcher:screen="0"
launcher:x="1"
launcher:y="0" />
</favorites>

12
res/xml/device_admin.xml Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Device admin capabilities declared for PawletDeviceAdminReceiver.
Required to set this APK as device owner via:
adb shell dpm set-device-owner app.pawlet.config/.PawletDeviceAdminReceiver
-->
<device-admin>
<uses-policies>
<limit-password />
<disable-camera />
</uses-policies>
</device-admin>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Managed configurations applied to target apps when this APK is the Device Owner.
Applied by ConfigReceiver.applyManagedConfigs() — uncomment the code block there
and activate device owner first:
adb shell dpm set-device-owner app.pawlet.config/.PawletDeviceAdminReceiver
Each <app package="..."> block sets restrictions on that app.
Each <restriction> inside it maps to a key the target app reads via
RestrictionsManager.getApplicationRestrictions().
type attribute: "string" (default), "boolean", "integer"
-->
<managed-configs>
<!--
<app package="app.lawnchair">
<restriction key="icon_pack" value="app.pawlet.config" type="string" />
</app>
-->
<!--
<app package="dev.patrickgold.florisboard">
<restriction key="some_config_key" value="some_value" type="string" />
</app>
-->
</managed-configs>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Default home screen layout — read by Lawnchair via Partner customization
(system APK path) and via the LayoutProvider ContentProvider (user APK path).
Format is identical to Launcher3's workspace XML.
See res/xml/default_workspace.xml for attribute reference.
-->
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto">
<!-- Row 0 -->
<favorite
launcher:packageName="com.vivaldi.browser"
launcher:className="com.vivaldi.browser.ChromeTabbedActivity"
launcher:screen="0"
launcher:x="0"
launcher:y="0" />
<favorite
launcher:packageName="com.android.settings"
launcher:className="com.android.settings.Settings"
launcher:screen="0"
launcher:x="1"
launcher:y="0" />
</favorites>

92
res/xml/settings.xml Normal file
View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Settings applied by ConfigProvisioner after installing this APK.
ConfigProvisioner has WRITE_SECURE_SETTINGS and applies these as system.
Tags: <secure> → Settings.Secure
<system> → Settings.System
<global> → Settings.Global
Conditional blocks:
<if [conditions...]>
... settings applied only when ALL conditions match ...
</if>
Condition attributes on <if> (all optional, AND logic):
manufacturer="motorola" exact match, case-insensitive (Build.MANUFACTURER)
brand="motorola" exact match, case-insensitive (Build.BRAND)
model="razr" substring match, case-insensitive (Build.MODEL)
sdk="35" exact Android API level
sdk_min="31" minimum API level (inclusive)
sdk_max="34" maximum API level (inclusive)
form_factor="tablet" tablet | phone | flip | tv
feature="android.hardware.camera.flash" any PackageManager feature string
Nesting <if> inside <if> = AND (both must be true).
Put separate <if> blocks at the same level for OR-like behaviour.
-->
<settings>
<!-- Always applied -->
<!-- <secure name="launcher3.layout.provider" value="app.pawlet.config.layout" /> -->
<!-- <secure name="default_input_method" value="dev.patrickgold.florisboard/.ime.FlorisImeService" /> -->
<!-- <system name="screen_brightness" value="128" /> -->
<!-- <global name="stay_on_while_plugged_in" value="3" /> -->
<!-- Android 12 and below only -->
<!--
<if sdk_max="32">
<system name="some_legacy_key" value="1" />
</if>
-->
<!-- Android 13+ -->
<!--
<if sdk_min="33">
<secure name="some_new_key" value="1" />
</if>
-->
<!-- Motorola devices -->
<!--
<if manufacturer="motorola">
<system name="some_moto_setting" value="1" />
</if>
-->
<!-- Motorola flip/foldable devices (Razr etc.) -->
<!--
<if manufacturer="motorola" form_factor="flip">
<system name="some_flip_setting" value="1" />
</if>
-->
<!-- Tablets only -->
<!--
<if form_factor="tablet">
<system name="screen_brightness" value="200" />
</if>
-->
<!-- Phones only -->
<!--
<if form_factor="phone">
<system name="screen_brightness" value="128" />
</if>
-->
<!-- Devices with a front-facing camera -->
<!--
<if feature="android.hardware.camera.front">
<secure name="some_camera_setting" value="1" />
</if>
-->
<!-- Raspberry Pi 5 (by model substring) -->
<!--
<if model="Raspberry Pi 5">
<system name="some_rpi5_setting" value="1" />
</if>
-->
</settings>

23
res/xml/shortcuts.xml Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
App shortcuts exposed to the launcher long-press menu.
Add <shortcut> entries per app that should have custom shortcuts.
See: https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts
-->
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<!--
<shortcut
android:shortcutId="example_shortcut"
android:enabled="true"
android:shortcutShortLabel="@string/shortcut_short_label"
android:shortcutLongLabel="@string/shortcut_long_label">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.example.app"
android:targetClass="com.example.app.MainActivity" />
</shortcut>
-->
</shortcuts>

15
settings.gradle Normal file
View File

@@ -0,0 +1,15 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "pawlet_config_apk"

View File

@@ -0,0 +1,98 @@
package app.pawlet.config
import android.app.admin.DevicePolicyManager
import android.content.BroadcastReceiver
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.res.XmlResourceParser
import android.os.Bundle
import android.util.Log
class ConfigReceiver : BroadcastReceiver() {
companion object {
private const val TAG = "PawletConfig"
private const val LAWNCHAIR_PKG = "app.lawnchair"
}
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
Intent.ACTION_BOOT_COMPLETED,
Intent.ACTION_MY_PACKAGE_REPLACED -> {
Log.i(TAG, "Applying PawletOS config (trigger: ${intent.action})")
applyConfig(context)
}
}
}
private fun applyConfig(context: Context) {
applyIconPack(context)
applyManagedConfigs(context)
}
// Tells Lawnchair to use this package as the icon pack via broadcast.
private fun applyIconPack(context: Context) {
val intent = Intent("app.lawnchair.action.APPLY_ICON_PACK").apply {
putExtra("icon_pack", context.packageName)
setPackage(LAWNCHAIR_PKG)
}
context.sendBroadcast(intent)
Log.i(TAG, "Icon pack broadcast sent → $LAWNCHAIR_PKG")
}
// Applies managed configurations (App Restrictions) to target apps.
// Requires this APK to be set as Device Owner first.
// To activate device owner (run once via adb or system provisioning):
// adb shell dpm set-device-owner app.pawlet.config/.PawletDeviceAdminReceiver
private fun applyManagedConfigs(context: Context) {
/*
val dpm = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
val admin = ComponentName(context, PawletDeviceAdminReceiver::class.java)
if (!dpm.isDeviceOwnerApp(context.packageName)) {
Log.w(TAG, "Not device owner — skipping managed config application")
return
}
try {
val xml = context.resources.getXml(R.xml.managed_configs)
var currentPkg: String? = null
var currentBundle = Bundle()
var event = xml.next()
while (event != XmlResourceParser.END_DOCUMENT) {
if (event == XmlResourceParser.START_TAG) {
when (xml.name) {
"app" -> {
currentPkg = xml.getAttributeValue(null, "package")
currentBundle = Bundle()
}
"restriction" -> {
val key = xml.getAttributeValue(null, "key") ?: continue
val value = xml.getAttributeValue(null, "value") ?: continue
val type = xml.getAttributeValue(null, "type") ?: "string"
when (type) {
"boolean" -> currentBundle.putBoolean(key, value.toBoolean())
"integer" -> currentBundle.putInt(key, value.toInt())
else -> currentBundle.putString(key, value)
}
}
}
} else if (event == XmlResourceParser.END_TAG && xml.name == "app") {
if (currentPkg != null) {
dpm.setApplicationRestrictions(admin, currentPkg, currentBundle)
Log.i(TAG, "Managed config applied → $currentPkg (${currentBundle.size()} keys)")
}
}
event = xml.next()
}
xml.close()
} catch (e: Exception) {
Log.w(TAG, "Failed to apply managed configs", e)
}
*/
Log.d(TAG, "Managed config application skipped (device owner not activated)")
}
}

View File

@@ -0,0 +1,21 @@
package app.pawlet.config
import android.app.admin.DeviceAdminReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
class PawletDeviceAdminReceiver : DeviceAdminReceiver() {
companion object {
private const val TAG = "PawletConfig.Admin"
}
override fun onEnabled(context: Context, intent: Intent) {
Log.i(TAG, "Device admin enabled")
}
override fun onDisabled(context: Context, intent: Intent) {
Log.i(TAG, "Device admin disabled")
}
}

View File

@@ -0,0 +1,14 @@
package app.pawlet.config
import android.app.Activity
import android.os.Bundle
// No-op activity required for icon pack discovery.
// Launchers query for packages with MAIN/LAUNCHER or theme intent filters;
// this activity satisfies that requirement without showing any UI.
class IconPackActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
finish()
}
}

View File

@@ -0,0 +1,40 @@
package app.pawlet.config
import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri
import android.os.ParcelFileDescriptor
import android.util.Log
import java.io.FileOutputStream
// Serves partner_default_layout.xml to Lawnchair via ContentProvider.
// Lawnchair reads this when Settings.Secure["launcher3.layout.provider"] = "app.pawlet.config.layout".
class LayoutProvider : ContentProvider() {
companion object {
private const val TAG = "PawletConfig.Layout"
}
override fun onCreate() = true
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor? {
Log.d(TAG, "Layout requested: $uri")
return try {
val tmp = java.io.File(context!!.cacheDir, "layout_export.xml")
context!!.resources.openRawResource(R.raw.partner_default_layout).use { input ->
FileOutputStream(tmp).use { output -> input.copyTo(output) }
}
ParcelFileDescriptor.open(tmp, ParcelFileDescriptor.MODE_READ_ONLY)
} catch (e: Exception) {
Log.e(TAG, "Failed to open layout file", e)
null
}
}
override fun query(uri: Uri, p: Array<String>?, s: String?, a: Array<String>?, o: String?): Cursor? = null
override fun getType(uri: Uri): String? = null
override fun insert(uri: Uri, values: ContentValues?): Uri? = null
override fun delete(uri: Uri, s: String?, a: Array<String>?) = 0
override fun update(uri: Uri, v: ContentValues?, s: String?, a: Array<String>?) = 0
}

View File

@@ -0,0 +1,13 @@
package app.pawlet.config
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
// Empty receiver — its presence is all Lawnchair needs to discover this package
// as a partner customization provider (MATCH_SYSTEM_ONLY query).
// Lawnchair then reads res/xml/partner_default_layout.xml from this package.
// Only works when this APK is installed as a system app (baked into the ROM).
class PartnerCustomizationReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) = Unit
}