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

Commit 3d3659bc authored by Jing Ji's avatar Jing Ji
Browse files

Rename android.app.ForegroundServiceTypeNotAllowedException to

..android.app.InvalidForegroundServiceTypeException.

And also add MissingForegroundServiceTypeException.

Bug: 254662240
Bug: 246792057
Test: atest CtsAppFgsTestCases
Change-Id: I9d39cb7fa75a14eb1b8cc97af13b612491803b61
parent 5bb5cd95
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -5291,11 +5291,8 @@ package android.app {
    field @NonNull public static final android.os.Parcelable.Creator<android.app.ForegroundServiceStartNotAllowedException> CREATOR;
  }
  public final class ForegroundServiceTypeNotAllowedException extends android.app.ServiceStartNotAllowedException implements android.os.Parcelable {
    ctor public ForegroundServiceTypeNotAllowedException(@NonNull String);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.ForegroundServiceTypeNotAllowedException> CREATOR;
  public abstract class ForegroundServiceTypeException extends android.app.ServiceStartNotAllowedException {
    ctor public ForegroundServiceTypeException(@NonNull String);
  }
  @Deprecated public class Fragment implements android.content.ComponentCallbacks2 android.view.View.OnCreateContextMenuListener {
@@ -5738,6 +5735,13 @@ package android.app {
    method @Deprecated public void setIntentRedelivery(boolean);
  }
  public final class InvalidForegroundServiceTypeException extends android.app.ForegroundServiceTypeException implements android.os.Parcelable {
    ctor public InvalidForegroundServiceTypeException(@NonNull String);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.InvalidForegroundServiceTypeException> CREATOR;
  }
  public class KeyguardManager {
    method @RequiresPermission(android.Manifest.permission.SUBSCRIBE_TO_KEYGUARD_LOCKED_STATE) public void addKeyguardLockedStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.app.KeyguardManager.KeyguardLockedStateListener);
    method @Deprecated public android.content.Intent createConfirmDeviceCredentialIntent(CharSequence, CharSequence);
@@ -5892,6 +5896,13 @@ package android.app {
    method public void showDialog();
  }
  public final class MissingForegroundServiceTypeException extends android.app.ForegroundServiceTypeException implements android.os.Parcelable {
    ctor public MissingForegroundServiceTypeException(@NonNull String);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.MissingForegroundServiceTypeException> CREATOR;
  }
  public class NativeActivity extends android.app.Activity implements android.view.InputQueue.Callback android.view.SurfaceHolder.Callback2 android.view.ViewTreeObserver.OnGlobalLayoutListener {
    ctor public NativeActivity();
    method public void onGlobalLayout();
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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;

import android.annotation.NonNull;

/**
 * Base exception thrown when an app tries to start a foreground {@link Service}
 * without a valid type.
 */
public abstract class ForegroundServiceTypeException extends ServiceStartNotAllowedException {
    /**
     * Constructor.
     */
    public ForegroundServiceTypeException(@NonNull String message) {
        super(message);
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_D
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_HEALTH;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
@@ -152,6 +153,20 @@ public abstract class ForegroundServiceTypePolicy {
    @Overridable
    public static final long FGS_TYPE_PERMISSION_CHANGE_ID = 254662522L;

    /**
     * The policy for the {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_MANIFEST}.
     *
     * @hide
     */
    public static final @NonNull ForegroundServiceTypePolicyInfo FGS_TYPE_POLICY_MANIFEST =
            new ForegroundServiceTypePolicyInfo(
            FOREGROUND_SERVICE_TYPE_MANIFEST,
            FGS_TYPE_NONE_DEPRECATION_CHANGE_ID,
            FGS_TYPE_NONE_DISABLED_CHANGE_ID,
            null,
            null
    );

    /**
     * The policy for the {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_NONE}.
     *
@@ -954,6 +969,8 @@ public abstract class ForegroundServiceTypePolicy {
         * Constructor
         */
        public DefaultForegroundServiceTypePolicy() {
            mForegroundServiceTypePolicies.put(FOREGROUND_SERVICE_TYPE_MANIFEST,
                    FGS_TYPE_POLICY_MANIFEST);
            mForegroundServiceTypePolicies.put(FOREGROUND_SERVICE_TYPE_NONE,
                    FGS_TYPE_POLICY_NONE);
            mForegroundServiceTypePolicies.put(FOREGROUND_SERVICE_TYPE_DATA_SYNC,
+11 −11
Original line number Diff line number Diff line
@@ -20,18 +20,18 @@ import android.os.Parcel;
import android.os.Parcelable;

/**
 * Exception thrown when an app tries to start a foreground {@link Service} without a valid type.
 * Exception thrown when an app tries to start a foreground {@link Service} with an invalid type.
 */
public final class ForegroundServiceTypeNotAllowedException
        extends ServiceStartNotAllowedException implements Parcelable {
public final class InvalidForegroundServiceTypeException
        extends ForegroundServiceTypeException implements Parcelable {
    /**
     * Constructor.
     */
    public ForegroundServiceTypeNotAllowedException(@NonNull String message) {
    public InvalidForegroundServiceTypeException(@NonNull String message) {
        super(message);
    }

    ForegroundServiceTypeNotAllowedException(@NonNull Parcel source) {
    InvalidForegroundServiceTypeException(@NonNull Parcel source) {
        super(source.readString());
    }

@@ -45,17 +45,17 @@ public final class ForegroundServiceTypeNotAllowedException
        dest.writeString(getMessage());
    }

    public static final @NonNull Creator<android.app.ForegroundServiceTypeNotAllowedException>
            CREATOR = new Creator<android.app.ForegroundServiceTypeNotAllowedException>() {
    public static final @NonNull Creator<android.app.InvalidForegroundServiceTypeException>
            CREATOR = new Creator<android.app.InvalidForegroundServiceTypeException>() {
                @NonNull
                public android.app.ForegroundServiceTypeNotAllowedException createFromParcel(
                public android.app.InvalidForegroundServiceTypeException createFromParcel(
                        Parcel source) {
                    return new android.app.ForegroundServiceTypeNotAllowedException(source);
                    return new android.app.InvalidForegroundServiceTypeException(source);
                }

                @NonNull
                public android.app.ForegroundServiceTypeNotAllowedException[] newArray(int size) {
                    return new android.app.ForegroundServiceTypeNotAllowedException[size];
                public android.app.InvalidForegroundServiceTypeException[] newArray(int size) {
                    return new android.app.InvalidForegroundServiceTypeException[size];
                }
            };
}
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * Exception thrown when an app tries to start a foreground {@link Service} without a type.
 */
public final class MissingForegroundServiceTypeException
        extends ForegroundServiceTypeException implements Parcelable {
    /**
     * Constructor.
     */
    public MissingForegroundServiceTypeException(@NonNull String message) {
        super(message);
    }

    MissingForegroundServiceTypeException(@NonNull Parcel source) {
        super(source.readString());
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(getMessage());
    }

    public static final @NonNull Creator<android.app.MissingForegroundServiceTypeException>
            CREATOR = new Creator<android.app.MissingForegroundServiceTypeException>() {
                @NonNull
                public android.app.MissingForegroundServiceTypeException createFromParcel(
                        Parcel source) {
                    return new android.app.MissingForegroundServiceTypeException(source);
                }

                @NonNull
                public android.app.MissingForegroundServiceTypeException[] newArray(int size) {
                    return new android.app.MissingForegroundServiceTypeException[size];
                }
            };
}
Loading