Advertisement
Guest User

Untitled

a guest
Sep 6th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. package com.sec.android.app.sbrowser.settings;
  2.  
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.os.Build.VERSION;
  7. import android.text.TextUtils;
  8. import android.util.Log;
  9. import com.sec.android.app.sbrowser.utils.UrlUtil;
  10.  
  11. public class HomepageSettingReceiver extends BroadcastReceiver {
  12. BrowserSettings mBrowserSettings = null;
  13.  
  14. public void onReceive(Context context, Intent intent) {
  15. if (intent != null) {
  16. this.mBrowserSettings = BrowserSettings.getInstance();
  17. String action = intent.getAction();
  18. StringBuilder sb = new StringBuilder();
  19. sb.append(" ** onReceive : URL is received..");
  20. sb.append(action);
  21. Log.w("HomepageSettingReceiver", sb.toString());
  22. if ("android.intent.action.OMADM_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.OMADM_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.OMADM_BROWSER_SET_HOMEPAGE_PROTECTED".equals(action) || "android.intent.action.CSC_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.CSC_BROWSER_SET_HOMEPAGE".equals(action) || "android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE".equals(action)) {
  23. String stringExtra = intent.getStringExtra("homepage");
  24. if (TextUtils.isEmpty(stringExtra) || stringExtra.length() < 3) {
  25. Log.e("HomepageSettingReceiver", " ** onReceive : received URL is Empty or too short!!!");
  26. return;
  27. }
  28. String guessUrl = UrlUtil.guessUrl(stringExtra);
  29. if ("android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE".equals(action)) {
  30. this.mBrowserSettings.setHomepageByChameleon(guessUrl);
  31. }
  32. this.mBrowserSettings.setFactoryResetHomeUrl(guessUrl);
  33. if ("android.intent.action.CSC_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.CSC_BROWSER_SET_HOMEPAGE".equals(action)) {
  34. sendBroadcastWithHomepage(context, "android.intent.action.CSC_BROWSER_HOMEPAGE", true, "com.samsung.sec.android.application.csc");
  35. }
  36. } else if ("android.intent.action.OMADM_BROWSER_GET_HOMEPAGE".equals(action) || "com.samsung.intent.action.OMADM_BROWSER_GET_HOMEPAGE".equals(action)) {
  37. if (VERSION.SDK_INT < 24) {
  38. sendBroadcastWithHomepage(context, "android.intent.action.OMADM_BROWSER_HOMEPAGE", true, null);
  39. } else {
  40. sendBroadcastWithHomepage(context, "com.samsung.intent.action.OMADM_BROWSER_HOMEPAGE", true, "com.ws.dm");
  41. }
  42. } else if ("android.intent.action.STK_BROWSER_GET_HOMEPAGE".equals(action) || "com.samsung.intent.action.STK_BROWSER_GET_HOMEPAGE".equals(action)) {
  43. sendBroadcastWithHomepage(context, "com.samsung.intent.action.STK_BROWSER_HOMEPAGE", false, "com.android.stk");
  44. } else if ("android.intent.action.STK_BROWSER_GET_HOMEPAGE2".equals(action) || "com.samsung.intent.action.STK_BROWSER_GET_HOMEPAGE2".equals(action)) {
  45. sendBroadcastWithHomepage(context, "com.samsung.intent.action.STK_BROWSER_HOMEPAGE2", false, "com.android.stk2");
  46. } else if ("com.samsung.intent.action.RETAIL_SET_HOMEPAGE_AS_QUICKACCESS".equals(action)) {
  47. this.mBrowserSettings.setHomepageAsQuickAccess();
  48. } else {
  49. Log.e("HomepageSettingReceiver", " ** onReceive : Wrong intents are received..");
  50. }
  51. }
  52. }
  53.  
  54. private void sendBroadcastWithHomepage(Context context, String str, boolean z, String str2) {
  55. String str3;
  56. Intent intent = new Intent(str);
  57. if (z) {
  58. str3 = this.mBrowserSettings.getDefaultHomePage();
  59. } else {
  60. str3 = this.mBrowserSettings.getHomePage();
  61. }
  62. intent.putExtra("homepage", str3);
  63. if (!TextUtils.isEmpty(str2)) {
  64. intent.setPackage(str2);
  65. }
  66. context.sendBroadcast(intent);
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement