Skip to content

Commit 40e86a5

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "New "Start dreams" launcher shortcut." into jb-mr1-dev
2 parents 378d131 + 32f6fd5 commit 40e86a5

File tree

6 files changed

+78
-3
lines changed

6 files changed

+78
-3
lines changed

packages/SystemUI/AndroidManifest.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,18 @@
193193
<category android:name="android.intent.category.DREAM" />
194194
</intent-filter>
195195
</service>
196+
197+
<activity android:name=".Somnambulator"
198+
android:label="@string/start_dreams"
199+
android:icon="@mipmap/ic_dreams"
200+
android:theme="@android:style/Theme.Wallpaper.NoTitleBar"
201+
android:exported="true"
202+
android:excludeFromRecents="true"
203+
>
204+
<intent-filter>
205+
<action android:name="android.intent.action.CREATE_SHORTCUT" />
206+
<category android:name="android.intent.category.DEFAULT" />
207+
</intent-filter>
208+
</activity>
196209
</application>
197210
</manifest>
3.49 KB
Loading
2.31 KB
Loading
4.88 KB
Loading

packages/SystemUI/res/values/strings.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@
372372
<!-- Content description of the clear button in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
373373
<string name="accessibility_clear_all">Clear all notifications.</string>
374374

375-
<!-- Description of the desk dock action that invokes the Android Dreams screen saver feature -->
376-
<string name="dreams_dock_launcher">Activate screen saver</string>
377-
378375
<!-- Title shown in notification popup for inspecting the responsible
379376
application -->
380377
<string name="status_bar_notification_inspect_item_title">App info</string>
@@ -400,4 +397,8 @@
400397

401398
<!-- Name of the Jelly Bean platlogo screensaver -->
402399
<string name="jelly_bean_dream_name">BeanFlinger</string>
400+
401+
<!-- Name of the launcher shortcut icon that allows dreams to be started immediately [CHAR LIMIT=20] -->
402+
<string name="start_dreams">Start dreams</string>
403+
403404
</resources>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*);
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.systemui;
18+
19+
import android.app.Activity;
20+
import android.content.Intent;
21+
import android.os.RemoteException;
22+
import android.os.ServiceManager;
23+
import android.service.dreams.IDreamManager;
24+
import android.util.Slog;
25+
26+
public class Somnambulator extends Activity {
27+
28+
public Somnambulator() {
29+
}
30+
31+
@Override
32+
public void onStart() {
33+
super.onStart();
34+
final Intent launchIntent = getIntent();
35+
final String action = launchIntent.getAction();
36+
if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
37+
Intent shortcutIntent = new Intent(this, Somnambulator.class);
38+
shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
39+
| Intent.FLAG_ACTIVITY_NEW_TASK);
40+
Intent resultIntent = new Intent();
41+
resultIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
42+
Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_dreams));
43+
resultIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
44+
resultIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.start_dreams));
45+
setResult(RESULT_OK, resultIntent);
46+
} else {
47+
IDreamManager somnambulist = IDreamManager.Stub.asInterface(
48+
ServiceManager.checkService("dreams"));
49+
if (somnambulist != null) {
50+
try {
51+
Slog.v("Somnambulator", "Dreaming by user request.");
52+
somnambulist.dream();
53+
} catch (RemoteException e) {
54+
// fine, stay asleep then
55+
}
56+
}
57+
}
58+
finish();
59+
}
60+
61+
}

0 commit comments

Comments
 (0)