Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6a33f2e authored by Santos Cordon's avatar Santos Cordon
Browse files

(Telecom-system part 4) Move telecom to the system server process.

Also remove TelecomApp since it is no longer run/necessary after this
change.

Bug: 18112269
Change-Id: I901023a2333b5c664cd2dc314d2df638355e9d41
parent 9d29ded2
Loading
Loading
Loading
Loading
+24 −13
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
        package="com.android.server.telecom"
        android:debuggable="true"
        coreApp="true"
        android:sharedUserId="android.uid.phone">
        android:sharedUserId="android.uid.system">

    <!-- Prevents the activity manager from delaying any activity-start
         requests by this package, including requests immediately after
@@ -28,6 +28,7 @@
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.CALL_PRIVILEGED" />
    <uses-permission android:name="android.permission.MANAGE_USERS" />
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_CALL_LOG" />
@@ -53,8 +54,7 @@
         can check for incompatible APIs. -->
    <uses-sdk android:minSdkVersion="19" />

    <application android:name="TelecomApp"
            android:persistent="true"
    <application android:persistent="true"
            android:label="@string/telecommAppLabel"
            android:icon="@mipmap/ic_launcher_phone"
            android:allowBackup="false"
@@ -79,7 +79,8 @@
        <activity android:name="CallActivity"
                android:theme="@style/Theme.Telecomm.Transparent"
                android:permission="android.permission.CALL_PHONE"
                android:excludeFromRecents="true">
                android:excludeFromRecents="true"
                android:process=":ui">
            <!-- CALL action intent filters for the various ways of initiating an outgoing call. -->
            <intent-filter>
                <action android:name="android.intent.action.CALL" />
@@ -115,7 +116,8 @@
             the system from processing this intent (b/8871505). -->
        <activity-alias android:name="PrivilegedCallActivity"
                android:targetActivity="CallActivity"
                android:permission="android.permission.CALL_PRIVILEGED">
                android:permission="android.permission.CALL_PRIVILEGED"
                android:process=":ui">
            <intent-filter android:priority="1000">
                <action android:name="android.intent.action.CALL_PRIVILEGED" />
                <category android:name="android.intent.category.DEFAULT" />
@@ -149,7 +151,8 @@
             that scheme be removed from this activity? -->
        <activity-alias android:name="EmergencyCallActivity"
                android:targetActivity="CallActivity"
                android:permission="android.permission.CALL_PRIVILEGED">
                android:permission="android.permission.CALL_PRIVILEGED"
                android:process=":ui">
            <intent-filter android:priority="1000">
                <action android:name="android.intent.action.CALL_EMERGENCY" />
                <category android:name="android.intent.category.DEFAULT" />
@@ -174,7 +177,8 @@
            </intent-filter>
        </activity-alias>

        <receiver android:name="TelecomBroadcastReceiver" android:exported="false">
        <receiver android:name="TelecomBroadcastReceiver" android:exported="false"
                android:process="system">
            <intent-filter>
                <action android:name="com.android.server.telecom.ACTION_CALL_BACK_FROM_NOTIFICATION" />
                <action android:name="com.android.server.telecom.ACTION_CALL_BACK_FROM_NOTIFICATION" />
@@ -182,7 +186,8 @@
            </intent-filter>
        </receiver>

        <receiver android:name="PhoneAccountBroadcastReceiver">
        <receiver android:name="PhoneAccountBroadcastReceiver"
                android:process="system">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
                <data android:scheme="package" />
@@ -192,7 +197,8 @@
        <activity android:name=".RespondViaSmsSettings$Settings"
                  android:label="@string/respond_via_sms_setting_title"
                  android:configChanges="orientation|screenSize|keyboardHidden"
                  android:theme="@style/Theme.Telecom.DialerSettings">
                  android:theme="@style/Theme.Telecom.DialerSettings"
                  android:process=":ui">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
