Merge "Fix issue #2560791: Expose API to go in to car mode." into froyo

This commit is contained in:
Dianne Hackborn
2010-03-31 23:03:26 -07:00
committed by Android (Google) Code Review
4 changed files with 30 additions and 14 deletions

View File

@@ -25351,6 +25351,19 @@
<parameter name="flags" type="int"> <parameter name="flags" type="int">
</parameter> </parameter>
</method> </method>
<method name="enableCarMode"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="flags" type="int">
</parameter>
</method>
<method name="getCurrentModeType" <method name="getCurrentModeType"
return="int" return="int"
abstract="false" abstract="false"

View File

@@ -124,6 +124,22 @@ public class UiModeManager {
*/ */
public static final int DISABLE_CAR_MODE_GO_HOME = 0x0001; public static final int DISABLE_CAR_MODE_GO_HOME = 0x0001;
/**
* Force device into car mode, like it had been placed in the car dock.
* This will cause the device to switch to the car home UI as part of
* the mode switch.
* @param flags Must be 0.
*/
public void enableCarMode(int flags) {
if (mService != null) {
try {
mService.enableCarMode();
} catch (RemoteException e) {
Log.e(TAG, "disableCarMode: RemoteException", e);
}
}
}
/** /**
* Turn off special mode if currently in car mode. * Turn off special mode if currently in car mode.
* @param flags May be 0 or {@link #DISABLE_CAR_MODE_GO_HOME}. * @param flags May be 0 or {@link #DISABLE_CAR_MODE_GO_HOME}.

View File

@@ -562,14 +562,6 @@
android:label="@string/permlab_changeConfiguration" android:label="@string/permlab_changeConfiguration"
android:description="@string/permdesc_changeConfiguration" /> android:description="@string/permdesc_changeConfiguration" />
<!-- Allows an application to enable the car mode.
@hide -->
<permission android:name="android.permission.ENABLE_CAR_MODE"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signature"
android:label="@string/permlab_enableCarMode"
android:description="@string/permdesc_enableCarMode" />
<!-- @deprecated The {@link android.app.ActivityManager#restartPackage} <!-- @deprecated The {@link android.app.ActivityManager#restartPackage}
API is no longer supported. --> API is no longer supported. -->
<permission android:name="android.permission.RESTART_PACKAGES" <permission android:name="android.permission.RESTART_PACKAGES"

View File

@@ -19,14 +19,12 @@ package com.android.server;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.IActivityManager;
import android.app.IUiModeManager; import android.app.IUiModeManager;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.app.UiModeManager; import android.app.UiModeManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -310,9 +308,6 @@ class UiModeManagerService extends IUiModeManager.Stub {
} }
public void enableCarMode() { public void enableCarMode() {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.ENABLE_CAR_MODE,
"Need ENABLE_CAR_MODE permission");
synchronized (mLock) { synchronized (mLock) {
setCarModeLocked(true); setCarModeLocked(true);
if (mSystemReady) { if (mSystemReady) {
@@ -394,7 +389,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
} else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) { } else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) {
uiMode = Configuration.UI_MODE_TYPE_DESK; uiMode = Configuration.UI_MODE_TYPE_DESK;
} }
if (uiMode != 0) { if (mCarModeEnabled) {
if (mNightMode == UiModeManager.MODE_NIGHT_AUTO) { if (mNightMode == UiModeManager.MODE_NIGHT_AUTO) {
updateTwilightLocked(); updateTwilightLocked();
uiMode |= mComputedNightMode ? Configuration.UI_MODE_NIGHT_YES uiMode |= mComputedNightMode ? Configuration.UI_MODE_NIGHT_YES