FileDocCategorySizeDatePackage
DevelopmentSettings.javaAPI DocAndroid 1.5 API17724Wed May 06 22:41:08 BST 2009com.android.development

DevelopmentSettings

public class DevelopmentSettings extends android.app.Activity

Fields Summary
private static final String
TAG
private static final int
DEBUG_APP_REQUEST
private android.widget.Button
mDebugAppButton
private android.widget.CheckBox
mWaitForDebuggerCB
private android.widget.CheckBox
mAlwaysFinishCB
private android.widget.CheckBox
mShowLoadCB
private android.widget.CheckBox
mShowCpuCB
private android.widget.CheckBox
mEnableGLCB
private android.widget.CheckBox
mShowUpdatesCB
private android.widget.CheckBox
mShowBackgroundCB
private android.widget.CheckBox
mShowSleepCB
private android.widget.CheckBox
mShowXmppCB
private android.widget.Spinner
mMaxProcsSpinner
private android.widget.Spinner
mWindowAnimationScaleSpinner
private android.widget.Spinner
mTransitionAnimationScaleSpinner
private android.widget.Spinner
mFontHintingSpinner
private String
mDebugApp
private boolean
mWaitForDebugger
private boolean
mAlwaysFinish
private int
mProcessLimit
private boolean
mShowSleep
private boolean
mShowXmpp
private AnimationScaleSelectedListener
mWindowAnimationScale
private AnimationScaleSelectedListener
mTransitionAnimationScale
private android.content.SharedPreferences
mSharedPrefs
private android.view.IWindowManager
mWindowManager
private static final boolean
FONT_HINTING_ENABLED
private static final String
FONT_HINTING_FILE
private View.OnClickListener
mDebugAppClicked
private View.OnClickListener
mWaitForDebuggerClicked
private View.OnClickListener
mAlwaysFinishClicked
private View.OnClickListener
mShowLoadClicked
private View.OnClickListener
mShowSleepClicked
private View.OnClickListener
mShowXmppClicked
private Spinner.OnItemSelectedListener
mMaxProcsChanged
private Spinner.OnItemSelectedListener
mFontHintingChanged
Constructors Summary
Methods Summary
public voidonActivityResult(int requestCode, int resultCode, android.content.Intent intent)


    
            
        if (requestCode == DEBUG_APP_REQUEST && resultCode == RESULT_OK) {
            mDebugApp = intent.getAction();
            writeDebugOptions();
            updateDebugOptions();
        }
    
public voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        setContentView(R.layout.development_settings);

        mDebugAppButton = (Button)findViewById(R.id.debug_app);
        mDebugAppButton.setOnClickListener(mDebugAppClicked);
        mWaitForDebuggerCB = (CheckBox)findViewById(R.id.wait_for_debugger);
        mWaitForDebuggerCB.setOnClickListener(mWaitForDebuggerClicked);
        mAlwaysFinishCB = (CheckBox)findViewById(R.id.always_finish);
        mAlwaysFinishCB.setOnClickListener(mAlwaysFinishClicked);
        mShowLoadCB = (CheckBox)findViewById(R.id.show_load);
        mShowLoadCB.setOnClickListener(mShowLoadClicked);
        mShowCpuCB = (CheckBox)findViewById(R.id.show_cpu);
        mShowCpuCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1000));
        mEnableGLCB = (CheckBox)findViewById(R.id.enable_gl);
        mEnableGLCB.getLayoutParams().height = 0; // doesn't do anything
        mEnableGLCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1004));
        mShowUpdatesCB = (CheckBox)findViewById(R.id.show_updates);
        mShowUpdatesCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1002));
        mShowBackgroundCB = (CheckBox)findViewById(R.id.show_background);
        mShowBackgroundCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1003));
        mShowSleepCB = (CheckBox)findViewById(R.id.show_sleep);
        mShowSleepCB.setOnClickListener(mShowSleepClicked);
        mShowXmppCB = (CheckBox)findViewById(R.id.show_xmpp);
        mShowXmppCB.setOnClickListener(mShowXmppClicked);
        mMaxProcsSpinner = (Spinner)findViewById(R.id.max_procs);
        mMaxProcsSpinner.setOnItemSelectedListener(mMaxProcsChanged);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                this,
                android.R.layout.simple_spinner_item,
                new String[] {
                        "No App Process Limit",
                        "Max 1 App Process",
                        "Max 2 App Processes",
                        "Max 3 App Processes",
                        "Max 4 App Processes" });
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mMaxProcsSpinner.setAdapter(adapter);
        mWindowAnimationScaleSpinner = setupAnimationSpinner(
                R.id.window_animation_scale, mWindowAnimationScale, "Window");
        mTransitionAnimationScaleSpinner = setupAnimationSpinner(
                R.id.transition_animation_scale, mTransitionAnimationScale, "Transition");

        if (FONT_HINTING_ENABLED) {
            mFontHintingSpinner = (Spinner)findViewById(R.id.font_hinting);
            mFontHintingSpinner.setOnItemSelectedListener(mFontHintingChanged);
            adapter = new ArrayAdapter<String>(
                    this,
                    android.R.layout.simple_spinner_item,
                    new String[] {
                            "Light Hinting",
                            "Medium Hinting" });
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            mFontHintingSpinner.setAdapter(adapter);
        }
        mSharedPrefs = getSharedPreferences("global", 0);
        mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
    
