Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions core/java/android/app/SystemServiceRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
import android.hardware.camera2.CameraManager;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.display.ColorDisplayManager;
import android.hardware.display.DcDimmingManager;
import android.hardware.display.DisplayManager;
import android.hardware.display.IDcDimmingManager;
import android.hardware.face.FaceManager;
import android.hardware.face.IFaceService;
import android.hardware.fingerprint.FingerprintManager;
Expand Down Expand Up @@ -971,6 +973,19 @@ public PocketManager createService(ContextImpl ctx) {
return new PocketManager(ctx.getOuterContext(), service);
}});

registerService(Context.DC_DIM_SERVICE, DcDimmingManager.class,
new CachedServiceFetcher<DcDimmingManager>() {
@Override
public DcDimmingManager createService(ContextImpl ctx) throws ServiceNotFoundException {
if (Resources.getSystem().getString(
com.android.internal.R.string.config_deviceDcDimmingSysfsNode).isEmpty()) {
return null;
}
IBinder b = ServiceManager.getServiceOrThrow(Context.DC_DIM_SERVICE);
IDcDimmingManager service = IDcDimmingManager.Stub.asInterface(b);
return new DcDimmingManager(service);
}});

registerService(Context.TV_INPUT_SERVICE, TvInputManager.class,
new CachedServiceFetcher<TvInputManager>() {
@Override
Expand Down
9 changes: 9 additions & 0 deletions core/java/android/content/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -6066,6 +6066,15 @@ public abstract boolean startInstrumentation(@NonNull ComponentName className,
*/
public static final String APP_LOCK_SERVICE = "app_lock";

/**
* {@link android.hardware.display.DcDimManager} for accessing and setting locked apps state.
*
* @see #getSystemService
* @see android.hardware.display.DcDimmingManager
* @hide
*/
public static final String DC_DIM_SERVICE = "dc_dim_service";

/**
* Determine whether the given permission is allowed for a particular
* process and user ID running in the system.
Expand Down
113 changes: 113 additions & 0 deletions core/java/android/hardware/display/DcDimmingManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright (C) 2020 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 android.hardware.display;

import android.content.Context;
import android.annotation.SystemService;
import android.os.RemoteException;

/**
* Manages the DC Dimming mode
* @author Rituj Beniwal
* @hide
*/
@SystemService(Context.DC_DIM_SERVICE)
public class DcDimmingManager {
private static final String TAG = "DcDimmingManager";

public static final int MODE_AUTO_OFF = 0;
public static final int MODE_AUTO_TIME = 1;

private IDcDimmingManager mService;

public DcDimmingManager (IDcDimmingManager service) {
mService = service;
}

/**
* Set the DC Dimming mode
* @hide
*/
public void setAutoMode(int mode) {
if (mService != null) {
try {
mService.setAutoMode(mode);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

/**
* Get the DC Dimming mode
* @hide
*/
public int getAutoMode() {
if (mService != null) {
try {
return mService.getAutoMode();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
return 0;
}

/**
* Whether the DC Dimming service is available
* @hide
*/
public boolean isAvailable() {
if (mService != null) {
try {
return mService.isAvailable();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
return false;
}

/**
* Enable or disable DC Dimming
* @hide
*/
public void setDcDimming(boolean enable) {
if (mService != null) {
try {
mService.setDcDimming(enable);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

/**
* Whether DC Dimming is enabled currently
* @hide
*/
public boolean isDcDimmingOn() {
if (mService != null) {
try {
return mService.isDcDimmingOn();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
return false;
}
}
30 changes: 30 additions & 0 deletions core/java/android/hardware/display/IDcDimmingManager.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (C) 2020 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 android.hardware.display;

/** @hide */
interface IDcDimmingManager {
void setAutoMode(in int mode);

int getAutoMode();

boolean isAvailable();

void setDcDimming(in boolean enable);

boolean isDcDimmingOn();
}
31 changes: 31 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,21 @@ public final class Settings {
public static final String ACTION_NIGHT_DISPLAY_SETTINGS =
"android.settings.NIGHT_DISPLAY_SETTINGS";

/**
* Activity Action: Show settings to allow configuration of DC Dimming.
* <p>
* In some cases, a matching Activity may not exist, so ensure you
* safeguard against this.
* <p>
* Input: Nothing.
* <p>
* Output: Nothing.
* @hide
*/
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_DC_DIMMING_SETTINGS =
"android.settings.DC_DIMMING_SETTINGS";

/**
* Activity Action: Show settings to allow configuration of Dark theme.
* <p>
Expand Down Expand Up @@ -4664,6 +4679,22 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
*/
public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;

/**
* Indicates the state of DC dimming AUTO mode:
* 0 - Off
* 1 - On
* @hide
*/
public static final String DC_DIMMING_AUTO_MODE = "dc_dimming_auto_mode";

/**
* Indicates the state of DC dimming:
* 0 - Off
* 1 - On
* @hide
*/
public static final String DC_DIMMING_STATE = "dc_dimming_state";

/**
* Control whether to enable adaptive sleep mode.
* @deprecated Use {@link android.provider.Settings.Secure#ADAPTIVE_SLEEP} instead.
Expand Down
12 changes: 12 additions & 0 deletions core/res/res/values/spark_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,16 @@

<!-- Fingerprint from stock ROM -->
<string name="config_stockFingerprint" translatable="false"></string>

<!-- Defines the sysfs attribute path used by the device
to enable/disable DC dimming. -->
<string name="config_deviceDcDimmingSysfsNode"></string>

<!-- Defines the value used by the device sysfs node
to enable DC dimming -->
<string name="config_deviceDcDimmingEnableValue">1</string>

<!-- Defines the value used by the device sysfs node
to disable DC dimming -->
<string name="config_deviceDcDimmingDisableValue">0</string>
</resources>
6 changes: 6 additions & 0 deletions core/res/res/values/spark_symbols.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,10 @@

<!-- Fingerprint from stock ROM -->
<java-symbol type="string" name="config_stockFingerprint" />

<!-- DC Dimming -->
<java-symbol type="string" name="config_deviceDcDimmingSysfsNode" />
<java-symbol type="string" name="config_deviceDcDimmingEnableValue" />
<java-symbol type="string" name="config_deviceDcDimmingDisableValue" />

</resources>
10 changes: 10 additions & 0 deletions packages/SystemUI/res/drawable/ic_dc_dimming_tile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:viewportWidth="24"
android:viewportHeight="24"
android:width="24dp"
android:height="24dp">
<path
android:pathData="M11.9999 0.689941L12.7493 1.43925C12.2925 1.8058 12 2.36875 12 3V5.99994H11.9999C8.68994 5.99994 5.99994 8.68994 5.99994 11.9999C5.99994 15.3099 8.68994 17.9999 11.9999 17.9999C13.0923 17.9999 14.1171 17.707 15 17.1954V20.3099L11.9999 23.3099L8.68994 19.9999H3.99994V15.3099L0.689941 11.9999L3.99994 8.68994V3.99994H8.68994L11.9999 0.689941ZM12 14C12 14.8115 12.4834 15.5102 13.1779 15.8238C12.8055 15.9383 12.41 16 12 16C9.79086 16 8 14.2091 8 12C8 9.79086 9.79086 8 12 8V14ZM14 13V4C14 3.45 14.45 3 15 3H21.56C22.26 3 22.74 3.7 22.49 4.35L20 11H22.26C23.03 11 23.51 11.83 23.12 12.5L17.93 21.4C17.67 21.84 17 21.66 17 21.15V14H15C14.45 14 14 13.55 14 13Z"
android:fillType="evenOdd"
android:fillColor="#000000" />
</vector>
4 changes: 2 additions & 2 deletions packages/SystemUI/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
<string name="quick_settings_tiles_stock" translatable="false">
internet,wifi,cell,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,nfc,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,onthego,aod,powershare,caffeine,ambient_display,usb_tether,sync,sound,heads_up,reboot,volume_panel,dataswitch,fpsinfo,livedisplay,reading_mode,anti_flicker,compass,cpuinfo,soundsearch,smartpixels,refresh_rate,preferred_network,screenshot,spark_idle,spark_boost
internet,wifi,cell,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,nfc,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,onthego,aod,powershare,caffeine,ambient_display,usb_tether,sync,sound,heads_up,reboot,volume_panel,dataswitch,fpsinfo,livedisplay,reading_mode,anti_flicker,compass,cpuinfo,soundsearch,smartpixels,refresh_rate,preferred_network,screenshot,spark_idle,spark_boost,dc_dimming
</string>

<!-- The tiles to display in QuickSettings -->
Expand Down Expand Up @@ -773,7 +773,7 @@
<item>@color/dream_overlay_aqi_very_unhealthy</item>
<item>@color/dream_overlay_aqi_hazardous</item>
</integer-array>

<integer name="background_blur_radius">80</integer>
<item name="background_blur_colour_opacity" format="float" type="dimen">0.88</item>
</resources>
3 changes: 3 additions & 0 deletions packages/SystemUI/res/values/spark_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,7 @@
<string name="usage_data">used today</string>
<string name="usage_data_default_suffix">Data</string>
<string name="usage_wifi_default_suffix">Wi-Fi</string>

<!-- DC Dimming -->
<string name="quick_settings_dc_dimming_label">DC Dimming</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.android.systemui.qs.tiles.CompassTile;
import com.android.systemui.qs.tiles.DataSaverTile;
import com.android.systemui.qs.tiles.DataSwitchTile;
import com.android.systemui.qs.tiles.DcDimmingTile;
import com.android.systemui.qs.tiles.DeviceControlsTile;
import com.android.systemui.qs.tiles.DndTile;
import com.android.systemui.qs.tiles.DreamTile;
Expand Down Expand Up @@ -148,6 +149,7 @@ public class QSFactoryImpl implements QSFactory {
private final Provider<ScreenshotTile> mScreenshotTileProvider;
private final Provider<SparkIdleManagerTile> mSparkIdleManagerTileProvider;
private final Provider<SparkBoostManagerTile> mSparkBoostManagerTileProvider;
private final Provider<DcDimmingTile> mDcDimmingTileProvider;

private final Lazy<QSHost> mQsHostLazy;
private final Provider<CustomTile.Builder> mCustomTileBuilderProvider;
Expand Down Expand Up @@ -210,10 +212,11 @@ public QSFactoryImpl(
Provider<PreferredNetworkTile> preferredNetworkTileProvider,
Provider<ScreenshotTile> screenshotTileProvider,
Provider<SparkIdleManagerTile> sparkIdleManagerTileProvider,
Provider<SparkBoostManagerTile> sparkBoostManagerTileProvider) {
Provider<SparkBoostManagerTile> sparkBoostManagerTileProvider,
Provider<DcDimmingTile> dcDimTileProvider) {
mQsHostLazy = qsHostLazy;
mCustomTileBuilderProvider = customTileBuilderProvider;

mWifiTileProvider = wifiTileProvider;
mInternetTileProvider = internetTileProvider;
mBluetoothTileProvider = bluetoothTileProvider;
Expand Down Expand Up @@ -269,6 +272,7 @@ public QSFactoryImpl(
mScreenshotTileProvider = screenshotTileProvider;
mSparkIdleManagerTileProvider = sparkIdleManagerTileProvider;
mSparkBoostManagerTileProvider = sparkBoostManagerTileProvider;
mDcDimmingTileProvider = dcDimTileProvider;
}

/** Creates a tile with a type based on {@code tileSpec} */
Expand Down Expand Up @@ -394,6 +398,8 @@ protected QSTileImpl createTileInternal(String tileSpec) {
return mSparkIdleManagerTileProvider.get();
case "spark_boost":
return mSparkBoostManagerTileProvider.get();
case "dc_dimming":
return mDcDimmingTileProvider.get();
}
// Custom tiles
if (tileSpec.startsWith(CustomTile.PREFIX)) {
Expand Down
Loading