Fixing issue where screenshot notification remains non-dismissible.
am: 44dbe294fb
* commit '44dbe294fbf06a1def61c48e758621e61ce23b08':
Fixing issue where screenshot notification remains non-dismissible.
This commit is contained in:
@@ -187,6 +187,15 @@
|
|||||||
android:process=":screenshot"
|
android:process=":screenshot"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
|
<!-- Called from PhoneWindowManager -->
|
||||||
|
<receiver android:name=".screenshot.ScreenshotServiceErrorReceiver"
|
||||||
|
android:process=":screenshot"
|
||||||
|
android:exported="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.android.systemui.screenshot.SHOW_ERROR" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<service android:name=".LoadAverageService"
|
<service android:name=".LoadAverageService"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,9 @@
|
|||||||
<string name="screenshot_saved_text">Touch to view your screenshot.</string>
|
<string name="screenshot_saved_text">Touch to view your screenshot.</string>
|
||||||
<!-- Notification title displayed when we fail to take a screenshot. [CHAR LIMIT=50] -->
|
<!-- Notification title displayed when we fail to take a screenshot. [CHAR LIMIT=50] -->
|
||||||
<string name="screenshot_failed_title">Couldn\'t capture screenshot.</string>
|
<string name="screenshot_failed_title">Couldn\'t capture screenshot.</string>
|
||||||
<!-- Notification text displayed when we fail to take a screenshot. [CHAR LIMIT=100] -->
|
<!-- Notification text displayed when we fail to save a screenshot for unknown reasons. [CHAR LIMIT=100] -->
|
||||||
|
<string name="screenshot_failed_to_save_unknown_text">Problem encountered while saving screenshot.</string>
|
||||||
|
<!-- Notification text displayed when we fail to save a screenshot. [CHAR LIMIT=100] -->
|
||||||
<string name="screenshot_failed_to_save_text">Can\'t save screenshot due to limited storage space.</string>
|
<string name="screenshot_failed_to_save_text">Can\'t save screenshot due to limited storage space.</string>
|
||||||
<!-- Notification text displayed when we fail to take a screenshot. [CHAR LIMIT=100] -->
|
<!-- Notification text displayed when we fail to take a screenshot. [CHAR LIMIT=100] -->
|
||||||
<string name="screenshot_failed_to_capture_text">Taking screenshots is not allowed by the app or your organization.</string>
|
<string name="screenshot_failed_to_capture_text">Taking screenshots is not allowed by the app or your organization.</string>
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.systemui.screenshot;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import com.android.systemui.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a number of miscellaneous, non-system-critical actions
|
||||||
|
* after the system has finished booting.
|
||||||
|
*/
|
||||||
|
public class ScreenshotServiceErrorReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(final Context context, Intent intent) {
|
||||||
|
// Show a message that we've failed to save the image to disk
|
||||||
|
NotificationManager nm = (NotificationManager)
|
||||||
|
context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
GlobalScreenshot.notifyScreenshotError(context, nm,
|
||||||
|
R.string.screenshot_failed_to_save_unknown_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -251,6 +251,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
// app shows again. If that doesn't happen for 30s we drop the gesture.
|
// app shows again. If that doesn't happen for 30s we drop the gesture.
|
||||||
private static final long PANIC_GESTURE_EXPIRATION = 30000;
|
private static final long PANIC_GESTURE_EXPIRATION = 30000;
|
||||||
|
|
||||||
|
private static final String SYSUI_PACKAGE = "com.android.systemui";
|
||||||
|
private static final String SYSUI_SCREENSHOT_SERVICE =
|
||||||
|
"com.android.systemui.screenshot.TakeScreenshotService";
|
||||||
|
private static final String SYSUI_SCREENSHOT_ERROR_RECEIVER =
|
||||||
|
"com.android.systemui.screenshot.ScreenshotServiceErrorReceiver";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyguard stuff
|
* Keyguard stuff
|
||||||
*/
|
*/
|
||||||
@@ -5186,6 +5192,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
if (mScreenshotConnection != null) {
|
if (mScreenshotConnection != null) {
|
||||||
mContext.unbindService(mScreenshotConnection);
|
mContext.unbindService(mScreenshotConnection);
|
||||||
mScreenshotConnection = null;
|
mScreenshotConnection = null;
|
||||||
|
notifyScreenshotError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5197,10 +5204,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
if (mScreenshotConnection != null) {
|
if (mScreenshotConnection != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ComponentName cn = new ComponentName("com.android.systemui",
|
final ComponentName serviceComponent = new ComponentName(SYSUI_PACKAGE,
|
||||||
"com.android.systemui.screenshot.TakeScreenshotService");
|
SYSUI_SCREENSHOT_SERVICE);
|
||||||
Intent intent = new Intent();
|
final Intent serviceIntent = new Intent();
|
||||||
intent.setComponent(cn);
|
serviceIntent.setComponent(serviceComponent);
|
||||||
ServiceConnection conn = new ServiceConnection() {
|
ServiceConnection conn = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
@@ -5235,17 +5242,35 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {}
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
notifyScreenshotError();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (mContext.bindServiceAsUser(
|
if (mContext.bindServiceAsUser(serviceIntent, conn,
|
||||||
intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) {
|
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
|
||||||
|
UserHandle.CURRENT)) {
|
||||||
mScreenshotConnection = conn;
|
mScreenshotConnection = conn;
|
||||||
mHandler.postDelayed(mScreenshotTimeout, 10000);
|
mHandler.postDelayed(mScreenshotTimeout, 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the screenshot service to show an error.
|
||||||
|
*/
|
||||||
|
private void notifyScreenshotError() {
|
||||||
|
// If the service process is killed, then ask it to clean up after itself
|
||||||
|
final ComponentName errorComponent = new ComponentName(SYSUI_PACKAGE,
|
||||||
|
SYSUI_SCREENSHOT_ERROR_RECEIVER);
|
||||||
|
Intent errorIntent = new Intent();
|
||||||
|
errorIntent.setComponent(errorComponent);
|
||||||
|
errorIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT |
|
||||||
|
Intent.FLAG_RECEIVER_FOREGROUND);
|
||||||
|
mContext.sendBroadcastAsUser(errorIntent, UserHandle.ALL);
|
||||||
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
|
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
|
||||||
|
|||||||
Reference in New Issue
Block a user