-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/edu/cmu/hcii/sugilite/automation/ServiceStatusManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package edu.cmu.hcii.sugilite.automation; | ||
|
||
import android.app.ActivityManager; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.provider.Settings; | ||
|
||
import edu.cmu.hcii.sugilite.SugiliteAccessibilityService; | ||
|
||
/** | ||
* @author toby | ||
* @date 6/17/16 | ||
* @time 5:03 PM | ||
*/ | ||
public class ServiceStatusManager { | ||
private Context context; | ||
public ServiceStatusManager(Context context){ | ||
this.context = context; | ||
} | ||
|
||
/** | ||
* | ||
* @return true if SugiliteAccessibilityService is active, false otherwise | ||
*/ | ||
public boolean isRunning() { | ||
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | ||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | ||
if (SugiliteAccessibilityService.class.getName().equals(service.service.getClassName())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* bring the user to the accessibility settings if SugiliteAccessibilityService is not active | ||
*/ | ||
public void promptEnabling(){ | ||
if(!isRunning()){ | ||
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); | ||
context.startActivity(intent); | ||
} | ||
} | ||
|
||
} |