Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -602,6 +602,7 @@ java_library { "core/java/android/speech/tts/EventLogTags.logtags", "core/java/android/net/EventLogTags.logtags", "core/java/android/webkit/EventLogTags.logtags", "core/java/com/android/internal/app/EventLogTags.logtags", "core/java/com/android/internal/logging/EventLogTags.logtags", "core/java/com/android/server/DropboxLogTags.logtags", "core/java/org/chromium/arc/EventLogTags.logtags", Loading core/java/com/android/internal/app/EventLogTags.logtags 0 → 100644 +6 −0 Original line number Diff line number Diff line # See system/core/logcat/event.logtags for a description of the format of this file. option java_package com.android.internal.app; 53000 harmful_app_warning_uninstall (package_name|3) 53001 harmful_app_warning_launch_anyway (package_name|3) No newline at end of file core/java/com/android/internal/app/HarmfulAppWarningActivity.java +42 −17 Original line number Diff line number Diff line Loading @@ -20,8 +20,12 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.TextView; import com.android.internal.R; /** Loading @@ -31,7 +35,7 @@ import com.android.internal.R; */ public class HarmfulAppWarningActivity extends AlertActivity implements DialogInterface.OnClickListener { private static final String TAG = "HarmfulAppWarningActivity"; private static final String TAG = HarmfulAppWarningActivity.class.getSimpleName(); private static final String EXTRA_HARMFUL_APP_WARNING = "harmful_app_warning"; Loading @@ -39,13 +43,11 @@ public class HarmfulAppWarningActivity extends AlertActivity implements private String mHarmfulAppWarning; private IntentSender mTarget; // [b/63909431] STOPSHIP replace placeholder UI with final Harmful App Warning UI @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); final Intent intent = getIntent(); mPackageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME); mTarget = intent.getParcelableExtra(Intent.EXTRA_INTENT); mHarmfulAppWarning = intent.getStringExtra(EXTRA_HARMFUL_APP_WARNING); Loading @@ -55,33 +57,56 @@ public class HarmfulAppWarningActivity extends AlertActivity implements finish(); } AlertController.AlertParams p = mAlertParams; final ApplicationInfo applicationInfo; try { applicationInfo = getPackageManager().getApplicationInfo(mPackageName, 0 /*flags*/); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Could not show warning because package does not exist ", e); finish(); return; } final AlertController.AlertParams p = mAlertParams; p.mTitle = getString(R.string.harmful_app_warning_title); p.mMessage = mHarmfulAppWarning; p.mPositiveButtonText = getString(R.string.harmful_app_warning_launch_anyway); p.mView = createView(applicationInfo); p.mPositiveButtonText = getString(R.string.harmful_app_warning_uninstall); p.mPositiveButtonListener = this; p.mNegativeButtonText = getString(R.string.harmful_app_warning_uninstall); p.mNegativeButtonText = getString(R.string.harmful_app_warning_open_anyway); p.mNegativeButtonListener = this; mAlert.installContent(mAlertParams); } private View createView(ApplicationInfo applicationInfo) { final View view = getLayoutInflater().inflate(R.layout.harmful_app_warning_dialog, null /*root*/); ((TextView) view.findViewById(R.id.app_name_text)) .setText(applicationInfo.loadSafeLabel(getPackageManager())); ((TextView) view.findViewById(R.id.message)) .setText(mHarmfulAppWarning); return view; } @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: getPackageManager().setHarmfulAppWarning(mPackageName, null); getPackageManager().deletePackage(mPackageName, null /*observer*/, 0 /*flags*/); EventLogTags.writeHarmfulAppWarningUninstall(mPackageName); finish(); break; case DialogInterface.BUTTON_NEGATIVE: getPackageManager().setHarmfulAppWarning(mPackageName, null /*warning*/); IntentSender target = getIntent().getParcelableExtra(Intent.EXTRA_INTENT); final IntentSender target = getIntent().getParcelableExtra(Intent.EXTRA_INTENT); try { startIntentSenderForResult(target, -1, null, 0, 0, 0); startIntentSenderForResult(target, -1 /*requestCode*/, null /*fillInIntent*/, 0 /*flagsMask*/, 0 /*flagsValue*/, 0 /*extraFlags*/); } catch (IntentSender.SendIntentException e) { // ignore.. Log.e(TAG, "Error while starting intent sender", e); } finish(); break; case DialogInterface.BUTTON_NEGATIVE: getPackageManager().deletePackage(mPackageName, null, 0); EventLogTags.writeHarmfulAppWarningLaunchAnyway(mPackageName); finish(); break; } Loading @@ -89,7 +114,7 @@ public class HarmfulAppWarningActivity extends AlertActivity implements public static Intent createHarmfulAppWarningIntent(Context context, String targetPackageName, IntentSender target, CharSequence harmfulAppWarning) { Intent intent = new Intent(); final Intent intent = new Intent(); intent.setClass(context, HarmfulAppWarningActivity.class); intent.putExtra(Intent.EXTRA_PACKAGE_NAME, targetPackageName); intent.putExtra(Intent.EXTRA_INTENT, target); Loading core/res/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3967,6 +3967,7 @@ android:theme="@style/Theme.DeviceDefault.Light.Dialog.Alert" android:excludeFromRecents="true" android:process=":ui" android:label="@string/harmful_app_warning_title" android:exported="false"> </activity> Loading core/res/res/drawable/red_shield.xml 0 → 100644 +32 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="34dp" android:height="37dp" android:viewportWidth="34" android:viewportHeight="37"> <group android:translateX="-3.000000" android:translateY="-2.000000"> <path android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 0 0 H 40 V 40 H 0 V 0 Z" /> <path android:fillColor="#D0021B" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M35.5858891,6.865 C27.841629,3.02166667 19.6666667,2 19.6666667,2 C19.6666667,2 11.4917044,3.02166667 3.74744428,6.865 C3.25808614,8.915 3,11.0533333 3,13.2533333 C3,15.515 3.27484498,17.715 3.79269315,19.8216667 C4.89374895,24.3033333 7.09753645,28.355 10.1023965,31.6783333 C12.7385621,34.5983333 15.9964806,36.955 19.6666667,38.5433333 C23.3368527,36.955 26.5947712,34.5983333 29.2326127,31.6783333 C32.2357969,28.355 34.4395844,24.3033333 35.5423161,19.8216667 C36.0584884,17.715 36.3333333,15.515 36.3333333,13.2533333 C36.3333333,11.0533333 36.0769231,8.915 35.5858891,6.865 M21.3333333,27.8333333 L18,27.8333333 L18,24.5 L21.3333333,24.5 L21.3333333,27.8333333 L21.3333333,27.8333333 Z M21.3333333,22 L18,22 L18,12 L21.3333333,12 L21.3333333,22 L21.3333333,22 Z" /> </group> </vector> No newline at end of file Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -602,6 +602,7 @@ java_library { "core/java/android/speech/tts/EventLogTags.logtags", "core/java/android/net/EventLogTags.logtags", "core/java/android/webkit/EventLogTags.logtags", "core/java/com/android/internal/app/EventLogTags.logtags", "core/java/com/android/internal/logging/EventLogTags.logtags", "core/java/com/android/server/DropboxLogTags.logtags", "core/java/org/chromium/arc/EventLogTags.logtags", Loading
core/java/com/android/internal/app/EventLogTags.logtags 0 → 100644 +6 −0 Original line number Diff line number Diff line # See system/core/logcat/event.logtags for a description of the format of this file. option java_package com.android.internal.app; 53000 harmful_app_warning_uninstall (package_name|3) 53001 harmful_app_warning_launch_anyway (package_name|3) No newline at end of file
core/java/com/android/internal/app/HarmfulAppWarningActivity.java +42 −17 Original line number Diff line number Diff line Loading @@ -20,8 +20,12 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.TextView; import com.android.internal.R; /** Loading @@ -31,7 +35,7 @@ import com.android.internal.R; */ public class HarmfulAppWarningActivity extends AlertActivity implements DialogInterface.OnClickListener { private static final String TAG = "HarmfulAppWarningActivity"; private static final String TAG = HarmfulAppWarningActivity.class.getSimpleName(); private static final String EXTRA_HARMFUL_APP_WARNING = "harmful_app_warning"; Loading @@ -39,13 +43,11 @@ public class HarmfulAppWarningActivity extends AlertActivity implements private String mHarmfulAppWarning; private IntentSender mTarget; // [b/63909431] STOPSHIP replace placeholder UI with final Harmful App Warning UI @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); final Intent intent = getIntent(); mPackageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME); mTarget = intent.getParcelableExtra(Intent.EXTRA_INTENT); mHarmfulAppWarning = intent.getStringExtra(EXTRA_HARMFUL_APP_WARNING); Loading @@ -55,33 +57,56 @@ public class HarmfulAppWarningActivity extends AlertActivity implements finish(); } AlertController.AlertParams p = mAlertParams; final ApplicationInfo applicationInfo; try { applicationInfo = getPackageManager().getApplicationInfo(mPackageName, 0 /*flags*/); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Could not show warning because package does not exist ", e); finish(); return; } final AlertController.AlertParams p = mAlertParams; p.mTitle = getString(R.string.harmful_app_warning_title); p.mMessage = mHarmfulAppWarning; p.mPositiveButtonText = getString(R.string.harmful_app_warning_launch_anyway); p.mView = createView(applicationInfo); p.mPositiveButtonText = getString(R.string.harmful_app_warning_uninstall); p.mPositiveButtonListener = this; p.mNegativeButtonText = getString(R.string.harmful_app_warning_uninstall); p.mNegativeButtonText = getString(R.string.harmful_app_warning_open_anyway); p.mNegativeButtonListener = this; mAlert.installContent(mAlertParams); } private View createView(ApplicationInfo applicationInfo) { final View view = getLayoutInflater().inflate(R.layout.harmful_app_warning_dialog, null /*root*/); ((TextView) view.findViewById(R.id.app_name_text)) .setText(applicationInfo.loadSafeLabel(getPackageManager())); ((TextView) view.findViewById(R.id.message)) .setText(mHarmfulAppWarning); return view; } @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: getPackageManager().setHarmfulAppWarning(mPackageName, null); getPackageManager().deletePackage(mPackageName, null /*observer*/, 0 /*flags*/); EventLogTags.writeHarmfulAppWarningUninstall(mPackageName); finish(); break; case DialogInterface.BUTTON_NEGATIVE: getPackageManager().setHarmfulAppWarning(mPackageName, null /*warning*/); IntentSender target = getIntent().getParcelableExtra(Intent.EXTRA_INTENT); final IntentSender target = getIntent().getParcelableExtra(Intent.EXTRA_INTENT); try { startIntentSenderForResult(target, -1, null, 0, 0, 0); startIntentSenderForResult(target, -1 /*requestCode*/, null /*fillInIntent*/, 0 /*flagsMask*/, 0 /*flagsValue*/, 0 /*extraFlags*/); } catch (IntentSender.SendIntentException e) { // ignore.. Log.e(TAG, "Error while starting intent sender", e); } finish(); break; case DialogInterface.BUTTON_NEGATIVE: getPackageManager().deletePackage(mPackageName, null, 0); EventLogTags.writeHarmfulAppWarningLaunchAnyway(mPackageName); finish(); break; } Loading @@ -89,7 +114,7 @@ public class HarmfulAppWarningActivity extends AlertActivity implements public static Intent createHarmfulAppWarningIntent(Context context, String targetPackageName, IntentSender target, CharSequence harmfulAppWarning) { Intent intent = new Intent(); final Intent intent = new Intent(); intent.setClass(context, HarmfulAppWarningActivity.class); intent.putExtra(Intent.EXTRA_PACKAGE_NAME, targetPackageName); intent.putExtra(Intent.EXTRA_INTENT, target); Loading
core/res/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3967,6 +3967,7 @@ android:theme="@style/Theme.DeviceDefault.Light.Dialog.Alert" android:excludeFromRecents="true" android:process=":ui" android:label="@string/harmful_app_warning_title" android:exported="false"> </activity> Loading
core/res/res/drawable/red_shield.xml 0 → 100644 +32 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="34dp" android:height="37dp" android:viewportWidth="34" android:viewportHeight="37"> <group android:translateX="-3.000000" android:translateY="-2.000000"> <path android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M 0 0 H 40 V 40 H 0 V 0 Z" /> <path android:fillColor="#D0021B" android:fillType="evenOdd" android:strokeWidth="1" android:pathData="M35.5858891,6.865 C27.841629,3.02166667 19.6666667,2 19.6666667,2 C19.6666667,2 11.4917044,3.02166667 3.74744428,6.865 C3.25808614,8.915 3,11.0533333 3,13.2533333 C3,15.515 3.27484498,17.715 3.79269315,19.8216667 C4.89374895,24.3033333 7.09753645,28.355 10.1023965,31.6783333 C12.7385621,34.5983333 15.9964806,36.955 19.6666667,38.5433333 C23.3368527,36.955 26.5947712,34.5983333 29.2326127,31.6783333 C32.2357969,28.355 34.4395844,24.3033333 35.5423161,19.8216667 C36.0584884,17.715 36.3333333,15.515 36.3333333,13.2533333 C36.3333333,11.0533333 36.0769231,8.915 35.5858891,6.865 M21.3333333,27.8333333 L18,27.8333333 L18,24.5 L21.3333333,24.5 L21.3333333,27.8333333 L21.3333333,27.8333333 Z M21.3333333,22 L18,22 L18,12 L21.3333333,12 L21.3333333,22 L21.3333333,22 Z" /> </group> </vector> No newline at end of file