diff --git a/base/api/current.xml b/base/api/current.xml
index 934e67a4..c60f1de8 100644
--- a/base/api/current.xml
+++ b/base/api/current.xml
@@ -76362,7 +76362,7 @@
type="float"
transient="false"
volatile="false"
- value="0.001f"
+ value="0.0010f"
static="true"
final="true"
deprecated="not deprecated"
@@ -147450,6 +147450,17 @@
visibility="public"
>
+
+
+
+
-
-
-
-
-
-
@@ -36,10 +31,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
-
-
-
-
-
@@ -47,9 +38,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
-
-
-
-
@@ -57,8 +45,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
-
-
-
@@ -66,7 +52,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
-
diff --git a/base/core/res/res/layout/onyx_input_method_extract_view.xml b/base/core/res/res/layout/onyx_input_method_extract_view.xml
index b8227225..b27f9631 100644
--- a/base/core/res/res/layout/onyx_input_method_extract_view.xml
+++ b/base/core/res/res/layout/onyx_input_method_extract_view.xml
@@ -6,7 +6,7 @@
android:background="@android:drawable/extract_edit_text"
android:gravity="top"
android:inputType="text"
- android:minLines="1"
+ android:lines="2"
android:scrollbars="vertical" >
diff --git a/base/packages/SettingsProvider/res/values/defaults.xml b/base/packages/SettingsProvider/res/values/defaults.xml
index a8af4765..009c8e98 100644
--- a/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/base/packages/SettingsProvider/res/values/defaults.xml
@@ -18,7 +18,7 @@
-->
true
- 60000
+ 5000
false
cell,bluetooth,wifi
diff --git a/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index f5060068..4811467a 100644
--- a/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -1014,10 +1014,12 @@ private void loadSystemSettings(SQLiteDatabase db) {
loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
R.bool.def_dim_screen);
loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,
- "1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 0);
+ "1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 3);
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
R.integer.def_screen_off_timeout);
-
+ loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT_BACKUP,
+ R.integer.def_screen_off_timeout);
+
// Set default cdma emergency tone
loadSetting(stmt, Settings.System.EMERGENCY_TONE, 0);
diff --git a/base/packages/SystemUI/res/drawable-mdpi/status_bar_background.9.png b/base/packages/SystemUI/res/drawable-mdpi/status_bar_background.9.png
index 262fb384..e509cf1b 100644
Binary files a/base/packages/SystemUI/res/drawable-mdpi/status_bar_background.9.png and b/base/packages/SystemUI/res/drawable-mdpi/status_bar_background.9.png differ
diff --git a/base/packages/SystemUI/res/drawable-mdpi/statusbar_background.9.png b/base/packages/SystemUI/res/drawable-mdpi/statusbar_background.9.png
index 262fb384..e509cf1b 100644
Binary files a/base/packages/SystemUI/res/drawable-mdpi/statusbar_background.9.png and b/base/packages/SystemUI/res/drawable-mdpi/statusbar_background.9.png differ
diff --git a/base/packages/SystemUI/res/drawable/home_l.png b/base/packages/SystemUI/res/drawable/home_l.png
new file mode 100644
index 00000000..0ad69902
Binary files /dev/null and b/base/packages/SystemUI/res/drawable/home_l.png differ
diff --git a/base/packages/SystemUI/res/drawable/refresh.png b/base/packages/SystemUI/res/drawable/refresh.png
new file mode 100644
index 00000000..952aa55e
Binary files /dev/null and b/base/packages/SystemUI/res/drawable/refresh.png differ
diff --git a/base/packages/SystemUI/res/drawable/status_bar_button.xml b/base/packages/SystemUI/res/drawable/status_bar_button.xml
new file mode 100644
index 00000000..306ee1c3
--- /dev/null
+++ b/base/packages/SystemUI/res/drawable/status_bar_button.xml
@@ -0,0 +1,24 @@
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/base/packages/SystemUI/res/layout/status_bar.xml b/base/packages/SystemUI/res/layout/status_bar.xml
index 45c0130a..d8f47867 100644
--- a/base/packages/SystemUI/res/layout/status_bar.xml
+++ b/base/packages/SystemUI/res/layout/status_bar.xml
@@ -18,100 +18,126 @@
*/
-->
-
-
+
+ android:focusable="true"
+ android:orientation="vertical" >
-
-
-
+
+
+
+
-
-
+
+
+
+
+ android:orientation="horizontal"
+ android:paddingRight="6dip" />
+ android:paddingRight="6dip"
+ android:singleLine="true"
+ android:textAppearance="@*android:style/TextAppearance.StatusBar.Icon"
+ android:textColor="#ff000000" />
-
-
-
+
+
+ android:layout_marginRight="8dip" >
+
+ android:layout_height="25dip" />
+
+ android:layout_height="25dip" />
-
+ android:layout_weight="1"
+ android:paddingRight="10dip"
+ android:paddingTop="2dip" >
+
-
+
+
+ android:textAppearance="@*android:style/TextAppearance.StatusBar.Ticker"
+ android:textColor="#000000" />
-
-
+ android:singleLine="true"
+ android:textAppearance="@*android:style/TextAppearance.StatusBar.Icon"
+ android:textColor="#000000" />
+
+
\ No newline at end of file
diff --git a/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java b/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
index e63f37f4..915db0a6 100644
--- a/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
+++ b/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
@@ -57,6 +57,7 @@
import android.text.style.StyleSpan;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
+import android.util.Log;
import android.util.Slog;
import android.view.View;
import android.view.ViewGroup;
@@ -76,6 +77,13 @@
import com.android.systemui.R;
import android.net.wimax.WimaxManagerConstants;
+import android.os.SystemClock;
+import android.os.ServiceManager;
+import android.view.IWindowManager;
+import android.view.KeyEvent;
+
+import com.android.systemui.statusbar.StatusBarView;
+
/**
* This class contains all of the policy about which icons are installed in the status
* bar at boot time. It goes through the normal API for icons, even though it probably
@@ -532,6 +540,8 @@ public class StatusBarPolicy {
// sync state
// If sync is active the SyncActive icon is displayed. If sync is not active but
// sync is failing the SyncFailing icon is displayed. Otherwise neither are displayed.
+
+
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
@@ -591,6 +601,9 @@ else if (action.equals(WimaxManagerConstants.WIMAX_ENABLED_STATUS_CHANGED) ||
else if (action.equals(Intent.ACTION_HDMI_PLUG)){
updateHdmi(intent);
}
+ else if (action.equals(StatusBarView.ACTION_ICONKEY_HOME)) {
+ updateIconKeyAction(intent);
+ }
}
};
@@ -633,12 +646,12 @@ public StatusBarPolicy(Context context) {
// wimax
//enable/disable wimax depending on the value in config.xml
- boolean isWimaxEnabled = mContext.getResources().getBoolean(
- com.android.internal.R.bool.config_wimaxEnabled);
- if (isWimaxEnabled) {
- mService.setIcon("wimax", sWimaxDisconnectedImg, 0);
- mService.setIconVisibility("wimax", false);
- }
+ //boolean isWimaxEnabled = mContext.getResources().getBoolean(
+ // com.android.internal.R.bool.config_wimaxEnabled);
+ //if (isWimaxEnabled) {
+ // mService.setIcon("wimax", sWimaxDisconnectedImg, 0);
+ // mService.setIconVisibility("wimax", false);
+ //}
// TTY status
mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0);
@@ -709,8 +722,11 @@ public StatusBarPolicy(Context context) {
filter.addAction(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION);
filter.addAction(WimaxManagerConstants.WIMAX_ENABLED_STATUS_CHANGED);
- filter.addAction(Intent.ACTION_HDMI_PLUG);
+ filter.addAction(Intent.ACTION_HDMI_PLUG);
+
+ filter.addAction(StatusBarView.ACTION_ICONKEY_HOME);
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
+
// load config to determine if to distinguish Hspa data icon
try {
@@ -1514,4 +1530,31 @@ public void handleMessage(Message msg) {
}
}
}
+
+ private final void updateIconKeyAction(Intent intent)
+ {
+ int keycode = intent.getIntExtra("keycode", -1);
+ IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
+
+ if (keycode != -1) {
+ long now = SystemClock.uptimeMillis();
+
+ KeyEvent down = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keycode, 0);
+ KeyEvent up = new KeyEvent(now, now, KeyEvent.ACTION_UP, keycode, 0);
+
+ try {
+ wm.injectKeyEvent(down, false);
+ }
+ catch (RemoteException e) {
+ Log.w(TAG, e);
+ }
+
+ try {
+ wm.injectKeyEvent(up, false);
+ }
+ catch (RemoteException e) {
+ Log.w(TAG, e);
+ }
+ }
+ }
}
diff --git a/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java b/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
index d3928d4b..42d87d83 100644
--- a/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
+++ b/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
@@ -772,7 +772,7 @@ void performCollapse() {
mExpandedDialog.getWindow().setAttributes(mExpandedParams);
mTrackingView.setVisibility(View.GONE);
mExpandedView.setVisibility(View.GONE);
-
+
if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) {
setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in);
}
diff --git a/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarView.java b/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarView.java
index 117b1264..addee08d 100644
--- a/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarView.java
+++ b/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarView.java
@@ -17,15 +17,19 @@
package com.android.systemui.statusbar;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.os.SystemClock;
import android.util.AttributeSet;
+import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
+import android.widget.Toast;
import com.android.systemui.R;
@@ -42,8 +46,17 @@ public class StatusBarView extends FrameLayout {
View mDate;
FixedSizeDrawable mBackground;
+ ImageButton mHomeButton;
+ ImageButton mRefreshButton;
+ final Context mContext;
+
+ public static final int KEY_HOME = KeyEvent.KEYCODE_HOME;
+
+ public static final String ACTION_ICONKEY_HOME = "android.intent.action.ICONKEY_HOME";
+
public StatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
+ mContext = context;
}
@Override
@@ -56,6 +69,12 @@ protected void onFinishInflate() {
mBackground = new FixedSizeDrawable(mDate.getBackground());
mBackground.setFixedBounds(0, 0, 0, 0);
mDate.setBackgroundDrawable(mBackground);
+
+ mHomeButton = (ImageButton)findViewById(R.id.go_home);
+ mHomeButton.setOnTouchListener(homeOnTouch);
+
+ mRefreshButton = (ImageButton)findViewById(R.id.refresh);
+ mRefreshButton.setOnTouchListener(refreshOnTouch);
}
@Override
@@ -146,8 +165,61 @@ public boolean onTouchEvent(MotionEvent event) {
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
- return mService.interceptTouchEvent(event)
- ? true : super.onInterceptTouchEvent(event);
+
+ if( (event.getX() > mRefreshButton.getRight()) || (event.getX() < mHomeButton.getLeft())){
+ return mService.interceptTouchEvent(event)
+ ? true : super.onInterceptTouchEvent(event);
+ }
+ return false;
+
+// return mService.interceptTouchEvent(event)
+// ? true : super.onInterceptTouchEvent(event);
+ }
+
+ void sendIntent(Intent intent)
+ {
+ mContext.sendBroadcast(intent);
+ }
+
+ private void sendKeyIntent(int keycode)
+ {
+ Intent intent = new Intent(ACTION_ICONKEY_HOME);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
+ intent.putExtra("keycode", keycode);
+ sendIntent(intent);
}
+
+ private OnTouchListener homeOnTouch = new OnTouchListener()
+ {
+ // @Override
+ public boolean onTouch(View v, MotionEvent event)
+ {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_UP:
+ {
+ sendKeyIntent(KEY_HOME);
+ }
+ break;
+ }
+ return false;
+ }
+ };
+
+ private OnTouchListener refreshOnTouch = new OnTouchListener()
+ {
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event)
+ {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_UP:
+ {
+ Toast.makeText(mContext, "Refresh", Toast.LENGTH_LONG).show();
+ }
+ break;
+ }
+ return false;
+ }
+ };
}
diff --git a/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index a1556610..4eaa9f0b 100644
--- a/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -174,7 +174,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
//tell kernel which suspend mode go in.
static final String AUTO_SUSPEND = "1";//perpheral like sd card ,tp ,keyboard can wakeup device,include power key and usb.
- static final String POWER_KEY_SUSPEND = "0";//power key and usb can wakeup devices.
+ public static final String POWER_KEY_SUSPEND = "0";//power key and usb can wakeup devices.
// Useful scan codes.
private static final int SW_LID = 0x00;
diff --git a/base/services/java/com/android/server/PowerManagerService.java b/base/services/java/com/android/server/PowerManagerService.java
index 52e83e9b..b63985ad 100644
--- a/base/services/java/com/android/server/PowerManagerService.java
+++ b/base/services/java/com/android/server/PowerManagerService.java
@@ -19,9 +19,12 @@
import com.android.internal.app.IBatteryStats;
import com.android.internal.app.ShutdownThread;
import com.android.server.am.BatteryStatsService;
+import com.android.internal.policy.impl.PhoneWindowManager;
import android.app.ActivityManagerNative;
+import android.app.AlarmManager;
import android.app.IActivityManager;
+import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ContentQueryMap;
import android.content.ContentResolver;
@@ -69,11 +72,13 @@
import static android.provider.Settings.System.WINDOW_ANIMATION_SCALE;
import static android.provider.Settings.System.TRANSITION_ANIMATION_SCALE;
import static android.provider.Settings.System.XEC_DLS_CONTROL;
+import static com.android.internal.policy.impl.PhoneWindowManager.POWER_KEY_SUSPEND;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;
@@ -98,16 +103,27 @@ class PowerManagerService extends IPowerManager.Stub
// time since last state: time since last event:
// The short keylight delay comes from secure settings; this is the default.
- private static final int SHORT_KEYLIGHT_DELAY_DEFAULT = 6000; // t+6 sec
- private static final int MEDIUM_KEYLIGHT_DELAY = 15000; // t+15 sec
- private static final int LONG_KEYLIGHT_DELAY = 6000; // t+6 sec
- private static final int LONG_DIM_TIME = 7000; // t+N-5 sec
+// private static final int SHORT_KEYLIGHT_DELAY_DEFAULT = 6000; // t+6 sec
+// private static final int MEDIUM_KEYLIGHT_DELAY = 15000; // t+15 sec
+// private static final int LONG_KEYLIGHT_DELAY = 6000; // t+6 sec
+// private static final int LONG_DIM_TIME = 7000; // t+N-5 sec
+
+ private static final int SHORT_KEYLIGHT_DELAY_DEFAULT = 1000;
+ private static final int MEDIUM_KEYLIGHT_DELAY = 1000;
+ private static final int LONG_KEYLIGHT_DELAY = 1000;
+ private static final int LONG_DIM_TIME = 1000;
+ private static final String ACTION_DEVICE_SHUTDOWN =
+ "com.android.server.action.DEVICE_SHUTDOWN";
+
// How long to wait to debounce light sensor changes.
private static final int LIGHT_SENSOR_DELAY = 2000;
// For debouncing the proximity sensor.
private static final int PROXIMITY_SENSOR_DELAY = 1000;
+
+ // For shutdown the device.
+ private static final int DEFAULT_POWEROFF_TIMEOUT = 30 * 60 * 1000;
// trigger proximity if distance is less than 5 cm
private static final float PROXIMITY_THRESHOLD = 5.0f;
@@ -161,6 +177,9 @@ class PowerManagerService extends IPowerManager.Stub
private final int MY_UID;
private final int MY_PID;
+ private PendingIntent mPendingIntent = null;
+ private AlarmManager mAlarmManager;
+ private static PowerManager.WakeLock sCpuWakeLock;
private boolean mDoneBooting = false;
private boolean mBootCompleted = false;
private int mStayOnConditions = 0;
@@ -402,6 +421,39 @@ public void onReceive(Context context, Intent intent) {
dockStateChanged(state);
}
}
+
+ public static void acquireCpuWakeLock(Context context) {
+ if (sCpuWakeLock != null) {
+ return;
+ }
+
+ PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+
+ sCpuWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
+ | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "AlarmClock");
+ sCpuWakeLock.acquire();
+ }
+
+ public static void releaseCpuLock() {
+ if (sCpuWakeLock != null) {
+ sCpuWakeLock.release();
+ sCpuWakeLock = null;
+ }
+ }
+
+ private final class ShutdownReceiver extends BroadcastReceiver {
+ public void onReceive(Context arg0, Intent arg1) {
+ // TODO Auto-generated method stub
+
+ acquireCpuWakeLock(arg0);
+ Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
+ intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(intent);
+ Slog.d(TAG, "----- Receiver Shutdown Timeout ----- ");
+ }
+
+ }
/**
* Set the setting that determines whether the device stays on when plugged in.
@@ -498,6 +550,7 @@ public void update(Observable o, Object arg) {
private ContentQueryMap mSettings;
+
void init(Context context, LightsService lights, IActivityManager activity,
BatteryService battery) {
mLightsService = lights;
@@ -637,6 +690,10 @@ void initInThread() {
filter = new IntentFilter();
filter.addAction(Intent.ACTION_DOCK_EVENT);
mContext.registerReceiver(new DockReceiver(), filter);
+ filter = new IntentFilter();
+ filter.addAction(ACTION_DEVICE_SHUTDOWN);
+ mContext.registerReceiver(new ShutdownReceiver(), filter);
+
// Listen for secure settings changes
mContext.getContentResolver().registerContentObserver(
@@ -1209,6 +1266,7 @@ private void setTimeoutLocked(long now, final long originalTimeoutOverride, int
{
case SCREEN_BRIGHT:
when = now + mKeylightDelay;
+
break;
case SCREEN_DIM:
if (mDimDelay >= 0) {
@@ -1261,9 +1319,34 @@ private void setTimeoutLocked(long now, final long originalTimeoutOverride, int
: -1;
mHandler.postAtTime(mTimeoutTask, when);
mNextTimeout = when; // for debugging
+
}
}
}
+
+ private void cancelShutdownTimer() {
+ if (mPendingIntent != null) {
+ mAlarmManager.cancel(mPendingIntent);
+ Slog.d(TAG, "------------------- Cancel shutdown timer -------------------");
+ mPendingIntent = null;
+ }
+ }
+
+ private void startShutdownTimer() {
+ if (mPendingIntent == null) {
+ mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
+
+ Intent intent = new Intent(ACTION_DEVICE_SHUTDOWN);
+ intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
+ Date t = new Date();
+ t.setTime(java.lang.System.currentTimeMillis() + DEFAULT_POWEROFF_TIMEOUT);
+// t.setTime(java.lang.System.currentTimeMillis() + 1 * 60 * 1000);
+ PendingIntent pi = mPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
+ mAlarmManager.set(AlarmManager.RTC_WAKEUP, t.getTime(), pi);
+ Slog.d(TAG, "------------------- Start shutdown timer -------------------");
+ }
+ }
private void cancelTimerLocked()
{
@@ -1272,11 +1355,12 @@ private void cancelTimerLocked()
}
private class TimeoutTask implements Runnable
- {
+ {
int nextState; // access should be synchronized on mLocks
+
long remainingTimeoutOverride;
- public void run()
- {
+
+ public void run() {
synchronized (mLocks) {
if (mSpew) {
Slog.d(TAG, "user activity timeout timed out nextState=" + this.nextState);
@@ -1291,8 +1375,7 @@ public void run()
long now = SystemClock.uptimeMillis();
- switch (this.nextState)
- {
+ switch (this.nextState) {
case SCREEN_BRIGHT:
if (mDimDelay >= 0) {
setTimeoutLocked(now, remainingTimeoutOverride, SCREEN_DIM);
@@ -1303,6 +1386,23 @@ public void run()
break;
}
}
+ if (mUserState == SCREEN_DIM) {
+// int timeout = Settings.System.getInt(mContext.getContentResolver(),
+// SCREEN_OFF_TIMEOUT, -1);
+// if (mContext != null && ActivityManagerNative.isSystemReady()
+// && timeout >= DEFAULT_POWEROFF_TIMEOUT) {
+// Slog.d(TAG, "--- ACTION_REQUEST_SHUTDOWN ---");
+// Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
+// intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
+// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+// mContext.startActivity(intent);
+// return;
+// }
+// if (timeout >= 60 * 1000) {
+// PhoneWindowManager.writeContent("/sys/power/power_mode", POWER_KEY_SUSPEND);
+// }
+ startShutdownTimer();
+ }
}
}
@@ -1381,7 +1481,6 @@ public void run()
}
if (value == 1) {
mScreenOnStart = SystemClock.uptimeMillis();
-
policy.screenTurnedOn();
try {
ActivityManagerNative.getDefault().wakingUp();
@@ -2315,7 +2414,9 @@ private void userActivity(long time, long timeoutOverride, boolean noChangeLight
}
}
}
-
+ if ((mUserActivityAllowed && !mProximitySensorActive)) {
+ cancelShutdownTimer();
+ }
if (mPolicy != null) {
mPolicy.userActivity();
}
diff --git a/base/services/java/com/android/server/WifiService.java b/base/services/java/com/android/server/WifiService.java
index 2813e03a..589ee20d 100644
--- a/base/services/java/com/android/server/WifiService.java
+++ b/base/services/java/com/android/server/WifiService.java
@@ -28,6 +28,9 @@
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLING;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;
+import static android.provider.Settings.System.DEFAULT_SCREEN_OFF_TIMEOUT_WIFI;
+import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
+import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT_BACKUP;
import android.app.AlarmManager;
import android.app.PendingIntent;
@@ -66,6 +69,7 @@
import android.os.ServiceManager;
import android.os.WorkSource;
import android.provider.Settings;
+import android.util.Log;
import android.util.Slog;
import android.text.TextUtils;
@@ -295,9 +299,23 @@ public void startWifi() {
/* Start if Wi-Fi is enabled or the saved state indicates Wi-Fi was on */
boolean wifiEnabled = !isAirplaneModeOn()
&& (getPersistedWifiEnabled() || testAndClearWifiSavedState());
- Slog.i(TAG, "WifiService starting up with Wi-Fi " +
- (wifiEnabled ? "enabled" : "disabled"));
+ Slog.i(TAG, "WifiService starting up with Wi-Fi " + (wifiEnabled ? "enabled" : "disabled"));
setWifiEnabled(wifiEnabled);
+ if (wifiEnabled) {
+ int timeout = Settings.System.getInt(mContext.getContentResolver(), SCREEN_OFF_TIMEOUT,
+ -1);
+ Settings.System.putInt(mContext.getContentResolver(), SCREEN_OFF_TIMEOUT_BACKUP,
+ timeout);// save screen_off_timeout to
+ // screen_off_timeout_backup
+ Log.d(TAG,
+ "Set SCREEN_OFF_TIMEOUT_BACKUP is "
+ + Settings.System.getInt(mContext.getContentResolver(),
+ SCREEN_OFF_TIMEOUT_BACKUP, -1));
+ if (timeout < DEFAULT_SCREEN_OFF_TIMEOUT_WIFI) {
+ Settings.System.putInt(mContext.getContentResolver(), SCREEN_OFF_TIMEOUT,
+ DEFAULT_SCREEN_OFF_TIMEOUT_WIFI);
+ }
+ }
}
private void updateTetherState(ArrayList available, ArrayList tethered) {
@@ -422,7 +440,7 @@ public boolean setWifiEnabled(boolean enable) {
return true;
}
-
+
/**
* Enables/disables Wi-Fi synchronously.
* @param enable {@code true} to turn Wi-Fi on, {@code false} to turn it off.
@@ -1770,7 +1788,11 @@ public void onReceive(Context context, Intent intent) {
}
}
mWifiStateTracker.setBluetoothScanMode(isBluetoothPlaying);
-
+ } else if (action.equals(Intent.ACTION_SHUTDOWN)) {
+ int timeout = Settings.System.getInt(mContext.getContentResolver(),
+ SCREEN_OFF_TIMEOUT_BACKUP, -1);
+ Settings.System.putInt(mContext.getContentResolver(), SCREEN_OFF_TIMEOUT, timeout);
+ Slog.w(TAG, "Writing screen_off_timeout " + timeout + " before shutdown...");
} else {
return;
}
@@ -1935,6 +1957,7 @@ private void registerForBroadcasts() {
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
+ intentFilter.addAction(Intent.ACTION_SHUTDOWN);
intentFilter.addAction(ACTION_DEVICE_IDLE);
intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
mContext.registerReceiver(mReceiver, intentFilter);
diff --git a/base/services/surfaceflinger/SurfaceFlinger.cpp b/base/services/surfaceflinger/SurfaceFlinger.cpp
index a8d160b3..e9f68a6f 100644
--- a/base/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/base/services/surfaceflinger/SurfaceFlinger.cpp
@@ -75,6 +75,9 @@
#define UI_FULL_MODE 0x0064
#define SPECIAL_MODE_MASK 0x0700
+#define ANDROID_STATUSBAR_HEIGHT_160 35
+#define ANDROID_STATUSBAR_HEIGHT_240 53
+
namespace android {
// ---------------------------------------------------------------------------
@@ -97,7 +100,7 @@ SurfaceFlinger::SurfaceFlinger()
mFreezeDisplayTime(0),
mDebugRegion(0),
mDebugBackground(0),
- mDebugFps(0),
+ mDebugFps(0),
mDebugInSwapBuffers(0),
mLastSwapBufferTime(0),
mDebugInTransaction(0),
@@ -105,12 +108,13 @@ SurfaceFlinger::SurfaceFlinger()
mBootFinished(false),
mConsoleSignals(0),
mSecureFrameBuffer(0),
- mSurfaceInitUpdate(false),
+ mSurfaceInitUpdate(false),
mSkipNextInitUpdate(false)
{
//fix the maximum layer is 10;
mRegionsDirtyReglist = new DirtyRegList[MAX_LAYER];
mNeedspecialupdate = 0;
+ mSystemBarHeight = ANDROID_STATUSBAR_HEIGHT_160; //DPI 160
init();
}
@@ -255,6 +259,25 @@ status_t SurfaceFlinger::readyToRun()
dcblk->fps = hw.getRefreshRate();
dcblk->density = hw.getDensity();
+ //Set Android system ar height
+ const float dpyDensity = hw.getDensity();
+ const int dpi = (int)(dpyDensity * 160.0f);
+ LOGI("****** Screen DPI =%d ******\n", dpi);
+ if (dpi == 240)
+ {
+ mSystemBarHeight = ANDROID_STATUSBAR_HEIGHT_240;
+ }
+ else if (dpi == 160)
+ {
+ mSystemBarHeight = ANDROID_STATUSBAR_HEIGHT_160;
+ }
+ else
+ {
+ mSystemBarHeight = (int)(dpyDensity * ANDROID_STATUSBAR_HEIGHT_160 + 0.5);
+ }
+
+ LOGI("****** Android StatusbarH =%d ******\n", mSystemBarHeight);
+
// Initialize OpenGL|ES
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
@@ -281,7 +304,7 @@ status_t SurfaceFlinger::readyToRun()
glLoadIdentity();
glOrthof(0, w, h, 0, 0, 1);
- LayerDim::initDimmer(this, w, h);
+ LayerDim::initDimmer(this, w, h);
mReadyToRunBarrier.open();
@@ -576,6 +599,7 @@ void SurfaceFlinger::releaseDirtyGroup()
// get parameters from client to see if we need to use special update or not.
void SurfaceFlinger::EinkOptPostFramebuffer()
+
{
bool bNeedPartialupdate = false;
Region pInvalidRegion = mInvalidRegion;
@@ -647,7 +671,7 @@ void SurfaceFlinger::EinkOptPostFramebuffer()
{
allrectList.add(rectList[j]);
allupdatemode.add(UI_DEFAULT_MODE);
- LOGI("EOPostFB rect %d left=%d, top=%d, right=%d, bottom=%d mode=%d \n",allnum, allrectList[allnum].left, allrectList[allnum].top,
+ LOGI("EOPostFB rect %d left=%d, top=%d, right=%d, bottom=%d mode=%d\n",allnum, allrectList[allnum].left, allrectList[allnum].top,
allrectList[allnum].right,allrectList[allnum].bottom,UI_DEFAULT_MODE);
allnum++;
}
@@ -1174,7 +1198,7 @@ void SurfaceFlinger::handlePageFlip()
const Region reminder(screenRegion.subtract(visibleRegion));
if (reminder.isEmpty()) {
// fullscreen candidate!
- LOGI("--->BYPASS found fullscrfeen candidate!\n");
+ LOGI("--->BYPASS found fullscreen candidate!\n");
bypassLayer = candidate;
}
}
@@ -1199,37 +1223,37 @@ void SurfaceFlinger::handlePageFlip()
else
{
int orientation = graphicPlane(0).getOrientation();
- LOGI("--->Set default update flag, %d<---\n", orientation);
+ LOGI("****** StatusBarH=%d, system orientation=%d ******\n", mSystemBarHeight, orientation);
mSurfaceInitUpdate = false;
if (orientation == ISurfaceComposer::eOrientationDefault)
{
- if ((mDirtyRegion.getBounds().top == hw.bounds().top) && (mDirtyRegion.getBounds().right == hw.bounds().right) && (mDirtyRegion.getBounds().bottom == hw.bounds().bottom) && (mDirtyRegion.getBounds().left == 35))
+ if ((mDirtyRegion.getBounds().top == hw.bounds().top) && (mDirtyRegion.getBounds().right == (hw.bounds().right-/*35*/mSystemBarHeight)) && (mDirtyRegion.getBounds().bottom == hw.bounds().bottom) && (mDirtyRegion.getBounds().left == hw.bounds().left))
{
- LOGI("===>Portrait0, Set init update flag<===\n");
+ LOGI("===>Portrait180, Set init update flag<===\n");
mSurfaceInitUpdate = true;
}
}
else if (orientation == ISurfaceComposer::eOrientation180)
{
- if ((mDirtyRegion.getBounds().top == hw.bounds().top) && (mDirtyRegion.getBounds().right == (hw.bounds().right-35)) && (mDirtyRegion.getBounds().bottom == hw.bounds().bottom) && (mDirtyRegion.getBounds().left == hw.bounds().left))
+ if ((mDirtyRegion.getBounds().top == hw.bounds().top) && (mDirtyRegion.getBounds().right == hw.bounds().right) && (mDirtyRegion.getBounds().bottom == hw.bounds().bottom) && (mDirtyRegion.getBounds().left == /*35*/mSystemBarHeight))
{
- LOGI("===>Portrait180, Set init update flag<===\n");
+ LOGI("===>Portrait0, Set init update flag<===\n");
mSurfaceInitUpdate = true;
}
}
else if (orientation == ISurfaceComposer::eOrientation90)
{
- if ((mDirtyRegion.getBounds().top == 35) && (mDirtyRegion.getBounds().right == hw.bounds().right) && (mDirtyRegion.getBounds().bottom == hw.bounds().bottom) && (mDirtyRegion.getBounds().left == hw.bounds().left))
+ if ((mDirtyRegion.getBounds().top == hw.bounds().top) && (mDirtyRegion.getBounds().right == hw.bounds().right) && (mDirtyRegion.getBounds().bottom == (hw.bounds().bottom-/*35*/mSystemBarHeight)) && (mDirtyRegion.getBounds().left == hw.bounds().left))
{
- LOGI("===>Lanscape90, Set init update flag<===\n");
+ LOGI("===>Lanscape270, Set init update flag<===\n");
mSurfaceInitUpdate = true;
}
}
else if (orientation == ISurfaceComposer::eOrientation270)
{
- if ((mDirtyRegion.getBounds().top == hw.bounds().top) && (mDirtyRegion.getBounds().right == hw.bounds().right) && (mDirtyRegion.getBounds().bottom == (hw.bounds().bottom-35)) && (mDirtyRegion.getBounds().left == hw.bounds().left))
+ if ((mDirtyRegion.getBounds().top == /*35*/mSystemBarHeight) && (mDirtyRegion.getBounds().right == hw.bounds().right) && (mDirtyRegion.getBounds().bottom == hw.bounds().bottom) && (mDirtyRegion.getBounds().left == hw.bounds().left))
{
- LOGI("===>Lanscape270, Set init update flag<===\n");
+ LOGI("===>Lanscape90, Set init update flag<===\n");
mSurfaceInitUpdate = true;
}
}
diff --git a/base/services/surfaceflinger/SurfaceFlinger.h b/base/services/surfaceflinger/SurfaceFlinger.h
index 0a5e4e9a..dc8dda78 100644
--- a/base/services/surfaceflinger/SurfaceFlinger.h
+++ b/base/services/surfaceflinger/SurfaceFlinger.h
@@ -435,17 +435,18 @@ class SurfaceFlinger :
eConsoleReleased = 1,
eConsoleAcquired = 2
};
- volatile int32_t mConsoleSignals;
-
- // only written in the main thread, only read in other threads
- volatile int32_t mSecureFrameBuffer;
- #ifdef SECOND_DISPLAY_SUPPORT
- int mTopOrientation;
- #endif
-
- //WO, mark surface init update
- bool mSurfaceInitUpdate;
- bool mSkipNextInitUpdate;
+ volatile int32_t mConsoleSignals;
+
+ // only written in the main thread, only read in other threads
+ volatile int32_t mSecureFrameBuffer;
+ #ifdef SECOND_DISPLAY_SUPPORT
+ int mTopOrientation;
+ #endif
+
+ //WO, mark surface init update
+ bool mSurfaceInitUpdate;
+ bool mSkipNextInitUpdate;
+ int mSystemBarHeight;
};
// ---------------------------------------------------------------------------