mirror of
https://github.com/Evolution-X/packages_apps_SystemUIFlagFlipper
synced 2026-01-27 12:56:48 +00:00
SystemUIFlagFlipper: initial draft
This commit is contained in:
25
Android.bp
Normal file
25
Android.bp
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2022 StatiXOS
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// http://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.
|
||||
|
||||
android_app {
|
||||
name: "SystemUIFlagFlipper",
|
||||
srcs: ["src/**/*.java"],
|
||||
static_libs: ["SystemUIFlagsLib"],
|
||||
resource_dirs: ["res"],
|
||||
platform_apis: true,
|
||||
system_ext_specific: true,
|
||||
certificate: "platform",
|
||||
privileged: true,
|
||||
manifest: "AndroidManifest.xml",
|
||||
}
|
||||
39
AndroidManifest.xml
Normal file
39
AndroidManifest.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2022 StatiXOS
|
||||
~
|
||||
~ 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
|
||||
~
|
||||
~ http://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.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.statix.systemuiflags">
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<application
|
||||
android:label="@string/app_name"
|
||||
android:allowBackup="false"
|
||||
android:requiredForAllUsers="true"
|
||||
android:supportsRtl="true">
|
||||
|
||||
<receiver android:name=".BootReceiver"
|
||||
android:directBootAware="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
19
res/values/config.xml
Normal file
19
res/values/config.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2022 StatiXOS
|
||||
|
||||
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
|
||||
|
||||
http://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.
|
||||
-->
|
||||
<resources>
|
||||
<string-array name="flags" />
|
||||
</resources>
|
||||
19
res/values/strings.xml
Normal file
19
res/values/strings.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2020 The Proton AOSP Project
|
||||
|
||||
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
|
||||
|
||||
http://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.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Simple Device Configuration</string>
|
||||
</resources>
|
||||
57
src/com/statix/systemuiflags/BootReceiver.java
Normal file
57
src/com/statix/systemuiflags/BootReceiver.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StatiXOS
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
package com.statix.systemuiflags;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.systemui.flags.FlagManager;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "SystemUIFlagFlipper";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
FlagManager manager = new FlagManager(context, new Handler(Looper.getMainLooper()));
|
||||
new Thread(() -> {
|
||||
Log.i(TAG, "Updating SystemUIFlags at boot");
|
||||
updateFlags(context, manager);
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void updateFlags(Context context, FlagManager flagManager) {
|
||||
updateConfig(context, R.array.flags, flagManager);
|
||||
}
|
||||
|
||||
private void updateConfig(Context context, int configArray, FlagManager flagManager) {
|
||||
// Set current properties
|
||||
String[] rawProperties = context.getResources().getStringArray(configArray);
|
||||
for (String property : rawProperties) {
|
||||
// Format: namespace/key=value
|
||||
String[] kv = property.split("=");
|
||||
int id = Integer.parseInt(kv[0]);
|
||||
boolean enabled = Boolean.parseBoolean(kv[1]);
|
||||
Log.i(TAG, "Setting flag " + id + " to " + enabled);
|
||||
|
||||
flagManager.setFlagValue(id, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user