From: Mateusz Bruno-Kaminski Date: Mon, 18 Jul 2016 11:12:10 +0000 (+0200) Subject: [API] Logging warnings for deprecated API elements X-Git-Tag: submit/tizen/20160808.053811~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abc4ff1f1f363acea109a2536bd40c3f5d371d7d;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [API] Logging warnings for deprecated API elements [Details] Added warnings which are logged when deprecated elements are used. Both in C++ and JavaScript. [Verification] Code compiles without errors and warnings shows up for deprecated API elements. Change-Id: I50bb501a5b29bb59d01ac5c0847ea6dac7203a98 Signed-off-by: Mateusz Bruno-Kaminski --- diff --git a/src/application/application_api.js b/src/application/application_api.js index 7b42f15c..77805ef8 100755 --- a/src/application/application_api.js +++ b/src/application/application_api.js @@ -564,6 +564,9 @@ var APPLICATION_EVENT_LISTENER = 'ApplicationEventListener'; var applicationEventListener = new ListenerManager(native, APPLICATION_EVENT_LISTENER); ApplicationManager.prototype.addAppInfoEventListener = function() { + console.warn('DEPRECATION WARNING: addAppInfoEventListener() is deprecated and will be removed from next release. ' + + 'Use tizen.package.setPackageInfoEventListener() instead.'); + var args = AV.validateMethod(arguments, [ { name : 'eventCallback', @@ -576,6 +579,9 @@ ApplicationManager.prototype.addAppInfoEventListener = function() { }; ApplicationManager.prototype.removeAppInfoEventListener = function() { + console.warn('DEPRECATION WARNING: removeAppInfoEventListener() is deprecated and will be removed from next release. ' + + 'Use tizen.package.unsetPackageInfoEventListener() instead.'); + var args = AV.validateMethod(arguments, [ { name : 'watchId', diff --git a/src/application/application_instance.cc b/src/application/application_instance.cc index 67ff539d..cb8d850a 100755 --- a/src/application/application_instance.cc +++ b/src/application/application_instance.cc @@ -159,12 +159,16 @@ void ApplicationInstance::GetAppMetaData(const picojson::value& args, picojson:: void ApplicationInstance::AddAppInfoEventListener(const picojson::value& args, picojson::object& out) { LoggerD("Entered"); + LoggerW("DEPRECATION WARNING: addAppInfoEventListener() is deprecated and will be removed from next release. " + "Use tizen.package.setPackageInfoEventListener() instead."); manager_.StartAppInfoEventListener(&out); } void ApplicationInstance::RemoveAppInfoEventListener(const picojson::value& args, picojson::object& out) { LoggerD("Entered"); + LoggerW("DEPRECATION WARNING: removeAppInfoEventListener() is deprecated and will be removed from next release. " + "Use tizen.package.unsetPackageInfoEventListener() instead."); manager_.StopAppInfoEventListener(); ReportSuccess(out); diff --git a/src/bluetooth/bluetooth_adapter.cc b/src/bluetooth/bluetooth_adapter.cc index e4283d66..396211dc 100755 --- a/src/bluetooth/bluetooth_adapter.cc +++ b/src/bluetooth/bluetooth_adapter.cc @@ -516,6 +516,8 @@ void BluetoothAdapter::SetName(const picojson::value& data, picojson::object& ou void BluetoothAdapter::SetPowered(const picojson::value& data, picojson::object& out) { LoggerD("Entered"); + LoggerW("DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. " + "Let the user turn on/off Bluetooth through the Settings application instead."); CHECK_BACKWARD_COMPABILITY_PRIVILEGE_ACCESS(Privilege::kBluetooth, Privilege::kBluetoothAdmin, &out); diff --git a/src/bluetooth/bluetooth_api.js b/src/bluetooth/bluetooth_api.js index 06c5fe92..c1c1864c 100755 --- a/src/bluetooth/bluetooth_api.js +++ b/src/bluetooth/bluetooth_api.js @@ -2030,6 +2030,9 @@ BluetoothAdapter.prototype.setName = function() { BluetoothAdapter.prototype.setPowered = function() { console.log('Entered BluetoothAdapter.setPowered()'); + console.warn('DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. ' + + 'Let the user turn on/off Bluetooth through the Settings application instead.'); + var args = AV.validateMethod(arguments, [ { name : 'powered', diff --git a/src/nfc/nfc_api.js b/src/nfc/nfc_api.js index 641a4ee6..3954049f 100644 --- a/src/nfc/nfc_api.js +++ b/src/nfc/nfc_api.js @@ -272,6 +272,9 @@ function NFCAdapter() { } NFCAdapter.prototype.setPowered = function() { + console.warn('DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. Let the user turn NFC on/off ' + + 'through the Settings application instead.'); + var args = validator_.validateArgs(arguments, [ { name: 'powered', diff --git a/src/nfc/nfc_instance.cc b/src/nfc/nfc_instance.cc index 781f90e8..4c0b50e7 100644 --- a/src/nfc/nfc_instance.cc +++ b/src/nfc/nfc_instance.cc @@ -205,6 +205,9 @@ void NFCInstance::SetExclusiveMode( void NFCInstance::SetPowered( const picojson::value& args, picojson::object& out) { LoggerD("Entered"); + LoggerW("DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. Let the user turn NFC on/off " + "through the Settings application instead."); + CHECK_PRIVILEGE_ACCESS(kPrivilegeNfcAdmin, &out); PlatformResult result = NFCAdapter::GetInstance()->SetPowered(args); diff --git a/src/power/power_api.js b/src/power/power_api.js index 96c75f0c..5be10265 100755 --- a/src/power/power_api.js +++ b/src/power/power_api.js @@ -120,11 +120,15 @@ function PowerManager() { * is desired to be. */ PowerManager.prototype.request = function(resource, state) { - var args = validator_.validateArgs(arguments, [ + var args = validator_.validateArgs(arguments, [ {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']}, {'name' : 'state', 'type': types_.ENUM, 'values' : ['SCREEN_OFF', 'SCREEN_DIM', 'SCREEN_NORMAL', 'SCREEN_BRIGHT', 'CPU_AWAKE']} ]); + if (args['state'] && args.state === PowerScreenState['SCREEN_BRIGHT']) { + console.warn('DEPRECATION WARNING: SCREEN_BRIGHT is deprecated and will be removed from next release.'); + } + var nativeParam = { }; @@ -273,6 +277,8 @@ PowerManager.prototype.restoreScreenBrightness = function() { * Turns on the screen. */ PowerManager.prototype.turnScreenOn = function() { + console.warn('DEPRECATION WARNING: turnScreenOn() is deprecated and will be removed from next release. Use request() instead.'); + var nativeParam = { }; @@ -288,6 +294,8 @@ PowerManager.prototype.turnScreenOn = function() { * Turns off the screen. */ PowerManager.prototype.turnScreenOff = function() { + console.warn('DEPRECATION WARNING: turnScreenOff() is deprecated and will be removed from next release. Use release() instead.'); + var nativeParam = { }; diff --git a/src/power/power_instance.cc b/src/power/power_instance.cc index a4b566de..82961235 100755 --- a/src/power/power_instance.cc +++ b/src/power/power_instance.cc @@ -173,6 +173,8 @@ void PowerInstance::PowerManagerRestorescreenbrightness(const picojson::value& a void PowerInstance::PowerManagerTurnscreenon(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); + LoggerW("DEPRECATION WARNING: turnScreenOn() is deprecated and will be removed from next release. Use request() instead."); + CHECK_PRIVILEGE_ACCESS(kPrivilegePower, &out); PlatformResult result = PowerManager::GetInstance()->SetScreenState(true); @@ -184,6 +186,8 @@ void PowerInstance::PowerManagerTurnscreenon(const picojson::value& args, picojs void PowerInstance::PowerManagerTurnscreenoff(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); + LoggerW("DEPRECATION WARNING: turnScreenOff() is deprecated and will be removed from next release. Use release() instead."); + CHECK_PRIVILEGE_ACCESS(kPrivilegePower, &out); PlatformResult result = PowerManager::GetInstance()->SetScreenState(false); diff --git a/src/power/power_manager.cc b/src/power/power_manager.cc index 865dca47..4bde5f66 100644 --- a/src/power/power_manager.cc +++ b/src/power/power_manager.cc @@ -102,6 +102,12 @@ void PowerManager::OnPlatformStateChangedCB(device_callback_e type, void* value, switch (state) { case DISPLAY_STATE_NORMAL : current = object->bright_state_enabled_ ? POWER_STATE_SCREEN_BRIGHT : POWER_STATE_SCREEN_NORMAL; + + // TODO: Remove log along with removal of deprecation power state + if (POWER_STATE_SCREEN_BRIGHT == current) { + LoggerW("DEPRECATION WARNING: SCREEN_BRIGHT is deprecated and will be removed from next release."); + } + break; case DISPLAY_STATE_SCREEN_DIM : current = POWER_STATE_SCREEN_DIM; @@ -187,6 +193,8 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { } case POWER_STATE_SCREEN_BRIGHT: { + LoggerW("DEPRECATION WARNING: SCREEN_BRIGHT is deprecated and will be removed from next release."); + int max_brightness; ret = device_display_get_max_brightness(0, &max_brightness); if (DEVICE_ERROR_NONE != ret) { @@ -220,8 +228,11 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { ret = device_display_get_state(&platform_state); if (DEVICE_ERROR_NONE != ret) LoggerE("device_display_get_state failed (%d)", ret); - if (platform_state == DISPLAY_STATE_NORMAL) + if (DISPLAY_STATE_NORMAL == platform_state) { + // TODO: Remove log along with removal of deprecation power state + LoggerW("DEPRECATION WARNING: SCREEN_BRIGHT is deprecated and will be removed from next release."); BroadcastScreenState(POWER_STATE_SCREEN_BRIGHT); + } break; } case POWER_STATE_SCREEN_OFF: @@ -392,6 +403,8 @@ PlatformResult PowerManager::SetPlatformBrightness(int brightness) { should_be_read_from_cache_ = true; return PlatformResult(ErrorCode::NO_ERROR); } else if (current_state_ == POWER_STATE_SCREEN_BRIGHT) { + LoggerW("DEPRECATION WARNING: SCREEN_BRIGHT is deprecated and will be removed from next release."); + current_brightness_ = brightness; LoggerD("Current state is not normal state the value is saved in cache: %d", brightness); should_be_read_from_cache_ = true; diff --git a/src/push/push_api.js b/src/push/push_api.js index afa13787..e415131b 100644 --- a/src/push/push_api.js +++ b/src/push/push_api.js @@ -56,7 +56,7 @@ PushManager.prototype.registerService = function() { values: tizen.ApplicationControl } ]); - console.warn('Method registerService() is deprecated, use register() instead.'); + console.warn('DEPRECATION WARNING: registerService() is deprecated and will be removed from next release. Use register() instead.'); this.register.apply(this, Array.prototype.slice.call(arguments, 1)); }; @@ -89,7 +89,7 @@ PushManager.prototype.register = function() { }; PushManager.prototype.unregisterService = function() { - console.warn('Method unregisterService() is deprecated, use unregister() instead.'); + console.warn('DEPRECATION WARNING: unregisterService() is deprecated and will be removed from next release. Use unregister() instead.'); this.unregister.apply(this, arguments); }; diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index 7fae0c7a..dad6383e 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -729,6 +729,8 @@ var SystemInfo = function() { }; SystemInfo.prototype.getCapabilities = function() { + console.warn('DEPRECATION WARNING: getCapabilities() is deprecated and will be removed from next release. Use getCapability() instead.'); + var result = native_.callSync('SystemInfo_getCapabilities', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); diff --git a/src/systeminfo/systeminfo_instance.cc b/src/systeminfo/systeminfo_instance.cc index 8f6ad504..15961ecf 100644 --- a/src/systeminfo/systeminfo_instance.cc +++ b/src/systeminfo/systeminfo_instance.cc @@ -81,6 +81,8 @@ SysteminfoInstance::~SysteminfoInstance() { void SysteminfoInstance::GetCapabilities(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); + LoggerW("DEPRECATION WARNING: getCapabilities() is deprecated and will be removed from next release. Use getCapability() instead."); + manager_.GetCapabilities(args, &out); } diff --git a/src/time/time_api.js b/src/time/time_api.js index ea6962b6..67ae6742 100644 --- a/src/time/time_api.js +++ b/src/time/time_api.js @@ -533,6 +533,8 @@ tizen.TZDate.prototype.toString = function() { tizen.TZDate.prototype.getTimezoneAbbreviation = function() { console.log('Entered TZDate.getTimezoneAbbreviation'); + console.warn('DEPRECATION WARNING: getTimezoneAbbreviation() is deprecated and will be removed from next release.'); + var result = native_.callSync('TZDate_getTimezoneAbbreviation', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); diff --git a/src/time/time_instance.cc b/src/time/time_instance.cc index c6e9cf20..1e63ece4 100644 --- a/src/time/time_instance.cc +++ b/src/time/time_instance.cc @@ -256,6 +256,8 @@ void TimeInstance::TZDate_toString(const picojson::value& args, picojson::object void TimeInstance::TZDate_getTimezoneAbbreviation(const picojson::value& args, picojson::object& out) { LoggerD("Entered"); + LoggerW("DEPRECATION WARNING: getTimezoneAbbreviation() is deprecated and will be removed from next release."); + if (!args.contains("timezone") || !args.contains("timestamp")) { LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter passed."), &out, ("Required parameters are missing: \"timezone\", \"timestamp\""));