ResolverDataProvider.java revision 9149dcaf414ebdac231af93d44abd5951a514a7e
1e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu/*
2e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * Copyright (C) 2008 The Android Open Source Project
3e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu *
4e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * Licensed under the Apache License, Version 2.0 (the "License");
5e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * you may not use this file except in compliance with the License.
6e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * You may obtain a copy of the License at
7e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu *
8e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu *      http://www.apache.org/licenses/LICENSE-2.0
9e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu *
10e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * Unless required by applicable law or agreed to in writing, software
11e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * distributed under the License is distributed on an "AS IS" BASIS,
12e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * See the License for the specific language governing permissions and
14e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu * limitations under the License.
15e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu */
16e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
17e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglupackage com.android.internal.app;
18e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
19e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport android.content.ComponentName;
20e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport android.content.Intent;
21e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport android.content.pm.ActivityInfo;
22e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport android.content.pm.ApplicationInfo;
23e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport android.content.pm.ResolveInfo;
24e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport android.os.UserHandle;
25e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
26e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport java.util.HashMap;
27e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport java.util.Map;
28e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyaliogluimport java.util.concurrent.atomic.AtomicInteger;
29e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
30e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu/**
319149dcaf414ebdac231af93d44abd5951a514a7eHakan Seyalioglu * Utility class used by resolver tests to create mock data
32e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu */
339149dcaf414ebdac231af93d44abd5951a514a7eHakan Seyaliogluclass ResolverDataProvider {
34e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
35e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    static ResolverActivity.ResolvedComponentInfo createResolvedComponentInfo(int i) {
36e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        return new ResolverActivity.ResolvedComponentInfo(createComponentName(i),
37e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu                createResolverIntent(i), createResolveInfo(i));
38e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    }
39e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
40e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    static ComponentName createComponentName(int i) {
41e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        final String name = "component" + i;
42e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        return new ComponentName("foo.bar." + name, name);
43e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    }
44e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
45e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    static ResolveInfo createResolveInfo(int i) {
46e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        final ResolveInfo resolveInfo = new ResolveInfo();
47e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        resolveInfo.activityInfo = createActivityInfo(i);
48e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        resolveInfo.targetUserId = UserHandle.USER_CURRENT;
49e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        return resolveInfo;
50e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    }
51e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
52e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    static ActivityInfo createActivityInfo(int i) {
53e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ActivityInfo ai = new ActivityInfo();
54e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.name = "activity_name" + i;
55e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.packageName = "foo_bar" + i;
56e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.enabled = true;
57e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.exported = true;
58e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.permission = null;
59e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.applicationInfo = createApplicationInfo();
60e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        return ai;
61e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    }
62e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
63e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    static ApplicationInfo createApplicationInfo() {
64e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ApplicationInfo ai = new ApplicationInfo();
65e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.name = "app_name";
66e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.packageName = "foo.bar";
67e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        ai.enabled = true;
68e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        return ai;
69e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    }
70e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu
71e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    static Intent createResolverIntent(int i) {
72e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu        return new Intent("intentAction" + i);
73e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu    }
74e1276bfe086a40a0fba7e81dd5db13f95287714dHakan Seyalioglu}