Skip to content

Commit

Permalink
Some alarms have no activity, but components instead. Fixes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteckler committed Oct 19, 2014
1 parent de61a16 commit dda1a4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
34 changes: 14 additions & 20 deletions app/src/main/java/com/ryansteckler/nlpunbounce/hooks/Wakelocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,25 +340,7 @@ private void handleAlarm(XC_MethodHook.MethodHookParam param, ArrayList<Object>
Intent intent = null;
try {
intent = (Intent) callMethod(pi, "getIntent");
// String debugString = intent.toString();
// XposedBridge.log(TAG + "Debug 4.3+ = " + debugString);
//
// IntentSender sender = pi.getIntentSender();
// debugString = sender.toString();
// XposedBridge.log(TAG + "Debug 4.2.2- = " + debugString);
//
} catch (NoSuchMethodError nsme) {
//API prior to 4.2.2_r1 don't have this.
/* if (!showedUnsupportedAlarmMessage) {
showedUnsupportedAlarmMessage = true;
XposedBridge.log(TAG + "Alarm prevention is not yet supported on Android versions less than 4.2.2");
}*/

/*
---------------- Added for JB 4.1.2 Support ------------------------
*/

Object mTarget = XposedHelpers.getObjectField(pi, "mTarget");

//debugLog("mTarget Class for PendingIntent: " + mTarget.getClass());
Expand All @@ -373,12 +355,24 @@ private void handleAlarm(XC_MethodHook.MethodHookParam param, ArrayList<Object>
}
}

if (intent == null || intent.getAction() == null) {
if (intent == null) {
//TODO: Why does the system have alarms with null intents?
continue;
}

String alarmName = null;
//Make sure one of the tags exists.
if (intent.getAction() != null) {
alarmName = intent.getAction();
} else if (intent.getComponent() != null) {
alarmName = intent.getComponent().flattenToShortString();
}

if (alarmName == null) {
//TODO: Why does the system have alarms with null intents?
continue;
}

String alarmName = intent.getAction();
//If we're blocking this wakelock
String prefName = "alarm_" + alarmName + "_enabled";
if (m_prefs.getBoolean(prefName, false)) {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,5 @@ Unbounceは、端末をウェイクしたままにする間隔や端末をウェ
アプリ内購入でPro機能をアンロックすると、どんなアラームやウェイクロックでもUnbounce (実行間隔の変更)出来るようになります。Pro機能を購入しなくても、以下のバッテリー消費が大きいものをUnbounce出来ます: NlpWakelock、NlpCollectorWakeLock、ALARM_WAKEUP_LOCATOR、ALARM_WAKE_ACTIVITY_DETECTION

[バッテリー]の持ちを極限まで高めよう!</string>
<!--Don't translate this one :) -->
<string translatable="false" name="app_font_family">sans_serif</string>

</resources>

0 comments on commit dda1a4d

Please sign in to comment.