mobile/android/base/webapp/Dispatcher.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 package org.mozilla.gecko.webapp;
michael@0 7
michael@0 8 import android.app.Activity;
michael@0 9 import android.content.Intent;
michael@0 10 import android.os.Bundle;
michael@0 11 import android.util.Log;
michael@0 12
michael@0 13 public class Dispatcher extends Activity {
michael@0 14 private static final String LOGTAG = "GeckoWebappDispatcher";
michael@0 15
michael@0 16 @Override
michael@0 17 protected void onCreate(Bundle bundle) {
michael@0 18 super.onCreate(bundle);
michael@0 19
michael@0 20 Allocator allocator = Allocator.getInstance(getApplicationContext());
michael@0 21
michael@0 22 if (bundle == null) {
michael@0 23 bundle = getIntent().getExtras();
michael@0 24 }
michael@0 25
michael@0 26 if (bundle == null) {
michael@0 27 Log.e(LOGTAG, "Passed intent data missing.");
michael@0 28 return;
michael@0 29 }
michael@0 30
michael@0 31 String packageName = bundle.getString("packageName");
michael@0 32
michael@0 33 if (packageName == null) {
michael@0 34 Log.e(LOGTAG, "Package name data missing.");
michael@0 35 return;
michael@0 36 }
michael@0 37
michael@0 38 int index = allocator.getIndexForApp(packageName);
michael@0 39 boolean isInstalled = index >= 0;
michael@0 40 if (!isInstalled) {
michael@0 41 index = allocator.findOrAllocatePackage(packageName);
michael@0 42 }
michael@0 43
michael@0 44 // Copy the intent, without interfering with it.
michael@0 45 Intent intent = new Intent(getIntent());
michael@0 46
michael@0 47 // Only change it's destination.
michael@0 48 intent.setClassName(getApplicationContext(), getPackageName() + ".WebApps$WebApp" + index);
michael@0 49
michael@0 50 // If and only if we haven't seen this before.
michael@0 51 intent.putExtra("isInstalled", isInstalled);
michael@0 52
michael@0 53 startActivity(intent);
michael@0 54 }
michael@0 55 }

mercurial