Fix Silence replacement, RIP CustomTiles

This commit is contained in:
Tad 2017-07-02 15:38:00 -04:00
parent 1ef1ada003
commit 73d0b61dba
3 changed files with 3 additions and 259 deletions

View File

@ -95,7 +95,6 @@
<!-- Misc -->
<project path="packages/apps/offline-calendar" name="SufficientlySecure/offline-calendar" remote="github" revision="master" />
<remove-project name="LineageOS/android_packages_apps_Messaging" />
<project path="packages/apps/Silence" name="SilenceIM/Silence" remote="github" revision="master" />
<!-- END OF ADDITIONAL REPOS -->

View File

@ -1,253 +0,0 @@
From a42004f47da3d2f8128f77b7170bf84dd86d7e19 Mon Sep 17 00:00:00 2001
From: Gabriele M <moto.falcon.git@gmail.com>
Date: Mon, 27 Mar 2017 17:23:04 +0200
Subject: [PATCH] CustomTiles: Add system profiles tile
This tile opens a dialog to change the current profile. If system
profiles are disabled, they'll be enabled as soon as a profile is
selected. Disabling system profiles from the tile is not possible.
Change-Id: I38b28be8fcf1eb7998d7d18df204802ea66554f6
---
AndroidManifest.xml | 11 ++
res/drawable/ic_profiles.xml | 28 +++++
res/values/strings.xml | 4 +
src/org/lineageos/customtiles/MainActivity.java | 1 +
src/org/lineageos/customtiles/ProfileTile.java | 139 ++++++++++++++++++++++++
5 files changed, 183 insertions(+)
create mode 100644 res/drawable/ic_profiles.xml
create mode 100644 src/org/lineageos/customtiles/ProfileTile.java
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6bef3c7..09f2de9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -129,6 +129,17 @@
</intent-filter>
</service>
+ <!-- Profiles -->
+ <service
+ android:name=".ProfileTile"
+ android:icon="@drawable/ic_profiles"
+ android:label="@string/system_profile_label"
+ android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
+ <intent-filter>
+ <action android:name="android.service.quicksettings.action.QS_TILE" />
+ </intent-filter>
+ </service>
+
<!-- WakeLock Service -->
<service
android:name=".WakelockService"
diff --git a/res/drawable/ic_profiles.xml b/res/drawable/ic_profiles.xml
new file mode 100644
index 0000000..79f7725
--- /dev/null
+++ b/res/drawable/ic_profiles.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2015 The CyanogenMod 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M19,5v14H5V5H19
+M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z
+M17,8 c0-0.6-0.4-1-1-1c-0.6,0-1,0.4-1,1s0.4,1,1,1C16.6,9,17,8.6,17,8z
+M13,8c0-0.6-0.4-1-1-1c-0.6,0-1,0.4-1,1s0.4,1,1,1 C12.6,9,13,8.6,13,8z
+M9,8c0-0.6-0.4-1-1-1S7,7.4,7,8s0.4,1,1,1S9,8.6,9,8z
+M17,13h-6v-2H9v2H7v2h2v2h2v-2h6V13z" />
+</vector>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 60cb829..e0dd75e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -24,8 +24,12 @@
<string name="sync_label">Sync</string>
<string name="volume_panel_label">Volume panel</string>
<string name="usb_tether_label">USB tethering</string>
+ <string name="system_profile_label">System Profile</string>
<!-- Caffeine -->
<string name="caffeine_label">Caffeine</string>
+ <string name="dialog_system_profile_title">Select profile</string>
+ <string name="dialog_system_profile_message">No system profile found</string>
+
</resources>
diff --git a/src/org/lineageos/customtiles/MainActivity.java b/src/org/lineageos/customtiles/MainActivity.java
index 95d3015..4f9f3ba 100644
--- a/src/org/lineageos/customtiles/MainActivity.java
+++ b/src/org/lineageos/customtiles/MainActivity.java
@@ -33,6 +33,7 @@ public class MainActivity extends Activity {
put(".SyncTile", new Intent(Settings.ACTION_SYNC_SETTINGS));
put(".UsbTetherTile", new Intent(Settings.ACTION_WIRELESS_SETTINGS));
put(".VolumePanelTile", new Intent(Settings.ACTION_SOUND_SETTINGS));
+ put(".ProfileTile", new Intent("org.cyanogenmod.cmparts.PROFILES_SETTINGS"));
}};
@Override
diff --git a/src/org/lineageos/customtiles/ProfileTile.java b/src/org/lineageos/customtiles/ProfileTile.java
new file mode 100644
index 0000000..ed3caab
--- /dev/null
+++ b/src/org/lineageos/customtiles/ProfileTile.java
@@ -0,0 +1,139 @@
+/*
+ * 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 org.lineageos.customtiles;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.service.quicksettings.Tile;
+import android.service.quicksettings.TileService;
+
+import java.util.UUID;
+
+import cyanogenmod.app.Profile;
+import cyanogenmod.app.ProfileManager;
+import cyanogenmod.providers.CMSettings;
+
+public class ProfileTile extends TileService {
+
+ private ProfileManager mProfileManager;
+
+ private Profile mCurrentProfile;
+
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ refresh();
+ }
+ };
+
+ @Override
+ public void onStartListening() {
+ super.onStartListening();
+
+ mProfileManager = ProfileManager.getInstance(getBaseContext());
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(ProfileManager.INTENT_ACTION_PROFILE_SELECTED);
+ filter.addAction(ProfileManager.INTENT_ACTION_PROFILE_UPDATED);
+ filter.addAction(ProfileManager.PROFILES_STATE_CHANGED_ACTION);
+ registerReceiver(mReceiver, filter);
+
+ refresh();
+ }
+
+ @Override
+ public void onStopListening() {
+ unregisterReceiver(mReceiver);
+ super.onStopListening();
+ }
+
+ private Dialog selectProfileDialog() {
+
+ Profile[] profilesList = mProfileManager.getProfiles();
+ if (profilesList.length == 0) {
+ return new AlertDialog.Builder(getBaseContext())
+ .setTitle(R.string.dialog_system_profile_title)
+ .setMessage(R.string.dialog_system_profile_message)
+ .setPositiveButton(android.R.string.ok, null)
+ .create();
+ }
+
+ final CharSequence[] profileLabels = new CharSequence[profilesList.length];
+ final UUID[] profileUuids = new UUID[profilesList.length];
+ int selectedProfile = -1;
+ for (int i = 0; i < profilesList.length; i++) {
+ UUID profileUuuid = profilesList[i].getUuid();
+ profileLabels[i] = profilesList[i].getName();
+ profileUuids[i] = profileUuuid;
+ if (mCurrentProfile != null && mCurrentProfile.getUuid().equals(profileUuuid)) {
+ selectedProfile = i;
+ }
+ }
+
+ return new AlertDialog.Builder(getBaseContext())
+ .setTitle(R.string.dialog_system_profile_title)
+ .setSingleChoiceItems(profileLabels, selectedProfile,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int index) {
+ if (!mProfileManager.isProfilesEnabled()) {
+ enableProfiles();
+ }
+ mProfileManager.setActiveProfile(profileUuids[index]);
+ dialogInterface.dismiss();
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, null)
+ .setCancelable(true)
+ .create();
+ }
+
+ @Override
+ public void onClick() {
+ super.onClick();
+
+ unlockAndRun(new Runnable() {
+ @Override
+ public void run() {
+ showDialog(selectProfileDialog());
+ }
+ });
+ }
+
+ private void refresh() {
+ if (mProfileManager.isProfilesEnabled()) {
+ mCurrentProfile = mProfileManager.getActiveProfile();
+ getQsTile().setState(Tile.STATE_ACTIVE);
+ getQsTile().setLabel(mCurrentProfile.getName());
+ } else {
+ mCurrentProfile = null;
+ getQsTile().setState(Tile.STATE_INACTIVE);
+ getQsTile().setLabel(getString(R.string.system_profile_label));
+ }
+ getQsTile().updateTile();
+ }
+
+ private void enableProfiles() {
+ CMSettings.System.putInt(getContentResolver(),
+ CMSettings.System.SYSTEM_PROFILES_ENABLED, 1);
+ }
+}
--
2.13.1

View File

@ -64,7 +64,7 @@ enter "build"
patch -p1 < $patches"android_build/0001-Automated_Build_Signing.patch" #Automated build signing
sed -i 's|echo "ro.build.user=$USER"|echo "ro.build.user=emy"|' tools/buildinfo.sh; #Override build user
sed -i 's|echo "ro.build.host=`hostname`"|echo "ro.build.host=dosbm"|' tools/buildinfo.sh; #Override build host
sed -i 's/messaging/Silence/' target/product/*.mk; #Replace AOSP Messaging app with Silence TODO: Refine this
sed -i 's/messaging/Silence/' target/product/*.mk; #Replace AOSP Messaging app with Silence
enter "device/qcom/sepolicy"
patch -p1 < $patches"android_device_qcom_sepolicy/0001-Camera_Fix.patch" #Fix camera on user builds
@ -77,7 +77,7 @@ patch -p1 < $patches"android_external_svox/94d2ddb.diff" #Fix garbled output See
enter "frameworks/base"
git revert 0326bb5e41219cf502727c3aa44ebf2daa19a5b3 #re-enable doze on devices without gms
git fetch https://review.lineageos.org/LineageOS/android_frameworks_base refs/changes/75/151975/34 && git cherry-pick FETCH_HEAD #network traffic
git fetch https://review.lineageos.org/LineageOS/android_frameworks_base refs/changes/75/151975/35 && git cherry-pick FETCH_HEAD #network traffic
sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/com/android/server/DropBoxManagerService.java; #Disable DropBox
sed -i '0,/wifi,cell,battery/s/wifi,cell,battery,dnd,flashlight,rotation,bt,airplane/wifi,cell,bt,dnd,flashlight,rotation,battery,saver,location,airplane,hotspot,nfc/' packages/SystemUI/res/values/config.xml;
patch -p1 < $patches"android_frameworks_base/0003-Signature_Spoofing.patch" #Allow packages to spoof their signature (MicroG)
@ -98,9 +98,6 @@ patch -p1 < $patches"android_packages_apps_CMUpdater/0001-Server.patch" #Switch
sed -i 's/CM_RELEASE_TYPE_DEFAULT = "UNOFFICIAL";/CM_RELEASE_TYPE_DEFAULT = "dos";/' src/com/cyanogenmod/updater/misc/Constants.java; #Change buildtype
sed -i 's/subStrings\[3\]\.length() < 7/subStrings\[3\]\.length() < 3/' src/com/cyanogenmod/updater/utils/Utils.java; #Fix not allowing buildtypes length < 7
enter "packages/apps/CustomTiles"
patch -p1 < $patches"android_packages_apps_CustomTiles/0001-Profiles.patch" #System profiles tile
enter "packages/apps/Dialer"
sed -i 's/FLP_DEFAULT = FLP_GOOGLE;/FLP_DEFAULT = FLP_OPENSTREETMAP;/' src/com/android/dialer/lookup/LookupSettings.java; #Change default FLP to OpenStreetMap
sed -i 's/CMSettings.System.ENABLE_FORWARD_LOOKUP, 1)/CMSettings.System.ENABLE_FORWARD_LOOKUP, 0)/' src/com/android/dialer/lookup/LookupSettings.java; #Disable FLP by default
@ -162,6 +159,7 @@ awk -i inplace '!/50-cm.sh/' config/common.mk; #Make sure our hosts is always us
patch -p1 < $patches"android_vendor_cm/0001-SCE.patch" #Include our extras such as MicroG and F-Droid
cp $patches"android_vendor_cm/sce.mk" config/sce.mk
sed -i 's/CM_BUILDTYPE := UNOFFICIAL/CM_BUILDTYPE := dos/' config/common.mk; #Change buildtype
sed -i 's/messaging/Silence/' config/telephony.mk; #Replace AOSP Messaging app with Silence
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