Merge "SystemUI demo mode." into klp-dev

This commit is contained in:
John Spurlock
2013-09-05 02:19:18 +00:00
committed by Android (Google) Code Review
13 changed files with 425 additions and 71 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -29,11 +29,12 @@ import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.BatteryManager;
import android.os.Bundle;
import android.provider.Settings;
import android.util.AttributeSet;
import android.view.View;
public class BatteryMeterView extends View {
public class BatteryMeterView extends View implements DemoMode {
public static final String TAG = BatteryMeterView.class.getSimpleName();
public static final String ACTION_LEVEL_TEST = "com.android.systemui.BATTERY_LEVEL_TEST";
@@ -204,7 +205,6 @@ public class BatteryMeterView extends View {
}
private int getColorForLevel(int percent) {
if (mTracker.plugged) return mChargeColor;
int thresh, color = 0;
for (int i=0; i<mColors.length; i+=2) {
thresh = mColors[i];
@@ -216,7 +216,8 @@ public class BatteryMeterView extends View {
@Override
public void draw(Canvas c) {
final int level = mTracker.level;
BatteryTracker tracker = mDemoMode ? mDemoTracker : mTracker;
final int level = tracker.level;
float drawFrac = (float) level / 100f;
final int pt = getPaddingTop();
final int pl = getPaddingLeft();
@@ -245,8 +246,8 @@ public class BatteryMeterView extends View {
c.drawRect(frame, mFramePaint);
// fill 'er up
final int pct = mTracker.level;
final int color = getColorForLevel(pct);
final int pct = tracker.level;
final int color = tracker.plugged ? mChargeColor : getColorForLevel(pct);
mBatteryPaint.setColor(color);
if (level >= FULL) {
@@ -270,16 +271,16 @@ public class BatteryMeterView extends View {
final float x = mWidth * 0.5f;
final float y = (mHeight + mWarningTextHeight) * 0.48f;
c.drawText(mWarningString, x, y, mWarningTextPaint);
} else if (mTracker.plugged) {
} else if (tracker.plugged) {
final Rect r = new Rect(
(int)frame.left + width / 4, (int)frame.top + height / 5,
(int)frame.right - width / 4, (int)frame.bottom - height / 6);
mLightning.setBounds(r);
mLightning.draw(c);
} else if (mShowPercent && !(mTracker.level == 100 && !SHOW_100_PERCENT)) {
} else if (mShowPercent && !(tracker.level == 100 && !SHOW_100_PERCENT)) {
mTextPaint.setTextSize(height *
(SINGLE_DIGIT_PERCENT ? 0.75f
: (mTracker.level == 100 ? 0.38f : 0.5f)));
: (tracker.level == 100 ? 0.38f : 0.5f)));
mTextHeight = -mTextPaint.getFontMetrics().ascent;
final String str = String.valueOf(SINGLE_DIGIT_PERCENT ? (pct/10) : pct);
@@ -302,4 +303,29 @@ public class BatteryMeterView extends View {
// c.drawRect(1, 1, mWidth, mHeight, pt);
}
}
private boolean mDemoMode;
private BatteryTracker mDemoTracker = new BatteryTracker();
@Override
public void dispatchDemoCommand(String command, Bundle args) {
if (!mDemoMode && command.equals(COMMAND_ENTER)) {
mDemoMode = true;
mDemoTracker.level = mTracker.level;
mDemoTracker.plugged = mTracker.plugged;
} else if (mDemoMode && command.equals(COMMAND_EXIT)) {
mDemoMode = false;
postInvalidate();
} else if (mDemoMode && command.equals(COMMAND_BATTERY)) {
String level = args.getString("level");
String plugged = args.getString("plugged");
if (level != null) {
mDemoTracker.level = Math.min(Math.max(Integer.parseInt(level), 0), 100);
}
if (plugged != null) {
mDemoTracker.plugged = Boolean.parseBoolean(plugged);
}
postInvalidate();
}
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2013 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;
import android.os.Bundle;
public interface DemoMode {
void dispatchDemoCommand(String command, Bundle args);
public static final String ACTION_DEMO = "com.android.systemui.demo";
public static final String COMMAND_ENTER = "enter";
public static final String COMMAND_EXIT = "exit";
public static final String COMMAND_CLOCK = "clock";
public static final String COMMAND_BATTERY = "battery";
public static final String COMMAND_NETWORK = "network";
public static final String COMMAND_BARS = "bars";
public static final String COMMAND_STATUS = "status";
}

View File

@@ -0,0 +1,151 @@
/*
* Copyright (C) 2013 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.phone;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.systemui.DemoMode;
import com.android.systemui.R;
import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.policy.LocationController;
public class DemoStatusIcons extends LinearLayout implements DemoMode {
private final LinearLayout mStatusIcons;
private final int mIconSize;
private boolean mDemoMode;
public DemoStatusIcons(LinearLayout statusIcons, int iconSize) {
super(statusIcons.getContext());
mStatusIcons = statusIcons;
mIconSize = iconSize;
setLayoutParams(mStatusIcons.getLayoutParams());
setOrientation(mStatusIcons.getOrientation());
setGravity(Gravity.CENTER_VERTICAL); // no LL.getGravity()
ViewGroup p = (ViewGroup) mStatusIcons.getParent();
p.addView(this, p.indexOfChild(mStatusIcons));
}
@Override
public void dispatchDemoCommand(String command, Bundle args) {
if (!mDemoMode && command.equals(COMMAND_ENTER)) {
mDemoMode = true;
mStatusIcons.setVisibility(View.GONE);
setVisibility(View.VISIBLE);
} else if (mDemoMode && command.equals(COMMAND_EXIT)) {
mDemoMode = false;
mStatusIcons.setVisibility(View.VISIBLE);
setVisibility(View.GONE);
} else if (mDemoMode && command.equals(COMMAND_STATUS)) {
String volume = args.getString("volume");
if (volume != null) {
int iconId = volume.equals("silent") ? R.drawable.stat_sys_ringer_silent
: volume.equals("vibrate") ? R.drawable.stat_sys_ringer_vibrate
: 0;
updateSlot("volume", null, iconId);
}
String bt = args.getString("bluetooth");
if (bt != null) {
int iconId = bt.equals("disconnected") ? R.drawable.stat_sys_data_bluetooth
: bt.equals("connected") ? R.drawable.stat_sys_data_bluetooth_connected
: 0;
updateSlot("bluetooth", null, iconId);
}
String location = args.getString("location");
if (location != null) {
int iconId = location.equals("show") ? LocationController.LOCATION_STATUS_ICON_ID
: 0;
updateSlot(LocationController.LOCATION_STATUS_ICON_PLACEHOLDER, null, iconId);
}
String alarm = args.getString("alarm");
if (alarm != null) {
int iconId = alarm.equals("show") ? R.drawable.stat_sys_alarm
: 0;
updateSlot("alarm_clock", null, iconId);
}
String sync = args.getString("sync");
if (sync != null) {
int iconId = sync.equals("show") ? R.drawable.stat_sys_sync
: 0;
updateSlot("sync_active", null, iconId);
}
String tty = args.getString("tty");
if (tty != null) {
int iconId = tty.equals("show") ? R.drawable.stat_sys_tty_mode
: 0;
updateSlot("tty", null, iconId);
}
String eri = args.getString("eri");
if (eri != null) {
int iconId = eri.equals("show") ? R.drawable.stat_sys_roaming_cdma_0
: 0;
updateSlot("cdma_eri", null, iconId);
}
String mute = args.getString("mute");
if (mute != null) {
int iconId = mute.equals("show") ? android.R.drawable.stat_notify_call_mute
: 0;
updateSlot("mute", null, iconId);
}
String speakerphone = args.getString("speakerphone");
if (speakerphone != null) {
int iconId = speakerphone.equals("show") ? android.R.drawable.stat_sys_speakerphone
: 0;
updateSlot("speakerphone", null, iconId);
}
}
}
private void updateSlot(String slot, String iconPkg, int iconId) {
if (!mDemoMode) return;
int removeIndex = -1;
for (int i = 0; i < getChildCount(); i++) {
StatusBarIconView v = (StatusBarIconView) getChildAt(i);
if (slot.equals(v.getTag())) {
if (iconId == 0) {
removeIndex = i;
break;
} else {
StatusBarIcon icon = v.getStatusBarIcon();
icon.iconPackage = iconPkg;
icon.iconId = iconId;
v.set(icon);
v.updateDrawable();
return;
}
}
}
if (iconId == 0) {
if (removeIndex != -1) {
removeViewAt(removeIndex);
return;
}
}
StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.CURRENT, iconId, 0, 0, "Demo");
StatusBarIconView v = new StatusBarIconView(mContext, null);
v.setTag(slot);
v.set(icon);
addView(v, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize));
}
}

View File

@@ -47,6 +47,7 @@ import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.InputMethodService;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
@@ -79,6 +80,7 @@ import android.widget.ScrollView;
import android.widget.TextView;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.systemui.DemoMode;
import com.android.systemui.EventLogTags;
import com.android.systemui.R;
import com.android.systemui.statusbar.BaseStatusBar;
@@ -102,7 +104,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
public class PhoneStatusBar extends BaseStatusBar {
public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
static final String TAG = "PhoneStatusBar";
public static final boolean DEBUG = BaseStatusBar.DEBUG;
public static final boolean SPEW = false;
@@ -363,7 +365,6 @@ public class PhoneStatusBar extends BaseStatusBar {
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
mStatusBarView.setBar(this);
PanelHolder holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.panel_holder);
mStatusBarView.setPanelHolder(holder);
@@ -605,18 +606,13 @@ public class PhoneStatusBar extends BaseStatusBar {
}
}
// final ImageView wimaxRSSI =
// (ImageView)sb.findViewById(R.id.wimax_signal);
// if (wimaxRSSI != null) {
// mNetworkController.addWimaxIconView(wimaxRSSI);
// }
// receive broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(ACTION_DEMO);
context.registerReceiver(mBroadcastReceiver, filter);
// listen for USER_SETUP_COMPLETE setting (per-user)
@@ -1874,6 +1870,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
private void checkBarModes() {
if (mDemoMode) return;
checkBarMode(mStatusBarMode, mStatusBarWindowState, mStatusBarView.getBarTransitions());
if (mNavigationBarView != null) {
checkBarMode(mNavigationBarMode,
@@ -2447,6 +2444,19 @@ public class PhoneStatusBar extends BaseStatusBar {
repositionNavigationBar();
notifyNavigationBarScreenOn(true);
}
else if (ACTION_DEMO.equals(action)) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
String command = bundle.getString("command", "").trim().toLowerCase();
if (command.length() > 0) {
try {
dispatchDemoCommand(command, bundle);
} catch (Throwable t) {
Log.w(TAG, "Error running demo command, intent=" + intent, t);
}
}
}
}
}
};
@@ -2676,4 +2686,66 @@ public class PhoneStatusBar extends BaseStatusBar {
}
mContext.unregisterReceiver(mBroadcastReceiver);
}
private boolean mDemoModeAllowed;
private boolean mDemoMode;
private DemoStatusIcons mDemoStatusIcons;
@Override
public void dispatchDemoCommand(String command, Bundle args) {
if (!mDemoModeAllowed) {
mDemoModeAllowed = Settings.Global.getInt(mContext.getContentResolver(),
"sysui_demo_allowed", 0) != 0;
}
if (!mDemoModeAllowed) return;
if (command.equals(COMMAND_ENTER)) {
mDemoMode = true;
} else if (command.equals(COMMAND_EXIT)) {
mDemoMode = false;
checkBarModes();
} else if (!mDemoMode) {
// automatically enter demo mode on first demo command
dispatchDemoCommand(COMMAND_ENTER, new Bundle());
}
boolean modeChange = command.equals(COMMAND_ENTER) || command.equals(COMMAND_EXIT);
if (modeChange || command.equals(COMMAND_CLOCK)) {
dispatchDemoCommandToView(command, args, R.id.clock);
}
if (modeChange || command.equals(COMMAND_BATTERY)) {
dispatchDemoCommandToView(command, args, R.id.battery);
}
if (modeChange || command.equals(COMMAND_STATUS)) {
if (mDemoStatusIcons == null) {
mDemoStatusIcons = new DemoStatusIcons(mStatusIcons, mIconSize);
}
mDemoStatusIcons.dispatchDemoCommand(command, args);
}
if (mNetworkController != null && (modeChange || command.equals(COMMAND_NETWORK))) {
mNetworkController.dispatchDemoCommand(command, args);
}
if (command.equals(COMMAND_BARS)) {
String mode = args.getString("mode");
int barMode = "opaque".equals(mode) ? MODE_OPAQUE :
"transparent".equals(mode) ? MODE_TRANSPARENT :
"semi-transparent".equals(mode) ? MODE_SEMI_TRANSPARENT :
-1;
if (barMode != -1) {
boolean animate = true;
if (mStatusBarView != null) {
mStatusBarView.getBarTransitions().transitionTo(barMode, animate);
}
if (mNavigationBarView != null) {
mNavigationBarView.getBarTransitions().transitionTo(barMode, animate);
}
}
}
}
private void dispatchDemoCommandToView(String command, Bundle args, int id) {
if (mStatusBarView == null) return;
View v = mStatusBarView.findViewById(id);
if (v instanceof DemoMode) {
((DemoMode)v).dispatchDemoCommand(command, args);
}
}
}

View File

@@ -157,9 +157,8 @@ public class PhoneStatusBarPolicy {
// Sync state
mService.setIcon("sync_active", R.drawable.stat_sys_sync, 0, null);
mService.setIcon("sync_failing", R.drawable.stat_sys_sync_error, 0, null);
mService.setIconVisibility("sync_active", false);
mService.setIconVisibility("sync_failing", false);
// "sync_failing" is obsolete: b/1297963
// volume
mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0, null);
@@ -175,10 +174,7 @@ public class PhoneStatusBarPolicy {
private final void updateSyncState(Intent intent) {
if (!SHOW_SYNC_ICON) return;
boolean isActive = intent.getBooleanExtra("active", false);
boolean isFailing = intent.getBooleanExtra("failing", false);
mService.setIconVisibility("sync_active", isActive);
// Don't display sync failing icon: BUG 1297963 Set sync error timeout to "never"
//mService.setIconVisibility("sync_failing", isFailing && !isActive);
}
private final void updateSimState(Intent intent) {

View File

@@ -23,10 +23,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View;
import android.widget.ImageView;
import com.android.systemui.R;
import java.util.ArrayList;
import java.util.HashSet;
@@ -35,11 +31,6 @@ import java.util.Set;
public class BluetoothController extends BroadcastReceiver {
private static final String TAG = "StatusBar.BluetoothController";
private Context mContext;
private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>();
private int mIconId = R.drawable.stat_sys_data_bluetooth;
private int mContentDescriptionId = 0;
private boolean mEnabled = false;
private Set<BluetoothDevice> mBondedDevices = new HashSet<BluetoothDevice>();
@@ -48,7 +39,6 @@ public class BluetoothController extends BroadcastReceiver {
new ArrayList<BluetoothStateChangeCallback>();
public BluetoothController(Context context) {
mContext = context;
IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
@@ -59,16 +49,11 @@ public class BluetoothController extends BroadcastReceiver {
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
handleAdapterStateChange(adapter.getState());
handleConnectionStateChange(adapter.getConnectionState());
}
refreshViews();
fireCallbacks();
updateBondedBluetoothDevices();
}
public void addIconView(ImageView v) {
mIconViews.add(v);
}
public void addStateChangedCallback(BluetoothStateChangeCallback cb) {
mChangeCallbacks.add(cb);
}
@@ -84,14 +69,8 @@ public class BluetoothController extends BroadcastReceiver {
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
handleAdapterStateChange(
intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR));
} else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
handleConnectionStateChange(
intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,
BluetoothAdapter.STATE_DISCONNECTED));
} else if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
// Fall through and update bonded devices and refresh view
}
refreshViews();
fireCallbacks();
updateBondedBluetoothDevices();
}
@@ -111,31 +90,11 @@ public class BluetoothController extends BroadcastReceiver {
}
}
public void handleAdapterStateChange(int adapterState) {
private void handleAdapterStateChange(int adapterState) {
mEnabled = (adapterState == BluetoothAdapter.STATE_ON);
}
public void handleConnectionStateChange(int connectionState) {
final boolean connected = (connectionState == BluetoothAdapter.STATE_CONNECTED);
if (connected) {
mIconId = R.drawable.stat_sys_data_bluetooth_connected;
mContentDescriptionId = R.string.accessibility_bluetooth_connected;
} else {
mIconId = R.drawable.stat_sys_data_bluetooth;
mContentDescriptionId = R.string.accessibility_bluetooth_disconnected;
}
}
public void refreshViews() {
int N = mIconViews.size();
for (int i=0; i<N; i++) {
ImageView v = mIconViews.get(i);
v.setImageResource(mIconId);
v.setVisibility(mEnabled ? View.VISIBLE : View.GONE);
v.setContentDescription((mContentDescriptionId == 0)
? null
: mContext.getString(mContentDescriptionId));
}
private void fireCallbacks() {
for (BluetoothStateChangeCallback cb : mChangeCallbacks) {
cb.onBluetoothStateChange(mEnabled);
}

View File

@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateFormat;
@@ -28,6 +29,8 @@ import android.text.style.RelativeSizeSpan;
import android.util.AttributeSet;
import android.widget.TextView;
import com.android.systemui.DemoMode;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -38,7 +41,7 @@ import libcore.icu.LocaleData;
/**
* Digital clock for the status bar.
*/
public class Clock extends TextView {
public class Clock extends TextView implements DemoMode {
private boolean mAttached;
private Calendar mCalendar;
private String mClockFormatString;
@@ -121,6 +124,7 @@ public class Clock extends TextView {
};
final void updateClock() {
if (mDemoMode) return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(getSmallTime());
}
@@ -196,5 +200,29 @@ public class Clock extends TextView {
return result;
}
private boolean mDemoMode;
@Override
public void dispatchDemoCommand(String command, Bundle args) {
if (!mDemoMode && command.equals(COMMAND_ENTER)) {
mDemoMode = true;
} else if (mDemoMode && command.equals(COMMAND_EXIT)) {
mDemoMode = false;
updateClock();
} else if (mDemoMode && command.equals(COMMAND_CLOCK)) {
String millis = args.getString("millis");
String hhmm = args.getString("hhmm");
if (millis != null) {
mCalendar.setTimeInMillis(Long.parseLong(millis));
} else if (hhmm != null && hhmm.length() == 4) {
int hh = Integer.parseInt(hhmm.substring(0, 2));
int mm = Integer.parseInt(hhmm.substring(2));
mCalendar.set(Calendar.HOUR, hh);
mCalendar.set(Calendar.MINUTE, mm);
}
setText(getSmallTime());
}
}
}

View File

@@ -42,8 +42,8 @@ import java.util.List;
public class LocationController extends BroadcastReceiver {
// The name of the placeholder corresponding to the location request status icon.
// This string corresponds to config_statusBarIcons in core/res/res/values/config.xml.
private static final String LOCATION_STATUS_ICON_PLACEHOLDER = "location";
private static final int LOCATION_STATUS_ICON_ID
public static final String LOCATION_STATUS_ICON_PLACEHOLDER = "location";
public static final int LOCATION_STATUS_ICON_ID
= R.drawable.stat_sys_device_access_location_found;
private static final int[] mHighPowerRequestAppOpArray

View File

@@ -27,6 +27,7 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wimax.WimaxManagerConstants;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
@@ -43,6 +44,7 @@ import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.internal.util.AsyncChannel;
import com.android.systemui.DemoMode;
import com.android.systemui.R;
import java.io.FileDescriptor;
@@ -51,12 +53,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class NetworkController extends BroadcastReceiver {
public class NetworkController extends BroadcastReceiver implements DemoMode {
// debug
static final String TAG = "StatusBar.NetworkController";
static final boolean DEBUG = false;
static final boolean CHATTY = false; // additional diagnostics, but not logspew
private static final int FLIGHT_MODE_ICON = R.drawable.stat_sys_signal_flightmode;
// telephony
boolean mHspaDataDistinguishable;
final TelephonyManager mPhone;
@@ -277,6 +281,7 @@ public class NetworkController extends BroadcastReceiver {
}
public void refreshSignalCluster(SignalCluster cluster) {
if (mDemoMode) return;
cluster.setWifiIndicators(
// only show wifi in the cluster if connected or if wifi-only
mWifiEnabled && (mWifiConnected || !mHasMobileDataFeature),
@@ -1051,7 +1056,7 @@ public class NetworkController extends BroadcastReceiver {
// look again; your radios are now airplanes
mContentDescriptionPhoneSignal = mContext.getString(
R.string.accessibility_airplane_mode);
mAirplaneIconId = R.drawable.stat_sys_signal_flightmode;
mAirplaneIconId = FLIGHT_MODE_ICON;
mPhoneSignalIconId = mDataSignalIconId = mDataTypeIconId = mQSDataTypeIconId = 0;
mQSPhoneSignalIconId = 0;
@@ -1359,4 +1364,87 @@ public class NetworkController extends BroadcastReceiver {
}
}
private boolean mDemoMode;
private int mDemoInetCondition;
private int mDemoWifiLevel;
private int mDemoDataTypeIconId;
private int mDemoMobileLevel;
@Override
public void dispatchDemoCommand(String command, Bundle args) {
if (!mDemoMode && command.equals(COMMAND_ENTER)) {
mDemoMode = true;
mDemoWifiLevel = mWifiLevel;
mDemoInetCondition = mInetCondition;
mDemoDataTypeIconId = mDataTypeIconId;
mDemoMobileLevel = mLastSignalLevel;
} else if (mDemoMode && command.equals(COMMAND_EXIT)) {
mDemoMode = false;
for (SignalCluster cluster : mSignalClusters) {
refreshSignalCluster(cluster);
}
} else if (mDemoMode && command.equals(COMMAND_NETWORK)) {
String airplane = args.getString("airplane");
if (airplane != null) {
boolean show = airplane.equals("show");
for (SignalCluster cluster : mSignalClusters) {
cluster.setIsAirplaneMode(show, FLIGHT_MODE_ICON);
}
}
String fully = args.getString("fully");
if (fully != null) {
mDemoInetCondition = Boolean.parseBoolean(fully) ? 1 : 0;
}
String wifi = args.getString("wifi");
if (wifi != null) {
boolean show = wifi.equals("show");
String level = args.getString("level");
if (level != null) {
mDemoWifiLevel = level.equals("null") ? -1
: Math.min(Integer.parseInt(level), WifiIcons.WIFI_LEVEL_COUNT - 1);
}
int iconId = mDemoWifiLevel < 0 ? R.drawable.stat_sys_wifi_signal_null
: WifiIcons.WIFI_SIGNAL_STRENGTH[mDemoInetCondition][mDemoWifiLevel];
for (SignalCluster cluster : mSignalClusters) {
cluster.setWifiIndicators(
show,
iconId,
"Demo");
}
}
String mobile = args.getString("mobile");
if (mobile != null) {
boolean show = mobile.equals("show");
String datatype = args.getString("datatype");
if (datatype != null) {
mDemoDataTypeIconId =
datatype.equals("1x") ? R.drawable.stat_sys_data_connected_1x :
datatype.equals("3g") ? R.drawable.stat_sys_data_connected_3g :
datatype.equals("4g") ? R.drawable.stat_sys_data_connected_4g :
datatype.equals("e") ? R.drawable.stat_sys_data_connected_e :
datatype.equals("g") ? R.drawable.stat_sys_data_connected_g :
datatype.equals("h") ? R.drawable.stat_sys_data_connected_h :
datatype.equals("lte") ? R.drawable.stat_sys_data_connected_lte :
datatype.equals("roam") ? R.drawable.stat_sys_data_connected_roam :
0;
}
int[][] icons = TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH;
String level = args.getString("level");
if (level != null) {
mDemoMobileLevel = level.equals("null") ? -1
: Math.min(Integer.parseInt(level), icons[0].length - 1);
}
int iconId = mDemoMobileLevel < 0 ? R.drawable.stat_sys_signal_null :
icons[mDemoInetCondition][mDemoMobileLevel];
for (SignalCluster cluster : mSignalClusters) {
cluster.setMobileDataIndicators(
show,
iconId,
mDemoDataTypeIconId,
"Demo",
"Demo");
}
}
}
}
}