2 * Copyright (C) 2011 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.settings;
19 import static android.provider.Settings.Secure.DREAM_COMPONENT;
21 import android.app.AlertDialog;
22 import android.content.Context;
23 import android.content.ComponentName;
24 import android.content.ContentResolver;
25 import android.content.DialogInterface;
26 import android.content.Intent;
27 import android.content.pm.ActivityInfo;
28 import android.content.pm.PackageManager;
29 import android.content.pm.ResolveInfo;
30 import android.content.res.Resources;
31 import android.preference.Preference;
32 import android.provider.Settings;
33 import android.util.AttributeSet;
34 import android.util.Log;
35 import android.view.Gravity;
36 import android.view.LayoutInflater;
37 import android.view.View;
38 import android.view.ViewGroup;
39 import android.widget.ArrayAdapter;
40 import android.widget.ListView;
41 import android.widget.BaseAdapter;
42 import android.widget.ImageView;
43 import android.widget.ListAdapter;
44 import android.widget.TextView;
46 import java.util.ArrayList;
47 import java.util.List;
49 public class DreamTesterPreference extends Preference {
50 private static final String TAG = "DreamTesterPreference";
52 private final PackageManager pm;
53 private final ContentResolver resolver;
55 public DreamTesterPreference(Context context, AttributeSet attrs) {
56 super(context, attrs);
57 pm = getContext().getPackageManager();
58 resolver = getContext().getContentResolver();
62 protected void onClick() {
63 String component = Settings.Secure.getString(resolver, DREAM_COMPONENT);
64 if (component != null) {
65 ComponentName cn = ComponentName.unflattenFromString(component);
66 Intent intent = new Intent(Intent.ACTION_MAIN)
68 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
69 | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
70 | Intent.FLAG_ACTIVITY_SINGLE_TOP)
71 .putExtra("android.dreams.TEST", true);
72 getContext().startActivity(intent);