| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.internal.app; |
| 18 |
|
| 19 |
import android.content.Intent; |
| 20 |
import android.content.pm.ActivityInfo; |
| 21 |
import android.os.Bundle; |
| 22 |
import android.text.TextUtils; |
| 23 |
import android.util.Slog; |
| 24 |
|
| 25 |
import com.android.internal.R; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
public class BlockedAppStreamingActivity extends AlertActivity { |
| 33 |
|
| 34 |
private static final String TAG = "BlockedAppStreamingActivity"; |
| 35 |
private static final String PACKAGE_NAME = "com.android.internal.app"; |
| 36 |
private static final String EXTRA_BLOCKED_ACTIVITY_INFO = |
| 37 |
PACKAGE_NAME + ".extra.BLOCKED_ACTIVITY_INFO"; |
| 38 |
private static final String EXTRA_STREAMED_DEVICE = PACKAGE_NAME + ".extra.STREAMED_DEVICE"; |
| 39 |
private static final String BLOCKED_COMPONENT_PLAYSTORE = "com.android.vending"; |
| 40 |
private static final String BLOCKED_COMPONENT_SETTINGS = "com.android.settings"; |
| 41 |
|
| 42 |
@Override |
| 43 |
protected void onCreate(Bundle savedInstanceState) { |
| 44 |
super.onCreate(savedInstanceState); |
| 45 |
|
| 46 |
Intent intent = getIntent(); |
| 47 |
CharSequence appLabel = null; |
| 48 |
ActivityInfo activityInfo = intent.getParcelableExtra(EXTRA_BLOCKED_ACTIVITY_INFO); |
| 49 |
if (activityInfo != null) { |
| 50 |
appLabel = activityInfo.loadLabel(getPackageManager()); |
| 51 |
} |
| 52 |
|
| 53 |
if (TextUtils.isEmpty(appLabel)) { |
| 54 |
Slog.wtf(TAG, "Invalid activity info: " + activityInfo); |
| 55 |
finish(); |
| 56 |
return; |
| 57 |
} |
| 58 |
|
| 59 |
CharSequence streamedDeviceName = intent.getCharSequenceExtra(EXTRA_STREAMED_DEVICE); |
| 60 |
if (!TextUtils.isEmpty(streamedDeviceName)) { |
| 61 |
if (TextUtils.equals(activityInfo.packageName, |
| 62 |
getPackageManager().getPermissionControllerPackageName())) { |
| 63 |
mAlertParams.mTitle = |
| 64 |
getString(R.string.app_streaming_blocked_title_for_permission_dialog); |
| 65 |
mAlertParams.mMessage = |
| 66 |
getString(R.string.app_streaming_blocked_message, streamedDeviceName); |
| 67 |
} else if (TextUtils.equals(activityInfo.packageName, BLOCKED_COMPONENT_PLAYSTORE)) { |
| 68 |
mAlertParams.mTitle = |
| 69 |
getString(R.string.app_streaming_blocked_title_for_playstore_dialog); |
| 70 |
mAlertParams.mMessage = |
| 71 |
getString(R.string.app_streaming_blocked_message, streamedDeviceName); |
| 72 |
} else if (TextUtils.equals(activityInfo.packageName, BLOCKED_COMPONENT_SETTINGS)) { |
| 73 |
mAlertParams.mTitle = |
| 74 |
getString(R.string.app_streaming_blocked_title_for_settings_dialog); |
| 75 |
mAlertParams.mMessage = |
| 76 |
getString(R.string.app_streaming_blocked_message_for_settings_dialog, |
| 77 |
streamedDeviceName); |
| 78 |
} else { |
| 79 |
|
| 80 |
mAlertParams.mMessage = |
| 81 |
getString(R.string.app_streaming_blocked_message, streamedDeviceName); |
| 82 |
} |
| 83 |
} else { |
| 84 |
|
| 85 |
mAlertParams.mMessage = getString(R.string.app_blocked_message, appLabel); |
| 86 |
} |
| 87 |
mAlertParams.mPositiveButtonText = getString(android.R.string.ok); |
| 88 |
setupAlert(); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public static Intent createIntent(ActivityInfo activityInfo, CharSequence streamedDeviceName) { |
| 96 |
return new Intent() |
| 97 |
.setClassName("android", BlockedAppStreamingActivity.class.getName()) |
| 98 |
.putExtra(EXTRA_BLOCKED_ACTIVITY_INFO, activityInfo) |
| 99 |
.putExtra(EXTRA_STREAMED_DEVICE, streamedDeviceName); |
| 100 |
} |
| 101 |
} |