Skip to content

Commit 65cbcbe

Browse files
author
John Spurlock
committed
Remove add widget transition jank (insecure).
Refactor to use common activity launcher. Still work to do on secure. Bug:7482560 Change-Id: I2f8869afe8172850e1cb019a051aaeb49bb8c5bc
1 parent ae73c69 commit 65cbcbe

File tree

2 files changed

+31
-38
lines changed

2 files changed

+31
-38
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardActivityLauncher.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import android.app.ActivityManagerNative;
2020
import android.app.ActivityOptions;
2121
import android.app.IActivityManager.WaitResult;
22+
import android.appwidget.AppWidgetManager;
23+
import android.appwidget.AppWidgetProviderInfo;
2224
import android.content.ActivityNotFoundException;
2325
import android.content.Context;
2426
import android.content.Intent;
@@ -112,6 +114,27 @@ public void launchCamera(Handler worker, Runnable onSecureCameraStarted) {
112114
}
113115
}
114116

117+
public void launchWidgetPicker(int appWidgetId) {
118+
Intent pickIntent = new Intent(AppWidgetManager.ACTION_KEYGUARD_APPWIDGET_PICK);
119+
120+
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
121+
pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false);
122+
pickIntent.putExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER,
123+
AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
124+
125+
Bundle options = new Bundle();
126+
options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
127+
AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
128+
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
129+
pickIntent.addFlags(
130+
Intent.FLAG_ACTIVITY_NEW_TASK
131+
| Intent.FLAG_ACTIVITY_SINGLE_TOP
132+
| Intent.FLAG_ACTIVITY_CLEAR_TOP
133+
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
134+
135+
launchActivity(pickIntent, false, false, null, null);
136+
}
137+
115138
/**
116139
* Launches the said intent for the current foreground user.
117140
*
@@ -128,7 +151,8 @@ public void launchActivity(final Intent intent,
128151
final Handler worker,
129152
final Runnable onStarted) {
130153
final Context context = getContext();
131-
final Bundle animation = ActivityOptions.makeCustomAnimation(context, 0, 0).toBundle();
154+
final Bundle animation = useDefaultAnimations ? null
155+
: ActivityOptions.makeCustomAnimation(context, 0, 0).toBundle();
132156
LockPatternUtils lockPatternUtils = getLockPatternUtils();
133157
intent.addFlags(
134158
Intent.FLAG_ACTIVITY_NEW_TASK

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@
3333
import android.content.res.Resources;
3434
import android.graphics.Canvas;
3535
import android.graphics.Rect;
36-
import android.os.Bundle;
3736
import android.os.Looper;
3837
import android.os.Parcel;
3938
import android.os.Parcelable;
4039
import android.os.SystemClock;
41-
import android.os.UserHandle;
4240
import android.os.UserManager;
4341
import android.util.AttributeSet;
4442
import android.util.Log;
@@ -898,48 +896,19 @@ private void addDefaultWidgets() {
898896
addWidgetButton.setOnClickListener(new OnClickListener() {
899897
@Override
900898
public void onClick(View v) {
901-
mCallback.setOnDismissRunnable(new Runnable() {
902-
903-
@Override
904-
public void run() {
905-
launchPickActivityIntent();
906-
}
907-
});
908-
mCallback.dismiss(false);
899+
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
900+
if (appWidgetId != -1) {
901+
mActivityLauncher.launchWidgetPicker(appWidgetId);
902+
} else {
903+
Log.e(TAG, "Unable to allocate an AppWidget id in lock screen");
904+
}
909905
}
910906
});
911907

912908
enableUserSelectorIfNecessary();
913909
initializeTransportControl();
914910
}
915911

916-
private void launchPickActivityIntent() {
917-
// Create intent to pick widget
918-
Intent pickIntent = new Intent(AppWidgetManager.ACTION_KEYGUARD_APPWIDGET_PICK);
919-
920-
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
921-
if (appWidgetId != -1) {
922-
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
923-
pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false);
924-
pickIntent.putExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER,
925-
AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
926-
927-
Bundle options = new Bundle();
928-
options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
929-
AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
930-
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
931-
pickIntent.addFlags(
932-
Intent.FLAG_ACTIVITY_NEW_TASK
933-
| Intent.FLAG_ACTIVITY_SINGLE_TOP
934-
| Intent.FLAG_ACTIVITY_CLEAR_TOP
935-
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
936-
mContext.startActivityAsUser(pickIntent,
937-
new UserHandle(UserHandle.USER_CURRENT));
938-
} else {
939-
Log.e(TAG, "Unable to allocate an AppWidget id in lock screen");
940-
}
941-
}
942-
943912
private void removeTransportFromWidgetPager() {
944913
int page = getWidgetPosition(R.id.keyguard_transport_control);
945914
if (page != -1) {

0 commit comments

Comments
 (0)