Merge "Use AssistUtils.getAssistInfo" into mnc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 358eae9..d792b5c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -956,6 +956,10 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.applications.ManageApplications" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1900,16 +1904,6 @@
</intent-filter>
</receiver>
- <activity android:name="BatteryInfo" android:label="@string/battery_info_label"
- android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
- <category android:name="android.intent.category.VOICE_LAUNCH" />
- </intent-filter>
- </activity>
-
<activity android:name="Display" android:label="@string/display_label"
android:configChanges="fontScale"
android:taskAffinity="com.android.settings"
diff --git a/res/layout/battery_info.xml b/res/layout/battery_info.xml
deleted file mode 100644
index 1016ad1..0000000
--- a/res/layout/battery_info.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/Settings/assets/res/any/layout/battery_info.xml
-**
-** Copyright 2006, 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.
-*/
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/info_layout">
-
- <!-- Battery Status -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_status_label" style="@style/info_label" />
- <TextView android:id="@+id/status" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Battery Status -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_power_label" style="@style/info_label" />
- <TextView android:id="@+id/power" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Battery Level -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_level_label" style="@style/info_label" />
- <TextView android:id="@+id/level" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Battery Scale -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_scale_label" style="@style/info_label" />
- <TextView android:id="@+id/scale" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Battery Health -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_health_label" style="@style/info_label" />
- <TextView android:id="@+id/health" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Battery Voltage -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_voltage_label" style="@style/info_label" />
- <TextView android:id="@+id/voltage" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Battery Temperature -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_temperature_label" style="@style/info_label" />
- <TextView android:id="@+id/temperature" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Battery Technology -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_technology_label" style="@style/info_label" />
- <TextView android:id="@+id/technology" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Uptime -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/battery_info_uptime" style="@style/info_label" />
- <TextView android:id="@+id/uptime" style="@style/info_value" />
- </LinearLayout>
-
-</LinearLayout>
-
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6a61aa0..4bc4129 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -164,35 +164,6 @@
<!-- Title for a notification shown. -->
<string name="sdcard_setting" product="default">SD card</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_status_label">Battery status:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_power_label">Power plug:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_scale_label">Battery scale:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_level_label">Battery level:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_label">Battery health:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_technology_label">Battery technology:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_voltage_label">Battery voltage:</string>
- <!-- Battery Info screen. Units shown after a value. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_voltage_units">mV</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_temperature_label">Battery temperature:</string>
- <!-- Battery Info screen. Units shown after a value. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_temperature_units">\u00B0 C</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_uptime">Time since boot:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_awake_battery">Awake time on battery:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_awake_plugged">Awake time when charging:</string>
- <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_screen_on">Screen ON time:</string>
-
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_status_unknown">Unknown</string>
<!-- [CHAR_LIMIT=20] Battery use screen. Battery status shown in chart label when charging from an unknown source. -->
@@ -210,29 +181,6 @@
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_status_full">Full</string>
- <!-- Battery Info screen. Units shown after a value. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_power_unplugged">Unplugged</string>
- <string name="battery_info_power_ac">AC</string>
- <string name="battery_info_power_usb">USB</string>
- <string name="battery_info_power_wireless">wireless</string>
- <string name="battery_info_power_ac_usb">AC+USB</string>
- <string name="battery_info_power_unknown">Unknown</string>
-
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_unknown">Unknown</string>
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_good">Good</string>
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_overheat">Overheat</string>
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_dead">Dead</string>
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_over_voltage">Over voltage</string>
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_unspecified_failure">Unknown error</string>
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_health_cold">Cold</string>
-
<!-- Used as setting title (for checkbox) on second screen after selecting Bluetooth settings -->
<string name="bluetooth">Bluetooth</string>
<!-- Bluetooth settings screen, summary after selecting Discoverable check box [CHAR LIMIT=50] -->
@@ -572,8 +520,6 @@
<string name="debug_intent_sender_label">Debug intent sender</string>
<!-- The title of the activity to see random device info. -->
<string name="device_info_label">Device info</string>
- <!-- The title of the activity to see battery info. -->
- <string name="battery_info_label">Battery info</string>
<!-- The title of the activity to adjust display settings -->
<string name="display_label">Screen</string>
<!-- The title of the activity to see phone info -->
@@ -3552,8 +3498,6 @@
<string name="testing_phone_info" product="tablet">Tablet information</string>
<!-- In the Testing screen. The item title of the activity that shows a bunch of phone-related information. -->
<string name="testing_phone_info" product="default">Phone information</string>
- <!-- In the Testing screen. The item title of the activity that shows a bunch of battery-related information. -->
- <string name="testing_battery_info">Battery information</string>
<!-- Do not translate. In the Testing screen. The item title of the activity that shows a bunch of SIM-related operations. -->
<string name="testing_sim_toolkit">SIM toolkit</string>
diff --git a/res/xml/testing_settings.xml b/res/xml/testing_settings.xml
index c55cb46..d8d7705 100644
--- a/res/xml/testing_settings.xml
+++ b/res/xml/testing_settings.xml
@@ -23,14 +23,6 @@
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.RadioInfo" />
</PreferenceScreen>
-
- <PreferenceScreen
- android:title="@string/testing_battery_info">
- <intent android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.settings"
- android:targetClass="com.android.settings.BatteryInfo" />
- </PreferenceScreen>
-
<PreferenceScreen
android:title="@string/testing_usage_stats">
diff --git a/src/com/android/settings/BatteryInfo.java b/src/com/android/settings/BatteryInfo.java
deleted file mode 100644
index d35771f..0000000
--- a/src/com/android/settings/BatteryInfo.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2006 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.settings;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.BatteryManager;
-import android.os.BatteryStats;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IPowerManager;
-import android.os.Message;
-import android.os.ServiceManager;
-import android.os.SystemClock;
-import android.text.format.DateUtils;
-import android.widget.TextView;
-
-import com.android.internal.app.IBatteryStats;
-
-public class BatteryInfo extends Activity {
- private TextView mStatus;
- private TextView mPower;
- private TextView mLevel;
- private TextView mScale;
- private TextView mHealth;
- private TextView mVoltage;
- private TextView mTemperature;
- private TextView mTechnology;
- private TextView mUptime;
- private IBatteryStats mBatteryStats;
- private IPowerManager mScreenStats;
-
- private static final int EVENT_TICK = 1;
-
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case EVENT_TICK:
- updateBatteryStats();
- sendEmptyMessageDelayed(EVENT_TICK, 1000);
-
- break;
- }
- }
- };
-
- /**
- * Format a number of tenths-units as a decimal string without using a
- * conversion to float. E.g. 347 -> "34.7", -99 -> "-9.9"
- */
- private final String tenthsToFixedString(int x) {
- int tens = x / 10;
- // use Math.abs to avoid "-9.-9" about -99
- return Integer.toString(tens) + "." + Math.abs(x - 10 * tens);
- }
-
- /**
- *Listens for intent broadcasts
- */
- private IntentFilter mIntentFilter;
-
- private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
- int plugType = intent.getIntExtra("plugged", 0);
-
- mLevel.setText("" + intent.getIntExtra("level", 0));
- mScale.setText("" + intent.getIntExtra("scale", 0));
- mVoltage.setText("" + intent.getIntExtra("voltage", 0) + " "
- + getString(R.string.battery_info_voltage_units));
- mTemperature.setText("" + tenthsToFixedString(intent.getIntExtra("temperature", 0))
- + getString(R.string.battery_info_temperature_units));
- mTechnology.setText("" + intent.getStringExtra("technology"));
-
- mStatus.setText(Utils.getBatteryStatus(getResources(), intent));
-
- switch (plugType) {
- case 0:
- mPower.setText(getString(R.string.battery_info_power_unplugged));
- break;
- case BatteryManager.BATTERY_PLUGGED_AC:
- mPower.setText(getString(R.string.battery_info_power_ac));
- break;
- case BatteryManager.BATTERY_PLUGGED_USB:
- mPower.setText(getString(R.string.battery_info_power_usb));
- break;
- case BatteryManager.BATTERY_PLUGGED_WIRELESS:
- mPower.setText(getString(R.string.battery_info_power_wireless));
- break;
- case (BatteryManager.BATTERY_PLUGGED_AC|BatteryManager.BATTERY_PLUGGED_USB):
- mPower.setText(getString(R.string.battery_info_power_ac_usb));
- break;
- default:
- mPower.setText(getString(R.string.battery_info_power_unknown));
- break;
- }
-
- int health = intent.getIntExtra("health", BatteryManager.BATTERY_HEALTH_UNKNOWN);
- String healthString;
- if (health == BatteryManager.BATTERY_HEALTH_GOOD) {
- healthString = getString(R.string.battery_info_health_good);
- } else if (health == BatteryManager.BATTERY_HEALTH_OVERHEAT) {
- healthString = getString(R.string.battery_info_health_overheat);
- } else if (health == BatteryManager.BATTERY_HEALTH_DEAD) {
- healthString = getString(R.string.battery_info_health_dead);
- } else if (health == BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE) {
- healthString = getString(R.string.battery_info_health_over_voltage);
- } else if (health == BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE) {
- healthString = getString(R.string.battery_info_health_unspecified_failure);
- } else if (health == BatteryManager.BATTERY_HEALTH_COLD) {
- healthString = getString(R.string.battery_info_health_cold);
- } else {
- healthString = getString(R.string.battery_info_health_unknown);
- }
- mHealth.setText(healthString);
- }
- }
- };
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- setContentView(R.layout.battery_info);
-
- // create the IntentFilter that will be used to listen
- // to battery status broadcasts
- mIntentFilter = new IntentFilter();
- mIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- mStatus = (TextView)findViewById(R.id.status);
- mPower = (TextView)findViewById(R.id.power);
- mLevel = (TextView)findViewById(R.id.level);
- mScale = (TextView)findViewById(R.id.scale);
- mHealth = (TextView)findViewById(R.id.health);
- mTechnology = (TextView)findViewById(R.id.technology);
- mVoltage = (TextView)findViewById(R.id.voltage);
- mTemperature = (TextView)findViewById(R.id.temperature);
- mUptime = (TextView) findViewById(R.id.uptime);
-
- // Get awake time plugged in and on battery
- mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(
- BatteryStats.SERVICE_NAME));
- mScreenStats = IPowerManager.Stub.asInterface(ServiceManager.getService(POWER_SERVICE));
- mHandler.sendEmptyMessageDelayed(EVENT_TICK, 1000);
-
- registerReceiver(mIntentReceiver, mIntentFilter);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mHandler.removeMessages(EVENT_TICK);
-
- // we are no longer on the screen stop the observers
- unregisterReceiver(mIntentReceiver);
- }
-
- private void updateBatteryStats() {
- long uptime = SystemClock.elapsedRealtime();
- mUptime.setText(DateUtils.formatElapsedTime(uptime / 1000));
- }
-
-}
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index e1df499..82ee910 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -24,6 +24,7 @@
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
+import android.os.PersistableBundle;
import android.os.SELinux;
import android.os.SystemClock;
import android.os.SystemProperties;
@@ -34,6 +35,7 @@
import android.preference.PreferenceScreen;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
+import android.telephony.CarrierConfigManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -234,10 +236,39 @@
}
} else if (preference.getKey().equals(KEY_DEVICE_FEEDBACK)) {
sendFeedback();
+ } else if(preference.getKey().equals(KEY_SYSTEM_UPDATE_SETTINGS)) {
+ CarrierConfigManager configManager =
+ (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ PersistableBundle b = configManager.getConfig();
+ if (b.getBoolean(CarrierConfigManager.KEY_CI_ACTION_ON_SYS_UPDATE_BOOL)) {
+ ciActionOnSysUpdate(b);
+ }
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
+ /**
+ * Trigger client initiated action (send intent) on system update
+ */
+ private void ciActionOnSysUpdate(PersistableBundle b) {
+ String intentStr = b.getString(CarrierConfigManager.
+ KEY_CI_ACTION_ON_SYS_UPDATE_INTENT_STRING);
+ if (!TextUtils.isEmpty(intentStr)) {
+ String extra = b.getString(CarrierConfigManager.
+ KEY_CI_ACTION_ON_SYS_UPDATE_EXTRA_STRING);
+ String extraVal = b.getString(CarrierConfigManager.
+ KEY_CI_ACTION_ON_SYS_UPDATE_EXTRA_VAL_STRING);
+
+ Intent intent = new Intent(intentStr);
+ if (!TextUtils.isEmpty(extra)) {
+ intent.putExtra(extra, extraVal);
+ }
+ Log.d(LOG_TAG, "ciActionOnSysUpdate: broadcasting intent " + intentStr +
+ " with extra " + extra + ", " + extraVal);
+ getActivity().getApplicationContext().sendBroadcast(intent);
+ }
+ }
+
private void removePreferenceIfPropertyMissing(PreferenceGroup preferenceGroup,
String preference, String property ) {
if (SystemProperties.get(property).equals("")) {
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 8281885..20c1601 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -184,6 +184,7 @@
private String mCurrentPkgName;
private int mCurrentUid;
+ private boolean mFinishAfterDialog;
private Menu mOptionsMenu;
@@ -240,12 +241,13 @@
mListType = LIST_TYPE_HIGH_POWER;
// Default to showing system.
mShowSystem = true;
- if (intent != null && Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS
- .equals(intent.getAction())) {
+ if (Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS.equals(intent.getAction())
+ && intent.getData() != null) {
mCurrentPkgName = intent.getData().getSchemeSpecificPart();
if (mCurrentPkgName != null) {
mCurrentUid = mApplicationsState.getEntry(mCurrentPkgName,
UserHandle.myUserId()).info.uid;
+ mFinishAfterDialog = true;
startApplicationDetailsActivity();
}
}
@@ -427,6 +429,12 @@
if (requestCode == INSTALLED_APP_DETAILS && mCurrentPkgName != null) {
if (mListType == LIST_TYPE_NOTIFICATION) {
mApplications.mExtraInfoBridge.forceUpdate(mCurrentPkgName, mCurrentUid);
+ } else if (mListType == LIST_TYPE_HIGH_POWER) {
+ if (mFinishAfterDialog) {
+ getActivity().onBackPressed();
+ } else {
+ mApplications.mExtraInfoBridge.forceUpdate(mCurrentPkgName, mCurrentUid);
+ }
} else {
mApplicationsState.requestSize(mCurrentPkgName, UserHandle.getUserId(mCurrentUid));
}
@@ -450,7 +458,8 @@
startAppInfoFragment(AppStorageSettings.class, R.string.storage_settings);
break;
case LIST_TYPE_HIGH_POWER:
- HighPowerDetail.show(getActivity(), mCurrentPkgName);
+ HighPowerDetail.show(this, mCurrentPkgName, INSTALLED_APP_DETAILS,
+ mFinishAfterDialog);
break;
// TODO: Figure out if there is a way where we can spin up the profile's settings
// process ahead of time, to avoid a long load of data when user clicks on a managed app.
diff --git a/src/com/android/settings/fuelgauge/HighPowerDetail.java b/src/com/android/settings/fuelgauge/HighPowerDetail.java
index f6964af..c57a461 100644
--- a/src/com/android/settings/fuelgauge/HighPowerDetail.java
+++ b/src/com/android/settings/fuelgauge/HighPowerDetail.java
@@ -20,6 +20,7 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
+import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -39,10 +40,13 @@
public class HighPowerDetail extends DialogFragment implements OnClickListener {
+ private static final String ARG_DEFAULT_ON = "default_on";
+
private final PowerWhitelistBackend mBackend = PowerWhitelistBackend.getInstance();
private String mPackageName;
private CharSequence mLabel;
+ private boolean mDefaultOn;
private Adapter mAdapter;
private int mSelectedIndex;
@@ -57,12 +61,13 @@
} catch (NameNotFoundException e) {
mLabel = mPackageName;
}
+ mDefaultOn = getArguments().getBoolean(ARG_DEFAULT_ON);
mAdapter = new Adapter(getContext(), R.layout.radio_with_summary);
mAdapter.add(new Pair<String, String>(getString(R.string.ignore_optimizations_on),
getString(R.string.ignore_optimizations_on_desc)));
mAdapter.add(new Pair<String, String>(getString(R.string.ignore_optimizations_off),
getString(R.string.ignore_optimizations_off_desc)));
- mSelectedIndex = mBackend.isWhitelisted(mPackageName) ? 0 : 1;
+ mSelectedIndex = mDefaultOn || mBackend.isWhitelisted(mPackageName) ? 0 : 1;
if (mBackend.isSysWhitelisted(mPackageName)) {
mAdapter.setEnabled(1, false);
}
@@ -97,6 +102,15 @@
}
}
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ super.onDismiss(dialog);
+ Fragment target = getTargetFragment();
+ if (target != null) {
+ target.onActivityResult(getTargetRequestCode(), 0, null);
+ }
+ }
+
public static CharSequence getSummary(Context context, AppEntry entry) {
return getSummary(context, entry.info.packageName);
}
@@ -106,12 +120,15 @@
? R.string.high_power_on : R.string.high_power_off);
}
- public static void show(Activity activity, String packageName) {
+ public static void show(Fragment caller, String packageName, int requestCode,
+ boolean defaultToOn) {
HighPowerDetail fragment = new HighPowerDetail();
Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, packageName);
+ args.putBoolean(ARG_DEFAULT_ON, defaultToOn);
fragment.setArguments(args);
- fragment.show(activity.getFragmentManager(), HighPowerDetail.class.getSimpleName());
+ fragment.setTargetFragment(caller, requestCode);
+ fragment.show(caller.getFragmentManager(), HighPowerDetail.class.getSimpleName());
}
private class Adapter extends ArrayAdapter<Pair<String, String>> {