mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-25 15:39:26 -05:00
Add a qs tile for controlling radio power
This commit is contained in:
parent
7d4faa1ef8
commit
dec73c392c
231
Patches/LineageOS-14.1/android_frameworks_base/0002-Radio.patch
Normal file
231
Patches/LineageOS-14.1/android_frameworks_base/0002-Radio.patch
Normal file
@ -0,0 +1,231 @@
|
||||
From 0eb8f3eb492844954cdbfa44b660cc5a278ebcd5 Mon Sep 17 00:00:00 2001
|
||||
From: Tad <tad@spotco.us>
|
||||
Date: Fri, 10 Nov 2017 17:28:06 -0500
|
||||
Subject: [PATCH] Add radio power tile (1/2)
|
||||
|
||||
Change-Id: Icec0f52b43d6bf319befa855a2dd753e9c99b98d
|
||||
---
|
||||
packages/SystemUI/res/drawable/ic_qs_radio_off.xml | 10 ++
|
||||
packages/SystemUI/res/drawable/ic_qs_radio_on.xml | 10 ++
|
||||
packages/SystemUI/res/values/cm_strings.xml | 3 +
|
||||
packages/SystemUI/res/values/config.xml | 2 +-
|
||||
.../android/systemui/qs/tiles/RadioPowerTile.java | 127 +++++++++++++++++++++
|
||||
.../systemui/statusbar/phone/QSTileHost.java | 2 +
|
||||
6 files changed, 153 insertions(+), 1 deletion(-)
|
||||
create mode 100644 packages/SystemUI/res/drawable/ic_qs_radio_off.xml
|
||||
create mode 100644 packages/SystemUI/res/drawable/ic_qs_radio_on.xml
|
||||
create mode 100644 packages/SystemUI/src/com/android/systemui/qs/tiles/RadioPowerTile.java
|
||||
|
||||
diff --git a/packages/SystemUI/res/drawable/ic_qs_radio_off.xml b/packages/SystemUI/res/drawable/ic_qs_radio_off.xml
|
||||
new file mode 100644
|
||||
index 00000000000..1cb49181faa
|
||||
--- /dev/null
|
||||
+++ b/packages/SystemUI/res/drawable/ic_qs_radio_off.xml
|
||||
@@ -0,0 +1,10 @@
|
||||
+<?xml version="1.0" encoding="utf-8"?>
|
||||
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
+ android:width="64dp"
|
||||
+ android:height="64dp"
|
||||
+ android:viewportWidth="24"
|
||||
+ android:viewportHeight="24">
|
||||
+ <path
|
||||
+ android:fillColor="#4DFFFFFF"
|
||||
+ android:pathData="M12,5c-3.87,0 -7,3.13 -7,7h2c0,-2.76 2.24,-5 5,-5s5,2.24 5,5h2c0,-3.87 -3.13,-7 -7,-7zM13,14.29c0.88,-0.39 1.5,-1.26 1.5,-2.29 0,-1.38 -1.12,-2.5 -2.5,-2.5S9.5,10.62 9.5,12c0,1.02 0.62,1.9 1.5,2.29v3.3L7.59,21 9,22.41l3,-3 3,3L16.41,21 13,17.59v-3.3zM12,1C5.93,1 1,5.93 1,12h2c0,-4.97 4.03,-9 9,-9s9,4.03 9,9h2c0,-6.07 -4.93,-11 -11,-11z" />
|
||||
+</vector>
|
||||
diff --git a/packages/SystemUI/res/drawable/ic_qs_radio_on.xml b/packages/SystemUI/res/drawable/ic_qs_radio_on.xml
|
||||
new file mode 100644
|
||||
index 00000000000..d446debdfc6
|
||||
--- /dev/null
|
||||
+++ b/packages/SystemUI/res/drawable/ic_qs_radio_on.xml
|
||||
@@ -0,0 +1,10 @@
|
||||
+<?xml version="1.0" encoding="utf-8"?>
|
||||
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
+ android:width="64dp"
|
||||
+ android:height="64dp"
|
||||
+ android:viewportWidth="24"
|
||||
+ android:viewportHeight="24">
|
||||
+ <path
|
||||
+ android:fillColor="#FFFFFFFF"
|
||||
+ android:pathData="M12,5c-3.87,0 -7,3.13 -7,7h2c0,-2.76 2.24,-5 5,-5s5,2.24 5,5h2c0,-3.87 -3.13,-7 -7,-7zM13,14.29c0.88,-0.39 1.5,-1.26 1.5,-2.29 0,-1.38 -1.12,-2.5 -2.5,-2.5S9.5,10.62 9.5,12c0,1.02 0.62,1.9 1.5,2.29v3.3L7.59,21 9,22.41l3,-3 3,3L16.41,21 13,17.59v-3.3zM12,1C5.93,1 1,5.93 1,12h2c0,-4.97 4.03,-9 9,-9s9,4.03 9,9h2c0,-6.07 -4.93,-11 -11,-11z" />
|
||||
+</vector>
|
||||
diff --git a/packages/SystemUI/res/values/cm_strings.xml b/packages/SystemUI/res/values/cm_strings.xml
|
||||
index b429946bd93..89e3210a21f 100644
|
||||
--- a/packages/SystemUI/res/values/cm_strings.xml
|
||||
+++ b/packages/SystemUI/res/values/cm_strings.xml
|
||||
@@ -230,4 +230,7 @@
|
||||
<string name="accessibility_lock_task">Prevent <xliff:g id="task">%1$s</xliff:g> from being dismissed</string>
|
||||
<!-- Content description for Accessibility on locked tasks in recents -->
|
||||
<string name="accessibility_unlock_task">Allow <xliff:g id="task">%1$s</xliff:g> to be dismissed</string>
|
||||
+
|
||||
+ <!-- Radio Power QS tile -->
|
||||
+ <string name="quick_settings_radio_power_label">Radio power</string>
|
||||
</resources>
|
||||
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
|
||||
index 47aacddfbd3..fe98a33d00c 100644
|
||||
--- a/packages/SystemUI/res/values/config.xml
|
||||
+++ b/packages/SystemUI/res/values/config.xml
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
||||
<string name="quick_settings_tiles_stock" translatable="false">
|
||||
- wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,work,cast,night,adb_network,ambient_display,caffeine,heads_up,sync,usb_tether,volume_panel,profiles
|
||||
+ wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,work,cast,night,adb_network,ambient_display,caffeine,heads_up,sync,usb_tether,volume_panel,profiles,radio_power
|
||||
</string>
|
||||
|
||||
<!-- The tiles to display in QuickSettings -->
|
||||
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RadioPowerTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RadioPowerTile.java
|
||||
new file mode 100644
|
||||
index 00000000000..b907205025c
|
||||
--- /dev/null
|
||||
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RadioPowerTile.java
|
||||
@@ -0,0 +1,127 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2015 The CyanogenMod Project
|
||||
+ * Copyright (C) 2017 The LineageOS 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.
|
||||
+ */
|
||||
+
|
||||
+package com.android.systemui.qs.tiles;
|
||||
+
|
||||
+import android.content.BroadcastReceiver;
|
||||
+import android.content.Context;
|
||||
+import android.content.Intent;
|
||||
+import android.content.IntentFilter;
|
||||
+import android.database.ContentObserver;
|
||||
+import android.os.UserHandle;
|
||||
+import android.provider.Settings;
|
||||
+
|
||||
+import com.android.internal.logging.MetricsLogger;
|
||||
+import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
+import com.android.internal.telephony.Phone;
|
||||
+import com.android.internal.telephony.PhoneFactory;
|
||||
+
|
||||
+import com.android.systemui.R;
|
||||
+import com.android.systemui.qs.QSTile;
|
||||
+
|
||||
+import android.telephony.ServiceState;
|
||||
+
|
||||
+
|
||||
+/** Quick settings tile: RadioPower **/
|
||||
+public class RadioPowerTile extends QSTile<QSTile.BooleanState> {
|
||||
+
|
||||
+ private boolean mListening;
|
||||
+
|
||||
+ public RadioPowerTile(Host host) {
|
||||
+ super(host);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isAvailable() {
|
||||
+ return PhoneFactory.getDefaultPhone() != null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BooleanState newTileState() {
|
||||
+ return new BooleanState();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void handleClick() {
|
||||
+ refreshState(!getRadioState());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Intent getLongClickIntent() {
|
||||
+ return new Intent().setClassName("com.android.settings", "com.android.settings.RadioInfo");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void handleLongClick() {
|
||||
+ mHost.startActivityDismissingKeyguard(getLongClickIntent());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void handleUpdateState(BooleanState state, Object arg) {
|
||||
+ state.visible = true;
|
||||
+ final boolean radioPower = arg instanceof Boolean ? (boolean) arg : getRadioState();
|
||||
+ state.value = radioPower;
|
||||
+ state.label = mContext.getString(R.string.quick_settings_radio_power_label);
|
||||
+ if(state.value) {
|
||||
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_radio_on);
|
||||
+ } else {
|
||||
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_radio_off);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CharSequence getTileLabel() {
|
||||
+ return mContext.getString(R.string.quick_settings_radio_power_label);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMetricsCategory() {
|
||||
+ return MetricsEvent.QS_AIRPLANEMODE;
|
||||
+ }
|
||||
+
|
||||
+ private boolean getRadioState() {
|
||||
+ final Phone phone = PhoneFactory.getDefaultPhone();
|
||||
+ return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
|
||||
+ }
|
||||
+
|
||||
+ private void setRadioState(boolean enabled) {
|
||||
+ final Phone phone = PhoneFactory.getDefaultPhone();
|
||||
+ phone.setRadioPower(enabled);
|
||||
+ }
|
||||
+
|
||||
+ public void setListening(boolean listening) {
|
||||
+ if (mListening == listening) return;
|
||||
+ mListening = listening;
|
||||
+ if (listening) {
|
||||
+ final IntentFilter filter = new IntentFilter();
|
||||
+ filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
+ mContext.registerReceiver(mReceiver, filter);
|
||||
+ } else {
|
||||
+ mContext.unregisterReceiver(mReceiver);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
+ @Override
|
||||
+ public void onReceive(Context context, Intent intent) {
|
||||
+ if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {
|
||||
+ refreshState();
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+}
|
||||
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
|
||||
index 7f8ef210b52..ac7fa6ab96c 100755
|
||||
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
|
||||
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
|
||||
@@ -59,6 +59,7 @@ import com.android.systemui.qs.tiles.IntentTile;
|
||||
import com.android.systemui.qs.tiles.LocationTile;
|
||||
import com.android.systemui.qs.tiles.NfcTile;
|
||||
import com.android.systemui.qs.tiles.NightDisplayTile;
|
||||
+import com.android.systemui.qs.tiles.RadioPowerTile;
|
||||
import com.android.systemui.qs.tiles.RotationLockTile;
|
||||
import com.android.systemui.qs.tiles.SyncTile;
|
||||
import com.android.systemui.qs.tiles.UsbTetherTile;
|
||||
@@ -441,6 +442,7 @@ public class QSTileHost implements QSTile.Host, Tunable {
|
||||
else if (tileSpec.equals("dnd")) return new DndTile(this);
|
||||
else if (tileSpec.equals("inversion")) return new ColorInversionTile(this);
|
||||
else if (tileSpec.equals("airplane")) return new AirplaneModeTile(this);
|
||||
+ else if (tileSpec.equals("radio_power")) return new RadioPowerTile(this);
|
||||
else if (tileSpec.equals("work")) return new WorkModeTile(this);
|
||||
else if (tileSpec.equals("rotation")) return new RotationLockTile(this);
|
||||
else if (tileSpec.equals("flashlight")) return new FlashlightTile(this);
|
||||
--
|
||||
2.15.0
|
||||
|
33
Patches/LineageOS-14.1/cm_platform_sdk/0001-Radio.patch
Normal file
33
Patches/LineageOS-14.1/cm_platform_sdk/0001-Radio.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From d69062c3f395613090ae902e43622af312036515 Mon Sep 17 00:00:00 2001
|
||||
From: Tad <tad@spotco.us>
|
||||
Date: Fri, 10 Nov 2017 12:50:12 -0500
|
||||
Subject: [PATCH] Add radio power tile (2/2)
|
||||
|
||||
Change-Id: I97745fc43ff6af599d7d30a6fd7db9b2942b3247
|
||||
---
|
||||
sdk/src/java/org/cyanogenmod/internal/util/QSConstants.java | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/sdk/src/java/org/cyanogenmod/internal/util/QSConstants.java b/sdk/src/java/org/cyanogenmod/internal/util/QSConstants.java
|
||||
index c5e62eb..8782128 100644
|
||||
--- a/sdk/src/java/org/cyanogenmod/internal/util/QSConstants.java
|
||||
+++ b/sdk/src/java/org/cyanogenmod/internal/util/QSConstants.java
|
||||
@@ -26,6 +26,7 @@ public class QSConstants {
|
||||
public static final String TILE_INVERSION = "inversion";
|
||||
public static final String TILE_CELLULAR = "cell";
|
||||
public static final String TILE_AIRPLANE = "airplane";
|
||||
+ public static final String TILE_RADIO_POWER = "radio_power";
|
||||
public static final String TILE_ROTATION = "rotation";
|
||||
public static final String TILE_FLASHLIGHT = "flashlight";
|
||||
public static final String TILE_LOCATION = "location";
|
||||
@@ -71,6 +72,7 @@ public class QSConstants {
|
||||
STATIC_TILES_AVAILABLE.add(TILE_BLUETOOTH);
|
||||
STATIC_TILES_AVAILABLE.add(TILE_CELLULAR);
|
||||
STATIC_TILES_AVAILABLE.add(TILE_AIRPLANE);
|
||||
+ STATIC_TILES_AVAILABLE.add(TILE_RADIO_POWER);
|
||||
STATIC_TILES_AVAILABLE.add(TILE_ROTATION);
|
||||
STATIC_TILES_AVAILABLE.add(TILE_FLASHLIGHT);
|
||||
STATIC_TILES_AVAILABLE.add(TILE_LOCATION);
|
||||
--
|
||||
2.15.0
|
||||
|
@ -131,6 +131,7 @@ sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/
|
||||
sed -i 's/com.android.messaging/org.smssecure.smssecure/' core/res/res/values/config.xml; #Change default SMS app to Silence
|
||||
#sed -i 's|config_permissionReviewRequired">false|config_permissionReviewRequired">true|' core/res/res/values/config.xml; #XXX: Super awesome, but breaks quick tiles
|
||||
patch -p1 < $patches"android_frameworks_base/0001-Reduced_Resolution.patch" #Allow reducing resolution to save power TODO: Add 800x480
|
||||
patch -p1 < $patches"android_frameworks_base/0002-Radio.patch" #Add a QS tile to control radio power
|
||||
patch -p1 < $patches"android_frameworks_base/0003-Signature_Spoofing.patch" #Allow packages to spoof their signature (MicroG)
|
||||
patch -p1 < $patches"android_frameworks_base/0005-Harden_Sig_Spoofing.patch" #Restrict signature spoofing to system apps signed with the platform key
|
||||
rm -rf packages/PrintRecommendationService; #App that just creates popups to install proprietary print apps
|
||||
@ -230,6 +231,7 @@ enter "vendor/cmsdk"
|
||||
git fetch https://review.lineageos.org/LineageOS/cm_platform_sdk refs/changes/21/148321/14 && git cherry-pick FETCH_HEAD #network traffic
|
||||
awk -i inplace '!/WeatherManagerServiceBroker/' cm/res/res/values/config.xml; #Disable Weather
|
||||
cp $patches"cm_platform_sdk/profile_default.xml" cm/res/res/xml/profile_default.xml; #Replace default profiles with *way* better ones
|
||||
patch -p1 < $patches"cm_platform_sdk/0001-Radio.patch" #Add a QS tile to control radio power
|
||||
sed -i 's/shouldUseOptimizations(weight)/true/' cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java; #Per app performance profiles fix
|
||||
#
|
||||
#END OF ROM CHANGES
|
||||
|
Loading…
Reference in New Issue
Block a user