@@ -202,22 +208,27 @@
                android:configChanges="orientation|screenSize|keyboardHidden"
                android:excludeFromRecents="true"
                android:launchMode="singleInstance"
                android:theme="@style/Theme.Telecomm.Transparent">
                android:theme="@style/Theme.Telecomm.Transparent"
                android:process=":ui">
        </activity>

        <receiver android:name=".CallReceiver"
            android:exported="false">
                android:exported="true"
                android:permission="android.permission.MODIFY_PHONE_STATE"
                android:process="system">
        </receiver>

        <service android:name="BluetoothPhoneService"
                android:singleUser="true">
                android:singleUser="true"
                android:process="system">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothHeadsetPhone" />
            </intent-filter>
        </service>

        <service android:name=".TelecomService"
                android:singleUser="true">
                android:singleUser="true"
                android:process="system">
            <intent-filter>
                <android android:name="android.telecom.ITelecomService" />
            </intent-filter>
+0 −1
Original line number Diff line number Diff line
@@ -123,7 +123,6 @@ public class CallActivity extends Activity {
        }

        intent.putExtra(CallReceiver.KEY_IS_DEFAULT_DIALER, isDefaultDialer());

        sendBroadcastToReceiver(intent);
    }

+3 −3
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public final class CallsManager extends Call.ListenerBase {
    /**
     * Singleton instance of the {@link CallsManager}, initialized from {@link TelecomService}.
     */
    private static CallsManager INSTANCE = null;
    private static CallsManager sInstance = null;

    private static final String TAG = "CallsManager";

@@ -138,7 +138,7 @@ public final class CallsManager extends Call.ListenerBase {

    /** Singleton accessor. */
    static CallsManager getInstance() {
        return INSTANCE;
        return sInstance;
    }

    /**
@@ -147,7 +147,7 @@ public final class CallsManager extends Call.ListenerBase {
     * @param instance The instance to set.
     */
    static void initialize(CallsManager instance) {
        INSTANCE = instance;
        sInstance = instance;
    }

    /**
+0 −83
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.server.telecom;

import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.ServiceManager;
import android.os.UserHandle;

/**
 * Top-level Application class for Telecom.
 */
public final class TelecomApp extends Application {

    /**
     * Used to bind to the telecom service. Once created, the telecom service will start the telecom
     * global state.
     */
    private class TelecomServiceConnection implements ServiceConnection {
        /** {@inheritDoc} */
        @Override public void onServiceConnected(ComponentName name, IBinder service) {
            Log.i(this, "onServiceConnected: %s", name);
            ServiceManager.addService(Context.TELECOM_SERVICE, service);
        }

        /** {@inheritDoc} */
        @Override public void onServiceDisconnected(ComponentName name) {
            Log.i(this, "onDisconnected: %s", name);
            bindToService();
        }
    }

    private ServiceConnection mServiceConnection;

    /** {@inheritDoc} */
    @Override
    public void onCreate() {
        super.onCreate();

        if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
            bindToService();
        }
    }

    private void bindToService() {
        if (mServiceConnection != null) {
            unbindService(mServiceConnection);
            mServiceConnection = null;
        }

        ComponentName componentName = new ComponentName(this, TelecomService.class);
        Intent intent = new Intent(TelecomService.SERVICE_INTERFACE);
        intent.setComponent(componentName);
        int bindFlags = Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT;

        Log.i(this, "binding to TelecomService.");
        ServiceConnection serviceConnection = new TelecomServiceConnection();
        if (bindServiceAsUser(intent, serviceConnection, bindFlags, UserHandle.OWNER)) {
            mServiceConnection = serviceConnection;
            Log.i(this, "TelecomService binding successful");
        } else {
            Log.e(this, null, "Failed to bind to TelecomService.");
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ public final class TelecomGlobals {

        mCallsManager = new CallsManager(mContext, mMissedCallNotifier, mPhoneAccountRegistrar);
        CallsManager.initialize(mCallsManager);
        Log.i(this, "CallsManager initialized");

        // Start the BluetoothPhoneService
        BluetoothPhoneService.start(mContext);
Loading