Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4e7aefd authored by Pedlar's avatar Pedlar Committed by Steve Kondik
Browse files

Galaxy S Style Power Widget

Change-Id: I27970609f71a2e53e39d276102900d51b763f785

Make it so the widget shows as on by default.

Only modify the view of the bar, if we want to.

Check to make sure the Uri we are modding is the one we want to.
This is to prevent the bar from be disabled for some paradoxial reason.

Added Flashlight button for devices with an LED. And a Sleep button

Don't instantiate unused power buttons in StatusBarService.

New power buttons in the StatusBar is a great thing. But, on my HTC Hero,
I got a lot of the following error in logcat:

E/FlashlightButton(  133): getFlashlightEnabled failed
E/FlashlightButton(  133): java.io.FileNotFoundException: /sys/class/leds/flashlight/brightness (No such
E/FlashlightButton(  133):      at org.apache.harmony.luni.platform.OSFileSystem.openImpl(Native Method)
E/FlashlightButton(  133):      at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:
E/FlashlightButton(  133):      at java.io.FileInputStream.<init>(FileInputStream.java:82)
E/FlashlightButton(  133):      at java.io.FileInputStream.<init>(FileInputStream.java:134)
E/FlashlightButton(  133):      at com.android.server.status.widget.FlashlightButton.getFlashlightEnable
E/FlashlightButton(  133):      at com.android.server.status.widget.FlashlightButton.updateState(Flashli
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService.updateStates(StatusBarServ
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService.updateWidget(StatusBarServ
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService.access$800(StatusBarServic
E/FlashlightButton(  133):      at com.android.server.status.StatusBarService$7.onReceive(StatusBarServi
E/FlashlightButton(  133):      at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(Ac
E/FlashlightButton(  133):      at android.os.Handler.handleCallback(Handler.java:587)
E/FlashlightButton(  133):      at android.os.Handler.dispatchMessage(Handler.java:92)
E/FlashlightButton(  133):      at android.os.Looper.loop(Looper.java:123)
E/FlashlightButton(  133):      at com.android.server.ServerThread.run(SystemServer.java:524)

This is beacause, all power buttons are instantiate, even if unused or
functionnality is missing. So, I remove most calls to getInstance() for
all of them and use a HashMap to store the buttons used and only call
them in updateStates() and updateWidget().d

Additionnaly, my change reduce memory usage of the status bar.

Fixed tabs, some indents and long lines.

Change-Id: I22b98bddc791c547d02b50a09b561aa469cc25b7

Fix 2g/3g toggle on UMTS networks
(the same fix has been already applied to Settings app power widget)

Change-Id: I255359ba4a6ba3d384140c4c9bd5f73e780b9037

Removed Catch error, as it is uneccesary, and causes log spam on devices with no flash

Cleanup notification bar flashlight widget to use Torch app,
and add state storage for flashlight.

Change-Id: I6d4ad46318a7593809e7ff63601f8bd70db64a0c

Add setting to hide notification pulldown after clicking a power widget button

Change-Id: Ibbb2da79ef93502990d122d1f31664e578a44a79

Restore notification bar flashlight toggle using correct brightness
setting.

Change-Id: I5a35a4eb399d54613b782eac78ca1d1dad7cecf5

allow the light sensor to be ignored when flashlight is on

on certain devices, the flashlight affects the light sensor, causing the display
autobrightness to switch to the maximum level when flashlight is on

Change-Id: I22d623ce5457fc3ae177b609da8b51904bc73e83

Fix NPE when checking TORCH_STATE on first boot.

Change-Id: I24fa8e62c9a2bbac693ff9825988e04384dd6d75
parent cf210c30
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -175,6 +175,11 @@ public abstract class ContentResolver {
        mContext = context;
        mContext = context;
    }
    }


    /** @hide */
    public final Context getContext() {
        return mContext;
    }

    /** @hide */
    /** @hide */
    protected abstract IContentProvider acquireProvider(Context c, String name);
    protected abstract IContentProvider acquireProvider(Context c, String name);
    /** Providing a default implementation of this, to avoid having to change
    /** Providing a default implementation of this, to avoid having to change
+1 −0
Original line number Original line Diff line number Diff line
@@ -139,6 +139,7 @@ public final class ContentService extends IContentService.Stub {
                ObserverCall oc = calls.get(i);
                ObserverCall oc = calls.get(i);
                try {
                try {
                    oc.mObserver.onChange(oc.mSelfNotify);
                    oc.mObserver.onChange(oc.mSelfNotify);
                    oc.mObserver.onChangeUri(uri, oc.mSelfNotify);
                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                        Log.v(TAG, "Notified " + oc.mObserver + " of " + "update at " + uri);
                        Log.v(TAG, "Notified " + oc.mObserver + " of " + "update at " + uri);
                    }
                    }
+31 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserException;


import android.graphics.Movie;
import android.graphics.Movie;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Build;
@@ -582,6 +583,36 @@ public class Resources {
        }
        }
    }
    }


    /**
     * Return a drawable object associated with a particular resource ID.
     * Various types of objects will be returned depending on the underlying
     * resource -- for example, a solid color, PNG image, scalable image, etc.
     * The Drawable API hides these implementation details.
     *
     * mtwebster: This version also applies a Porter Duff color mask onto the object before
     * returning the object. Put in Resources to give reusability, I plan on
     * applying this to other parts of the gui
     *
     * @param id The desired resource identifier, as generated by the aapt tool.
     *            This integer encodes the package, type, and resource entry.
     *            The value 0 is an invalid identifier.
     * @param mask The color mask to use (alpha-r-g-b)
     * @param masktype The Porter Duff filter mode
     * @throws NotFoundException Throws NotFoundException if the given ID does
     *             not exist.
     * @return Drawable An object that can be used to draw this resource.
     * @hide
     */
    public Drawable getDrawable(int id, int mask, Mode maskType) throws NotFoundException {
        synchronized (mTmpValue) {
            TypedValue value = mTmpValue;
            getValue(id, value, true);
            Drawable tmpDrawable = loadDrawable(value, id);
            tmpDrawable.setColorFilter(mask, maskType);
            return tmpDrawable;
        }
    }

    /**
    /**
     * Return a movie object associated with the particular resource ID.
     * Return a movie object associated with the particular resource ID.
     * @param id The desired resource identifier, as generated by the aapt
     * @param id The desired resource identifier, as generated by the aapt
+32 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.database;
package android.database;


import android.net.Uri;
import android.os.Handler;
import android.os.Handler;


/**
/**
@@ -34,15 +35,25 @@ public abstract class ContentObserver {
    private final class NotificationRunnable implements Runnable {
    private final class NotificationRunnable implements Runnable {


        private boolean mSelf;
        private boolean mSelf;
        private Uri mUri = null;


        public NotificationRunnable(boolean self) {
        public NotificationRunnable(boolean self) {
            mSelf = self;
            mSelf = self;
        }
        }


        public NotificationRunnable(Uri uri, boolean self) {
            mSelf = self;
            mUri = uri;
        }

        public void run() {
        public void run() {
            if (mUri != null) {
                ContentObserver.this.onChangeUri(mUri, mSelf);
            } else {
                ContentObserver.this.onChange(mSelf);
                ContentObserver.this.onChange(mSelf);
            }
            }
        }
        }
    }


    private static final class Transport extends IContentObserver.Stub {
    private static final class Transport extends IContentObserver.Stub {
        ContentObserver mContentObserver;
        ContentObserver mContentObserver;
@@ -66,6 +77,13 @@ public abstract class ContentObserver {
            }
            }
        }
        }


        public void onChangeUri(Uri uri, boolean selfChange) {
            ContentObserver contentObserver = mContentObserver;
            if (contentObserver != null) {
                contentObserver.dispatchChange(uri, selfChange);
            }
        }

        public void releaseContentObserver() {
        public void releaseContentObserver() {
            mContentObserver = null;
            mContentObserver = null;
        }
        }
@@ -128,6 +146,9 @@ public abstract class ContentObserver {
     */
     */
    public void onChange(boolean selfChange) {}
    public void onChange(boolean selfChange) {}


    /** @hide */
    public void onChangeUri(Uri uri, boolean selfChange) {}

    public final void dispatchChange(boolean selfChange) {
    public final void dispatchChange(boolean selfChange) {
        if (mHandler == null) {
        if (mHandler == null) {
            onChange(selfChange);
            onChange(selfChange);
@@ -135,4 +156,14 @@ public abstract class ContentObserver {
            mHandler.post(new NotificationRunnable(selfChange));
            mHandler.post(new NotificationRunnable(selfChange));
        }
        }
    }
    }

    /** @hide */
    public final void dispatchChange(Uri uri, boolean selfChange) {
        if (mHandler == null) {
            onChangeUri(uri, selfChange);
        } else {
            mHandler.post(new NotificationRunnable(uri, selfChange));
        }
    }

}
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,8 @@


package android.database;
package android.database;


import android.net.Uri;

/**
/**
 * @hide
 * @hide
 */
 */
@@ -28,4 +30,5 @@ interface IContentObserver
     * commit on the cursor that is being observed.
     * commit on the cursor that is being observed.
     */
     */
    oneway void onChange(boolean selfUpdate);
    oneway void onChange(boolean selfUpdate);
    oneway void onChangeUri(in Uri uri, boolean selfUpdate);
}
}
Loading