----------- frameworks/base/packages/SystemUI/res/values/config.xml -----------
index 260d81b..02c6a11 100644
@@ -119,7 +119,7 @@
<!-- The default tiles to display in QuickSettings --><stringname="quick_settings_tiles_default"translatable="false">
- wifi,bt,inversion,dnd,cell,airplane,rotation,flashlight,location,cast,hotspot
+ wifi,bt,inversion,dnd,cell,airplane,rotation,flashlight,location,screenshot,hotspot
</string><!-- The tiles to display in QuickSettings -->
----------- frameworks/base/packages/SystemUI/res/values/strings.xml -----------
index 5fc7e5d..0e3c17a 100644
@@ -1121,7 +1121,7 @@
<stringname="remove_from_settings_prompt">Remove System UI Tuner from Settings and stop using all of its features?"</string><stringname="utouu_status_bar_phone_going">Calling. Click to return</string><stringname="utouu_status_bar_phone_going_in_lockscreen">Calling</string>
-
+ <stringname="screenshot_title">ScreenShot</string><stringname="key_writer_test">加密芯片测试</string><stringname="key_writer_string1">芯片是否写入KEY:</string><stringname="key_writer_string2">NV中的KEY:</string>
-- frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSTile.java --
index 5bad7e5..7e1a288 100644
@@ -41,7 +41,7 @@ import com.android.systemui.statusbar.policy.LocationController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.RotationLockController;
import com.android.systemui.statusbar.policy.ZenModeController;
-
+import com.android.systemui.statusbar.policy.ScreenShotController; //add
/// M: Add other tiles
import com.mediatek.systemui.statusbar.policy.AudioProfileController;
import com.mediatek.systemui.statusbar.policy.HotKnotController;
@@ -358,6 +358,9 @@ public abstract class QSTile<TState extends State> implements Listenable {
*/
AudioProfileController getAudioProfileController();
+ /// M: add screenshot in quick setting by Lee
+ ScreenShotController getScreenShotController();
+
public interface Callback {
void onTilesChanged();
}
---frameworks/base/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenShotTile.java
new file mode 100644
index 0000000..5080e91
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2014 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
+ *
+ * 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
+ * limitations under the License.
+ */
+
+package com.android.systemui.qs.tiles;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ComponentName;
+import android.content.ServiceConnection;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.UserHandle;
+import android.os.RemoteException;
+import android.os.Message;
+import android.os.Messenger;
+
+import android.util.Log;
+
+import com.android.systemui.R;
+import com.android.systemui.qs.GlobalSetting;
+import com.android.systemui.qs.QSTile;
+import com.android.internal.logging.MetricsLogger;
+
+/** Quick settings tile: Airplane mode **/
+publicclass ScreenShotTile extends QSTile<QSTile.BooleanState> {
+
+ final Handler mHandler;
+
+ final Object mScreenshotLock = new Object();
+ ServiceConnection mScreenshotConnection = null;
+ final Host mHost;
+
+ public ScreenShotTile(Host host) {
+ super(host);
+ mHost = host;
+ mHandler = new Handler();
+ }
+
+ @Override
+ protected BooleanState newTileState() {
+ returnnew BooleanState();
+ }
+
+ @Override
+ publicvoid handleClick() {
+ //Log.v("Lee", "handleClick() mHost="+mHost);
+ if (mHost != null) {
+ mHost.getScreenShotController().onCollapsePanels();
+ }
+ mHandler.postDelayed(mScreenshotRunnable, 1000);
+ }
+
+ @Override
+ protectedvoid handleUpdateState(BooleanState state, Object arg) {
+ state.label = mContext.getString(R.string.screenshot_title);
+ state.visible = true;
+ state.icon = ResourceIcon.get(R.drawable.ic_qs_screenshot);
+ }
+
+ @Override
+ publicint getMetricsCategory() {
+ return MetricsLogger.QS_LOCATION;
+ }
+
+ @Override
+ publicvoid setListening(boolean listening) {
+
+ }
+
+ privatefinal Runnable mScreenshotRunnable = new Runnable() {
+ @Override
+ publicvoid run() {
+ takeScreenshot();
+ }
+ };
+
+ final Runnable mScreenshotTimeout = new Runnable() {
+ @Overridepublicvoid run() {
+ synchronized (mScreenshotLock) {
+ if (mScreenshotConnection != null) {
+ mContext.unbindService(mScreenshotConnection);
+ mScreenshotConnection = null;
+ }
+ }
+ }
+ };
+
+ // Assume this is called from the Handler thread.
+ privatevoid takeScreenshot() {
+ synchronized (mScreenshotLock) {
+ if (mScreenshotConnection != null) {
+ return;
+ }
+ ComponentName cn = new ComponentName("com.android.systemui",
+ "com.android.systemui.screenshot.TakeScreenshotService");
+ Intent intent = new Intent();
+ intent.setComponent(cn);
+ ServiceConnection conn = new ServiceConnection() {
+ @Override
+ publicvoid onServiceConnected(ComponentName name, IBinder service) {
+ synchronized (mScreenshotLock) {
+ if (mScreenshotConnection != this) {
+ return;
+ }
+ Messenger messenger = new Messenger(service);
+ Message msg = Message.obtain(null, 1);
+ final ServiceConnection myConn = this;
+ Handler h = new Handler(mHandler.getLooper()) {
+ @Override
+ publicvoid handleMessage(Message msg) {
+ synchronized (mScreenshotLock) {
+ if (mScreenshotConnection == myConn) {
+ mContext.unbindService(mScreenshotConnection);
+ mScreenshotConnection = null;
+ mHandler.removeCallbacks(mScreenshotTimeout);
+ }
+ }
+ }
+ };
+ msg.replyTo = new Messenger(h);
+ msg.arg1 = 1;
+ msg.arg2 = 0;
+ try {
+ messenger.send(msg);
+ } catch (RemoteException e) {
+ }
+ }
+ }
+ @Override
+ publicvoid onServiceDisconnected(ComponentName name) {}
+ };
+ if (mContext.bindServiceAsUser(
+ intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) {
+ mScreenshotConnection = conn;
+ mHandler.postDelayed(mScreenshotTimeout, 10000);
+ }
+ }
+ }
+}
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index c74d0c5..d1fb830 100644
@@ -152,9 +152,11 @@ import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.PreviewInflater;
import com.android.systemui.statusbar.policy.RotationLockControllerImpl;
import com.android.systemui.statusbar.policy.SecurityControllerImpl;
+import com.android.systemui.statusbar.policy.ScreenShotControllerImpl;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
+import com.android.systemui.statusbar.policy.ScreenShotController;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout.OnChildLocationsChangedListener;
import com.android.systemui.statusbar.stack.StackViewState;
@@ -291,6 +293,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
HotKnotControllerImpl mHotKnotController;
//add AudioProfile in quicksetting
AudioProfileControllerImpl mAudioProfileController;
+ /// M: add screenshot in quicksetting by Lee
+ ScreenShotControllerImpl mScreenShotControllerImpl;
// /@}
int mNaturalBarHeight = -1;
@@ -900,6 +904,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
SIMHelper.setContext(mContext);
// /@}
+ /// M: add screenshot in quicksetting by Lee
+ mScreenShotControllerImpl = new ScreenShotControllerImpl(this);
+ /// M: end by Lee
if (mContext.getResources().getBoolean(R.bool.config_showRotationLock)) {
mRotationLockController = new RotationLockControllerImpl(mContext);
}
@@ -969,6 +976,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mHotKnotController,
/// M: add AudioProfile in quicksetting
mAudioProfileController
+ /// M: add screenshot in quicksetting by Lee
+ ,mScreenShotControllerImpl
);
mQSPanel.setHost(qsh);
mQSPanel.setTiles(qsh.getTiles());
@@ -3749,6 +3758,36 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
return false;
}
+ /// M: add screenshot in quicksetting by Lee
+ private static final int UPDATE_UI = 0x100;
+ Handler mHandlerUI = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ super.handleMessage(msg);
+ switch (msg.what) {
+ case UPDATE_UI:
+ if (mNotificationPanel.isQsExpanded()) {
+ //Log.e("Lee", "handleMessage() 111111");
+ if (mNotificationPanel.isQsDetailShowing()) {
+ mNotificationPanel.closeQsDetail();
+ } else {
+ mNotificationPanel.animateCloseQs();
+ }
+ }
+ if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) {
+ //Log.e("Lee", "handleMessage() 222222");
+ animateCollapsePanels();
+ }
+ break;
+ }
+ }
+ };
+ public void collapsePanels() {
+ //Log.e("Lee", "collapsePanels()");
+ mHandlerUI.obtainMessage(UPDATE_UI).sendToTarget();
+ }
+ /// M: end by Lee
+
public boolean onSpacePressed() {
if (mScreenOn != null && mScreenOn
&& (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/ScreenShotController.java
new file mode 100644
index 0000000..c108ed4
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed toin 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.
+ */
+package com.android.systemui.statusbar.policy;
+
+publicinterface ScreenShotController {
+
+ void onCollapsePanels();
+
+}
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/ScreenShotControllerImpl.java
new file mode 100644
index 0000000..fd8c861
@@ -0,0 +1,53 @@
+/*
+* Copyright (C) 2014 MediaTek Inc.
+* Modification based on code covered by the mentioned copyright
+* and/or permission notice(s).
+*/
+/*
+ * Copyright (C) 2014 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
+ *
+ * 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
+ * limitations under the License.
+ */
+package com.android.systemui.statusbar.policy;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.android.systemui.statusbar.BaseStatusBar;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
+
+publicclassScreenShotControllerImplimplementsScreenShotController {
+
+ privatestaticfinal String TAG = "ScreenShotController";
+ privatestaticfinalboolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+ private PhoneStatusBar phoneStatusBar;
+
+ publicScreenShotControllerImpl(BaseStatusBar statusBar) {
+ //Log.v("Lee", "ScreenShotControllerImpl()");
+ if (statusBar instanceof PhoneStatusBar) {
+ phoneStatusBar = (PhoneStatusBar) statusBar;
+ } else {
+ Log.e("Lee", "error in ScreenShotControllerImpl()");
+ }
+
+ }
+
+ @Override
+ publicvoidonCollapsePanels() {
+ //Log.e("Lee", "onCollapsePanels()");
+ if (phoneStatusBar != null) {
+ phoneStatusBar.collapsePanels();
+ }
+ }
+
+}