summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEthan Chen <intervigil@gmail.com>2015-02-19 16:17:17 -0800
committerRicardo Cerqueira <ricardo@cyngn.com>2015-11-12 13:58:04 +0000
commitbf4366d0b0651c58f7a02d7ea03324eab36f8d3f (patch)
treebad07901d6ac46b2f74f3d0541928e7c2e92f64b /src
parentff050bd8e40fd4abeeb6b32e6b679bd48a914c97 (diff)
downloadandroid_packages_apps_Screencast-bf4366d0b0651c58f7a02d7ea03324eab36f8d3f.tar.gz
android_packages_apps_Screencast-bf4366d0b0651c58f7a02d7ea03324eab36f8d3f.tar.bz2
android_packages_apps_Screencast-bf4366d0b0651c58f7a02d7ea03324eab36f8d3f.zip
Screencast: Stop screen record on user switch
Change-Id: I0c6261ac7e4ff9fe98f89181eda6fb92e69f303c
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/screencast/ScreencastService.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/com/cyanogenmod/screencast/ScreencastService.java b/src/com/cyanogenmod/screencast/ScreencastService.java
index 28839af..2daf179 100644
--- a/src/com/cyanogenmod/screencast/ScreencastService.java
+++ b/src/com/cyanogenmod/screencast/ScreencastService.java
@@ -20,8 +20,10 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.net.Uri;
@@ -55,6 +57,16 @@ public class ScreencastService extends Service {
private static final String SHOW_TOUCHES = "show_touches";
+ private BroadcastReceiver mUserSwitchReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(Intent.ACTION_USER_BACKGROUND)) {
+ context.startService(new Intent("com.cyngn.ACTION_STOP_SCREENCAST")
+ .setClass(context, ScreencastService.class));
+ }
+ }
+ };
+
@Override
public IBinder onBind(Intent intent) {
return null;
@@ -167,6 +179,9 @@ public class ScreencastService extends Service {
updateNotification(ScreencastService.this);
}
}, 100, 1000);
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_USER_BACKGROUND);
+ registerReceiver(mUserSwitchReceiver, filter);
}
catch (Exception e) {
Log.e("Mirror", "error", e);
@@ -174,6 +189,7 @@ public class ScreencastService extends Service {
}
else if (intent != null && TextUtils.equals(intent.getAction(), "org.cyanogenmod.ACTION_STOP_SCREENCAST")) {
try {
+ unregisterReceiver(mUserSwitchReceiver);
getSharedPreferences(ScreencastService.PREFS, 0).edit().putBoolean(ScreencastService.KEY_RECORDING, false).apply();
// clean show_touches settings if user enable show_touches in this activity
Settings.System.putInt(getContentResolver(), SHOW_TOUCHES, 0);