Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
c6baa82f
Commit
c6baa82f
authored
4 years ago
by
Miranda Kephart
Committed by
Android (Google) Code Review
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge "[DO NOT MERGE] Close screenshot process on user switched" into rvc-qpr-dev
parents
a8ef91d3
05f7aef1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/java/com/android/internal/util/ScreenshotHelper.java
+31
-11
31 additions, 11 deletions
core/java/com/android/internal/util/ScreenshotHelper.java
with
31 additions
and
11 deletions
core/java/com/android/internal/util/ScreenshotHelper.java
+
31
−
11
View file @
c6baa82f
package
com.android.internal.util
;
import
static
android
.
content
.
Intent
.
ACTION_USER_SWITCHED
;
import
static
android
.
view
.
WindowManager
.
ScreenshotSource
.
SCREENSHOT_OTHER
;
import
android.annotation.NonNull
;
import
android.annotation.Nullable
;
import
android.content.BroadcastReceiver
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.ServiceConnection
;
import
android.graphics.Insets
;
import
android.graphics.Rect
;
...
...
@@ -161,8 +164,21 @@ public class ScreenshotHelper {
private
ServiceConnection
mScreenshotConnection
=
null
;
private
final
Context
mContext
;
private
final
BroadcastReceiver
mBroadcastReceiver
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
synchronized
(
mScreenshotLock
)
{
if
(
ACTION_USER_SWITCHED
.
equals
(
intent
.
getAction
()))
{
resetConnection
();
}
}
}
};
public
ScreenshotHelper
(
Context
context
)
{
mContext
=
context
;
IntentFilter
filter
=
new
IntentFilter
(
ACTION_USER_SWITCHED
);
mContext
.
registerReceiver
(
mBroadcastReceiver
,
filter
);
}
/**
...
...
@@ -279,9 +295,8 @@ public class ScreenshotHelper {
final
Runnable
mScreenshotTimeout
=
()
->
{
synchronized
(
mScreenshotLock
)
{
if
(
mScreenshotConnection
!=
null
)
{
mContext
.
unbindService
(
mScreenshotConnection
);
mScreenshotConnection
=
null
;
mScreenshotService
=
null
;
Log
.
e
(
TAG
,
"Timed out before getting screenshot capture response"
);
resetConnection
();
notifyScreenshotError
();
}
}
...
...
@@ -304,11 +319,7 @@ public class ScreenshotHelper {
break
;
case
SCREENSHOT_MSG_PROCESS_COMPLETE:
synchronized
(
mScreenshotLock
)
{
if
(
mScreenshotConnection
!=
null
)
{
mContext
.
unbindService
(
mScreenshotConnection
);
mScreenshotConnection
=
null
;
mScreenshotService
=
null
;
}
resetConnection
();
}
break
;
}
...
...
@@ -348,9 +359,7 @@ public class ScreenshotHelper {
public
void
onServiceDisconnected
(
ComponentName
name
)
{
synchronized
(
mScreenshotLock
)
{
if
(
mScreenshotConnection
!=
null
)
{
mContext
.
unbindService
(
mScreenshotConnection
);
mScreenshotConnection
=
null
;
mScreenshotService
=
null
;
resetConnection
();
// only log an error if we're still within the timeout period
if
(
handler
.
hasCallbacks
(
mScreenshotTimeout
))
{
handler
.
removeCallbacks
(
mScreenshotTimeout
);
...
...
@@ -382,6 +391,17 @@ public class ScreenshotHelper {
}
}
/**
* Unbinds the current screenshot connection (if any).
*/
private
void
resetConnection
()
{
if
(
mScreenshotConnection
!=
null
)
{
mContext
.
unbindService
(
mScreenshotConnection
);
mScreenshotConnection
=
null
;
mScreenshotService
=
null
;
}
}
/**
* Notifies the screenshot service to show an error.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment