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

Commit cf2beec9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't schedule restart service if it will be bring down"

parents 7ce605eb c0067011
Loading
Loading
Loading
Loading
+2 −16
Original line number Diff line number Diff line
@@ -1270,10 +1270,8 @@
                <action android:name="com.android.frameworks.coretests.activity.BROADCAST_REMOTE_DENIED" />
            </intent-filter>
        </receiver>
        <service android:name="android.app.activity.LocalService">
            <intent-filter>
                <action android:name="com.android.frameworks.coretests.activity.SERVICE_LOCAL" />
            </intent-filter>
        <service android:name="android.app.activity.ServiceTest$RemoteService"
                android:process=":RemoteService">
            <meta-data android:name="com.android.frameworks.coretests.string" android:value="foo" />
            <meta-data android:name="com.android.frameworks.coretests.boolean" android:value="true" />
            <meta-data android:name="com.android.frameworks.coretests.integer" android:value="100" />
@@ -1281,18 +1279,6 @@
            <meta-data android:name="com.android.frameworks.coretests.float" android:value="100.1" />
            <meta-data android:name="com.android.frameworks.coretests.reference" android:resource="@xml/metadata" />
        </service>
        <service android:name="android.app.activity.LocalDeniedService"
                android:permission="com.android.frameworks.coretests.permission.TEST_DENIED">
            <intent-filter>
                <action android:name="com.android.frameworks.coretests.activity.SERVICE_LOCAL_DENIED" />
            </intent-filter>
        </service>
        <service android:name="android.app.activity.LocalGrantedService"
                android:permission="com.android.frameworks.coretests.permission.TEST_GRANTED">
            <intent-filter>
                <action android:name="com.android.frameworks.coretests.activity.SERVICE_LOCAL_GRANTED" />
            </intent-filter>
        </service>

        <service
            android:name="android.service.settings.suggestions.MockSuggestionService"
+0 −22
Original line number Diff line number Diff line
/*
 * 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 android.app.activity;

public class LocalDeniedService extends LocalService
{
}
+0 −22
Original line number Diff line number Diff line
/*
 * 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 android.app.activity;

public class LocalGrantedService extends LocalService
{
}
+2 −2
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ReceiverCallNotAllowedException;
import android.content.ServiceConnection;
import android.os.RemoteException;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;

public class LocalReceiver extends BroadcastReceiver {
    public LocalReceiver() {
@@ -52,7 +52,7 @@ public class LocalReceiver extends BroadcastReceiver {
                    public void onServiceDisconnected(ComponentName name) {
                    }
                };
                context.bindService(new Intent(context, LocalService.class), sc, 0);
                context.bindService(new Intent(context, ServiceTest.RemoteService.class), sc, 0);
                context.unbindService(sc);
            } catch (ReceiverCallNotAllowedException e) {
                //resultString = "This is the correct behavior but not yet implemented";
+0 −122
Original line number Diff line number Diff line
/*
 * 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 android.app.activity;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.IBinder;
import android.os.Parcel;
import android.util.Log;

public class LocalService extends Service {
    private final IBinder mBinder = new Binder() {

        @Override
        protected boolean onTransact(int code, Parcel data, Parcel reply,
                int flags) throws RemoteException {
            if (code == ServiceTest.SET_REPORTER_CODE) {
                data.enforceInterface(ServiceTest.SERVICE_LOCAL);
                mReportObject = data.readStrongBinder();
                return true;
            } else {
                return super.onTransact(code, data, reply, flags);
            }
        }
        
    };

    private IBinder mReportObject;
    private int mStartCount = 1;

    public LocalService() {
    }

    @Override
    public void onStart(Intent intent, int startId) {
        //Log.i("LocalService", "onStart: " + intent);
        if (intent.getExtras() != null) {
            mReportObject = intent.getExtras().getIBinder(ServiceTest.REPORT_OBJ_NAME);
            if (mReportObject != null) {
                try {
                    Parcel data = Parcel.obtain();
                    data.writeInterfaceToken(ServiceTest.SERVICE_LOCAL);
                    data.writeInt(mStartCount);
                    mStartCount++;
                    mReportObject.transact(
                            ServiceTest.STARTED_CODE, data, null, 0);
                    data.recycle();
                } catch (RemoteException e) {
                }
            }
        }
    }

    @Override
    public void onDestroy() {
        Log.i("LocalService", "onDestroy: mReportObject=" + mReportObject);
        if (mReportObject != null) {
            try {
                Parcel data = Parcel.obtain();
                data.writeInterfaceToken(ServiceTest.SERVICE_LOCAL);
                mReportObject.transact(
                        ServiceTest.DESTROYED_CODE, data, null, 0);
                data.recycle();
            } catch (RemoteException e) {
            }
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.i("LocalService", "onBind: " + intent);
        return mBinder;
    }
    
    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("LocalService", "onUnbind: " + intent);
        if (mReportObject != null) {
            try {
                Parcel data = Parcel.obtain();
                data.writeInterfaceToken(ServiceTest.SERVICE_LOCAL);
                mReportObject.transact(
                        ServiceTest.UNBIND_CODE, data, null, 0);
                data.recycle();
            } catch (RemoteException e) {
            }
        }
        return true;
    }
    
    @Override
    public void onRebind(Intent intent) {
        Log.i("LocalService", "onUnbind: " + intent);
        if (mReportObject != null) {
            try {
                Parcel data = Parcel.obtain();
                data.writeInterfaceToken(ServiceTest.SERVICE_LOCAL);
                mReportObject.transact(
                        ServiceTest.REBIND_CODE, data, null, 0);
                data.recycle();
            } catch (RemoteException e) {
            }
        }
    }
}
Loading