From 88720f5d24d3a11213921cd8120a2295e6eeb873 Mon Sep 17 00:00:00 2001 From: Arthur Ishiguro Date: Wed, 21 Oct 2020 15:18:14 -0700 Subject: [PATCH] Adds airplane mode handing in IContextHubWrapper Bug: 166845383 Test: Compile Change-Id: I9971e9393921b7f7a04fd46df54cde6192600860 --- .../server/location/IContextHubWrapper.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/services/core/java/com/android/server/location/IContextHubWrapper.java b/services/core/java/com/android/server/location/IContextHubWrapper.java index 613964a5ed14d..9ac7c6b955832 100644 --- a/services/core/java/com/android/server/location/IContextHubWrapper.java +++ b/services/core/java/com/android/server/location/IContextHubWrapper.java @@ -116,6 +116,19 @@ public abstract class IContextHubWrapper { */ public abstract void onWifiSettingChanged(boolean enabled); + /** + * @return True if this version of the Contexthub HAL supports airplane mode setting + * notifications. + */ + public abstract boolean supportsAirplaneModeSettingNotifications(); + + /** + * Notifies the Contexthub implementation of an airplane mode setting change. + * + * @param enabled true if the airplane mode setting has been enabled. + */ + public abstract void onAirplaneModeSettingChanged(boolean enabled); + private static class ContextHubWrapperV1_0 extends IContextHubWrapper { private android.hardware.contexthub.V1_0.IContexthub mHub; @@ -135,11 +148,18 @@ public abstract class IContextHubWrapper { return false; } + public boolean supportsAirplaneModeSettingNotifications() { + return false; + } + public void onLocationSettingChanged(boolean enabled) { } public void onWifiSettingChanged(boolean enabled) { } + + public void onAirplaneModeSettingChanged(boolean enabled) { + } } private static class ContextHubWrapperV1_1 extends IContextHubWrapper { @@ -161,6 +181,10 @@ public abstract class IContextHubWrapper { return false; } + public boolean supportsAirplaneModeSettingNotifications() { + return false; + } + public void onLocationSettingChanged(boolean enabled) { try { mHub.onSettingChanged(Setting.LOCATION, @@ -172,6 +196,9 @@ public abstract class IContextHubWrapper { public void onWifiSettingChanged(boolean enabled) { } + + public void onAirplaneModeSettingChanged(boolean enabled) { + } } private static class ContextHubWrapperV1_2 extends IContextHubWrapper { @@ -193,6 +220,10 @@ public abstract class IContextHubWrapper { return true; } + public boolean supportsAirplaneModeSettingNotifications() { + return true; + } + public void onLocationSettingChanged(boolean enabled) { sendSettingChanged(Setting.LOCATION, enabled ? SettingValue.ENABLED : SettingValue.DISABLED); @@ -203,6 +234,11 @@ public abstract class IContextHubWrapper { enabled ? SettingValue.ENABLED : SettingValue.DISABLED); } + public void onAirplaneModeSettingChanged(boolean enabled) { + sendSettingChanged(android.hardware.contexthub.V1_2.Setting.AIRPLANE_MODE, + enabled ? SettingValue.ENABLED : SettingValue.DISABLED); + } + private void sendSettingChanged(byte setting, byte newValue) { try { mHub.onSettingChanged_1_2(setting, newValue);