diff options
8 files changed, 141 insertions, 149 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index eca5af976d42..d640de109a25 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -2,16 +2,16 @@  **  ** Copyright 2007, 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  +** 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  +**     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  +** 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.  */ @@ -126,6 +126,10 @@ public class Am {                  String value = nextArgRequired();                  intent.putExtra(key, value);                  hasIntentInfo = true; +            } else if (opt.equals("--esn")) { +                String key = nextArgRequired(); +                intent.putExtra(key, (String) null); +                hasIntentInfo = true;              } else if (opt.equals("--ei")) {                  String key = nextArgRequired();                  String value = nextArgRequired(); @@ -364,7 +368,7 @@ public class Am {          private boolean mRawMode = false;          /** -         * Set or reset "raw mode".  In "raw mode", all bundles are dumped.  In "pretty mode",  +         * Set or reset "raw mode".  In "raw mode", all bundles are dumped.  In "pretty mode",           * if a bundle includes Instrumentation.REPORT_KEY_STREAMRESULT, just print that.           * @param rawMode true for raw mode, false for pretty mode.           */ @@ -507,6 +511,7 @@ public class Am {                  "        [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" +                  "        [-c <CATEGORY> [-c <CATEGORY>] ...]\n" +                  "        [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]\n" + +                "        [--esn <EXTRA_KEY> ...]\n" +                  "        [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]\n" +                  "        [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]\n" +                  "        [-n <COMPONENT>] [-f <FLAGS>] [<URI>]\n" diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index cb95396d28ce..f8592e26bd30 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -344,14 +344,14 @@ public class BluetoothService extends IBluetooth.Stub {                  // records, use a DBUS call instead.                  switch (msg.arg1) {                  case 1: -                    Log.d(TAG, "Registering hsag record"); -                    SystemService.start("hsag"); +                    Log.d(TAG, "Registering hfag record"); +                    SystemService.start("hfag");                      mHandler.sendMessageDelayed(                              mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 2, -1), 500);                      break;                  case 2: -                    Log.d(TAG, "Registering hfag record"); -                    SystemService.start("hfag"); +                    Log.d(TAG, "Registering hsag record"); +                    SystemService.start("hsag");                      mHandler.sendMessageDelayed(                              mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 3, -1), 500);                      break; diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 1ab46fc0a6ab..b8bd6a086006 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -237,25 +237,6 @@ public interface WindowManagerPolicy {          public boolean hasAppShownWindows();          /** -         * Return true if the application token has been asked to display an  -         * app starting icon as the application is starting up.  -         *  -         * @return Returns true if setAppStartingIcon() was called for this  -         *         window's token. -         */ -        public boolean hasAppStartingIcon(); - -        /** -         * Return the Window that is being displayed as this window's  -         * application token is being started.  -         *  -         * @return Returns the currently displayed starting window, or null if  -         *         it was not requested, has not yet been displayed, or has -         *         been removed. -         */ -        public WindowState getAppStartingWindow(); - -        /**           * Is this window visible?  It is not visible if there is no           * surface, or we are in the process of running an exit animation           * that will remove the surface. @@ -793,11 +774,6 @@ public interface WindowManagerPolicy {      void exitKeyguardSecurely(OnKeyguardExitResult callback);      /** -     * Return if keyguard is currently showing. -     */ -    public boolean keyguardIsShowingTq(); - -    /**       * inKeyguardRestrictedKeyInputMode       *       * if keyguard screen is showing or in restricted key input mode (i.e. in diff --git a/services/java/com/android/server/LightsService.java b/services/java/com/android/server/LightsService.java index ae8d3212085a..1937b043f530 100644 --- a/services/java/com/android/server/LightsService.java +++ b/services/java/com/android/server/LightsService.java @@ -30,6 +30,9 @@ public class LightsService {      static final int LIGHT_ID_BATTERY = 3;      static final int LIGHT_ID_NOTIFICATIONS = 4;      static final int LIGHT_ID_ATTENTION = 5; +    static final int LIGHT_ID_BLUETOOTH = 6; +    static final int LIGHT_ID_WIFI = 7; +    static final int LIGHT_ID_COUNT = 8;      static final int LIGHT_FLASH_NONE = 0;      static final int LIGHT_FLASH_TIMED = 1; @@ -45,79 +48,101 @@ public class LightsService {       */      static final int BRIGHTNESS_MODE_SENSOR = 1; -    private boolean mAttentionLightOn; -    private boolean mPulsing; +    private final Light mLights[] = new Light[LIGHT_ID_COUNT]; -    LightsService(Context context) { +    public final class Light { -        mNativePointer = init_native(); -        mContext = context; -    } +        private Light(int id) { +            mId = id; +        } -    protected void finalize() throws Throwable { -        finalize_native(mNativePointer); -        super.finalize(); -    } +        public void setBrightness(int brightness) { +            setBrightness(brightness, BRIGHTNESS_MODE_USER); +        } -    void setLightOff(int light) { -        setLight_native(mNativePointer, light, 0, LIGHT_FLASH_NONE, 0, 0, 0); -    } +        public void setBrightness(int brightness, int brightnessMode) { +            synchronized (this) { +                int color = brightness & 0x000000ff; +                color = 0xff000000 | (color << 16) | (color << 8) | color; +                setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode); +            } +        } -    void setLightBrightness(int light, int brightness, int brightnessMode) { -        int b = brightness & 0x000000ff; -        b = 0xff000000 | (b << 16) | (b << 8) | b; -        setLight_native(mNativePointer, light, b, LIGHT_FLASH_NONE, 0, 0, brightnessMode); -    } +        public void setColor(int color) { +            synchronized (this) { +                setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, 0); +            } +        } -    void setLightColor(int light, int color) { -        setLight_native(mNativePointer, light, color, LIGHT_FLASH_NONE, 0, 0, 0); -    } +        public void setFlashing(int color, int mode, int onMS, int offMS) { +            synchronized (this) { +                setLightLocked(color, mode, onMS, offMS, BRIGHTNESS_MODE_USER); +            } +        } -    void setLightFlashing(int light, int color, int mode, int onMS, int offMS) { -        setLight_native(mNativePointer, light, color, mode, onMS, offMS, 0); -    } +        public void pulse() { +            synchronized (this) { +                if (mColor == 0 && !mFlashing) { +                    setLightLocked(0x00ffffff, LIGHT_FLASH_HARDWARE, 7, 0, BRIGHTNESS_MODE_USER); +                    mH.sendMessageDelayed(Message.obtain(mH, 1, this), 3000); +                } +            } +        } -    public void setAttentionLight(boolean on, int color) { -        // Not worthy of a permission.  We shouldn't have a flashlight permission. -        synchronized (this) { -            mAttentionLightOn = on; -            mPulsing = false; -            setLight_native(mNativePointer, LIGHT_ID_ATTENTION, color, -                    LIGHT_FLASH_HARDWARE, on ? 3 : 0, 0, 0); +        public void turnOff() { +            synchronized (this) { +                setLightLocked(0, LIGHT_FLASH_NONE, 0, 0, 0); +            }          } -    } -    public void pulseBreathingLight() { -        synchronized (this) { -            // HACK: Added at the last minute of cupcake -- design this better; -            // Don't reuse the attention light -- make another one. -            if (false) { -                Log.d(TAG, "pulseBreathingLight mAttentionLightOn=" + mAttentionLightOn -                        + " mPulsing=" + mPulsing); +        private void stopFlashing() { +            synchronized (this) { +                setLightLocked(mColor, LIGHT_FLASH_NONE, 0, 0, BRIGHTNESS_MODE_USER);              } -            if (!mAttentionLightOn && !mPulsing) { -                mPulsing = true; -                setLight_native(mNativePointer, LIGHT_ID_ATTENTION, 0x00ffffff, -                        LIGHT_FLASH_HARDWARE, 7, 0, 0); -                mH.sendMessageDelayed(Message.obtain(mH, 1), 3000); +        } + +        private void setLightLocked(int color, int mode, int onMS, int offMS, int brightnessMode) { +            if (color != mColor || mode != mMode || onMS != mOnMS || offMS != mOffMS) { +                mColor = color; +                mMode = mode; +                mOnMS = onMS; +                mOffMS = offMS; +                setLight_native(mNativePointer, mId, color, mode, onMS, offMS, brightnessMode);              }          } + +        private int mId; +        private int mColor; +        private int mMode; +        private int mOnMS; +        private int mOffMS; +        private boolean mFlashing; +    } + +    LightsService(Context context) { + +        mNativePointer = init_native(); +        mContext = context; + +        for (int i = 0; i < LIGHT_ID_COUNT; i++) { +            mLights[i] = new Light(i); +        } +    } + +    protected void finalize() throws Throwable { +        finalize_native(mNativePointer); +        super.finalize(); +    } + +    public Light getLight(int id) { +        return mLights[id];      }      private Handler mH = new Handler() {          @Override          public void handleMessage(Message msg) { -            synchronized (this) { -                if (false) { -                    Log.d(TAG, "pulse cleanup handler firing mPulsing=" + mPulsing); -                } -                if (mPulsing) { -                    mPulsing = false; -                    setLight_native(mNativePointer, LIGHT_ID_ATTENTION, -                            mAttentionLightOn ? 0xffffffff : 0, -                            LIGHT_FLASH_NONE, 0, 0, 0); -                } -            } +            Light light = (Light)msg.obj; +            light.stopFlashing();          }      }; diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index b89cd3f4dd07..c179eb84049d 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -87,6 +87,9 @@ class NotificationManagerService extends INotificationManager.Stub      private WorkerHandler mHandler;      private StatusBarService mStatusBarService;      private LightsService mLightsService; +    private LightsService.Light mBatteryLight; +    private LightsService.Light mNotificationLight; +    private LightsService.Light mAttentionLight;      private NotificationRecord mSoundNotification;      private AsyncPlayer mSound; @@ -376,6 +379,10 @@ class NotificationManagerService extends INotificationManager.Stub          mStatusBarService = statusBar;          statusBar.setNotificationCallbacks(mNotificationCallbacks); +        mBatteryLight = lights.getLight(LightsService.LIGHT_ID_BATTERY); +        mNotificationLight = lights.getLight(LightsService.LIGHT_ID_NOTIFICATIONS); +        mAttentionLight = lights.getLight(LightsService.LIGHT_ID_ATTENTION); +          // Don't start allowing notifications until the setup wizard has run once.          // After that, including subsequent boots, init with notifications turned on.          // This works on the first boot because the setup wizard will toggle this @@ -678,7 +685,7 @@ class NotificationManagerService extends INotificationManager.Stub                      long identity = Binder.clearCallingIdentity();                      try {                          r.statusBarKey = mStatusBarService.addIcon(icon, n); -                        mLightsService.pulseBreathingLight(); +                        mAttentionLight.pulse();                      }                      finally {                          Binder.restoreCallingIdentity(identity); @@ -969,24 +976,20 @@ class NotificationManagerService extends INotificationManager.Stub          // Battery low always shows, other states only show if charging.          if (mBatteryLow) {              if (mBatteryCharging) { -                mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY, -                    BATTERY_LOW_ARGB); +                mBatteryLight.setColor(BATTERY_LOW_ARGB);              } else {                  // Flash when battery is low and not charging -                mLightsService.setLightFlashing(LightsService.LIGHT_ID_BATTERY, -                    BATTERY_LOW_ARGB, LightsService.LIGHT_FLASH_TIMED, -                    BATTERY_BLINK_ON, BATTERY_BLINK_OFF); +                mBatteryLight.setFlashing(BATTERY_LOW_ARGB, LightsService.LIGHT_FLASH_TIMED, +                        BATTERY_BLINK_ON, BATTERY_BLINK_OFF);              }          } else if (mBatteryCharging) {              if (mBatteryFull) { -                mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY, -                        BATTERY_FULL_ARGB); +                mBatteryLight.setColor(BATTERY_FULL_ARGB);              } else { -                mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY, -                        BATTERY_MEDIUM_ARGB); +                mBatteryLight.setColor(BATTERY_MEDIUM_ARGB);              }          } else { -            mLightsService.setLightOff(LightsService.LIGHT_ID_BATTERY); +            mBatteryLight.turnOff();          }          // handle notification lights @@ -998,10 +1001,9 @@ class NotificationManagerService extends INotificationManager.Stub              }          }          if (mLedNotification == null) { -            mLightsService.setLightOff(LightsService.LIGHT_ID_NOTIFICATIONS); +            mNotificationLight.turnOff();          } else { -            mLightsService.setLightFlashing( -                    LightsService.LIGHT_ID_NOTIFICATIONS, +            mNotificationLight.setFlashing(                      mLedNotification.notification.ledARGB,                      LightsService.LIGHT_FLASH_TIMED,                      mLedNotification.notification.ledOnMS, diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index ca7d94a683ea..8584d74e3590 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -183,6 +183,10 @@ class PowerManagerService extends IPowerManager.Stub      private Intent mScreenOnIntent;      private LightsService mLightsService;      private Context mContext; +    private LightsService.Light mLcdLight; +    private LightsService.Light mButtonLight; +    private LightsService.Light mKeyboardLight; +    private LightsService.Light mAttentionLight;      private UnsynchronizedWakeLock mBroadcastWakeLock;      private UnsynchronizedWakeLock mStayOnWhilePluggedInScreenDimLock;      private UnsynchronizedWakeLock mStayOnWhilePluggedInPartialLock; @@ -428,6 +432,11 @@ class PowerManagerService extends IPowerManager.Stub          mBatteryStats = BatteryStatsService.getService();          mBatteryService = battery; +        mLcdLight = lights.getLight(LightsService.LIGHT_ID_BACKLIGHT); +        mButtonLight = lights.getLight(LightsService.LIGHT_ID_BUTTONS); +        mKeyboardLight = lights.getLight(LightsService.LIGHT_ID_KEYBOARD); +        mAttentionLight = lights.getLight(LightsService.LIGHT_ID_ATTENTION); +          mHandlerThread = new HandlerThread("PowerManagerService") {              @Override              protected void onLooperPrepared() { @@ -1362,13 +1371,8 @@ class PowerManagerService extends IPowerManager.Stub                  enableLightSensor(on);                  if (!on) {                      // make sure button and key backlights are off too -                    int brightnessMode = (mUseSoftwareAutoBrightness -                            ? LightsService.BRIGHTNESS_MODE_SENSOR -                            : LightsService.BRIGHTNESS_MODE_USER); -                    mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS, 0, -                        brightnessMode); -                    mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD, 0, -                        brightnessMode); +                    mButtonLight.turnOff(); +                    mKeyboardLight.turnOff();                      // clear current value so we will update based on the new conditions                      // when the sensor is reenabled.                      mLightSensorValue = -1; @@ -1723,19 +1727,13 @@ class PowerManagerService extends IPowerManager.Stub                              ? LightsService.BRIGHTNESS_MODE_SENSOR                              : LightsService.BRIGHTNESS_MODE_USER);          if ((mask & SCREEN_BRIGHT_BIT) != 0) { -            mLightsService.setLightBrightness(LightsService.LIGHT_ID_BACKLIGHT, value, -                brightnessMode); +            mLcdLight.setBrightness(value, brightnessMode);          } -        brightnessMode = (mUseSoftwareAutoBrightness -                            ? LightsService.BRIGHTNESS_MODE_SENSOR -                            : LightsService.BRIGHTNESS_MODE_USER);          if ((mask & BUTTON_BRIGHT_BIT) != 0) { -            mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS, value, -                brightnessMode); +            mButtonLight.setBrightness(value);          }          if ((mask & KEYBOARD_BRIGHT_BIT) != 0) { -            mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD, value, -                brightnessMode); +            mKeyboardLight.setBrightness(value);          }      } @@ -2083,8 +2081,7 @@ class PowerManagerService extends IPowerManager.Stub                          int brightnessMode = (mAutoBrightessEnabled                                              ? LightsService.BRIGHTNESS_MODE_SENSOR                                              : LightsService.BRIGHTNESS_MODE_USER); -                        mLightsService.setLightBrightness(LightsService.LIGHT_ID_BACKLIGHT, -                                lcdValue, brightnessMode); +                        mLcdLight.setBrightness(lcdValue, brightnessMode);                      }                  }                  if (mButtonBrightnessOverride < 0) { @@ -2095,11 +2092,7 @@ class PowerManagerService extends IPowerManager.Stub                              startAnimation = true;                          }                      } else { -                        int brightnessMode = (mUseSoftwareAutoBrightness -                                            ? LightsService.BRIGHTNESS_MODE_SENSOR -                                            : LightsService.BRIGHTNESS_MODE_USER); -                        mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS, -                                buttonValue, brightnessMode); +                         mButtonLight.setBrightness(buttonValue);                      }                  }                  if (mButtonBrightnessOverride < 0 || !mKeyboardVisible) { @@ -2110,11 +2103,7 @@ class PowerManagerService extends IPowerManager.Stub                              startAnimation = true;                          }                      } else { -                        int brightnessMode = (mUseSoftwareAutoBrightness -                                            ? LightsService.BRIGHTNESS_MODE_SENSOR -                                            : LightsService.BRIGHTNESS_MODE_USER); -                        mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD, -                                keyboardValue, brightnessMode); +                        mKeyboardLight.setBrightness(keyboardValue);                      }                  }                  if (startAnimation) { @@ -2443,12 +2432,9 @@ class PowerManagerService extends IPowerManager.Stub          mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);          // Don't let applications turn the screen all the way off          brightness = Math.max(brightness, Power.BRIGHTNESS_DIM); -        mLightsService.setLightBrightness(LightsService.LIGHT_ID_BACKLIGHT, brightness, -                LightsService.BRIGHTNESS_MODE_USER); -        mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD, -            (mKeyboardVisible ? brightness : 0), LightsService.BRIGHTNESS_MODE_USER); -        mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS, brightness, -            LightsService.BRIGHTNESS_MODE_USER); +        mLcdLight.setBrightness(brightness); +        mKeyboardLight.setBrightness(mKeyboardVisible ? brightness : 0); +        mButtonLight.setBrightness(brightness);          long identity = Binder.clearCallingIdentity();          try {              mBatteryStats.noteScreenBrightness(brightness); @@ -2478,7 +2464,7 @@ class PowerManagerService extends IPowerManager.Stub      public void setAttentionLight(boolean on, int color) {          mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); -        mLightsService.setAttentionLight(on, color); +        mAttentionLight.setFlashing(color, LightsService.LIGHT_FLASH_HARDWARE, (on ? 3 : 0), 0);      }      private void enableProximityLockLocked() { diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 63a5435a4f59..538d60e12fb8 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -7191,14 +7191,6 @@ public class WindowManagerService extends IWindowManager.Stub              return mAppToken != null ? mAppToken.firstWindowDrawn : false;          } -        public boolean hasAppStartingIcon() { -            return mAppToken != null ? (mAppToken.startingData != null) : false; -        } - -        public WindowManagerPolicy.WindowState getAppStartingWindow() { -            return mAppToken != null ? mAppToken.startingWindow : null; -        } -          public void setAnimation(Animation anim) {              if (localLOGV) Log.v(                  TAG, "Setting animation in " + this + ": " + anim); diff --git a/services/jni/com_android_server_LightsService.cpp b/services/jni/com_android_server_LightsService.cpp index 1df9c814634e..9ed495195c45 100644 --- a/services/jni/com_android_server_LightsService.cpp +++ b/services/jni/com_android_server_LightsService.cpp @@ -39,6 +39,8 @@ enum {      LIGHT_INDEX_BATTERY = 3,      LIGHT_INDEX_NOTIFICATIONS = 4,      LIGHT_INDEX_ATTENTION = 5, +    LIGHT_INDEX_BLUETOOTH = 6, +    LIGHT_INDEX_WIFI = 7,      LIGHT_COUNT  }; @@ -80,6 +82,10 @@ static jint init_native(JNIEnv *env, jobject clazz)                  = get_device(module, LIGHT_ID_NOTIFICATIONS);          devices->lights[LIGHT_INDEX_ATTENTION]                  = get_device(module, LIGHT_ID_ATTENTION); +        devices->lights[LIGHT_INDEX_BLUETOOTH] +                = get_device(module, LIGHT_ID_BLUETOOTH); +        devices->lights[LIGHT_INDEX_WIFI] +                = get_device(module, LIGHT_ID_WIFI);      } else {          memset(devices, 0, sizeof(Devices));      }  |