ParanoidSystemUI: Add Always-on Display QS tile
[mickaelmendes50] - Rework QS Tile label logical when power save mode is on Squashed with: Author: Marko Man <darkobas@gmail.com> Date: Wed Apr 18 13:22:52 2018 +0200 base: SystemUI: add qs AOD tile Change-Id: I0d9948dbd48e309d8fcc9b2c33be8b17810dc5b0 Author: shagbag913 <sh4gbag913@gmail.com> Date: Sun Mar 1 15:49:17 2020 -0500 AODTile: disable tile when power save mode is on AOD is not allowed when power save mode is active, reflect that upon the tile. Signed-off-by: NurKeinNeid <mralexman3000@gmail.com> Change-Id: I3fc7f2a33d25a1616e8df5698ca2bc2a23d45cbb Author: Bruno Martins <bgcngm@gmail.com> Date: Sun Apr 12 19:04:24 2020 +0100 AODTile: Explicitely disable long clicks Returning null in the getLongClickIntent() method is not enough to disable tile long clock and results in crashes: E AndroidRuntime: FATAL EXCEPTION: main E AndroidRuntime: Process: com.android.systemui, PID: 1391 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.resolveTypeIfNeeded(android.content.ContentResolver)' on a null object reference E AndroidRuntime: at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:1062) E AndroidRuntime: at com.android.systemui.ActivityIntentHelper.getTargetActivityInfo(ActivityIntentHelper.java:70) E AndroidRuntime: at com.android.systemui.ActivityIntentHelper.wouldLaunchResolverActivity(ActivityIntentHelper.java:47) E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.startActivityDismissingKeyguard(StatusBar.java:2724) E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.startActivityDismissingKeyguard(StatusBar.java:2709) E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.startActivityDismissingKeyguard(StatusBar.java:2716) E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.handleStartActivityDismissingKeyguard(StatusBar.java:3159) E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.lambda$postStartActivityDismissingKeyguard$26$StatusBar(StatusBar.java:3155) E AndroidRuntime: at com.android.systemui.statusbar.phone.-$$Lambda$StatusBar$CSd9n4rtnrfFyOdT2eTFRNUO5xM.run(Unknown Source:4) E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883) E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100) E AndroidRuntime: at android.os.Looper.loop(Looper.java:214) E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356) E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491) E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) Change-Id: Ia7d4da4723600c47bedbfeb4b9152924a50d52dd Author: Bruno Martins <bgcngm@gmail.com> Date: Tue Jun 9 21:47:24 2020 +0100 AODTile: Rewrite AOD setting handling This fixes the tile status on clean installs, which was showing as active despite AOD being disabled. Change-Id: I148cfb34938165395bc52c830d1f2e374b5427df Author: Luca Stefani <luca.stefani.ge1@gmail.com> Date: Thu Mar 18 12:22:21 2021 +0100 SystemUI: AODTile: Use SecureSetting to change doze setting Change-Id: Ic39d26ac8a37041b75862627a497274b24f3362c Author: LuK1337 <priv.luk@gmail.com> Date: Thu Mar 18 12:23:45 2021 +0100 SystemUI: AODTile: Actually start using SecureSetting Change-Id: I37f0194fcb54db1cf3cae221f7f702d398834ced Author: Michael Bestas <mkbestas@gmail.com> Date: 2023-03-15 17:10:40 +0200 fixup! SystemUI: Add AOD QS tile Change-Id: I32e94533a8f2815579d8f1f2d6cb18c7d686af96 Change-Id: I5249106fea3518e8fa69990d1aa13c21cc542cb1
This commit is contained in:
parent
d3924fd818
commit
915c07efad
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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="#ffffff"
|
||||||
|
android:pathData="M17,19 L17,5 L7,5 L7,19 L17,19 M17,1 C18.1046,1,19,1.89543,19,3 L19,21 C19,22.1046,18.1046,23,17,23 L7,23 C5.89,23,5,22.1,5,21 L5,3 C5,1.89,5.89,1,7,1 L17,1 M9,7 L15,7 L15,9 L9,9 L9,7" />
|
||||||
|
</vector>
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
<!-- Always-on Display QS tile -->
|
<!-- Always-on Display QS tile -->
|
||||||
<string name="quick_settings_aod_label">Always-on display</string>
|
<string name="quick_settings_aod_label">Always-on display</string>
|
||||||
|
|
||||||
<!-- Sound QS Tile -->
|
<!-- Sound QS Tile -->
|
||||||
<string name="quick_settings_sound_label">Sound</string>
|
<string name="quick_settings_sound_label">Sound</string>
|
||||||
<string name="quick_settings_sound_ring">Ring</string>
|
<string name="quick_settings_sound_ring">Ring</string>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
||||||
<string name="quick_settings_tiles_stock" translatable="false">
|
<string name="quick_settings_tiles_stock" translatable="false">
|
||||||
|
|
||||||
internet,bt,flashlight,dnd,alarm,airplane,nfc,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,caffeine,dataswitch,heads_up,dc_dimming,aod,usb_tether,sound,sync
|
internet,bt,flashlight,dnd,alarm,airplane,nfc,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,caffeine,dataswitch,heads_up,dc_dimming,aod,usb_tether,sound,sync
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ import com.android.systemui.util.leak.GarbageMonitor;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
|
|
||||||
|
import co.aospa.systemui.qs.tiles.AlwaysOnDisplayTile;
|
||||||
import co.aospa.systemui.qs.tiles.CaffeineTile;
|
import co.aospa.systemui.qs.tiles.CaffeineTile;
|
||||||
import co.aospa.systemui.qs.tiles.DataSwitchTile;
|
import co.aospa.systemui.qs.tiles.DataSwitchTile;
|
||||||
import co.aospa.systemui.qs.tiles.DcDimmingTile;
|
import co.aospa.systemui.qs.tiles.DcDimmingTile;
|
||||||
|
@ -67,6 +68,7 @@ import dagger.Lazy;
|
||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
public class ParanoidQSFactoryImpl extends QSFactoryImpl {
|
public class ParanoidQSFactoryImpl extends QSFactoryImpl {
|
||||||
|
|
||||||
|
private final Provider<AlwaysOnDisplayTile> mAODTileProvider;
|
||||||
private final Provider<CaffeineTile> mCaffeineTileProvider;
|
private final Provider<CaffeineTile> mCaffeineTileProvider;
|
||||||
private final Provider<DataSwitchTile> mDataSwitchTileProvider;
|
private final Provider<DataSwitchTile> mDataSwitchTileProvider;
|
||||||
private final Provider<HeadsUpTile> mHeadsUpTileProvider;
|
private final Provider<HeadsUpTile> mHeadsUpTileProvider;
|
||||||
|
@ -107,6 +109,7 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
|
||||||
Provider<OneHandedModeTile> oneHandedModeTileProvider,
|
Provider<OneHandedModeTile> oneHandedModeTileProvider,
|
||||||
Provider<ColorCorrectionTile> colorCorrectionTileProvider,
|
Provider<ColorCorrectionTile> colorCorrectionTileProvider,
|
||||||
Provider<DreamTile> dreamTileProvider,
|
Provider<DreamTile> dreamTileProvider,
|
||||||
|
Provider<AlwaysOnDisplayTile> aodTileProvider,
|
||||||
Provider<CaffeineTile> caffeineTileProvider,
|
Provider<CaffeineTile> caffeineTileProvider,
|
||||||
Provider<DataSwitchTile> dataSwitchTileProvider,
|
Provider<DataSwitchTile> dataSwitchTileProvider,
|
||||||
Provider<HeadsUpTile> headsUpTileProvider,
|
Provider<HeadsUpTile> headsUpTileProvider,
|
||||||
|
@ -124,6 +127,7 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
|
||||||
microphoneToggleTileProvider, deviceControlsTileProvider, alarmTileProvider,
|
microphoneToggleTileProvider, deviceControlsTileProvider, alarmTileProvider,
|
||||||
quickAccessWalletTileProvider, qrCodeScannerTileProvider, oneHandedModeTileProvider,
|
quickAccessWalletTileProvider, qrCodeScannerTileProvider, oneHandedModeTileProvider,
|
||||||
colorCorrectionTileProvider, dreamTileProvider);
|
colorCorrectionTileProvider, dreamTileProvider);
|
||||||
|
mAODTileProvider = aodTileProvider;
|
||||||
mCaffeineTileProvider = caffeineTileProvider;
|
mCaffeineTileProvider = caffeineTileProvider;
|
||||||
mDataSwitchTileProvider = dataSwitchTileProvider;
|
mDataSwitchTileProvider = dataSwitchTileProvider;
|
||||||
mHeadsUpTileProvider = headsUpTileProvider;
|
mHeadsUpTileProvider = headsUpTileProvider;
|
||||||
|
@ -136,6 +140,8 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
|
||||||
@Override
|
@Override
|
||||||
protected QSTileImpl createTileInternal(String tileSpec) {
|
protected QSTileImpl createTileInternal(String tileSpec) {
|
||||||
switch (tileSpec) {
|
switch (tileSpec) {
|
||||||
|
case "aod":
|
||||||
|
return mAODTileProvider.get();
|
||||||
case "caffeine":
|
case "caffeine":
|
||||||
return mCaffeineTileProvider.get();
|
return mCaffeineTileProvider.get();
|
||||||
case "dataswitch":
|
case "dataswitch":
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The OmniROM Project
|
||||||
|
* 2020-2021 The LineageOS Project
|
||||||
|
* 2023 Paranoid Android
|
||||||
|
*
|
||||||
|
* 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 co.aospa.systemui.qs.tiles;
|
||||||
|
|
||||||
|
import static com.android.internal.logging.MetricsLogger.VIEW_UNKNOWN;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.service.quicksettings.Tile;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.dagger.qualifiers.Background;
|
||||||
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
|
import com.android.systemui.plugins.FalsingManager;
|
||||||
|
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
||||||
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
|
import com.android.systemui.qs.QSHost;
|
||||||
|
import com.android.systemui.qs.SettingObserver;
|
||||||
|
import com.android.systemui.qs.logging.QSLogger;
|
||||||
|
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
|
import com.android.systemui.statusbar.policy.BatteryController;
|
||||||
|
import com.android.systemui.util.settings.SecureSettings;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
public class AlwaysOnDisplayTile extends QSTileImpl<BooleanState> implements
|
||||||
|
BatteryController.BatteryStateChangeCallback {
|
||||||
|
|
||||||
|
private final Icon mIcon = ResourceIcon.get(R.drawable.ic_qs_aod);
|
||||||
|
private final BatteryController mBatteryController;
|
||||||
|
|
||||||
|
private final SettingObserver mSetting;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public AlwaysOnDisplayTile(
|
||||||
|
QSHost host,
|
||||||
|
@Background Looper backgroundLooper,
|
||||||
|
@Main Handler mainHandler,
|
||||||
|
FalsingManager falsingManager,
|
||||||
|
MetricsLogger metricsLogger,
|
||||||
|
StatusBarStateController statusBarStateController,
|
||||||
|
ActivityStarter activityStarter,
|
||||||
|
QSLogger qsLogger,
|
||||||
|
SecureSettings secureSettings,
|
||||||
|
BatteryController batteryController,
|
||||||
|
UserTracker userTracker
|
||||||
|
) {
|
||||||
|
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
|
||||||
|
statusBarStateController, activityStarter, qsLogger);
|
||||||
|
|
||||||
|
mSetting = new SettingObserver(secureSettings, mHandler, Settings.Secure.DOZE_ALWAYS_ON,
|
||||||
|
userTracker.getUserId()) {
|
||||||
|
@Override
|
||||||
|
protected void handleValueChanged(int value, boolean observedChange) {
|
||||||
|
handleRefreshState(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mBatteryController = batteryController;
|
||||||
|
batteryController.observe(getLifecycle(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPowerSaveChanged(boolean isPowerSave) {
|
||||||
|
refreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleDestroy() {
|
||||||
|
super.handleDestroy();
|
||||||
|
mSetting.setListening(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_dozeAlwaysOnDisplayAvailable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BooleanState newTileState() {
|
||||||
|
BooleanState state = new BooleanState();
|
||||||
|
state.handlesLongClick = false;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleSetListening(boolean listening) {
|
||||||
|
super.handleSetListening(listening);
|
||||||
|
mSetting.setListening(listening);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleUserSwitch(int newUserId) {
|
||||||
|
mSetting.setUserId(newUserId);
|
||||||
|
handleRefreshState(mSetting.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleClick(@Nullable View view) {
|
||||||
|
mSetting.setValue(mState.value ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Intent getLongClickIntent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getTileLabel() {
|
||||||
|
return mContext.getString(R.string.quick_settings_aod_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||||
|
final int value = arg instanceof Integer ? (Integer) arg : mSetting.getValue();
|
||||||
|
final boolean enable = value != 0;
|
||||||
|
if (state.slash == null) {
|
||||||
|
state.slash = new SlashState();
|
||||||
|
}
|
||||||
|
state.icon = mIcon;
|
||||||
|
state.value = enable;
|
||||||
|
state.slash.isSlashed = state.value;
|
||||||
|
state.label = mContext.getString(R.string.quick_settings_aod_label);
|
||||||
|
if (mBatteryController.isAodPowerSave()) {
|
||||||
|
state.state = Tile.STATE_UNAVAILABLE;
|
||||||
|
state.secondaryLabel = mContext.getString(R.string.battery_detail_switch_title);
|
||||||
|
} else {
|
||||||
|
state.state = enable ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||||
|
state.secondaryLabel = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue