Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sec.android.app.sbrowser.settings;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Build.VERSION;
- import android.text.TextUtils;
- import android.util.Log;
- import com.sec.android.app.sbrowser.utils.UrlUtil;
- public class HomepageSettingReceiver extends BroadcastReceiver {
- BrowserSettings mBrowserSettings = null;
- public void onReceive(Context context, Intent intent) {
- if (intent != null) {
- this.mBrowserSettings = BrowserSettings.getInstance();
- String action = intent.getAction();
- StringBuilder sb = new StringBuilder();
- sb.append(" ** onReceive : URL is received..");
- sb.append(action);
- Log.w("HomepageSettingReceiver", sb.toString());
- 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)) {
- String stringExtra = intent.getStringExtra("homepage");
- if (TextUtils.isEmpty(stringExtra) || stringExtra.length() < 3) {
- Log.e("HomepageSettingReceiver", " ** onReceive : received URL is Empty or too short!!!");
- return;
- }
- String guessUrl = UrlUtil.guessUrl(stringExtra);
- if ("android.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.CHAMELEON_BROWSER_SET_HOMEPAGE".equals(action)) {
- this.mBrowserSettings.setHomepageByChameleon(guessUrl);
- }
- this.mBrowserSettings.setFactoryResetHomeUrl(guessUrl);
- if ("android.intent.action.CSC_BROWSER_SET_HOMEPAGE".equals(action) || "com.samsung.intent.action.CSC_BROWSER_SET_HOMEPAGE".equals(action)) {
- sendBroadcastWithHomepage(context, "android.intent.action.CSC_BROWSER_HOMEPAGE", true, "com.samsung.sec.android.application.csc");
- }
- } else if ("android.intent.action.OMADM_BROWSER_GET_HOMEPAGE".equals(action) || "com.samsung.intent.action.OMADM_BROWSER_GET_HOMEPAGE".equals(action)) {
- if (VERSION.SDK_INT < 24) {
- sendBroadcastWithHomepage(context, "android.intent.action.OMADM_BROWSER_HOMEPAGE", true, null);
- } else {
- sendBroadcastWithHomepage(context, "com.samsung.intent.action.OMADM_BROWSER_HOMEPAGE", true, "com.ws.dm");
- }
- } else if ("android.intent.action.STK_BROWSER_GET_HOMEPAGE".equals(action) || "com.samsung.intent.action.STK_BROWSER_GET_HOMEPAGE".equals(action)) {
- sendBroadcastWithHomepage(context, "com.samsung.intent.action.STK_BROWSER_HOMEPAGE", false, "com.android.stk");
- } else if ("android.intent.action.STK_BROWSER_GET_HOMEPAGE2".equals(action) || "com.samsung.intent.action.STK_BROWSER_GET_HOMEPAGE2".equals(action)) {
- sendBroadcastWithHomepage(context, "com.samsung.intent.action.STK_BROWSER_HOMEPAGE2", false, "com.android.stk2");
- } else if ("com.samsung.intent.action.RETAIL_SET_HOMEPAGE_AS_QUICKACCESS".equals(action)) {
- this.mBrowserSettings.setHomepageAsQuickAccess();
- } else {
- Log.e("HomepageSettingReceiver", " ** onReceive : Wrong intents are received..");
- }
- }
- }
- private void sendBroadcastWithHomepage(Context context, String str, boolean z, String str2) {
- String str3;
- Intent intent = new Intent(str);
- if (z) {
- str3 = this.mBrowserSettings.getDefaultHomePage();
- } else {
- str3 = this.mBrowserSettings.getHomePage();
- }
- intent.putExtra("homepage", str3);
- if (!TextUtils.isEmpty(str2)) {
- intent.setPackage(str2);
- }
- context.sendBroadcast(intent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement