use of com.android.keyguard.KeyguardHostView.OnDismissAction in project platform_frameworks_base by android.
the class BaseStatusBar method bindGuts.
private void bindGuts(final ExpandableNotificationRow row) {
row.inflateGuts();
final StatusBarNotification sbn = row.getStatusBarNotification();
PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier());
row.setTag(sbn.getPackageName());
final NotificationGuts guts = row.getGuts();
guts.setClosedListener(this);
final String pkg = sbn.getPackageName();
String appname = pkg;
Drawable pkgicon = null;
int appUid = -1;
try {
final ApplicationInfo info = pmUser.getApplicationInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
if (info != null) {
appname = String.valueOf(pmUser.getApplicationLabel(info));
pkgicon = pmUser.getApplicationIcon(info);
appUid = info.uid;
}
} catch (NameNotFoundException e) {
// app is gone, just show package name and generic icon
pkgicon = pmUser.getDefaultActivityIcon();
}
((ImageView) guts.findViewById(R.id.app_icon)).setImageDrawable(pkgicon);
((TextView) guts.findViewById(R.id.pkgname)).setText(appname);
final TextView settingsButton = (TextView) guts.findViewById(R.id.more_settings);
if (appUid >= 0) {
final int appUidF = appUid;
settingsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_INFO);
guts.resetFalsingCheck();
startAppNotificationSettingsActivity(pkg, appUidF);
}
});
settingsButton.setText(R.string.notification_more_settings);
} else {
settingsButton.setVisibility(View.GONE);
}
guts.bindImportance(pmUser, sbn, mNonBlockablePkgs, mNotificationData.getImportance(sbn.getKey()));
final TextView doneButton = (TextView) guts.findViewById(R.id.done);
doneButton.setText(R.string.notification_done);
doneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// If the user has security enabled, show challenge if the setting is changed.
if (guts.hasImportanceChanged() && isLockscreenPublicMode() && (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
OnDismissAction dismissAction = new OnDismissAction() {
@Override
public boolean onDismiss() {
saveImportanceCloseControls(sbn, row, guts, v);
return true;
}
};
onLockedNotificationImportanceChange(dismissAction);
} else {
saveImportanceCloseControls(sbn, row, guts, v);
}
}
});
}
use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by AOSPA.
the class BaseStatusBar method startPendingIntentDismissingKeyguard.
public void startPendingIntentDismissingKeyguard(final PendingIntent intent) {
if (!isDeviceProvisioned())
return;
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
final boolean afterKeyguardGone = intent.isActivity() && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(), mCurrentUserId);
dismissKeyguardThenExecute(new OnDismissAction() {
public boolean onDismiss() {
new Thread() {
@Override
public void run() {
try {
if (keyguardShowing && !afterKeyguardGone) {
ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
}
// The intent we are sending is for the application, which
// won't have permission to immediately start an activity after
// the user switches to home. We know it is safe to do at this
// point, so make sure new activity switches are now allowed.
ActivityManagerNative.getDefault().resumeAppSwitches();
} catch (RemoteException e) {
}
try {
intent.send(null, 0, null, null, null, null, getActivityOptions());
} catch (PendingIntent.CanceledException e) {
// the stack trace isn't very helpful here.
// Just log the exception message.
Log.w(TAG, "Sending intent failed: " + e);
// TODO: Dismiss Keyguard.
}
if (intent.isActivity()) {
mAssistManager.hideAssist();
overrideActivityPendingAppTransition(keyguardShowing && !afterKeyguardGone);
}
}
}.start();
// close the shade if it was open
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, /* force */
true);
visibilityChanged(false);
return true;
}
}, afterKeyguardGone);
}
use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by AOSPA.
the class BaseStatusBar method bindGuts.
private void bindGuts(final ExpandableNotificationRow row) {
row.inflateGuts();
final StatusBarNotification sbn = row.getStatusBarNotification();
PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier());
row.setTag(sbn.getPackageName());
final NotificationGuts guts = row.getGuts();
guts.setClosedListener(this);
final String pkg = sbn.getPackageName();
String appname = pkg;
Drawable pkgicon = null;
int appUid = -1;
try {
final ApplicationInfo info = pmUser.getApplicationInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
if (info != null) {
appname = String.valueOf(pmUser.getApplicationLabel(info));
pkgicon = pmUser.getApplicationIcon(info);
appUid = info.uid;
}
} catch (NameNotFoundException e) {
// app is gone, just show package name and generic icon
pkgicon = pmUser.getDefaultActivityIcon();
}
((ImageView) guts.findViewById(R.id.app_icon)).setImageDrawable(pkgicon);
((TextView) guts.findViewById(R.id.pkgname)).setText(appname);
final TextView settingsButton = (TextView) guts.findViewById(R.id.more_settings);
if (appUid >= 0) {
final int appUidF = appUid;
settingsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_INFO);
guts.resetFalsingCheck();
startAppNotificationSettingsActivity(pkg, appUidF);
}
});
settingsButton.setText(R.string.notification_more_settings);
} else {
settingsButton.setVisibility(View.GONE);
}
guts.bindImportance(pmUser, sbn, mNonBlockablePkgs, mNotificationData.getImportance(sbn.getKey()));
final TextView doneButton = (TextView) guts.findViewById(R.id.done);
doneButton.setText(R.string.notification_done);
doneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// If the user has security enabled, show challenge if the setting is changed.
if (guts.hasImportanceChanged() && isLockscreenPublicMode() && (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
OnDismissAction dismissAction = new OnDismissAction() {
@Override
public boolean onDismiss() {
saveImportanceCloseControls(sbn, row, guts, v);
return true;
}
};
onLockedNotificationImportanceChange(dismissAction);
} else {
saveImportanceCloseControls(sbn, row, guts, v);
}
}
});
}
use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by AOSPA.
the class PhoneStatusBar method executeRunnableDismissingKeyguard.
public void executeRunnableDismissingKeyguard(final Runnable runnable, final Runnable cancelAction, final boolean dismissShade, final boolean afterKeyguardGone, final boolean deferred) {
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
dismissKeyguardThenExecute(new OnDismissAction() {
@Override
public boolean onDismiss() {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
try {
if (keyguardShowing && !afterKeyguardGone) {
ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
}
if (runnable != null) {
runnable.run();
}
} catch (RemoteException e) {
}
}
});
if (dismissShade) {
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, /* force */
true);
}
return deferred;
}
}, cancelAction, afterKeyguardGone);
}
use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by ResurrectionRemix.
the class BaseStatusBar method startPendingIntentDismissingKeyguard.
public void startPendingIntentDismissingKeyguard(final PendingIntent intent) {
if (!isDeviceProvisioned())
return;
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
final boolean afterKeyguardGone = intent.isActivity() && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(), mCurrentUserId);
dismissKeyguardThenExecute(new OnDismissAction() {
public boolean onDismiss() {
new Thread() {
@Override
public void run() {
try {
if (keyguardShowing && !afterKeyguardGone) {
ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
}
// The intent we are sending is for the application, which
// won't have permission to immediately start an activity after
// the user switches to home. We know it is safe to do at this
// point, so make sure new activity switches are now allowed.
ActivityManagerNative.getDefault().resumeAppSwitches();
} catch (RemoteException e) {
}
try {
intent.send(null, 0, null, null, null, null, getActivityOptions());
} catch (PendingIntent.CanceledException e) {
// the stack trace isn't very helpful here.
// Just log the exception message.
Log.w(TAG, "Sending intent failed: " + e);
// TODO: Dismiss Keyguard.
}
if (intent.isActivity()) {
mAssistManager.hideAssist();
overrideActivityPendingAppTransition(keyguardShowing && !afterKeyguardGone);
}
}
}.start();
// close the shade if it was open
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, /* force */
true);
visibilityChanged(false);
return true;
}
}, afterKeyguardGone);
}
Aggregations