summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMathew Inwood <mathewi@google.com>2013-08-21 11:55:44 +0100
committerMathew Inwood <mathewi@google.com>2013-08-21 17:56:42 +0100
commit3347f31bd268ca3153abe5def9361f625bd73efd (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /tests
parent7f56189a43893f0b6374fff628e95c134eb85047 (diff)
downloadApplicationsProvider-3347f31bd268ca3153abe5def9361f625bd73efd.tar.gz
The ApplicationsProvider is no longer used, so remove it. Change-Id: I6ee638a3d2b65f092d6f90410156d7cd24436914
Diffstat (limited to 'tests')
-rw-r--r--tests/Android.mk18
-rw-r--r--tests/AndroidManifest.xml28
-rw-r--r--tests/runtests6
-rw-r--r--tests/src/com/android/providers/applications/ApplicationsProviderForTesting.java108
-rw-r--r--tests/src/com/android/providers/applications/ApplicationsProviderTest.java305
-rw-r--r--tests/src/com/android/providers/applications/MockActivityManager.java42
-rw-r--r--tests/src/com/android/providers/applications/MockPackageManager.java101
7 files changed, 0 insertions, 608 deletions
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 7d1fe34..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_INSTRUMENTATION_FOR := ApplicationsProvider
-
-# framework is required to access android.provider.Applications
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-LOCAL_PACKAGE_NAME := ApplicationsProviderTests
-LOCAL_CERTIFICATE := shared
-
-include $(BUILD_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
deleted file mode 100644
index c614afc..0000000
--- a/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.providers.applications.tests">
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.providers.applications"
- android:label="Tests for the ApplicationsProvider">
- </instrumentation>
-</manifest>
diff --git a/tests/runtests b/tests/runtests
deleted file mode 100644
index be1c779..0000000
--- a/tests/runtests
+++ /dev/null
@@ -1,6 +0,0 @@
-mmm packages/providers/ApplicationsProvider || return
-mmm packages/providers/ApplicationsProvider/tests || return
-adb install -r ${OUT}/system/app/ApplicationsProvider.apk || return
-adb install -r ${OUT}/data/app/ApplicationsProviderTests.apk || return
-adb shell am instrument -w -e class com.android.providers.applications.ApplicationsProviderTest com.android.providers.applications.tests/android.test.InstrumentationTestRunner || return
-
diff --git a/tests/src/com/android/providers/applications/ApplicationsProviderForTesting.java b/tests/src/com/android/providers/applications/ApplicationsProviderForTesting.java
deleted file mode 100644
index 56a3d80..0000000
--- a/tests/src/com/android/providers/applications/ApplicationsProviderForTesting.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.providers.applications;
-
-import android.content.pm.PackageManager;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-
-import com.android.internal.os.PkgUsageStats;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * An extension of {@link ApplicationsProvider} that makes its testing easier.
- */
-public class ApplicationsProviderForTesting extends ApplicationsProvider {
-
- private PackageManager mMockPackageManager;
-
- private MockActivityManager mMockActivityManager;
-
- private boolean mHasGlobalSearchPermission;
-
- private MockUpdateHandler mMockUpdateHandler;
-
- @Override
- protected PackageManager getPackageManager() {
- return mMockPackageManager;
- }
-
- protected void setMockPackageManager(PackageManager mockPackageManager) {
- mMockPackageManager = mockPackageManager;
- }
-
- @Override
- protected Map<String, PkgUsageStats> fetchUsageStats() {
- Map<String, PkgUsageStats> stats = new HashMap<String, PkgUsageStats>();
- for (PkgUsageStats pus : mMockActivityManager.getAllPackageUsageStats()) {
- stats.put(pus.packageName, pus);
- }
- return stats;
- }
-
- protected void setMockActivityManager(MockActivityManager mockActivityManager) {
- mMockActivityManager = mockActivityManager;
- }
-
- protected void setHasGlobalSearchPermission(boolean hasGlobalSearchPermission) {
- mHasGlobalSearchPermission = hasGlobalSearchPermission;
- }
-
- @Override
- protected boolean hasGlobalSearchPermission() {
- return mHasGlobalSearchPermission;
- }
-
- @Override
- Handler createHandler(Looper looper) {
- mMockUpdateHandler = new MockUpdateHandler(looper);
- return mMockUpdateHandler;
- }
-
- public boolean dispatchNextMessage() {
- return mMockUpdateHandler.dispatchNextMessage();
- }
-
- private class MockUpdateHandler extends UpdateHandler {
-
- List<Message> mMessages = new ArrayList<Message>();
-
- MockUpdateHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
- mMessages.add(msg);
- return true;
- }
-
- public boolean dispatchNextMessage() {
- if (!mMessages.isEmpty()) {
- dispatchMessage(mMessages.remove(0));
- return true;
- } else {
- return false;
- }
- }
- }
-}
diff --git a/tests/src/com/android/providers/applications/ApplicationsProviderTest.java b/tests/src/com/android/providers/applications/ApplicationsProviderTest.java
deleted file mode 100644
index 99a8a2e..0000000
--- a/tests/src/com/android/providers/applications/ApplicationsProviderTest.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.providers.applications;
-
-import android.app.SearchManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.Applications;
-import android.test.ProviderTestCase2;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import java.util.concurrent.FutureTask;
-
-
-/**
- * Instrumentation test for the ApplicationsProvider.
- *
- * The tests use an IsolatedContext, and are not affected by the real list of
- * applications on the device. The ApplicationsProvider's persistent database
- * is also created in an isolated context so it doesn't interfere with the
- * database of the actual ApplicationsProvider installed on the device.
- */
-@SmallTest
-public class ApplicationsProviderTest extends ProviderTestCase2<ApplicationsProviderForTesting> {
-
- private ApplicationsProviderForTesting mProvider;
-
- private MockActivityManager mMockActivityManager;
-
- public ApplicationsProviderTest() {
- super(ApplicationsProviderForTesting.class, Applications.AUTHORITY);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mProvider = getProvider();
- mMockActivityManager = new MockActivityManager();
- }
-
- /**
- * Ensures that the ApplicationsProvider is in a ready-to-test state.
- */
- private void initProvider(ApplicationsProviderForTesting provider) throws Exception {
- // Decouple the provider from Android's real list of applications.
- MockPackageManager mockPackageManager = new MockPackageManager();
- addDefaultTestPackages(mockPackageManager);
-
- initProvider(provider, mockPackageManager);
- }
-
- private void initProvider(ApplicationsProviderForTesting provider,
- MockPackageManager mockPackageManager) throws Exception {
- provider.setMockPackageManager(mockPackageManager);
- provider.setMockActivityManager(mMockActivityManager);
-
- assertTrue(provider.dispatchNextMessage());
- }
-
- /**
- * Register a few default applications with the ApplicationsProvider that
- * tests can query.
- */
- private void addDefaultTestPackages(MockPackageManager mockPackageManager) {
- mockPackageManager.addPackage(
- "Email", new ComponentName("com.android.email", "com.android.email.MainView"));
- mockPackageManager.addPackage(
- "Ebay", new ComponentName("com.android.ebay", "com.android.ebay.Shopping"));
- mockPackageManager.addPackage(
- "Fakeapp", new ComponentName("com.android.fakeapp", "com.android.fakeapp.FakeView"));
-
- // Apps that can be used to test ordering.
- mockPackageManager.addPackage("AlphabeticA", new ComponentName("a", "a.AView"));
- mockPackageManager.addPackage("AlphabeticB", new ComponentName("b", "b.BView"));
- mockPackageManager.addPackage("AlphabeticC", new ComponentName("c", "c.CView"));
- mockPackageManager.addPackage("AlphabeticD", new ComponentName("d", "d.DView"));
- mockPackageManager.addPackage("AlphabeticD2", new ComponentName("d", "d.DView2"));
- }
-
- public void testSearch_singleResult() throws Exception {
- initProvider(mProvider);
- testSearch("ema", "Email");
- }
-
- public void testSearch_multipleResults() throws Exception {
- initProvider(mProvider);
- testSearch("e", "Ebay", "Email");
- }
-
- public void testSearch_noResults() throws Exception {
- initProvider(mProvider);
- testSearch("nosuchapp");
- }
-
- public void testSearch_orderingIsAlphabeticByDefault() throws Exception {
- initProvider(mProvider);
- testSearch("alphabetic", "AlphabeticA", "AlphabeticB", "AlphabeticC", "AlphabeticD",
- "AlphabeticD2");
- }
-
- public void testSearch_emptySearchQueryReturnsEverything() throws Exception {
- initProvider(mProvider);
- testSearch("",
- "AlphabeticA", "AlphabeticB", "AlphabeticC", "AlphabeticD", "AlphabeticD2",
- "Ebay", "Email", "Fakeapp");
- }
-
- public void testSearch_appsAreRankedByUsageTimeOnStartup() throws Exception {
- mMockActivityManager.addLastResumeTime("d", "d.DView", 3);
- mMockActivityManager.addLastResumeTime("b", "b.BView", 1);
- // Missing usage time for "a".
- mMockActivityManager.addLastResumeTime("c", "c.CView", 0);
-
- // Launch count database is populated on startup.
- mProvider.setHasGlobalSearchPermission(true);
-
- initProvider(mProvider);
-
- // New ranking: D, B, A, C (first by launch count, then
- // - if the launch counts of two apps are equal - alphabetically)
- testSearch("alphabetic", "AlphabeticD", "AlphabeticB", "AlphabeticA", "AlphabeticC",
- "AlphabeticD2");
- }
-
- public void testSearch_appsAreRankedByResumeTimeAfterUpdate() throws Exception {
- initProvider(mProvider);
- mProvider.setHasGlobalSearchPermission(true);
-
- mMockActivityManager.addLastResumeTime("d", "d.DView", 3);
- mMockActivityManager.addLastResumeTime("b", "b.BView", 1);
- // Missing launch count for "a".
- mMockActivityManager.addLastResumeTime("c", "c.CView", 0);
-
- // Fetch new data from usage stat provider (in the real instance this
- // is triggered by a zero-query from global search).
- mProvider.updateUsageStats();
-
- // New ranking: D, B, A, C (first by launch count, then
- // - if the launch counts of two apps are equal - alphabetically)
- testSearch("alphabetic", "AlphabeticD", "AlphabeticB", "AlphabeticA", "AlphabeticC",
- "AlphabeticD2");
- }
-
- public void testSearch_noLastAccessTimesWithoutPermission() throws Exception {
- initProvider(mProvider);
- mProvider.setHasGlobalSearchPermission(false);
- mMockActivityManager.addLastResumeTime("d", "d.DView", 1);
- mMockActivityManager.addLastResumeTime("b", "b.BView", 2);
- mMockActivityManager.addLastResumeTime("c", "c.CView", 3);
-
- assertNull(getGlobalSearchCursor("", false));
-
- Cursor cursor = getGlobalSearchCursor("alphabetic", false);
- assertEquals(-1, cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_LAST_ACCESS_HINT));
- }
-
- public void testSearch_lastAccessTimes() throws Exception {
- initProvider(mProvider);
- mProvider.setHasGlobalSearchPermission(true);
- mMockActivityManager.addLastResumeTime("d", "d.DView", 1);
- mMockActivityManager.addLastResumeTime("b", "b.BView", 2);
- mMockActivityManager.addLastResumeTime("c", "c.CView", 3);
-
- testLastAccessTimes("", true, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0);
-
- testLastAccessTimes("alphabetic", true, 3, 2, 1, 0, 0);
-
- // Update the last resume time of "c".
- mMockActivityManager.addLastResumeTime("c", "c.CView", 5);
- // Without a refresh, we should see the same results as before.
- testLastAccessTimes("alphabetic", false, 3, 2, 1, 0, 0);
- // If we refresh, we should see the change.
- testLastAccessTimes("alphabetic", true, 5, 2, 1, 0, 0);
- }
-
- /**
- * The ApplicationsProvider must only rank by launch count if the caller
- * is a privileged application - ordering apps by launch count when asked
- * by a regular application would leak information about user behavior.
- */
- public void testSearch_notAllowedToRankByLaunchCount() throws Exception {
- initProvider(mProvider);
- // Simulate non-privileged calling application.
- mProvider.setHasGlobalSearchPermission(false);
-
- mMockActivityManager.addLastResumeTime("d", "d.DView", 3);
- mMockActivityManager.addLastResumeTime("b", "b.BView", 1);
- mMockActivityManager.addLastResumeTime("a", "a.AView", 0);
- mMockActivityManager.addLastResumeTime("c", "c.CView", 0);
-
- // Fetch new data from launch count provider.
- mProvider.updateUsageStats();
-
- // Launch count information mustn't be leaked - ranking is still
- // alphabetic.
- testSearch("alphabetic", "AlphabeticA", "AlphabeticB", "AlphabeticC", "AlphabeticD",
- "AlphabeticD2");
- }
-
- public void testSearch_disabledPackage() throws Exception {
- MockPackageManager mockPackageManager = new MockPackageManager();
- mockPackageManager.addPackage("DisabledPackageApp1",
- new ComponentName("dp", "dp.DisView1"));
- mockPackageManager.addPackage("DisabledPackageApp2",
- new ComponentName("dp", "dp.DisView2"),
- PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
- PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
- initProvider(mProvider, mockPackageManager);
-
- mProvider.setHasGlobalSearchPermission(true);
- testSearch("dis");
- }
-
- public void testSearch_disabledComponent() throws Exception {
- MockPackageManager mockPackageManager = new MockPackageManager();
- mockPackageManager.addPackage("DisabledApp1", new ComponentName("da", "da.DaView1"),
- PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
- PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
- mockPackageManager.addPackage("DisabledApp2", new ComponentName("da", "da.DaView2"),
- PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
- PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
- initProvider(mProvider, mockPackageManager);
-
- mProvider.setHasGlobalSearchPermission(true);
- testSearch("dis", "DisabledApp2");
- }
-
- private void testSearch(String searchQuery, String... expectedResultsInOrder) {
- Cursor cursor = Applications.search(getMockContentResolver(), searchQuery);
-
- assertNotNull(cursor);
- assertFalse(cursor.isClosed());
-
- verifySearchResults(cursor, expectedResultsInOrder);
-
- cursor.close();
- }
-
- private void verifySearchResults(Cursor cursor, String... expectedResultsInOrder) {
- int expectedResultCount = expectedResultsInOrder.length;
- assertEquals("Wrong number of app search results.",
- expectedResultCount, cursor.getCount());
-
- if (expectedResultCount > 0) {
- cursor.moveToFirst();
- int nameIndex = cursor.getColumnIndex(ApplicationsProvider.NAME);
- // Verify that the actual results match the expected ones.
- for (int i = 0; i < cursor.getCount(); i++) {
- assertEquals("Wrong search result at position " + i,
- expectedResultsInOrder[i], cursor.getString(nameIndex));
- cursor.moveToNext();
- }
- }
- }
-
- private Cursor getGlobalSearchCursor(String searchQuery, boolean refresh) {
- Uri.Builder uriBuilder = Applications.CONTENT_URI.buildUpon();
- uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY).appendPath(searchQuery);
- if (refresh) {
- uriBuilder.appendQueryParameter(ApplicationsProvider.REFRESH_STATS, "");
- }
- return getMockContentResolver().query(uriBuilder.build(), null, null, null, null);
- }
-
- private void testLastAccessTimes(String searchQuery, boolean refresh,
- int... expectedLastAccessTimesInOrder) {
- Cursor cursor = getGlobalSearchCursor(searchQuery, refresh);
-
- assertNotNull(cursor);
- assertFalse(cursor.isClosed());
-
- verifyLastAccessTimes(cursor, expectedLastAccessTimesInOrder);
-
- cursor.close();
- }
-
- private void verifyLastAccessTimes(Cursor cursor, int... expectedLastAccessTimesInOrder) {
- cursor.moveToFirst();
- int lastAccessTimeIndex = cursor.getColumnIndex(
- SearchManager.SUGGEST_COLUMN_LAST_ACCESS_HINT);
- // Verify that the actual results match the expected ones.
- for (int i = 0; i < cursor.getCount(); i++) {
- assertEquals("Wrong last-access time at position " + i,
- expectedLastAccessTimesInOrder[i], cursor.getInt(lastAccessTimeIndex));
- cursor.moveToNext();
- }
- }
-}
diff --git a/tests/src/com/android/providers/applications/MockActivityManager.java b/tests/src/com/android/providers/applications/MockActivityManager.java
deleted file mode 100644
index 5ac5cf3..0000000
--- a/tests/src/com/android/providers/applications/MockActivityManager.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.providers.applications;
-
-import com.android.internal.os.PkgUsageStats;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The real ActivityManager is difficult to mock out (has a package visibility
- * constructor), so this doesn't extend it.
- */
-public class MockActivityManager {
-
- private Map<String, PkgUsageStats> mPackageUsageStats = new HashMap<String, PkgUsageStats>();
-
- public void addLastResumeTime(String packageName, String componentName, long lastResumeTime) {
- if (!mPackageUsageStats.containsKey(packageName)) {
- PkgUsageStats stats = new PkgUsageStats(packageName, 1, 0, new HashMap<String, Long>());
- mPackageUsageStats.put(packageName, stats);
- }
- mPackageUsageStats.get(packageName).componentResumeTimes.put(componentName, lastResumeTime);
- }
-
- public PkgUsageStats[] getAllPackageUsageStats() {
- return mPackageUsageStats.values().toArray(new PkgUsageStats[mPackageUsageStats.size()]);
- }
-}
diff --git a/tests/src/com/android/providers/applications/MockPackageManager.java b/tests/src/com/android/providers/applications/MockPackageManager.java
deleted file mode 100644
index 9db7ee5..0000000
--- a/tests/src/com/android/providers/applications/MockPackageManager.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-package com.android.providers.applications;
-
-import android.content.ComponentName;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class MockPackageManager extends android.test.mock.MockPackageManager {
-
- private List<ResolveInfo> mPackages = new ArrayList<ResolveInfo>();
-
- private Map<String, Integer> mApplicationEnabledSettings = new HashMap<String, Integer>();
- private Map<String, Integer> mComponentEnabledSettings = new HashMap<String, Integer>();
-
- /**
- * Returns all packages registered with the mock package manager.
- * ApplicationsProvider uses this method to query the list of applications.
- */
- @Override
- public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
- return mPackages;
- }
-
- @Override
- public int getApplicationEnabledSetting(String packageName) {
- return mApplicationEnabledSettings.get(packageName);
- }
-
- @Override
- public int getComponentEnabledSetting(ComponentName componentName) {
- return mComponentEnabledSettings.get(componentName.flattenToString());
- }
-
- /**
- * Adds a new package to the mock package manager.
- *
- * Example:
- * addPackage("Email", new ComponentName("com.android.email", "com.android.email.MainView"),
- * PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
- * PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
- *
- * @param title the user-friendly title of the application (this is what
- * users will search for)
- * @param componentName The full component name of the app.
- * @param appEnabledSetting The setting which should be returned from
- * {@link #getApplicationEnabledSetting}, for this component's package.
- * @param componentEnabledSetting The setting which should be returned from
- * {@link #getComponentEnabledSetting}, for this component.
- */
- public void addPackage(final String title, ComponentName componentName, int appEnabledSetting,
- int componentEnabledSetting) {
- // Set the application's title.
- ResolveInfo packageInfo = new ResolveInfo() {
- @Override
- public CharSequence loadLabel(PackageManager pm) {
- return title;
- }
- };
-
- // Set the application's ComponentName.
- packageInfo.activityInfo = new ActivityInfo();
- packageInfo.activityInfo.name = componentName.getClassName();
- packageInfo.activityInfo.applicationInfo = new ApplicationInfo();
- packageInfo.activityInfo.applicationInfo.packageName = componentName.getPackageName();
-
- mPackages.add(packageInfo);
-
- mApplicationEnabledSettings.put(componentName.getPackageName(), appEnabledSetting);
- mComponentEnabledSettings.put(componentName.flattenToString(), componentEnabledSetting);
- }
-
- public void addPackage(final String title, ComponentName componentName) {
- addPackage(title, componentName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
- PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
- }
-}