[Settings]Crashed when 3rd-party app call ZenModeScheduleRuleSettings directly

Fix the issue that some 3rd-party apps call ZenModeScheduleRuleSettings directly
without set the extra ConditionProviderService.EXTRA_RULE_ID. It will raise the
exception and make settings crash.

Test: 1. Install the app "QuickShortcutMaker"
      2. Following the steps descripted in the issue:
         https://issuetracker.google.com/issues/37977351
      3. make ROBOTEST_FILTER="(ZenModeScheduleRuleSettingsTest)" RunSettingsRoboTests

Change-Id: Ia7de0e691eef6d0da26e629ff0c6af7006757623
Signed-off-by: liurong <liurong@xiaomi.com>
This commit is contained in:
liurong
2017-05-04 18:31:35 +08:00
committed by Doris Ling
parent b51efdb511
commit 20965328db
2 changed files with 121 additions and 0 deletions

View File

@@ -85,6 +85,12 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
}
mId = intent.getStringExtra(ConditionProviderService.EXTRA_RULE_ID);
if (mId == null) {
Log.w(TAG, "rule id is null");
toastAndFinish();
return;
}
if (DEBUG) Log.d(TAG, "mId=" + mId);
if (refreshRuleOrFinish()) {
return;