public voidonResume()

        super.onResume();
        updateDebugOptions();
        updateFinishOptions();
        updateProcessLimitOptions();
        updateSharedOptions();
        updateFlingerOptions();
        updateSleepOptions();
        updateXmppOptions();        

        try {
            FileInputStream  in = new FileInputStream( FONT_HINTING_FILE );
            int    mode = in.read() - 48;
            if (mode >= 0 && mode < 3)
                mFontHintingSpinner.setSelection(mode);
            in.close();
        } catch (Exception e) {
        }

        mWindowAnimationScale.load();
        mTransitionAnimationScale.load();
    
android.widget.SpinnersetupAnimationSpinner(int resid, com.android.development.DevelopmentSettings$AnimationScaleSelectedListener listener, java.lang.String name)

        Spinner spinner = (Spinner)findViewById(resid);
        spinner.setOnItemSelectedListener(listener);
        ArrayAdapter adapter = new ArrayAdapter<String>(
                this,
                android.R.layout.simple_spinner_item,
                new String[] {
                        name + " Animation Scale 1x",
                        name + " Animation Scale 2x",
                        name + " Animation Scale 5x",
                        name + " Animation Scale 10x",
                        name + " Animation Off" });
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        listener.spinner = spinner;
        return spinner;
    
private voidupdateDebugOptions()

        mDebugApp = Settings.System.getString(
            getContentResolver(), Settings.System.DEBUG_APP);
        mWaitForDebugger = Settings.System.getInt(
            getContentResolver(), Settings.System.WAIT_FOR_DEBUGGER, 0) != 0;

        mDebugAppButton.setText(
            mDebugApp == null || mDebugApp.length() == 0 ? "(none)" : mDebugApp);
        mWaitForDebuggerCB.setChecked(mWaitForDebugger);
    
private voidupdateFinishOptions()

        mAlwaysFinish = Settings.System.getInt(
            getContentResolver(), Settings.System.ALWAYS_FINISH_ACTIVITIES, 0) != 0;
        mAlwaysFinishCB.setChecked(mAlwaysFinish);
    
private voidupdateFlingerOptions()

        // magic communication with surface flinger.
        try {
            IBinder flinger = ServiceManager.getService("SurfaceFlinger");
            if (flinger != null) {
                Parcel data = Parcel.obtain();
                Parcel reply = Parcel.obtain();
                data.writeInterfaceToken("android.ui.ISurfaceComposer");
                flinger.transact(1010, data, reply, 0);
                int v;
                v = reply.readInt();
                mShowCpuCB.setChecked(v != 0);
                v = reply.readInt();
                mEnableGLCB.setChecked(v != 0);
                v = reply.readInt();
                mShowUpdatesCB.setChecked(v != 0);
                v = reply.readInt();
                mShowBackgroundCB.setChecked(v != 0);
                reply.recycle();
                data.recycle();
            }
        } catch (RemoteException ex) {
        }
    
private voidupdateProcessLimitOptions()

        try {
            mProcessLimit = ActivityManagerNative.getDefault().getProcessLimit();
            mMaxProcsSpinner.setSelection(mProcessLimit);
        } catch (RemoteException ex) {
        }
    
private voidupdateSharedOptions()

        mShowLoadCB.setChecked(Settings.System.getInt(getContentResolver(),
                Settings.System.SHOW_PROCESSES, 0) != 0);
    
private voidupdateSleepOptions()

        try {
            FileInputStream is = new FileInputStream(
                "/sys/devices/platform/gpio_sleep_debug/enable");
            int character = is.read();
            mShowSleep = character == '1";
            is.close();
        } catch (Exception e) {
            Log.w(TAG, "Failed reading gpio_sleep_debug");
            mShowSleep = false;
        }
        mShowSleepCB.setChecked(mShowSleep);
    
private voidupdateXmppOptions()

        mShowXmpp = Settings.System.getShowGTalkServiceStatus(getContentResolver());
        mShowXmppCB.setChecked(mShowXmpp);
    
private voidwriteDebugOptions()

        try {
            ActivityManagerNative.getDefault().setDebugApp(
                mDebugApp, mWaitForDebugger, true);
        } catch (RemoteException ex) {
        }
    
private voidwriteFinishOptions()

        try {
            ActivityManagerNative.getDefault().setAlwaysFinish(mAlwaysFinish);
        } catch (RemoteException ex) {
        }
    
private voidwriteProcessLimitOptions()

        try {
            ActivityManagerNative.getDefault().setProcessLimit(mProcessLimit);
        } catch (RemoteException ex) {
        }
    
private voidwriteSleepOptions()

        try {
            FileOutputStream os = new FileOutputStream(
                "/sys/devices/platform/gpio_sleep_debug/enable", true);
            if(mShowSleep)
                os.write(new byte[] { (byte)'1" });
            else
                os.write(new byte[] { (byte)'0" });
            os.close();
        } catch (Exception e) {
            Log.w(TAG, "Failed setting gpio_sleep_debug");
        }
    
private voidwriteXmppOptions()

        Settings.System.setShowGTalkServiceStatus(getContentResolver(), mShowXmpp);