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
This commit is contained in:
@@ -46,6 +46,16 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- handle dock insertion, launch screensaver instead -->
|
||||
<activity android:name=".DreamsDockLauncher"
|
||||
android:label="@string/dreams_dock_launcher">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.DESK_DOCK" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".usb.UsbStorageActivity"
|
||||
android:excludeFromRecents="true">
|
||||
</activity>
|
||||
|
||||
@@ -351,4 +351,7 @@
|
||||
|
||||
<!-- Content description of the clear button in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_clear_all">Clear all notifications.</string>
|
||||
|
||||
<!-- Description of the desk dock action that invokes the Android Dreams screen saver feature -->
|
||||
<string name="dreams_dock_launcher">Activate screen saver</string>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.android.systemui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Slog;
|
||||
|
||||
public class DreamsDockLauncher extends Activity {
|
||||
private static final String TAG = "DreamsDockLauncher";
|
||||
@Override
|
||||
protected void onCreate (Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
try {
|
||||
String component = Settings.Secure.getString(
|
||||
getContentResolver(), Settings.Secure.DREAM_COMPONENT);
|
||||
if (component != null) {
|
||||
ComponentName cn = ComponentName.unflattenFromString(component);
|
||||
Intent zzz = new Intent(Intent.ACTION_MAIN)
|
||||
.setComponent(cn)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||
| Intent.FLAG_ACTIVITY_NO_USER_ACTION
|
||||
);
|
||||
startActivity(zzz);
|
||||
} else {
|
||||
Slog.e(TAG, "Couldn't start screen saver: none selected");
|
||||
}
|
||||
} catch (android.content.ActivityNotFoundException exc) {
|
||||
// no screensaver? give up
|
||||
Slog.e(TAG, "Couldn't start screen saver: none installed");
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user