зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1072376 - Only set lock screen flags if we're showing on the lockscreen. r=lucasr
This commit is contained in:
Родитель
c8d14e42a2
Коммит
b095b0ee5a
|
@ -78,8 +78,8 @@ import org.mozilla.gecko.widget.GeckoActionProvider;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -521,14 +521,8 @@ public class BrowserApp extends GeckoApp
|
|||
final String args = intent.getStringExtra("args");
|
||||
|
||||
if (GuestSession.shouldUse(this, args)) {
|
||||
GuestSession.configureWindow(getWindow());
|
||||
mProfile = GeckoProfile.createGuestProfile(this);
|
||||
} else {
|
||||
// We also allow non-guest sessions if the keyguard isn't a secure one.
|
||||
final KeyguardManager manager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
||||
if (Versions.feature16Plus && !manager.isKeyguardSecure()) {
|
||||
GuestSession.configureWindow(getWindow());
|
||||
}
|
||||
GeckoProfile.maybeCleanupGuestProfile(this);
|
||||
}
|
||||
|
||||
|
@ -757,6 +751,7 @@ public class BrowserApp extends GeckoApp
|
|||
final String args = getIntent().getStringExtra("args");
|
||||
// If an external intent tries to start Fennec in guest mode, and it's not already
|
||||
// in guest mode, this will change modes before opening the url.
|
||||
// NOTE: OnResume is called twice sometimes when showing on the lock screen.
|
||||
final boolean enableGuestSession = GuestSession.shouldUse(this, args);
|
||||
final boolean inGuestSession = GeckoProfile.get(this).inGuestMode();
|
||||
if (enableGuestSession != inGuestSession) {
|
||||
|
@ -765,6 +760,19 @@ public class BrowserApp extends GeckoApp
|
|||
return;
|
||||
}
|
||||
|
||||
final KeyguardManager manager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
||||
// The test machines return null for the KeyguardService, despite running Android 4.2.
|
||||
if (Versions.feature11Plus && manager != null) {
|
||||
// If the keyguard is showing AND we're either in guest mode or the keyguard is insecure,
|
||||
// allow showing this window. We do this in onResume so that we can avoid setting these flags if the keyguard
|
||||
// is not showing since it affects Android's layout of the window.
|
||||
if (manager.isKeyguardLocked() && (GeckoProfile.get(this).inGuestMode() || !manager.isKeyguardSecure())) {
|
||||
GuestSession.configureWindow(getWindow());
|
||||
} else {
|
||||
GuestSession.unconfigureWindow(getWindow());
|
||||
}
|
||||
}
|
||||
|
||||
EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener)this,
|
||||
"Prompt:ShowTop");
|
||||
}
|
||||
|
|
|
@ -73,9 +73,14 @@ public class GuestSession {
|
|||
|
||||
public static void configureWindow(Window window) {
|
||||
// In guest sessions we allow showing over the keyguard.
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
}
|
||||
|
||||
public static void unconfigureWindow(Window window) {
|
||||
// In guest sessions we allow showing over the keyguard.
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
}
|
||||
|
||||
private static PendingIntent getNotificationIntent(Context context) {
|
||||
Intent intent = new Intent(NOTIFICATION_INTENT);
|
||||
intent.setClass(context, BrowserApp.class);
|
||||
|
|
Загрузка…
Ссылка в новой задаче