Skip to content

Commit 221733a

Browse files
committed
Offer the user an option to launch Dreams when docked.
SystemUI now registers for DESK_DOCK launches, so users with other dock apps installed can still opt to use those in this new regime. (Part of migrating users away from DeskClock as the dock app.) Bug: 3155234 Change-Id: I0da0f04f8a0a89e7d237c092f16f4f27eb88c92c
1 parent 69a1da4 commit 221733a

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

packages/SystemUI/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
</intent-filter>
4747
</receiver>
4848

49+
<!-- handle dock insertion, launch screensaver instead -->
50+
<activity android:name=".DreamsDockLauncher"
51+
android:label="@string/dreams_dock_launcher">
52+
<intent-filter>
53+
<action android:name="android.intent.action.MAIN" />
54+
<category android:name="android.intent.category.DEFAULT" />
55+
<category android:name="android.intent.category.DESK_DOCK" />
56+
</intent-filter>
57+
</activity>
58+
4959
<activity android:name=".usb.UsbStorageActivity"
5060
android:excludeFromRecents="true">
5161
</activity>

packages/SystemUI/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,7 @@
351351

352352
<!-- Content description of the clear button in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
353353
<string name="accessibility_clear_all">Clear all notifications.</string>
354+
355+
<!-- Description of the desk dock action that invokes the Android Dreams screen saver feature -->
356+
<string name="dreams_dock_launcher">Activate screen saver</string>
354357
</resources>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.android.systemui;
2+
3+
import android.app.Activity;
4+
import android.content.BroadcastReceiver;
5+
import android.content.ComponentName;
6+
import android.content.ContentResolver;
7+
import android.content.Context;
8+
import android.content.Intent;
9+
import android.os.Bundle;
10+
import android.provider.Settings;
11+
import android.util.Slog;
12+
13+
public class DreamsDockLauncher extends Activity {
14+
private static final String TAG = "DreamsDockLauncher";
15+
@Override
16+
protected void onCreate (Bundle icicle) {
17+
super.onCreate(icicle);
18+
try {
19+
String component = Settings.Secure.getString(
20+
getContentResolver(), Settings.Secure.DREAM_COMPONENT);
21+
if (component != null) {
22+
ComponentName cn = ComponentName.unflattenFromString(component);
23+
Intent zzz = new Intent(Intent.ACTION_MAIN)
24+
.setComponent(cn)
25+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
26+
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
27+
| Intent.FLAG_ACTIVITY_NO_USER_ACTION
28+
);
29+
startActivity(zzz);
30+
} else {
31+
Slog.e(TAG, "Couldn't start screen saver: none selected");
32+
}
33+
} catch (android.content.ActivityNotFoundException exc) {
34+
// no screensaver? give up
35+
Slog.e(TAG, "Couldn't start screen saver: none installed");
36+
}
37+
finish();
38+
}
39+
}

0 commit comments

Comments
 (0)