This commit is contained in:
2020-08-26 19:56:45 +08:00
parent 7ff6b2ec35
commit 3ece010fc1
208 changed files with 14753 additions and 637 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3a965b0d8627041048c5be1d402b87fa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e8f62fc56ae664591a73ace40b595fbc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6b6d7834d901044f6a74e2b05c400288
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 46dcf25d2a03849d4a9ae740954185f7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8fa46280710da41ae84c4cc5c499f838
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
/*
**
** Copyright 2007, 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.content.pm;
/**
* API for package data change related callbacks from the Package Manager.
* Some usage scenarios include deletion of cache directory, generate
* statistics related to code, data, cache usage(TODO)
* {@hide}
*/
oneway interface IPackageDataObserver {
void onRemoveCompleted(in String packageName, boolean succeeded);
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ce6c657eddf84474d832f73ca7f316d3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
/*
**
** Copyright 2007, 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.content.pm;
import android.content.pm.PackageStats;
/**
* API for package data change related callbacks from the Package Manager.
* Some usage scenarios include deletion of cache directory, generate
* statistics related to code, data, cache usage(TODO)
* {@hide}
*/
oneway interface IPackageStatsObserver {
void onGetStatsCompleted(in PackageStats pStats, boolean succeeded);
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9f06640819cc148519af7afd7dbf0bd6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
/* //device/java/android/android/view/WindowManager.aidl
**
** Copyright 2007, 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.content.pm;
parcelable PackageStats;

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: afd008f2b81e345d79a53b81a9717b37
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 87a290543623a46c6aff6135e41f463f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
/* //device/java/android/android/content/Intent.aidl
**
** Copyright 2007, 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.telephony;
parcelable NeighboringCellInfo;

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a60804883286546169ba84d213cabda9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ef46d13c40a61435cb1e22efcc048fbb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: daacac906364e4ad685966e068b761f6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c1c9f534efb0428b96e21e5cace49f6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22f10847859b8450c976ba08cacffaad
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,261 @@
/*
* Copyright (C) 2007 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.internal.telephony;
import android.os.Bundle;
import java.util.List;
import android.telephony.NeighboringCellInfo;
/**
* Interface used to interact with the phone. Mostly this is used by the
* TelephonyManager class. A few places are still using this directly.
* Please clean them up if possible and use TelephonyManager insteadl.
*
* {@hide}
*/
interface ITelephony {
/**
* Dial a number. This doesn't place the call. It displays
* the Dialer screen.
* @param number the number to be dialed. If null, this
* would display the Dialer screen with no number pre-filled.
*/
void dial(String number);
/**
* Place a call to the specified number.
* @param number the number to be called.
*/
void call(String number);
/**
* If there is currently a call in progress, show the call screen.
* The DTMF dialpad may or may not be visible initially, depending on
* whether it was up when the user last exited the InCallScreen.
*
* @return true if the call screen was shown.
*/
boolean showCallScreen();
/**
* Variation of showCallScreen() that also specifies whether the
* DTMF dialpad should be initially visible when the InCallScreen
* comes up.
*
* @param showDialpad if true, make the dialpad visible initially,
* otherwise hide the dialpad initially.
* @return true if the call screen was shown.
*
* @see showCallScreen
*/
boolean showCallScreenWithDialpad(boolean showDialpad);
/**
* End call or go to the Home screen
*
* @return whether it hung up
*/
boolean endCall();
/**
* Answer the currently-ringing call.
*
* If there's already a current active call, that call will be
* automatically put on hold. If both lines are currently in use, the
* current active call will be ended.
*
* TODO: provide a flag to let the caller specify what policy to use
* if both lines are in use. (The current behavior is hardwired to
* "answer incoming, end ongoing", which is how the CALL button
* is specced to behave.)
*
* TODO: this should be a oneway call (especially since it's called
* directly from the key queue thread).
*/
void answerRingingCall();
/**
* Silence the ringer if an incoming call is currently ringing.
* (If vibrating, stop the vibrator also.)
*
* It's safe to call this if the ringer has already been silenced, or
* even if there's no incoming call. (If so, this method will do nothing.)
*
* TODO: this should be a oneway call too (see above).
* (Actually *all* the methods here that return void can
* probably be oneway.)
*/
void silenceRinger();
/**
* Check if we are in either an active or holding call
* @return true if the phone state is OFFHOOK.
*/
boolean isOffhook();
/**
* Check if an incoming phone call is ringing or call waiting.
* @return true if the phone state is RINGING.
*/
boolean isRinging();
/**
* Check if the phone is idle.
* @return true if the phone state is IDLE.
*/
boolean isIdle();
/**
* Check to see if the radio is on or not.
* @return returns true if the radio is on.
*/
boolean isRadioOn();
/**
* Check if the SIM pin lock is enabled.
* @return true if the SIM pin lock is enabled.
*/
boolean isSimPinEnabled();
/**
* Cancels the missed calls notification.
*/
void cancelMissedCallsNotification();
/**
* Supply a pin to unlock the SIM. Blocks until a result is determined.
* @param pin The pin to check.
* @return whether the operation was a success.
*/
boolean supplyPin(String pin);
/**
* Handles PIN MMI commands (PIN/PIN2/PUK/PUK2), which are initiated
* without SEND (so <code>dial</code> is not appropriate).
*
* @param dialString the MMI command to be executed.
* @return true if MMI command is executed.
*/
boolean handlePinMmi(String dialString);
/**
* Toggles the radio on or off.
*/
void toggleRadioOnOff();
/**
* Set the radio to on or off
*/
boolean setRadio(boolean turnOn);
/**
* Request to update location information in service state
*/
void updateServiceLocation();
/**
* Enable location update notifications.
*/
void enableLocationUpdates();
/**
* Disable location update notifications.
*/
void disableLocationUpdates();
/**
* Enable a specific APN type.
*/
int enableApnType(String type);
/**
* Disable a specific APN type.
*/
int disableApnType(String type);
/**
* Allow mobile data connections.
*/
boolean enableDataConnectivity();
/**
* Disallow mobile data connections.
*/
boolean disableDataConnectivity();
/**
* Report whether data connectivity is possible.
*/
boolean isDataConnectivityPossible();
Bundle getCellLocation();
/**
* Returns the neighboring cell information of the device.
*/
List<NeighboringCellInfo> getNeighboringCellInfo();
int getCallState();
int getDataActivity();
int getDataState();
/**
* Returns the current active phone type as integer.
* Returns TelephonyManager.PHONE_TYPE_CDMA if RILConstants.CDMA_PHONE
* and TelephonyManager.PHONE_TYPE_GSM if RILConstants.GSM_PHONE
*/
int getActivePhoneType();
/**
* Returns the CDMA ERI icon index to display
*/
int getCdmaEriIconIndex();
/**
* Returns the CDMA ERI icon mode,
* 0 - ON
* 1 - FLASHING
*/
int getCdmaEriIconMode();
/**
* Returns the CDMA ERI text,
*/
String getCdmaEriText();
/**
* Returns true if CDMA provisioning needs to run.
*/
boolean getCdmaNeedsProvisioning();
/**
* Returns the unread count of voicemails
*/
int getVoiceMessageCount();
/**
* Returns the network type
*/
int getNetworkType();
/**
* Return true if an ICC card is present
*/
boolean hasIccCard();
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 565db95d956c14d8d9ff4fb1e5f152bf
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a3932aff55cb540b793c2bdb7565d2ac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5bdc81fc52c0a4a6a9b18de546826625
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dfd2e3e30deb14145b8e32d47bc36cf9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 584755be53a974f1a8337092c5215bd9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,125 @@
/*
* This file is auto-generated. DO NOT MODIFY.
*/
package android.content.pm;
/**
* API for package data change related callbacks from the Package Manager.
* Some usage scenarios include deletion of cache directory, generate
* statistics related to code, data, cache usage(TODO)
* {@hide}
*/
public interface IPackageDataObserver extends android.os.IInterface
{
/** Default implementation for IPackageDataObserver. */
public static class Default implements android.content.pm.IPackageDataObserver
{
@Override public void onRemoveCompleted(java.lang.String packageName, boolean succeeded) throws android.os.RemoteException
{
}
@Override
public android.os.IBinder asBinder() {
return null;
}
}
/** Local-side IPC implementation stub class. */
public static abstract class Stub extends android.os.Binder implements android.content.pm.IPackageDataObserver
{
private static final java.lang.String DESCRIPTOR = "android.content.pm.IPackageDataObserver";
/** Construct the stub at attach it to the interface. */
public Stub()
{
this.attachInterface(this, DESCRIPTOR);
}
/**
* Cast an IBinder object into an android.content.pm.IPackageDataObserver interface,
* generating a proxy if needed.
*/
public static android.content.pm.IPackageDataObserver asInterface(android.os.IBinder obj)
{
if ((obj==null)) {
return null;
}
android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
if (((iin!=null)&&(iin instanceof android.content.pm.IPackageDataObserver))) {
return ((android.content.pm.IPackageDataObserver)iin);
}
return new android.content.pm.IPackageDataObserver.Stub.Proxy(obj);
}
@Override public android.os.IBinder asBinder()
{
return this;
}
@Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
{
java.lang.String descriptor = DESCRIPTOR;
switch (code)
{
case INTERFACE_TRANSACTION:
{
reply.writeString(descriptor);
return true;
}
case TRANSACTION_onRemoveCompleted:
{
data.enforceInterface(descriptor);
java.lang.String _arg0;
_arg0 = data.readString();
boolean _arg1;
_arg1 = (0!=data.readInt());
this.onRemoveCompleted(_arg0, _arg1);
return true;
}
default:
{
return super.onTransact(code, data, reply, flags);
}
}
}
private static class Proxy implements android.content.pm.IPackageDataObserver
{
private android.os.IBinder mRemote;
Proxy(android.os.IBinder remote)
{
mRemote = remote;
}
@Override public android.os.IBinder asBinder()
{
return mRemote;
}
public java.lang.String getInterfaceDescriptor()
{
return DESCRIPTOR;
}
@Override public void onRemoveCompleted(java.lang.String packageName, boolean succeeded) throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain();
try {
_data.writeInterfaceToken(DESCRIPTOR);
_data.writeString(packageName);
_data.writeInt(((succeeded)?(1):(0)));
boolean _status = mRemote.transact(Stub.TRANSACTION_onRemoveCompleted, _data, null, android.os.IBinder.FLAG_ONEWAY);
if (!_status && getDefaultImpl() != null) {
getDefaultImpl().onRemoveCompleted(packageName, succeeded);
return;
}
}
finally {
_data.recycle();
}
}
public static android.content.pm.IPackageDataObserver sDefaultImpl;
}
static final int TRANSACTION_onRemoveCompleted = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
public static boolean setDefaultImpl(android.content.pm.IPackageDataObserver impl) {
if (Stub.Proxy.sDefaultImpl == null && impl != null) {
Stub.Proxy.sDefaultImpl = impl;
return true;
}
return false;
}
public static android.content.pm.IPackageDataObserver getDefaultImpl() {
return Stub.Proxy.sDefaultImpl;
}
}
public void onRemoveCompleted(java.lang.String packageName, boolean succeeded) throws android.os.RemoteException;
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 5fc4afade24d14ad3aef4d41ef868e9a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,136 @@
/*
* This file is auto-generated. DO NOT MODIFY.
*/
package android.content.pm;
/**
* API for package data change related callbacks from the Package Manager.
* Some usage scenarios include deletion of cache directory, generate
* statistics related to code, data, cache usage(TODO)
* {@hide}
*/
public interface IPackageStatsObserver extends android.os.IInterface
{
/** Default implementation for IPackageStatsObserver. */
public static class Default implements android.content.pm.IPackageStatsObserver
{
@Override public void onGetStatsCompleted(android.content.pm.PackageStats pStats, boolean succeeded) throws android.os.RemoteException
{
}
@Override
public android.os.IBinder asBinder() {
return null;
}
}
/** Local-side IPC implementation stub class. */
public static abstract class Stub extends android.os.Binder implements android.content.pm.IPackageStatsObserver
{
private static final java.lang.String DESCRIPTOR = "android.content.pm.IPackageStatsObserver";
/** Construct the stub at attach it to the interface. */
public Stub()
{
this.attachInterface(this, DESCRIPTOR);
}
/**
* Cast an IBinder object into an android.content.pm.IPackageStatsObserver interface,
* generating a proxy if needed.
*/
public static android.content.pm.IPackageStatsObserver asInterface(android.os.IBinder obj)
{
if ((obj==null)) {
return null;
}
android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
if (((iin!=null)&&(iin instanceof android.content.pm.IPackageStatsObserver))) {
return ((android.content.pm.IPackageStatsObserver)iin);
}
return new android.content.pm.IPackageStatsObserver.Stub.Proxy(obj);
}
@Override public android.os.IBinder asBinder()
{
return this;
}
@Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
{
java.lang.String descriptor = DESCRIPTOR;
switch (code)
{
case INTERFACE_TRANSACTION:
{
reply.writeString(descriptor);
return true;
}
case TRANSACTION_onGetStatsCompleted:
{
data.enforceInterface(descriptor);
android.content.pm.PackageStats _arg0;
if ((0!=data.readInt())) {
_arg0 = android.content.pm.PackageStats.CREATOR.createFromParcel(data);
}
else {
_arg0 = null;
}
boolean _arg1;
_arg1 = (0!=data.readInt());
this.onGetStatsCompleted(_arg0, _arg1);
return true;
}
default:
{
return super.onTransact(code, data, reply, flags);
}
}
}
private static class Proxy implements android.content.pm.IPackageStatsObserver
{
private android.os.IBinder mRemote;
Proxy(android.os.IBinder remote)
{
mRemote = remote;
}
@Override public android.os.IBinder asBinder()
{
return mRemote;
}
public java.lang.String getInterfaceDescriptor()
{
return DESCRIPTOR;
}
@Override public void onGetStatsCompleted(android.content.pm.PackageStats pStats, boolean succeeded) throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain();
try {
_data.writeInterfaceToken(DESCRIPTOR);
if ((pStats!=null)) {
_data.writeInt(1);
pStats.writeToParcel(_data, 0);
}
else {
_data.writeInt(0);
}
_data.writeInt(((succeeded)?(1):(0)));
boolean _status = mRemote.transact(Stub.TRANSACTION_onGetStatsCompleted, _data, null, android.os.IBinder.FLAG_ONEWAY);
if (!_status && getDefaultImpl() != null) {
getDefaultImpl().onGetStatsCompleted(pStats, succeeded);
return;
}
}
finally {
_data.recycle();
}
}
public static android.content.pm.IPackageStatsObserver sDefaultImpl;
}
static final int TRANSACTION_onGetStatsCompleted = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
public static boolean setDefaultImpl(android.content.pm.IPackageStatsObserver impl) {
if (Stub.Proxy.sDefaultImpl == null && impl != null) {
Stub.Proxy.sDefaultImpl = impl;
return true;
}
return false;
}
public static android.content.pm.IPackageStatsObserver getDefaultImpl() {
return Stub.Proxy.sDefaultImpl;
}
}
public void onGetStatsCompleted(android.content.pm.PackageStats pStats, boolean succeeded) throws android.os.RemoteException;
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 17f9ec184c3b940af9a0bd7f9d1c5ee7
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 12d49a1a05449429383d2dd5bc950c04
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7012fb3bf42f245888666fd9bab52d30
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35150b0c6e306492abe809096346b87d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 04bd79513d9de4ae98802c0b9d943128
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d297c8da4cb394f029003c9507059f2c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: e36108243301b48b2b87f2aec0353457
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d0aa4a454694c436ab2eee05fb2121bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 11c893940831146979c7e7598efdb32f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8bf198c8bbb1346a89fe2d9429fdef63
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3d4c11bdd31bb45a2b28d13a49d734a4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
package com.coolape.tianrun;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.util.Log;
public class CLOutgoingCallListener extends BroadcastReceiver {
String TAG = "unity";
static Boolean isOutgoingCall = false;
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
Log.d(TAG, "开始拨号,但并不知道是否接通电话");
if (U3dPlugin.isNeedRecordOutCall) {
isOutgoingCall = true;
U3dPlugin.onBegainOutgoingCall();
}
} else if (intent.getAction().equals(
TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
TelephonyManager telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);// 注册监听器
if (telephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
if (U3dPlugin.isNeedRecordOutCall && isOutgoingCall) {
U3dPlugin.onEndgoingCall();
isOutgoingCall = false;
}
Log.d(TAG, "挂电话");
}
}
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 7c47c9be3131645a7b1255d79145cd79
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,149 @@
package com.coolape.tianrun;
import java.util.Calendar;
import com.android.internal.telephony.ITelephony;
import com.newland.PhoneUtils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Message;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
/**
*
* @author JD 功能:打电话,录音,通话时间
*
*/
public class CLTeleInterface {
private String TAG = "TeleInterface";
private Context activity;
// private Handler handler;
private Calendar calendar;
private String teleStartTime;
private String teleEndTime;
private TelephonyManager telephonyManager;
public static int TELE_START_TIME = 5;
public static int TELE_END_TIME = 6;
public String getTeleStartTime() {
return teleStartTime;
}
public String getTeleEndTime() {
return teleEndTime;
}
public PhoneListener listener;
/**
* 构造函数
*
* @param activity
* @param handler
* 自定义handler接收消息 msg.what 5:电话拨通时间 6:电话挂断时间
*/
// public TeleInterface(Context activity, Handler handler) {
public CLTeleInterface(Context activity) {
this.activity = activity;
// this.handler = handler;
}
/**
* 拨打电话
*
* @param phoneNum
* 需要拨打号码
*/
public void Call(String phoneNum) {
if (phoneNum.length() != 0) {
Intent phoneIntent = new Intent("android.intent.action.CALL",
Uri.parse("tel:" + phoneNum));
activity.startActivity(phoneIntent);
} else {
Toast.makeText(activity, "不能输入为空", Toast.LENGTH_LONG).show();
}
}
/**
* 来电监听注册
*/
public void teleListen() {
telephonyManager = (TelephonyManager) activity
.getSystemService(Context.TELEPHONY_SERVICE);// 注册监听器
if(listener == null) {
listener = new PhoneListener();
}
telephonyManager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);// 监听电话状态
}
/**
* 挂断电话
*
* @throws Exception
*/
public void endCall() throws Exception {
ITelephony iTelephony = PhoneUtils.getITelephony(telephonyManager);
iTelephony.endCall();// 自动挂断电话
}
private final class PhoneListener extends PhoneStateListener {
private String incomeNumber=""; // 来电号码
private boolean isComingCall = false;
// private MediaRecorder mediaRecorder;
// private File root_file, file;
@Override
public void onCallStateChanged(int state, String incomingNumber) {
try {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING: // 来电
Log.d(TAG, "来电============");
this.incomeNumber = incomingNumber;
Log.d(TAG, "incomingNumber==" + incomingNumber);
isComingCall = true;
break;
case TelephonyManager.CALL_STATE_OFFHOOK: // 接通电话
Log.d(TAG, "接通电话============");
calendar = Calendar.getInstance();
teleStartTime = calendar.getTime().toString();
Message msg_start = new Message();
msg_start.what = TELE_START_TIME;
msg_start.obj = teleStartTime;
Log.d(TAG, "StartTime=====" + teleStartTime);
if (U3dPlugin.isNeedRecordOutCall) {
// isOutgoingCall = true;
U3dPlugin.onBegainOutgoingCall();
}
break;
case TelephonyManager.CALL_STATE_IDLE: // 挂掉电话
if(isComingCall) {
U3dPlugin.onEndincomeCall(incomeNumber);
// incomeNumber = "";
isComingCall = false;
} else {
if (U3dPlugin.isNeedRecordOutCall) {
U3dPlugin.onEndgoingCall();
// isOutgoingCall = false;
}
}
Log.d(TAG, "挂掉电话===================");
break;
}
super.onCallStateChanged(state, incomingNumber);
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 41b4e79026479440ca9684104f56b83b
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,123 @@
package com.coolape.tianrun;
import android.content.Context;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnSeekCompleteListener;
import android.net.Uri;
public class MyMediaPlayer {
public static volatile MediaPlayer player = null;
static String onPrepareOrgs = "";
public void prepare(Context context, String audioSource, String orgs) {
onPrepareOrgs = orgs;
try {
Uri uri = Uri.parse(audioSource);
if (player == null) {
player = MediaPlayer.create(context, uri);
player.setLooping(false);
} else {
if (player.isPlaying()) {
stop();
}
player.reset();
if (audioSource.startsWith("http")) {
player.setDataSource(context, uri);
} else {
player.setDataSource(audioSource);
}
player.prepareAsync();
}
player.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer player) {
player.setLooping(false);
int len = player.getDuration();
U3dPlugin.UnitySendMessage("onMediaPrepared", len + "",
onPrepareOrgs);
}
});
player.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer player) {
pause();
U3dPlugin.UnitySendMessage("onMediaComplet", "true",
onPrepareOrgs);
}
});
player.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer arg0, int arg1, int arg2) {
U3dPlugin.UnitySendMessage("onMediaError", "false",
onPrepareOrgs);
return false;
}
});
player.setOnSeekCompleteListener(new OnSeekCompleteListener() {
@Override
public void onSeekComplete(MediaPlayer arg0) {
// TODO Auto-generated method stub
U3dPlugin.UnitySendMessage("onMediaSeek", "true",
onPrepareOrgs);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
public int getProgress() {
if (player != null) {
return player.getCurrentPosition();
} else {
return 0;
}
}
public void pause() {
if (player != null && player.isPlaying()){
player.pause();
}
}
public void play() {
if (player != null && !player.isPlaying()){
player.start();
}
}
public void stop() {
if (player != null)
return;
if (player.isPlaying()) {
player.stop();
}
try {
// mp.prepareAsync();
// player.prepare();
player.reset();
// player.seekTo(0);
} catch (Exception e) {
e.printStackTrace();
}
}
public void seek(int progress) {
if (player != null)
player.seekTo(progress);
}
public void destroy() {
if (player != null) {
player.stop();
player.release();
}
player = null;
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 454367b24531b47b59738a9ba52727ee
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,236 @@
package com.coolape.tianrun;
import java.io.File;
import java.util.concurrent.ExecutionException;
import org.json.JSONException;
import org.json.JSONObject;
import android.media.MediaRecorder;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.czt.mp3recorder.MP3Recorder;
import com.newland.PhoneUtils;
import com.unity3d.player.UnityPlayer;
public class U3dPlugin {
static String TAG = "U3d";
public CLTeleInterface teleInterface;
public static String u3dListener = "";
public static String recordFileName = "";
public static Boolean isNeedRecordOutCall = false;
public static Boolean isConnectedRecordOutCall = false;
public static Boolean isWaiting4IncomeCall = false;
public static CLOutgoingCallListener outgoingCallRecver = new CLOutgoingCallListener();
public static String onEndIncomeCallOrgs = "";
public static String onEndCallOrgs = "";
public static U3dPlugin self;
// static MediaRecorder mediaRecorder;
private static MP3Recorder mRecorder;
private static File file;
public static MyMediaPlayer mediaPlayer;
public static int DefaultAudioSource = -1;
public void init(String _u3dListener) {
self = this;
u3dListener = _u3dListener;
mediaPlayer = new MyMediaPlayer();
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
teleInterface = new CLTeleInterface(UnityPlayer.currentActivity);
teleInterface.teleListen();
}
});
}
public void onDestroy() {
if (mRecorder != null) {
mRecorder.stop();
mRecorder = null;
}
file = null;
}
public void waitingIncomeCall(String _onEndIncomeCallOrgs) {
onEndIncomeCallOrgs = _onEndIncomeCallOrgs;
// isWaiting4IncomeCall = true;
}
public void begainCall(String _recordFileName, String _onEndCallOrgs) {
onEndCallOrgs = _onEndCallOrgs;
recordFileName = _recordFileName;
isNeedRecordOutCall = true;
}
public static void onBegainOutgoingCall() {
if (isNeedRecordOutCall) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
recordCall(recordFileName);
}
});
}
}
public static void onEndincomeCall(String incomingPhoneNo) {
// if (isWaiting4IncomeCall) {
// isWaiting4IncomeCall = false;
UnitySendMessage("onEndincomeCall", incomingPhoneNo, onEndIncomeCallOrgs);
// }
}
public static void onEndgoingCall() {
if (isNeedRecordOutCall) {
endRecordCall();
UnitySendMessage("onEndOutGoingCall", "0", onEndCallOrgs);
recordFileName = "";
isNeedRecordOutCall = false;
isConnectedRecordOutCall = false;
}
}
public static void recordCall(String fileName) {
if (fileName == null || fileName.isEmpty())
return;
try {
file = new File(fileName);
if (!file.exists()) {
file.createNewFile();
}
if (mRecorder == null) {
mRecorder = new MP3Recorder(file);
}
mRecorder.setRecordFile(file);
// int sdkVer = PhoneUtils.getSDKVersionNumber();
if (DefaultAudioSource < 0) {
// if (sdkVer >= 23) {
// DefaultAudioSource = MediaRecorder.AudioSource.MIC;
// } else {
DefaultAudioSource = MediaRecorder.AudioSource.VOICE_CALL;
// }
}
// 获得声音数据源
mRecorder.setAudioSource(DefaultAudioSource);
mRecorder.start();
Log.d(TAG, "开始录音!");
} catch (Exception e) {
e.printStackTrace();
try {
endRecordCall();
if (mRecorder == null) {
mRecorder = new MP3Recorder(file);
}
file = new File(fileName);
if (!file.exists()) {
file.createNewFile();
}
if (mRecorder == null) {
mRecorder = new MP3Recorder(file);
}
mRecorder.setRecordFile(file);
DefaultAudioSource = MediaRecorder.AudioSource.MIC;
// int sdkVer = PhoneUtils.getSDKVersionNumber();
mRecorder.setAudioSource(DefaultAudioSource);
mRecorder.start();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
public static void endRecordCall() {
// if (mediaRecorder != null) {
// mediaRecorder.stop();
// mediaRecorder.release();
// mediaRecorder = null;
// }
try {
if (mRecorder != null) {
mRecorder.stop();
// mRecorder = null;
file = null;
Log.d(TAG, "结束录音!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
static String audioSource;
static String orgs;
public void prepareMedia(String _audioSource, String _orgs) {
audioSource = _audioSource;
orgs = _orgs;
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
mediaPlayer.prepare(UnityPlayer.currentActivity, audioSource,
orgs);
}
});
}
public void mediaPlay() {
mediaPlayer.play();
}
public void mediaStop() {
mediaPlayer.stop();
}
public void mediaPause() {
mediaPlayer.pause();
}
static int seekPosition = 0;
public void mediaSeek(int progress) {
seekPosition = progress;
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
mediaPlayer.seek(seekPosition);
}
});
}
public void mediaDestroy() {
mediaPlayer.destroy();
}
public int getMediaProgress() {
return mediaPlayer.getProgress();
}
public static void UnitySendMessage(String CallbackFunc, String retCode,
String orgs) {
if (u3dListener.isEmpty()) {
return;
}
try {
JSONObject jsonObj = new JSONObject();
jsonObj.put("code", retCode);
jsonObj.put("orgs", orgs);
UnityPlayer.UnitySendMessage(u3dListener, CallbackFunc,
jsonObj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: cab5480656f834957a7195cdc9f55ea4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9faff43252f784dd0acb3a936a2db671
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c58eb358ced9748b8913d328d4a96636
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,153 @@
package com.czt.mp3recorder;
import android.media.AudioRecord;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import com.czt.mp3recorder.util.LameUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class DataEncodeThread extends HandlerThread implements AudioRecord.OnRecordPositionUpdateListener {
private StopHandler mHandler;
private static final int PROCESS_STOP = 1;
private byte[] mMp3Buffer;
private FileOutputStream mFileOutputStream;
private static class StopHandler extends Handler {
private DataEncodeThread encodeThread;
public StopHandler(Looper looper, DataEncodeThread encodeThread) {
super(looper);
this.encodeThread = encodeThread;
}
@Override
public void handleMessage(Message msg) {
if (msg.what == PROCESS_STOP) {
//处理缓冲区中的数据
while (encodeThread.processData() > 0);
// Cancel any event left in the queue
removeCallbacksAndMessages(null);
encodeThread.flushAndRelease();
getLooper().quit();
}
}
}
/**
* Constructor
* @param file file
* @param bufferSize bufferSize
* @throws FileNotFoundException file not found
*/
public DataEncodeThread(File file, int bufferSize) throws FileNotFoundException {
super("DataEncodeThread");
this.mFileOutputStream = new FileOutputStream(file);
mMp3Buffer = new byte[(int) (7200 + (bufferSize * 2 * 1.25))];
}
@Override
public synchronized void start() {
super.start();
mHandler = new StopHandler(getLooper(), this);
}
private void check() {
if (mHandler == null) {
throw new IllegalStateException();
}
}
public void sendStopMessage() {
check();
mHandler.sendEmptyMessage(PROCESS_STOP);
}
public Handler getHandler() {
check();
return mHandler;
}
@Override
public void onMarkerReached(AudioRecord recorder) {
// Do nothing
}
@Override
public void onPeriodicNotification(AudioRecord recorder) {
processData();
}
/**
* 从缓冲区中读取并处理数据使用lame编码MP3
* @return 从缓冲区中读取的数据的长度
* 缓冲区中没有数据时返回0
*/
private int processData() {
if (mTasks.size() > 0) {
Task task = mTasks.remove(0);
short[] buffer = task.getData();
int readSize = task.getReadSize();
int encodedSize = LameUtil.encode(buffer, buffer, readSize, mMp3Buffer);
if (encodedSize > 0){
try {
mFileOutputStream.write(mMp3Buffer, 0, encodedSize);
} catch (IOException e) {
e.printStackTrace();
}
}
return readSize;
}
return 0;
}
/**
* Flush all data left in lame buffer to file
*/
private void flushAndRelease() {
//将MP3结尾信息写入buffer中
final int flushResult = LameUtil.flush(mMp3Buffer);
if (flushResult > 0) {
try {
mFileOutputStream.write(mMp3Buffer, 0, flushResult);
} catch (IOException e) {
e.printStackTrace();
}finally{
if (mFileOutputStream != null) {
try {
mFileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
LameUtil.close();
}
}
}
private List<Task> mTasks = Collections.synchronizedList(new ArrayList<Task>());
public void addTask(short[] rawData, int readSize){
mTasks.add(new Task(rawData, readSize));
}
private class Task{
private short[] rawData;
private int readSize;
public Task(short[] rawData, int readSize){
this.rawData = rawData.clone();
this.readSize = readSize;
}
public short[] getData(){
return rawData;
}
public int getReadSize(){
return readSize;
}
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 3f6f8444c067b489ab5f68e3b42557cb
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,192 @@
package com.czt.mp3recorder;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.util.Log;
import com.czt.mp3recorder.util.LameUtil;
import java.io.File;
import java.io.IOException;
public class MP3Recorder {
//=======================AudioRecord Default Settings=======================
private static int DEFAULT_AUDIO_SOURCE = MediaRecorder.AudioSource.MIC;
/**
* 以下三项为默认配置参数。Google Android文档明确表明只有以下3个参数是可以在所有设备上保证支持的。
*/
private static final int DEFAULT_SAMPLING_RATE = 44100;//模拟器仅支持从麦克风输入8kHz采样率
private static final int DEFAULT_CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_MONO;
/**
* 下面是对此的封装
* private static final int DEFAULT_AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
*/
private static final PCMFormat DEFAULT_AUDIO_FORMAT = PCMFormat.PCM_16BIT;
//======================Lame Default Settings=====================
private static final int DEFAULT_LAME_MP3_QUALITY = 7;
/**
* 与DEFAULT_CHANNEL_CONFIG相关因为是mono单声所以是1
*/
private static final int DEFAULT_LAME_IN_CHANNEL = 1;
/**
* Encoded bit rate. MP3 file will be encoded with bit rate 32kbps
*/
private static final int DEFAULT_LAME_MP3_BIT_RATE = 32;
//==================================================================
/**
* 自定义 每160帧作为一个周期通知一下需要进行编码
*/
private static final int FRAME_COUNT = 160;
private AudioRecord mAudioRecord = null;
private int mBufferSize;
private short[] mPCMBuffer;
private DataEncodeThread mEncodeThread;
private boolean mIsRecording = false;
private File mRecordFile;
/**
* Default constructor. Setup recorder with default sampling rate 1 channel,
* 16 bits pcm
* @param recordFile target file
*/
public MP3Recorder(File recordFile) {
mRecordFile = recordFile;
}
public void setRecordFile(File recordFile) {
mRecordFile = recordFile;
}
public void setAudioSource(int audioSource) {
DEFAULT_AUDIO_SOURCE = audioSource;
}
/**
* Start recording. Create an encoding thread. Start record from this
* thread.
*
* @throws IOException initAudioRecorder throws
*/
public void start() throws IOException {
if (mIsRecording) {
return;
}
mIsRecording = true; // 提早防止init或startRecording被多次调用
initAudioRecorder();
mAudioRecord.startRecording();
new Thread() {
@Override
public void run() {
//设置线程权限
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
while (mIsRecording) {
int readSize = mAudioRecord.read(mPCMBuffer, 0, mBufferSize);
if (readSize > 0) {
mEncodeThread.addTask(mPCMBuffer, readSize);
calculateRealVolume(mPCMBuffer, readSize);
}
}
// release and finalize audioRecord
mAudioRecord.stop();
mAudioRecord.release();
mAudioRecord = null;
// stop the encoding thread and try to wait
// until the thread finishes its job
mEncodeThread.sendStopMessage();
}
/**
* 此计算方法来自samsung开发范例
*
* @param buffer buffer
* @param readSize readSize
*/
private void calculateRealVolume(short[] buffer, int readSize) {
double sum = 0;
for (int i = 0; i < readSize; i++) {
// 这里没有做运算的优化,为了更加清晰的展示代码
sum += buffer[i] * buffer[i];
}
if (readSize > 0) {
double amplitude = sum / readSize;
mVolume = (int) Math.sqrt(amplitude);
}
}
}.start();
}
private int mVolume;
/**
* 获取真实的音量。 [算法来自三星]
* @return 真实音量
*/
public int getRealVolume() {
return mVolume;
}
/**
* 获取相对音量。 超过最大值时取最大值。
* @return 音量
*/
public int getVolume(){
if (mVolume >= MAX_VOLUME) {
return MAX_VOLUME;
}
return mVolume;
}
private static final int MAX_VOLUME = 2000;
/**
* 根据资料假定的最大值。 实测时有时超过此值。
* @return 最大音量值。
*/
public int getMaxVolume(){
return MAX_VOLUME;
}
public void stop(){
mIsRecording = false;
}
public boolean isRecording() {
return mIsRecording;
}
/**
* Initialize audio recorder
*/
private void initAudioRecorder() throws IOException {
mBufferSize = AudioRecord.getMinBufferSize(DEFAULT_SAMPLING_RATE,
DEFAULT_CHANNEL_CONFIG, DEFAULT_AUDIO_FORMAT.getAudioFormat());
int bytesPerFrame = DEFAULT_AUDIO_FORMAT.getBytesPerFrame();
/* Get number of samples. Calculate the buffer size
* (round up to the factor of given frame size)
* 使能被整除,方便下面的周期性通知
* */
int frameSize = mBufferSize / bytesPerFrame;
if (frameSize % FRAME_COUNT != 0) {
frameSize += (FRAME_COUNT - frameSize % FRAME_COUNT);
mBufferSize = frameSize * bytesPerFrame;
}
/* Setup audio recorder */
mAudioRecord = new AudioRecord(DEFAULT_AUDIO_SOURCE,
DEFAULT_SAMPLING_RATE, DEFAULT_CHANNEL_CONFIG, DEFAULT_AUDIO_FORMAT.getAudioFormat(),
mBufferSize);
mPCMBuffer = new short[mBufferSize];
/*
* Initialize lame buffer
* mp3 sampling rate is the same as the recorded pcm sampling rate
* The bit rate is 32kbps
*
*/
LameUtil.init(DEFAULT_SAMPLING_RATE, DEFAULT_LAME_IN_CHANNEL, DEFAULT_SAMPLING_RATE, DEFAULT_LAME_MP3_BIT_RATE, DEFAULT_LAME_MP3_QUALITY);
// Create and run thread used to encode data
// The thread will
mEncodeThread = new DataEncodeThread(mRecordFile, mBufferSize);
mEncodeThread.start();
mAudioRecord.setRecordPositionUpdateListener(mEncodeThread, mEncodeThread.getHandler());
mAudioRecord.setPositionNotificationPeriod(FRAME_COUNT);
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 134eee28cbbda46bd8c5032af2a8fb0a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
package com.czt.mp3recorder;
import android.media.AudioFormat;
public enum PCMFormat {
PCM_8BIT (1, AudioFormat.ENCODING_PCM_8BIT),
PCM_16BIT (2, AudioFormat.ENCODING_PCM_16BIT);
private int bytesPerFrame;
private int audioFormat;
PCMFormat(int bytesPerFrame, int audioFormat) {
this.bytesPerFrame = bytesPerFrame;
this.audioFormat = audioFormat;
}
public int getBytesPerFrame() {
return bytesPerFrame;
}
public int getAudioFormat() {
return audioFormat;
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 6cfce2307b2fa48d6ae51da8e719e1e3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5796cc6b4b0a2492da182ee538742752
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,74 @@
package com.czt.mp3recorder.util;
public class LameUtil {
static{
System.loadLibrary("mp3lame");
}
/**
* Initialize LAME.
*
* @param inSamplerate
* input sample rate in Hz.
* @param inChannel
* number of channels in input stream.
* @param outSamplerate
* output sample rate in Hz.
* @param outBitrate
* brate compression ratio in KHz.
* @param quality
* <p>quality=0..9. 0=best (very slow). 9=worst.</p>
* <p>recommended:</p>
* <p>2 near-best quality, not too slow</p>
* <p>5 good quality, fast</p>
* 7 ok quality, really fast
*/
public native static void init(int inSamplerate, int inChannel,
int outSamplerate, int outBitrate, int quality);
/**
* Encode buffer to mp3.
*
* @param bufferLeft
* PCM data for left channel.
* @param bufferRight
* PCM data for right channel.
* @param samples
* number of samples per channel.
* @param mp3buf
* result encoded MP3 stream. You must specified
* "7200 + (1.25 * buffer_l.length)" length array.
* @return <p>number of bytes output in mp3buf. Can be 0.</p>
* <p>-1: mp3buf was too small</p>
* <p>-2: malloc() problem</p>
* <p>-3: lame_init_params() not called</p>
* -4: psycho acoustic problems
*/
public native static int encode(short[] bufferLeft, short[] bufferRight,
int samples, byte[] mp3buf);
/**
* Flush LAME buffer.
*
* REQUIRED:
* lame_encode_flush will flush the intenal PCM buffers, padding with
* 0's to make sure the final frame is complete, and then flush
* the internal MP3 buffers, and thus may return a
* final few mp3 frames. 'mp3buf' should be at least 7200 bytes long
* to hold all possible emitted data.
*
* will also write id3v1 tags (if any) into the bitstream
*
* return code = number of bytes output to mp3buf. Can be 0
* @param mp3buf
* result encoded MP3 stream. You must specified at least 7200
* bytes.
* @return number of bytes output to mp3buf. Can be 0.
*/
public native static int flush(byte[] mp3buf);
/**
* Close LAME.
*/
public native static void close();
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 091a5e5f71553434695297dd6e4e2b16
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2948157a0f46743fe821133054dff30d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
package com.newland;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import com.android.internal.telephony.ITelephony;
import android.app.Service;
import android.content.Context;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.util.Log;
public class PhoneUtils {
/**
* 从TelephonyManager中实例化ITelephony并返回
*/
static public ITelephony getITelephony(TelephonyManager telMgr)
throws Exception {
Method getITelephonyMethod = telMgr.getClass().getDeclaredMethod(
"getITelephony");
getITelephonyMethod.setAccessible(true);// 私有化函数也能使用
return (ITelephony) getITelephonyMethod.invoke(telMgr);
}
public static int getSDKVersionNumber() {
int sdkVersion;
try {
sdkVersion = Integer.valueOf(android.os.Build.VERSION.SDK_INT);
} catch (NumberFormatException e) {
sdkVersion = 0;
}
return sdkVersion;
}
//判断手机是否处于正在通话中
public static boolean phoneIsInUse(Context context) {
int sdkVer = getSDKVersionNumber();
if(sdkVer >= 23) {
return phoneIsInUse6_0(context);
} else {
return phoneIsInUse5_0(context);
}
}
//Android如何判断手机是否处于正在通话中Android 6.0之前具体版本没追溯用的方法在Android 5.1上好用)
public static boolean phoneIsInUse5_0(Context context) {
boolean phoneInUse = false;
TelephonyManager mTelephonyManager = (TelephonyManager)context.getSystemService(Service.TELEPHONY_SERVICE);
Class<TelephonyManager> c = TelephonyManager.class;
Method getITelephonyMethod = null;
try {
getITelephonyMethod = c.getDeclaredMethod("getITelephony",
(Class[]) null);
getITelephonyMethod.setAccessible(true);
ITelephony iTelephony = (ITelephony) getITelephonyMethod.invoke(
mTelephonyManager, (Object[]) null);
phoneInUse = !iTelephony.isIdle();
} catch (Exception e) {
e.printStackTrace();
}
return phoneInUse;
}
//Android 6.0之后用以上方法不好用了遍寻源码及网上资料得已下方法在Android 6.0上好用):
public static boolean phoneIsInUse6_0(Context context){
TelecomManager tm = (TelecomManager)context.getSystemService(Context.TELECOM_SERVICE);
return tm.isInCall();
}
static public void printAllInform(Class clsShow) {
try {
// 取得所有方法
Method[] hideMethod = clsShow.getDeclaredMethods();
int i = 0;
for (; i < hideMethod.length; i++) {
Log.e("method name", hideMethod[i].getName());
}
// 取得所有常量
Field[] allFields = clsShow.getFields();
for (i = 0; i < allFields.length; i++) {
Log.e("Field name", allFields[i].getName());
}
} catch (SecurityException e) {
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
} catch (IllegalArgumentException e) {
// throw new RuntimeException(e.getMessage());
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: f2f1aac6d559f41b0a60fbfb671ffce2
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 245ca7d3e3aa64c04832c9f7d5de8364
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
#ifndef CallListner_h
#define CallListner_h
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCall.h>
@interface CallListner : NSObject
@property (assign, nonatomic)NSString *unityListner;
@property(nonatomic, strong) CTCallCenter* callCenter;
@end
#endif

View File

@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 03672e374aa1342ef8be44593f8ebab0
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
#import <Foundation/Foundation.h>
#import "CallListner.h"
static CallListner* _CallListner;
@implementation CallListner
+(CallListner*) instance
{
if (_CallListner != nil) {
return _CallListner;
} else {
_CallListner =(CallListner*)([[CallListner alloc] init]);
}
return _CallListner;
}
- (id)init:(NSString *)listner
{
_unityListner = listner;
[self initCallCenter];
return self;
}
- (void)initCallCenter {
bool *isComingCall = false;
_callCenter = [[CTCallCenter alloc] init];
_callCenter.callEventHandler = ^(CTCall* call) {
dispatch_async(dispatch_get_main_queue(), ^{
if ([call.callState isEqualToString:CTCallStateDisconnected]) {
// NSLog("CTCallCenter:Call has been disconnected");
NSLog(@"电话挂断");
if(isComingCall) {
[self sendUnityMessage:@"onEndincomeCall", ""]
} else {
[self sendUnityMessage:@"onEndOutGoingCall", ""]
}
} else if ([call.callState isEqualToString:CTCallStateConnected]) {
// NSLog("CTCallCenter:Callhasjustbeen connected");
NSLog(@"电话接通");
if(isComingCall) {
[self sendUnityMessage:@"onConectedComingCall", ""]
} else {
[self sendUnityMessage:@"onConectedOutGoingCall", ""]
}
} else if ([call.callState isEqualToString:CTCallStateIncoming]) {
// NSLog("CTCallCenter:Call is incoming");
NSLog(@"电话被叫");
isComingCall = true;
} else if ([call.callState isEqualToString:CTCallStateDialing]) {
// NSLog("CTCallCenter:Call is Dialing");
NSLog(@"电话主动拨打电话");
isComingCall = false;
} else {
// NSLog("CTCallCenter:Nothing is done");
NSLog(@"电话其他状态");
}
});
};
}
-(void) sendUnityMessage:(const NSString*)method with:(NSString*)msg
{
if(_unityListner != nil && msg != nil) {
UnitySendMessage([_unityListner UTF8String],
[method UTF8String], [msg UTF8String]);
}
}
@end
#if __cplusplus
extern "C" {
#endif
void _init(const char* goName);
#if __cplusplus
}
#endif
void _init(const char* goName) {
[[CallListner instance] init:[NSString stringWithUTF8String:goName]];
}

View File

@@ -0,0 +1,104 @@
fileFormatVersion: 2
guid: a9a9ea5d9e8164a519f0906e5dd1d0bd
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
CompileFlags:
FrameworkDependencies: CoreTelephony;
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant: