直接重點
沒寄錯的話 andorid 5 和 andorid 6 相比
LINUX/android/external/sepolicy/service_contexts
LINUX/android/frameworks/base/core/java/android/app/SystemServiceRegistry.java
這兩個有更動
------------------ LINUX/android/external/sepolicy/service.te ------------------
index 56478d0..f7e5c7f 100644
@@ -75,6 +75,7 @@ type print_service, app_api_service, system_server_service, service_manager_type
type processinfo_service, system_server_service, service_manager_type;
type procstats_service, app_api_service, system_server_service, service_manager_type;
type registry_service, app_api_service, system_server_service, service_manager_type;
+type reborn_service, app_api_service, system_server_service, service_manager_type;
type restrictions_service, app_api_service, system_server_service, service_manager_type;
type rttmanager_service, app_api_service, system_server_service, service_manager_type;
type samplingprofiler_service, system_server_service, service_manager_type;
--------------- LINUX/android/external/sepolicy/service_contexts ---------------
index 85dcd3d..ee6d66f 100644
@@ -95,6 +95,7 @@ procstats u:object_r:procstats_service:s0
radio.phonesubinfo u:object_r:radio_service:s0
radio.phone u:object_r:radio_service:s0
radio.sms u:object_r:radio_service:s0
+reborn u:object_r:reborn_service:s0
restrictions u:object_r:restrictions_service:s0
rttmanager u:object_r:rttmanager_service:s0
samplingprofiler u:object_r:samplingprofiler_service:s0
------------------- LINUX/android/frameworks/base/Android.mk -------------------
index 111fba6..34fb35c 100644
@@ -215,6 +215,7 @@ LOCAL_SRC_FILES += \
core/java/android/os/IPermissionController.aidl \
core/java/android/os/IProcessInfoService.aidl \
core/java/android/os/IPowerManager.aidl \
+ core/java/android/os/IRebornManager.aidl \
core/java/android/os/IRemoteCallback.aidl \
core/java/android/os/ISchedulingPolicyService.aidl \
core/java/android/os/IUpdateLock.aidl \
LINUX/android/frameworks/base/core/java/android/app/SystemServiceRegistry.java
index 3d264c6..03f6b03 100644
@@ -96,6 +96,10 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.Vibrator;
import android.os.storage.StorageManager;
+// **********************************************
+import android.os.IRebornManager;
+import android.os.RebornManager;
+// **********************************************
import android.print.IPrintManager;
import android.print.PrintManager;
import android.hardware.fingerprint.FingerprintManager;
@@ -687,6 +691,17 @@ final class SystemServiceRegistry {
return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b));
}});
+ // **************************************
+ registerService(Context.REBORN_SERVICE, RebornManager.class,
+ new CachedServiceFetcher<RebornManager>() {
+ @Override
+ public RebornManager createService(ContextImpl ctx) {
+ IBinder b = ServiceManager.getService(Context.REBORN_SERVICE);
+ IRebornManager service = IRebornManager.Stub.asInterface(b);
+ return new RebornManager(service);
+ }});
+ // **************************************
+
registerService(Context.MIDI_SERVICE, MidiManager.class,
new CachedServiceFetcher<MidiManager>() {
@Override
----- LINUX/android/frameworks/base/core/java/android/content/Context.java -----
index 758b6ff..147f331 100644
@@ -2511,6 +2511,9 @@ public abstract class Context {
MEDIA_PROJECTION_SERVICE,
MIDI_SERVICE,
RADIO_SERVICE,
+ // **********************************
+ REBORN_SERVICE,
+ // **********************************
})
@Retention(RetentionPolicy.SOURCE)
public @interface ServiceName {}
@@ -3374,6 +3377,18 @@ public abstract class Context {
*/
public static final String RADIO_SERVICE = "radio";
+
+ // ******************************************
+ /**
+ * Use with {@link #getSystemService} to retrieve a
+ * {@link android.os.RebornManager} for handling management of
+ * reborn audio services.
+ *
+ * @see #getSystemService
+ * @see android.os.RebornManager
+ */
+ public static final String REBORN_SERVICE = "reborn";
+ // ******************************************
/**
* Determine whether the given permission is allowed for a particular
* process and user ID running in the system.
----- LINUX/android/frameworks/base/core/java/android/content/Intent.java -----
index 87d52e4..fdd16c1 100644
@@ -2614,6 +2614,45 @@ public class Intent implements Parcelable, Cloneable {
public static final String ACTION_IDLE_MAINTENANCE_END =
"android.intent.action.ACTION_IDLE_MAINTENANCE_END";
+
+ // ******************************************
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_STANDALONE_MODE_CHANGED = "android.intent.action.STANDALONE_MODE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LINE_OUT_MODE_STATE_CHANGED = "android.intent.action.LINE_OUT_MODE_STATE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_BALANCE_STATE_CHANGED = "android.intent.action.BALANCE_STATE";
+
+ //David Wang
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_VARIABLE_LINE_OUT_STATE_CHANGED = "android.intent.action.VARIABLE_LINE_OUT_STATE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_BALANCE_AUTO_VOLUME_MODE_STATE_CHANGED = "android.intent.action.BALANCE_AUTO_VOLUME_MODE_STATE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LR_BALANCE_VALUE_CHANGED = "android.intent.action.LR_BALANCE_VALUE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_DIGITAL_FILTER_STATE_CHANGED = "android.intent.action.DIGITAL_FILTER_STATE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LOCK_RANGE_VALUE_CHANGED = "android.intent.action.LOCK_RANGE_VALUE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_VOLUME_LIMITER_VALUE_CHANGED = "android.intent.action.VOLUME_LIMITER_VALUE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_GAIN_VALUE_CHANGED = "android.intent.action.GAIN_VALUE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_VOLUME_LOCK_MODE_STATE_CHANGED = "android.intent.action.VOLUME_LOCK_MODE_STATE";
+ // ******************************************
+
+
+
/**
* Broadcast Action: a remote intent is to be broadcasted.
*
---- LINUX/android/frameworks/base/core/java/android/os/IRebornManager.aidl ----
new file mode 100644
index 0000000..74c4f0d
@@ -0,0 +1,24 @@
+package android.os;
+
+import android.os.LRBalance;
+
+interface IRebornManager
+{
+ boolean startStandalone(int category);
+ boolean stopStandalone();
+ boolean setStandalone(boolean enable);
+ int getLineOutState();
+ boolean setLineOutState(boolean on);
+ int getBalanceState();
+ boolean setBalanceState(int state);
+ LRBalance getLRBalance();
+ boolean setLRBalance(in LRBalance lrBalance);
+ int getDigitalFilterState();
+ boolean setDigitalFilterState(int state);
+ int getLockRange();
+ boolean setLockRange(int value);
+ int getVolumeLimiter();
+ boolean setVolumeLimiter(int value);
+ int getGain();
+ boolean setGain(int value);
+}
------ LINUX/android/frameworks/base/core/java/android/os/LRBalance.aidl ------
new file mode 100644
index 0000000..2413de8
@@ -0,0 +1,3 @@
+package android.os;
+
+parcelable LRBalance;
------ LINUX/android/frameworks/base/core/java/android/os/LRBalance.java ------
new file mode 100644
index 0000000..a8361b3
@@ -0,0 +1,44 @@
+package android.os;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+// http://developer.android.com/guide/components/aidl.html
+public class LRBalance implements Parcelable {
+ public int lValue;
+ public int rValue;
+
+ public static final Creator<LRBalance> CREATOR =
+ new Creator<LRBalance>() {
+ public LRBalance createFromParcel(Parcel in) {
+ return new LRBalance(in);
+ }
+
+ public LRBalance[] newArray(int size) {
+ return new LRBalance[size];
+ }
+ };
+
+ public LRBalance() {
+ lValue = 0;
+ rValue = 0;
+ }
+
+ public LRBalance(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public void readFromParcel(Parcel in) {
+ lValue = in.readInt();
+ rValue = in.readInt();
+ }
+
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(lValue);
+ out.writeInt(rValue);
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+}
---- LINUX/android/frameworks/base/core/java/android/os/RebornManager.java ----
new file mode 100644
index 0000000..c14c49a
@@ -0,0 +1,183 @@
+package android.os;
+
+import android.os.LRBalance;
+import android.os.RemoteException;
+
+public class RebornManager {
+ private static final String TAG = "RebornManager";
+
+ public static final int STANDALONE_CATEGORY_LCD_DISPLAY = 0x00000001;
+ public static final int STANDALONE_CATEGORY_BLUETOOTH = 0x00000002;
+ public static final int STANDALONE_CATEGORY_WIFI = 0x00000004;
+ public static final int STANDALONE_CATEGORY_GPS = 0x00000008;
+
+ public static final int LINE_OUT_STATE_ERROR = -1;
+
+ public static final int BALANCE_STATE_ERROR = -1;
+ public static final int BALANCE_STATE_BALANCED = 0;
+ public static final int BALANCE_STATE_ACG = 1;
+ public static final int BALANCE_STATE_OFF = 2;
+
+ public static final int LR_BALANCE_ERROR = -1;
+ public static final int MAX_L_BALANCE = 79; // 80 (0 ~ 79) steps
+ public static final int MAX_R_BALANCE = 79; // 80 (0 ~ 79) steps
+
+ public static final int DIGITAL_FILTER_STATE_ERROR = -1;
+ public static final int DIGITAL_FILTER_STATE_SHARP = 0; // fast roll-off
+ public static final int DIGITAL_FILTER_STATE_SLOW = 1; // slow roll-off
+ public static final int DIGITAL_FILTER_STATE_SHORT = 2; // minimum phase
+
+ public static final int LOCK_RANGE_ERROR = -1;
+ public static final int MAX_LOCK_RANGE = 15; // 16 (0 ~ 15) steps
+
+ public static final int VOLUME_LIMITER_ERROR = -1;
+ public static final int MAX_VOLUME_LIMITER = 160; // 161 (0 ~ 160) steps
+
+ public static final int GAIN_ERROR = -1;
+ public static final int GAIN_HIGH = 0;
+ public static final int GAIN_NORMAL = 1;
+ public static final int GAIN_LOW = 2;
+
+ private final IRebornManager mService;
+
+ public RebornManager(IRebornManager service) {
+ mService = service;
+ }
+
+ public boolean startStandalone(int category) {
+ try {
+ return mService.startStandalone(category);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public boolean stopStandalone() {
+ try {
+ return mService.stopStandalone();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public boolean setStandalone(boolean enable) {
+ try {
+ return mService.setStandalone(enable);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public int getLineOutState() {
+ try {
+ return mService.getLineOutState();
+ } catch (RemoteException e) {
+ return LINE_OUT_STATE_ERROR;
+ }
+ }
+
+ public boolean setLineOutState(boolean on) {
+ try {
+ return mService.setLineOutState(on);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public int getBalanceState() {
+ try {
+ return mService.getBalanceState();
+ } catch (RemoteException e) {
+ return BALANCE_STATE_ERROR;
+ }
+ }
+
+ public boolean setBalanceState(int state) {
+ try {
+ return mService.setBalanceState(state);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public LRBalance getLRBalance() {
+ try {
+ return mService.getLRBalance();
+ } catch (RemoteException e) {
+ return null;
+ }
+ }
+
+ public boolean setLRBalance(LRBalance lrBalance) {
+ try {
+ return mService.setLRBalance(lrBalance);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public int getDigitalFilterState() {
+ try {
+ return mService.getDigitalFilterState();
+ } catch (RemoteException e) {
+ return DIGITAL_FILTER_STATE_ERROR;
+ }
+ }
+
+ public boolean setDigitalFilterState(int state) {
+ try {
+ return mService.setDigitalFilterState(state);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public int getLockRange() {
+ try {
+ return mService.getLockRange();
+ } catch (RemoteException e) {
+ return LOCK_RANGE_ERROR;
+ }
+ }
+
+ public boolean setLockRange(int value) {
+ try {
+ return mService.setLockRange(value);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public int getVolumeLimiter() {
+ try {
+ return mService.getVolumeLimiter();
+ } catch (RemoteException e) {
+ return VOLUME_LIMITER_ERROR;
+ }
+ }
+
+ public boolean setVolumeLimiter(int value) {
+ try {
+ return mService.setVolumeLimiter(value);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ public int getGain() {
+ try {
+ return mService.getGain();
+ } catch (RemoteException e) {
+ return GAIN_ERROR;
+ }
+ }
+
+ public boolean setGain(int value) {
+ try {
+ return mService.setGain(value);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+}
+
---- LINUX/android/frameworks/base/core/java/android/provider/Settings.java ----
index 90f0707..2ba1136 100644
@@ -87,6 +87,26 @@ public final class Settings {
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_SETTINGS = "android.settings.SETTINGS";
+
+ // ******************************************
+ /**
+ * Activity Action: Show settings to allow configuration of output select.
+ * <p>
+ * In some cases, a matching Activity may not exist, so ensure you
+ * safeguard against this.
+ * <p>
+ * Input: Nothing.
+ * <p>
+ * Output: Nothing.
+
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_OUTPUT_SELECT_SETTINGS =
+ "android.settings.OUTPUT_SELECT_SETTINGS";
+ // ******************************************
+
+
+
/**
* Activity Action: Show settings to allow configuration of APNs.
* <p>
@@ -5981,6 +6001,63 @@ public final class Settings {
*/
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/global");
+
+ // **************************************
+ /**
+ * Whether Standalone Mode is on.
+ */
+ public static final String STANDALONE_MODE_ON = "standalone_mode_on";
+
+ /**
+ * Defines Standalone Mode restoration value.
+ */
+ public static final String STANDALONE_MODE_RESTORATION_VALUE = "standalone_mode_restoration_value";
+
+ /**
+ * Whether Line Out Mode is on.
+ */
+ public static final String LINE_OUT_MODE_ON = "line_out_mode_on";
+
+ /**
+ * Defines balance state.
+ */
+ public static final String BALANCE_STATE = "balance_state";
+
+ /**
+ * Defines lvalue of LR balance.
+ */
+ public static final String LR_BALANCE_LVALUE = "lr_balance_lvalue";
+
+ /**
+ * Defines rvalue of LR balance.
+ */
+ public static final String LR_BALANCE_RVALUE = "lr_balance_rvalue";
+
+ /**
+ * Defines digital filter state.
+ */
+ public static final String DIGITAL_FILTER_STATE = "digital_filter_state";
+
+ /**
+ * Defines lock range value.
+ */
+ public static final String LOCK_RANGE_VALUE = "lock_range_value";
+
+ /**
+ * Defines volume limiter value.
+ */
+ public static final String VOLUME_LIMITER_VALUE = "volume_limiter_value";
+
+ /**
+ * Defines gain value.
+ */
+ public static final String GAIN_VALUE = "gain_value";
+ // **************************************
+
+
+
+
+
/**
* Whether users are allowed to add more users or guest from lockscreen.
* <p>
---------- LINUX/android/frameworks/base/core/res/AndroidManifest.xml ----------
index 08bccc1..75b1006 100644
@@ -2667,6 +2667,13 @@
<permission android:name="android.permission.DISPATCH_NFC_MESSAGE"
android:protectionLevel="signature|privileged" />
+ <!-- ************************************ -->
+ <!-- Allows an application to use RebornManager APIs. -->
+ <permission android:name="android.permission.REBORN_SERVICE"
+ android:protectionLevel="normal" />
+ <!-- ************************************ -->
+
+
<!-- The system process is explicitly the only one allowed to launch the
confirmation UI for full backup/restore -->
<uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>
LINUX/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index c0a1e5c..c56dbb3 100644
@@ -290,4 +290,20 @@
example "com.google.android.marvin.talkback/
com.google.android.marvin.talkback.TalkBackService" -->
<string name="def_enable_accessibility_services" translatable="false"></string>
+
+ <!-- ************************************ -->
+ <bool name="def_standalone_mode_on">false</bool>
+ <integer name="def_standalone_mode_restoration_value">0</integer>
+ <bool name="def_line_out_mode_on">false</bool>
+ <integer name="def_balance_state">0</integer>
+ <integer name="def_lr_balance_lvalue">0</integer>
+ <integer name="def_lr_balance_rvalue">0</integer>
+ <integer name="def_digital_filter_state">0</integer>
+ <integer name="def_lock_range_value">0</integer>
+ <integer name="def_volume_limiter_value">0</integer>
+ <integer name="def_gain_value">0</integer>
+ <!-- ************************************ -->
+
+
+
</resources>
LINUX/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 5a14967..7d3ac51 100644
@@ -2555,6 +2555,40 @@ class DatabaseHelper extends SQLiteOpenHelper {
stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)"
+ " VALUES(?,?);");
+
+ // **********************************
+ loadBooleanSetting(stmt, Settings.Global.STANDALONE_MODE_ON,
+ R.bool.def_standalone_mode_on);
+
+ loadIntegerSetting(stmt, Settings.Global.STANDALONE_MODE_RESTORATION_VALUE,
+ R.integer.def_standalone_mode_restoration_value);
+
+ loadBooleanSetting(stmt, Settings.Global.LINE_OUT_MODE_ON,
+ R.bool.def_line_out_mode_on);
+
+ loadIntegerSetting(stmt, Settings.Global.BALANCE_STATE,
+ R.integer.def_balance_state);
+
+ loadIntegerSetting(stmt, Settings.Global.LR_BALANCE_LVALUE,
+ R.integer.def_lr_balance_lvalue);
+
+ loadIntegerSetting(stmt, Settings.Global.LR_BALANCE_RVALUE,
+ R.integer.def_lr_balance_rvalue);
+
+ loadIntegerSetting(stmt, Settings.Global.DIGITAL_FILTER_STATE,
+ R.integer.def_digital_filter_state);
+
+ loadIntegerSetting(stmt, Settings.Global.LOCK_RANGE_VALUE,
+ R.integer.def_lock_range_value);
+
+ loadIntegerSetting(stmt, Settings.Global.VOLUME_LIMITER_VALUE,
+ R.integer.def_volume_limiter_value);
+
+ loadIntegerSetting(stmt, Settings.Global.GAIN_VALUE,
+ R.integer.def_gain_value);
+ // **********************************
+
+
// --- Previously in 'system'
loadBooleanSetting(stmt, Settings.Global.AIRPLANE_MODE_ON,
R.bool.def_airplane_mode_on);
LINUX/android/frameworks/base/services/core/java/com/android/server/RebornService.java
new file mode 100755
index 0000000..e3bdd3a
@@ -0,0 +1,415 @@
+package com.android.server;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.wifi.WifiManager;
+import android.os.Binder;
+import android.os.IRebornManager;
+import android.os.RebornManager;
+import android.os.LRBalance;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+public class RebornService extends IRebornManager.Stub {
+ private static final String TAG = "RebornService";
+
+ private Context mContext;
+
+ public RebornService(Context context) {
+ mContext = context;
+ }
+
+ private void enforceRebornServicePermission() {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.REBORN_SERVICE,
+ "RebornService");
+ }
+
+ private boolean setBluetoothEnabled(boolean enabled)
+ {
+ boolean OK = false;
+
+ try {
+ BluetoothManager bluetoothManager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
+ BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
+ if ( enabled )
+ OK = bluetoothAdapter.enable();
+ else
+ OK = bluetoothAdapter.disable();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return OK;
+ }
+
+ private boolean setWifiEnabled(boolean enabled)
+ {
+ boolean OK = false;
+
+ try {
+ WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
+ OK = wifiManager.setWifiEnabled(enabled);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return OK;
+ }
+
+ // ********************************************************************************************
+ public boolean startStandalone(int category) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ if ( (category & RebornManager.STANDALONE_CATEGORY_LCD_DISPLAY) != 0 ) {
+
+ }
+ if ( (category & RebornManager.STANDALONE_CATEGORY_BLUETOOTH) != 0 ) {
+ setBluetoothEnabled(false);
+ }
+ if ( (category & RebornManager.STANDALONE_CATEGORY_WIFI) != 0 ) {
+ setWifiEnabled(false);
+ }
+ if ( (category & RebornManager.STANDALONE_CATEGORY_GPS) != 0 ) {
+
+ }
+
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.STANDALONE_MODE_ON, 1);
+ Settings.Global.putInt(cr, Settings.Global.STANDALONE_MODE_RESTORATION_VALUE, category);
+ Intent intent = new Intent(Intent.ACTION_STANDALONE_MODE_CHANGED);
+ intent.putExtra("state", 1);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public boolean stopStandalone() {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = 0;
+ int category = Settings.Global.getInt(cr, Settings.Global.STANDALONE_MODE_RESTORATION_VALUE, def);
+
+ if ( (category & RebornManager.STANDALONE_CATEGORY_LCD_DISPLAY) != 0 ) {
+
+ }
+ if ( (category & RebornManager.STANDALONE_CATEGORY_BLUETOOTH) != 0 ) {
+ setBluetoothEnabled(true);
+ }
+ if ( (category & RebornManager.STANDALONE_CATEGORY_WIFI) != 0 ) {
+ setWifiEnabled(true);
+ }
+ if ( (category & RebornManager.STANDALONE_CATEGORY_GPS) != 0 ) {
+
+ }
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public boolean setStandalone(boolean enable) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.STANDALONE_MODE_ON, enable ? 1 : 0);
+ Intent intent = new Intent(Intent.ACTION_STANDALONE_MODE_CHANGED);
+ intent.putExtra("state", enable);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public int getLineOutState() {
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = 0;
+ return Settings.Global.getInt(cr, Settings.Global.LINE_OUT_MODE_ON, def);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return RebornManager.LINE_OUT_STATE_ERROR;
+ }
+
+ public boolean setLineOutState(boolean on) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.LINE_OUT_MODE_ON, on ? 1 : 0);
+ Intent intent = new Intent(Intent.ACTION_LINE_OUT_MODE_STATE_CHANGED);
+ intent.putExtra("state", on);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public int getBalanceState() {
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = RebornManager.BALANCE_STATE_ERROR;
+ return Settings.Global.getInt(cr, Settings.Global.BALANCE_STATE, def);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return RebornManager.BALANCE_STATE_ERROR;
+ }
+
+ public boolean setBalanceState(int state) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.BALANCE_STATE, state);
+ Intent intent = new Intent(Intent.ACTION_BALANCE_STATE_CHANGED);
+ intent.putExtra("state", state);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public LRBalance getLRBalance() {
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ LRBalance lrBalance = new LRBalance();
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = RebornManager.BALANCE_STATE_ERROR;
+ lrBalance.lValue = Settings.Global.getInt(cr, Settings.Global.LR_BALANCE_LVALUE, def);
+ lrBalance.rValue = Settings.Global.getInt(cr, Settings.Global.LR_BALANCE_RVALUE, def);
+ return lrBalance;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return null;
+ }
+
+ public boolean setLRBalance(LRBalance lrBalance) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.LR_BALANCE_LVALUE, lrBalance.lValue);
+ Settings.Global.putInt(cr, Settings.Global.LR_BALANCE_RVALUE, lrBalance.rValue);
+ Intent intent = new Intent(Intent.ACTION_LR_BALANCE_VALUE_CHANGED);
+ intent.putExtra("lvalue", lrBalance.lValue);
+ intent.putExtra("rvalue", lrBalance.rValue);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public int getDigitalFilterState() {
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = RebornManager.DIGITAL_FILTER_STATE_ERROR;
+ return Settings.Global.getInt(cr, Settings.Global.DIGITAL_FILTER_STATE, def);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return RebornManager.DIGITAL_FILTER_STATE_ERROR;
+ }
+
+ public boolean setDigitalFilterState(int state) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.DIGITAL_FILTER_STATE, state);
+ Intent intent = new Intent(Intent.ACTION_DIGITAL_FILTER_STATE_CHANGED);
+ intent.putExtra("state", state);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public int getLockRange() {
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = RebornManager.LOCK_RANGE_ERROR;
+ return Settings.Global.getInt(cr, Settings.Global.LOCK_RANGE_VALUE, def);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return RebornManager.LOCK_RANGE_ERROR;
+ }
+
+ public boolean setLockRange(int value) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.LOCK_RANGE_VALUE, value);
+ Intent intent = new Intent(Intent.ACTION_LOCK_RANGE_VALUE_CHANGED);
+ intent.putExtra("value", value);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public int getVolumeLimiter() {
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = RebornManager.VOLUME_LIMITER_ERROR;
+ return Settings.Global.getInt(cr, Settings.Global.VOLUME_LIMITER_VALUE, def);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return RebornManager.VOLUME_LIMITER_ERROR;
+ }
+
+ public boolean setVolumeLimiter(int value) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.VOLUME_LIMITER_VALUE, value);
+ Intent intent = new Intent(Intent.ACTION_VOLUME_LIMITER_VALUE_CHANGED);
+ intent.putExtra("value", value);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+
+ public int getGain() {
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ int def = RebornManager.GAIN_ERROR;
+ return Settings.Global.getInt(cr, Settings.Global.GAIN_VALUE, def);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return RebornManager.GAIN_ERROR;
+ }
+
+ public boolean setGain(int value) {
+ boolean OK = false;
+
+ enforceRebornServicePermission();
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ContentResolver cr = mContext.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.GAIN_VALUE, value);
+ Intent intent = new Intent(Intent.ACTION_GAIN_VALUE_CHANGED);
+ intent.putExtra("value", value);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ OK = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
+ return OK;
+ }
+}
LINUX/android/frameworks/base/services/java/com/android/server/SystemServer.java
index 1e25ecd..3b9059e 100644
@@ -429,6 +429,9 @@ public final class SystemServer {
MmsServiceBroker mmsService = null;
EntropyMixer entropyMixer = null;
CameraService cameraService = null;
+ // **************************************
+ RebornService rebornService = null;
+ // **************************************
boolean disableStorage = SystemProperties.getBoolean("config.disable_storage", false);
boolean disableBluetooth = SystemProperties.getBoolean("config.disable_bluetooth", false);
@@ -987,6 +990,19 @@ public final class SystemServer {
}
mSystemServiceManager.startService(LauncherAppsService.class);
+
+
+ // **********************************
+ try {
+ Slog.i(TAG, "Reborn Service");
+ rebornService = new RebornService(context);
+ ServiceManager.addService(Context.REBORN_SERVICE, rebornService);
+ } catch (Throwable e) {
+ reportWtf("starting Reborn Service", e);
+ }
+ // **********************************
+
+
}
if (!disableNonCoreServices) {
@@ -1088,6 +1104,9 @@ public final class SystemServer {
final MediaRouterService mediaRouterF = mediaRouter;
final AudioService audioServiceF = audioService;
final MmsServiceBroker mmsServiceF = mmsService;
+ // **************************************
+ //final RebornService rebornServiceF = rebornService;
+ // **************************************
// We now tell the activity manager it is okay to run third party
// code. It will call back into us once it has gotten to the state
@@ -1217,6 +1236,15 @@ public final class SystemServer {
} catch (Throwable e) {
reportWtf("Notifying MmsService running", e);
}
+
+ // ******************************
+ //try {
+ // if (rebornServiceF != null) rebornServiceF.systemRunning();
+ //} catch (Throwable e) {
+ // reportWtf("Notifying RebornService running", e);
+ //}
+ // ******************************
+
}
});
}
0 意見:
張貼留言